@@ -7,25 +7,23 @@ import omit from 'rc-util/lib/omit';
77
88export type SegmentedValue = string | number ;
99
10- type RawOption = SegmentedValue ;
10+ type SegmentedRawOption = SegmentedValue ;
1111
12- interface LabeledOption {
12+ interface SegmentedLabeledOption {
1313 className ?: string ;
1414 disabled ?: boolean ;
1515 label : React . ReactNode ;
16- value : RawOption ;
16+ value : SegmentedRawOption ;
1717}
1818
19- type Option = RawOption | LabeledOption ;
20- 21- type Options = Option [ ] ;
19+ type SegmentedOptions = ( SegmentedRawOption | SegmentedLabeledOption ) [ ] ;
2220
2321type ExtendedHTMLInputElement = Omit < HTMLInputElement , 'value' > & {
2422 value : SegmentedValue ;
2523} ;
2624
2725export interface SegmentedProps extends React . HTMLProps < HTMLDivElement > {
28- options : Options ;
26+ options : SegmentedOptions ;
2927 defaultValue ?: SegmentedValue ;
3028 value ?: SegmentedValue ;
3129 onChange ?: ( e : React . ChangeEvent < ExtendedHTMLInputElement > ) => void ;
@@ -35,7 +33,7 @@ export interface SegmentedProps extends React.HTMLProps<HTMLDivElement> {
3533 motionName ?: string ;
3634}
3735
38- function normalizeOptions ( options : Options ) : LabeledOption [ ] {
36+ function normalizeOptions ( options : SegmentedOptions ) : SegmentedLabeledOption [ ] {
3937 return options . map ( ( option ) => {
4038 if ( typeof option === 'object' ) {
4139 return option || { } ;
@@ -52,14 +50,17 @@ const calcThumbStyle = (targetElement: HTMLElement): React.CSSProperties => ({
5250 width : targetElement . clientWidth ,
5351} ) ;
5452
55- const SegmentedOption : React . FC < {
53+ const InternalSegmentedOption : React . FC < {
5654 prefixCls : string ;
5755 className ?: string ;
5856 disabled ?: boolean ;
5957 checked : boolean ;
6058 label : React . ReactNode ;
61- value : RawOption ;
62- onChange : ( e : React . ChangeEvent < HTMLInputElement > , value : RawOption ) => void ;
59+ value : SegmentedRawOption ;
60+ onChange : (
61+ e : React . ChangeEvent < HTMLInputElement > ,
62+ value : SegmentedRawOption ,
63+ ) => void ;
6364} > = ( { prefixCls, className, disabled, checked, label, value, onChange } ) => {
6465 const handleChange = ( event : React . ChangeEvent < HTMLInputElement > ) => {
6566 if ( disabled ) {
@@ -119,7 +120,7 @@ const Segmented = React.forwardRef<HTMLDivElement, SegmentedProps>(
119120 ) ;
120121
121122 const [ visualSelected , setVisualSelected ] = React . useState <
122- RawOption | undefined
123+ SegmentedRawOption | undefined
123124 > ( selected ) ;
124125
125126 const [ thumbShow , setThumbShow ] = React . useState ( false ) ;
@@ -143,7 +144,7 @@ const Segmented = React.forwardRef<HTMLDivElement, SegmentedProps>(
143144
144145 const handleChange = (
145146 event : React . ChangeEvent < HTMLInputElement > ,
146- value : RawOption ,
147+ value : SegmentedRawOption ,
147148 ) => {
148149 if ( disabled ) {
149150 return ;
@@ -231,7 +232,7 @@ const Segmented = React.forwardRef<HTMLDivElement, SegmentedProps>(
231232 } }
232233 </ CSSMotion >
233234 { segmentedOptions . map ( ( segmentedOption ) => (
234- < SegmentedOption
235+ < InternalSegmentedOption
235236 key = { segmentedOption . value }
236237 prefixCls = { prefixCls }
237238 className = { classNames ( segmentedOption . className , {
0 commit comments