@rjsf/core 5.2.1 → 5.3.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.cjs.development.js +194 -99
- package/dist/core.cjs.development.js.map +1 -1
- package/dist/core.cjs.production.min.js +1 -1
- package/dist/core.cjs.production.min.js.map +1 -1
- package/dist/core.esm.js +193 -99
- package/dist/core.esm.js.map +1 -1
- package/dist/core.umd.development.js +196 -102
- package/dist/core.umd.development.js.map +1 -1
- package/dist/core.umd.production.min.js +1 -1
- package/dist/core.umd.production.min.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/package.json +12 -12
|
@@ -9,13 +9,14 @@ var get = require('lodash/get');
|
|
|
9
9
|
var isEmpty = require('lodash/isEmpty');
|
|
10
10
|
var _pick = require('lodash/pick');
|
|
11
11
|
var _toPath = require('lodash/toPath');
|
|
12
|
+
var cloneDeep = require('lodash/cloneDeep');
|
|
12
13
|
var isObject = require('lodash/isObject');
|
|
13
14
|
var set = require('lodash/set');
|
|
14
15
|
var nanoid = require('nanoid');
|
|
15
16
|
var omit = require('lodash/omit');
|
|
17
|
+
var Markdown = require('markdown-to-jsx');
|
|
16
18
|
var has = require('lodash/has');
|
|
17
19
|
var unset = require('lodash/unset');
|
|
18
|
-
var Markdown = require('markdown-to-jsx');
|
|
19
20
|
|
|
20
21
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
21
22
|
|
|
@@ -23,12 +24,13 @@ var get__default = /*#__PURE__*/_interopDefaultLegacy(get);
|
|
|
23
24
|
var isEmpty__default = /*#__PURE__*/_interopDefaultLegacy(isEmpty);
|
|
24
25
|
var _pick__default = /*#__PURE__*/_interopDefaultLegacy(_pick);
|
|
25
26
|
var _toPath__default = /*#__PURE__*/_interopDefaultLegacy(_toPath);
|
|
27
|
+
var cloneDeep__default = /*#__PURE__*/_interopDefaultLegacy(cloneDeep);
|
|
26
28
|
var isObject__default = /*#__PURE__*/_interopDefaultLegacy(isObject);
|
|
27
29
|
var set__default = /*#__PURE__*/_interopDefaultLegacy(set);
|
|
28
30
|
var omit__default = /*#__PURE__*/_interopDefaultLegacy(omit);
|
|
31
|
+
var Markdown__default = /*#__PURE__*/_interopDefaultLegacy(Markdown);
|
|
29
32
|
var has__default = /*#__PURE__*/_interopDefaultLegacy(has);
|
|
30
33
|
var unset__default = /*#__PURE__*/_interopDefaultLegacy(unset);
|
|
31
|
-
var Markdown__default = /*#__PURE__*/_interopDefaultLegacy(Markdown);
|
|
32
34
|
|
|
33
35
|
function _defineProperties(target, props) {
|
|
34
36
|
for (var i = 0; i < props.length; i++) {
|
|
@@ -165,6 +167,31 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
165
167
|
_this._handleAddClick(event, index);
|
|
166
168
|
};
|
|
167
169
|
};
|
|
170
|
+
_this.onCopyIndexClick = function (index) {
|
|
171
|
+
return function (event) {
|
|
172
|
+
if (event) {
|
|
173
|
+
event.preventDefault();
|
|
174
|
+
}
|
|
175
|
+
var onChange = _this.props.onChange;
|
|
176
|
+
var keyedFormData = _this.state.keyedFormData;
|
|
177
|
+
var newKeyedFormDataRow = {
|
|
178
|
+
key: generateRowId(),
|
|
179
|
+
item: cloneDeep__default["default"](keyedFormData[index].item)
|
|
180
|
+
};
|
|
181
|
+
var newKeyedFormData = [].concat(keyedFormData);
|
|
182
|
+
if (index !== undefined) {
|
|
183
|
+
newKeyedFormData.splice(index + 1, 0, newKeyedFormDataRow);
|
|
184
|
+
} else {
|
|
185
|
+
newKeyedFormData.push(newKeyedFormDataRow);
|
|
186
|
+
}
|
|
187
|
+
_this.setState({
|
|
188
|
+
keyedFormData: newKeyedFormData,
|
|
189
|
+
updatedKeyedFormData: true
|
|
190
|
+
}, function () {
|
|
191
|
+
return onChange(keyedToPlainFormData(newKeyedFormData));
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
};
|
|
168
195
|
_this.onDropIndexClick = function (index) {
|
|
169
196
|
return function (event) {
|
|
170
197
|
if (event) {
|
|
@@ -324,8 +351,9 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
324
351
|
_proto.canAddItem = function canAddItem(formItems) {
|
|
325
352
|
var _this$props6 = this.props,
|
|
326
353
|
schema = _this$props6.schema,
|
|
327
|
-
uiSchema = _this$props6.uiSchema
|
|
328
|
-
|
|
354
|
+
uiSchema = _this$props6.uiSchema,
|
|
355
|
+
registry = _this$props6.registry;
|
|
356
|
+
var _getUiOptions = utils.getUiOptions(uiSchema, registry.globalUiOptions),
|
|
329
357
|
addable = _getUiOptions.addable;
|
|
330
358
|
if (addable !== false) {
|
|
331
359
|
// if ui:options.addable was not explicitly set to false, we can add
|
|
@@ -767,10 +795,8 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
767
795
|
canAdd = props.canAdd,
|
|
768
796
|
_props$canRemove = props.canRemove,
|
|
769
797
|
canRemove = _props$canRemove === void 0 ? true : _props$canRemove,
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
_props$canMoveDown = props.canMoveDown,
|
|
773
|
-
canMoveDown = _props$canMoveDown === void 0 ? true : _props$canMoveDown,
|
|
798
|
+
canMoveUp = props.canMoveUp,
|
|
799
|
+
canMoveDown = props.canMoveDown,
|
|
774
800
|
itemSchema = props.itemSchema,
|
|
775
801
|
itemData = props.itemData,
|
|
776
802
|
itemUiSchema = props.itemUiSchema,
|
|
@@ -792,16 +818,20 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
792
818
|
formContext = _this$props13.formContext;
|
|
793
819
|
var _registry$fields = registry.fields,
|
|
794
820
|
ArraySchemaField = _registry$fields.ArraySchemaField,
|
|
795
|
-
SchemaField = _registry$fields.SchemaField
|
|
821
|
+
SchemaField = _registry$fields.SchemaField,
|
|
822
|
+
globalUiOptions = registry.globalUiOptions;
|
|
796
823
|
var ItemSchemaField = ArraySchemaField || SchemaField;
|
|
797
|
-
var _getUiOptions5 = utils.getUiOptions(uiSchema),
|
|
824
|
+
var _getUiOptions5 = utils.getUiOptions(uiSchema, globalUiOptions),
|
|
798
825
|
_getUiOptions5$ordera = _getUiOptions5.orderable,
|
|
799
826
|
orderable = _getUiOptions5$ordera === void 0 ? true : _getUiOptions5$ordera,
|
|
800
827
|
_getUiOptions5$remova = _getUiOptions5.removable,
|
|
801
|
-
removable = _getUiOptions5$remova === void 0 ? true : _getUiOptions5$remova
|
|
828
|
+
removable = _getUiOptions5$remova === void 0 ? true : _getUiOptions5$remova,
|
|
829
|
+
_getUiOptions5$copyab = _getUiOptions5.copyable,
|
|
830
|
+
copyable = _getUiOptions5$copyab === void 0 ? false : _getUiOptions5$copyab;
|
|
802
831
|
var has = {
|
|
803
832
|
moveUp: orderable && canMoveUp,
|
|
804
833
|
moveDown: orderable && canMoveDown,
|
|
834
|
+
copy: copyable && canAdd,
|
|
805
835
|
remove: removable && canRemove,
|
|
806
836
|
toolbar: false
|
|
807
837
|
};
|
|
@@ -834,6 +864,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
834
864
|
className: 'array-item',
|
|
835
865
|
disabled: disabled,
|
|
836
866
|
canAdd: canAdd,
|
|
867
|
+
hasCopy: has.copy,
|
|
837
868
|
hasToolbar: has.toolbar,
|
|
838
869
|
hasMoveUp: has.moveUp,
|
|
839
870
|
hasMoveDown: has.moveDown,
|
|
@@ -842,6 +873,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
842
873
|
totalItems: totalItems,
|
|
843
874
|
key: key,
|
|
844
875
|
onAddIndexClick: this.onAddIndexClick,
|
|
876
|
+
onCopyIndexClick: this.onCopyIndexClick,
|
|
845
877
|
onDropIndexClick: this.onDropIndexClick,
|
|
846
878
|
onReorderClick: this.onReorderClick,
|
|
847
879
|
readonly: readonly,
|
|
@@ -1294,8 +1326,10 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1294
1326
|
};
|
|
1295
1327
|
};
|
|
1296
1328
|
_this.getAvailableKey = function (preferredKey, formData) {
|
|
1297
|
-
var
|
|
1298
|
-
|
|
1329
|
+
var _this$props3 = _this.props,
|
|
1330
|
+
uiSchema = _this$props3.uiSchema,
|
|
1331
|
+
registry = _this$props3.registry;
|
|
1332
|
+
var _getUiOptions = utils.getUiOptions(uiSchema, registry.globalUiOptions),
|
|
1299
1333
|
_getUiOptions$duplica = _getUiOptions.duplicateKeySuffixSeparator,
|
|
1300
1334
|
duplicateKeySuffixSeparator = _getUiOptions$duplica === void 0 ? '-' : _getUiOptions$duplica;
|
|
1301
1335
|
var index = 0;
|
|
@@ -1311,10 +1345,10 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1311
1345
|
if (oldValue === value) {
|
|
1312
1346
|
return;
|
|
1313
1347
|
}
|
|
1314
|
-
var _this$
|
|
1315
|
-
formData = _this$
|
|
1316
|
-
onChange = _this$
|
|
1317
|
-
errorSchema = _this$
|
|
1348
|
+
var _this$props4 = _this.props,
|
|
1349
|
+
formData = _this$props4.formData,
|
|
1350
|
+
onChange = _this$props4.onChange,
|
|
1351
|
+
errorSchema = _this$props4.errorSchema;
|
|
1318
1352
|
value = _this.getAvailableKey(value, formData);
|
|
1319
1353
|
var newFormData = _extends({}, formData);
|
|
1320
1354
|
var newKeys = (_newKeys = {}, _newKeys[oldValue] = value, _newKeys);
|
|
@@ -1335,10 +1369,10 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1335
1369
|
if (!schema.additionalProperties) {
|
|
1336
1370
|
return;
|
|
1337
1371
|
}
|
|
1338
|
-
var _this$
|
|
1339
|
-
formData = _this$
|
|
1340
|
-
onChange = _this$
|
|
1341
|
-
registry = _this$
|
|
1372
|
+
var _this$props5 = _this.props,
|
|
1373
|
+
formData = _this$props5.formData,
|
|
1374
|
+
onChange = _this$props5.onChange,
|
|
1375
|
+
registry = _this$props5.registry;
|
|
1342
1376
|
var newFormData = _extends({}, formData);
|
|
1343
1377
|
var type = undefined;
|
|
1344
1378
|
if (isObject__default["default"](schema.additionalProperties)) {
|
|
@@ -1413,35 +1447,36 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1413
1447
|
*/
|
|
1414
1448
|
_proto.render = function render() {
|
|
1415
1449
|
var _this2 = this;
|
|
1416
|
-
var _this$
|
|
1417
|
-
rawSchema = _this$
|
|
1418
|
-
_this$
|
|
1419
|
-
uiSchema = _this$
|
|
1420
|
-
formData = _this$
|
|
1421
|
-
errorSchema = _this$
|
|
1422
|
-
idSchema = _this$
|
|
1423
|
-
name = _this$
|
|
1424
|
-
_this$
|
|
1425
|
-
required = _this$
|
|
1426
|
-
_this$
|
|
1427
|
-
disabled = _this$
|
|
1428
|
-
_this$
|
|
1429
|
-
readonly = _this$
|
|
1430
|
-
hideError = _this$
|
|
1431
|
-
idPrefix = _this$
|
|
1432
|
-
idSeparator = _this$
|
|
1433
|
-
onBlur = _this$
|
|
1434
|
-
onFocus = _this$
|
|
1435
|
-
registry = _this$
|
|
1450
|
+
var _this$props6 = this.props,
|
|
1451
|
+
rawSchema = _this$props6.schema,
|
|
1452
|
+
_this$props6$uiSchema = _this$props6.uiSchema,
|
|
1453
|
+
uiSchema = _this$props6$uiSchema === void 0 ? {} : _this$props6$uiSchema,
|
|
1454
|
+
formData = _this$props6.formData,
|
|
1455
|
+
errorSchema = _this$props6.errorSchema,
|
|
1456
|
+
idSchema = _this$props6.idSchema,
|
|
1457
|
+
name = _this$props6.name,
|
|
1458
|
+
_this$props6$required = _this$props6.required,
|
|
1459
|
+
required = _this$props6$required === void 0 ? false : _this$props6$required,
|
|
1460
|
+
_this$props6$disabled = _this$props6.disabled,
|
|
1461
|
+
disabled = _this$props6$disabled === void 0 ? false : _this$props6$disabled,
|
|
1462
|
+
_this$props6$readonly = _this$props6.readonly,
|
|
1463
|
+
readonly = _this$props6$readonly === void 0 ? false : _this$props6$readonly,
|
|
1464
|
+
hideError = _this$props6.hideError,
|
|
1465
|
+
idPrefix = _this$props6.idPrefix,
|
|
1466
|
+
idSeparator = _this$props6.idSeparator,
|
|
1467
|
+
onBlur = _this$props6.onBlur,
|
|
1468
|
+
onFocus = _this$props6.onFocus,
|
|
1469
|
+
registry = _this$props6.registry;
|
|
1436
1470
|
var fields = registry.fields,
|
|
1437
1471
|
formContext = registry.formContext,
|
|
1438
|
-
schemaUtils = registry.schemaUtils
|
|
1472
|
+
schemaUtils = registry.schemaUtils,
|
|
1473
|
+
translateString = registry.translateString;
|
|
1439
1474
|
var SchemaField = fields.SchemaField;
|
|
1440
1475
|
var schema = schemaUtils.retrieveSchema(rawSchema, formData);
|
|
1441
1476
|
var uiOptions = utils.getUiOptions(uiSchema);
|
|
1442
1477
|
var _schema$properties = schema.properties,
|
|
1443
1478
|
schemaProperties = _schema$properties === void 0 ? {} : _schema$properties;
|
|
1444
|
-
var title = schema.title === undefined ? name : schema.title;
|
|
1479
|
+
var title = uiOptions.title || (schema.title === undefined ? name : schema.title);
|
|
1445
1480
|
var description = uiOptions.description || schema.description;
|
|
1446
1481
|
var orderedProperties;
|
|
1447
1482
|
try {
|
|
@@ -1449,14 +1484,14 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1449
1484
|
orderedProperties = utils.orderProperties(properties, uiOptions.order);
|
|
1450
1485
|
} catch (err) {
|
|
1451
1486
|
return jsxRuntime.jsxs("div", {
|
|
1452
|
-
children: [jsxRuntime.
|
|
1487
|
+
children: [jsxRuntime.jsx("p", {
|
|
1453
1488
|
className: 'config-error',
|
|
1454
1489
|
style: {
|
|
1455
1490
|
color: 'red'
|
|
1456
1491
|
},
|
|
1457
|
-
children:
|
|
1458
|
-
children: err.message
|
|
1459
|
-
})
|
|
1492
|
+
children: jsxRuntime.jsx(Markdown__default["default"], {
|
|
1493
|
+
children: translateString(utils.TranslatableString.InvalidObjectField, [name || 'root', err.message])
|
|
1494
|
+
})
|
|
1460
1495
|
}), jsxRuntime.jsx("pre", {
|
|
1461
1496
|
children: JSON.stringify(schema)
|
|
1462
1497
|
})]
|
|
@@ -1464,7 +1499,7 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1464
1499
|
}
|
|
1465
1500
|
var Template = utils.getTemplate('ObjectFieldTemplate', registry, uiOptions);
|
|
1466
1501
|
var templateProps = {
|
|
1467
|
-
title:
|
|
1502
|
+
title: title,
|
|
1468
1503
|
description: description,
|
|
1469
1504
|
properties: orderedProperties.map(function (name) {
|
|
1470
1505
|
var addedByAdditionalProperties = has__default["default"](schema, [utils.PROPERTIES_KEY, name, utils.ADDITIONAL_PROPERTY_FLAG]);
|
|
@@ -1592,8 +1627,9 @@ function SchemaFieldRender(props) {
|
|
|
1592
1627
|
_props$wasPropertyKey = props.wasPropertyKeyModified,
|
|
1593
1628
|
wasPropertyKeyModified = _props$wasPropertyKey === void 0 ? false : _props$wasPropertyKey;
|
|
1594
1629
|
var formContext = registry.formContext,
|
|
1595
|
-
schemaUtils = registry.schemaUtils
|
|
1596
|
-
|
|
1630
|
+
schemaUtils = registry.schemaUtils,
|
|
1631
|
+
globalUiOptions = registry.globalUiOptions;
|
|
1632
|
+
var uiOptions = utils.getUiOptions(uiSchema, globalUiOptions);
|
|
1597
1633
|
var FieldTemplate = utils.getTemplate('FieldTemplate', registry, uiOptions);
|
|
1598
1634
|
var DescriptionFieldTemplate = utils.getTemplate('DescriptionFieldTemplate', registry, uiOptions);
|
|
1599
1635
|
var FieldHelpTemplate = utils.getTemplate('FieldHelpTemplate', registry, uiOptions);
|
|
@@ -1618,7 +1654,7 @@ function SchemaFieldRender(props) {
|
|
|
1618
1654
|
if (Object.keys(schema).length === 0) {
|
|
1619
1655
|
return null;
|
|
1620
1656
|
}
|
|
1621
|
-
var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema);
|
|
1657
|
+
var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
1622
1658
|
var _ref = errorSchema || {},
|
|
1623
1659
|
__errors = _ref.__errors,
|
|
1624
1660
|
fieldErrorSchema = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
@@ -1915,13 +1951,16 @@ function ArrayFieldItemTemplate(props) {
|
|
|
1915
1951
|
hasMoveDown = props.hasMoveDown,
|
|
1916
1952
|
hasMoveUp = props.hasMoveUp,
|
|
1917
1953
|
hasRemove = props.hasRemove,
|
|
1954
|
+
hasCopy = props.hasCopy,
|
|
1918
1955
|
index = props.index,
|
|
1956
|
+
onCopyIndexClick = props.onCopyIndexClick,
|
|
1919
1957
|
onDropIndexClick = props.onDropIndexClick,
|
|
1920
1958
|
onReorderClick = props.onReorderClick,
|
|
1921
1959
|
readonly = props.readonly,
|
|
1922
1960
|
registry = props.registry,
|
|
1923
1961
|
uiSchema = props.uiSchema;
|
|
1924
1962
|
var _registry$templates$B = registry.templates.ButtonTemplates,
|
|
1963
|
+
CopyButton = _registry$templates$B.CopyButton,
|
|
1925
1964
|
MoveDownButton = _registry$templates$B.MoveDownButton,
|
|
1926
1965
|
MoveUpButton = _registry$templates$B.MoveUpButton,
|
|
1927
1966
|
RemoveButton = _registry$templates$B.RemoveButton;
|
|
@@ -1956,6 +1995,12 @@ function ArrayFieldItemTemplate(props) {
|
|
|
1956
1995
|
onClick: onReorderClick(index, index + 1),
|
|
1957
1996
|
uiSchema: uiSchema,
|
|
1958
1997
|
registry: registry
|
|
1998
|
+
}), hasCopy && jsxRuntime.jsx(CopyButton, {
|
|
1999
|
+
style: btnStyle,
|
|
2000
|
+
disabled: disabled || readonly,
|
|
2001
|
+
onClick: onCopyIndexClick(index),
|
|
2002
|
+
uiSchema: uiSchema,
|
|
2003
|
+
registry: registry
|
|
1959
2004
|
}), hasRemove && jsxRuntime.jsx(RemoveButton, {
|
|
1960
2005
|
style: btnStyle,
|
|
1961
2006
|
disabled: disabled || readonly,
|
|
@@ -2164,6 +2209,15 @@ function IconButton(props) {
|
|
|
2164
2209
|
})
|
|
2165
2210
|
}));
|
|
2166
2211
|
}
|
|
2212
|
+
function CopyButton(props) {
|
|
2213
|
+
var translateString = props.registry.translateString;
|
|
2214
|
+
return jsxRuntime.jsx(IconButton, _extends({
|
|
2215
|
+
title: translateString(utils.TranslatableString.CopyButton),
|
|
2216
|
+
className: 'array-item-copy'
|
|
2217
|
+
}, props, {
|
|
2218
|
+
icon: 'copy'
|
|
2219
|
+
}));
|
|
2220
|
+
}
|
|
2167
2221
|
function MoveDownButton(props) {
|
|
2168
2222
|
var translateString = props.registry.translateString;
|
|
2169
2223
|
return jsxRuntime.jsx(IconButton, _extends({
|
|
@@ -2222,6 +2276,7 @@ function buttonTemplates() {
|
|
|
2222
2276
|
return {
|
|
2223
2277
|
SubmitButton: SubmitButton,
|
|
2224
2278
|
AddButton: AddButton,
|
|
2279
|
+
CopyButton: CopyButton,
|
|
2225
2280
|
MoveDownButton: MoveDownButton,
|
|
2226
2281
|
MoveUpButton: MoveUpButton,
|
|
2227
2282
|
RemoveButton: RemoveButton
|
|
@@ -3382,6 +3437,26 @@ function TextWidget(props) {
|
|
|
3382
3437
|
return jsxRuntime.jsx(BaseInputTemplate, _extends({}, props));
|
|
3383
3438
|
}
|
|
3384
3439
|
|
|
3440
|
+
/** The `TimeWidget` component uses the `BaseInputTemplate` changing the type to `time` and transforms
|
|
3441
|
+
* the value to undefined when it is falsy during the `onChange` handling.
|
|
3442
|
+
*
|
|
3443
|
+
* @param props - The `WidgetProps` for this component
|
|
3444
|
+
*/
|
|
3445
|
+
function TimeWidget(props) {
|
|
3446
|
+
var onChange = props.onChange,
|
|
3447
|
+
options = props.options,
|
|
3448
|
+
registry = props.registry;
|
|
3449
|
+
var BaseInputTemplate = utils.getTemplate('BaseInputTemplate', registry, options);
|
|
3450
|
+
var handleChange = react.useCallback(function (value) {
|
|
3451
|
+
return onChange(value ? value + ":00" : undefined);
|
|
3452
|
+
}, [onChange]);
|
|
3453
|
+
return jsxRuntime.jsx(BaseInputTemplate, _extends({
|
|
3454
|
+
type: 'time'
|
|
3455
|
+
}, props, {
|
|
3456
|
+
onChange: handleChange
|
|
3457
|
+
}));
|
|
3458
|
+
}
|
|
3459
|
+
|
|
3385
3460
|
/** The `URLWidget` component uses the `BaseInputTemplate` changing the type to `url`.
|
|
3386
3461
|
*
|
|
3387
3462
|
* @param props - The `WidgetProps` for this component
|
|
@@ -3410,24 +3485,25 @@ function UpDownWidget(props) {
|
|
|
3410
3485
|
|
|
3411
3486
|
function widgets() {
|
|
3412
3487
|
return {
|
|
3488
|
+
AltDateWidget: AltDateWidget,
|
|
3489
|
+
AltDateTimeWidget: AltDateTimeWidget,
|
|
3490
|
+
CheckboxWidget: CheckboxWidget,
|
|
3491
|
+
CheckboxesWidget: CheckboxesWidget,
|
|
3492
|
+
ColorWidget: ColorWidget,
|
|
3493
|
+
DateWidget: DateWidget,
|
|
3494
|
+
DateTimeWidget: DateTimeWidget,
|
|
3495
|
+
EmailWidget: EmailWidget,
|
|
3496
|
+
FileWidget: FileWidget,
|
|
3497
|
+
HiddenWidget: HiddenWidget,
|
|
3413
3498
|
PasswordWidget: PasswordWidget,
|
|
3414
3499
|
RadioWidget: RadioWidget,
|
|
3415
|
-
UpDownWidget: UpDownWidget,
|
|
3416
3500
|
RangeWidget: RangeWidget,
|
|
3417
3501
|
SelectWidget: SelectWidget,
|
|
3418
3502
|
TextWidget: TextWidget,
|
|
3419
|
-
DateWidget: DateWidget,
|
|
3420
|
-
DateTimeWidget: DateTimeWidget,
|
|
3421
|
-
AltDateWidget: AltDateWidget,
|
|
3422
|
-
AltDateTimeWidget: AltDateTimeWidget,
|
|
3423
|
-
EmailWidget: EmailWidget,
|
|
3424
|
-
URLWidget: URLWidget,
|
|
3425
3503
|
TextareaWidget: TextareaWidget,
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
CheckboxWidget: CheckboxWidget,
|
|
3430
|
-
CheckboxesWidget: CheckboxesWidget
|
|
3504
|
+
TimeWidget: TimeWidget,
|
|
3505
|
+
UpDownWidget: UpDownWidget,
|
|
3506
|
+
URLWidget: URLWidget
|
|
3431
3507
|
};
|
|
3432
3508
|
}
|
|
3433
3509
|
|
|
@@ -3571,6 +3647,21 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3571
3647
|
return onChange && onChange(_extends({}, _this.state, state), id);
|
|
3572
3648
|
});
|
|
3573
3649
|
};
|
|
3650
|
+
_this.reset = function () {
|
|
3651
|
+
var onChange = _this.props.onChange;
|
|
3652
|
+
var newState = _this.getStateFromProps(_this.props, undefined);
|
|
3653
|
+
var newFormData = newState.formData;
|
|
3654
|
+
var state = {
|
|
3655
|
+
formData: newFormData,
|
|
3656
|
+
errorSchema: {},
|
|
3657
|
+
errors: [],
|
|
3658
|
+
schemaValidationErrors: [],
|
|
3659
|
+
schemaValidationErrorSchema: {}
|
|
3660
|
+
};
|
|
3661
|
+
_this.setState(state, function () {
|
|
3662
|
+
return onChange && onChange(_extends({}, _this.state, state));
|
|
3663
|
+
});
|
|
3664
|
+
};
|
|
3574
3665
|
_this.onBlur = function (id, data) {
|
|
3575
3666
|
var onBlur = _this.props.onBlur;
|
|
3576
3667
|
if (onBlur) {
|
|
@@ -3784,7 +3875,10 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3784
3875
|
/** Returns the registry for the form */
|
|
3785
3876
|
_proto.getRegistry = function getRegistry() {
|
|
3786
3877
|
var _this$props$templates;
|
|
3787
|
-
var
|
|
3878
|
+
var _this$props4 = this.props,
|
|
3879
|
+
customTranslateString = _this$props4.translateString,
|
|
3880
|
+
_this$props4$uiSchema = _this$props4.uiSchema,
|
|
3881
|
+
uiSchema = _this$props4$uiSchema === void 0 ? {} : _this$props4$uiSchema;
|
|
3788
3882
|
var schemaUtils = this.state.schemaUtils;
|
|
3789
3883
|
var _getDefaultRegistry = getDefaultRegistry(),
|
|
3790
3884
|
fields = _getDefaultRegistry.fields,
|
|
@@ -3801,7 +3895,8 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3801
3895
|
rootSchema: this.props.schema,
|
|
3802
3896
|
formContext: this.props.formContext || formContext,
|
|
3803
3897
|
schemaUtils: schemaUtils,
|
|
3804
|
-
translateString: customTranslateString || translateString
|
|
3898
|
+
translateString: customTranslateString || translateString,
|
|
3899
|
+
globalUiOptions: uiSchema[utils.UI_GLOBAL_OPTIONS_KEY]
|
|
3805
3900
|
};
|
|
3806
3901
|
}
|
|
3807
3902
|
/** Provides a function that can be used to programmatically submit the `Form` */;
|
|
@@ -3820,11 +3915,11 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3820
3915
|
* @param error - The error on which to focus
|
|
3821
3916
|
*/;
|
|
3822
3917
|
_proto.focusOnError = function focusOnError(error) {
|
|
3823
|
-
var _this$
|
|
3824
|
-
_this$
|
|
3825
|
-
idPrefix = _this$
|
|
3826
|
-
_this$
|
|
3827
|
-
idSeparator = _this$
|
|
3918
|
+
var _this$props5 = this.props,
|
|
3919
|
+
_this$props5$idPrefix = _this$props5.idPrefix,
|
|
3920
|
+
idPrefix = _this$props5$idPrefix === void 0 ? 'root' : _this$props5$idPrefix,
|
|
3921
|
+
_this$props5$idSepara = _this$props5.idSeparator,
|
|
3922
|
+
idSeparator = _this$props5$idSepara === void 0 ? '_' : _this$props5$idSepara;
|
|
3828
3923
|
var property = error.property;
|
|
3829
3924
|
var path = _toPath__default["default"](property);
|
|
3830
3925
|
if (path[0] === '') {
|
|
@@ -3850,10 +3945,10 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3850
3945
|
* @returns - True if the form is valid, false otherwise.
|
|
3851
3946
|
*/;
|
|
3852
3947
|
_proto.validateForm = function validateForm() {
|
|
3853
|
-
var _this$
|
|
3854
|
-
extraErrors = _this$
|
|
3855
|
-
focusOnFirstError = _this$
|
|
3856
|
-
onError = _this$
|
|
3948
|
+
var _this$props6 = this.props,
|
|
3949
|
+
extraErrors = _this$props6.extraErrors,
|
|
3950
|
+
focusOnFirstError = _this$props6.focusOnFirstError,
|
|
3951
|
+
onError = _this$props6.onError;
|
|
3857
3952
|
var formData = this.state.formData;
|
|
3858
3953
|
var schemaUtils = this.state.schemaUtils;
|
|
3859
3954
|
var schemaValidation = this.validate(formData);
|
|
@@ -3890,31 +3985,31 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3890
3985
|
* needed along with the submit button or any children of the form.
|
|
3891
3986
|
*/;
|
|
3892
3987
|
_proto.render = function render() {
|
|
3893
|
-
var _this$
|
|
3894
|
-
children = _this$
|
|
3895
|
-
id = _this$
|
|
3896
|
-
idPrefix = _this$
|
|
3897
|
-
idSeparator = _this$
|
|
3898
|
-
_this$
|
|
3899
|
-
className = _this$
|
|
3900
|
-
tagName = _this$
|
|
3901
|
-
name = _this$
|
|
3902
|
-
method = _this$
|
|
3903
|
-
target = _this$
|
|
3904
|
-
action = _this$
|
|
3905
|
-
autoComplete = _this$
|
|
3906
|
-
enctype = _this$
|
|
3907
|
-
acceptcharset = _this$
|
|
3908
|
-
_this$
|
|
3909
|
-
noHtml5Validate = _this$
|
|
3910
|
-
_this$
|
|
3911
|
-
disabled = _this$
|
|
3912
|
-
_this$
|
|
3913
|
-
readonly = _this$
|
|
3914
|
-
formContext = _this$
|
|
3915
|
-
_this$
|
|
3916
|
-
showErrorList = _this$
|
|
3917
|
-
_internalFormWrapper = _this$
|
|
3988
|
+
var _this$props7 = this.props,
|
|
3989
|
+
children = _this$props7.children,
|
|
3990
|
+
id = _this$props7.id,
|
|
3991
|
+
idPrefix = _this$props7.idPrefix,
|
|
3992
|
+
idSeparator = _this$props7.idSeparator,
|
|
3993
|
+
_this$props7$classNam = _this$props7.className,
|
|
3994
|
+
className = _this$props7$classNam === void 0 ? '' : _this$props7$classNam,
|
|
3995
|
+
tagName = _this$props7.tagName,
|
|
3996
|
+
name = _this$props7.name,
|
|
3997
|
+
method = _this$props7.method,
|
|
3998
|
+
target = _this$props7.target,
|
|
3999
|
+
action = _this$props7.action,
|
|
4000
|
+
autoComplete = _this$props7.autoComplete,
|
|
4001
|
+
enctype = _this$props7.enctype,
|
|
4002
|
+
acceptcharset = _this$props7.acceptcharset,
|
|
4003
|
+
_this$props7$noHtml5V = _this$props7.noHtml5Validate,
|
|
4004
|
+
noHtml5Validate = _this$props7$noHtml5V === void 0 ? false : _this$props7$noHtml5V,
|
|
4005
|
+
_this$props7$disabled = _this$props7.disabled,
|
|
4006
|
+
disabled = _this$props7$disabled === void 0 ? false : _this$props7$disabled,
|
|
4007
|
+
_this$props7$readonly = _this$props7.readonly,
|
|
4008
|
+
readonly = _this$props7$readonly === void 0 ? false : _this$props7$readonly,
|
|
4009
|
+
formContext = _this$props7.formContext,
|
|
4010
|
+
_this$props7$showErro = _this$props7.showErrorList,
|
|
4011
|
+
showErrorList = _this$props7$showErro === void 0 ? 'top' : _this$props7$showErro,
|
|
4012
|
+
_internalFormWrapper = _this$props7._internalFormWrapper;
|
|
3918
4013
|
var _this$state4 = this.state,
|
|
3919
4014
|
schema = _this$state4.schema,
|
|
3920
4015
|
uiSchema = _this$state4.uiSchema,
|