@rjsf/chakra-ui 6.4.1 → 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.esm.js
CHANGED
|
@@ -677,7 +677,8 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
677
677
|
onBlur: !readonly ? onKeyRenameBlur : void 0,
|
|
678
678
|
type: "text",
|
|
679
679
|
mb: 1
|
|
680
|
-
}
|
|
680
|
+
},
|
|
681
|
+
label
|
|
681
682
|
) }) }),
|
|
682
683
|
/* @__PURE__ */ jsx21(GridItem4, { colSpan: 5, children }),
|
|
683
684
|
/* @__PURE__ */ jsx21(GridItem4, { justifySelf: "flex-end", style: { marginTop: displayLabel ? `${margin}px` : void 0 }, children: /* @__PURE__ */ jsx21(
|
|
@@ -879,8 +880,10 @@ function CheckboxWidget(props) {
|
|
|
879
880
|
import { CheckboxGroup, FieldsetRoot as FieldsetRoot2, Stack, Text as Text4, FieldsetLegend } from "@chakra-ui/react";
|
|
880
881
|
import {
|
|
881
882
|
ariaDescribedByIds as ariaDescribedByIds3,
|
|
882
|
-
|
|
883
|
-
|
|
883
|
+
enumOptionSelectedValue,
|
|
884
|
+
enumOptionValueDecoder,
|
|
885
|
+
enumOptionValueEncoder,
|
|
886
|
+
getOptionValueFormat,
|
|
884
887
|
optionId,
|
|
885
888
|
labelValue as labelValue3
|
|
886
889
|
} from "@rjsf/utils";
|
|
@@ -903,10 +906,11 @@ function CheckboxesWidget(props) {
|
|
|
903
906
|
uiSchema
|
|
904
907
|
} = props;
|
|
905
908
|
const { enumOptions, enumDisabled, emptyValue } = options;
|
|
906
|
-
const
|
|
907
|
-
const
|
|
909
|
+
const optionValueFormat = getOptionValueFormat(options);
|
|
910
|
+
const _onBlur = ({ target }) => onBlur(id, enumOptionValueDecoder(target && target.value, enumOptions, optionValueFormat, emptyValue));
|
|
911
|
+
const _onFocus = ({ target }) => onFocus(id, enumOptionValueDecoder(target && target.value, enumOptions, optionValueFormat, emptyValue));
|
|
908
912
|
const row = options ? options.inline : false;
|
|
909
|
-
const
|
|
913
|
+
const selectValue = enumOptionSelectedValue(value, enumOptions, true, optionValueFormat, []);
|
|
910
914
|
const chakraProps = getChakra({ uiSchema });
|
|
911
915
|
return /* @__PURE__ */ jsxs15(
|
|
912
916
|
FieldsetRoot2,
|
|
@@ -920,11 +924,11 @@ function CheckboxesWidget(props) {
|
|
|
920
924
|
/* @__PURE__ */ jsx26(
|
|
921
925
|
CheckboxGroup,
|
|
922
926
|
{
|
|
923
|
-
onValueChange: (option) => onChange(
|
|
924
|
-
value:
|
|
927
|
+
onValueChange: (option) => onChange(enumOptionValueDecoder(option, enumOptions, optionValueFormat, emptyValue)),
|
|
928
|
+
value: selectValue,
|
|
925
929
|
"aria-describedby": ariaDescribedByIds3(id),
|
|
926
930
|
readOnly: readonly,
|
|
927
|
-
required,
|
|
931
|
+
invalid: required && value.length === 0,
|
|
928
932
|
children: /* @__PURE__ */ jsx26(Stack, { direction: row ? "row" : "column", children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
|
|
929
933
|
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
930
934
|
return /* @__PURE__ */ jsx26(
|
|
@@ -932,7 +936,7 @@ function CheckboxesWidget(props) {
|
|
|
932
936
|
{
|
|
933
937
|
id: optionId(id, index),
|
|
934
938
|
name: htmlName || id,
|
|
935
|
-
value:
|
|
939
|
+
value: enumOptionValueEncoder(option.value, index, optionValueFormat),
|
|
936
940
|
disabled: disabled || itemDisabled || readonly,
|
|
937
941
|
onBlur: _onBlur,
|
|
938
942
|
onFocus: _onFocus,
|
|
@@ -952,8 +956,10 @@ function CheckboxesWidget(props) {
|
|
|
952
956
|
import { Stack as Stack2 } from "@chakra-ui/react";
|
|
953
957
|
import {
|
|
954
958
|
ariaDescribedByIds as ariaDescribedByIds4,
|
|
955
|
-
|
|
956
|
-
|
|
959
|
+
enumOptionSelectedValue as enumOptionSelectedValue2,
|
|
960
|
+
enumOptionValueDecoder as enumOptionValueDecoder2,
|
|
961
|
+
enumOptionValueEncoder as enumOptionValueEncoder2,
|
|
962
|
+
getOptionValueFormat as getOptionValueFormat2,
|
|
957
963
|
labelValue as labelValue4,
|
|
958
964
|
optionId as optionId2
|
|
959
965
|
} from "@rjsf/utils";
|
|
@@ -990,11 +996,12 @@ function RadioWidget({
|
|
|
990
996
|
uiSchema
|
|
991
997
|
}) {
|
|
992
998
|
const { enumOptions, enumDisabled, emptyValue } = options;
|
|
993
|
-
const
|
|
994
|
-
const
|
|
995
|
-
const
|
|
999
|
+
const optionValueFormat = getOptionValueFormat2(options);
|
|
1000
|
+
const _onChange = ({ target: { value: value2 } }) => onChange(enumOptionValueDecoder2(value2, enumOptions, optionValueFormat, emptyValue));
|
|
1001
|
+
const _onBlur = ({ target: { value: value2 } }) => onBlur(id, enumOptionValueDecoder2(value2, enumOptions, optionValueFormat, emptyValue));
|
|
1002
|
+
const _onFocus = ({ target: { value: value2 } }) => onFocus(id, enumOptionValueDecoder2(value2, enumOptions, optionValueFormat, emptyValue));
|
|
996
1003
|
const row = options ? options.inline : false;
|
|
997
|
-
const
|
|
1004
|
+
const selectValue = enumOptionSelectedValue2(value, enumOptions, false, optionValueFormat, null);
|
|
998
1005
|
const chakraProps = getChakra({ uiSchema });
|
|
999
1006
|
return /* @__PURE__ */ jsx28(
|
|
1000
1007
|
Field,
|
|
@@ -1011,7 +1018,7 @@ function RadioWidget({
|
|
|
1011
1018
|
onChange: _onChange,
|
|
1012
1019
|
onBlur: _onBlur,
|
|
1013
1020
|
onFocus: _onFocus,
|
|
1014
|
-
value:
|
|
1021
|
+
value: selectValue,
|
|
1015
1022
|
name: htmlName || id,
|
|
1016
1023
|
"aria-describedby": ariaDescribedByIds4(id),
|
|
1017
1024
|
children: /* @__PURE__ */ jsx28(Stack2, { direction: row ? "row" : "column", children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
|
|
@@ -1019,7 +1026,7 @@ function RadioWidget({
|
|
|
1019
1026
|
return /* @__PURE__ */ jsx28(
|
|
1020
1027
|
Radio,
|
|
1021
1028
|
{
|
|
1022
|
-
value:
|
|
1029
|
+
value: enumOptionValueEncoder2(option.value, index, optionValueFormat),
|
|
1023
1030
|
id: optionId2(id, index),
|
|
1024
1031
|
disabled: disabled || itemDisabled || readonly,
|
|
1025
1032
|
children: option.label
|
|
@@ -1122,8 +1129,10 @@ function RangeWidget({
|
|
|
1122
1129
|
import { useMemo, useRef } from "react";
|
|
1123
1130
|
import {
|
|
1124
1131
|
ariaDescribedByIds as ariaDescribedByIds6,
|
|
1125
|
-
|
|
1126
|
-
|
|
1132
|
+
enumOptionSelectedValue as enumOptionSelectedValue3,
|
|
1133
|
+
enumOptionValueDecoder as enumOptionValueDecoder3,
|
|
1134
|
+
enumOptionValueEncoder as enumOptionValueEncoder3,
|
|
1135
|
+
getOptionValueFormat as getOptionValueFormat3,
|
|
1127
1136
|
labelValue as labelValue6
|
|
1128
1137
|
} from "@rjsf/utils";
|
|
1129
1138
|
import { createListCollection, Select as ChakraSelect2 } from "@chakra-ui/react";
|
|
@@ -1214,26 +1223,25 @@ function SelectWidget(props) {
|
|
|
1214
1223
|
uiSchema
|
|
1215
1224
|
} = props;
|
|
1216
1225
|
const { enumOptions, enumDisabled, emptyValue } = options;
|
|
1226
|
+
const optionValueFormat = getOptionValueFormat3(options);
|
|
1217
1227
|
const _onMultiChange = ({ value: value2 }) => {
|
|
1218
|
-
return onChange(
|
|
1228
|
+
return onChange(enumOptionValueDecoder3(value2, enumOptions, optionValueFormat, emptyValue));
|
|
1219
1229
|
};
|
|
1220
1230
|
const _onSingleChange = ({ value: value2 }) => {
|
|
1221
|
-
const selected =
|
|
1231
|
+
const selected = enumOptionValueDecoder3(value2, enumOptions, optionValueFormat, emptyValue);
|
|
1222
1232
|
return onChange(Array.isArray(selected) && selected.length === 1 ? selected[0] : selected);
|
|
1223
1233
|
};
|
|
1224
|
-
const _onBlur = ({ target }) => onBlur(id,
|
|
1225
|
-
const _onFocus = ({ target }) => onFocus(id,
|
|
1234
|
+
const _onBlur = ({ target }) => onBlur(id, enumOptionValueDecoder3(target && target.value, enumOptions, optionValueFormat, emptyValue));
|
|
1235
|
+
const _onFocus = ({ target }) => onFocus(id, enumOptionValueDecoder3(target && target.value, enumOptions, optionValueFormat, emptyValue));
|
|
1226
1236
|
const showPlaceholderOption = !multiple && schema.default === void 0;
|
|
1227
|
-
const
|
|
1228
|
-
const valueLabelMap2 = {};
|
|
1237
|
+
const displayEnumOptions = useMemo(() => {
|
|
1229
1238
|
let displayEnumOptions2 = [];
|
|
1230
1239
|
if (Array.isArray(enumOptions)) {
|
|
1231
1240
|
displayEnumOptions2 = enumOptions.map((option, index) => {
|
|
1232
1241
|
const { value: value2, label: label2 } = option;
|
|
1233
|
-
valueLabelMap2[index] = label2 || String(value2);
|
|
1234
1242
|
return {
|
|
1235
1243
|
label: label2,
|
|
1236
|
-
value:
|
|
1244
|
+
value: enumOptionValueEncoder3(value2, index, optionValueFormat),
|
|
1237
1245
|
disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(value2) !== -1
|
|
1238
1246
|
};
|
|
1239
1247
|
});
|
|
@@ -1241,23 +1249,12 @@ function SelectWidget(props) {
|
|
|
1241
1249
|
displayEnumOptions2.unshift({ value: "", label: placeholder || "" });
|
|
1242
1250
|
}
|
|
1243
1251
|
}
|
|
1244
|
-
return
|
|
1245
|
-
}, [enumDisabled, enumOptions, placeholder, showPlaceholderOption]);
|
|
1252
|
+
return displayEnumOptions2;
|
|
1253
|
+
}, [enumDisabled, enumOptions, placeholder, showPlaceholderOption, optionValueFormat]);
|
|
1246
1254
|
const isMultiple = typeof multiple !== "undefined" && multiple !== false && Boolean(enumOptions);
|
|
1247
|
-
const
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
label: valueLabelMap[i],
|
|
1251
|
-
value: i.toString()
|
|
1252
|
-
};
|
|
1253
|
-
});
|
|
1254
|
-
const getSingleValue = () => typeof selectedIndex !== "undefined" ? [
|
|
1255
|
-
{
|
|
1256
|
-
label: valueLabelMap[selectedIndex] || "",
|
|
1257
|
-
value: selectedIndex.toString()
|
|
1258
|
-
}
|
|
1259
|
-
] : [];
|
|
1260
|
-
const formValue = (isMultiple ? getMultiValue() : getSingleValue()).map((item) => item.value);
|
|
1255
|
+
const formValue = [
|
|
1256
|
+
enumOptionSelectedValue3(value, enumOptions, isMultiple, optionValueFormat, isMultiple ? [] : "")
|
|
1257
|
+
].flat().filter((v) => v !== "");
|
|
1261
1258
|
const selectOptions = createListCollection({
|
|
1262
1259
|
items: displayEnumOptions.filter((item) => item.value)
|
|
1263
1260
|
});
|
|
@@ -1307,8 +1304,8 @@ function SelectWidget(props) {
|
|
|
1307
1304
|
import { useMemo as useMemo2 } from "react";
|
|
1308
1305
|
import {
|
|
1309
1306
|
ariaDescribedByIds as ariaDescribedByIds7,
|
|
1310
|
-
enumOptionsIndexForValue
|
|
1311
|
-
enumOptionsValueForIndex
|
|
1307
|
+
enumOptionsIndexForValue,
|
|
1308
|
+
enumOptionsValueForIndex,
|
|
1312
1309
|
labelValue as labelValue7
|
|
1313
1310
|
} from "@rjsf/utils";
|
|
1314
1311
|
import { createListCollection as createListCollection2, NativeSelect } from "@chakra-ui/react";
|
|
@@ -1335,10 +1332,10 @@ function NativeSelectWidget(props) {
|
|
|
1335
1332
|
} = props;
|
|
1336
1333
|
const { enumOptions, enumDisabled, emptyValue } = options;
|
|
1337
1334
|
const _onChange = ({ target }) => {
|
|
1338
|
-
return onChange(
|
|
1335
|
+
return onChange(enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue));
|
|
1339
1336
|
};
|
|
1340
|
-
const _onBlur = ({ target }) => onBlur(id,
|
|
1341
|
-
const _onFocus = ({ target }) => onFocus(id,
|
|
1337
|
+
const _onBlur = ({ target }) => onBlur(id, enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue));
|
|
1338
|
+
const _onFocus = ({ target }) => onFocus(id, enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue));
|
|
1342
1339
|
const showPlaceholderOption = !multiple && schema.default === void 0;
|
|
1343
1340
|
const { valueLabelMap, displayEnumOptions } = useMemo2(() => {
|
|
1344
1341
|
const valueLabelMap2 = {};
|
|
@@ -1356,7 +1353,7 @@ function NativeSelectWidget(props) {
|
|
|
1356
1353
|
}
|
|
1357
1354
|
return { valueLabelMap: valueLabelMap2, displayEnumOptions: displayEnumOptions2 };
|
|
1358
1355
|
}, [enumDisabled, enumOptions]);
|
|
1359
|
-
const selectedIndex =
|
|
1356
|
+
const selectedIndex = enumOptionsIndexForValue(value, enumOptions, false);
|
|
1360
1357
|
const getSingleValue = () => typeof selectedIndex !== "undefined" ? [
|
|
1361
1358
|
{
|
|
1362
1359
|
label: valueLabelMap[selectedIndex] || "",
|