|
9 | 9 | StrictRJSFSchema,
|
10 | 10 | WidgetProps,
|
11 | 11 | } from '@rjsf/utils';
|
12 |
| -import { MultiSelect, Select } from '@mantine/core'; |
| 12 | +import { MultiSelect, NativeSelect } from '@mantine/core'; |
13 | 13 | import { createErrors } from '../utils/createErrors';
|
14 | 14 | import { useFieldContext } from '../templates/FieldTemplate';
|
15 | 15 |
|
@@ -83,28 +83,25 @@ function SelectWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extend
|
83 | 83 | />
|
84 | 84 | );
|
85 | 85 | } else {
|
| 86 | + const valuedData = (enumOptions || []).map(({ value, label }, i) => { |
| 87 | + const disabled = enumDisabled && enumDisabled.indexOf(value) !== -1; |
| 88 | + return { value: String(i), label, disabled }; |
| 89 | + }); |
| 90 | + const data = [{ value: '-1', label: placeholder || '' }, ...valuedData]; |
86 | 91 | return (
|
87 |
| - <Select |
88 |
| - allowDeselect |
89 |
| - checkIconPosition='right' |
90 |
| - clearable={!required} |
91 |
| - data={(enumOptions || []).map(({ value, label }, i) => { |
92 |
| - const disabled = enumDisabled && enumDisabled.indexOf(value) !== -1; |
93 |
| - return { value: String(i), label, disabled }; |
94 |
| - })} |
| 92 | + <NativeSelect |
| 93 | + data={data} |
95 | 94 | description={description}
|
96 | 95 | disabled={disabled || readonly}
|
97 | 96 | error={createErrors<T>(rawErrors, hideError)}
|
98 | 97 | label={labelValue(label, hideLabel, false)}
|
99 | 98 | autoFocus={autofocus}
|
100 | 99 | required={required}
|
101 |
| - searchable |
102 |
| - value={selectedIndices as string | null} |
103 |
| - onChange={handleChange} |
104 |
| - onDropdownClose={handleBlur} |
105 |
| - onDropdownOpen={handleFocus} |
| 100 | + value={selectedIndices ?? '-1'} |
| 101 | + onChange={(event) => handleChange(event.currentTarget.value)} |
| 102 | + onFocus={handleFocus} |
| 103 | + onBlur={handleBlur} |
106 | 104 | aria-describedby={ariaDescribedByIds<T>(id)}
|
107 |
| - placeholder={placeholder} |
108 | 105 | className='armt-widget-select armt-widget-select-single'
|
109 | 106 | />
|
110 | 107 | );
|
|
0 commit comments