@rjsf/mui 6.4.2 → 6.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -0
- package/dist/index.cjs +353 -214
- package/dist/index.cjs.map +4 -4
- package/dist/mui.esm.js +354 -185
- package/dist/mui.esm.js.map +4 -4
- package/dist/mui.umd.js +293 -165
- package/lib/AddButton/AddButton.js +12 -2
- package/lib/AddButton/AddButton.js.map +1 -1
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.d.ts +22 -1
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js +3 -1
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js.map +1 -1
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.d.ts +20 -1
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js +3 -1
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js.map +1 -1
- package/lib/BaseInputTemplate/BaseInputTemplate.d.ts +17 -1
- package/lib/BaseInputTemplate/BaseInputTemplate.js +9 -4
- package/lib/BaseInputTemplate/BaseInputTemplate.js.map +1 -1
- package/lib/CheckboxWidget/CheckboxWidget.d.ts +13 -1
- package/lib/CheckboxWidget/CheckboxWidget.js +3 -1
- package/lib/CheckboxWidget/CheckboxWidget.js.map +1 -1
- package/lib/CheckboxesWidget/CheckboxesWidget.d.ts +17 -2
- package/lib/CheckboxesWidget/CheckboxesWidget.js +12 -7
- package/lib/CheckboxesWidget/CheckboxesWidget.js.map +1 -1
- package/lib/DescriptionField/DescriptionField.d.ts +10 -1
- package/lib/DescriptionField/DescriptionField.js +6 -1
- package/lib/DescriptionField/DescriptionField.js.map +1 -1
- package/lib/ErrorList/ErrorList.d.ts +29 -2
- package/lib/ErrorList/ErrorList.js +7 -4
- package/lib/ErrorList/ErrorList.js.map +1 -1
- package/lib/FieldErrorTemplate/FieldErrorTemplate.d.ts +16 -1
- package/lib/FieldErrorTemplate/FieldErrorTemplate.js +8 -4
- package/lib/FieldErrorTemplate/FieldErrorTemplate.js.map +1 -1
- package/lib/FieldHelpTemplate/FieldHelpTemplate.d.ts +10 -1
- package/lib/FieldHelpTemplate/FieldHelpTemplate.js +6 -2
- package/lib/FieldHelpTemplate/FieldHelpTemplate.js.map +1 -1
- package/lib/FieldTemplate/FieldTemplate.d.ts +13 -1
- package/lib/FieldTemplate/FieldTemplate.js +3 -1
- package/lib/FieldTemplate/FieldTemplate.js.map +1 -1
- package/lib/IconButton/IconButton.js +12 -2
- package/lib/IconButton/IconButton.js.map +1 -1
- package/lib/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.d.ts +13 -1
- package/lib/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.js +6 -2
- package/lib/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.js.map +1 -1
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.d.ts +16 -1
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js +4 -2
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js.map +1 -1
- package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.js +3 -3
- package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.js.map +1 -1
- package/lib/RadioWidget/RadioWidget.d.ts +17 -2
- package/lib/RadioWidget/RadioWidget.js +13 -9
- package/lib/RadioWidget/RadioWidget.js.map +1 -1
- package/lib/RangeWidget/RangeWidget.d.ts +10 -1
- package/lib/RangeWidget/RangeWidget.js +3 -1
- package/lib/RangeWidget/RangeWidget.js.map +1 -1
- package/lib/SelectWidget/SelectWidget.d.ts +14 -3
- package/lib/SelectWidget/SelectWidget.js +26 -19
- package/lib/SelectWidget/SelectWidget.js.map +1 -1
- package/lib/SubmitButton/SubmitButton.d.ts +13 -1
- package/lib/SubmitButton/SubmitButton.js +5 -2
- package/lib/SubmitButton/SubmitButton.js.map +1 -1
- package/lib/TitleField/TitleField.d.ts +24 -2
- package/lib/TitleField/TitleField.js +9 -4
- package/lib/TitleField/TitleField.js.map +1 -1
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.d.ts +16 -1
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js +7 -2
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/util.d.ts +9 -0
- package/lib/util.js +24 -0
- package/lib/util.js.map +1 -0
- package/package.json +7 -7
- package/src/AddButton/AddButton.tsx +21 -3
- package/src/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx +39 -9
- package/src/ArrayFieldTemplate/ArrayFieldTemplate.tsx +30 -8
- package/src/BaseInputTemplate/BaseInputTemplate.tsx +29 -5
- package/src/CheckboxWidget/CheckboxWidget.tsx +20 -2
- package/src/CheckboxesWidget/CheckboxesWidget.tsx +51 -23
- package/src/DescriptionField/DescriptionField.tsx +25 -3
- package/src/ErrorList/ErrorList.tsx +52 -15
- package/src/FieldErrorTemplate/FieldErrorTemplate.tsx +34 -8
- package/src/FieldHelpTemplate/FieldHelpTemplate.tsx +30 -3
- package/src/FieldTemplate/FieldTemplate.tsx +26 -4
- package/src/IconButton/IconButton.tsx +21 -2
- package/src/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.tsx +28 -6
- package/src/ObjectFieldTemplate/ObjectFieldTemplate.tsx +25 -5
- package/src/OptionalDataControlsTemplate/OptionalDataControlsTemplate.tsx +3 -1
- package/src/RadioWidget/RadioWidget.tsx +43 -26
- package/src/RangeWidget/RangeWidget.tsx +16 -1
- package/src/SelectWidget/SelectWidget.tsx +71 -49
- package/src/SubmitButton/SubmitButton.tsx +36 -5
- package/src/TitleField/TitleField.tsx +54 -16
- package/src/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx +39 -5
- package/src/util.ts +30 -0
package/dist/mui.umd.js
CHANGED
|
@@ -5,13 +5,34 @@
|
|
|
5
5
|
})(this, (function (exports, core, AddIcon, IconButton, utils, jsxRuntime, Box, Grid4, Paper, react, TextField, InputAdornment, Typography, ErrorIcon, List, ListItem, ListItemIcon, ListItemText, ArrowDownwardIcon, ArrowUpwardIcon, CopyIcon, RemoveIcon, ClearIcon, FormHelperText, FormControl, Button, Divider, Checkbox, FormControlLabel, FormGroup, FormLabel, Radio, RadioGroup, Slider, MenuItem) { 'use strict';
|
|
6
6
|
|
|
7
7
|
// src/MuiForm/MuiForm.tsx
|
|
8
|
+
|
|
9
|
+
// src/util.ts
|
|
10
|
+
function getMuiProps(options, propsToFilter, rjsfSlotPropsOnly) {
|
|
11
|
+
const muiProps = options?.mui || {};
|
|
12
|
+
if (propsToFilter) {
|
|
13
|
+
return Object.keys(muiProps).filter((key) => propsToFilter.includes(key)).reduce((obj, key) => {
|
|
14
|
+
obj[key] = muiProps[key];
|
|
15
|
+
return obj;
|
|
16
|
+
}, {});
|
|
17
|
+
}
|
|
18
|
+
return muiProps;
|
|
19
|
+
}
|
|
8
20
|
function AddButton({
|
|
9
21
|
uiSchema,
|
|
10
22
|
registry,
|
|
11
23
|
...props
|
|
12
24
|
}) {
|
|
13
25
|
const { translateString } = registry;
|
|
14
|
-
|
|
26
|
+
const uiOptions = utils.getUiOptions(uiSchema);
|
|
27
|
+
const muiProps = getMuiProps(uiOptions, [
|
|
28
|
+
"color",
|
|
29
|
+
"disableFocusRipple",
|
|
30
|
+
"disableRipple",
|
|
31
|
+
"edge",
|
|
32
|
+
"size",
|
|
33
|
+
"sx"
|
|
34
|
+
]);
|
|
35
|
+
return /* @__PURE__ */ jsxRuntime.jsx(IconButton, { title: translateString(utils.TranslatableString.AddItemButton), ...props, color: "primary", ...muiProps, children: /* @__PURE__ */ jsxRuntime.jsx(AddIcon, {}) });
|
|
15
36
|
}
|
|
16
37
|
function ArrayFieldItemTemplate(props) {
|
|
17
38
|
const { children, buttonsProps, hasDescription, hasToolbar, uiSchema, registry } = props;
|
|
@@ -28,9 +49,18 @@
|
|
|
28
49
|
fontWeight: "bold",
|
|
29
50
|
minWidth: 0
|
|
30
51
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
52
|
+
const { rjsfSlotProps: muiSlotProps } = getMuiProps(uiOptions);
|
|
53
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Grid4, { container: true, alignItems: "center", ...muiSlotProps?.arrayItemGridContainer, children: [
|
|
54
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
55
|
+
Grid4,
|
|
56
|
+
{
|
|
57
|
+
size: { xs: 8, sm: 9, md: 10, lg: 11, xl: 11.25 },
|
|
58
|
+
style: { overflow: "auto" },
|
|
59
|
+
...muiSlotProps?.arrayItemGridItem,
|
|
60
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Box, { mb: 2, ...muiSlotProps?.arrayItemOuterBox, children: /* @__PURE__ */ jsxRuntime.jsx(Paper, { elevation: 2, ...muiSlotProps?.arrayItemPaper, children: /* @__PURE__ */ jsxRuntime.jsx(Box, { p: 2, ...muiSlotProps?.arrayItemInnerBox, children }) }) })
|
|
61
|
+
}
|
|
62
|
+
),
|
|
63
|
+
hasToolbar && /* @__PURE__ */ jsxRuntime.jsx(Grid4, { sx: { mt: hasDescription ? -5 : -1.5 }, ...muiSlotProps?.arrayItemToolbarGrid, children: /* @__PURE__ */ jsxRuntime.jsx(ArrayFieldItemButtonsTemplate, { ...buttonsProps, style: btnStyle }) })
|
|
34
64
|
] });
|
|
35
65
|
}
|
|
36
66
|
function ArrayFieldTemplate(props) {
|
|
@@ -63,7 +93,8 @@
|
|
|
63
93
|
const {
|
|
64
94
|
ButtonTemplates: { AddButton: AddButton2 }
|
|
65
95
|
} = registry.templates;
|
|
66
|
-
|
|
96
|
+
const { rjsfSlotProps: muiSlotProps } = getMuiProps(uiOptions);
|
|
97
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Paper, { elevation: 2, ...muiSlotProps?.arrayPaper, children: /* @__PURE__ */ jsxRuntime.jsxs(Box, { p: 2, ...muiSlotProps?.arrayBox, children: [
|
|
67
98
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
68
99
|
ArrayFieldTitleTemplate,
|
|
69
100
|
{
|
|
@@ -88,7 +119,7 @@
|
|
|
88
119
|
),
|
|
89
120
|
!showOptionalDataControlInTitle ? optionalDataControl : void 0,
|
|
90
121
|
items,
|
|
91
|
-
canAdd && /* @__PURE__ */ jsxRuntime.jsx(Grid4, { container: true, justifyContent: "flex-end", children: /* @__PURE__ */ jsxRuntime.jsx(Grid4, { children: /* @__PURE__ */ jsxRuntime.jsx(Box, { mt: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
122
|
+
canAdd && /* @__PURE__ */ jsxRuntime.jsx(Grid4, { container: true, justifyContent: "flex-end", ...muiSlotProps?.arrayAddButtonGridContainer, children: /* @__PURE__ */ jsxRuntime.jsx(Grid4, { ...muiSlotProps?.arrayAddButtonGridItem, children: /* @__PURE__ */ jsxRuntime.jsx(Box, { mt: 2, ...muiSlotProps?.arrayAddButtonBox, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
92
123
|
AddButton2,
|
|
93
124
|
{
|
|
94
125
|
id: utils.buttonId(fieldPathId, "add"),
|
|
@@ -135,8 +166,11 @@
|
|
|
135
166
|
} = props;
|
|
136
167
|
const { ClearButton: ClearButton2 } = registry.templates.ButtonTemplates;
|
|
137
168
|
const { step, min, max, accept, ...rest } = utils.getInputProps(schema, type, options);
|
|
169
|
+
const muiProps = getMuiProps(options);
|
|
170
|
+
const { slotProps: muiSlotProps, ...otherMuiProps } = muiProps;
|
|
138
171
|
const htmlInputProps = {
|
|
139
172
|
...slotProps?.htmlInput,
|
|
173
|
+
...muiSlotProps?.htmlInput,
|
|
140
174
|
step,
|
|
141
175
|
min,
|
|
142
176
|
max,
|
|
@@ -146,7 +180,7 @@
|
|
|
146
180
|
const _onChange = ({ target: { value: value2 } }) => onChange(value2 === "" ? options.emptyValue : value2);
|
|
147
181
|
const _onBlur = ({ target }) => onBlur(id, target && target.value);
|
|
148
182
|
const _onFocus = ({ target }) => onFocus(id, target && target.value);
|
|
149
|
-
const DisplayInputLabelProps = TYPES_THAT_SHRINK_LABEL.includes(type) ? { ...slotProps?.inputLabel, ...InputLabelProps, shrink: true } : { ...slotProps?.inputLabel, ...InputLabelProps };
|
|
183
|
+
const DisplayInputLabelProps = TYPES_THAT_SHRINK_LABEL.includes(type) ? { ...slotProps?.inputLabel, ...muiSlotProps?.inputLabel, ...InputLabelProps, shrink: true } : { ...slotProps?.inputLabel, ...muiSlotProps?.inputLabel, ...InputLabelProps };
|
|
150
184
|
const _onClear = react.useCallback(
|
|
151
185
|
(e) => {
|
|
152
186
|
e.preventDefault();
|
|
@@ -155,7 +189,7 @@
|
|
|
155
189
|
},
|
|
156
190
|
[onChange, options.emptyValue]
|
|
157
191
|
);
|
|
158
|
-
const inputProps = { ...InputProps, ...slotProps?.input };
|
|
192
|
+
const inputProps = { ...InputProps, ...slotProps?.input, ...muiSlotProps?.input };
|
|
159
193
|
if (options.allowClearTextInputs && value && !readonly && !disabled) {
|
|
160
194
|
const clearAdornment = /* @__PURE__ */ jsxRuntime.jsx(InputAdornment, { position: "end", children: /* @__PURE__ */ jsxRuntime.jsx(ClearButton2, { registry, onClick: _onClear }) });
|
|
161
195
|
inputProps.endAdornment = !inputProps.endAdornment ? clearAdornment : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
@@ -176,6 +210,7 @@
|
|
|
176
210
|
disabled: disabled || readonly,
|
|
177
211
|
slotProps: {
|
|
178
212
|
...slotProps,
|
|
213
|
+
...muiSlotProps,
|
|
179
214
|
input: inputProps,
|
|
180
215
|
htmlInput: htmlInputProps,
|
|
181
216
|
inputLabel: DisplayInputLabelProps
|
|
@@ -186,7 +221,7 @@
|
|
|
186
221
|
onChange: onChangeOverride || _onChange,
|
|
187
222
|
onBlur: _onBlur,
|
|
188
223
|
onFocus: _onFocus,
|
|
189
|
-
...textFieldProps,
|
|
224
|
+
...{ ...otherMuiProps, ...textFieldProps },
|
|
190
225
|
"aria-describedby": utils.ariaDescribedByIds(id, !!schema.examples)
|
|
191
226
|
}
|
|
192
227
|
),
|
|
@@ -195,29 +230,44 @@
|
|
|
195
230
|
}
|
|
196
231
|
function DescriptionField(props) {
|
|
197
232
|
const { id, description, registry, uiSchema } = props;
|
|
233
|
+
const uiOptions = utils.getUiOptions(uiSchema);
|
|
234
|
+
const muiProps = getMuiProps(uiOptions);
|
|
235
|
+
const { rjsfSlotProps: muiSlotProps } = muiProps;
|
|
198
236
|
if (description) {
|
|
199
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Typography, { id, variant: "subtitle2", style: { marginTop: "5px" }, children: /* @__PURE__ */ jsxRuntime.jsx(core.RichDescription, { description, registry, uiSchema }) });
|
|
237
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Typography, { id, variant: "subtitle2", style: { marginTop: "5px" }, ...muiSlotProps?.descTypography, children: /* @__PURE__ */ jsxRuntime.jsx(core.RichDescription, { description, registry, uiSchema }) });
|
|
200
238
|
}
|
|
201
239
|
return null;
|
|
202
240
|
}
|
|
203
241
|
function ErrorList({
|
|
204
242
|
errors,
|
|
205
|
-
registry
|
|
243
|
+
registry,
|
|
244
|
+
uiSchema
|
|
206
245
|
}) {
|
|
207
246
|
const { translateString } = registry;
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
247
|
+
const uiOptions = utils.getUiOptions(uiSchema);
|
|
248
|
+
const { rjsfSlotProps: muiSlotProps } = getMuiProps(uiOptions);
|
|
249
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Paper, { elevation: 2, ...muiSlotProps?.errorPaper, children: /* @__PURE__ */ jsxRuntime.jsxs(Box, { mb: 2, p: 2, ...muiSlotProps?.errorBox, children: [
|
|
250
|
+
/* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "h6", ...muiSlotProps?.errorTypography, children: translateString(utils.TranslatableString.ErrorsLabel) }),
|
|
251
|
+
/* @__PURE__ */ jsxRuntime.jsx(List, { dense: true, ...muiSlotProps?.errorList, children: errors.map((error, i) => {
|
|
252
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ListItem, { ...muiSlotProps?.errorListItem, children: [
|
|
253
|
+
/* @__PURE__ */ jsxRuntime.jsx(ListItemIcon, { ...muiSlotProps?.errorListItemIcon, children: /* @__PURE__ */ jsxRuntime.jsx(ErrorIcon, { color: "error" }) }),
|
|
254
|
+
/* @__PURE__ */ jsxRuntime.jsx(ListItemText, { primary: error.stack, ...muiSlotProps?.errorListItemText })
|
|
214
255
|
] }, i);
|
|
215
256
|
}) })
|
|
216
257
|
] }) });
|
|
217
258
|
}
|
|
218
259
|
function MuiIconButton(props) {
|
|
219
260
|
const { icon, color, uiSchema, registry, ...otherProps } = props;
|
|
220
|
-
|
|
261
|
+
const uiOptions = utils.getUiOptions(uiSchema);
|
|
262
|
+
const muiProps = getMuiProps(uiOptions, [
|
|
263
|
+
"color",
|
|
264
|
+
"disableFocusRipple",
|
|
265
|
+
"disableRipple",
|
|
266
|
+
"edge",
|
|
267
|
+
"size",
|
|
268
|
+
"sx"
|
|
269
|
+
]);
|
|
270
|
+
return /* @__PURE__ */ jsxRuntime.jsx(IconButton, { ...muiProps, ...otherProps, size: "small", color, children: icon });
|
|
221
271
|
}
|
|
222
272
|
function CopyButton(props) {
|
|
223
273
|
const {
|
|
@@ -288,13 +338,16 @@
|
|
|
288
338
|
);
|
|
289
339
|
}
|
|
290
340
|
function FieldErrorTemplate(props) {
|
|
291
|
-
const { errors = [], fieldPathId } = props;
|
|
341
|
+
const { errors = [], fieldPathId, uiSchema } = props;
|
|
292
342
|
if (errors.length === 0) {
|
|
293
343
|
return null;
|
|
294
344
|
}
|
|
295
345
|
const id = utils.errorId(fieldPathId);
|
|
296
|
-
|
|
297
|
-
|
|
346
|
+
const uiOptions = utils.getUiOptions(uiSchema);
|
|
347
|
+
const muiProps = getMuiProps(uiOptions);
|
|
348
|
+
const { rjsfSlotProps: muiSlotProps } = muiProps;
|
|
349
|
+
return /* @__PURE__ */ jsxRuntime.jsx(List, { id, dense: true, disablePadding: true, ...muiSlotProps?.fieldErrorList, children: errors.map((error, i) => {
|
|
350
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ListItem, { disableGutters: true, ...muiSlotProps?.fieldErrorListItem, children: /* @__PURE__ */ jsxRuntime.jsx(FormHelperText, { component: "div", id: `${id}-${i}`, ...muiSlotProps?.fieldErrorFormHelperText, children: error }) }, i);
|
|
298
351
|
}) });
|
|
299
352
|
}
|
|
300
353
|
function FieldHelpTemplate(props) {
|
|
@@ -302,7 +355,19 @@
|
|
|
302
355
|
if (!help) {
|
|
303
356
|
return null;
|
|
304
357
|
}
|
|
305
|
-
|
|
358
|
+
const uiOptions = utils.getUiOptions(uiSchema);
|
|
359
|
+
const muiProps = getMuiProps(uiOptions);
|
|
360
|
+
const { rjsfSlotProps: muiSlotProps } = muiProps;
|
|
361
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
362
|
+
FormHelperText,
|
|
363
|
+
{
|
|
364
|
+
component: "div",
|
|
365
|
+
id: utils.helpId(fieldPathId),
|
|
366
|
+
style: { marginTop: "5px" },
|
|
367
|
+
...muiSlotProps?.helpFormHelperText,
|
|
368
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(core.RichHelp, { help, registry, uiSchema })
|
|
369
|
+
}
|
|
370
|
+
);
|
|
306
371
|
}
|
|
307
372
|
function FieldTemplate(props) {
|
|
308
373
|
const {
|
|
@@ -338,6 +403,7 @@
|
|
|
338
403
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "none" }, children });
|
|
339
404
|
}
|
|
340
405
|
const isCheckbox = uiOptions.widget === "checkbox";
|
|
406
|
+
const { rjsfSlotProps: muiSlotProps, ...otherMuiProps } = getMuiProps(uiOptions);
|
|
341
407
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
342
408
|
WrapIfAdditionalTemplate2,
|
|
343
409
|
{
|
|
@@ -356,12 +422,23 @@
|
|
|
356
422
|
schema,
|
|
357
423
|
uiSchema,
|
|
358
424
|
registry,
|
|
359
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
425
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
426
|
+
FormControl,
|
|
427
|
+
{
|
|
428
|
+
fullWidth: true,
|
|
429
|
+
error: rawErrors.length ? true : false,
|
|
430
|
+
required,
|
|
431
|
+
...muiSlotProps?.fieldFormControl,
|
|
432
|
+
sx: otherMuiProps.sx,
|
|
433
|
+
className: otherMuiProps.className,
|
|
434
|
+
children: [
|
|
435
|
+
children,
|
|
436
|
+
displayLabel && !isCheckbox && rawDescription ? /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "caption", color: "textSecondary", ...muiSlotProps?.fieldTypography, children: description }) : null,
|
|
437
|
+
errors,
|
|
438
|
+
help
|
|
439
|
+
]
|
|
440
|
+
}
|
|
441
|
+
)
|
|
365
442
|
}
|
|
366
443
|
);
|
|
367
444
|
}
|
|
@@ -370,9 +447,11 @@
|
|
|
370
447
|
return /* @__PURE__ */ jsxRuntime.jsx(Grid4, { container: !column, ...rest, children });
|
|
371
448
|
}
|
|
372
449
|
function MultiSchemaFieldTemplate(props) {
|
|
373
|
-
const { optionSchemaField, selector } = props;
|
|
374
|
-
|
|
375
|
-
|
|
450
|
+
const { optionSchemaField, selector, uiSchema } = props;
|
|
451
|
+
const uiOptions = utils.getUiOptions(uiSchema);
|
|
452
|
+
const { rjsfSlotProps: muiSlotProps } = getMuiProps(uiOptions);
|
|
453
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Box, { sx: { mb: 2 }, ...muiSlotProps?.multiBox, children: [
|
|
454
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormControl, { fullWidth: true, sx: { mb: 2 }, ...muiSlotProps?.multiFormControl, children: selector }),
|
|
376
455
|
optionSchemaField
|
|
377
456
|
] });
|
|
378
457
|
}
|
|
@@ -403,6 +482,7 @@
|
|
|
403
482
|
const {
|
|
404
483
|
ButtonTemplates: { AddButton: AddButton2 }
|
|
405
484
|
} = registry.templates;
|
|
485
|
+
const { rjsfSlotProps: muiSlotProps } = getMuiProps(uiOptions);
|
|
406
486
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
407
487
|
title && /* @__PURE__ */ jsxRuntime.jsx(
|
|
408
488
|
TitleFieldTemplate,
|
|
@@ -426,17 +506,17 @@
|
|
|
426
506
|
registry
|
|
427
507
|
}
|
|
428
508
|
),
|
|
429
|
-
/* @__PURE__ */ jsxRuntime.jsxs(Grid4, { container: true, spacing: 2, style: { marginTop: "10px" }, children: [
|
|
509
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Grid4, { container: true, spacing: 2, style: { marginTop: "10px" }, ...muiSlotProps?.objectGridContainer, children: [
|
|
430
510
|
!showOptionalDataControlInTitle ? optionalDataControl : void 0,
|
|
431
511
|
properties.map(
|
|
432
512
|
(element, index) => (
|
|
433
513
|
// Remove the <Grid> if the inner element is hidden as the <Grid>
|
|
434
514
|
// itself would otherwise still take up space.
|
|
435
|
-
element.hidden ? element.content : /* @__PURE__ */ jsxRuntime.jsx(Grid4, { size: { xs: 12 }, style: { marginBottom: "10px" }, children: element.content }, index)
|
|
515
|
+
element.hidden ? element.content : /* @__PURE__ */ jsxRuntime.jsx(Grid4, { size: { xs: 12 }, style: { marginBottom: "10px" }, ...muiSlotProps?.objectGridItem, children: element.content }, index)
|
|
436
516
|
)
|
|
437
517
|
)
|
|
438
518
|
] }),
|
|
439
|
-
utils.canExpand(schema, uiSchema, formData) && /* @__PURE__ */ jsxRuntime.jsx(Grid4, { container: true, justifyContent: "flex-end", children: /* @__PURE__ */ jsxRuntime.jsx(Grid4, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
519
|
+
utils.canExpand(schema, uiSchema, formData) && /* @__PURE__ */ jsxRuntime.jsx(Grid4, { container: true, justifyContent: "flex-end", ...muiSlotProps?.objectAddButtonGridContainer, children: /* @__PURE__ */ jsxRuntime.jsx(Grid4, { ...muiSlotProps?.objectAddButtonGridItem, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
440
520
|
AddButton2,
|
|
441
521
|
{
|
|
442
522
|
id: utils.buttonId(fieldPathId, "add"),
|
|
@@ -450,13 +530,14 @@
|
|
|
450
530
|
] });
|
|
451
531
|
}
|
|
452
532
|
function OptionalDataControlsTemplate(props) {
|
|
453
|
-
const { id, registry, label, onAddClick, onRemoveClick } = props;
|
|
533
|
+
const { id, registry, label, onAddClick, onRemoveClick, uiSchema } = props;
|
|
454
534
|
if (onAddClick) {
|
|
455
535
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
456
536
|
MuiIconButton,
|
|
457
537
|
{
|
|
458
538
|
id,
|
|
459
539
|
registry,
|
|
540
|
+
uiSchema,
|
|
460
541
|
className: "rjsf-add-optional-data",
|
|
461
542
|
onClick: onAddClick,
|
|
462
543
|
title: label,
|
|
@@ -469,6 +550,7 @@
|
|
|
469
550
|
{
|
|
470
551
|
id,
|
|
471
552
|
registry,
|
|
553
|
+
uiSchema,
|
|
472
554
|
className: "rjsf-remove-optional-data",
|
|
473
555
|
onClick: onRemoveClick,
|
|
474
556
|
title: label
|
|
@@ -482,23 +564,35 @@
|
|
|
482
564
|
if (norender) {
|
|
483
565
|
return null;
|
|
484
566
|
}
|
|
485
|
-
|
|
567
|
+
const uiOptions = utils.getUiOptions(uiSchema);
|
|
568
|
+
const { rjsfSlotProps: muiSlotProps, ...otherMuiProps } = getMuiProps(uiOptions);
|
|
569
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Box, { marginTop: 3, ...muiSlotProps?.submitBox, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
570
|
+
Button,
|
|
571
|
+
{
|
|
572
|
+
type: "submit",
|
|
573
|
+
variant: "contained",
|
|
574
|
+
color: "primary",
|
|
575
|
+
...submitButtonProps,
|
|
576
|
+
...otherMuiProps,
|
|
577
|
+
...muiSlotProps?.submitButton,
|
|
578
|
+
children: submitText
|
|
579
|
+
}
|
|
580
|
+
) });
|
|
486
581
|
}
|
|
487
|
-
function TitleField({
|
|
488
|
-
id,
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
let heading = /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "h5", children: title });
|
|
582
|
+
function TitleField(props) {
|
|
583
|
+
const { id, title, optionalDataControl, uiSchema } = props;
|
|
584
|
+
const uiOptions = utils.getUiOptions(uiSchema);
|
|
585
|
+
const { rjsfSlotProps: muiSlotProps } = getMuiProps(uiOptions);
|
|
586
|
+
let heading = /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "h5", ...muiSlotProps?.titleTypography, children: title });
|
|
493
587
|
if (optionalDataControl) {
|
|
494
|
-
heading = /* @__PURE__ */ jsxRuntime.jsxs(Grid4, { container: true, spacing: 0, children: [
|
|
495
|
-
/* @__PURE__ */ jsxRuntime.jsx(Grid4, { size: "grow", children: heading }),
|
|
496
|
-
/* @__PURE__ */ jsxRuntime.jsx(Grid4, { justifyContent: "flex-end", children: optionalDataControl })
|
|
588
|
+
heading = /* @__PURE__ */ jsxRuntime.jsxs(Grid4, { container: true, spacing: 0, ...muiSlotProps?.titleGridContainer, children: [
|
|
589
|
+
/* @__PURE__ */ jsxRuntime.jsx(Grid4, { size: "grow", ...muiSlotProps?.titleGridItem, children: heading }),
|
|
590
|
+
/* @__PURE__ */ jsxRuntime.jsx(Grid4, { justifyContent: "flex-end", ...muiSlotProps?.titleOptionalDataGridItem, children: optionalDataControl })
|
|
497
591
|
] });
|
|
498
592
|
}
|
|
499
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Box, { id, mb: 1, mt: 1, children: [
|
|
593
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Box, { id, mb: 1, mt: 1, ...muiSlotProps?.titleBox, children: [
|
|
500
594
|
heading,
|
|
501
|
-
/* @__PURE__ */ jsxRuntime.jsx(Divider, {})
|
|
595
|
+
/* @__PURE__ */ jsxRuntime.jsx(Divider, { ...muiSlotProps?.titleDivider })
|
|
502
596
|
] });
|
|
503
597
|
}
|
|
504
598
|
function WrapIfAdditionalTemplate(props) {
|
|
@@ -528,39 +622,56 @@
|
|
|
528
622
|
paddingRight: 6,
|
|
529
623
|
fontWeight: "bold"
|
|
530
624
|
};
|
|
625
|
+
const uiOptions = utils.getUiOptions(uiSchema);
|
|
626
|
+
const { rjsfSlotProps } = getMuiProps(uiOptions);
|
|
627
|
+
const muiSlotProps = rjsfSlotProps;
|
|
531
628
|
if (!additional) {
|
|
532
629
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames, style, children });
|
|
533
630
|
}
|
|
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
|
-
|
|
631
|
+
const { wrapGridContainer, wrapKeyGridItem, wrapChildrenGridItem, wrapRemoveButtonGridItem } = muiSlotProps || {};
|
|
632
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
633
|
+
Grid4,
|
|
634
|
+
{
|
|
635
|
+
container: true,
|
|
636
|
+
alignItems: "flex-start",
|
|
637
|
+
spacing: 2,
|
|
638
|
+
className: classNames,
|
|
639
|
+
style,
|
|
640
|
+
...wrapGridContainer,
|
|
641
|
+
children: [
|
|
642
|
+
/* @__PURE__ */ jsxRuntime.jsx(Grid4, { size: 5.5, ...wrapKeyGridItem, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
643
|
+
TextField,
|
|
644
|
+
{
|
|
645
|
+
fullWidth: true,
|
|
646
|
+
required,
|
|
647
|
+
label: displayLabel ? keyLabel : void 0,
|
|
648
|
+
defaultValue: label,
|
|
649
|
+
disabled: disabled || readonly,
|
|
650
|
+
id: `${id}-key`,
|
|
651
|
+
name: `${id}-key`,
|
|
652
|
+
onBlur: !readonly ? onKeyRenameBlur : void 0,
|
|
653
|
+
type: "text"
|
|
654
|
+
},
|
|
655
|
+
label
|
|
656
|
+
) }),
|
|
657
|
+
/* @__PURE__ */ jsxRuntime.jsx(Grid4, { size: 5.5, ...wrapChildrenGridItem, children }),
|
|
658
|
+
/* @__PURE__ */ jsxRuntime.jsx(Grid4, { sx: { mt: 1.5 }, ...wrapRemoveButtonGridItem, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
659
|
+
RemoveButton2,
|
|
660
|
+
{
|
|
661
|
+
id: utils.buttonId(id, "remove"),
|
|
662
|
+
className: "rjsf-object-property-remove",
|
|
663
|
+
iconType: "default",
|
|
664
|
+
style: btnStyle,
|
|
665
|
+
disabled: disabled || readonly,
|
|
666
|
+
onClick: onRemoveProperty,
|
|
667
|
+
uiSchema,
|
|
668
|
+
registry
|
|
669
|
+
}
|
|
670
|
+
) })
|
|
671
|
+
]
|
|
672
|
+
},
|
|
673
|
+
`${id}-key`
|
|
674
|
+
);
|
|
564
675
|
}
|
|
565
676
|
|
|
566
677
|
// src/Templates/Templates.ts
|
|
@@ -620,6 +731,7 @@
|
|
|
620
731
|
const _onBlur = () => onBlur(id, value);
|
|
621
732
|
const _onFocus = () => onFocus(id, value);
|
|
622
733
|
const description = options.description ?? schema.description;
|
|
734
|
+
const { rjsfSlotProps: muiSlotProps, ...otherMuiProps } = getMuiProps(options);
|
|
623
735
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
624
736
|
!hideLabel && description && /* @__PURE__ */ jsxRuntime.jsx(
|
|
625
737
|
DescriptionFieldTemplate,
|
|
@@ -634,6 +746,8 @@
|
|
|
634
746
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
635
747
|
FormControlLabel,
|
|
636
748
|
{
|
|
749
|
+
...otherMuiProps,
|
|
750
|
+
...muiSlotProps?.formControlLabel,
|
|
637
751
|
control: /* @__PURE__ */ jsxRuntime.jsx(
|
|
638
752
|
Checkbox,
|
|
639
753
|
{
|
|
@@ -646,7 +760,8 @@
|
|
|
646
760
|
onChange: _onChange,
|
|
647
761
|
onBlur: _onBlur,
|
|
648
762
|
onFocus: _onFocus,
|
|
649
|
-
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
763
|
+
"aria-describedby": utils.ariaDescribedByIds(id),
|
|
764
|
+
...muiSlotProps?.checkbox
|
|
650
765
|
}
|
|
651
766
|
),
|
|
652
767
|
label: utils.labelValue(label, hideLabel, false)
|
|
@@ -654,22 +769,24 @@
|
|
|
654
769
|
)
|
|
655
770
|
] });
|
|
656
771
|
}
|
|
657
|
-
function CheckboxesWidget({
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
772
|
+
function CheckboxesWidget(props) {
|
|
773
|
+
const {
|
|
774
|
+
label,
|
|
775
|
+
hideLabel,
|
|
776
|
+
id,
|
|
777
|
+
htmlName,
|
|
778
|
+
disabled,
|
|
779
|
+
options,
|
|
780
|
+
value,
|
|
781
|
+
autofocus,
|
|
782
|
+
readonly,
|
|
783
|
+
required,
|
|
784
|
+
onChange,
|
|
785
|
+
onBlur,
|
|
786
|
+
onFocus
|
|
787
|
+
} = props;
|
|
672
788
|
const { enumOptions, enumDisabled, inline, emptyValue } = options;
|
|
789
|
+
const optionValueFormat = utils.getOptionValueFormat(options);
|
|
673
790
|
const checkboxesValues = Array.isArray(value) ? value : [value];
|
|
674
791
|
const _onChange = (index) => ({ target: { checked } }) => {
|
|
675
792
|
if (checked) {
|
|
@@ -678,19 +795,21 @@
|
|
|
678
795
|
onChange(utils.enumOptionsDeselectValue(index, checkboxesValues, enumOptions));
|
|
679
796
|
}
|
|
680
797
|
};
|
|
681
|
-
const _onBlur = ({ target }) => onBlur(id, utils.
|
|
682
|
-
const _onFocus = ({ target }) => onFocus(id, utils.
|
|
798
|
+
const _onBlur = ({ target }) => onBlur(id, utils.enumOptionValueDecoder(target && target.value, enumOptions, optionValueFormat, emptyValue));
|
|
799
|
+
const _onFocus = ({ target }) => onFocus(id, utils.enumOptionValueDecoder(target && target.value, enumOptions, optionValueFormat, emptyValue));
|
|
800
|
+
const { rjsfSlotProps: muiSlotProps, ...otherMuiProps } = getMuiProps(options);
|
|
683
801
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
684
802
|
utils.labelValue(
|
|
685
803
|
/* @__PURE__ */ jsxRuntime.jsx(FormLabel, { required, htmlFor: id, children: label || void 0 }),
|
|
686
804
|
hideLabel
|
|
687
805
|
),
|
|
688
|
-
/* @__PURE__ */ jsxRuntime.jsx(FormGroup, { id, row: !!inline, children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
|
|
806
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormGroup, { ...otherMuiProps, ...muiSlotProps?.formGroup, id, row: !!inline, children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
|
|
689
807
|
const checked = utils.enumOptionsIsSelected(option.value, checkboxesValues);
|
|
690
808
|
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
691
809
|
const checkbox = /* @__PURE__ */ jsxRuntime.jsx(
|
|
692
810
|
Checkbox,
|
|
693
811
|
{
|
|
812
|
+
...muiSlotProps?.checkbox,
|
|
694
813
|
id: utils.optionId(id, index),
|
|
695
814
|
name: htmlName || id,
|
|
696
815
|
checked,
|
|
@@ -702,30 +821,28 @@
|
|
|
702
821
|
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
703
822
|
}
|
|
704
823
|
);
|
|
705
|
-
return /* @__PURE__ */
|
|
824
|
+
return /* @__PURE__ */ react.createElement(
|
|
825
|
+
FormControlLabel,
|
|
826
|
+
{
|
|
827
|
+
...muiSlotProps?.formControlLabel,
|
|
828
|
+
control: checkbox,
|
|
829
|
+
key: index,
|
|
830
|
+
label: option.label
|
|
831
|
+
}
|
|
832
|
+
);
|
|
706
833
|
}) })
|
|
707
834
|
] });
|
|
708
835
|
}
|
|
709
|
-
function RadioWidget({
|
|
710
|
-
id,
|
|
711
|
-
htmlName,
|
|
712
|
-
options,
|
|
713
|
-
value,
|
|
714
|
-
required,
|
|
715
|
-
disabled,
|
|
716
|
-
readonly,
|
|
717
|
-
label,
|
|
718
|
-
hideLabel,
|
|
719
|
-
onChange,
|
|
720
|
-
onBlur,
|
|
721
|
-
onFocus
|
|
722
|
-
}) {
|
|
836
|
+
function RadioWidget(props) {
|
|
837
|
+
const { id, htmlName, options, value, required, disabled, readonly, label, hideLabel, onChange, onBlur, onFocus } = props;
|
|
723
838
|
const { enumOptions, enumDisabled, emptyValue } = options;
|
|
724
|
-
const
|
|
725
|
-
const
|
|
726
|
-
const
|
|
839
|
+
const optionValueFormat = utils.getOptionValueFormat(options);
|
|
840
|
+
const _onChange = (_, value2) => onChange(utils.enumOptionValueDecoder(value2, enumOptions, optionValueFormat, emptyValue));
|
|
841
|
+
const _onBlur = ({ target }) => onBlur(id, utils.enumOptionValueDecoder(target && target.value, enumOptions, optionValueFormat, emptyValue));
|
|
842
|
+
const _onFocus = ({ target }) => onFocus(id, utils.enumOptionValueDecoder(target && target.value, enumOptions, optionValueFormat, emptyValue));
|
|
727
843
|
const row = options ? options.inline : false;
|
|
728
|
-
const
|
|
844
|
+
const selectValue = utils.enumOptionSelectedValue(value, enumOptions, false, optionValueFormat, "");
|
|
845
|
+
const { rjsfSlotProps: muiSlotProps, ...otherMuiProps } = getMuiProps(options);
|
|
729
846
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
730
847
|
utils.labelValue(
|
|
731
848
|
/* @__PURE__ */ jsxRuntime.jsx(FormLabel, { required, htmlFor: id, children: label || void 0 }),
|
|
@@ -734,9 +851,11 @@
|
|
|
734
851
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
735
852
|
RadioGroup,
|
|
736
853
|
{
|
|
854
|
+
...otherMuiProps,
|
|
855
|
+
...muiSlotProps?.radioGroup,
|
|
737
856
|
id,
|
|
738
857
|
name: htmlName || id,
|
|
739
|
-
value:
|
|
858
|
+
value: selectValue,
|
|
740
859
|
row,
|
|
741
860
|
onChange: _onChange,
|
|
742
861
|
onBlur: _onBlur,
|
|
@@ -744,15 +863,16 @@
|
|
|
744
863
|
"aria-describedby": utils.ariaDescribedByIds(id),
|
|
745
864
|
children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
|
|
746
865
|
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
747
|
-
const radio = /* @__PURE__ */
|
|
866
|
+
const radio = /* @__PURE__ */ react.createElement(
|
|
748
867
|
FormControlLabel,
|
|
749
868
|
{
|
|
750
|
-
|
|
869
|
+
...muiSlotProps?.formControlLabel,
|
|
870
|
+
control: /* @__PURE__ */ jsxRuntime.jsx(Radio, { ...muiSlotProps?.radio, name: htmlName || id, id: utils.optionId(id, index), color: "primary" }),
|
|
751
871
|
label: option.label,
|
|
752
|
-
value:
|
|
872
|
+
value: utils.enumOptionValueEncoder(option.value, index, optionValueFormat),
|
|
873
|
+
key: index,
|
|
753
874
|
disabled: disabled || itemDisabled || readonly
|
|
754
|
-
}
|
|
755
|
-
index
|
|
875
|
+
}
|
|
756
876
|
);
|
|
757
877
|
return radio;
|
|
758
878
|
})
|
|
@@ -768,6 +888,7 @@
|
|
|
768
888
|
};
|
|
769
889
|
const _onBlur = ({ target }) => onBlur(id, target && target.value);
|
|
770
890
|
const _onFocus = ({ target }) => onFocus(id, target && target.value);
|
|
891
|
+
const { rjsfSlotProps: muiSlotProps, ...otherMuiProps } = getMuiProps(options);
|
|
771
892
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
772
893
|
utils.labelValue(
|
|
773
894
|
/* @__PURE__ */ jsxRuntime.jsx(FormLabel, { required, htmlFor: id, children: label || void 0 }),
|
|
@@ -781,55 +902,59 @@
|
|
|
781
902
|
onBlur: _onBlur,
|
|
782
903
|
onFocus: _onFocus,
|
|
783
904
|
valueLabelDisplay: "auto",
|
|
905
|
+
...otherMuiProps,
|
|
906
|
+
...muiSlotProps?.slider,
|
|
784
907
|
...sliderProps,
|
|
785
908
|
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
786
909
|
}
|
|
787
910
|
)
|
|
788
911
|
] });
|
|
789
912
|
}
|
|
790
|
-
function SelectWidget({
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
913
|
+
function SelectWidget(props) {
|
|
914
|
+
const {
|
|
915
|
+
schema,
|
|
916
|
+
id,
|
|
917
|
+
name,
|
|
918
|
+
// remove this from textFieldProps
|
|
919
|
+
htmlName,
|
|
920
|
+
options,
|
|
921
|
+
label,
|
|
922
|
+
hideLabel,
|
|
923
|
+
required,
|
|
924
|
+
disabled,
|
|
925
|
+
placeholder,
|
|
926
|
+
readonly,
|
|
927
|
+
value,
|
|
928
|
+
multiple,
|
|
929
|
+
autofocus,
|
|
930
|
+
onChange,
|
|
931
|
+
onBlur,
|
|
932
|
+
onFocus,
|
|
933
|
+
errorSchema,
|
|
934
|
+
rawErrors = [],
|
|
935
|
+
registry,
|
|
936
|
+
uiSchema,
|
|
937
|
+
hideError,
|
|
938
|
+
...textFieldProps
|
|
939
|
+
} = props;
|
|
816
940
|
const { enumOptions, enumDisabled, emptyValue: optEmptyVal } = options;
|
|
817
|
-
|
|
818
|
-
const
|
|
819
|
-
const
|
|
820
|
-
const
|
|
821
|
-
const
|
|
822
|
-
const
|
|
823
|
-
const
|
|
941
|
+
const optionValueFormat = utils.getOptionValueFormat(options);
|
|
942
|
+
const isMultiple = typeof multiple === "undefined" ? false : !!multiple;
|
|
943
|
+
const emptyValue = isMultiple ? [] : "";
|
|
944
|
+
const isEmpty = typeof value === "undefined" || isMultiple && value.length < 1 || !isMultiple && value === emptyValue;
|
|
945
|
+
const _onChange = ({ target: { value: value2 } }) => onChange(utils.enumOptionValueDecoder(value2, enumOptions, optionValueFormat, optEmptyVal));
|
|
946
|
+
const _onBlur = ({ target }) => onBlur(id, utils.enumOptionValueDecoder(target && target.value, enumOptions, optionValueFormat, optEmptyVal));
|
|
947
|
+
const _onFocus = ({ target }) => onFocus(id, utils.enumOptionValueDecoder(target && target.value, enumOptions, optionValueFormat, optEmptyVal));
|
|
948
|
+
const { rjsfSlotProps: muiSlotProps, ...otherMuiProps } = getMuiProps(options);
|
|
824
949
|
const { InputLabelProps, SelectProps, autocomplete, ...textFieldRemainingProps } = textFieldProps;
|
|
825
|
-
const showPlaceholderOption = !
|
|
950
|
+
const showPlaceholderOption = !isMultiple && schema.default === void 0;
|
|
826
951
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
827
952
|
TextField,
|
|
828
953
|
{
|
|
829
954
|
id,
|
|
830
955
|
name: htmlName || id,
|
|
831
956
|
label: utils.labelValue(label || void 0, hideLabel, void 0),
|
|
832
|
-
value:
|
|
957
|
+
value: utils.enumOptionSelectedValue(value, enumOptions, isMultiple, optionValueFormat, emptyValue),
|
|
833
958
|
required,
|
|
834
959
|
disabled: disabled || readonly,
|
|
835
960
|
autoFocus: autofocus,
|
|
@@ -839,22 +964,25 @@
|
|
|
839
964
|
onChange: _onChange,
|
|
840
965
|
onBlur: _onBlur,
|
|
841
966
|
onFocus: _onFocus,
|
|
842
|
-
...textFieldRemainingProps,
|
|
967
|
+
...{ ...otherMuiProps, ...textFieldRemainingProps },
|
|
843
968
|
select: true,
|
|
844
|
-
|
|
845
|
-
...
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
969
|
+
slotProps: {
|
|
970
|
+
...muiSlotProps,
|
|
971
|
+
inputLabel: {
|
|
972
|
+
...muiSlotProps?.inputLabel,
|
|
973
|
+
shrink: !isEmpty
|
|
974
|
+
},
|
|
975
|
+
select: {
|
|
976
|
+
...muiSlotProps?.select,
|
|
977
|
+
multiple
|
|
978
|
+
}
|
|
851
979
|
},
|
|
852
980
|
"aria-describedby": utils.ariaDescribedByIds(id),
|
|
853
981
|
children: [
|
|
854
982
|
showPlaceholderOption && /* @__PURE__ */ jsxRuntime.jsx(MenuItem, { value: "", children: placeholder }),
|
|
855
983
|
Array.isArray(enumOptions) && enumOptions.map(({ value: value2, label: label2 }, i) => {
|
|
856
984
|
const disabled2 = Array.isArray(enumDisabled) && enumDisabled.indexOf(value2) !== -1;
|
|
857
|
-
return /* @__PURE__ */ jsxRuntime.jsx(MenuItem, { value:
|
|
985
|
+
return /* @__PURE__ */ jsxRuntime.jsx(MenuItem, { value: utils.enumOptionValueEncoder(value2, i, optionValueFormat), disabled: disabled2, children: label2 }, i);
|
|
858
986
|
})
|
|
859
987
|
]
|
|
860
988
|
}
|