@rjsf/mui 5.0.0-beta.16 → 5.0.0-beta.18
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/dist/mui.cjs.development.js +64 -60
- package/dist/mui.cjs.development.js.map +1 -1
- package/dist/mui.cjs.production.min.js +1 -1
- package/dist/mui.cjs.production.min.js.map +1 -1
- package/dist/mui.esm.js +65 -61
- package/dist/mui.esm.js.map +1 -1
- package/dist/mui.umd.development.js +64 -60
- package/dist/mui.umd.development.js.map +1 -1
- package/dist/mui.umd.production.min.js +1 -1
- package/dist/mui.umd.production.min.js.map +1 -1
- package/package.json +17 -17
|
@@ -95,11 +95,11 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
95
95
|
return target;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
var _excluded$
|
|
98
|
+
var _excluded$4 = ["uiSchema", "registry"];
|
|
99
99
|
/** The `AddButton` renders a button that represent the `Add` action on a form
|
|
100
100
|
*/
|
|
101
101
|
function AddButton(_ref) {
|
|
102
|
-
var props = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
102
|
+
var props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
103
103
|
return /*#__PURE__*/React__default["default"].createElement(IconButton__default["default"], _extends({
|
|
104
104
|
title: "Add Item"
|
|
105
105
|
}, props, {
|
|
@@ -173,7 +173,7 @@ function ArrayFieldItemTemplate(props) {
|
|
|
173
173
|
})));
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
var _excluded$
|
|
176
|
+
var _excluded$3 = ["key"];
|
|
177
177
|
/** The `ArrayFieldTemplate` component is the template used to render all items in an array.
|
|
178
178
|
*
|
|
179
179
|
* @param props - The `ArrayFieldTemplateItemType` props for the component
|
|
@@ -218,7 +218,7 @@ function ArrayFieldTemplate(props) {
|
|
|
218
218
|
key: "array-item-list-" + idSchema.$id
|
|
219
219
|
}, items && items.map(function (_ref) {
|
|
220
220
|
var key = _ref.key,
|
|
221
|
-
itemProps = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
221
|
+
itemProps = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
222
222
|
return /*#__PURE__*/React__default["default"].createElement(ArrayFieldItemTemplate, _extends({
|
|
223
223
|
key: key
|
|
224
224
|
}, itemProps));
|
|
@@ -238,7 +238,7 @@ function ArrayFieldTemplate(props) {
|
|
|
238
238
|
})))))));
|
|
239
239
|
}
|
|
240
240
|
|
|
241
|
-
var _excluded$
|
|
241
|
+
var _excluded$2 = ["id", "placeholder", "required", "readonly", "disabled", "type", "label", "value", "onChange", "onBlur", "onFocus", "autofocus", "options", "schema", "uiSchema", "rawErrors", "formContext", "registry"],
|
|
242
242
|
_excluded2$1 = ["step", "min", "max"];
|
|
243
243
|
/** The `BaseInputTemplate` is the template to use to render the basic `<input>` component for the `core` theme.
|
|
244
244
|
* It is used as the template for rendering many of the <input> based widgets that differ by `type` and callbacks only.
|
|
@@ -265,7 +265,7 @@ function BaseInputTemplate(props) {
|
|
|
265
265
|
_props$rawErrors = props.rawErrors,
|
|
266
266
|
rawErrors = _props$rawErrors === void 0 ? [] : _props$rawErrors,
|
|
267
267
|
registry = props.registry,
|
|
268
|
-
textFieldProps = _objectWithoutPropertiesLoose(props, _excluded$
|
|
268
|
+
textFieldProps = _objectWithoutPropertiesLoose(props, _excluded$2);
|
|
269
269
|
var inputProps = utils.getInputProps(schema, type, options);
|
|
270
270
|
// Now we need to pull out the step, min, max into an inner `inputProps` for material-ui
|
|
271
271
|
var step = inputProps.step,
|
|
@@ -278,7 +278,7 @@ function BaseInputTemplate(props) {
|
|
|
278
278
|
min: min,
|
|
279
279
|
max: max
|
|
280
280
|
}, schema.examples ? {
|
|
281
|
-
list:
|
|
281
|
+
list: utils.examplesId(id)
|
|
282
282
|
} : undefined)
|
|
283
283
|
}, rest);
|
|
284
284
|
var _onChange = function _onChange(_ref) {
|
|
@@ -309,8 +309,10 @@ function BaseInputTemplate(props) {
|
|
|
309
309
|
onChange: _onChange,
|
|
310
310
|
onBlur: _onBlur,
|
|
311
311
|
onFocus: _onFocus
|
|
312
|
-
}, textFieldProps
|
|
313
|
-
|
|
312
|
+
}, textFieldProps, {
|
|
313
|
+
"aria-describedby": utils.ariaDescribedByIds(id, !!schema.examples)
|
|
314
|
+
})), schema.examples && /*#__PURE__*/React__default["default"].createElement("datalist", {
|
|
315
|
+
id: utils.examplesId(id)
|
|
314
316
|
}, schema.examples.concat(schema["default"] ? [schema["default"]] : []).map(function (example) {
|
|
315
317
|
return /*#__PURE__*/React__default["default"].createElement("option", {
|
|
316
318
|
key: example,
|
|
@@ -364,12 +366,12 @@ function ErrorList(_ref) {
|
|
|
364
366
|
}))));
|
|
365
367
|
}
|
|
366
368
|
|
|
367
|
-
var _excluded = ["icon", "color", "uiSchema", "registry"],
|
|
369
|
+
var _excluded$1 = ["icon", "color", "uiSchema", "registry"],
|
|
368
370
|
_excluded2 = ["iconType"];
|
|
369
371
|
function MuiIconButton(props) {
|
|
370
372
|
var icon = props.icon,
|
|
371
373
|
color = props.color,
|
|
372
|
-
otherProps = _objectWithoutPropertiesLoose(props, _excluded);
|
|
374
|
+
otherProps = _objectWithoutPropertiesLoose(props, _excluded$1);
|
|
373
375
|
return /*#__PURE__*/React__default["default"].createElement(IconButton__default["default"], _extends({}, otherProps, {
|
|
374
376
|
size: "small",
|
|
375
377
|
color: color
|
|
@@ -417,7 +419,7 @@ function FieldErrorTemplate(props) {
|
|
|
417
419
|
if (errors.length === 0) {
|
|
418
420
|
return null;
|
|
419
421
|
}
|
|
420
|
-
var id = idSchema
|
|
422
|
+
var id = utils.errorId(idSchema);
|
|
421
423
|
return /*#__PURE__*/React__default["default"].createElement(List__default["default"], {
|
|
422
424
|
dense: true,
|
|
423
425
|
disablePadding: true
|
|
@@ -441,7 +443,7 @@ function FieldHelpTemplate(props) {
|
|
|
441
443
|
if (!help) {
|
|
442
444
|
return null;
|
|
443
445
|
}
|
|
444
|
-
var id = idSchema
|
|
446
|
+
var id = utils.helpId(idSchema);
|
|
445
447
|
return /*#__PURE__*/React__default["default"].createElement(FormHelperText__default["default"], {
|
|
446
448
|
id: id
|
|
447
449
|
}, help);
|
|
@@ -456,6 +458,7 @@ function FieldTemplate(props) {
|
|
|
456
458
|
var id = props.id,
|
|
457
459
|
children = props.children,
|
|
458
460
|
classNames = props.classNames,
|
|
461
|
+
style = props.style,
|
|
459
462
|
disabled = props.disabled,
|
|
460
463
|
displayLabel = props.displayLabel,
|
|
461
464
|
hidden = props.hidden,
|
|
@@ -483,6 +486,7 @@ function FieldTemplate(props) {
|
|
|
483
486
|
}
|
|
484
487
|
return /*#__PURE__*/React__default["default"].createElement(WrapIfAdditionalTemplate, {
|
|
485
488
|
classNames: classNames,
|
|
489
|
+
style: style,
|
|
486
490
|
disabled: disabled,
|
|
487
491
|
id: id,
|
|
488
492
|
label: label,
|
|
@@ -528,14 +532,14 @@ function ObjectFieldTemplate(props) {
|
|
|
528
532
|
// Button templates are not overridden in the uiSchema
|
|
529
533
|
var AddButton = registry.templates.ButtonTemplates.AddButton;
|
|
530
534
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, (uiOptions.title || title) && /*#__PURE__*/React__default["default"].createElement(TitleFieldTemplate, {
|
|
531
|
-
id: idSchema
|
|
535
|
+
id: utils.titleId(idSchema),
|
|
532
536
|
title: title,
|
|
533
537
|
required: required,
|
|
534
538
|
schema: schema,
|
|
535
539
|
uiSchema: uiSchema,
|
|
536
540
|
registry: registry
|
|
537
541
|
}), (uiOptions.description || description) && /*#__PURE__*/React__default["default"].createElement(DescriptionFieldTemplate, {
|
|
538
|
-
id: idSchema
|
|
542
|
+
id: utils.descriptionId(idSchema),
|
|
539
543
|
description: uiOptions.description || description,
|
|
540
544
|
schema: schema,
|
|
541
545
|
uiSchema: uiSchema,
|
|
@@ -618,6 +622,7 @@ function TitleField(_ref) {
|
|
|
618
622
|
function WrapIfAdditionalTemplate(props) {
|
|
619
623
|
var children = props.children,
|
|
620
624
|
classNames = props.classNames,
|
|
625
|
+
style = props.style,
|
|
621
626
|
disabled = props.disabled,
|
|
622
627
|
id = props.id,
|
|
623
628
|
label = props.label,
|
|
@@ -640,7 +645,8 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
640
645
|
};
|
|
641
646
|
if (!additional) {
|
|
642
647
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
643
|
-
className: classNames
|
|
648
|
+
className: classNames,
|
|
649
|
+
style: style
|
|
644
650
|
}, children);
|
|
645
651
|
}
|
|
646
652
|
var handleBlur = function handleBlur(_ref) {
|
|
@@ -652,7 +658,8 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
652
658
|
key: id + "-key",
|
|
653
659
|
alignItems: "center",
|
|
654
660
|
spacing: 2,
|
|
655
|
-
className: classNames
|
|
661
|
+
className: classNames,
|
|
662
|
+
style: style
|
|
656
663
|
}, /*#__PURE__*/React__default["default"].createElement(Grid__default["default"], {
|
|
657
664
|
item: true,
|
|
658
665
|
xs: true
|
|
@@ -746,26 +753,13 @@ function CheckboxWidget(props) {
|
|
|
746
753
|
autoFocus: autofocus,
|
|
747
754
|
onChange: _onChange,
|
|
748
755
|
onBlur: _onBlur,
|
|
749
|
-
onFocus: _onFocus
|
|
756
|
+
onFocus: _onFocus,
|
|
757
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
750
758
|
}),
|
|
751
759
|
label: label || ""
|
|
752
760
|
});
|
|
753
761
|
}
|
|
754
762
|
|
|
755
|
-
var selectValue = function selectValue(value, selected, all) {
|
|
756
|
-
var at = all.indexOf(value);
|
|
757
|
-
var updated = selected.slice(0, at).concat(value, selected.slice(at));
|
|
758
|
-
// As inserting values at predefined index positions doesn't work with empty
|
|
759
|
-
// arrays, we need to reorder the updated selection to match the initial order
|
|
760
|
-
return updated.sort(function (a, b) {
|
|
761
|
-
return all.indexOf(a) > all.indexOf(b);
|
|
762
|
-
});
|
|
763
|
-
};
|
|
764
|
-
var deselectValue = function deselectValue(value, selected) {
|
|
765
|
-
return selected.filter(function (v) {
|
|
766
|
-
return v !== value;
|
|
767
|
-
});
|
|
768
|
-
};
|
|
769
763
|
/** The `CheckboxesWidget` is a widget for rendering checkbox groups.
|
|
770
764
|
* It is typically used to represent an array of enums.
|
|
771
765
|
*
|
|
@@ -787,26 +781,23 @@ function CheckboxesWidget(_ref) {
|
|
|
787
781
|
var enumOptions = options.enumOptions,
|
|
788
782
|
enumDisabled = options.enumDisabled,
|
|
789
783
|
inline = options.inline;
|
|
784
|
+
var checkboxesValues = Array.isArray(value) ? value : [value];
|
|
790
785
|
var _onChange = function _onChange(option) {
|
|
791
786
|
return function (_ref2) {
|
|
792
787
|
var checked = _ref2.target.checked;
|
|
793
|
-
var all = enumOptions.map(function (_ref3) {
|
|
794
|
-
var value = _ref3.value;
|
|
795
|
-
return value;
|
|
796
|
-
});
|
|
797
788
|
if (checked) {
|
|
798
|
-
onChange(
|
|
789
|
+
onChange(utils.enumOptionsSelectValue(option.value, checkboxesValues, enumOptions));
|
|
799
790
|
} else {
|
|
800
|
-
onChange(
|
|
791
|
+
onChange(utils.enumOptionsDeselectValue(option.value, checkboxesValues));
|
|
801
792
|
}
|
|
802
793
|
};
|
|
803
794
|
};
|
|
804
|
-
var _onBlur = function _onBlur(
|
|
805
|
-
var value =
|
|
795
|
+
var _onBlur = function _onBlur(_ref3) {
|
|
796
|
+
var value = _ref3.target.value;
|
|
806
797
|
return onBlur(id, value);
|
|
807
798
|
};
|
|
808
|
-
var _onFocus = function _onFocus(
|
|
809
|
-
var value =
|
|
799
|
+
var _onFocus = function _onFocus(_ref4) {
|
|
800
|
+
var value = _ref4.target.value;
|
|
810
801
|
return onFocus(id, value);
|
|
811
802
|
};
|
|
812
803
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(FormLabel__default["default"], {
|
|
@@ -816,17 +807,18 @@ function CheckboxesWidget(_ref) {
|
|
|
816
807
|
id: id,
|
|
817
808
|
row: !!inline
|
|
818
809
|
}, Array.isArray(enumOptions) && enumOptions.map(function (option, index) {
|
|
819
|
-
var checked =
|
|
810
|
+
var checked = checkboxesValues.includes(option.value);
|
|
820
811
|
var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
821
812
|
var checkbox = /*#__PURE__*/React__default["default"].createElement(Checkbox__default["default"], {
|
|
822
|
-
id: id
|
|
813
|
+
id: utils.optionId(id, option),
|
|
823
814
|
name: id,
|
|
824
815
|
checked: checked,
|
|
825
816
|
disabled: disabled || itemDisabled || readonly,
|
|
826
817
|
autoFocus: autofocus && index === 0,
|
|
827
818
|
onChange: _onChange(option),
|
|
828
819
|
onBlur: _onBlur,
|
|
829
|
-
onFocus: _onFocus
|
|
820
|
+
onFocus: _onFocus,
|
|
821
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
830
822
|
});
|
|
831
823
|
return /*#__PURE__*/React__default["default"].createElement(FormControlLabel__default["default"], {
|
|
832
824
|
control: checkbox,
|
|
@@ -918,13 +910,14 @@ function RadioWidget(_ref) {
|
|
|
918
910
|
row: row,
|
|
919
911
|
onChange: _onChange,
|
|
920
912
|
onBlur: _onBlur,
|
|
921
|
-
onFocus: _onFocus
|
|
913
|
+
onFocus: _onFocus,
|
|
914
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
922
915
|
}, Array.isArray(enumOptions) && enumOptions.map(function (option) {
|
|
923
916
|
var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
924
917
|
var radio = /*#__PURE__*/React__default["default"].createElement(FormControlLabel__default["default"], {
|
|
925
918
|
control: /*#__PURE__*/React__default["default"].createElement(Radio__default["default"], {
|
|
926
919
|
name: id,
|
|
927
|
-
id: id
|
|
920
|
+
id: utils.optionId(id, option),
|
|
928
921
|
color: "primary"
|
|
929
922
|
}),
|
|
930
923
|
label: "" + option.label,
|
|
@@ -979,9 +972,12 @@ function RangeWidget(props) {
|
|
|
979
972
|
onBlur: _onBlur,
|
|
980
973
|
onFocus: _onFocus,
|
|
981
974
|
valueLabelDisplay: "auto"
|
|
982
|
-
}, sliderProps
|
|
975
|
+
}, sliderProps, {
|
|
976
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
977
|
+
})));
|
|
983
978
|
}
|
|
984
979
|
|
|
980
|
+
var _excluded = ["schema", "id", "options", "label", "required", "disabled", "placeholder", "readonly", "value", "multiple", "autofocus", "onChange", "onBlur", "onFocus", "rawErrors", "registry", "uiSchema", "hideError", "formContext"];
|
|
985
981
|
/** The `SelectWidget` is a widget for rendering dropdowns.
|
|
986
982
|
* It is typically used with string properties constrained with enum options.
|
|
987
983
|
*
|
|
@@ -994,6 +990,7 @@ function SelectWidget(_ref) {
|
|
|
994
990
|
label = _ref.label,
|
|
995
991
|
required = _ref.required,
|
|
996
992
|
disabled = _ref.disabled,
|
|
993
|
+
placeholder = _ref.placeholder,
|
|
997
994
|
readonly = _ref.readonly,
|
|
998
995
|
value = _ref.value,
|
|
999
996
|
multiple = _ref.multiple,
|
|
@@ -1002,10 +999,13 @@ function SelectWidget(_ref) {
|
|
|
1002
999
|
onBlur = _ref.onBlur,
|
|
1003
1000
|
onFocus = _ref.onFocus,
|
|
1004
1001
|
_ref$rawErrors = _ref.rawErrors,
|
|
1005
|
-
rawErrors = _ref$rawErrors === void 0 ? [] : _ref$rawErrors
|
|
1002
|
+
rawErrors = _ref$rawErrors === void 0 ? [] : _ref$rawErrors,
|
|
1003
|
+
textFieldProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
1006
1004
|
var enumOptions = options.enumOptions,
|
|
1007
1005
|
enumDisabled = options.enumDisabled;
|
|
1006
|
+
multiple = typeof multiple === "undefined" ? false : !!multiple;
|
|
1008
1007
|
var emptyValue = multiple ? [] : "";
|
|
1008
|
+
var isEmpty = typeof value === "undefined" || multiple && value.length < 1 || !multiple && value === emptyValue;
|
|
1009
1009
|
var _onChange = function _onChange(_ref2) {
|
|
1010
1010
|
var value = _ref2.target.value;
|
|
1011
1011
|
return onChange(utils.processSelectValue(schema, value, options));
|
|
@@ -1018,26 +1018,30 @@ function SelectWidget(_ref) {
|
|
|
1018
1018
|
var value = _ref4.target.value;
|
|
1019
1019
|
return onFocus(id, utils.processSelectValue(schema, value, options));
|
|
1020
1020
|
};
|
|
1021
|
-
return /*#__PURE__*/React__default["default"].createElement(TextField__default["default"], {
|
|
1021
|
+
return /*#__PURE__*/React__default["default"].createElement(TextField__default["default"], _extends({
|
|
1022
1022
|
id: id,
|
|
1023
1023
|
name: id,
|
|
1024
1024
|
label: label || schema.title,
|
|
1025
|
-
|
|
1026
|
-
value: typeof value === "undefined" ? emptyValue : value,
|
|
1025
|
+
value: isEmpty ? emptyValue : value,
|
|
1027
1026
|
required: required,
|
|
1028
1027
|
disabled: disabled || readonly,
|
|
1029
1028
|
autoFocus: autofocus,
|
|
1029
|
+
placeholder: placeholder,
|
|
1030
1030
|
error: rawErrors.length > 0,
|
|
1031
1031
|
onChange: _onChange,
|
|
1032
1032
|
onBlur: _onBlur,
|
|
1033
|
-
onFocus: _onFocus
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1033
|
+
onFocus: _onFocus
|
|
1034
|
+
}, textFieldProps, {
|
|
1035
|
+
select // Apply this and the following props after the potential overrides defined in textFieldProps
|
|
1036
|
+
: true,
|
|
1037
|
+
InputLabelProps: _extends({}, textFieldProps.InputLabelProps, {
|
|
1038
|
+
shrink: !isEmpty
|
|
1039
|
+
}),
|
|
1040
|
+
SelectProps: _extends({}, textFieldProps.SelectProps, {
|
|
1041
|
+
multiple: multiple
|
|
1042
|
+
}),
|
|
1043
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
1044
|
+
}), enumOptions.map(function (_ref5, i) {
|
|
1041
1045
|
var value = _ref5.value,
|
|
1042
1046
|
label = _ref5.label;
|
|
1043
1047
|
var disabled = enumDisabled && enumDisabled.indexOf(value) != -1;
|