@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
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react/jsx-runtime'), require('react'), require('@rjsf/utils'), require('lodash-es/get'), require('lodash-es/isEmpty'), require('lodash-es/pick'), require('lodash-es/toPath'), require('lodash-es/isObject'), require('lodash-es/set'), require('nanoid'), require('lodash-es/omit'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'react/jsx-runtime', 'react', '@rjsf/utils', 'lodash-es/get', 'lodash-es/isEmpty', 'lodash-es/pick', 'lodash-es/toPath', 'lodash-es/isObject', 'lodash-es/set', 'nanoid', 'lodash-es/omit', 'lodash-es/has', 'lodash-es/unset'
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.JSONSchemaForm = {}, global.jsxRuntime, global.React, global.utils, global.get, global.isEmpty, global._pick, global._toPath, global.isObject, global.set, global.nanoid, global.omit, global.
|
|
5
|
-
})(this, (function (exports, jsxRuntime, react, utils, get, isEmpty, _pick, _toPath, isObject, set, nanoid, omit, has, unset
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react/jsx-runtime'), require('react'), require('@rjsf/utils'), require('lodash-es/get'), require('lodash-es/isEmpty'), require('lodash-es/pick'), require('lodash-es/toPath'), require('lodash-es/cloneDeep'), require('lodash-es/isObject'), require('lodash-es/set'), require('nanoid'), require('lodash-es/omit'), require('markdown-to-jsx'), require('lodash-es/has'), require('lodash-es/unset')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'react/jsx-runtime', 'react', '@rjsf/utils', 'lodash-es/get', 'lodash-es/isEmpty', 'lodash-es/pick', 'lodash-es/toPath', 'lodash-es/cloneDeep', 'lodash-es/isObject', 'lodash-es/set', 'nanoid', 'lodash-es/omit', 'markdown-to-jsx', 'lodash-es/has', 'lodash-es/unset'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.JSONSchemaForm = {}, global.jsxRuntime, global.React, global.utils, global.get, global.isEmpty, global._pick, global._toPath, global.cloneDeep, global.isObject, global.set, global.nanoid, global.omit, global.Markdown, global.has, global.unset));
|
|
5
|
+
})(this, (function (exports, jsxRuntime, react, utils, get, isEmpty, _pick, _toPath, cloneDeep, isObject, set, nanoid, omit, Markdown, has, unset) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -10,12 +10,13 @@
|
|
|
10
10
|
var isEmpty__default = /*#__PURE__*/_interopDefaultLegacy(isEmpty);
|
|
11
11
|
var _pick__default = /*#__PURE__*/_interopDefaultLegacy(_pick);
|
|
12
12
|
var _toPath__default = /*#__PURE__*/_interopDefaultLegacy(_toPath);
|
|
13
|
+
var cloneDeep__default = /*#__PURE__*/_interopDefaultLegacy(cloneDeep);
|
|
13
14
|
var isObject__default = /*#__PURE__*/_interopDefaultLegacy(isObject);
|
|
14
15
|
var set__default = /*#__PURE__*/_interopDefaultLegacy(set);
|
|
15
16
|
var omit__default = /*#__PURE__*/_interopDefaultLegacy(omit);
|
|
17
|
+
var Markdown__default = /*#__PURE__*/_interopDefaultLegacy(Markdown);
|
|
16
18
|
var has__default = /*#__PURE__*/_interopDefaultLegacy(has);
|
|
17
19
|
var unset__default = /*#__PURE__*/_interopDefaultLegacy(unset);
|
|
18
|
-
var Markdown__default = /*#__PURE__*/_interopDefaultLegacy(Markdown);
|
|
19
20
|
|
|
20
21
|
function _defineProperties(target, props) {
|
|
21
22
|
for (var i = 0; i < props.length; i++) {
|
|
@@ -152,6 +153,31 @@
|
|
|
152
153
|
_this._handleAddClick(event, index);
|
|
153
154
|
};
|
|
154
155
|
};
|
|
156
|
+
_this.onCopyIndexClick = function (index) {
|
|
157
|
+
return function (event) {
|
|
158
|
+
if (event) {
|
|
159
|
+
event.preventDefault();
|
|
160
|
+
}
|
|
161
|
+
var onChange = _this.props.onChange;
|
|
162
|
+
var keyedFormData = _this.state.keyedFormData;
|
|
163
|
+
var newKeyedFormDataRow = {
|
|
164
|
+
key: generateRowId(),
|
|
165
|
+
item: cloneDeep__default["default"](keyedFormData[index].item)
|
|
166
|
+
};
|
|
167
|
+
var newKeyedFormData = [].concat(keyedFormData);
|
|
168
|
+
if (index !== undefined) {
|
|
169
|
+
newKeyedFormData.splice(index + 1, 0, newKeyedFormDataRow);
|
|
170
|
+
} else {
|
|
171
|
+
newKeyedFormData.push(newKeyedFormDataRow);
|
|
172
|
+
}
|
|
173
|
+
_this.setState({
|
|
174
|
+
keyedFormData: newKeyedFormData,
|
|
175
|
+
updatedKeyedFormData: true
|
|
176
|
+
}, function () {
|
|
177
|
+
return onChange(keyedToPlainFormData(newKeyedFormData));
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
};
|
|
155
181
|
_this.onDropIndexClick = function (index) {
|
|
156
182
|
return function (event) {
|
|
157
183
|
if (event) {
|
|
@@ -311,8 +337,9 @@
|
|
|
311
337
|
_proto.canAddItem = function canAddItem(formItems) {
|
|
312
338
|
var _this$props6 = this.props,
|
|
313
339
|
schema = _this$props6.schema,
|
|
314
|
-
uiSchema = _this$props6.uiSchema
|
|
315
|
-
|
|
340
|
+
uiSchema = _this$props6.uiSchema,
|
|
341
|
+
registry = _this$props6.registry;
|
|
342
|
+
var _getUiOptions = utils.getUiOptions(uiSchema, registry.globalUiOptions),
|
|
316
343
|
addable = _getUiOptions.addable;
|
|
317
344
|
if (addable !== false) {
|
|
318
345
|
// if ui:options.addable was not explicitly set to false, we can add
|
|
@@ -754,10 +781,8 @@
|
|
|
754
781
|
canAdd = props.canAdd,
|
|
755
782
|
_props$canRemove = props.canRemove,
|
|
756
783
|
canRemove = _props$canRemove === void 0 ? true : _props$canRemove,
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
_props$canMoveDown = props.canMoveDown,
|
|
760
|
-
canMoveDown = _props$canMoveDown === void 0 ? true : _props$canMoveDown,
|
|
784
|
+
canMoveUp = props.canMoveUp,
|
|
785
|
+
canMoveDown = props.canMoveDown,
|
|
761
786
|
itemSchema = props.itemSchema,
|
|
762
787
|
itemData = props.itemData,
|
|
763
788
|
itemUiSchema = props.itemUiSchema,
|
|
@@ -779,16 +804,20 @@
|
|
|
779
804
|
formContext = _this$props13.formContext;
|
|
780
805
|
var _registry$fields = registry.fields,
|
|
781
806
|
ArraySchemaField = _registry$fields.ArraySchemaField,
|
|
782
|
-
SchemaField = _registry$fields.SchemaField
|
|
807
|
+
SchemaField = _registry$fields.SchemaField,
|
|
808
|
+
globalUiOptions = registry.globalUiOptions;
|
|
783
809
|
var ItemSchemaField = ArraySchemaField || SchemaField;
|
|
784
|
-
var _getUiOptions5 = utils.getUiOptions(uiSchema),
|
|
810
|
+
var _getUiOptions5 = utils.getUiOptions(uiSchema, globalUiOptions),
|
|
785
811
|
_getUiOptions5$ordera = _getUiOptions5.orderable,
|
|
786
812
|
orderable = _getUiOptions5$ordera === void 0 ? true : _getUiOptions5$ordera,
|
|
787
813
|
_getUiOptions5$remova = _getUiOptions5.removable,
|
|
788
|
-
removable = _getUiOptions5$remova === void 0 ? true : _getUiOptions5$remova
|
|
814
|
+
removable = _getUiOptions5$remova === void 0 ? true : _getUiOptions5$remova,
|
|
815
|
+
_getUiOptions5$copyab = _getUiOptions5.copyable,
|
|
816
|
+
copyable = _getUiOptions5$copyab === void 0 ? false : _getUiOptions5$copyab;
|
|
789
817
|
var has = {
|
|
790
818
|
moveUp: orderable && canMoveUp,
|
|
791
819
|
moveDown: orderable && canMoveDown,
|
|
820
|
+
copy: copyable && canAdd,
|
|
792
821
|
remove: removable && canRemove,
|
|
793
822
|
toolbar: false
|
|
794
823
|
};
|
|
@@ -821,6 +850,7 @@
|
|
|
821
850
|
className: 'array-item',
|
|
822
851
|
disabled: disabled,
|
|
823
852
|
canAdd: canAdd,
|
|
853
|
+
hasCopy: has.copy,
|
|
824
854
|
hasToolbar: has.toolbar,
|
|
825
855
|
hasMoveUp: has.moveUp,
|
|
826
856
|
hasMoveDown: has.moveDown,
|
|
@@ -829,6 +859,7 @@
|
|
|
829
859
|
totalItems: totalItems,
|
|
830
860
|
key: key,
|
|
831
861
|
onAddIndexClick: this.onAddIndexClick,
|
|
862
|
+
onCopyIndexClick: this.onCopyIndexClick,
|
|
832
863
|
onDropIndexClick: this.onDropIndexClick,
|
|
833
864
|
onReorderClick: this.onReorderClick,
|
|
834
865
|
readonly: readonly,
|
|
@@ -1281,8 +1312,10 @@
|
|
|
1281
1312
|
};
|
|
1282
1313
|
};
|
|
1283
1314
|
_this.getAvailableKey = function (preferredKey, formData) {
|
|
1284
|
-
var
|
|
1285
|
-
|
|
1315
|
+
var _this$props3 = _this.props,
|
|
1316
|
+
uiSchema = _this$props3.uiSchema,
|
|
1317
|
+
registry = _this$props3.registry;
|
|
1318
|
+
var _getUiOptions = utils.getUiOptions(uiSchema, registry.globalUiOptions),
|
|
1286
1319
|
_getUiOptions$duplica = _getUiOptions.duplicateKeySuffixSeparator,
|
|
1287
1320
|
duplicateKeySuffixSeparator = _getUiOptions$duplica === void 0 ? '-' : _getUiOptions$duplica;
|
|
1288
1321
|
var index = 0;
|
|
@@ -1298,10 +1331,10 @@
|
|
|
1298
1331
|
if (oldValue === value) {
|
|
1299
1332
|
return;
|
|
1300
1333
|
}
|
|
1301
|
-
var _this$
|
|
1302
|
-
formData = _this$
|
|
1303
|
-
onChange = _this$
|
|
1304
|
-
errorSchema = _this$
|
|
1334
|
+
var _this$props4 = _this.props,
|
|
1335
|
+
formData = _this$props4.formData,
|
|
1336
|
+
onChange = _this$props4.onChange,
|
|
1337
|
+
errorSchema = _this$props4.errorSchema;
|
|
1305
1338
|
value = _this.getAvailableKey(value, formData);
|
|
1306
1339
|
var newFormData = _extends({}, formData);
|
|
1307
1340
|
var newKeys = (_newKeys = {}, _newKeys[oldValue] = value, _newKeys);
|
|
@@ -1322,10 +1355,10 @@
|
|
|
1322
1355
|
if (!schema.additionalProperties) {
|
|
1323
1356
|
return;
|
|
1324
1357
|
}
|
|
1325
|
-
var _this$
|
|
1326
|
-
formData = _this$
|
|
1327
|
-
onChange = _this$
|
|
1328
|
-
registry = _this$
|
|
1358
|
+
var _this$props5 = _this.props,
|
|
1359
|
+
formData = _this$props5.formData,
|
|
1360
|
+
onChange = _this$props5.onChange,
|
|
1361
|
+
registry = _this$props5.registry;
|
|
1329
1362
|
var newFormData = _extends({}, formData);
|
|
1330
1363
|
var type = undefined;
|
|
1331
1364
|
if (isObject__default["default"](schema.additionalProperties)) {
|
|
@@ -1400,35 +1433,36 @@
|
|
|
1400
1433
|
*/
|
|
1401
1434
|
_proto.render = function render() {
|
|
1402
1435
|
var _this2 = this;
|
|
1403
|
-
var _this$
|
|
1404
|
-
rawSchema = _this$
|
|
1405
|
-
_this$
|
|
1406
|
-
uiSchema = _this$
|
|
1407
|
-
formData = _this$
|
|
1408
|
-
errorSchema = _this$
|
|
1409
|
-
idSchema = _this$
|
|
1410
|
-
name = _this$
|
|
1411
|
-
_this$
|
|
1412
|
-
required = _this$
|
|
1413
|
-
_this$
|
|
1414
|
-
disabled = _this$
|
|
1415
|
-
_this$
|
|
1416
|
-
readonly = _this$
|
|
1417
|
-
hideError = _this$
|
|
1418
|
-
idPrefix = _this$
|
|
1419
|
-
idSeparator = _this$
|
|
1420
|
-
onBlur = _this$
|
|
1421
|
-
onFocus = _this$
|
|
1422
|
-
registry = _this$
|
|
1436
|
+
var _this$props6 = this.props,
|
|
1437
|
+
rawSchema = _this$props6.schema,
|
|
1438
|
+
_this$props6$uiSchema = _this$props6.uiSchema,
|
|
1439
|
+
uiSchema = _this$props6$uiSchema === void 0 ? {} : _this$props6$uiSchema,
|
|
1440
|
+
formData = _this$props6.formData,
|
|
1441
|
+
errorSchema = _this$props6.errorSchema,
|
|
1442
|
+
idSchema = _this$props6.idSchema,
|
|
1443
|
+
name = _this$props6.name,
|
|
1444
|
+
_this$props6$required = _this$props6.required,
|
|
1445
|
+
required = _this$props6$required === void 0 ? false : _this$props6$required,
|
|
1446
|
+
_this$props6$disabled = _this$props6.disabled,
|
|
1447
|
+
disabled = _this$props6$disabled === void 0 ? false : _this$props6$disabled,
|
|
1448
|
+
_this$props6$readonly = _this$props6.readonly,
|
|
1449
|
+
readonly = _this$props6$readonly === void 0 ? false : _this$props6$readonly,
|
|
1450
|
+
hideError = _this$props6.hideError,
|
|
1451
|
+
idPrefix = _this$props6.idPrefix,
|
|
1452
|
+
idSeparator = _this$props6.idSeparator,
|
|
1453
|
+
onBlur = _this$props6.onBlur,
|
|
1454
|
+
onFocus = _this$props6.onFocus,
|
|
1455
|
+
registry = _this$props6.registry;
|
|
1423
1456
|
var fields = registry.fields,
|
|
1424
1457
|
formContext = registry.formContext,
|
|
1425
|
-
schemaUtils = registry.schemaUtils
|
|
1458
|
+
schemaUtils = registry.schemaUtils,
|
|
1459
|
+
translateString = registry.translateString;
|
|
1426
1460
|
var SchemaField = fields.SchemaField;
|
|
1427
1461
|
var schema = schemaUtils.retrieveSchema(rawSchema, formData);
|
|
1428
1462
|
var uiOptions = utils.getUiOptions(uiSchema);
|
|
1429
1463
|
var _schema$properties = schema.properties,
|
|
1430
1464
|
schemaProperties = _schema$properties === void 0 ? {} : _schema$properties;
|
|
1431
|
-
var title = schema.title === undefined ? name : schema.title;
|
|
1465
|
+
var title = uiOptions.title || (schema.title === undefined ? name : schema.title);
|
|
1432
1466
|
var description = uiOptions.description || schema.description;
|
|
1433
1467
|
var orderedProperties;
|
|
1434
1468
|
try {
|
|
@@ -1436,14 +1470,14 @@
|
|
|
1436
1470
|
orderedProperties = utils.orderProperties(properties, uiOptions.order);
|
|
1437
1471
|
} catch (err) {
|
|
1438
1472
|
return jsxRuntime.jsxs("div", {
|
|
1439
|
-
children: [jsxRuntime.
|
|
1473
|
+
children: [jsxRuntime.jsx("p", {
|
|
1440
1474
|
className: 'config-error',
|
|
1441
1475
|
style: {
|
|
1442
1476
|
color: 'red'
|
|
1443
1477
|
},
|
|
1444
|
-
children:
|
|
1445
|
-
children: err.message
|
|
1446
|
-
})
|
|
1478
|
+
children: jsxRuntime.jsx(Markdown__default["default"], {
|
|
1479
|
+
children: translateString(utils.TranslatableString.InvalidObjectField, [name || 'root', err.message])
|
|
1480
|
+
})
|
|
1447
1481
|
}), jsxRuntime.jsx("pre", {
|
|
1448
1482
|
children: JSON.stringify(schema)
|
|
1449
1483
|
})]
|
|
@@ -1451,7 +1485,7 @@
|
|
|
1451
1485
|
}
|
|
1452
1486
|
var Template = utils.getTemplate('ObjectFieldTemplate', registry, uiOptions);
|
|
1453
1487
|
var templateProps = {
|
|
1454
|
-
title:
|
|
1488
|
+
title: title,
|
|
1455
1489
|
description: description,
|
|
1456
1490
|
properties: orderedProperties.map(function (name) {
|
|
1457
1491
|
var addedByAdditionalProperties = has__default["default"](schema, [utils.PROPERTIES_KEY, name, utils.ADDITIONAL_PROPERTY_FLAG]);
|
|
@@ -1579,8 +1613,9 @@
|
|
|
1579
1613
|
_props$wasPropertyKey = props.wasPropertyKeyModified,
|
|
1580
1614
|
wasPropertyKeyModified = _props$wasPropertyKey === void 0 ? false : _props$wasPropertyKey;
|
|
1581
1615
|
var formContext = registry.formContext,
|
|
1582
|
-
schemaUtils = registry.schemaUtils
|
|
1583
|
-
|
|
1616
|
+
schemaUtils = registry.schemaUtils,
|
|
1617
|
+
globalUiOptions = registry.globalUiOptions;
|
|
1618
|
+
var uiOptions = utils.getUiOptions(uiSchema, globalUiOptions);
|
|
1584
1619
|
var FieldTemplate = utils.getTemplate('FieldTemplate', registry, uiOptions);
|
|
1585
1620
|
var DescriptionFieldTemplate = utils.getTemplate('DescriptionFieldTemplate', registry, uiOptions);
|
|
1586
1621
|
var FieldHelpTemplate = utils.getTemplate('FieldHelpTemplate', registry, uiOptions);
|
|
@@ -1605,7 +1640,7 @@
|
|
|
1605
1640
|
if (Object.keys(schema).length === 0) {
|
|
1606
1641
|
return null;
|
|
1607
1642
|
}
|
|
1608
|
-
var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema);
|
|
1643
|
+
var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
1609
1644
|
var _ref = errorSchema || {},
|
|
1610
1645
|
__errors = _ref.__errors,
|
|
1611
1646
|
fieldErrorSchema = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
@@ -1902,13 +1937,16 @@
|
|
|
1902
1937
|
hasMoveDown = props.hasMoveDown,
|
|
1903
1938
|
hasMoveUp = props.hasMoveUp,
|
|
1904
1939
|
hasRemove = props.hasRemove,
|
|
1940
|
+
hasCopy = props.hasCopy,
|
|
1905
1941
|
index = props.index,
|
|
1942
|
+
onCopyIndexClick = props.onCopyIndexClick,
|
|
1906
1943
|
onDropIndexClick = props.onDropIndexClick,
|
|
1907
1944
|
onReorderClick = props.onReorderClick,
|
|
1908
1945
|
readonly = props.readonly,
|
|
1909
1946
|
registry = props.registry,
|
|
1910
1947
|
uiSchema = props.uiSchema;
|
|
1911
1948
|
var _registry$templates$B = registry.templates.ButtonTemplates,
|
|
1949
|
+
CopyButton = _registry$templates$B.CopyButton,
|
|
1912
1950
|
MoveDownButton = _registry$templates$B.MoveDownButton,
|
|
1913
1951
|
MoveUpButton = _registry$templates$B.MoveUpButton,
|
|
1914
1952
|
RemoveButton = _registry$templates$B.RemoveButton;
|
|
@@ -1943,6 +1981,12 @@
|
|
|
1943
1981
|
onClick: onReorderClick(index, index + 1),
|
|
1944
1982
|
uiSchema: uiSchema,
|
|
1945
1983
|
registry: registry
|
|
1984
|
+
}), hasCopy && jsxRuntime.jsx(CopyButton, {
|
|
1985
|
+
style: btnStyle,
|
|
1986
|
+
disabled: disabled || readonly,
|
|
1987
|
+
onClick: onCopyIndexClick(index),
|
|
1988
|
+
uiSchema: uiSchema,
|
|
1989
|
+
registry: registry
|
|
1946
1990
|
}), hasRemove && jsxRuntime.jsx(RemoveButton, {
|
|
1947
1991
|
style: btnStyle,
|
|
1948
1992
|
disabled: disabled || readonly,
|
|
@@ -2151,6 +2195,15 @@
|
|
|
2151
2195
|
})
|
|
2152
2196
|
}));
|
|
2153
2197
|
}
|
|
2198
|
+
function CopyButton(props) {
|
|
2199
|
+
var translateString = props.registry.translateString;
|
|
2200
|
+
return jsxRuntime.jsx(IconButton, _extends({
|
|
2201
|
+
title: translateString(utils.TranslatableString.CopyButton),
|
|
2202
|
+
className: 'array-item-copy'
|
|
2203
|
+
}, props, {
|
|
2204
|
+
icon: 'copy'
|
|
2205
|
+
}));
|
|
2206
|
+
}
|
|
2154
2207
|
function MoveDownButton(props) {
|
|
2155
2208
|
var translateString = props.registry.translateString;
|
|
2156
2209
|
return jsxRuntime.jsx(IconButton, _extends({
|
|
@@ -2209,6 +2262,7 @@
|
|
|
2209
2262
|
return {
|
|
2210
2263
|
SubmitButton: SubmitButton,
|
|
2211
2264
|
AddButton: AddButton,
|
|
2265
|
+
CopyButton: CopyButton,
|
|
2212
2266
|
MoveDownButton: MoveDownButton,
|
|
2213
2267
|
MoveUpButton: MoveUpButton,
|
|
2214
2268
|
RemoveButton: RemoveButton
|
|
@@ -3369,6 +3423,26 @@
|
|
|
3369
3423
|
return jsxRuntime.jsx(BaseInputTemplate, _extends({}, props));
|
|
3370
3424
|
}
|
|
3371
3425
|
|
|
3426
|
+
/** The `TimeWidget` component uses the `BaseInputTemplate` changing the type to `time` and transforms
|
|
3427
|
+
* the value to undefined when it is falsy during the `onChange` handling.
|
|
3428
|
+
*
|
|
3429
|
+
* @param props - The `WidgetProps` for this component
|
|
3430
|
+
*/
|
|
3431
|
+
function TimeWidget(props) {
|
|
3432
|
+
var onChange = props.onChange,
|
|
3433
|
+
options = props.options,
|
|
3434
|
+
registry = props.registry;
|
|
3435
|
+
var BaseInputTemplate = utils.getTemplate('BaseInputTemplate', registry, options);
|
|
3436
|
+
var handleChange = react.useCallback(function (value) {
|
|
3437
|
+
return onChange(value ? value + ":00" : undefined);
|
|
3438
|
+
}, [onChange]);
|
|
3439
|
+
return jsxRuntime.jsx(BaseInputTemplate, _extends({
|
|
3440
|
+
type: 'time'
|
|
3441
|
+
}, props, {
|
|
3442
|
+
onChange: handleChange
|
|
3443
|
+
}));
|
|
3444
|
+
}
|
|
3445
|
+
|
|
3372
3446
|
/** The `URLWidget` component uses the `BaseInputTemplate` changing the type to `url`.
|
|
3373
3447
|
*
|
|
3374
3448
|
* @param props - The `WidgetProps` for this component
|
|
@@ -3397,24 +3471,25 @@
|
|
|
3397
3471
|
|
|
3398
3472
|
function widgets() {
|
|
3399
3473
|
return {
|
|
3474
|
+
AltDateWidget: AltDateWidget,
|
|
3475
|
+
AltDateTimeWidget: AltDateTimeWidget,
|
|
3476
|
+
CheckboxWidget: CheckboxWidget,
|
|
3477
|
+
CheckboxesWidget: CheckboxesWidget,
|
|
3478
|
+
ColorWidget: ColorWidget,
|
|
3479
|
+
DateWidget: DateWidget,
|
|
3480
|
+
DateTimeWidget: DateTimeWidget,
|
|
3481
|
+
EmailWidget: EmailWidget,
|
|
3482
|
+
FileWidget: FileWidget,
|
|
3483
|
+
HiddenWidget: HiddenWidget,
|
|
3400
3484
|
PasswordWidget: PasswordWidget,
|
|
3401
3485
|
RadioWidget: RadioWidget,
|
|
3402
|
-
UpDownWidget: UpDownWidget,
|
|
3403
3486
|
RangeWidget: RangeWidget,
|
|
3404
3487
|
SelectWidget: SelectWidget,
|
|
3405
3488
|
TextWidget: TextWidget,
|
|
3406
|
-
DateWidget: DateWidget,
|
|
3407
|
-
DateTimeWidget: DateTimeWidget,
|
|
3408
|
-
AltDateWidget: AltDateWidget,
|
|
3409
|
-
AltDateTimeWidget: AltDateTimeWidget,
|
|
3410
|
-
EmailWidget: EmailWidget,
|
|
3411
|
-
URLWidget: URLWidget,
|
|
3412
3489
|
TextareaWidget: TextareaWidget,
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
CheckboxWidget: CheckboxWidget,
|
|
3417
|
-
CheckboxesWidget: CheckboxesWidget
|
|
3490
|
+
TimeWidget: TimeWidget,
|
|
3491
|
+
UpDownWidget: UpDownWidget,
|
|
3492
|
+
URLWidget: URLWidget
|
|
3418
3493
|
};
|
|
3419
3494
|
}
|
|
3420
3495
|
|
|
@@ -3558,6 +3633,21 @@
|
|
|
3558
3633
|
return onChange && onChange(_extends({}, _this.state, state), id);
|
|
3559
3634
|
});
|
|
3560
3635
|
};
|
|
3636
|
+
_this.reset = function () {
|
|
3637
|
+
var onChange = _this.props.onChange;
|
|
3638
|
+
var newState = _this.getStateFromProps(_this.props, undefined);
|
|
3639
|
+
var newFormData = newState.formData;
|
|
3640
|
+
var state = {
|
|
3641
|
+
formData: newFormData,
|
|
3642
|
+
errorSchema: {},
|
|
3643
|
+
errors: [],
|
|
3644
|
+
schemaValidationErrors: [],
|
|
3645
|
+
schemaValidationErrorSchema: {}
|
|
3646
|
+
};
|
|
3647
|
+
_this.setState(state, function () {
|
|
3648
|
+
return onChange && onChange(_extends({}, _this.state, state));
|
|
3649
|
+
});
|
|
3650
|
+
};
|
|
3561
3651
|
_this.onBlur = function (id, data) {
|
|
3562
3652
|
var onBlur = _this.props.onBlur;
|
|
3563
3653
|
if (onBlur) {
|
|
@@ -3771,7 +3861,10 @@
|
|
|
3771
3861
|
/** Returns the registry for the form */
|
|
3772
3862
|
_proto.getRegistry = function getRegistry() {
|
|
3773
3863
|
var _this$props$templates;
|
|
3774
|
-
var
|
|
3864
|
+
var _this$props4 = this.props,
|
|
3865
|
+
customTranslateString = _this$props4.translateString,
|
|
3866
|
+
_this$props4$uiSchema = _this$props4.uiSchema,
|
|
3867
|
+
uiSchema = _this$props4$uiSchema === void 0 ? {} : _this$props4$uiSchema;
|
|
3775
3868
|
var schemaUtils = this.state.schemaUtils;
|
|
3776
3869
|
var _getDefaultRegistry = getDefaultRegistry(),
|
|
3777
3870
|
fields = _getDefaultRegistry.fields,
|
|
@@ -3788,7 +3881,8 @@
|
|
|
3788
3881
|
rootSchema: this.props.schema,
|
|
3789
3882
|
formContext: this.props.formContext || formContext,
|
|
3790
3883
|
schemaUtils: schemaUtils,
|
|
3791
|
-
translateString: customTranslateString || translateString
|
|
3884
|
+
translateString: customTranslateString || translateString,
|
|
3885
|
+
globalUiOptions: uiSchema[utils.UI_GLOBAL_OPTIONS_KEY]
|
|
3792
3886
|
};
|
|
3793
3887
|
}
|
|
3794
3888
|
/** Provides a function that can be used to programmatically submit the `Form` */;
|
|
@@ -3807,11 +3901,11 @@
|
|
|
3807
3901
|
* @param error - The error on which to focus
|
|
3808
3902
|
*/;
|
|
3809
3903
|
_proto.focusOnError = function focusOnError(error) {
|
|
3810
|
-
var _this$
|
|
3811
|
-
_this$
|
|
3812
|
-
idPrefix = _this$
|
|
3813
|
-
_this$
|
|
3814
|
-
idSeparator = _this$
|
|
3904
|
+
var _this$props5 = this.props,
|
|
3905
|
+
_this$props5$idPrefix = _this$props5.idPrefix,
|
|
3906
|
+
idPrefix = _this$props5$idPrefix === void 0 ? 'root' : _this$props5$idPrefix,
|
|
3907
|
+
_this$props5$idSepara = _this$props5.idSeparator,
|
|
3908
|
+
idSeparator = _this$props5$idSepara === void 0 ? '_' : _this$props5$idSepara;
|
|
3815
3909
|
var property = error.property;
|
|
3816
3910
|
var path = _toPath__default["default"](property);
|
|
3817
3911
|
if (path[0] === '') {
|
|
@@ -3837,10 +3931,10 @@
|
|
|
3837
3931
|
* @returns - True if the form is valid, false otherwise.
|
|
3838
3932
|
*/;
|
|
3839
3933
|
_proto.validateForm = function validateForm() {
|
|
3840
|
-
var _this$
|
|
3841
|
-
extraErrors = _this$
|
|
3842
|
-
focusOnFirstError = _this$
|
|
3843
|
-
onError = _this$
|
|
3934
|
+
var _this$props6 = this.props,
|
|
3935
|
+
extraErrors = _this$props6.extraErrors,
|
|
3936
|
+
focusOnFirstError = _this$props6.focusOnFirstError,
|
|
3937
|
+
onError = _this$props6.onError;
|
|
3844
3938
|
var formData = this.state.formData;
|
|
3845
3939
|
var schemaUtils = this.state.schemaUtils;
|
|
3846
3940
|
var schemaValidation = this.validate(formData);
|
|
@@ -3877,31 +3971,31 @@
|
|
|
3877
3971
|
* needed along with the submit button or any children of the form.
|
|
3878
3972
|
*/;
|
|
3879
3973
|
_proto.render = function render() {
|
|
3880
|
-
var _this$
|
|
3881
|
-
children = _this$
|
|
3882
|
-
id = _this$
|
|
3883
|
-
idPrefix = _this$
|
|
3884
|
-
idSeparator = _this$
|
|
3885
|
-
_this$
|
|
3886
|
-
className = _this$
|
|
3887
|
-
tagName = _this$
|
|
3888
|
-
name = _this$
|
|
3889
|
-
method = _this$
|
|
3890
|
-
target = _this$
|
|
3891
|
-
action = _this$
|
|
3892
|
-
autoComplete = _this$
|
|
3893
|
-
enctype = _this$
|
|
3894
|
-
acceptcharset = _this$
|
|
3895
|
-
_this$
|
|
3896
|
-
noHtml5Validate = _this$
|
|
3897
|
-
_this$
|
|
3898
|
-
disabled = _this$
|
|
3899
|
-
_this$
|
|
3900
|
-
readonly = _this$
|
|
3901
|
-
formContext = _this$
|
|
3902
|
-
_this$
|
|
3903
|
-
showErrorList = _this$
|
|
3904
|
-
_internalFormWrapper = _this$
|
|
3974
|
+
var _this$props7 = this.props,
|
|
3975
|
+
children = _this$props7.children,
|
|
3976
|
+
id = _this$props7.id,
|
|
3977
|
+
idPrefix = _this$props7.idPrefix,
|
|
3978
|
+
idSeparator = _this$props7.idSeparator,
|
|
3979
|
+
_this$props7$classNam = _this$props7.className,
|
|
3980
|
+
className = _this$props7$classNam === void 0 ? '' : _this$props7$classNam,
|
|
3981
|
+
tagName = _this$props7.tagName,
|
|
3982
|
+
name = _this$props7.name,
|
|
3983
|
+
method = _this$props7.method,
|
|
3984
|
+
target = _this$props7.target,
|
|
3985
|
+
action = _this$props7.action,
|
|
3986
|
+
autoComplete = _this$props7.autoComplete,
|
|
3987
|
+
enctype = _this$props7.enctype,
|
|
3988
|
+
acceptcharset = _this$props7.acceptcharset,
|
|
3989
|
+
_this$props7$noHtml5V = _this$props7.noHtml5Validate,
|
|
3990
|
+
noHtml5Validate = _this$props7$noHtml5V === void 0 ? false : _this$props7$noHtml5V,
|
|
3991
|
+
_this$props7$disabled = _this$props7.disabled,
|
|
3992
|
+
disabled = _this$props7$disabled === void 0 ? false : _this$props7$disabled,
|
|
3993
|
+
_this$props7$readonly = _this$props7.readonly,
|
|
3994
|
+
readonly = _this$props7$readonly === void 0 ? false : _this$props7$readonly,
|
|
3995
|
+
formContext = _this$props7.formContext,
|
|
3996
|
+
_this$props7$showErro = _this$props7.showErrorList,
|
|
3997
|
+
showErrorList = _this$props7$showErro === void 0 ? 'top' : _this$props7$showErro,
|
|
3998
|
+
_internalFormWrapper = _this$props7._internalFormWrapper;
|
|
3905
3999
|
var _this$state4 = this.state,
|
|
3906
4000
|
schema = _this$state4.schema,
|
|
3907
4001
|
uiSchema = _this$state4.uiSchema,
|