@rjsf/core 6.5.2 → 6.6.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/core.umd.js +267 -282
- package/dist/index.cjs +357 -372
- package/dist/index.cjs.map +4 -4
- package/dist/index.esm.js +335 -348
- package/dist/index.esm.js.map +4 -4
- package/lib/components/Form.d.ts +3 -4
- package/lib/components/Form.d.ts.map +1 -1
- package/lib/components/Form.js +33 -26
- package/lib/components/RichDescription.js +1 -1
- package/lib/components/RichHelp.js +1 -1
- package/lib/components/fields/FallbackField.d.ts.map +1 -1
- package/lib/components/fields/FallbackField.js +1 -1
- package/lib/components/fields/LayoutGridField.js +1 -1
- package/lib/components/fields/MultiSchemaField.d.ts.map +1 -1
- package/lib/components/fields/MultiSchemaField.js +1 -1
- package/lib/components/fields/ObjectField.js +1 -1
- package/lib/components/fields/SchemaField.d.ts.map +1 -1
- package/lib/components/fields/SchemaField.js +8 -3
- package/lib/components/fields/index.js +1 -1
- package/lib/components/templates/ButtonTemplates/index.js +1 -1
- package/lib/components/templates/FieldHelpTemplate.d.ts.map +1 -1
- package/lib/components/templates/UnsupportedField.js +1 -1
- package/lib/components/templates/index.js +2 -2
- package/lib/components/widgets/FileWidget.d.ts.map +1 -1
- package/lib/components/widgets/FileWidget.js +3 -2
- package/lib/components/widgets/index.js +4 -4
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/withTheme.d.ts +1 -1
- package/lib/withTheme.d.ts.map +1 -1
- package/package.json +17 -17
- package/src/components/Form.tsx +37 -53
- package/src/components/RichDescription.tsx +1 -1
- package/src/components/RichHelp.tsx +1 -1
- package/src/components/fields/FallbackField.tsx +1 -1
- package/src/components/fields/LayoutGridField.tsx +1 -1
- package/src/components/fields/MultiSchemaField.tsx +3 -3
- package/src/components/fields/ObjectField.tsx +1 -1
- package/src/components/fields/SchemaField.tsx +11 -2
- package/src/components/fields/index.ts +1 -1
- package/src/components/templates/ButtonTemplates/index.ts +1 -1
- package/src/components/templates/FieldHelpTemplate.tsx +1 -0
- package/src/components/templates/UnsupportedField.tsx +1 -1
- package/src/components/templates/index.ts +2 -2
- package/src/components/widgets/FileWidget.tsx +3 -2
- package/src/components/widgets/index.ts +4 -4
- package/src/index.ts +1 -1
- package/src/tsconfig.json +0 -1
- package/src/withTheme.tsx +2 -1
package/dist/core.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@rjsf/utils'), require('lodash/cloneDeep'), require('lodash/get'), require('lodash/isEmpty'), require('lodash/pick'), require('lodash/set'), require('lodash/toPath'), require('lodash/unset'), require('lodash/isObject'), require('lodash/uniqueId'), require('react/jsx-runtime'), require('lodash/each'), require('lodash/flatten'), require('lodash/has'), require('lodash/includes'), require('lodash/intersection'), require('lodash/
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'react', '@rjsf/utils', 'lodash/cloneDeep', 'lodash/get', 'lodash/isEmpty', 'lodash/pick', 'lodash/set', 'lodash/toPath', 'lodash/unset', 'lodash/isObject', 'lodash/uniqueId', 'react/jsx-runtime', 'lodash/each', 'lodash/flatten', 'lodash/has', 'lodash/includes', 'lodash/intersection', 'lodash/
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.JSONSchemaForm = {}, global.react, global.utils, global._cloneDeep, global.get, global.isEmpty, global._pick, global.set, global._toPath, global._unset, global.isObject, global.uniqueId, global.jsxRuntime, global.each, global.flatten, global.has, global.includes, global.intersection, global.
|
|
5
|
-
})(this, (function (exports, react, utils, _cloneDeep, get, isEmpty, _pick, set, _toPath, _unset, isObject, uniqueId, jsxRuntime, each, flatten, has, includes, intersection,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@rjsf/utils'), require('lodash/cloneDeep'), require('lodash/get'), require('lodash/isEmpty'), require('lodash/pick'), require('lodash/set'), require('lodash/toPath'), require('lodash/unset'), require('lodash/isObject'), require('lodash/uniqueId'), require('react/jsx-runtime'), require('lodash/each'), require('lodash/flatten'), require('lodash/has'), require('lodash/includes'), require('lodash/intersection'), require('lodash/isEqual'), require('lodash/isFunction'), require('lodash/isPlainObject'), require('lodash/isString'), require('lodash/isUndefined'), require('lodash/last'), require('lodash/noop'), require('lodash/omit'), require('markdown-to-jsx'), require('markdown-to-jsx/react'), require('@rjsf/validator-ajv8')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'react', '@rjsf/utils', 'lodash/cloneDeep', 'lodash/get', 'lodash/isEmpty', 'lodash/pick', 'lodash/set', 'lodash/toPath', 'lodash/unset', 'lodash/isObject', 'lodash/uniqueId', 'react/jsx-runtime', 'lodash/each', 'lodash/flatten', 'lodash/has', 'lodash/includes', 'lodash/intersection', 'lodash/isEqual', 'lodash/isFunction', 'lodash/isPlainObject', 'lodash/isString', 'lodash/isUndefined', 'lodash/last', 'lodash/noop', 'lodash/omit', 'markdown-to-jsx', 'markdown-to-jsx/react', '@rjsf/validator-ajv8'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.JSONSchemaForm = {}, global.react$1, global.utils, global._cloneDeep, global.get, global.isEmpty, global._pick, global.set, global._toPath, global._unset, global.isObject, global.uniqueId, global.jsxRuntime, global.each, global.flatten, global.has, global.includes, global.intersection, global.isEqual, global.isFunction, global.isPlainObject, global.isString, global.isUndefined, global.last, global.noop, global.omit3, global.markdownToJsx, global.react, global.validator));
|
|
5
|
+
})(this, (function (exports, react$1, utils, _cloneDeep, get, isEmpty, _pick, set, _toPath, _unset, isObject, uniqueId, jsxRuntime, each, flatten, has, includes, intersection, isEqual, isFunction, isPlainObject, isString, isUndefined, last, noop, omit3, markdownToJsx, react, validator) { 'use strict';
|
|
6
6
|
|
|
7
7
|
// src/components/Form.tsx
|
|
8
8
|
function generateRowId() {
|
|
@@ -271,31 +271,31 @@
|
|
|
271
271
|
toolbar: false
|
|
272
272
|
};
|
|
273
273
|
has4.toolbar = Object.keys(has4).some((key) => has4[key]);
|
|
274
|
-
const onAddItem = react.useCallback(
|
|
274
|
+
const onAddItem = react$1.useCallback(
|
|
275
275
|
(event) => {
|
|
276
276
|
handleAddItem(event, index + 1);
|
|
277
277
|
},
|
|
278
278
|
[handleAddItem, index]
|
|
279
279
|
);
|
|
280
|
-
const onCopyItem = react.useCallback(
|
|
280
|
+
const onCopyItem = react$1.useCallback(
|
|
281
281
|
(event) => {
|
|
282
282
|
handleCopyItem(event, index);
|
|
283
283
|
},
|
|
284
284
|
[handleCopyItem, index]
|
|
285
285
|
);
|
|
286
|
-
const onRemoveItem = react.useCallback(
|
|
286
|
+
const onRemoveItem = react$1.useCallback(
|
|
287
287
|
(event) => {
|
|
288
288
|
handleRemoveItem(event, index);
|
|
289
289
|
},
|
|
290
290
|
[handleRemoveItem, index]
|
|
291
291
|
);
|
|
292
|
-
const onMoveUpItem = react.useCallback(
|
|
292
|
+
const onMoveUpItem = react$1.useCallback(
|
|
293
293
|
(event) => {
|
|
294
294
|
handleReorderItems(event, index, index - 1);
|
|
295
295
|
},
|
|
296
296
|
[handleReorderItems, index]
|
|
297
297
|
);
|
|
298
|
-
const onMoveDownItem = react.useCallback(
|
|
298
|
+
const onMoveDownItem = react$1.useCallback(
|
|
299
299
|
(event) => {
|
|
300
300
|
handleReorderItems(event, index, index + 1);
|
|
301
301
|
},
|
|
@@ -576,8 +576,8 @@
|
|
|
576
576
|
return /* @__PURE__ */ jsxRuntime.jsx(Template, { ...arrayProps });
|
|
577
577
|
}
|
|
578
578
|
function useKeyedFormData(formData = []) {
|
|
579
|
-
const newHash = react.useMemo(() => utils.hashObject(formData), [formData]);
|
|
580
|
-
const [state, setState] = react.useState(() => ({
|
|
579
|
+
const newHash = react$1.useMemo(() => utils.hashObject(formData), [formData]);
|
|
580
|
+
const [state, setState] = react$1.useState(() => ({
|
|
581
581
|
formDataHash: newHash,
|
|
582
582
|
keyedFormData: generateKeyedFormData(formData)
|
|
583
583
|
}));
|
|
@@ -592,7 +592,7 @@
|
|
|
592
592
|
formDataHash = newHash;
|
|
593
593
|
setState({ formDataHash, keyedFormData });
|
|
594
594
|
}
|
|
595
|
-
const updateKeyedFormData = react.useCallback((newData) => {
|
|
595
|
+
const updateKeyedFormData = react$1.useCallback((newData) => {
|
|
596
596
|
const plainFormData = keyedToPlainFormData(newData);
|
|
597
597
|
const newHash2 = utils.hashObject(plainFormData);
|
|
598
598
|
setState({ formDataHash: newHash2, keyedFormData: newData });
|
|
@@ -605,7 +605,7 @@
|
|
|
605
605
|
const { globalFormOptions, schemaUtils, translateString } = registry;
|
|
606
606
|
const { keyedFormData, updateKeyedFormData } = useKeyedFormData(formData);
|
|
607
607
|
const childFieldPathId = props.childFieldPathId ?? fieldPathId;
|
|
608
|
-
const handleAddItem = react.useCallback(
|
|
608
|
+
const handleAddItem = react$1.useCallback(
|
|
609
609
|
(event, index) => {
|
|
610
610
|
if (event) {
|
|
611
611
|
event.preventDefault();
|
|
@@ -636,7 +636,7 @@
|
|
|
636
636
|
},
|
|
637
637
|
[keyedFormData, registry, schema, onChange, updateKeyedFormData, errorSchema, childFieldPathId]
|
|
638
638
|
);
|
|
639
|
-
const handleCopyItem = react.useCallback(
|
|
639
|
+
const handleCopyItem = react$1.useCallback(
|
|
640
640
|
(event, index) => {
|
|
641
641
|
if (event) {
|
|
642
642
|
event.preventDefault();
|
|
@@ -667,7 +667,7 @@
|
|
|
667
667
|
},
|
|
668
668
|
[keyedFormData, onChange, updateKeyedFormData, errorSchema, childFieldPathId]
|
|
669
669
|
);
|
|
670
|
-
const handleRemoveItem = react.useCallback(
|
|
670
|
+
const handleRemoveItem = react$1.useCallback(
|
|
671
671
|
(event, index) => {
|
|
672
672
|
if (event) {
|
|
673
673
|
event.preventDefault();
|
|
@@ -689,7 +689,7 @@
|
|
|
689
689
|
},
|
|
690
690
|
[keyedFormData, onChange, updateKeyedFormData, errorSchema, childFieldPathId]
|
|
691
691
|
);
|
|
692
|
-
const handleReorderItems = react.useCallback(
|
|
692
|
+
const handleReorderItems = react$1.useCallback(
|
|
693
693
|
(event, index, newIndex) => {
|
|
694
694
|
if (event) {
|
|
695
695
|
event.preventDefault();
|
|
@@ -720,7 +720,7 @@
|
|
|
720
720
|
},
|
|
721
721
|
[keyedFormData, onChange, updateKeyedFormData, errorSchema, childFieldPathId]
|
|
722
722
|
);
|
|
723
|
-
const handleChange = react.useCallback(
|
|
723
|
+
const handleChange = react$1.useCallback(
|
|
724
724
|
(value, path, newErrorSchema, id) => {
|
|
725
725
|
const lastPathIsItemIndex = typeof path.at(-1) === "number";
|
|
726
726
|
onChange(
|
|
@@ -735,7 +735,7 @@
|
|
|
735
735
|
},
|
|
736
736
|
[onChange]
|
|
737
737
|
);
|
|
738
|
-
const onSelectChange = react.useCallback(
|
|
738
|
+
const onSelectChange = react$1.useCallback(
|
|
739
739
|
(value) => {
|
|
740
740
|
onChange(value, childFieldPathId.path, void 0, childFieldPathId?.[utils.ID_KEY]);
|
|
741
741
|
},
|
|
@@ -859,7 +859,7 @@
|
|
|
859
859
|
enumOptions = utils.optionsList({ enum: enums }, uiSchema);
|
|
860
860
|
}
|
|
861
861
|
}
|
|
862
|
-
const onWidgetChange = react.useCallback(
|
|
862
|
+
const onWidgetChange = react$1.useCallback(
|
|
863
863
|
(value, errorSchema, id) => {
|
|
864
864
|
return onChange(value, fieldPathId.path, errorSchema, id);
|
|
865
865
|
},
|
|
@@ -942,13 +942,13 @@
|
|
|
942
942
|
errorSchema
|
|
943
943
|
} = props;
|
|
944
944
|
const { translateString, fields: fields2, globalFormOptions } = registry;
|
|
945
|
-
const [type, setType] = react.useState(getTypeOfFormData(formData));
|
|
945
|
+
const [type, setType] = react$1.useState(getTypeOfFormData(formData));
|
|
946
946
|
const uiOptions = utils.getUiOptions(uiSchema);
|
|
947
947
|
const typeSelectorInnerFieldPathId = utils.useDeepCompareMemo(
|
|
948
948
|
utils.toFieldPathId("__internal_type_selector", globalFormOptions, fieldPathId)
|
|
949
949
|
);
|
|
950
950
|
const schemaTitle = translateString(utils.TranslatableString.Type);
|
|
951
|
-
const typesOptionSchema = react.useMemo(() => getFallbackTypeSelectionSchema(schemaTitle), [schemaTitle]);
|
|
951
|
+
const typesOptionSchema = react$1.useMemo(() => getFallbackTypeSelectionSchema(schemaTitle), [schemaTitle]);
|
|
952
952
|
const onTypeChange = (newType) => {
|
|
953
953
|
if (newType != null) {
|
|
954
954
|
setType(newType);
|
|
@@ -1191,7 +1191,7 @@
|
|
|
1191
1191
|
const { registry, schema: rawSchema, formData } = layoutGridFieldProps;
|
|
1192
1192
|
const { schemaUtils } = registry;
|
|
1193
1193
|
const schema = schemaUtils.retrieveSchema(rawSchema, formData);
|
|
1194
|
-
return childrenLayoutGridSchemaId.map((layoutGridSchema) => /* @__PURE__ */ react.createElement(
|
|
1194
|
+
return childrenLayoutGridSchemaId.map((layoutGridSchema) => /* @__PURE__ */ react$1.createElement(
|
|
1195
1195
|
LayoutGridField,
|
|
1196
1196
|
{
|
|
1197
1197
|
...layoutGridFieldProps,
|
|
@@ -1418,7 +1418,7 @@
|
|
|
1418
1418
|
hideError = false
|
|
1419
1419
|
} = props;
|
|
1420
1420
|
const { widgets: widgets2, schemaUtils, globalUiOptions } = registry;
|
|
1421
|
-
const [enumOptions, setEnumOptions] = react.useState(computeEnumOptions(schema, options, schemaUtils, uiSchema, formData));
|
|
1421
|
+
const [enumOptions, setEnumOptions] = react$1.useState(computeEnumOptions(schema, options, schemaUtils, uiSchema, formData));
|
|
1422
1422
|
const id = get(fieldPathId, utils.ID_KEY);
|
|
1423
1423
|
const discriminator = utils.getDiscriminatorFieldFromSchema(schema);
|
|
1424
1424
|
const FieldErrorTemplate2 = utils.getTemplate("FieldErrorTemplate", registry, options);
|
|
@@ -1427,7 +1427,7 @@
|
|
|
1427
1427
|
const optionsHash = utils.hashObject(options);
|
|
1428
1428
|
const uiSchemaHash = uiSchema ? utils.hashObject(uiSchema) : "";
|
|
1429
1429
|
const formDataHash = formData ? utils.hashObject(formData) : "";
|
|
1430
|
-
react.useEffect(() => {
|
|
1430
|
+
react$1.useEffect(() => {
|
|
1431
1431
|
setEnumOptions(computeEnumOptions(schema, options, schemaUtils, uiSchema, formData));
|
|
1432
1432
|
}, [schemaHash, optionsHash, schemaUtils, uiSchemaHash, formDataHash]);
|
|
1433
1433
|
const {
|
|
@@ -1512,7 +1512,7 @@
|
|
|
1512
1512
|
}
|
|
1513
1513
|
);
|
|
1514
1514
|
}
|
|
1515
|
-
var AnyOfField = class extends react.Component {
|
|
1515
|
+
var AnyOfField = class extends react$1.Component {
|
|
1516
1516
|
/** Constructs an `AnyOfField` with the given `props` to initialize the initially selected option in state
|
|
1517
1517
|
*
|
|
1518
1518
|
* @param props - The `FieldProps` for this template
|
|
@@ -1710,14 +1710,24 @@
|
|
|
1710
1710
|
}
|
|
1711
1711
|
};
|
|
1712
1712
|
var MultiSchemaField_default = AnyOfField;
|
|
1713
|
+
function NullField(props) {
|
|
1714
|
+
const { formData, onChange, fieldPathId } = props;
|
|
1715
|
+
react$1.useEffect(() => {
|
|
1716
|
+
if (formData === void 0) {
|
|
1717
|
+
onChange(null, fieldPathId.path);
|
|
1718
|
+
}
|
|
1719
|
+
}, [fieldPathId, formData, onChange]);
|
|
1720
|
+
return null;
|
|
1721
|
+
}
|
|
1722
|
+
var NullField_default = NullField;
|
|
1713
1723
|
var trailingCharMatcherWithPrefix = /\.([0-9]*0)*$/;
|
|
1714
1724
|
var trailingCharMatcher = /[0.]0*$/;
|
|
1715
1725
|
function NumberField(props) {
|
|
1716
1726
|
const { registry, onChange, formData, value: initialValue } = props;
|
|
1717
|
-
const [lastValue, setLastValue] = react.useState(initialValue);
|
|
1727
|
+
const [lastValue, setLastValue] = react$1.useState(initialValue);
|
|
1718
1728
|
const { StringField: StringField2 } = registry.fields;
|
|
1719
1729
|
let value = formData;
|
|
1720
|
-
const handleChange = react.useCallback(
|
|
1730
|
+
const handleChange = react$1.useCallback(
|
|
1721
1731
|
(value2, path, errorSchema, id) => {
|
|
1722
1732
|
setLastValue(value2);
|
|
1723
1733
|
if (`${value2}`.charAt(0) === ".") {
|
|
@@ -1739,8 +1749,8 @@
|
|
|
1739
1749
|
var NumberField_default = NumberField;
|
|
1740
1750
|
|
|
1741
1751
|
// src/components/constants.ts
|
|
1742
|
-
var ADDITIONAL_PROPERTY_KEY_REMOVE = Symbol("remove-this-key");
|
|
1743
|
-
var IS_RESET = Symbol("reset");
|
|
1752
|
+
var ADDITIONAL_PROPERTY_KEY_REMOVE = /* @__PURE__ */ Symbol("remove-this-key");
|
|
1753
|
+
var IS_RESET = /* @__PURE__ */ Symbol("reset");
|
|
1744
1754
|
function isRequired(schema, name) {
|
|
1745
1755
|
return Array.isArray(schema.required) && schema.required.indexOf(name) !== -1;
|
|
1746
1756
|
}
|
|
@@ -1781,13 +1791,13 @@
|
|
|
1781
1791
|
handleRemoveProperty,
|
|
1782
1792
|
addedByAdditionalProperties
|
|
1783
1793
|
} = props;
|
|
1784
|
-
const [wasPropertyKeyModified, setWasPropertyKeyModified] = react.useState(false);
|
|
1794
|
+
const [wasPropertyKeyModified, setWasPropertyKeyModified] = react$1.useState(false);
|
|
1785
1795
|
const { globalFormOptions, fields: fields2 } = registry;
|
|
1786
1796
|
const { SchemaField: SchemaField2 } = fields2;
|
|
1787
1797
|
const innerFieldIdPathId = utils.useDeepCompareMemo(
|
|
1788
1798
|
utils.toFieldPathId(propertyName, globalFormOptions, fieldPathId.path)
|
|
1789
1799
|
);
|
|
1790
|
-
const onPropertyChange = react.useCallback(
|
|
1800
|
+
const onPropertyChange = react$1.useCallback(
|
|
1791
1801
|
(value, path, newErrorSchema, id) => {
|
|
1792
1802
|
if (value === void 0 && addedByAdditionalProperties) {
|
|
1793
1803
|
value = "";
|
|
@@ -1796,7 +1806,7 @@
|
|
|
1796
1806
|
},
|
|
1797
1807
|
[onChange, addedByAdditionalProperties]
|
|
1798
1808
|
);
|
|
1799
|
-
const onKeyRename = react.useCallback(
|
|
1809
|
+
const onKeyRename = react$1.useCallback(
|
|
1800
1810
|
(value) => {
|
|
1801
1811
|
if (propertyName !== value) {
|
|
1802
1812
|
setWasPropertyKeyModified(true);
|
|
@@ -1805,7 +1815,7 @@
|
|
|
1805
1815
|
},
|
|
1806
1816
|
[propertyName, handleKeyRename]
|
|
1807
1817
|
);
|
|
1808
|
-
const onKeyRenameBlur = react.useCallback(
|
|
1818
|
+
const onKeyRenameBlur = react$1.useCallback(
|
|
1809
1819
|
(event) => {
|
|
1810
1820
|
const {
|
|
1811
1821
|
target: { value }
|
|
@@ -1814,7 +1824,7 @@
|
|
|
1814
1824
|
},
|
|
1815
1825
|
[onKeyRename]
|
|
1816
1826
|
);
|
|
1817
|
-
const onRemoveProperty = react.useCallback(() => {
|
|
1827
|
+
const onRemoveProperty = react$1.useCallback(() => {
|
|
1818
1828
|
handleRemoveProperty(propertyName);
|
|
1819
1829
|
}, [propertyName, handleRemoveProperty]);
|
|
1820
1830
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1861,19 +1871,19 @@
|
|
|
1861
1871
|
} = props;
|
|
1862
1872
|
const { fields: fields2, schemaUtils, translateString, globalUiOptions } = registry;
|
|
1863
1873
|
const { OptionalDataControlsField: OptionalDataControlsField2 } = fields2;
|
|
1864
|
-
const formDataRef = react.useRef(formData);
|
|
1874
|
+
const formDataRef = react$1.useRef(formData);
|
|
1865
1875
|
formDataRef.current = formData;
|
|
1866
1876
|
const schema = schemaUtils.retrieveSchema(rawSchema, formData, true);
|
|
1867
1877
|
const uiOptions = utils.getUiOptions(uiSchema, globalUiOptions);
|
|
1868
1878
|
const { properties: schemaProperties = {} } = schema;
|
|
1869
1879
|
const childFieldPathId = props.childFieldPathId ?? fieldPathId;
|
|
1870
|
-
const lastRenamedProperty = react.useRef({ previousKey: "", currentKey: void 0 });
|
|
1880
|
+
const lastRenamedProperty = react$1.useRef({ previousKey: "", currentKey: void 0 });
|
|
1871
1881
|
const templateTitle = uiOptions.title ?? schema.title ?? title ?? name;
|
|
1872
1882
|
const description = uiOptions.description ?? schema.description;
|
|
1873
1883
|
const renderOptionalField = utils.shouldRenderOptionalField(registry, schema, required, uiSchema);
|
|
1874
1884
|
const hasFormData = utils.isFormDataAvailable(formData);
|
|
1875
1885
|
let orderedProperties = [];
|
|
1876
|
-
const getAvailableKey = react.useCallback(
|
|
1886
|
+
const getAvailableKey = react$1.useCallback(
|
|
1877
1887
|
(preferredKey, formData2) => {
|
|
1878
1888
|
const { duplicateKeySuffixSeparator = "-" } = utils.getUiOptions(uiSchema, globalUiOptions);
|
|
1879
1889
|
let index = 0;
|
|
@@ -1885,7 +1895,7 @@
|
|
|
1885
1895
|
},
|
|
1886
1896
|
[uiSchema, globalUiOptions]
|
|
1887
1897
|
);
|
|
1888
|
-
const onAddProperty = react.useCallback(() => {
|
|
1898
|
+
const onAddProperty = react$1.useCallback(() => {
|
|
1889
1899
|
if (!(schema.additionalProperties || schema.patternProperties)) {
|
|
1890
1900
|
return;
|
|
1891
1901
|
}
|
|
@@ -1923,7 +1933,7 @@
|
|
|
1923
1933
|
}
|
|
1924
1934
|
onChange(newFormData, childFieldPathId.path);
|
|
1925
1935
|
}, [formData, onChange, registry, childFieldPathId, getAvailableKey, schema]);
|
|
1926
|
-
const handleKeyRename = react.useCallback(
|
|
1936
|
+
const handleKeyRename = react$1.useCallback(
|
|
1927
1937
|
(oldKey, newKey) => {
|
|
1928
1938
|
if (oldKey !== newKey) {
|
|
1929
1939
|
const currentFormData = formDataRef.current;
|
|
@@ -1947,13 +1957,13 @@
|
|
|
1947
1957
|
},
|
|
1948
1958
|
[onChange, childFieldPathId, getAvailableKey]
|
|
1949
1959
|
);
|
|
1950
|
-
const handleRemoveProperty = react.useCallback(
|
|
1960
|
+
const handleRemoveProperty = react$1.useCallback(
|
|
1951
1961
|
(key) => {
|
|
1952
1962
|
onChange(ADDITIONAL_PROPERTY_KEY_REMOVE, [...childFieldPathId.path, key]);
|
|
1953
1963
|
},
|
|
1954
1964
|
[onChange, childFieldPathId]
|
|
1955
1965
|
);
|
|
1956
|
-
const getStableKey = react.useCallback((property) => {
|
|
1966
|
+
const getStableKey = react$1.useCallback((property) => {
|
|
1957
1967
|
if (lastRenamedProperty.current.currentKey === property) {
|
|
1958
1968
|
return lastRenamedProperty.current.previousKey;
|
|
1959
1969
|
}
|
|
@@ -1965,7 +1975,7 @@
|
|
|
1965
1975
|
orderedProperties = utils.orderProperties(properties, uiOptions.order);
|
|
1966
1976
|
} catch (err) {
|
|
1967
1977
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1968
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "rjsf-config-error", style: { color: "red" }, children: /* @__PURE__ */ jsxRuntime.jsx(Markdown, { options: { disableParsingRawHTML: true }, children: translateString(utils.TranslatableString.InvalidObjectField, [name || "root", err.message]) }) }),
|
|
1978
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "rjsf-config-error", style: { color: "red" }, children: /* @__PURE__ */ jsxRuntime.jsx(markdownToJsx.Markdown, { options: { disableParsingRawHTML: true }, children: translateString(utils.TranslatableString.InvalidObjectField, [name || "root", err.message]) }) }),
|
|
1969
1979
|
/* @__PURE__ */ jsxRuntime.jsx("pre", { children: JSON.stringify(schema) })
|
|
1970
1980
|
] });
|
|
1971
1981
|
}
|
|
@@ -2143,7 +2153,7 @@
|
|
|
2143
2153
|
const FieldErrorTemplate2 = utils.getTemplate("FieldErrorTemplate", registry, uiOptions);
|
|
2144
2154
|
const schema = schemaUtils.retrieveSchema(_schema, formData);
|
|
2145
2155
|
const fieldId = fieldPathId[utils.ID_KEY];
|
|
2146
|
-
const handleFieldComponentChange = react.useCallback(
|
|
2156
|
+
const handleFieldComponentChange = react$1.useCallback(
|
|
2147
2157
|
(formData2, path, newErrorSchema, id2) => {
|
|
2148
2158
|
const theId = id2 || fieldId;
|
|
2149
2159
|
return onChange(formData2, path, newErrorSchema, theId);
|
|
@@ -2151,7 +2161,9 @@
|
|
|
2151
2161
|
[fieldId, onChange]
|
|
2152
2162
|
);
|
|
2153
2163
|
const FieldComponent = getFieldComponent(schema, uiOptions, registry);
|
|
2154
|
-
const
|
|
2164
|
+
const isDeprecated = Boolean(schema.deprecated);
|
|
2165
|
+
const deprecatedHandling = isDeprecated ? uiOptions.deprecatedHandling ?? "label" : void 0;
|
|
2166
|
+
const disabled = Boolean(uiOptions.disabled ?? props.disabled) || deprecatedHandling === "disable";
|
|
2155
2167
|
const readonly = Boolean(uiOptions.readonly ?? (props.readonly || props.schema.readOnly || schema.readOnly));
|
|
2156
2168
|
const uiSchemaHideError = uiOptions.hideError;
|
|
2157
2169
|
const hideError = uiSchemaHideError === void 0 ? props.hideError : Boolean(uiSchemaHideError);
|
|
@@ -2214,9 +2226,12 @@
|
|
|
2214
2226
|
} else {
|
|
2215
2227
|
label = utils.ADDITIONAL_PROPERTY_FLAG in schema ? name : uiOptions.title || props.schema.title || schema.title || props.title || name;
|
|
2216
2228
|
}
|
|
2229
|
+
if (deprecatedHandling === "label") {
|
|
2230
|
+
label = registry.translateString(utils.TranslatableString.DeprecatedLabel, [label]);
|
|
2231
|
+
}
|
|
2217
2232
|
const description = uiOptions.description || props.schema.description || schema.description || "";
|
|
2218
2233
|
const help = uiOptions.help;
|
|
2219
|
-
const hidden = uiOptions.widget === "hidden";
|
|
2234
|
+
const hidden = uiOptions.widget === "hidden" || deprecatedHandling === "hide";
|
|
2220
2235
|
const classNames = ["rjsf-field", `rjsf-field-${utils.getSchemaType(schema)}`];
|
|
2221
2236
|
if (!hideError && __errors && __errors.length > 0) {
|
|
2222
2237
|
classNames.push("rjsf-field-error");
|
|
@@ -2306,7 +2321,7 @@
|
|
|
2306
2321
|
)
|
|
2307
2322
|
] }) });
|
|
2308
2323
|
}
|
|
2309
|
-
var SchemaField = class extends react.Component {
|
|
2324
|
+
var SchemaField = class extends react$1.Component {
|
|
2310
2325
|
shouldComponentUpdate(nextProps) {
|
|
2311
2326
|
const {
|
|
2312
2327
|
registry: { globalFormOptions }
|
|
@@ -2349,7 +2364,7 @@
|
|
|
2349
2364
|
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
2350
2365
|
const label = uiTitle ?? title ?? schemaTitle ?? name;
|
|
2351
2366
|
const Widget = utils.getWidget(schema, widget, widgets2);
|
|
2352
|
-
const onWidgetChange = react.useCallback(
|
|
2367
|
+
const onWidgetChange = react$1.useCallback(
|
|
2353
2368
|
(value, errorSchema, id) => {
|
|
2354
2369
|
return onChange(value, fieldPathId.path, errorSchema, id);
|
|
2355
2370
|
},
|
|
@@ -2382,16 +2397,6 @@
|
|
|
2382
2397
|
);
|
|
2383
2398
|
}
|
|
2384
2399
|
var StringField_default = StringField;
|
|
2385
|
-
function NullField(props) {
|
|
2386
|
-
const { formData, onChange, fieldPathId } = props;
|
|
2387
|
-
react.useEffect(() => {
|
|
2388
|
-
if (formData === void 0) {
|
|
2389
|
-
onChange(null, fieldPathId.path);
|
|
2390
|
-
}
|
|
2391
|
-
}, [fieldPathId, formData, onChange]);
|
|
2392
|
-
return null;
|
|
2393
|
-
}
|
|
2394
|
-
var NullField_default = NullField;
|
|
2395
2400
|
|
|
2396
2401
|
// src/components/fields/index.ts
|
|
2397
2402
|
function fields() {
|
|
@@ -2437,28 +2442,6 @@
|
|
|
2437
2442
|
}
|
|
2438
2443
|
);
|
|
2439
2444
|
}
|
|
2440
|
-
function ArrayFieldItemTemplate(props) {
|
|
2441
|
-
const { children, className, buttonsProps, displayLabel, hasDescription, hasToolbar, registry, uiSchema } = props;
|
|
2442
|
-
const uiOptions = utils.getUiOptions(uiSchema);
|
|
2443
|
-
const ArrayFieldItemButtonsTemplate2 = utils.getTemplate(
|
|
2444
|
-
"ArrayFieldItemButtonsTemplate",
|
|
2445
|
-
registry,
|
|
2446
|
-
uiOptions
|
|
2447
|
-
);
|
|
2448
|
-
const btnStyle = {
|
|
2449
|
-
flex: 1,
|
|
2450
|
-
paddingLeft: 6,
|
|
2451
|
-
paddingRight: 6,
|
|
2452
|
-
fontWeight: "bold"
|
|
2453
|
-
};
|
|
2454
|
-
const margin = hasDescription ? 31 : 9;
|
|
2455
|
-
const containerStyle = { display: "flex", alignItems: displayLabel ? "center" : "baseline" };
|
|
2456
|
-
const toolbarStyle = { display: "flex", justifyContent: "flex-end", marginTop: displayLabel ? `${margin}px` : 0 };
|
|
2457
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: containerStyle, children: [
|
|
2458
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: hasToolbar ? "col-xs-9 col-md-10 col-xl-11" : "col-xs-12", children }),
|
|
2459
|
-
hasToolbar && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "col-xs-3 col-md-2 col-xl-1 array-item-toolbox", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "btn-group", style: toolbarStyle, children: /* @__PURE__ */ jsxRuntime.jsx(ArrayFieldItemButtonsTemplate2, { ...buttonsProps, style: btnStyle }) }) })
|
|
2460
|
-
] });
|
|
2461
|
-
}
|
|
2462
2445
|
function ArrayFieldItemButtonsTemplate(props) {
|
|
2463
2446
|
const {
|
|
2464
2447
|
disabled,
|
|
@@ -2523,6 +2506,28 @@
|
|
|
2523
2506
|
)
|
|
2524
2507
|
] });
|
|
2525
2508
|
}
|
|
2509
|
+
function ArrayFieldItemTemplate(props) {
|
|
2510
|
+
const { children, className, buttonsProps, displayLabel, hasDescription, hasToolbar, registry, uiSchema } = props;
|
|
2511
|
+
const uiOptions = utils.getUiOptions(uiSchema);
|
|
2512
|
+
const ArrayFieldItemButtonsTemplate2 = utils.getTemplate(
|
|
2513
|
+
"ArrayFieldItemButtonsTemplate",
|
|
2514
|
+
registry,
|
|
2515
|
+
uiOptions
|
|
2516
|
+
);
|
|
2517
|
+
const btnStyle = {
|
|
2518
|
+
flex: 1,
|
|
2519
|
+
paddingLeft: 6,
|
|
2520
|
+
paddingRight: 6,
|
|
2521
|
+
fontWeight: "bold"
|
|
2522
|
+
};
|
|
2523
|
+
const margin = hasDescription ? 31 : 9;
|
|
2524
|
+
const containerStyle = { display: "flex", alignItems: displayLabel ? "center" : "baseline" };
|
|
2525
|
+
const toolbarStyle = { display: "flex", justifyContent: "flex-end", marginTop: displayLabel ? `${margin}px` : 0 };
|
|
2526
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: containerStyle, children: [
|
|
2527
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: hasToolbar ? "col-xs-9 col-md-10 col-xl-11" : "col-xs-12", children }),
|
|
2528
|
+
hasToolbar && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "col-xs-3 col-md-2 col-xl-1 array-item-toolbox", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "btn-group", style: toolbarStyle, children: /* @__PURE__ */ jsxRuntime.jsx(ArrayFieldItemButtonsTemplate2, { ...buttonsProps, style: btnStyle }) }) })
|
|
2529
|
+
] });
|
|
2530
|
+
}
|
|
2526
2531
|
function ArrayFieldTemplate(props) {
|
|
2527
2532
|
const {
|
|
2528
2533
|
canAdd,
|
|
@@ -2670,19 +2675,19 @@
|
|
|
2670
2675
|
} else {
|
|
2671
2676
|
inputValue = value == null ? "" : value;
|
|
2672
2677
|
}
|
|
2673
|
-
const _onChange = react.useCallback(
|
|
2678
|
+
const _onChange = react$1.useCallback(
|
|
2674
2679
|
({ target: { value: value2 } }) => onChange(value2 === "" ? options.emptyValue : value2),
|
|
2675
2680
|
[onChange, options]
|
|
2676
2681
|
);
|
|
2677
|
-
const _onBlur = react.useCallback(
|
|
2682
|
+
const _onBlur = react$1.useCallback(
|
|
2678
2683
|
({ target }) => onBlur(id, target && target.value),
|
|
2679
2684
|
[onBlur, id]
|
|
2680
2685
|
);
|
|
2681
|
-
const _onFocus = react.useCallback(
|
|
2686
|
+
const _onFocus = react$1.useCallback(
|
|
2682
2687
|
({ target }) => onFocus(id, target && target.value),
|
|
2683
2688
|
[onFocus, id]
|
|
2684
2689
|
);
|
|
2685
|
-
const _onClear = react.useCallback(
|
|
2690
|
+
const _onClear = react$1.useCallback(
|
|
2686
2691
|
(e) => {
|
|
2687
2692
|
e.preventDefault();
|
|
2688
2693
|
e.stopPropagation();
|
|
@@ -2713,13 +2718,6 @@
|
|
|
2713
2718
|
/* @__PURE__ */ jsxRuntime.jsx(SchemaExamples, { id, schema })
|
|
2714
2719
|
] });
|
|
2715
2720
|
}
|
|
2716
|
-
function SubmitButton({ uiSchema }) {
|
|
2717
|
-
const { submitText, norender, props: submitButtonProps = {} } = utils.getSubmitButtonOptions(uiSchema);
|
|
2718
|
-
if (norender) {
|
|
2719
|
-
return null;
|
|
2720
|
-
}
|
|
2721
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", ...submitButtonProps, className: `btn btn-info ${submitButtonProps.className || ""}`, children: submitText }) });
|
|
2722
|
-
}
|
|
2723
2721
|
function IconButton(props) {
|
|
2724
2722
|
const { iconType = "default", icon, className, uiSchema, registry, ...otherProps } = props;
|
|
2725
2723
|
return /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: `btn btn-${iconType} ${className}`, ...otherProps, children: /* @__PURE__ */ jsxRuntime.jsx("i", { className: `glyphicon glyphicon-${icon}` }) });
|
|
@@ -2800,6 +2798,13 @@
|
|
|
2800
2798
|
}
|
|
2801
2799
|
) });
|
|
2802
2800
|
}
|
|
2801
|
+
function SubmitButton({ uiSchema }) {
|
|
2802
|
+
const { submitText, norender, props: submitButtonProps = {} } = utils.getSubmitButtonOptions(uiSchema);
|
|
2803
|
+
if (norender) {
|
|
2804
|
+
return null;
|
|
2805
|
+
}
|
|
2806
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", ...submitButtonProps, className: `btn btn-info ${submitButtonProps.className || ""}`, children: submitText }) });
|
|
2807
|
+
}
|
|
2803
2808
|
|
|
2804
2809
|
// src/components/templates/ButtonTemplates/index.ts
|
|
2805
2810
|
function buttonTemplates() {
|
|
@@ -2819,7 +2824,7 @@
|
|
|
2819
2824
|
const { globalUiOptions } = registry;
|
|
2820
2825
|
const uiOptions = utils.getUiOptions(uiSchema, globalUiOptions);
|
|
2821
2826
|
if (uiOptions.enableMarkdownInDescription && typeof description === "string") {
|
|
2822
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Markdown, { options: { disableParsingRawHTML: true }, "data-testid": TEST_IDS.markdown, children: description });
|
|
2827
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.Markdown, { options: { disableParsingRawHTML: true }, "data-testid": TEST_IDS.markdown, children: description });
|
|
2823
2828
|
}
|
|
2824
2829
|
return description;
|
|
2825
2830
|
}
|
|
@@ -2859,6 +2864,37 @@
|
|
|
2859
2864
|
}
|
|
2860
2865
|
);
|
|
2861
2866
|
}
|
|
2867
|
+
function FieldErrorTemplate(props) {
|
|
2868
|
+
const { errors = [], fieldPathId } = props;
|
|
2869
|
+
if (errors.length === 0) {
|
|
2870
|
+
return null;
|
|
2871
|
+
}
|
|
2872
|
+
const id = utils.errorId(fieldPathId);
|
|
2873
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx("ul", { id, className: "error-detail bs-callout bs-callout-info", children: errors.filter((elem) => !!elem).map((error, index) => {
|
|
2874
|
+
return /* @__PURE__ */ jsxRuntime.jsx("li", { className: "text-danger", children: error }, index);
|
|
2875
|
+
}) }) });
|
|
2876
|
+
}
|
|
2877
|
+
var TEST_IDS2 = utils.getTestIds();
|
|
2878
|
+
function RichHelp({
|
|
2879
|
+
help,
|
|
2880
|
+
registry,
|
|
2881
|
+
uiSchema = {}
|
|
2882
|
+
}) {
|
|
2883
|
+
const { globalUiOptions } = registry;
|
|
2884
|
+
const uiOptions = utils.getUiOptions(uiSchema, globalUiOptions);
|
|
2885
|
+
if (uiOptions.enableMarkdownInHelp && typeof help === "string") {
|
|
2886
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.Markdown, { options: { disableParsingRawHTML: true }, "data-testid": TEST_IDS2.markdown, children: help });
|
|
2887
|
+
}
|
|
2888
|
+
return help;
|
|
2889
|
+
}
|
|
2890
|
+
RichHelp.TEST_IDS = TEST_IDS2;
|
|
2891
|
+
function FieldHelpTemplate(props) {
|
|
2892
|
+
const { fieldPathId, help, uiSchema, registry } = props;
|
|
2893
|
+
if (!help) {
|
|
2894
|
+
return null;
|
|
2895
|
+
}
|
|
2896
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { id: utils.helpId(fieldPathId), className: "help-block", children: /* @__PURE__ */ jsxRuntime.jsx(RichHelp, { help, registry, uiSchema }) });
|
|
2897
|
+
}
|
|
2862
2898
|
var REQUIRED_FIELD_SYMBOL = "*";
|
|
2863
2899
|
function Label(props) {
|
|
2864
2900
|
const { label, required, id } = props;
|
|
@@ -2893,37 +2929,6 @@
|
|
|
2893
2929
|
|
|
2894
2930
|
// src/components/templates/FieldTemplate/index.ts
|
|
2895
2931
|
var FieldTemplate_default = FieldTemplate;
|
|
2896
|
-
function FieldErrorTemplate(props) {
|
|
2897
|
-
const { errors = [], fieldPathId } = props;
|
|
2898
|
-
if (errors.length === 0) {
|
|
2899
|
-
return null;
|
|
2900
|
-
}
|
|
2901
|
-
const id = utils.errorId(fieldPathId);
|
|
2902
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx("ul", { id, className: "error-detail bs-callout bs-callout-info", children: errors.filter((elem) => !!elem).map((error, index) => {
|
|
2903
|
-
return /* @__PURE__ */ jsxRuntime.jsx("li", { className: "text-danger", children: error }, index);
|
|
2904
|
-
}) }) });
|
|
2905
|
-
}
|
|
2906
|
-
var TEST_IDS2 = utils.getTestIds();
|
|
2907
|
-
function RichHelp({
|
|
2908
|
-
help,
|
|
2909
|
-
registry,
|
|
2910
|
-
uiSchema = {}
|
|
2911
|
-
}) {
|
|
2912
|
-
const { globalUiOptions } = registry;
|
|
2913
|
-
const uiOptions = utils.getUiOptions(uiSchema, globalUiOptions);
|
|
2914
|
-
if (uiOptions.enableMarkdownInHelp && typeof help === "string") {
|
|
2915
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Markdown, { options: { disableParsingRawHTML: true }, "data-testid": TEST_IDS2.markdown, children: help });
|
|
2916
|
-
}
|
|
2917
|
-
return help;
|
|
2918
|
-
}
|
|
2919
|
-
RichHelp.TEST_IDS = TEST_IDS2;
|
|
2920
|
-
function FieldHelpTemplate(props) {
|
|
2921
|
-
const { fieldPathId, help, uiSchema, registry } = props;
|
|
2922
|
-
if (!help) {
|
|
2923
|
-
return null;
|
|
2924
|
-
}
|
|
2925
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { id: utils.helpId(fieldPathId), className: "help-block", children: /* @__PURE__ */ jsxRuntime.jsx(RichHelp, { help, registry, uiSchema }) });
|
|
2926
|
-
}
|
|
2927
2932
|
function GridTemplate(props) {
|
|
2928
2933
|
const { children, column, className, ...rest } = props;
|
|
2929
2934
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className, ...rest, children });
|
|
@@ -3057,7 +3062,7 @@
|
|
|
3057
3062
|
translateParams.push(reason);
|
|
3058
3063
|
}
|
|
3059
3064
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "unsupported-field", children: [
|
|
3060
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { children: /* @__PURE__ */ jsxRuntime.jsx(Markdown, { options: { disableParsingRawHTML: true }, children: translateString(translateEnum, translateParams) }) }),
|
|
3065
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { children: /* @__PURE__ */ jsxRuntime.jsx(markdownToJsx.Markdown, { options: { disableParsingRawHTML: true }, children: translateString(translateEnum, translateParams) }) }),
|
|
3061
3066
|
schema && /* @__PURE__ */ jsxRuntime.jsx("pre", { children: JSON.stringify(schema, null, 2) })
|
|
3062
3067
|
] });
|
|
3063
3068
|
}
|
|
@@ -3154,6 +3159,14 @@
|
|
|
3154
3159
|
};
|
|
3155
3160
|
}
|
|
3156
3161
|
var templates_default = templates;
|
|
3162
|
+
function AltDateTimeWidget({
|
|
3163
|
+
time = true,
|
|
3164
|
+
...props
|
|
3165
|
+
}) {
|
|
3166
|
+
const { AltDateWidget: AltDateWidget2 } = props.registry.widgets;
|
|
3167
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AltDateWidget2, { time, ...props });
|
|
3168
|
+
}
|
|
3169
|
+
var AltDateTimeWidget_default = AltDateTimeWidget;
|
|
3157
3170
|
function AltDateWidget(props) {
|
|
3158
3171
|
const { disabled = false, readonly = false, autofocus = false, options, id, name, registry, onBlur, onFocus } = props;
|
|
3159
3172
|
const { translateString } = registry;
|
|
@@ -3179,14 +3192,63 @@
|
|
|
3179
3192
|
] });
|
|
3180
3193
|
}
|
|
3181
3194
|
var AltDateWidget_default = AltDateWidget;
|
|
3182
|
-
function
|
|
3183
|
-
|
|
3184
|
-
|
|
3195
|
+
function CheckboxesWidget({
|
|
3196
|
+
id,
|
|
3197
|
+
disabled,
|
|
3198
|
+
options,
|
|
3199
|
+
value,
|
|
3200
|
+
autofocus = false,
|
|
3201
|
+
readonly,
|
|
3202
|
+
onChange,
|
|
3203
|
+
onBlur,
|
|
3204
|
+
onFocus,
|
|
3205
|
+
htmlName
|
|
3185
3206
|
}) {
|
|
3186
|
-
const {
|
|
3187
|
-
|
|
3207
|
+
const { inline = false, enumOptions, enumDisabled, emptyValue } = options;
|
|
3208
|
+
const optionValueFormat = utils.getOptionValueFormat(options);
|
|
3209
|
+
const checkboxesValues = Array.isArray(value) ? value : [value];
|
|
3210
|
+
const handleBlur = react$1.useCallback(
|
|
3211
|
+
({ target }) => onBlur(id, utils.enumOptionValueDecoder(target && target.value, enumOptions, optionValueFormat, emptyValue)),
|
|
3212
|
+
[onBlur, id, enumOptions, emptyValue, optionValueFormat]
|
|
3213
|
+
);
|
|
3214
|
+
const handleFocus = react$1.useCallback(
|
|
3215
|
+
({ target }) => onFocus(id, utils.enumOptionValueDecoder(target && target.value, enumOptions, optionValueFormat, emptyValue)),
|
|
3216
|
+
[onFocus, id, enumOptions, emptyValue, optionValueFormat]
|
|
3217
|
+
);
|
|
3218
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "checkboxes", id, children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
|
|
3219
|
+
const checked = utils.enumOptionsIsSelected(option.value, checkboxesValues);
|
|
3220
|
+
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
3221
|
+
const disabledCls = disabled || itemDisabled || readonly ? "disabled" : "";
|
|
3222
|
+
const handleChange = (event) => {
|
|
3223
|
+
if (event.target.checked) {
|
|
3224
|
+
onChange(utils.enumOptionsSelectValue(index, checkboxesValues, enumOptions));
|
|
3225
|
+
} else {
|
|
3226
|
+
onChange(utils.enumOptionsDeselectValue(index, checkboxesValues, enumOptions));
|
|
3227
|
+
}
|
|
3228
|
+
};
|
|
3229
|
+
const checkbox = /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
3230
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3231
|
+
"input",
|
|
3232
|
+
{
|
|
3233
|
+
type: "checkbox",
|
|
3234
|
+
id: utils.optionId(id, index),
|
|
3235
|
+
name: htmlName || id,
|
|
3236
|
+
checked,
|
|
3237
|
+
value: utils.enumOptionValueEncoder(option.value, index, optionValueFormat),
|
|
3238
|
+
disabled: disabled || itemDisabled || readonly,
|
|
3239
|
+
autoFocus: autofocus && index === 0,
|
|
3240
|
+
onChange: handleChange,
|
|
3241
|
+
onBlur: handleBlur,
|
|
3242
|
+
onFocus: handleFocus,
|
|
3243
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
3244
|
+
}
|
|
3245
|
+
),
|
|
3246
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: option.label })
|
|
3247
|
+
] });
|
|
3248
|
+
return inline ? /* @__PURE__ */ jsxRuntime.jsx("label", { className: `checkbox-inline ${disabledCls}`, children: checkbox }, index) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: `checkbox ${disabledCls}`, children: /* @__PURE__ */ jsxRuntime.jsx("label", { children: checkbox }) }, index);
|
|
3249
|
+
}) });
|
|
3188
3250
|
}
|
|
3189
|
-
var
|
|
3251
|
+
var CheckboxesWidget_default = CheckboxesWidget;
|
|
3190
3252
|
function CheckboxWidget({
|
|
3191
3253
|
schema,
|
|
3192
3254
|
uiSchema,
|
|
@@ -3210,15 +3272,15 @@
|
|
|
3210
3272
|
options
|
|
3211
3273
|
);
|
|
3212
3274
|
const required = utils.schemaRequiresTrueValue(schema);
|
|
3213
|
-
const handleChange = react.useCallback(
|
|
3275
|
+
const handleChange = react$1.useCallback(
|
|
3214
3276
|
(event) => onChange(event.target.checked),
|
|
3215
3277
|
[onChange]
|
|
3216
3278
|
);
|
|
3217
|
-
const handleBlur = react.useCallback(
|
|
3279
|
+
const handleBlur = react$1.useCallback(
|
|
3218
3280
|
(event) => onBlur(id, event.target.checked),
|
|
3219
3281
|
[onBlur, id]
|
|
3220
3282
|
);
|
|
3221
|
-
const handleFocus = react.useCallback(
|
|
3283
|
+
const handleFocus = react$1.useCallback(
|
|
3222
3284
|
(event) => onFocus(id, event.target.checked),
|
|
3223
3285
|
[onFocus, id]
|
|
3224
3286
|
);
|
|
@@ -3258,74 +3320,11 @@
|
|
|
3258
3320
|
] });
|
|
3259
3321
|
}
|
|
3260
3322
|
var CheckboxWidget_default = CheckboxWidget;
|
|
3261
|
-
function CheckboxesWidget({
|
|
3262
|
-
id,
|
|
3263
|
-
disabled,
|
|
3264
|
-
options,
|
|
3265
|
-
value,
|
|
3266
|
-
autofocus = false,
|
|
3267
|
-
readonly,
|
|
3268
|
-
onChange,
|
|
3269
|
-
onBlur,
|
|
3270
|
-
onFocus,
|
|
3271
|
-
htmlName
|
|
3272
|
-
}) {
|
|
3273
|
-
const { inline = false, enumOptions, enumDisabled, emptyValue } = options;
|
|
3274
|
-
const optionValueFormat = utils.getOptionValueFormat(options);
|
|
3275
|
-
const checkboxesValues = Array.isArray(value) ? value : [value];
|
|
3276
|
-
const handleBlur = react.useCallback(
|
|
3277
|
-
({ target }) => onBlur(id, utils.enumOptionValueDecoder(target && target.value, enumOptions, optionValueFormat, emptyValue)),
|
|
3278
|
-
[onBlur, id, enumOptions, emptyValue, optionValueFormat]
|
|
3279
|
-
);
|
|
3280
|
-
const handleFocus = react.useCallback(
|
|
3281
|
-
({ target }) => onFocus(id, utils.enumOptionValueDecoder(target && target.value, enumOptions, optionValueFormat, emptyValue)),
|
|
3282
|
-
[onFocus, id, enumOptions, emptyValue, optionValueFormat]
|
|
3283
|
-
);
|
|
3284
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "checkboxes", id, children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
|
|
3285
|
-
const checked = utils.enumOptionsIsSelected(option.value, checkboxesValues);
|
|
3286
|
-
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
3287
|
-
const disabledCls = disabled || itemDisabled || readonly ? "disabled" : "";
|
|
3288
|
-
const handleChange = (event) => {
|
|
3289
|
-
if (event.target.checked) {
|
|
3290
|
-
onChange(utils.enumOptionsSelectValue(index, checkboxesValues, enumOptions));
|
|
3291
|
-
} else {
|
|
3292
|
-
onChange(utils.enumOptionsDeselectValue(index, checkboxesValues, enumOptions));
|
|
3293
|
-
}
|
|
3294
|
-
};
|
|
3295
|
-
const checkbox = /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
3296
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3297
|
-
"input",
|
|
3298
|
-
{
|
|
3299
|
-
type: "checkbox",
|
|
3300
|
-
id: utils.optionId(id, index),
|
|
3301
|
-
name: htmlName || id,
|
|
3302
|
-
checked,
|
|
3303
|
-
value: utils.enumOptionValueEncoder(option.value, index, optionValueFormat),
|
|
3304
|
-
disabled: disabled || itemDisabled || readonly,
|
|
3305
|
-
autoFocus: autofocus && index === 0,
|
|
3306
|
-
onChange: handleChange,
|
|
3307
|
-
onBlur: handleBlur,
|
|
3308
|
-
onFocus: handleFocus,
|
|
3309
|
-
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
3310
|
-
}
|
|
3311
|
-
),
|
|
3312
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: option.label })
|
|
3313
|
-
] });
|
|
3314
|
-
return inline ? /* @__PURE__ */ jsxRuntime.jsx("label", { className: `checkbox-inline ${disabledCls}`, children: checkbox }, index) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: `checkbox ${disabledCls}`, children: /* @__PURE__ */ jsxRuntime.jsx("label", { children: checkbox }) }, index);
|
|
3315
|
-
}) });
|
|
3316
|
-
}
|
|
3317
|
-
var CheckboxesWidget_default = CheckboxesWidget;
|
|
3318
3323
|
function ColorWidget(props) {
|
|
3319
3324
|
const { disabled, readonly, options, registry } = props;
|
|
3320
3325
|
const BaseInputTemplate2 = utils.getTemplate("BaseInputTemplate", registry, options);
|
|
3321
3326
|
return /* @__PURE__ */ jsxRuntime.jsx(BaseInputTemplate2, { type: "color", ...props, disabled: disabled || readonly });
|
|
3322
3327
|
}
|
|
3323
|
-
function DateWidget(props) {
|
|
3324
|
-
const { onChange, options, registry } = props;
|
|
3325
|
-
const BaseInputTemplate2 = utils.getTemplate("BaseInputTemplate", registry, options);
|
|
3326
|
-
const handleChange = react.useCallback((value) => onChange(value || void 0), [onChange]);
|
|
3327
|
-
return /* @__PURE__ */ jsxRuntime.jsx(BaseInputTemplate2, { type: "date", ...props, onChange: handleChange });
|
|
3328
|
-
}
|
|
3329
3328
|
function DateTimeWidget(props) {
|
|
3330
3329
|
const { onChange, value, options, registry } = props;
|
|
3331
3330
|
const BaseInputTemplate2 = utils.getTemplate("BaseInputTemplate", registry, options);
|
|
@@ -3339,6 +3338,12 @@
|
|
|
3339
3338
|
}
|
|
3340
3339
|
);
|
|
3341
3340
|
}
|
|
3341
|
+
function DateWidget(props) {
|
|
3342
|
+
const { onChange, options, registry } = props;
|
|
3343
|
+
const BaseInputTemplate2 = utils.getTemplate("BaseInputTemplate", registry, options);
|
|
3344
|
+
const handleChange = react$1.useCallback((value) => onChange(value || void 0), [onChange]);
|
|
3345
|
+
return /* @__PURE__ */ jsxRuntime.jsx(BaseInputTemplate2, { type: "date", ...props, onChange: handleChange });
|
|
3346
|
+
}
|
|
3342
3347
|
function EmailWidget(props) {
|
|
3343
3348
|
const { options, registry } = props;
|
|
3344
3349
|
const BaseInputTemplate2 = utils.getTemplate("BaseInputTemplate", registry, options);
|
|
@@ -3377,7 +3382,7 @@
|
|
|
3377
3382
|
const { name, size, type } = fileInfo;
|
|
3378
3383
|
const handleRemove = () => onRemove(key);
|
|
3379
3384
|
return /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
|
|
3380
|
-
/* @__PURE__ */ jsxRuntime.jsx(Markdown, { children: translateString(utils.TranslatableString.FilesInfo, [name, type, String(size)]) }),
|
|
3385
|
+
/* @__PURE__ */ jsxRuntime.jsx(markdownToJsx.Markdown, { children: translateString(utils.TranslatableString.FilesInfo, [name, type, String(size)]) }),
|
|
3381
3386
|
preview && /* @__PURE__ */ jsxRuntime.jsx(FileInfoPreview, { fileInfo, registry }),
|
|
3382
3387
|
/* @__PURE__ */ jsxRuntime.jsx(RemoveButton2, { onClick: handleRemove, registry })
|
|
3383
3388
|
] }, key);
|
|
@@ -3389,7 +3394,7 @@
|
|
|
3389
3394
|
const BaseInputTemplate2 = utils.getTemplate("BaseInputTemplate", registry, options);
|
|
3390
3395
|
const handleOnChangeEvent = (event) => {
|
|
3391
3396
|
if (event.target.files) {
|
|
3392
|
-
handleChange(event.target.files);
|
|
3397
|
+
void handleChange(event.target.files);
|
|
3393
3398
|
}
|
|
3394
3399
|
};
|
|
3395
3400
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
@@ -3446,11 +3451,11 @@
|
|
|
3446
3451
|
}) {
|
|
3447
3452
|
const { enumOptions, enumDisabled, inline, emptyValue } = options;
|
|
3448
3453
|
const optionValueFormat = utils.getOptionValueFormat(options);
|
|
3449
|
-
const handleBlur = react.useCallback(
|
|
3454
|
+
const handleBlur = react$1.useCallback(
|
|
3450
3455
|
({ target }) => onBlur(id, utils.enumOptionValueDecoder(target && target.value, enumOptions, optionValueFormat, emptyValue)),
|
|
3451
3456
|
[onBlur, enumOptions, emptyValue, id, optionValueFormat]
|
|
3452
3457
|
);
|
|
3453
|
-
const handleFocus = react.useCallback(
|
|
3458
|
+
const handleFocus = react$1.useCallback(
|
|
3454
3459
|
({ target }) => onFocus(id, utils.enumOptionValueDecoder(target && target.value, enumOptions, optionValueFormat, emptyValue)),
|
|
3455
3460
|
[onFocus, enumOptions, emptyValue, id, optionValueFormat]
|
|
3456
3461
|
);
|
|
@@ -3512,7 +3517,7 @@
|
|
|
3512
3517
|
const { stars = 5, shape = "star" } = options;
|
|
3513
3518
|
const numStars = schema.maximum ? Math.min(schema.maximum, 5) : Math.min(Math.max(stars, 1), 5);
|
|
3514
3519
|
const min = schema.minimum || 0;
|
|
3515
|
-
const handleStarClick = react.useCallback(
|
|
3520
|
+
const handleStarClick = react$1.useCallback(
|
|
3516
3521
|
(starValue) => {
|
|
3517
3522
|
if (!disabled && !readonly) {
|
|
3518
3523
|
onChange(starValue);
|
|
@@ -3520,7 +3525,7 @@
|
|
|
3520
3525
|
},
|
|
3521
3526
|
[onChange, disabled, readonly]
|
|
3522
3527
|
);
|
|
3523
|
-
const handleFocus = react.useCallback(
|
|
3528
|
+
const handleFocus = react$1.useCallback(
|
|
3524
3529
|
(event) => {
|
|
3525
3530
|
if (onFocus) {
|
|
3526
3531
|
const starValue = Number(event.target.dataset.value);
|
|
@@ -3529,7 +3534,7 @@
|
|
|
3529
3534
|
},
|
|
3530
3535
|
[onFocus, id]
|
|
3531
3536
|
);
|
|
3532
|
-
const handleBlur = react.useCallback(
|
|
3537
|
+
const handleBlur = react$1.useCallback(
|
|
3533
3538
|
(event) => {
|
|
3534
3539
|
if (onBlur) {
|
|
3535
3540
|
const starValue = Number(event.target.dataset.value);
|
|
@@ -3620,21 +3625,21 @@
|
|
|
3620
3625
|
const { enumOptions, enumDisabled, emptyValue: optEmptyVal } = options;
|
|
3621
3626
|
const emptyValue = multiple ? [] : "";
|
|
3622
3627
|
const optionValueFormat = utils.getOptionValueFormat(options);
|
|
3623
|
-
const handleFocus = react.useCallback(
|
|
3628
|
+
const handleFocus = react$1.useCallback(
|
|
3624
3629
|
(event) => {
|
|
3625
3630
|
const newValue = getValue(event, multiple);
|
|
3626
3631
|
return onFocus(id, utils.enumOptionValueDecoder(newValue, enumOptions, optionValueFormat, optEmptyVal));
|
|
3627
3632
|
},
|
|
3628
3633
|
[onFocus, id, multiple, enumOptions, optEmptyVal, optionValueFormat]
|
|
3629
3634
|
);
|
|
3630
|
-
const handleBlur = react.useCallback(
|
|
3635
|
+
const handleBlur = react$1.useCallback(
|
|
3631
3636
|
(event) => {
|
|
3632
3637
|
const newValue = getValue(event, multiple);
|
|
3633
3638
|
return onBlur(id, utils.enumOptionValueDecoder(newValue, enumOptions, optionValueFormat, optEmptyVal));
|
|
3634
3639
|
},
|
|
3635
3640
|
[onBlur, id, multiple, enumOptions, optEmptyVal, optionValueFormat]
|
|
3636
3641
|
);
|
|
3637
|
-
const handleChange = react.useCallback(
|
|
3642
|
+
const handleChange = react$1.useCallback(
|
|
3638
3643
|
(event) => {
|
|
3639
3644
|
const newValue = getValue(event, multiple);
|
|
3640
3645
|
return onChange(utils.enumOptionValueDecoder(newValue, enumOptions, optionValueFormat, optEmptyVal));
|
|
@@ -3684,15 +3689,15 @@
|
|
|
3684
3689
|
onFocus,
|
|
3685
3690
|
htmlName
|
|
3686
3691
|
}) {
|
|
3687
|
-
const handleChange = react.useCallback(
|
|
3692
|
+
const handleChange = react$1.useCallback(
|
|
3688
3693
|
({ target: { value: value2 } }) => onChange(value2 === "" ? options.emptyValue : value2),
|
|
3689
3694
|
[onChange, options.emptyValue]
|
|
3690
3695
|
);
|
|
3691
|
-
const handleBlur = react.useCallback(
|
|
3696
|
+
const handleBlur = react$1.useCallback(
|
|
3692
3697
|
({ target }) => onBlur(id, target && target.value),
|
|
3693
3698
|
[onBlur, id]
|
|
3694
3699
|
);
|
|
3695
|
-
const handleFocus = react.useCallback(
|
|
3700
|
+
const handleFocus = react$1.useCallback(
|
|
3696
3701
|
({ target }) => onFocus(id, target && target.value),
|
|
3697
3702
|
[id, onFocus]
|
|
3698
3703
|
);
|
|
@@ -3725,18 +3730,18 @@
|
|
|
3725
3730
|
function TimeWidget(props) {
|
|
3726
3731
|
const { onChange, options, registry } = props;
|
|
3727
3732
|
const BaseInputTemplate2 = utils.getTemplate("BaseInputTemplate", registry, options);
|
|
3728
|
-
const handleChange = react.useCallback((value) => onChange(value ? `${value}:00` : void 0), [onChange]);
|
|
3733
|
+
const handleChange = react$1.useCallback((value) => onChange(value ? `${value}:00` : void 0), [onChange]);
|
|
3729
3734
|
return /* @__PURE__ */ jsxRuntime.jsx(BaseInputTemplate2, { type: "time", ...props, onChange: handleChange });
|
|
3730
3735
|
}
|
|
3731
|
-
function
|
|
3736
|
+
function UpDownWidget(props) {
|
|
3732
3737
|
const { options, registry } = props;
|
|
3733
3738
|
const BaseInputTemplate2 = utils.getTemplate("BaseInputTemplate", registry, options);
|
|
3734
|
-
return /* @__PURE__ */ jsxRuntime.jsx(BaseInputTemplate2, { type: "
|
|
3739
|
+
return /* @__PURE__ */ jsxRuntime.jsx(BaseInputTemplate2, { type: "number", ...props });
|
|
3735
3740
|
}
|
|
3736
|
-
function
|
|
3741
|
+
function URLWidget(props) {
|
|
3737
3742
|
const { options, registry } = props;
|
|
3738
3743
|
const BaseInputTemplate2 = utils.getTemplate("BaseInputTemplate", registry, options);
|
|
3739
|
-
return /* @__PURE__ */ jsxRuntime.jsx(BaseInputTemplate2, { type: "
|
|
3744
|
+
return /* @__PURE__ */ jsxRuntime.jsx(BaseInputTemplate2, { type: "url", ...props });
|
|
3740
3745
|
}
|
|
3741
3746
|
|
|
3742
3747
|
// src/components/widgets/index.ts
|
|
@@ -3788,7 +3793,7 @@
|
|
|
3788
3793
|
...status !== void 0 && { status }
|
|
3789
3794
|
};
|
|
3790
3795
|
}
|
|
3791
|
-
var Form = class extends react.Component {
|
|
3796
|
+
var Form = class extends react$1.Component {
|
|
3792
3797
|
/** The ref used to hold the `form` element, this needs to be `any` because `tagName` or `_internalFormWrapper` can
|
|
3793
3798
|
* provide any possible type here
|
|
3794
3799
|
*/
|
|
@@ -3848,7 +3853,7 @@
|
|
|
3848
3853
|
if (onChange && !utils.deepEquals(this.state.formData, formData)) {
|
|
3849
3854
|
onChange(toIChangeEvent(this.state));
|
|
3850
3855
|
}
|
|
3851
|
-
this.formElement = react.createRef();
|
|
3856
|
+
this.formElement = react$1.createRef();
|
|
3852
3857
|
}
|
|
3853
3858
|
/**
|
|
3854
3859
|
* `getSnapshotBeforeUpdate` is a React lifecycle method that is invoked right before the most recently rendered
|
|
@@ -4217,7 +4222,7 @@
|
|
|
4217
4222
|
this._isProcessingUserChange = true;
|
|
4218
4223
|
const { newValue, path, id } = this.pendingChanges[0];
|
|
4219
4224
|
const { newErrorSchema } = this.pendingChanges[0];
|
|
4220
|
-
const { extraErrors, omitExtraData, liveOmit, noValidate, liveValidate, onChange
|
|
4225
|
+
const { extraErrors, omitExtraData, liveOmit, noValidate, liveValidate, onChange } = this.props;
|
|
4221
4226
|
const { formData: oldFormData, schemaUtils, schema, fieldPathId, schemaValidationErrorSchema, errors } = this.state;
|
|
4222
4227
|
let { customErrors } = this.state;
|
|
4223
4228
|
let mergeBaseErrorSchema = schemaValidationErrorSchema;
|
|
@@ -4232,7 +4237,26 @@
|
|
|
4232
4237
|
if (newValue === ADDITIONAL_PROPERTY_KEY_REMOVE) {
|
|
4233
4238
|
_unset(formData, path);
|
|
4234
4239
|
} else if (!isRootPath) {
|
|
4235
|
-
|
|
4240
|
+
let unsetPath = false;
|
|
4241
|
+
let valueForPath = newValue;
|
|
4242
|
+
if (newValue === void 0) {
|
|
4243
|
+
const lastSegment = path[path.length - 1];
|
|
4244
|
+
if (typeof lastSegment === "number") {
|
|
4245
|
+
valueForPath = null;
|
|
4246
|
+
} else {
|
|
4247
|
+
const { field } = schemaUtils.findFieldInSchema(schema, path, oldFormData);
|
|
4248
|
+
const leaf = field;
|
|
4249
|
+
const isOneOfOrAnyOfLeaf = leaf && (utils.ONE_OF_KEY in leaf || utils.ANY_OF_KEY in leaf);
|
|
4250
|
+
if (!isOneOfOrAnyOfLeaf && leaf !== void 0) {
|
|
4251
|
+
unsetPath = true;
|
|
4252
|
+
}
|
|
4253
|
+
}
|
|
4254
|
+
}
|
|
4255
|
+
if (unsetPath) {
|
|
4256
|
+
_unset(formData, path);
|
|
4257
|
+
} else {
|
|
4258
|
+
set(formData, path, valueForPath);
|
|
4259
|
+
}
|
|
4236
4260
|
}
|
|
4237
4261
|
const newState = this.getStateFromProps(this.props, inputForDefaults, void 0, void 0, void 0, true);
|
|
4238
4262
|
formData = newState.formData;
|
|
@@ -4247,18 +4271,6 @@
|
|
|
4247
4271
|
formData: newFormData
|
|
4248
4272
|
};
|
|
4249
4273
|
}
|
|
4250
|
-
if (removeEmptyOptionalObjects) {
|
|
4251
|
-
newFormData = utils.removeOptionalEmptyObjects(
|
|
4252
|
-
schemaUtils.getValidator(),
|
|
4253
|
-
schema,
|
|
4254
|
-
schemaUtils.getRootSchema(),
|
|
4255
|
-
newFormData
|
|
4256
|
-
);
|
|
4257
|
-
state = {
|
|
4258
|
-
...state,
|
|
4259
|
-
formData: newFormData
|
|
4260
|
-
};
|
|
4261
|
-
}
|
|
4262
4274
|
if (newErrorSchema) {
|
|
4263
4275
|
const oldValidationError = !isRootPath ? get(schemaValidationErrorSchema, path) : schemaValidationErrorSchema;
|
|
4264
4276
|
if (!isEmpty(oldValidationError)) {
|
|
@@ -4360,33 +4372,24 @@
|
|
|
4360
4372
|
* @param data - The data associated with the field that was blurred
|
|
4361
4373
|
*/
|
|
4362
4374
|
onBlur = (id, data) => {
|
|
4363
|
-
const { onBlur, omitExtraData, liveOmit, liveValidate
|
|
4375
|
+
const { onBlur, omitExtraData, liveOmit, liveValidate } = this.props;
|
|
4364
4376
|
if (onBlur) {
|
|
4365
4377
|
onBlur(id, data);
|
|
4366
4378
|
}
|
|
4367
4379
|
if (omitExtraData === true && liveOmit === "onBlur" || liveValidate === "onBlur") {
|
|
4368
4380
|
const { onChange, extraErrors } = this.props;
|
|
4369
|
-
const { formData
|
|
4381
|
+
const { formData } = this.state;
|
|
4370
4382
|
let newFormData = formData;
|
|
4371
4383
|
let state = { formData: newFormData };
|
|
4372
4384
|
if (omitExtraData === true && liveOmit === "onBlur") {
|
|
4373
4385
|
newFormData = this.omitExtraData(formData);
|
|
4374
4386
|
state = { formData: newFormData };
|
|
4375
4387
|
}
|
|
4376
|
-
if (removeEmptyOptionalObjects) {
|
|
4377
|
-
newFormData = utils.removeOptionalEmptyObjects(
|
|
4378
|
-
schemaUtils.getValidator(),
|
|
4379
|
-
schema,
|
|
4380
|
-
schemaUtils.getRootSchema(),
|
|
4381
|
-
newFormData
|
|
4382
|
-
);
|
|
4383
|
-
state = { ...state, formData: newFormData };
|
|
4384
|
-
}
|
|
4385
4388
|
if (liveValidate === "onBlur") {
|
|
4386
|
-
const { schema
|
|
4389
|
+
const { schema, schemaUtils, errorSchema, customErrors, retrievedSchema } = this.state;
|
|
4387
4390
|
const liveValidation = this.liveValidate(
|
|
4388
|
-
|
|
4389
|
-
|
|
4391
|
+
schema,
|
|
4392
|
+
schemaUtils,
|
|
4390
4393
|
errorSchema,
|
|
4391
4394
|
newFormData,
|
|
4392
4395
|
extraErrors,
|
|
@@ -4433,20 +4436,11 @@
|
|
|
4433
4436
|
return;
|
|
4434
4437
|
}
|
|
4435
4438
|
event.persist();
|
|
4436
|
-
const { omitExtraData, extraErrors, noValidate, onSubmit
|
|
4439
|
+
const { omitExtraData, extraErrors, noValidate, onSubmit } = this.props;
|
|
4437
4440
|
let { formData: newFormData } = this.state;
|
|
4438
4441
|
if (omitExtraData === true) {
|
|
4439
4442
|
newFormData = this.omitExtraData(newFormData);
|
|
4440
4443
|
}
|
|
4441
|
-
if (removeEmptyOptionalObjects) {
|
|
4442
|
-
const { schemaUtils, schema } = this.state;
|
|
4443
|
-
newFormData = utils.removeOptionalEmptyObjects(
|
|
4444
|
-
schemaUtils.getValidator(),
|
|
4445
|
-
schema,
|
|
4446
|
-
schemaUtils.getRootSchema(),
|
|
4447
|
-
newFormData
|
|
4448
|
-
);
|
|
4449
|
-
}
|
|
4450
4444
|
if (noValidate || this.validateFormWithFormData(newFormData)) {
|
|
4451
4445
|
const errorSchema = extraErrors || {};
|
|
4452
4446
|
const errors = extraErrors ? utils.toErrorList(extraErrors) : [];
|
|
@@ -4611,20 +4605,11 @@
|
|
|
4611
4605
|
* @returns - True if the form is valid, false otherwise.
|
|
4612
4606
|
*/
|
|
4613
4607
|
validateForm() {
|
|
4614
|
-
const { omitExtraData
|
|
4608
|
+
const { omitExtraData } = this.props;
|
|
4615
4609
|
let { formData: newFormData } = this.state;
|
|
4616
4610
|
if (omitExtraData === true) {
|
|
4617
4611
|
newFormData = this.omitExtraData(newFormData);
|
|
4618
4612
|
}
|
|
4619
|
-
if (removeEmptyOptionalObjects) {
|
|
4620
|
-
const { schemaUtils, schema } = this.state;
|
|
4621
|
-
newFormData = utils.removeOptionalEmptyObjects(
|
|
4622
|
-
schemaUtils.getValidator(),
|
|
4623
|
-
schema,
|
|
4624
|
-
schemaUtils.getRootSchema(),
|
|
4625
|
-
newFormData
|
|
4626
|
-
);
|
|
4627
|
-
}
|
|
4628
4613
|
return this.validateFormWithFormData(newFormData);
|
|
4629
4614
|
}
|
|
4630
4615
|
/** Renders the `Form` fields inside the <form> | `tagName` or `_internalFormWrapper`, rendering any errors if
|
|
@@ -4701,8 +4686,26 @@
|
|
|
4701
4686
|
);
|
|
4702
4687
|
}
|
|
4703
4688
|
};
|
|
4689
|
+
function getTestRegistry(rootSchema, fields2 = {}, templates2 = {}, widgets2 = {}, formContext = {}, globalFormOptions = {
|
|
4690
|
+
idPrefix: utils.DEFAULT_ID_PREFIX,
|
|
4691
|
+
idSeparator: utils.DEFAULT_ID_SEPARATOR,
|
|
4692
|
+
useFallbackUiForUnsupportedType: false
|
|
4693
|
+
}) {
|
|
4694
|
+
const defaults = getDefaultRegistry();
|
|
4695
|
+
const schemaUtils = utils.createSchemaUtils(validator, rootSchema);
|
|
4696
|
+
return {
|
|
4697
|
+
fields: { ...defaults.fields, ...fields2 },
|
|
4698
|
+
templates: { ...defaults.templates, ...templates2 },
|
|
4699
|
+
widgets: { ...defaults.widgets, ...widgets2 },
|
|
4700
|
+
formContext,
|
|
4701
|
+
rootSchema,
|
|
4702
|
+
schemaUtils,
|
|
4703
|
+
translateString: utils.englishStringTranslator,
|
|
4704
|
+
globalFormOptions
|
|
4705
|
+
};
|
|
4706
|
+
}
|
|
4704
4707
|
function withTheme(themeProps) {
|
|
4705
|
-
return react.forwardRef(
|
|
4708
|
+
return react$1.forwardRef(
|
|
4706
4709
|
({ fields: fields2, widgets: widgets2, templates: templates2, ...directProps }, ref) => {
|
|
4707
4710
|
fields2 = { ...themeProps?.fields, ...fields2 };
|
|
4708
4711
|
widgets2 = { ...themeProps?.widgets, ...widgets2 };
|
|
@@ -4728,24 +4731,6 @@
|
|
|
4728
4731
|
}
|
|
4729
4732
|
);
|
|
4730
4733
|
}
|
|
4731
|
-
function getTestRegistry(rootSchema, fields2 = {}, templates2 = {}, widgets2 = {}, formContext = {}, globalFormOptions = {
|
|
4732
|
-
idPrefix: utils.DEFAULT_ID_PREFIX,
|
|
4733
|
-
idSeparator: utils.DEFAULT_ID_SEPARATOR,
|
|
4734
|
-
useFallbackUiForUnsupportedType: false
|
|
4735
|
-
}) {
|
|
4736
|
-
const defaults = getDefaultRegistry();
|
|
4737
|
-
const schemaUtils = utils.createSchemaUtils(validator, rootSchema);
|
|
4738
|
-
return {
|
|
4739
|
-
fields: { ...defaults.fields, ...fields2 },
|
|
4740
|
-
templates: { ...defaults.templates, ...templates2 },
|
|
4741
|
-
widgets: { ...defaults.widgets, ...widgets2 },
|
|
4742
|
-
formContext,
|
|
4743
|
-
rootSchema,
|
|
4744
|
-
schemaUtils,
|
|
4745
|
-
translateString: utils.englishStringTranslator,
|
|
4746
|
-
globalFormOptions
|
|
4747
|
-
};
|
|
4748
|
-
}
|
|
4749
4734
|
|
|
4750
4735
|
// src/index.ts
|
|
4751
4736
|
var index_default = Form;
|