-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
/
Select.tsx
709 lines (662 loc) · 21.9 KB
/
Select.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
import * as React from 'react';
import PropTypes from 'prop-types';
import { OverrideProps, DefaultComponentProps } from '@mui/types';
import {
unstable_capitalize as capitalize,
unstable_useForkRef as useForkRef,
unstable_useControlled as useControlled,
} from '@mui/utils';
import PopperUnstyled, { PopperUnstyledProps } from '@mui/base/PopperUnstyled';
import {
useSelect,
SelectUnstyledContext,
flattenOptionGroups,
getOptionsFromChildren,
} from '@mui/base/SelectUnstyled';
import type { SelectChild, SelectOption } from '@mui/base/SelectUnstyled';
import composeClasses from '@mui/base/composeClasses';
import { StyledList } from '../List/List';
import ListProvider, { scopedVariables } from '../List/ListProvider';
import Unfold from '../internal/svg-icons/Unfold';
import { styled, useThemeProps } from '../styles';
import useSlot from '../utils/useSlot';
import { SelectOwnProps, SelectStaticProps, SelectOwnerState, SelectTypeMap } from './SelectProps';
import selectClasses, { getSelectUtilityClass } from './selectClasses';
import { ListOwnerState } from '../List';
import FormControlContext from '../FormControl/FormControlContext';
function defaultRenderSingleValue<TValue>(selectedOption: SelectOption<TValue> | null) {
return selectedOption?.label ?? '';
}
function defaultFormValueProvider<TValue>(selectedOption: SelectOption<TValue> | null) {
if (selectedOption?.value == null) {
return '';
}
if (typeof selectedOption.value === 'string' || typeof selectedOption.value === 'number') {
return selectedOption.value;
}
return JSON.stringify(selectedOption.value);
}
const useUtilityClasses = (ownerState: SelectOwnerState<any>) => {
const { color, disabled, focusVisible, size, variant, open } = ownerState;
const slots = {
root: [
'root',
disabled && 'disabled',
focusVisible && 'focusVisible',
open && 'expanded',
variant && `variant${capitalize(variant)}`,
color && `color${capitalize(color)}`,
size && `size${capitalize(size)}`,
],
button: ['button'],
startDecorator: ['startDecorator'],
endDecorator: ['endDecorator'],
indicator: ['indicator', open && 'expanded'],
listbox: [
'listbox',
open && 'expanded',
disabled && 'disabled',
variant && `variant${capitalize(variant)}`,
color && `color${capitalize(color)}`,
size && `size${capitalize(size)}`,
],
};
return composeClasses(slots, getSelectUtilityClass, {});
};
const SelectRoot = styled('div', {
name: 'JoySelect',
slot: 'Root',
overridesResolver: (props, styles) => styles.root,
})<{ ownerState: SelectStaticProps }>(({ theme, ownerState }) => {
const variantStyle = theme.variants[`${ownerState.variant!}`]?.[ownerState.color!];
return [
{
'--Select-radius': theme.vars.radius.sm,
'--Select-gap': '0.5rem',
'--Select-placeholderOpacity': 0.5,
'--Select-focusedThickness': theme.vars.focus.thickness,
'--Select-focusedHighlight':
theme.vars.palette[ownerState.color === 'neutral' ? 'primary' : ownerState.color!]?.[500],
'--Select-indicator-color': variantStyle?.backgroundColor
? variantStyle?.color
: theme.vars.palette.text.tertiary,
...(ownerState.size === 'sm' && {
'--Select-minHeight': '2rem',
'--Select-paddingInline': '0.5rem',
'--Select-decorator-childHeight': 'min(1.5rem, var(--Select-minHeight))',
'--Icon-fontSize': '1.25rem',
}),
...(ownerState.size === 'md' && {
'--Select-minHeight': '2.5rem',
'--Select-paddingInline': '0.75rem',
'--Select-decorator-childHeight': 'min(2rem, var(--Select-minHeight))',
'--Icon-fontSize': '1.5rem',
}),
...(ownerState.size === 'lg' && {
'--Select-minHeight': '3rem',
'--Select-paddingInline': '1rem',
'--Select-decorator-childHeight': 'min(2.375rem, var(--Select-minHeight))',
'--Icon-fontSize': '1.75rem',
}),
// variables for controlling child components
'--Select-decorator-childOffset':
'min(calc(var(--Select-paddingInline) - (var(--Select-minHeight) - 2 * var(--variant-borderWidth, 0px) - var(--Select-decorator-childHeight)) / 2), var(--Select-paddingInline))',
'--_Select-paddingBlock':
'max((var(--Select-minHeight) - 2 * var(--variant-borderWidth, 0px) - var(--Select-decorator-childHeight)) / 2, 0px)',
'--Select-decorator-childRadius':
'max(var(--Select-radius) - var(--_Select-paddingBlock), min(var(--_Select-paddingBlock) / 2, var(--Select-radius) / 2))',
'--Button-minHeight': 'var(--Select-decorator-childHeight)',
'--IconButton-size': 'var(--Select-decorator-childHeight)',
'--Button-radius': 'var(--Select-decorator-childRadius)',
'--IconButton-radius': 'var(--Select-decorator-childRadius)',
boxSizing: 'border-box',
minWidth: 0,
minHeight: 'var(--Select-minHeight)',
position: 'relative',
display: 'flex',
alignItems: 'center',
borderRadius: 'var(--Select-radius)',
cursor: 'pointer',
...(!variantStyle.backgroundColor && {
backgroundColor: theme.vars.palette.background.surface,
}),
...(ownerState.size && {
paddingBlock: { sm: 2, md: 3, lg: 4 }[ownerState.size], // the padding-block act as a minimum spacing between content and root element
}),
paddingInline: `var(--Select-paddingInline)`,
fontFamily: theme.vars.fontFamily.body,
fontSize: theme.vars.fontSize.md,
...(ownerState.size === 'sm' && {
fontSize: theme.vars.fontSize.sm,
}),
// TODO: discuss the transition approach in a separate PR.
transition:
'background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms',
'&:before': {
boxSizing: 'border-box',
content: '""',
display: 'block',
position: 'absolute',
pointerEvents: 'none',
top: 0,
left: 0,
right: 0,
bottom: 0,
zIndex: 1,
borderRadius: 'inherit',
margin: 'calc(var(--variant-borderWidth, 0px) * -1)', // for outlined variant
},
[`&.${selectClasses.focusVisible}`]: {
'--Select-indicator-color': 'var(--Select-focusedHighlight)',
},
[`&.${selectClasses.disabled}`]: {
'--Select-indicator-color': 'inherit',
},
...(ownerState.variant !== 'solid' && {
[`&.${selectClasses.focusVisible}`]: {
'&:before': {
boxShadow: `inset 0 0 0 var(--Select-focusedThickness) var(--Select-focusedHighlight)`,
},
},
}),
},
{
// apply global variant styles
...variantStyle,
'&:hover': theme.variants[`${ownerState.variant!}Hover`]?.[ownerState.color!],
[`&.${selectClasses.disabled}`]:
theme.variants[`${ownerState.variant!}Disabled`]?.[ownerState.color!],
},
];
});
const SelectButton = styled('button', {
name: 'JoySelect',
slot: 'Button',
overridesResolver: (props, styles) => styles.button,
})<{ ownerState: SelectOwnerState<any> }>(({ ownerState }) => ({
// reset user-agent button style
border: 0,
outline: 'none',
background: 'none',
padding: 0,
fontSize: 'inherit',
color: 'inherit',
alignSelf: 'stretch',
// make children horizontally aligned
display: 'flex',
alignItems: 'center',
flex: 1,
fontFamily: 'inherit',
cursor: 'pointer',
...((ownerState.value === null || ownerState.value === undefined) && {
opacity: 'var(--Select-placeholderOpacity)',
}),
}));
const SelectListbox = styled(StyledList, {
name: 'JoySelect',
slot: 'Listbox',
overridesResolver: (props, styles) => styles.listbox,
})<{ ownerState: SelectOwnerState<any> }>(({ theme, ownerState }) => {
const variantStyle = theme.variants[ownerState.variant!]?.[ownerState.color!];
return {
'--focus-outline-offset': `calc(${theme.vars.focus.thickness} * -1)`, // to prevent the focus outline from being cut by overflow
'--List-radius': theme.vars.radius.sm,
'--List-item-stickyBackground':
variantStyle?.backgroundColor ||
variantStyle?.background ||
theme.vars.palette.background.popup,
'--List-item-stickyTop': 'calc(var(--List-padding, var(--List-divider-gap)) * -1)', // negative amount of the List's padding block
...scopedVariables,
outline: 'none',
boxShadow: theme.shadow.md,
zIndex: 1000,
...(!variantStyle?.backgroundColor && {
backgroundColor: theme.vars.palette.background.popup,
}),
};
});
const SelectStartDecorator = styled('span', {
name: 'JoySelect',
slot: 'StartDecorator',
overridesResolver: (props, styles) => styles.startDecorator,
})<{ ownerState: SelectOwnerState<any> }>(({ theme, ownerState }) => ({
'--Button-margin': '0 0 0 calc(var(--Select-decorator-childOffset) * -1)',
'--IconButton-margin': '0 0 0 calc(var(--Select-decorator-childOffset) * -1)',
'--Icon-margin': '0 0 0 calc(var(--Select-paddingInline) / -4)',
display: 'inherit',
alignItems: 'center',
marginInlineEnd: 'var(--Select-gap)',
color: theme.vars.palette.text.tertiary,
...(ownerState.focusVisible && {
color: 'var(--Select-focusedHighlight)',
}),
}));
const SelectEndDecorator = styled('span', {
name: 'JoySelect',
slot: 'EndDecorator',
overridesResolver: (props, styles) => styles.endDecorator,
})<{ ownerState: SelectOwnerState<any> }>(({ theme, ownerState }) => {
const variantStyle = theme.variants[ownerState.variant!]?.[ownerState.color!];
return {
'--Button-margin': '0 calc(var(--Select-decorator-childOffset) * -1) 0 0',
'--IconButton-margin': '0 calc(var(--Select-decorator-childOffset) * -1) 0 0',
'--Icon-margin': '0 calc(var(--Select-paddingInline) / -4) 0 0',
display: 'inherit',
alignItems: 'center',
marginInlineStart: 'var(--Select-gap)',
color: variantStyle?.color,
};
});
const SelectIndicator = styled('span', {
name: 'JoySelect',
slot: 'Indicator',
})<{ ownerState: SelectOwnerState<any> }>(({ ownerState }) => ({
...(ownerState.size === 'sm' && {
'--Icon-fontSize': '1.125rem',
}),
...(ownerState.size === 'md' && {
'--Icon-fontSize': '1.25rem',
}),
...(ownerState.size === 'lg' && {
'--Icon-fontSize': '1.5rem',
}),
color: 'var(--Select-indicator-color)',
display: 'inherit',
alignItems: 'center',
marginInlineStart: 'var(--Select-gap)',
marginInlineEnd: 'calc(var(--Select-paddingInline) / -4)',
[`.${selectClasses.endDecorator} + &`]: {
marginInlineStart: 'calc(var(--Select-gap) / 2)',
},
}));
const Select = React.forwardRef(function Select<TValue extends {}>(
inProps: SelectOwnProps<TValue>,
ref: React.ForwardedRef<any>,
) {
const props = useThemeProps({
props: inProps,
name: 'JoySelect',
});
const {
action,
autoFocus,
children,
defaultValue,
defaultListboxOpen = false,
disabled: disabledExternalProp,
getSerializedValue = defaultFormValueProvider,
placeholder,
listboxId,
listboxOpen: listboxOpenProp,
onChange,
onListboxOpenChange,
onClose,
renderValue: renderValueProp,
value: valueProp,
size: sizeProp = 'md',
variant = 'outlined',
color: colorProp = 'neutral',
startDecorator,
endDecorator,
indicator = <Unfold />,
// props to forward to the button (all handlers should go through slotProps.button)
'aria-describedby': ariaDescribedby,
'aria-label': ariaLabel,
'aria-labelledby': ariaLabelledby,
id,
name,
...other
} = props as typeof inProps & {
// need to cast types because SelectOwnProps does not have these properties
'aria-describedby'?: string;
'aria-label'?: string;
'aria-labelledby'?: string;
id?: string;
name?: string;
};
const formControl = React.useContext(FormControlContext);
if (process.env.NODE_ENV !== 'production') {
const registerEffect = formControl?.registerEffect;
// eslint-disable-next-line react-hooks/rules-of-hooks
React.useEffect(() => {
if (registerEffect) {
return registerEffect();
}
return undefined;
}, [registerEffect]);
}
const disabledProp = inProps.disabled ?? formControl?.disabled ?? disabledExternalProp;
const size = inProps.size ?? formControl?.size ?? sizeProp;
const color = formControl?.error ? 'danger' : inProps.color ?? formControl?.color ?? colorProp;
const renderValue = renderValueProp ?? defaultRenderSingleValue;
const [anchorEl, setAnchorEl] = React.useState<HTMLElement | null>(null);
const [groupedOptions, setGroupedOptions] = React.useState<SelectChild<TValue>[]>([]);
const options = React.useMemo(() => flattenOptionGroups(groupedOptions), [groupedOptions]);
const [listboxOpen, setListboxOpen] = useControlled({
controlled: listboxOpenProp,
default: defaultListboxOpen,
name: 'SelectUnstyled',
state: 'listboxOpen',
});
const rootRef = React.useRef<HTMLElement | null>(null);
const buttonRef = React.useRef<HTMLElement | null>(null);
const listboxRef = React.useRef<HTMLElement | null>(null);
const handleRef = useForkRef(ref, rootRef);
React.useImperativeHandle(
action,
() => ({
focusVisible: () => {
buttonRef.current?.focus();
},
}),
[],
);
React.useEffect(() => {
setGroupedOptions(getOptionsFromChildren(children));
}, [children]);
React.useEffect(() => {
setAnchorEl(rootRef.current);
}, []);
React.useEffect(() => {
if (autoFocus) {
buttonRef.current!.focus();
}
}, [autoFocus]);
const handleOpenChange = (isOpen: boolean) => {
setListboxOpen(isOpen);
onListboxOpenChange?.(isOpen);
if (!isOpen) {
onClose?.();
}
};
const {
buttonActive,
buttonFocusVisible,
disabled,
getButtonProps,
getListboxProps,
getOptionProps,
getOptionState,
value,
} = useSelect({
buttonRef,
defaultValue,
disabled: disabledProp,
listboxId,
multiple: false,
onChange,
onOpenChange: handleOpenChange,
open: listboxOpen,
options,
value: valueProp,
});
const ownerState = {
...props,
active: buttonActive,
defaultListboxOpen,
disabled,
focusVisible: buttonFocusVisible,
open: listboxOpen,
renderValue,
value,
size,
variant,
color,
};
const classes = useUtilityClasses(ownerState);
const selectedOption = React.useMemo(() => {
return options.find((o) => value === o.value) ?? null;
}, [options, value]);
const [SlotRoot, rootProps] = useSlot('root', {
ref: handleRef,
className: classes.root,
elementType: SelectRoot,
externalForwardedProps: other,
getSlotProps: (handlers) => ({
onMouseDown: (event: React.MouseEvent<HTMLDivElement>) => {
if (
!listboxOpen &&
!buttonRef.current?.contains(event.target as Node) &&
!event.isPropagationStopped()
) {
// show the popup if user click outside of the button element.
// the close action is already handled by blur event.
handleOpenChange(true);
}
handlers.onMouseDown?.(event);
},
}),
ownerState,
});
const [SlotButton, buttonProps] = useSlot('button', {
additionalProps: {
'aria-describedby': ariaDescribedby ?? formControl?.['aria-describedby'],
'aria-label': ariaLabel,
'aria-labelledby': ariaLabelledby ?? formControl?.labelId,
id: id ?? formControl?.htmlFor,
name,
},
className: classes.button,
elementType: SelectButton,
externalForwardedProps: other,
getSlotProps: getButtonProps,
ownerState,
});
const [SlotListbox, listboxProps] = useSlot('listbox', {
additionalProps: {
ref: listboxRef,
anchorEl,
disablePortal: true,
open: listboxOpen,
placement: 'bottom' as const,
},
className: classes.listbox,
elementType: PopperUnstyled,
externalForwardedProps: other,
getSlotProps: getListboxProps,
ownerState: {
...ownerState,
nesting: false,
row: false,
wrap: false,
} as SelectOwnerState<any> & ListOwnerState,
internalForwardedProps: {
component: SelectListbox,
},
});
const [SlotStartDecorator, startDecoratorProps] = useSlot('startDecorator', {
className: classes.startDecorator,
elementType: SelectStartDecorator,
externalForwardedProps: other,
ownerState,
});
const [SlotEndDecorator, endDecoratorProps] = useSlot('endDecorator', {
className: classes.endDecorator,
elementType: SelectEndDecorator,
externalForwardedProps: other,
ownerState,
});
const [SlotIndicator, indicatorProps] = useSlot('indicator', {
className: classes.indicator,
elementType: SelectIndicator,
externalForwardedProps: other,
ownerState,
});
const context = React.useMemo(
() => ({
getOptionProps,
getOptionState,
listboxRef,
color,
}),
[color, getOptionProps, getOptionState],
);
const modifiers = React.useMemo<PopperUnstyledProps['modifiers']>(
() => [
{
name: 'offset',
options: {
offset: [0, 4],
},
},
{
// popper will have the same width as root element when open
name: 'equalWidth',
enabled: true,
phase: 'beforeWrite',
requires: ['computeStyles'],
fn: ({ state }) => {
state.styles.popper.width = `${state.rects.reference.width}px`;
},
},
...(listboxProps.modifiers || []),
],
[listboxProps.modifiers],
);
return (
<React.Fragment>
<SlotRoot {...rootProps}>
{startDecorator && (
<SlotStartDecorator {...startDecoratorProps}>{startDecorator}</SlotStartDecorator>
)}
<SlotButton {...buttonProps}>
{selectedOption ? renderValue(selectedOption) : placeholder}
</SlotButton>
{endDecorator && <SlotEndDecorator {...endDecoratorProps}>{endDecorator}</SlotEndDecorator>}
{indicator && <SlotIndicator {...indicatorProps}>{indicator}</SlotIndicator>}
</SlotRoot>
{anchorEl && (
// @ts-ignore internal logic: `listboxComponent` should not replace `SelectListbox`.
<SlotListbox {...listboxProps} modifiers={modifiers}>
<SelectUnstyledContext.Provider value={context}>
{/* for building grouped options */}
<ListProvider nested>{children}</ListProvider>
</SelectUnstyledContext.Provider>
</SlotListbox>
)}
{name && <input type="hidden" name={name} value={getSerializedValue(selectedOption)} />}
</React.Fragment>
);
}) as SelectComponent;
interface SelectComponent {
<TValue extends {}, C extends React.ElementType>(
props: {
/**
* The component used for the root node.
* Either a string to use a HTML element or a component.
*/
component: C;
} & OverrideProps<SelectTypeMap<TValue>, C>,
): JSX.Element | null;
<TValue extends {}>(props: DefaultComponentProps<SelectTypeMap<TValue>>): JSX.Element | null;
propTypes?: any;
}
Select.propTypes /* remove-proptypes */ = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit TypeScript types and run "yarn proptypes" |
// ----------------------------------------------------------------------
/**
* A ref for imperative actions. It currently only supports `focusVisible()` action.
*/
action: PropTypes.oneOfType([
PropTypes.func,
PropTypes.shape({
current: PropTypes.shape({
focusVisible: PropTypes.func.isRequired,
}),
}),
]),
/**
* @ignore
*/
children: PropTypes.node,
/**
* The color of the component. It supports those theme colors that make sense for this component.
* @default 'primary'
*/
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([
PropTypes.oneOf(['danger', 'info', 'neutral', 'primary', 'success', 'warning']),
PropTypes.string,
]),
/**
* The component used for the root node.
* Either a string to use a HTML element or a component.
*/
component: PropTypes.elementType,
/**
* The default selected value. Use when the component is not controlled.
*/
defaultValue: PropTypes.any,
/**
* If `true`, the component is disabled.
* @default false
*/
disabled: PropTypes.bool,
/**
* Trailing adornment for the select.
*/
endDecorator: PropTypes.node,
/**
* A function to convert the currently selected value to a string.
* Used to set a value of a hidden input associated with the select,
* so that the selected value can be posted with a form.
*/
getSerializedValue: PropTypes.func,
/**
* The indicator(*) for the select.
* ________________
* [ value * ]
* ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
*/
indicator: PropTypes.node,
/**
* Callback fired when an option is selected.
*/
onChange: PropTypes.func,
/**
* Triggered when focus leaves the menu and the menu should close.
*/
onClose: PropTypes.func,
/**
* Text to show when there is no selected value.
*/
placeholder: PropTypes.node,
/**
* Function that customizes the rendering of the selected value.
*/
renderValue: PropTypes.func,
/**
* The size of the component.
*/
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([
PropTypes.oneOf(['sm', 'md', 'lg']),
PropTypes.string,
]),
/**
* Leading adornment for the select.
*/
startDecorator: PropTypes.node,
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])),
PropTypes.func,
PropTypes.object,
]),
/**
* The selected value.
* Set to `null` to deselect all options.
*/
value: PropTypes.any,
/**
* The variant to use.
* @default 'solid'
*/
variant: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([
PropTypes.oneOf(['outlined', 'plain', 'soft', 'solid']),
PropTypes.string,
]),
} as any;
export default Select;