@rjsf/core 5.18.4 → 5.18.5
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/core.umd.js +24 -18
- package/dist/index.esm.js +24 -18
- package/dist/index.esm.js.map +3 -3
- package/dist/index.js +24 -18
- package/dist/index.js.map +3 -3
- package/lib/components/Form.js +1 -1
- package/lib/components/Form.js.map +1 -1
- package/lib/components/fields/ArrayField.d.ts +2 -2
- package/lib/components/fields/NumberField.js +1 -1
- package/lib/components/fields/NumberField.js.map +1 -1
- package/lib/components/fields/ObjectField.js +5 -2
- package/lib/components/fields/ObjectField.js.map +1 -1
- package/lib/components/fields/SchemaField.js +4 -3
- package/lib/components/fields/SchemaField.js.map +1 -1
- package/lib/components/templates/BaseInputTemplate.js +2 -2
- package/lib/components/templates/BaseInputTemplate.js.map +1 -1
- package/lib/components/templates/WrapIfAdditionalTemplate.js +1 -1
- package/lib/components/templates/WrapIfAdditionalTemplate.js.map +1 -1
- package/lib/components/widgets/CheckboxesWidget.js +2 -2
- package/lib/components/widgets/CheckboxesWidget.js.map +1 -1
- package/lib/components/widgets/RadioWidget.js +2 -2
- package/lib/components/widgets/RadioWidget.js.map +1 -1
- package/lib/components/widgets/TextareaWidget.js +2 -2
- package/lib/components/widgets/TextareaWidget.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/src/components/Form.tsx +2 -2
- package/src/components/fields/NumberField.tsx +1 -1
- package/src/components/fields/ObjectField.tsx +6 -3
- package/src/components/fields/SchemaField.tsx +3 -3
- package/src/components/templates/BaseInputTemplate.tsx +5 -2
- package/src/components/templates/WrapIfAdditionalTemplate.tsx +1 -1
- package/src/components/widgets/CheckboxesWidget.tsx +4 -4
- package/src/components/widgets/RadioWidget.tsx +4 -4
- package/src/components/widgets/TextareaWidget.tsx +2 -2
package/dist/core.umd.js
CHANGED
|
@@ -1063,7 +1063,7 @@
|
|
|
1063
1063
|
[onChange]
|
|
1064
1064
|
);
|
|
1065
1065
|
if (typeof lastValue === "string" && typeof value === "number") {
|
|
1066
|
-
const re = new RegExp(
|
|
1066
|
+
const re = new RegExp(`^(${String(value).replace(".", "\\.")})?\\.?0*$`);
|
|
1067
1067
|
if (lastValue.match(re)) {
|
|
1068
1068
|
value = lastValue;
|
|
1069
1069
|
}
|
|
@@ -1180,20 +1180,23 @@
|
|
|
1180
1180
|
const { formData, onChange, registry } = this.props;
|
|
1181
1181
|
const newFormData = { ...formData };
|
|
1182
1182
|
let type = void 0;
|
|
1183
|
+
let defaultValue = void 0;
|
|
1183
1184
|
if (isObject(schema.additionalProperties)) {
|
|
1184
1185
|
type = schema.additionalProperties.type;
|
|
1186
|
+
defaultValue = schema.additionalProperties.default;
|
|
1185
1187
|
let apSchema = schema.additionalProperties;
|
|
1186
1188
|
if (utils.REF_KEY in apSchema) {
|
|
1187
1189
|
const { schemaUtils } = registry;
|
|
1188
1190
|
apSchema = schemaUtils.retrieveSchema({ $ref: apSchema[utils.REF_KEY] }, formData);
|
|
1189
1191
|
type = apSchema.type;
|
|
1192
|
+
defaultValue = apSchema.default;
|
|
1190
1193
|
}
|
|
1191
1194
|
if (!type && (utils.ANY_OF_KEY in apSchema || utils.ONE_OF_KEY in apSchema)) {
|
|
1192
1195
|
type = "object";
|
|
1193
1196
|
}
|
|
1194
1197
|
}
|
|
1195
1198
|
const newKey = this.getAvailableKey("newKey", newFormData);
|
|
1196
|
-
set(newFormData, newKey, this.getDefaultValue(type));
|
|
1199
|
+
set(newFormData, newKey, defaultValue ?? this.getDefaultValue(type));
|
|
1197
1200
|
onChange(newFormData);
|
|
1198
1201
|
};
|
|
1199
1202
|
}
|
|
@@ -1241,8 +1244,8 @@
|
|
|
1241
1244
|
idSchema,
|
|
1242
1245
|
name,
|
|
1243
1246
|
required = false,
|
|
1244
|
-
disabled
|
|
1245
|
-
readonly
|
|
1247
|
+
disabled,
|
|
1248
|
+
readonly,
|
|
1246
1249
|
hideError,
|
|
1247
1250
|
idPrefix,
|
|
1248
1251
|
idSeparator,
|
|
@@ -1413,11 +1416,11 @@
|
|
|
1413
1416
|
[fieldId, onChange]
|
|
1414
1417
|
);
|
|
1415
1418
|
const FieldComponent = getFieldComponent(schema, uiOptions, idSchema, registry);
|
|
1416
|
-
const disabled = Boolean(
|
|
1417
|
-
const readonly = Boolean(
|
|
1419
|
+
const disabled = Boolean(uiOptions.disabled ?? props.disabled);
|
|
1420
|
+
const readonly = Boolean(uiOptions.readonly ?? props.readonly ?? props.schema.readOnly ?? schema.readOnly);
|
|
1418
1421
|
const uiSchemaHideError = uiOptions.hideError;
|
|
1419
1422
|
const hideError = uiSchemaHideError === void 0 ? props.hideError : Boolean(uiSchemaHideError);
|
|
1420
|
-
const autofocus = Boolean(
|
|
1423
|
+
const autofocus = Boolean(uiOptions.autofocus ?? props.autofocus);
|
|
1421
1424
|
if (Object.keys(schema).length === 0) {
|
|
1422
1425
|
return null;
|
|
1423
1426
|
}
|
|
@@ -1915,9 +1918,12 @@
|
|
|
1915
1918
|
({ target: { value: value2 } }) => onChange(value2 === "" ? options.emptyValue : value2),
|
|
1916
1919
|
[onChange, options]
|
|
1917
1920
|
);
|
|
1918
|
-
const _onBlur = react.useCallback(
|
|
1921
|
+
const _onBlur = react.useCallback(
|
|
1922
|
+
({ target }) => onBlur(id, target && target.value),
|
|
1923
|
+
[onBlur, id]
|
|
1924
|
+
);
|
|
1919
1925
|
const _onFocus = react.useCallback(
|
|
1920
|
-
({ target
|
|
1926
|
+
({ target }) => onFocus(id, target && target.value),
|
|
1921
1927
|
[onFocus, id]
|
|
1922
1928
|
);
|
|
1923
1929
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
@@ -2241,7 +2247,7 @@
|
|
|
2241
2247
|
className: "form-control",
|
|
2242
2248
|
type: "text",
|
|
2243
2249
|
id: `${id}-key`,
|
|
2244
|
-
onBlur: (
|
|
2250
|
+
onBlur: ({ target }) => onKeyChange(target && target.value),
|
|
2245
2251
|
defaultValue: label
|
|
2246
2252
|
}
|
|
2247
2253
|
)
|
|
@@ -2497,11 +2503,11 @@
|
|
|
2497
2503
|
}) {
|
|
2498
2504
|
const checkboxesValues = Array.isArray(value) ? value : [value];
|
|
2499
2505
|
const handleBlur = react.useCallback(
|
|
2500
|
-
({ target
|
|
2506
|
+
({ target }) => onBlur(id, utils.enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue)),
|
|
2501
2507
|
[onBlur, id]
|
|
2502
2508
|
);
|
|
2503
2509
|
const handleFocus = react.useCallback(
|
|
2504
|
-
({ target
|
|
2510
|
+
({ target }) => onFocus(id, utils.enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue)),
|
|
2505
2511
|
[onFocus, id]
|
|
2506
2512
|
);
|
|
2507
2513
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "checkboxes", id, children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
|
|
@@ -2744,11 +2750,11 @@
|
|
|
2744
2750
|
}) {
|
|
2745
2751
|
const { enumOptions, enumDisabled, inline, emptyValue } = options;
|
|
2746
2752
|
const handleBlur = react.useCallback(
|
|
2747
|
-
({ target
|
|
2753
|
+
({ target }) => onBlur(id, utils.enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue)),
|
|
2748
2754
|
[onBlur, id]
|
|
2749
2755
|
);
|
|
2750
2756
|
const handleFocus = react.useCallback(
|
|
2751
|
-
({ target
|
|
2757
|
+
({ target }) => onFocus(id, utils.enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue)),
|
|
2752
2758
|
[onFocus, id]
|
|
2753
2759
|
);
|
|
2754
2760
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "field-radio-group", id, children: Array.isArray(enumOptions) && enumOptions.map((option, i) => {
|
|
@@ -2881,11 +2887,11 @@
|
|
|
2881
2887
|
[onChange, options.emptyValue]
|
|
2882
2888
|
);
|
|
2883
2889
|
const handleBlur = react.useCallback(
|
|
2884
|
-
({ target
|
|
2890
|
+
({ target }) => onBlur(id, target && target.value),
|
|
2885
2891
|
[onBlur, id]
|
|
2886
2892
|
);
|
|
2887
2893
|
const handleFocus = react.useCallback(
|
|
2888
|
-
({ target
|
|
2894
|
+
({ target }) => onFocus(id, target && target.value),
|
|
2889
2895
|
[id, onFocus]
|
|
2890
2896
|
);
|
|
2891
2897
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3497,8 +3503,8 @@
|
|
|
3497
3503
|
acceptcharset,
|
|
3498
3504
|
acceptCharset,
|
|
3499
3505
|
noHtml5Validate = false,
|
|
3500
|
-
disabled
|
|
3501
|
-
readonly
|
|
3506
|
+
disabled,
|
|
3507
|
+
readonly,
|
|
3502
3508
|
formContext,
|
|
3503
3509
|
showErrorList = "top",
|
|
3504
3510
|
_internalFormWrapper
|
package/dist/index.esm.js
CHANGED
|
@@ -1134,7 +1134,7 @@ function NumberField(props) {
|
|
|
1134
1134
|
[onChange]
|
|
1135
1135
|
);
|
|
1136
1136
|
if (typeof lastValue === "string" && typeof value === "number") {
|
|
1137
|
-
const re = new RegExp(
|
|
1137
|
+
const re = new RegExp(`^(${String(value).replace(".", "\\.")})?\\.?0*$`);
|
|
1138
1138
|
if (lastValue.match(re)) {
|
|
1139
1139
|
value = lastValue;
|
|
1140
1140
|
}
|
|
@@ -1272,20 +1272,23 @@ var ObjectField = class extends Component3 {
|
|
|
1272
1272
|
const { formData, onChange, registry } = this.props;
|
|
1273
1273
|
const newFormData = { ...formData };
|
|
1274
1274
|
let type = void 0;
|
|
1275
|
+
let defaultValue = void 0;
|
|
1275
1276
|
if (isObject3(schema.additionalProperties)) {
|
|
1276
1277
|
type = schema.additionalProperties.type;
|
|
1278
|
+
defaultValue = schema.additionalProperties.default;
|
|
1277
1279
|
let apSchema = schema.additionalProperties;
|
|
1278
1280
|
if (REF_KEY in apSchema) {
|
|
1279
1281
|
const { schemaUtils } = registry;
|
|
1280
1282
|
apSchema = schemaUtils.retrieveSchema({ $ref: apSchema[REF_KEY] }, formData);
|
|
1281
1283
|
type = apSchema.type;
|
|
1284
|
+
defaultValue = apSchema.default;
|
|
1282
1285
|
}
|
|
1283
1286
|
if (!type && (ANY_OF_KEY2 in apSchema || ONE_OF_KEY2 in apSchema)) {
|
|
1284
1287
|
type = "object";
|
|
1285
1288
|
}
|
|
1286
1289
|
}
|
|
1287
1290
|
const newKey = this.getAvailableKey("newKey", newFormData);
|
|
1288
|
-
set2(newFormData, newKey, this.getDefaultValue(type));
|
|
1291
|
+
set2(newFormData, newKey, defaultValue ?? this.getDefaultValue(type));
|
|
1289
1292
|
onChange(newFormData);
|
|
1290
1293
|
};
|
|
1291
1294
|
}
|
|
@@ -1333,8 +1336,8 @@ var ObjectField = class extends Component3 {
|
|
|
1333
1336
|
idSchema,
|
|
1334
1337
|
name,
|
|
1335
1338
|
required = false,
|
|
1336
|
-
disabled
|
|
1337
|
-
readonly
|
|
1339
|
+
disabled,
|
|
1340
|
+
readonly,
|
|
1338
1341
|
hideError,
|
|
1339
1342
|
idPrefix,
|
|
1340
1343
|
idSeparator,
|
|
@@ -1524,11 +1527,11 @@ function SchemaFieldRender(props) {
|
|
|
1524
1527
|
[fieldId, onChange]
|
|
1525
1528
|
);
|
|
1526
1529
|
const FieldComponent = getFieldComponent(schema, uiOptions, idSchema, registry);
|
|
1527
|
-
const disabled = Boolean(
|
|
1528
|
-
const readonly = Boolean(
|
|
1530
|
+
const disabled = Boolean(uiOptions.disabled ?? props.disabled);
|
|
1531
|
+
const readonly = Boolean(uiOptions.readonly ?? props.readonly ?? props.schema.readOnly ?? schema.readOnly);
|
|
1529
1532
|
const uiSchemaHideError = uiOptions.hideError;
|
|
1530
1533
|
const hideError = uiSchemaHideError === void 0 ? props.hideError : Boolean(uiSchemaHideError);
|
|
1531
|
-
const autofocus = Boolean(
|
|
1534
|
+
const autofocus = Boolean(uiOptions.autofocus ?? props.autofocus);
|
|
1532
1535
|
if (Object.keys(schema).length === 0) {
|
|
1533
1536
|
return null;
|
|
1534
1537
|
}
|
|
@@ -2073,9 +2076,12 @@ function BaseInputTemplate(props) {
|
|
|
2073
2076
|
({ target: { value: value2 } }) => onChange(value2 === "" ? options.emptyValue : value2),
|
|
2074
2077
|
[onChange, options]
|
|
2075
2078
|
);
|
|
2076
|
-
const _onBlur = useCallback3(
|
|
2079
|
+
const _onBlur = useCallback3(
|
|
2080
|
+
({ target }) => onBlur(id, target && target.value),
|
|
2081
|
+
[onBlur, id]
|
|
2082
|
+
);
|
|
2077
2083
|
const _onFocus = useCallback3(
|
|
2078
|
-
({ target
|
|
2084
|
+
({ target }) => onFocus(id, target && target.value),
|
|
2079
2085
|
[onFocus, id]
|
|
2080
2086
|
);
|
|
2081
2087
|
return /* @__PURE__ */ jsxs6(Fragment2, { children: [
|
|
@@ -2467,7 +2473,7 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
2467
2473
|
className: "form-control",
|
|
2468
2474
|
type: "text",
|
|
2469
2475
|
id: `${id}-key`,
|
|
2470
|
-
onBlur: (
|
|
2476
|
+
onBlur: ({ target }) => onKeyChange(target && target.value),
|
|
2471
2477
|
defaultValue: label
|
|
2472
2478
|
}
|
|
2473
2479
|
)
|
|
@@ -2761,11 +2767,11 @@ function CheckboxesWidget({
|
|
|
2761
2767
|
}) {
|
|
2762
2768
|
const checkboxesValues = Array.isArray(value) ? value : [value];
|
|
2763
2769
|
const handleBlur = useCallback6(
|
|
2764
|
-
({ target
|
|
2770
|
+
({ target }) => onBlur(id, enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue)),
|
|
2765
2771
|
[onBlur, id]
|
|
2766
2772
|
);
|
|
2767
2773
|
const handleFocus = useCallback6(
|
|
2768
|
-
({ target
|
|
2774
|
+
({ target }) => onFocus(id, enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue)),
|
|
2769
2775
|
[onFocus, id]
|
|
2770
2776
|
);
|
|
2771
2777
|
return /* @__PURE__ */ jsx29("div", { className: "checkboxes", id, children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
|
|
@@ -3056,11 +3062,11 @@ function RadioWidget({
|
|
|
3056
3062
|
}) {
|
|
3057
3063
|
const { enumOptions, enumDisabled, inline, emptyValue } = options;
|
|
3058
3064
|
const handleBlur = useCallback9(
|
|
3059
|
-
({ target
|
|
3065
|
+
({ target }) => onBlur(id, enumOptionsValueForIndex2(target && target.value, enumOptions, emptyValue)),
|
|
3060
3066
|
[onBlur, id]
|
|
3061
3067
|
);
|
|
3062
3068
|
const handleFocus = useCallback9(
|
|
3063
|
-
({ target
|
|
3069
|
+
({ target }) => onFocus(id, enumOptionsValueForIndex2(target && target.value, enumOptions, emptyValue)),
|
|
3064
3070
|
[onFocus, id]
|
|
3065
3071
|
);
|
|
3066
3072
|
return /* @__PURE__ */ jsx37("div", { className: "field-radio-group", id, children: Array.isArray(enumOptions) && enumOptions.map((option, i) => {
|
|
@@ -3210,11 +3216,11 @@ function TextareaWidget({
|
|
|
3210
3216
|
[onChange, options.emptyValue]
|
|
3211
3217
|
);
|
|
3212
3218
|
const handleBlur = useCallback11(
|
|
3213
|
-
({ target
|
|
3219
|
+
({ target }) => onBlur(id, target && target.value),
|
|
3214
3220
|
[onBlur, id]
|
|
3215
3221
|
);
|
|
3216
3222
|
const handleFocus = useCallback11(
|
|
3217
|
-
({ target
|
|
3223
|
+
({ target }) => onFocus(id, target && target.value),
|
|
3218
3224
|
[id, onFocus]
|
|
3219
3225
|
);
|
|
3220
3226
|
return /* @__PURE__ */ jsx40(
|
|
@@ -3846,8 +3852,8 @@ var Form = class extends Component5 {
|
|
|
3846
3852
|
acceptcharset,
|
|
3847
3853
|
acceptCharset,
|
|
3848
3854
|
noHtml5Validate = false,
|
|
3849
|
-
disabled
|
|
3850
|
-
readonly
|
|
3855
|
+
disabled,
|
|
3856
|
+
readonly,
|
|
3851
3857
|
formContext,
|
|
3852
3858
|
showErrorList = "top",
|
|
3853
3859
|
_internalFormWrapper
|