@rjsf/chakra-ui 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/dist/chakra-ui.esm.js +47 -50
- package/dist/chakra-ui.esm.js.map +3 -3
- package/dist/chakra-ui.umd.js +29 -38
- package/dist/index.cjs +29 -38
- package/dist/index.cjs.map +3 -3
- package/lib/CheckboxesWidget/CheckboxesWidget.js +7 -6
- package/lib/CheckboxesWidget/CheckboxesWidget.js.map +1 -1
- package/lib/RadioWidget/RadioWidget.js +8 -8
- package/lib/RadioWidget/RadioWidget.js.map +1 -1
- package/lib/SelectWidget/SelectWidget.js +17 -27
- package/lib/SelectWidget/SelectWidget.js.map +1 -1
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js +1 -1
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/src/CheckboxesWidget/CheckboxesWidget.tsx +14 -9
- package/src/RadioWidget/RadioWidget.tsx +11 -8
- package/src/SelectWidget/SelectWidget.tsx +20 -35
- package/src/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx +1 -0
package/dist/chakra-ui.umd.js
CHANGED
|
@@ -540,7 +540,8 @@
|
|
|
540
540
|
onBlur: !readonly ? onKeyRenameBlur : void 0,
|
|
541
541
|
type: "text",
|
|
542
542
|
mb: 1
|
|
543
|
-
}
|
|
543
|
+
},
|
|
544
|
+
label
|
|
544
545
|
) }) }),
|
|
545
546
|
/* @__PURE__ */ jsxRuntime.jsx(react$1.GridItem, { colSpan: 5, children }),
|
|
546
547
|
/* @__PURE__ */ jsxRuntime.jsx(react$1.GridItem, { justifySelf: "flex-end", style: { marginTop: displayLabel ? `${margin}px` : void 0 }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -724,10 +725,11 @@
|
|
|
724
725
|
uiSchema
|
|
725
726
|
} = props;
|
|
726
727
|
const { enumOptions, enumDisabled, emptyValue } = options;
|
|
727
|
-
const
|
|
728
|
-
const
|
|
728
|
+
const optionValueFormat = utils.getOptionValueFormat(options);
|
|
729
|
+
const _onBlur = ({ target }) => onBlur(id, utils.enumOptionValueDecoder(target && target.value, enumOptions, optionValueFormat, emptyValue));
|
|
730
|
+
const _onFocus = ({ target }) => onFocus(id, utils.enumOptionValueDecoder(target && target.value, enumOptions, optionValueFormat, emptyValue));
|
|
729
731
|
const row = options ? options.inline : false;
|
|
730
|
-
const
|
|
732
|
+
const selectValue = utils.enumOptionSelectedValue(value, enumOptions, true, optionValueFormat, []);
|
|
731
733
|
const chakraProps = getChakra({ });
|
|
732
734
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
733
735
|
react$1.FieldsetRoot,
|
|
@@ -741,11 +743,11 @@
|
|
|
741
743
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
742
744
|
react$1.CheckboxGroup,
|
|
743
745
|
{
|
|
744
|
-
onValueChange: (option) => onChange(utils.
|
|
745
|
-
value:
|
|
746
|
+
onValueChange: (option) => onChange(utils.enumOptionValueDecoder(option, enumOptions, optionValueFormat, emptyValue)),
|
|
747
|
+
value: selectValue,
|
|
746
748
|
"aria-describedby": utils.ariaDescribedByIds(id),
|
|
747
749
|
readOnly: readonly,
|
|
748
|
-
required,
|
|
750
|
+
invalid: required && value.length === 0,
|
|
749
751
|
children: /* @__PURE__ */ jsxRuntime.jsx(react$1.Stack, { direction: row ? "row" : "column", children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
|
|
750
752
|
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
751
753
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -753,7 +755,7 @@
|
|
|
753
755
|
{
|
|
754
756
|
id: utils.optionId(id, index),
|
|
755
757
|
name: htmlName || id,
|
|
756
|
-
value:
|
|
758
|
+
value: utils.enumOptionValueEncoder(option.value, index, optionValueFormat),
|
|
757
759
|
disabled: disabled || itemDisabled || readonly,
|
|
758
760
|
onBlur: _onBlur,
|
|
759
761
|
onFocus: _onFocus,
|
|
@@ -793,11 +795,12 @@
|
|
|
793
795
|
uiSchema
|
|
794
796
|
}) {
|
|
795
797
|
const { enumOptions, enumDisabled, emptyValue } = options;
|
|
796
|
-
const
|
|
797
|
-
const
|
|
798
|
-
const
|
|
798
|
+
const optionValueFormat = utils.getOptionValueFormat(options);
|
|
799
|
+
const _onChange = ({ target: { value: value2 } }) => onChange(utils.enumOptionValueDecoder(value2, enumOptions, optionValueFormat, emptyValue));
|
|
800
|
+
const _onBlur = ({ target: { value: value2 } }) => onBlur(id, utils.enumOptionValueDecoder(value2, enumOptions, optionValueFormat, emptyValue));
|
|
801
|
+
const _onFocus = ({ target: { value: value2 } }) => onFocus(id, utils.enumOptionValueDecoder(value2, enumOptions, optionValueFormat, emptyValue));
|
|
799
802
|
const row = options ? options.inline : false;
|
|
800
|
-
const
|
|
803
|
+
const selectValue = utils.enumOptionSelectedValue(value, enumOptions, false, optionValueFormat, null);
|
|
801
804
|
const chakraProps = getChakra({ });
|
|
802
805
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
803
806
|
Field,
|
|
@@ -814,7 +817,7 @@
|
|
|
814
817
|
onChange: _onChange,
|
|
815
818
|
onBlur: _onBlur,
|
|
816
819
|
onFocus: _onFocus,
|
|
817
|
-
value:
|
|
820
|
+
value: selectValue,
|
|
818
821
|
name: htmlName || id,
|
|
819
822
|
"aria-describedby": utils.ariaDescribedByIds(id),
|
|
820
823
|
children: /* @__PURE__ */ jsxRuntime.jsx(react$1.Stack, { direction: row ? "row" : "column", children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
|
|
@@ -822,7 +825,7 @@
|
|
|
822
825
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
823
826
|
Radio,
|
|
824
827
|
{
|
|
825
|
-
value:
|
|
828
|
+
value: utils.enumOptionValueEncoder(option.value, index, optionValueFormat),
|
|
826
829
|
id: utils.optionId(id, index),
|
|
827
830
|
disabled: disabled || itemDisabled || readonly,
|
|
828
831
|
children: option.label
|
|
@@ -984,26 +987,25 @@
|
|
|
984
987
|
uiSchema
|
|
985
988
|
} = props;
|
|
986
989
|
const { enumOptions, enumDisabled, emptyValue } = options;
|
|
990
|
+
const optionValueFormat = utils.getOptionValueFormat(options);
|
|
987
991
|
const _onMultiChange = ({ value: value2 }) => {
|
|
988
|
-
return onChange(utils.
|
|
992
|
+
return onChange(utils.enumOptionValueDecoder(value2, enumOptions, optionValueFormat, emptyValue));
|
|
989
993
|
};
|
|
990
994
|
const _onSingleChange = ({ value: value2 }) => {
|
|
991
|
-
const selected = utils.
|
|
995
|
+
const selected = utils.enumOptionValueDecoder(value2, enumOptions, optionValueFormat, emptyValue);
|
|
992
996
|
return onChange(Array.isArray(selected) && selected.length === 1 ? selected[0] : selected);
|
|
993
997
|
};
|
|
994
|
-
const _onBlur = ({ target }) => onBlur(id, utils.
|
|
995
|
-
const _onFocus = ({ target }) => onFocus(id, utils.
|
|
998
|
+
const _onBlur = ({ target }) => onBlur(id, utils.enumOptionValueDecoder(target && target.value, enumOptions, optionValueFormat, emptyValue));
|
|
999
|
+
const _onFocus = ({ target }) => onFocus(id, utils.enumOptionValueDecoder(target && target.value, enumOptions, optionValueFormat, emptyValue));
|
|
996
1000
|
const showPlaceholderOption = !multiple && schema.default === void 0;
|
|
997
|
-
const
|
|
998
|
-
const valueLabelMap2 = {};
|
|
1001
|
+
const displayEnumOptions = react.useMemo(() => {
|
|
999
1002
|
let displayEnumOptions2 = [];
|
|
1000
1003
|
if (Array.isArray(enumOptions)) {
|
|
1001
1004
|
displayEnumOptions2 = enumOptions.map((option, index) => {
|
|
1002
1005
|
const { value: value2, label: label2 } = option;
|
|
1003
|
-
valueLabelMap2[index] = label2 || String(value2);
|
|
1004
1006
|
return {
|
|
1005
1007
|
label: label2,
|
|
1006
|
-
value:
|
|
1008
|
+
value: utils.enumOptionValueEncoder(value2, index, optionValueFormat),
|
|
1007
1009
|
disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(value2) !== -1
|
|
1008
1010
|
};
|
|
1009
1011
|
});
|
|
@@ -1011,23 +1013,12 @@
|
|
|
1011
1013
|
displayEnumOptions2.unshift({ value: "", label: placeholder || "" });
|
|
1012
1014
|
}
|
|
1013
1015
|
}
|
|
1014
|
-
return
|
|
1015
|
-
}, [enumDisabled, enumOptions, placeholder, showPlaceholderOption]);
|
|
1016
|
+
return displayEnumOptions2;
|
|
1017
|
+
}, [enumDisabled, enumOptions, placeholder, showPlaceholderOption, optionValueFormat]);
|
|
1016
1018
|
const isMultiple = typeof multiple !== "undefined" && multiple !== false && Boolean(enumOptions);
|
|
1017
|
-
const
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
label: valueLabelMap[i],
|
|
1021
|
-
value: i.toString()
|
|
1022
|
-
};
|
|
1023
|
-
});
|
|
1024
|
-
const getSingleValue = () => typeof selectedIndex !== "undefined" ? [
|
|
1025
|
-
{
|
|
1026
|
-
label: valueLabelMap[selectedIndex] || "",
|
|
1027
|
-
value: selectedIndex.toString()
|
|
1028
|
-
}
|
|
1029
|
-
] : [];
|
|
1030
|
-
const formValue = (isMultiple ? getMultiValue() : getSingleValue()).map((item) => item.value);
|
|
1019
|
+
const formValue = [
|
|
1020
|
+
utils.enumOptionSelectedValue(value, enumOptions, isMultiple, optionValueFormat, isMultiple ? [] : "")
|
|
1021
|
+
].flat().filter((v) => v !== "");
|
|
1031
1022
|
const selectOptions = react$1.createListCollection({
|
|
1032
1023
|
items: displayEnumOptions.filter((item) => item.value)
|
|
1033
1024
|
});
|
package/dist/index.cjs
CHANGED
|
@@ -697,7 +697,8 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
697
697
|
onBlur: !readonly ? onKeyRenameBlur : void 0,
|
|
698
698
|
type: "text",
|
|
699
699
|
mb: 1
|
|
700
|
-
}
|
|
700
|
+
},
|
|
701
|
+
label
|
|
701
702
|
) }) }),
|
|
702
703
|
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_react25.GridItem, { colSpan: 5, children }),
|
|
703
704
|
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_react25.GridItem, { justifySelf: "flex-end", style: { marginTop: displayLabel ? `${margin}px` : void 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
@@ -906,10 +907,11 @@ function CheckboxesWidget(props) {
|
|
|
906
907
|
uiSchema
|
|
907
908
|
} = props;
|
|
908
909
|
const { enumOptions, enumDisabled, emptyValue } = options;
|
|
909
|
-
const
|
|
910
|
-
const
|
|
910
|
+
const optionValueFormat = (0, import_utils18.getOptionValueFormat)(options);
|
|
911
|
+
const _onBlur = ({ target }) => onBlur(id, (0, import_utils18.enumOptionValueDecoder)(target && target.value, enumOptions, optionValueFormat, emptyValue));
|
|
912
|
+
const _onFocus = ({ target }) => onFocus(id, (0, import_utils18.enumOptionValueDecoder)(target && target.value, enumOptions, optionValueFormat, emptyValue));
|
|
911
913
|
const row = options ? options.inline : false;
|
|
912
|
-
const
|
|
914
|
+
const selectValue = (0, import_utils18.enumOptionSelectedValue)(value, enumOptions, true, optionValueFormat, []);
|
|
913
915
|
const chakraProps = getChakra({ uiSchema });
|
|
914
916
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
915
917
|
import_react30.FieldsetRoot,
|
|
@@ -923,11 +925,11 @@ function CheckboxesWidget(props) {
|
|
|
923
925
|
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
924
926
|
import_react30.CheckboxGroup,
|
|
925
927
|
{
|
|
926
|
-
onValueChange: (option) => onChange((0, import_utils18.
|
|
927
|
-
value:
|
|
928
|
+
onValueChange: (option) => onChange((0, import_utils18.enumOptionValueDecoder)(option, enumOptions, optionValueFormat, emptyValue)),
|
|
929
|
+
value: selectValue,
|
|
928
930
|
"aria-describedby": (0, import_utils18.ariaDescribedByIds)(id),
|
|
929
931
|
readOnly: readonly,
|
|
930
|
-
required,
|
|
932
|
+
invalid: required && value.length === 0,
|
|
931
933
|
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_react30.Stack, { direction: row ? "row" : "column", children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
|
|
932
934
|
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
933
935
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
@@ -935,7 +937,7 @@ function CheckboxesWidget(props) {
|
|
|
935
937
|
{
|
|
936
938
|
id: (0, import_utils18.optionId)(id, index),
|
|
937
939
|
name: htmlName || id,
|
|
938
|
-
value:
|
|
940
|
+
value: (0, import_utils18.enumOptionValueEncoder)(option.value, index, optionValueFormat),
|
|
939
941
|
disabled: disabled || itemDisabled || readonly,
|
|
940
942
|
onBlur: _onBlur,
|
|
941
943
|
onFocus: _onFocus,
|
|
@@ -987,11 +989,12 @@ function RadioWidget({
|
|
|
987
989
|
uiSchema
|
|
988
990
|
}) {
|
|
989
991
|
const { enumOptions, enumDisabled, emptyValue } = options;
|
|
990
|
-
const
|
|
991
|
-
const
|
|
992
|
-
const
|
|
992
|
+
const optionValueFormat = (0, import_utils20.getOptionValueFormat)(options);
|
|
993
|
+
const _onChange = ({ target: { value: value2 } }) => onChange((0, import_utils20.enumOptionValueDecoder)(value2, enumOptions, optionValueFormat, emptyValue));
|
|
994
|
+
const _onBlur = ({ target: { value: value2 } }) => onBlur(id, (0, import_utils20.enumOptionValueDecoder)(value2, enumOptions, optionValueFormat, emptyValue));
|
|
995
|
+
const _onFocus = ({ target: { value: value2 } }) => onFocus(id, (0, import_utils20.enumOptionValueDecoder)(value2, enumOptions, optionValueFormat, emptyValue));
|
|
993
996
|
const row = options ? options.inline : false;
|
|
994
|
-
const
|
|
997
|
+
const selectValue = (0, import_utils20.enumOptionSelectedValue)(value, enumOptions, false, optionValueFormat, null);
|
|
995
998
|
const chakraProps = getChakra({ uiSchema });
|
|
996
999
|
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
997
1000
|
Field,
|
|
@@ -1008,7 +1011,7 @@ function RadioWidget({
|
|
|
1008
1011
|
onChange: _onChange,
|
|
1009
1012
|
onBlur: _onBlur,
|
|
1010
1013
|
onFocus: _onFocus,
|
|
1011
|
-
value:
|
|
1014
|
+
value: selectValue,
|
|
1012
1015
|
name: htmlName || id,
|
|
1013
1016
|
"aria-describedby": (0, import_utils20.ariaDescribedByIds)(id),
|
|
1014
1017
|
children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_react33.Stack, { direction: row ? "row" : "column", children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
|
|
@@ -1016,7 +1019,7 @@ function RadioWidget({
|
|
|
1016
1019
|
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
1017
1020
|
Radio,
|
|
1018
1021
|
{
|
|
1019
|
-
value:
|
|
1022
|
+
value: (0, import_utils20.enumOptionValueEncoder)(option.value, index, optionValueFormat),
|
|
1020
1023
|
id: (0, import_utils20.optionId)(id, index),
|
|
1021
1024
|
disabled: disabled || itemDisabled || readonly,
|
|
1022
1025
|
children: option.label
|
|
@@ -1202,26 +1205,25 @@ function SelectWidget(props) {
|
|
|
1202
1205
|
uiSchema
|
|
1203
1206
|
} = props;
|
|
1204
1207
|
const { enumOptions, enumDisabled, emptyValue } = options;
|
|
1208
|
+
const optionValueFormat = (0, import_utils24.getOptionValueFormat)(options);
|
|
1205
1209
|
const _onMultiChange = ({ value: value2 }) => {
|
|
1206
|
-
return onChange((0, import_utils24.
|
|
1210
|
+
return onChange((0, import_utils24.enumOptionValueDecoder)(value2, enumOptions, optionValueFormat, emptyValue));
|
|
1207
1211
|
};
|
|
1208
1212
|
const _onSingleChange = ({ value: value2 }) => {
|
|
1209
|
-
const selected = (0, import_utils24.
|
|
1213
|
+
const selected = (0, import_utils24.enumOptionValueDecoder)(value2, enumOptions, optionValueFormat, emptyValue);
|
|
1210
1214
|
return onChange(Array.isArray(selected) && selected.length === 1 ? selected[0] : selected);
|
|
1211
1215
|
};
|
|
1212
|
-
const _onBlur = ({ target }) => onBlur(id, (0, import_utils24.
|
|
1213
|
-
const _onFocus = ({ target }) => onFocus(id, (0, import_utils24.
|
|
1216
|
+
const _onBlur = ({ target }) => onBlur(id, (0, import_utils24.enumOptionValueDecoder)(target && target.value, enumOptions, optionValueFormat, emptyValue));
|
|
1217
|
+
const _onFocus = ({ target }) => onFocus(id, (0, import_utils24.enumOptionValueDecoder)(target && target.value, enumOptions, optionValueFormat, emptyValue));
|
|
1214
1218
|
const showPlaceholderOption = !multiple && schema.default === void 0;
|
|
1215
|
-
const
|
|
1216
|
-
const valueLabelMap2 = {};
|
|
1219
|
+
const displayEnumOptions = (0, import_react38.useMemo)(() => {
|
|
1217
1220
|
let displayEnumOptions2 = [];
|
|
1218
1221
|
if (Array.isArray(enumOptions)) {
|
|
1219
1222
|
displayEnumOptions2 = enumOptions.map((option, index) => {
|
|
1220
1223
|
const { value: value2, label: label2 } = option;
|
|
1221
|
-
valueLabelMap2[index] = label2 || String(value2);
|
|
1222
1224
|
return {
|
|
1223
1225
|
label: label2,
|
|
1224
|
-
value:
|
|
1226
|
+
value: (0, import_utils24.enumOptionValueEncoder)(value2, index, optionValueFormat),
|
|
1225
1227
|
disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(value2) !== -1
|
|
1226
1228
|
};
|
|
1227
1229
|
});
|
|
@@ -1229,23 +1231,12 @@ function SelectWidget(props) {
|
|
|
1229
1231
|
displayEnumOptions2.unshift({ value: "", label: placeholder || "" });
|
|
1230
1232
|
}
|
|
1231
1233
|
}
|
|
1232
|
-
return
|
|
1233
|
-
}, [enumDisabled, enumOptions, placeholder, showPlaceholderOption]);
|
|
1234
|
+
return displayEnumOptions2;
|
|
1235
|
+
}, [enumDisabled, enumOptions, placeholder, showPlaceholderOption, optionValueFormat]);
|
|
1234
1236
|
const isMultiple = typeof multiple !== "undefined" && multiple !== false && Boolean(enumOptions);
|
|
1235
|
-
const
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
label: valueLabelMap[i],
|
|
1239
|
-
value: i.toString()
|
|
1240
|
-
};
|
|
1241
|
-
});
|
|
1242
|
-
const getSingleValue = () => typeof selectedIndex !== "undefined" ? [
|
|
1243
|
-
{
|
|
1244
|
-
label: valueLabelMap[selectedIndex] || "",
|
|
1245
|
-
value: selectedIndex.toString()
|
|
1246
|
-
}
|
|
1247
|
-
] : [];
|
|
1248
|
-
const formValue = (isMultiple ? getMultiValue() : getSingleValue()).map((item) => item.value);
|
|
1237
|
+
const formValue = [
|
|
1238
|
+
(0, import_utils24.enumOptionSelectedValue)(value, enumOptions, isMultiple, optionValueFormat, isMultiple ? [] : "")
|
|
1239
|
+
].flat().filter((v) => v !== "");
|
|
1249
1240
|
const selectOptions = (0, import_react39.createListCollection)({
|
|
1250
1241
|
items: displayEnumOptions.filter((item) => item.value)
|
|
1251
1242
|
});
|