@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
package/dist/core.esm.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { Component, useState, useCallback, useEffect, useReducer, useMemo, createRef, forwardRef } from 'react';
|
|
3
|
-
import { isFixedItems, allowAdditionalItems, getUiOptions, ITEMS_KEY, getTemplate, TranslatableString, isCustomWidget, getWidget, optionsList, deepEquals, ERRORS_KEY, asNumber, REF_KEY, orderProperties, PROPERTIES_KEY, ADDITIONAL_PROPERTY_FLAG, ANY_OF_KEY, ONE_OF_KEY, mergeObjects, UI_OPTIONS_KEY, descriptionId, getSchemaType, ID_KEY, hasWidget, titleId, getInputProps, examplesId, ariaDescribedByIds, getSubmitButtonOptions, errorId, helpId, canExpand, parseDateString, toDateString, pad, schemaRequiresTrueValue, enumOptionsValueForIndex, enumOptionsIsSelected, optionId, enumOptionsSelectValue, enumOptionsDeselectValue, utcToLocal, localToUTC, dataURItoBlob, enumOptionsIndexForValue, englishStringTranslator, createSchemaUtils, shouldRender, isObject as isObject$1, RJSF_ADDITONAL_PROPERTIES_FLAG, NAME_KEY } from '@rjsf/utils';
|
|
3
|
+
import { isFixedItems, allowAdditionalItems, getUiOptions, ITEMS_KEY, getTemplate, TranslatableString, isCustomWidget, getWidget, optionsList, deepEquals, ERRORS_KEY, asNumber, REF_KEY, orderProperties, PROPERTIES_KEY, ADDITIONAL_PROPERTY_FLAG, ANY_OF_KEY, ONE_OF_KEY, mergeObjects, UI_OPTIONS_KEY, descriptionId, getSchemaType, ID_KEY, hasWidget, titleId, getInputProps, examplesId, ariaDescribedByIds, getSubmitButtonOptions, errorId, helpId, canExpand, parseDateString, toDateString, pad, schemaRequiresTrueValue, enumOptionsValueForIndex, enumOptionsIsSelected, optionId, enumOptionsSelectValue, enumOptionsDeselectValue, utcToLocal, localToUTC, dataURItoBlob, enumOptionsIndexForValue, englishStringTranslator, createSchemaUtils, shouldRender, UI_GLOBAL_OPTIONS_KEY, isObject as isObject$1, RJSF_ADDITONAL_PROPERTIES_FLAG, NAME_KEY } from '@rjsf/utils';
|
|
4
4
|
import get from 'lodash-es/get';
|
|
5
5
|
import isEmpty from 'lodash-es/isEmpty';
|
|
6
6
|
import _pick from 'lodash-es/pick';
|
|
7
7
|
import _toPath from 'lodash-es/toPath';
|
|
8
|
+
import cloneDeep from 'lodash-es/cloneDeep';
|
|
8
9
|
import isObject from 'lodash-es/isObject';
|
|
9
10
|
import set from 'lodash-es/set';
|
|
10
11
|
import { nanoid } from 'nanoid';
|
|
11
12
|
import omit from 'lodash-es/omit';
|
|
13
|
+
import Markdown from 'markdown-to-jsx';
|
|
12
14
|
import has from 'lodash-es/has';
|
|
13
15
|
import unset from 'lodash-es/unset';
|
|
14
|
-
import Markdown from 'markdown-to-jsx';
|
|
15
16
|
|
|
16
17
|
function _defineProperties(target, props) {
|
|
17
18
|
for (var i = 0; i < props.length; i++) {
|
|
@@ -148,6 +149,31 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
148
149
|
_this._handleAddClick(event, index);
|
|
149
150
|
};
|
|
150
151
|
};
|
|
152
|
+
_this.onCopyIndexClick = function (index) {
|
|
153
|
+
return function (event) {
|
|
154
|
+
if (event) {
|
|
155
|
+
event.preventDefault();
|
|
156
|
+
}
|
|
157
|
+
var onChange = _this.props.onChange;
|
|
158
|
+
var keyedFormData = _this.state.keyedFormData;
|
|
159
|
+
var newKeyedFormDataRow = {
|
|
160
|
+
key: generateRowId(),
|
|
161
|
+
item: cloneDeep(keyedFormData[index].item)
|
|
162
|
+
};
|
|
163
|
+
var newKeyedFormData = [].concat(keyedFormData);
|
|
164
|
+
if (index !== undefined) {
|
|
165
|
+
newKeyedFormData.splice(index + 1, 0, newKeyedFormDataRow);
|
|
166
|
+
} else {
|
|
167
|
+
newKeyedFormData.push(newKeyedFormDataRow);
|
|
168
|
+
}
|
|
169
|
+
_this.setState({
|
|
170
|
+
keyedFormData: newKeyedFormData,
|
|
171
|
+
updatedKeyedFormData: true
|
|
172
|
+
}, function () {
|
|
173
|
+
return onChange(keyedToPlainFormData(newKeyedFormData));
|
|
174
|
+
});
|
|
175
|
+
};
|
|
176
|
+
};
|
|
151
177
|
_this.onDropIndexClick = function (index) {
|
|
152
178
|
return function (event) {
|
|
153
179
|
if (event) {
|
|
@@ -307,8 +333,9 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
307
333
|
_proto.canAddItem = function canAddItem(formItems) {
|
|
308
334
|
var _this$props6 = this.props,
|
|
309
335
|
schema = _this$props6.schema,
|
|
310
|
-
uiSchema = _this$props6.uiSchema
|
|
311
|
-
|
|
336
|
+
uiSchema = _this$props6.uiSchema,
|
|
337
|
+
registry = _this$props6.registry;
|
|
338
|
+
var _getUiOptions = getUiOptions(uiSchema, registry.globalUiOptions),
|
|
312
339
|
addable = _getUiOptions.addable;
|
|
313
340
|
if (addable !== false) {
|
|
314
341
|
// if ui:options.addable was not explicitly set to false, we can add
|
|
@@ -750,10 +777,8 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
750
777
|
canAdd = props.canAdd,
|
|
751
778
|
_props$canRemove = props.canRemove,
|
|
752
779
|
canRemove = _props$canRemove === void 0 ? true : _props$canRemove,
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
_props$canMoveDown = props.canMoveDown,
|
|
756
|
-
canMoveDown = _props$canMoveDown === void 0 ? true : _props$canMoveDown,
|
|
780
|
+
canMoveUp = props.canMoveUp,
|
|
781
|
+
canMoveDown = props.canMoveDown,
|
|
757
782
|
itemSchema = props.itemSchema,
|
|
758
783
|
itemData = props.itemData,
|
|
759
784
|
itemUiSchema = props.itemUiSchema,
|
|
@@ -775,16 +800,20 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
775
800
|
formContext = _this$props13.formContext;
|
|
776
801
|
var _registry$fields = registry.fields,
|
|
777
802
|
ArraySchemaField = _registry$fields.ArraySchemaField,
|
|
778
|
-
SchemaField = _registry$fields.SchemaField
|
|
803
|
+
SchemaField = _registry$fields.SchemaField,
|
|
804
|
+
globalUiOptions = registry.globalUiOptions;
|
|
779
805
|
var ItemSchemaField = ArraySchemaField || SchemaField;
|
|
780
|
-
var _getUiOptions5 = getUiOptions(uiSchema),
|
|
806
|
+
var _getUiOptions5 = getUiOptions(uiSchema, globalUiOptions),
|
|
781
807
|
_getUiOptions5$ordera = _getUiOptions5.orderable,
|
|
782
808
|
orderable = _getUiOptions5$ordera === void 0 ? true : _getUiOptions5$ordera,
|
|
783
809
|
_getUiOptions5$remova = _getUiOptions5.removable,
|
|
784
|
-
removable = _getUiOptions5$remova === void 0 ? true : _getUiOptions5$remova
|
|
810
|
+
removable = _getUiOptions5$remova === void 0 ? true : _getUiOptions5$remova,
|
|
811
|
+
_getUiOptions5$copyab = _getUiOptions5.copyable,
|
|
812
|
+
copyable = _getUiOptions5$copyab === void 0 ? false : _getUiOptions5$copyab;
|
|
785
813
|
var has = {
|
|
786
814
|
moveUp: orderable && canMoveUp,
|
|
787
815
|
moveDown: orderable && canMoveDown,
|
|
816
|
+
copy: copyable && canAdd,
|
|
788
817
|
remove: removable && canRemove,
|
|
789
818
|
toolbar: false
|
|
790
819
|
};
|
|
@@ -817,6 +846,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
817
846
|
className: 'array-item',
|
|
818
847
|
disabled: disabled,
|
|
819
848
|
canAdd: canAdd,
|
|
849
|
+
hasCopy: has.copy,
|
|
820
850
|
hasToolbar: has.toolbar,
|
|
821
851
|
hasMoveUp: has.moveUp,
|
|
822
852
|
hasMoveDown: has.moveDown,
|
|
@@ -825,6 +855,7 @@ var ArrayField = /*#__PURE__*/function (_Component) {
|
|
|
825
855
|
totalItems: totalItems,
|
|
826
856
|
key: key,
|
|
827
857
|
onAddIndexClick: this.onAddIndexClick,
|
|
858
|
+
onCopyIndexClick: this.onCopyIndexClick,
|
|
828
859
|
onDropIndexClick: this.onDropIndexClick,
|
|
829
860
|
onReorderClick: this.onReorderClick,
|
|
830
861
|
readonly: readonly,
|
|
@@ -1277,8 +1308,10 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1277
1308
|
};
|
|
1278
1309
|
};
|
|
1279
1310
|
_this.getAvailableKey = function (preferredKey, formData) {
|
|
1280
|
-
var
|
|
1281
|
-
|
|
1311
|
+
var _this$props3 = _this.props,
|
|
1312
|
+
uiSchema = _this$props3.uiSchema,
|
|
1313
|
+
registry = _this$props3.registry;
|
|
1314
|
+
var _getUiOptions = getUiOptions(uiSchema, registry.globalUiOptions),
|
|
1282
1315
|
_getUiOptions$duplica = _getUiOptions.duplicateKeySuffixSeparator,
|
|
1283
1316
|
duplicateKeySuffixSeparator = _getUiOptions$duplica === void 0 ? '-' : _getUiOptions$duplica;
|
|
1284
1317
|
var index = 0;
|
|
@@ -1294,10 +1327,10 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1294
1327
|
if (oldValue === value) {
|
|
1295
1328
|
return;
|
|
1296
1329
|
}
|
|
1297
|
-
var _this$
|
|
1298
|
-
formData = _this$
|
|
1299
|
-
onChange = _this$
|
|
1300
|
-
errorSchema = _this$
|
|
1330
|
+
var _this$props4 = _this.props,
|
|
1331
|
+
formData = _this$props4.formData,
|
|
1332
|
+
onChange = _this$props4.onChange,
|
|
1333
|
+
errorSchema = _this$props4.errorSchema;
|
|
1301
1334
|
value = _this.getAvailableKey(value, formData);
|
|
1302
1335
|
var newFormData = _extends({}, formData);
|
|
1303
1336
|
var newKeys = (_newKeys = {}, _newKeys[oldValue] = value, _newKeys);
|
|
@@ -1318,10 +1351,10 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1318
1351
|
if (!schema.additionalProperties) {
|
|
1319
1352
|
return;
|
|
1320
1353
|
}
|
|
1321
|
-
var _this$
|
|
1322
|
-
formData = _this$
|
|
1323
|
-
onChange = _this$
|
|
1324
|
-
registry = _this$
|
|
1354
|
+
var _this$props5 = _this.props,
|
|
1355
|
+
formData = _this$props5.formData,
|
|
1356
|
+
onChange = _this$props5.onChange,
|
|
1357
|
+
registry = _this$props5.registry;
|
|
1325
1358
|
var newFormData = _extends({}, formData);
|
|
1326
1359
|
var type = undefined;
|
|
1327
1360
|
if (isObject(schema.additionalProperties)) {
|
|
@@ -1396,35 +1429,36 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1396
1429
|
*/
|
|
1397
1430
|
_proto.render = function render() {
|
|
1398
1431
|
var _this2 = this;
|
|
1399
|
-
var _this$
|
|
1400
|
-
rawSchema = _this$
|
|
1401
|
-
_this$
|
|
1402
|
-
uiSchema = _this$
|
|
1403
|
-
formData = _this$
|
|
1404
|
-
errorSchema = _this$
|
|
1405
|
-
idSchema = _this$
|
|
1406
|
-
name = _this$
|
|
1407
|
-
_this$
|
|
1408
|
-
required = _this$
|
|
1409
|
-
_this$
|
|
1410
|
-
disabled = _this$
|
|
1411
|
-
_this$
|
|
1412
|
-
readonly = _this$
|
|
1413
|
-
hideError = _this$
|
|
1414
|
-
idPrefix = _this$
|
|
1415
|
-
idSeparator = _this$
|
|
1416
|
-
onBlur = _this$
|
|
1417
|
-
onFocus = _this$
|
|
1418
|
-
registry = _this$
|
|
1432
|
+
var _this$props6 = this.props,
|
|
1433
|
+
rawSchema = _this$props6.schema,
|
|
1434
|
+
_this$props6$uiSchema = _this$props6.uiSchema,
|
|
1435
|
+
uiSchema = _this$props6$uiSchema === void 0 ? {} : _this$props6$uiSchema,
|
|
1436
|
+
formData = _this$props6.formData,
|
|
1437
|
+
errorSchema = _this$props6.errorSchema,
|
|
1438
|
+
idSchema = _this$props6.idSchema,
|
|
1439
|
+
name = _this$props6.name,
|
|
1440
|
+
_this$props6$required = _this$props6.required,
|
|
1441
|
+
required = _this$props6$required === void 0 ? false : _this$props6$required,
|
|
1442
|
+
_this$props6$disabled = _this$props6.disabled,
|
|
1443
|
+
disabled = _this$props6$disabled === void 0 ? false : _this$props6$disabled,
|
|
1444
|
+
_this$props6$readonly = _this$props6.readonly,
|
|
1445
|
+
readonly = _this$props6$readonly === void 0 ? false : _this$props6$readonly,
|
|
1446
|
+
hideError = _this$props6.hideError,
|
|
1447
|
+
idPrefix = _this$props6.idPrefix,
|
|
1448
|
+
idSeparator = _this$props6.idSeparator,
|
|
1449
|
+
onBlur = _this$props6.onBlur,
|
|
1450
|
+
onFocus = _this$props6.onFocus,
|
|
1451
|
+
registry = _this$props6.registry;
|
|
1419
1452
|
var fields = registry.fields,
|
|
1420
1453
|
formContext = registry.formContext,
|
|
1421
|
-
schemaUtils = registry.schemaUtils
|
|
1454
|
+
schemaUtils = registry.schemaUtils,
|
|
1455
|
+
translateString = registry.translateString;
|
|
1422
1456
|
var SchemaField = fields.SchemaField;
|
|
1423
1457
|
var schema = schemaUtils.retrieveSchema(rawSchema, formData);
|
|
1424
1458
|
var uiOptions = getUiOptions(uiSchema);
|
|
1425
1459
|
var _schema$properties = schema.properties,
|
|
1426
1460
|
schemaProperties = _schema$properties === void 0 ? {} : _schema$properties;
|
|
1427
|
-
var title = schema.title === undefined ? name : schema.title;
|
|
1461
|
+
var title = uiOptions.title || (schema.title === undefined ? name : schema.title);
|
|
1428
1462
|
var description = uiOptions.description || schema.description;
|
|
1429
1463
|
var orderedProperties;
|
|
1430
1464
|
try {
|
|
@@ -1432,14 +1466,14 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1432
1466
|
orderedProperties = orderProperties(properties, uiOptions.order);
|
|
1433
1467
|
} catch (err) {
|
|
1434
1468
|
return jsxs("div", {
|
|
1435
|
-
children: [
|
|
1469
|
+
children: [jsx("p", {
|
|
1436
1470
|
className: 'config-error',
|
|
1437
1471
|
style: {
|
|
1438
1472
|
color: 'red'
|
|
1439
1473
|
},
|
|
1440
|
-
children:
|
|
1441
|
-
children: err.message
|
|
1442
|
-
})
|
|
1474
|
+
children: jsx(Markdown, {
|
|
1475
|
+
children: translateString(TranslatableString.InvalidObjectField, [name || 'root', err.message])
|
|
1476
|
+
})
|
|
1443
1477
|
}), jsx("pre", {
|
|
1444
1478
|
children: JSON.stringify(schema)
|
|
1445
1479
|
})]
|
|
@@ -1447,7 +1481,7 @@ var ObjectField = /*#__PURE__*/function (_Component) {
|
|
|
1447
1481
|
}
|
|
1448
1482
|
var Template = getTemplate('ObjectFieldTemplate', registry, uiOptions);
|
|
1449
1483
|
var templateProps = {
|
|
1450
|
-
title:
|
|
1484
|
+
title: title,
|
|
1451
1485
|
description: description,
|
|
1452
1486
|
properties: orderedProperties.map(function (name) {
|
|
1453
1487
|
var addedByAdditionalProperties = has(schema, [PROPERTIES_KEY, name, ADDITIONAL_PROPERTY_FLAG]);
|
|
@@ -1575,8 +1609,9 @@ function SchemaFieldRender(props) {
|
|
|
1575
1609
|
_props$wasPropertyKey = props.wasPropertyKeyModified,
|
|
1576
1610
|
wasPropertyKeyModified = _props$wasPropertyKey === void 0 ? false : _props$wasPropertyKey;
|
|
1577
1611
|
var formContext = registry.formContext,
|
|
1578
|
-
schemaUtils = registry.schemaUtils
|
|
1579
|
-
|
|
1612
|
+
schemaUtils = registry.schemaUtils,
|
|
1613
|
+
globalUiOptions = registry.globalUiOptions;
|
|
1614
|
+
var uiOptions = getUiOptions(uiSchema, globalUiOptions);
|
|
1580
1615
|
var FieldTemplate = getTemplate('FieldTemplate', registry, uiOptions);
|
|
1581
1616
|
var DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, uiOptions);
|
|
1582
1617
|
var FieldHelpTemplate = getTemplate('FieldHelpTemplate', registry, uiOptions);
|
|
@@ -1601,7 +1636,7 @@ function SchemaFieldRender(props) {
|
|
|
1601
1636
|
if (Object.keys(schema).length === 0) {
|
|
1602
1637
|
return null;
|
|
1603
1638
|
}
|
|
1604
|
-
var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema);
|
|
1639
|
+
var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
1605
1640
|
var _ref = errorSchema || {},
|
|
1606
1641
|
__errors = _ref.__errors,
|
|
1607
1642
|
fieldErrorSchema = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
@@ -1898,13 +1933,16 @@ function ArrayFieldItemTemplate(props) {
|
|
|
1898
1933
|
hasMoveDown = props.hasMoveDown,
|
|
1899
1934
|
hasMoveUp = props.hasMoveUp,
|
|
1900
1935
|
hasRemove = props.hasRemove,
|
|
1936
|
+
hasCopy = props.hasCopy,
|
|
1901
1937
|
index = props.index,
|
|
1938
|
+
onCopyIndexClick = props.onCopyIndexClick,
|
|
1902
1939
|
onDropIndexClick = props.onDropIndexClick,
|
|
1903
1940
|
onReorderClick = props.onReorderClick,
|
|
1904
1941
|
readonly = props.readonly,
|
|
1905
1942
|
registry = props.registry,
|
|
1906
1943
|
uiSchema = props.uiSchema;
|
|
1907
1944
|
var _registry$templates$B = registry.templates.ButtonTemplates,
|
|
1945
|
+
CopyButton = _registry$templates$B.CopyButton,
|
|
1908
1946
|
MoveDownButton = _registry$templates$B.MoveDownButton,
|
|
1909
1947
|
MoveUpButton = _registry$templates$B.MoveUpButton,
|
|
1910
1948
|
RemoveButton = _registry$templates$B.RemoveButton;
|
|
@@ -1939,6 +1977,12 @@ function ArrayFieldItemTemplate(props) {
|
|
|
1939
1977
|
onClick: onReorderClick(index, index + 1),
|
|
1940
1978
|
uiSchema: uiSchema,
|
|
1941
1979
|
registry: registry
|
|
1980
|
+
}), hasCopy && jsx(CopyButton, {
|
|
1981
|
+
style: btnStyle,
|
|
1982
|
+
disabled: disabled || readonly,
|
|
1983
|
+
onClick: onCopyIndexClick(index),
|
|
1984
|
+
uiSchema: uiSchema,
|
|
1985
|
+
registry: registry
|
|
1942
1986
|
}), hasRemove && jsx(RemoveButton, {
|
|
1943
1987
|
style: btnStyle,
|
|
1944
1988
|
disabled: disabled || readonly,
|
|
@@ -2147,6 +2191,15 @@ function IconButton(props) {
|
|
|
2147
2191
|
})
|
|
2148
2192
|
}));
|
|
2149
2193
|
}
|
|
2194
|
+
function CopyButton(props) {
|
|
2195
|
+
var translateString = props.registry.translateString;
|
|
2196
|
+
return jsx(IconButton, _extends({
|
|
2197
|
+
title: translateString(TranslatableString.CopyButton),
|
|
2198
|
+
className: 'array-item-copy'
|
|
2199
|
+
}, props, {
|
|
2200
|
+
icon: 'copy'
|
|
2201
|
+
}));
|
|
2202
|
+
}
|
|
2150
2203
|
function MoveDownButton(props) {
|
|
2151
2204
|
var translateString = props.registry.translateString;
|
|
2152
2205
|
return jsx(IconButton, _extends({
|
|
@@ -2205,6 +2258,7 @@ function buttonTemplates() {
|
|
|
2205
2258
|
return {
|
|
2206
2259
|
SubmitButton: SubmitButton,
|
|
2207
2260
|
AddButton: AddButton,
|
|
2261
|
+
CopyButton: CopyButton,
|
|
2208
2262
|
MoveDownButton: MoveDownButton,
|
|
2209
2263
|
MoveUpButton: MoveUpButton,
|
|
2210
2264
|
RemoveButton: RemoveButton
|
|
@@ -3365,6 +3419,26 @@ function TextWidget(props) {
|
|
|
3365
3419
|
return jsx(BaseInputTemplate, _extends({}, props));
|
|
3366
3420
|
}
|
|
3367
3421
|
|
|
3422
|
+
/** The `TimeWidget` component uses the `BaseInputTemplate` changing the type to `time` and transforms
|
|
3423
|
+
* the value to undefined when it is falsy during the `onChange` handling.
|
|
3424
|
+
*
|
|
3425
|
+
* @param props - The `WidgetProps` for this component
|
|
3426
|
+
*/
|
|
3427
|
+
function TimeWidget(props) {
|
|
3428
|
+
var onChange = props.onChange,
|
|
3429
|
+
options = props.options,
|
|
3430
|
+
registry = props.registry;
|
|
3431
|
+
var BaseInputTemplate = getTemplate('BaseInputTemplate', registry, options);
|
|
3432
|
+
var handleChange = useCallback(function (value) {
|
|
3433
|
+
return onChange(value ? value + ":00" : undefined);
|
|
3434
|
+
}, [onChange]);
|
|
3435
|
+
return jsx(BaseInputTemplate, _extends({
|
|
3436
|
+
type: 'time'
|
|
3437
|
+
}, props, {
|
|
3438
|
+
onChange: handleChange
|
|
3439
|
+
}));
|
|
3440
|
+
}
|
|
3441
|
+
|
|
3368
3442
|
/** The `URLWidget` component uses the `BaseInputTemplate` changing the type to `url`.
|
|
3369
3443
|
*
|
|
3370
3444
|
* @param props - The `WidgetProps` for this component
|
|
@@ -3393,24 +3467,25 @@ function UpDownWidget(props) {
|
|
|
3393
3467
|
|
|
3394
3468
|
function widgets() {
|
|
3395
3469
|
return {
|
|
3470
|
+
AltDateWidget: AltDateWidget,
|
|
3471
|
+
AltDateTimeWidget: AltDateTimeWidget,
|
|
3472
|
+
CheckboxWidget: CheckboxWidget,
|
|
3473
|
+
CheckboxesWidget: CheckboxesWidget,
|
|
3474
|
+
ColorWidget: ColorWidget,
|
|
3475
|
+
DateWidget: DateWidget,
|
|
3476
|
+
DateTimeWidget: DateTimeWidget,
|
|
3477
|
+
EmailWidget: EmailWidget,
|
|
3478
|
+
FileWidget: FileWidget,
|
|
3479
|
+
HiddenWidget: HiddenWidget,
|
|
3396
3480
|
PasswordWidget: PasswordWidget,
|
|
3397
3481
|
RadioWidget: RadioWidget,
|
|
3398
|
-
UpDownWidget: UpDownWidget,
|
|
3399
3482
|
RangeWidget: RangeWidget,
|
|
3400
3483
|
SelectWidget: SelectWidget,
|
|
3401
3484
|
TextWidget: TextWidget,
|
|
3402
|
-
DateWidget: DateWidget,
|
|
3403
|
-
DateTimeWidget: DateTimeWidget,
|
|
3404
|
-
AltDateWidget: AltDateWidget,
|
|
3405
|
-
AltDateTimeWidget: AltDateTimeWidget,
|
|
3406
|
-
EmailWidget: EmailWidget,
|
|
3407
|
-
URLWidget: URLWidget,
|
|
3408
3485
|
TextareaWidget: TextareaWidget,
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
CheckboxWidget: CheckboxWidget,
|
|
3413
|
-
CheckboxesWidget: CheckboxesWidget
|
|
3486
|
+
TimeWidget: TimeWidget,
|
|
3487
|
+
UpDownWidget: UpDownWidget,
|
|
3488
|
+
URLWidget: URLWidget
|
|
3414
3489
|
};
|
|
3415
3490
|
}
|
|
3416
3491
|
|
|
@@ -3554,6 +3629,21 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3554
3629
|
return onChange && onChange(_extends({}, _this.state, state), id);
|
|
3555
3630
|
});
|
|
3556
3631
|
};
|
|
3632
|
+
_this.reset = function () {
|
|
3633
|
+
var onChange = _this.props.onChange;
|
|
3634
|
+
var newState = _this.getStateFromProps(_this.props, undefined);
|
|
3635
|
+
var newFormData = newState.formData;
|
|
3636
|
+
var state = {
|
|
3637
|
+
formData: newFormData,
|
|
3638
|
+
errorSchema: {},
|
|
3639
|
+
errors: [],
|
|
3640
|
+
schemaValidationErrors: [],
|
|
3641
|
+
schemaValidationErrorSchema: {}
|
|
3642
|
+
};
|
|
3643
|
+
_this.setState(state, function () {
|
|
3644
|
+
return onChange && onChange(_extends({}, _this.state, state));
|
|
3645
|
+
});
|
|
3646
|
+
};
|
|
3557
3647
|
_this.onBlur = function (id, data) {
|
|
3558
3648
|
var onBlur = _this.props.onBlur;
|
|
3559
3649
|
if (onBlur) {
|
|
@@ -3767,7 +3857,10 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3767
3857
|
/** Returns the registry for the form */
|
|
3768
3858
|
_proto.getRegistry = function getRegistry() {
|
|
3769
3859
|
var _this$props$templates;
|
|
3770
|
-
var
|
|
3860
|
+
var _this$props4 = this.props,
|
|
3861
|
+
customTranslateString = _this$props4.translateString,
|
|
3862
|
+
_this$props4$uiSchema = _this$props4.uiSchema,
|
|
3863
|
+
uiSchema = _this$props4$uiSchema === void 0 ? {} : _this$props4$uiSchema;
|
|
3771
3864
|
var schemaUtils = this.state.schemaUtils;
|
|
3772
3865
|
var _getDefaultRegistry = getDefaultRegistry(),
|
|
3773
3866
|
fields = _getDefaultRegistry.fields,
|
|
@@ -3784,7 +3877,8 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3784
3877
|
rootSchema: this.props.schema,
|
|
3785
3878
|
formContext: this.props.formContext || formContext,
|
|
3786
3879
|
schemaUtils: schemaUtils,
|
|
3787
|
-
translateString: customTranslateString || translateString
|
|
3880
|
+
translateString: customTranslateString || translateString,
|
|
3881
|
+
globalUiOptions: uiSchema[UI_GLOBAL_OPTIONS_KEY]
|
|
3788
3882
|
};
|
|
3789
3883
|
}
|
|
3790
3884
|
/** Provides a function that can be used to programmatically submit the `Form` */;
|
|
@@ -3803,11 +3897,11 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3803
3897
|
* @param error - The error on which to focus
|
|
3804
3898
|
*/;
|
|
3805
3899
|
_proto.focusOnError = function focusOnError(error) {
|
|
3806
|
-
var _this$
|
|
3807
|
-
_this$
|
|
3808
|
-
idPrefix = _this$
|
|
3809
|
-
_this$
|
|
3810
|
-
idSeparator = _this$
|
|
3900
|
+
var _this$props5 = this.props,
|
|
3901
|
+
_this$props5$idPrefix = _this$props5.idPrefix,
|
|
3902
|
+
idPrefix = _this$props5$idPrefix === void 0 ? 'root' : _this$props5$idPrefix,
|
|
3903
|
+
_this$props5$idSepara = _this$props5.idSeparator,
|
|
3904
|
+
idSeparator = _this$props5$idSepara === void 0 ? '_' : _this$props5$idSepara;
|
|
3811
3905
|
var property = error.property;
|
|
3812
3906
|
var path = _toPath(property);
|
|
3813
3907
|
if (path[0] === '') {
|
|
@@ -3833,10 +3927,10 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3833
3927
|
* @returns - True if the form is valid, false otherwise.
|
|
3834
3928
|
*/;
|
|
3835
3929
|
_proto.validateForm = function validateForm() {
|
|
3836
|
-
var _this$
|
|
3837
|
-
extraErrors = _this$
|
|
3838
|
-
focusOnFirstError = _this$
|
|
3839
|
-
onError = _this$
|
|
3930
|
+
var _this$props6 = this.props,
|
|
3931
|
+
extraErrors = _this$props6.extraErrors,
|
|
3932
|
+
focusOnFirstError = _this$props6.focusOnFirstError,
|
|
3933
|
+
onError = _this$props6.onError;
|
|
3840
3934
|
var formData = this.state.formData;
|
|
3841
3935
|
var schemaUtils = this.state.schemaUtils;
|
|
3842
3936
|
var schemaValidation = this.validate(formData);
|
|
@@ -3873,31 +3967,31 @@ var Form = /*#__PURE__*/function (_Component) {
|
|
|
3873
3967
|
* needed along with the submit button or any children of the form.
|
|
3874
3968
|
*/;
|
|
3875
3969
|
_proto.render = function render() {
|
|
3876
|
-
var _this$
|
|
3877
|
-
children = _this$
|
|
3878
|
-
id = _this$
|
|
3879
|
-
idPrefix = _this$
|
|
3880
|
-
idSeparator = _this$
|
|
3881
|
-
_this$
|
|
3882
|
-
className = _this$
|
|
3883
|
-
tagName = _this$
|
|
3884
|
-
name = _this$
|
|
3885
|
-
method = _this$
|
|
3886
|
-
target = _this$
|
|
3887
|
-
action = _this$
|
|
3888
|
-
autoComplete = _this$
|
|
3889
|
-
enctype = _this$
|
|
3890
|
-
acceptcharset = _this$
|
|
3891
|
-
_this$
|
|
3892
|
-
noHtml5Validate = _this$
|
|
3893
|
-
_this$
|
|
3894
|
-
disabled = _this$
|
|
3895
|
-
_this$
|
|
3896
|
-
readonly = _this$
|
|
3897
|
-
formContext = _this$
|
|
3898
|
-
_this$
|
|
3899
|
-
showErrorList = _this$
|
|
3900
|
-
_internalFormWrapper = _this$
|
|
3970
|
+
var _this$props7 = this.props,
|
|
3971
|
+
children = _this$props7.children,
|
|
3972
|
+
id = _this$props7.id,
|
|
3973
|
+
idPrefix = _this$props7.idPrefix,
|
|
3974
|
+
idSeparator = _this$props7.idSeparator,
|
|
3975
|
+
_this$props7$classNam = _this$props7.className,
|
|
3976
|
+
className = _this$props7$classNam === void 0 ? '' : _this$props7$classNam,
|
|
3977
|
+
tagName = _this$props7.tagName,
|
|
3978
|
+
name = _this$props7.name,
|
|
3979
|
+
method = _this$props7.method,
|
|
3980
|
+
target = _this$props7.target,
|
|
3981
|
+
action = _this$props7.action,
|
|
3982
|
+
autoComplete = _this$props7.autoComplete,
|
|
3983
|
+
enctype = _this$props7.enctype,
|
|
3984
|
+
acceptcharset = _this$props7.acceptcharset,
|
|
3985
|
+
_this$props7$noHtml5V = _this$props7.noHtml5Validate,
|
|
3986
|
+
noHtml5Validate = _this$props7$noHtml5V === void 0 ? false : _this$props7$noHtml5V,
|
|
3987
|
+
_this$props7$disabled = _this$props7.disabled,
|
|
3988
|
+
disabled = _this$props7$disabled === void 0 ? false : _this$props7$disabled,
|
|
3989
|
+
_this$props7$readonly = _this$props7.readonly,
|
|
3990
|
+
readonly = _this$props7$readonly === void 0 ? false : _this$props7$readonly,
|
|
3991
|
+
formContext = _this$props7.formContext,
|
|
3992
|
+
_this$props7$showErro = _this$props7.showErrorList,
|
|
3993
|
+
showErrorList = _this$props7$showErro === void 0 ? 'top' : _this$props7$showErro,
|
|
3994
|
+
_internalFormWrapper = _this$props7._internalFormWrapper;
|
|
3901
3995
|
var _this$state4 = this.state,
|
|
3902
3996
|
schema = _this$state4.schema,
|
|
3903
3997
|
uiSchema = _this$state4.uiSchema,
|