@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/index.js
CHANGED
|
@@ -1132,7 +1132,7 @@ function NumberField(props) {
|
|
|
1132
1132
|
[onChange]
|
|
1133
1133
|
);
|
|
1134
1134
|
if (typeof lastValue === "string" && typeof value === "number") {
|
|
1135
|
-
const re = new RegExp(
|
|
1135
|
+
const re = new RegExp(`^(${String(value).replace(".", "\\.")})?\\.?0*$`);
|
|
1136
1136
|
if (lastValue.match(re)) {
|
|
1137
1137
|
value = lastValue;
|
|
1138
1138
|
}
|
|
@@ -1260,20 +1260,23 @@ var ObjectField = class extends import_react4.Component {
|
|
|
1260
1260
|
const { formData, onChange, registry } = this.props;
|
|
1261
1261
|
const newFormData = { ...formData };
|
|
1262
1262
|
let type = void 0;
|
|
1263
|
+
let defaultValue = void 0;
|
|
1263
1264
|
if ((0, import_isObject3.default)(schema.additionalProperties)) {
|
|
1264
1265
|
type = schema.additionalProperties.type;
|
|
1266
|
+
defaultValue = schema.additionalProperties.default;
|
|
1265
1267
|
let apSchema = schema.additionalProperties;
|
|
1266
1268
|
if (import_utils5.REF_KEY in apSchema) {
|
|
1267
1269
|
const { schemaUtils } = registry;
|
|
1268
1270
|
apSchema = schemaUtils.retrieveSchema({ $ref: apSchema[import_utils5.REF_KEY] }, formData);
|
|
1269
1271
|
type = apSchema.type;
|
|
1272
|
+
defaultValue = apSchema.default;
|
|
1270
1273
|
}
|
|
1271
1274
|
if (!type && (import_utils5.ANY_OF_KEY in apSchema || import_utils5.ONE_OF_KEY in apSchema)) {
|
|
1272
1275
|
type = "object";
|
|
1273
1276
|
}
|
|
1274
1277
|
}
|
|
1275
1278
|
const newKey = this.getAvailableKey("newKey", newFormData);
|
|
1276
|
-
(0, import_set2.default)(newFormData, newKey, this.getDefaultValue(type));
|
|
1279
|
+
(0, import_set2.default)(newFormData, newKey, defaultValue ?? this.getDefaultValue(type));
|
|
1277
1280
|
onChange(newFormData);
|
|
1278
1281
|
};
|
|
1279
1282
|
}
|
|
@@ -1321,8 +1324,8 @@ var ObjectField = class extends import_react4.Component {
|
|
|
1321
1324
|
idSchema,
|
|
1322
1325
|
name,
|
|
1323
1326
|
required = false,
|
|
1324
|
-
disabled
|
|
1325
|
-
readonly
|
|
1327
|
+
disabled,
|
|
1328
|
+
readonly,
|
|
1326
1329
|
hideError,
|
|
1327
1330
|
idPrefix,
|
|
1328
1331
|
idSeparator,
|
|
@@ -1501,11 +1504,11 @@ function SchemaFieldRender(props) {
|
|
|
1501
1504
|
[fieldId, onChange]
|
|
1502
1505
|
);
|
|
1503
1506
|
const FieldComponent = getFieldComponent(schema, uiOptions, idSchema, registry);
|
|
1504
|
-
const disabled = Boolean(
|
|
1505
|
-
const readonly = Boolean(
|
|
1507
|
+
const disabled = Boolean(uiOptions.disabled ?? props.disabled);
|
|
1508
|
+
const readonly = Boolean(uiOptions.readonly ?? props.readonly ?? props.schema.readOnly ?? schema.readOnly);
|
|
1506
1509
|
const uiSchemaHideError = uiOptions.hideError;
|
|
1507
1510
|
const hideError = uiSchemaHideError === void 0 ? props.hideError : Boolean(uiSchemaHideError);
|
|
1508
|
-
const autofocus = Boolean(
|
|
1511
|
+
const autofocus = Boolean(uiOptions.autofocus ?? props.autofocus);
|
|
1509
1512
|
if (Object.keys(schema).length === 0) {
|
|
1510
1513
|
return null;
|
|
1511
1514
|
}
|
|
@@ -2030,9 +2033,12 @@ function BaseInputTemplate(props) {
|
|
|
2030
2033
|
({ target: { value: value2 } }) => onChange(value2 === "" ? options.emptyValue : value2),
|
|
2031
2034
|
[onChange, options]
|
|
2032
2035
|
);
|
|
2033
|
-
const _onBlur = (0, import_react7.useCallback)(
|
|
2036
|
+
const _onBlur = (0, import_react7.useCallback)(
|
|
2037
|
+
({ target }) => onBlur(id, target && target.value),
|
|
2038
|
+
[onBlur, id]
|
|
2039
|
+
);
|
|
2034
2040
|
const _onFocus = (0, import_react7.useCallback)(
|
|
2035
|
-
({ target
|
|
2041
|
+
({ target }) => onFocus(id, target && target.value),
|
|
2036
2042
|
[onFocus, id]
|
|
2037
2043
|
);
|
|
2038
2044
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
@@ -2410,7 +2416,7 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
2410
2416
|
className: "form-control",
|
|
2411
2417
|
type: "text",
|
|
2412
2418
|
id: `${id}-key`,
|
|
2413
|
-
onBlur: (
|
|
2419
|
+
onBlur: ({ target }) => onKeyChange(target && target.value),
|
|
2414
2420
|
defaultValue: label
|
|
2415
2421
|
}
|
|
2416
2422
|
)
|
|
@@ -2684,11 +2690,11 @@ function CheckboxesWidget({
|
|
|
2684
2690
|
}) {
|
|
2685
2691
|
const checkboxesValues = Array.isArray(value) ? value : [value];
|
|
2686
2692
|
const handleBlur = (0, import_react10.useCallback)(
|
|
2687
|
-
({ target
|
|
2693
|
+
({ target }) => onBlur(id, (0, import_utils24.enumOptionsValueForIndex)(target && target.value, enumOptions, emptyValue)),
|
|
2688
2694
|
[onBlur, id]
|
|
2689
2695
|
);
|
|
2690
2696
|
const handleFocus = (0, import_react10.useCallback)(
|
|
2691
|
-
({ target
|
|
2697
|
+
({ target }) => onFocus(id, (0, import_utils24.enumOptionsValueForIndex)(target && target.value, enumOptions, emptyValue)),
|
|
2692
2698
|
[onFocus, id]
|
|
2693
2699
|
);
|
|
2694
2700
|
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "checkboxes", id, children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
|
|
@@ -2966,11 +2972,11 @@ function RadioWidget({
|
|
|
2966
2972
|
}) {
|
|
2967
2973
|
const { enumOptions, enumDisabled, inline, emptyValue } = options;
|
|
2968
2974
|
const handleBlur = (0, import_react13.useCallback)(
|
|
2969
|
-
({ target
|
|
2975
|
+
({ target }) => onBlur(id, (0, import_utils31.enumOptionsValueForIndex)(target && target.value, enumOptions, emptyValue)),
|
|
2970
2976
|
[onBlur, id]
|
|
2971
2977
|
);
|
|
2972
2978
|
const handleFocus = (0, import_react13.useCallback)(
|
|
2973
|
-
({ target
|
|
2979
|
+
({ target }) => onFocus(id, (0, import_utils31.enumOptionsValueForIndex)(target && target.value, enumOptions, emptyValue)),
|
|
2974
2980
|
[onFocus, id]
|
|
2975
2981
|
);
|
|
2976
2982
|
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "field-radio-group", id, children: Array.isArray(enumOptions) && enumOptions.map((option, i) => {
|
|
@@ -3116,11 +3122,11 @@ function TextareaWidget({
|
|
|
3116
3122
|
[onChange, options.emptyValue]
|
|
3117
3123
|
);
|
|
3118
3124
|
const handleBlur = (0, import_react15.useCallback)(
|
|
3119
|
-
({ target
|
|
3125
|
+
({ target }) => onBlur(id, target && target.value),
|
|
3120
3126
|
[onBlur, id]
|
|
3121
3127
|
);
|
|
3122
3128
|
const handleFocus = (0, import_react15.useCallback)(
|
|
3123
|
-
({ target
|
|
3129
|
+
({ target }) => onFocus(id, target && target.value),
|
|
3124
3130
|
[id, onFocus]
|
|
3125
3131
|
);
|
|
3126
3132
|
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
@@ -3752,8 +3758,8 @@ var Form = class extends import_react17.Component {
|
|
|
3752
3758
|
acceptcharset,
|
|
3753
3759
|
acceptCharset,
|
|
3754
3760
|
noHtml5Validate = false,
|
|
3755
|
-
disabled
|
|
3756
|
-
readonly
|
|
3761
|
+
disabled,
|
|
3762
|
+
readonly,
|
|
3757
3763
|
formContext,
|
|
3758
3764
|
showErrorList = "top",
|
|
3759
3765
|
_internalFormWrapper
|