@rjsf/core 5.2.1 → 5.3.1

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.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
- var _getUiOptions = getUiOptions(uiSchema),
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
- _props$canMoveUp = props.canMoveUp,
754
- canMoveUp = _props$canMoveUp === void 0 ? true : _props$canMoveUp,
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 uiSchema = _this.props.uiSchema;
1281
- var _getUiOptions = getUiOptions(uiSchema),
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$props3 = _this.props,
1298
- formData = _this$props3.formData,
1299
- onChange = _this$props3.onChange,
1300
- errorSchema = _this$props3.errorSchema;
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$props4 = _this.props,
1322
- formData = _this$props4.formData,
1323
- onChange = _this$props4.onChange,
1324
- registry = _this$props4.registry;
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$props5 = this.props,
1400
- rawSchema = _this$props5.schema,
1401
- _this$props5$uiSchema = _this$props5.uiSchema,
1402
- uiSchema = _this$props5$uiSchema === void 0 ? {} : _this$props5$uiSchema,
1403
- formData = _this$props5.formData,
1404
- errorSchema = _this$props5.errorSchema,
1405
- idSchema = _this$props5.idSchema,
1406
- name = _this$props5.name,
1407
- _this$props5$required = _this$props5.required,
1408
- required = _this$props5$required === void 0 ? false : _this$props5$required,
1409
- _this$props5$disabled = _this$props5.disabled,
1410
- disabled = _this$props5$disabled === void 0 ? false : _this$props5$disabled,
1411
- _this$props5$readonly = _this$props5.readonly,
1412
- readonly = _this$props5$readonly === void 0 ? false : _this$props5$readonly,
1413
- hideError = _this$props5.hideError,
1414
- idPrefix = _this$props5.idPrefix,
1415
- idSeparator = _this$props5.idSeparator,
1416
- onBlur = _this$props5.onBlur,
1417
- onFocus = _this$props5.onFocus,
1418
- registry = _this$props5.registry;
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: [jsxs("p", {
1469
+ children: [jsx("p", {
1436
1470
  className: 'config-error',
1437
1471
  style: {
1438
1472
  color: 'red'
1439
1473
  },
1440
- children: ["Invalid ", name || 'root', " object field configuration:", jsx("em", {
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: uiOptions.title || 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
- var uiOptions = getUiOptions(uiSchema);
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
@@ -2686,22 +2740,25 @@ function AltDateWidget(_ref2) {
2686
2740
  onChange = _ref2.onChange,
2687
2741
  value = _ref2.value;
2688
2742
  var translateString = registry.translateString;
2743
+ var _useState = useState(value),
2744
+ lastValue = _useState[0],
2745
+ setLastValue = _useState[1];
2689
2746
  var _useReducer = useReducer(function (state, action) {
2690
2747
  return _extends({}, state, action);
2691
2748
  }, parseDateString(value, time)),
2692
2749
  state = _useReducer[0],
2693
2750
  setState = _useReducer[1];
2694
2751
  useEffect(function () {
2695
- if (value && value !== toDateString(state, time)) {
2752
+ var stateValue = toDateString(state, time);
2753
+ if (readyForChange(state) && stateValue !== value) {
2754
+ // The user changed the date to a new valid data via the comboboxes, so call onChange
2755
+ onChange(stateValue);
2756
+ } else if (lastValue !== value) {
2757
+ // We got a new value in the props
2758
+ setLastValue(value);
2696
2759
  setState(parseDateString(value, time));
2697
2760
  }
2698
- }, [value, state, time]);
2699
- useEffect(function () {
2700
- if (readyForChange(state)) {
2701
- // Only propagate to parent state if we have a complete date{time}
2702
- onChange(toDateString(state, time));
2703
- }
2704
- }, [state, time, onChange]);
2761
+ }, [time, value, onChange, state, lastValue]);
2705
2762
  var handleChange = useCallback(function (property, value) {
2706
2763
  var _setState;
2707
2764
  setState((_setState = {}, _setState[property] = value, _setState));
@@ -2711,17 +2768,16 @@ function AltDateWidget(_ref2) {
2711
2768
  if (disabled || readonly) {
2712
2769
  return;
2713
2770
  }
2714
- var nowDateObj = parseDateString(new Date().toJSON(), time);
2715
- setState(nowDateObj);
2771
+ var nextState = parseDateString(new Date().toJSON(), time);
2772
+ onChange(toDateString(nextState, time));
2716
2773
  }, [disabled, readonly, time]);
2717
2774
  var handleClear = useCallback(function (event) {
2718
2775
  event.preventDefault();
2719
2776
  if (disabled || readonly) {
2720
2777
  return;
2721
2778
  }
2722
- setState(parseDateString('', time));
2723
2779
  onChange(undefined);
2724
- }, [disabled, readonly, time, onChange]);
2780
+ }, [disabled, readonly, onChange]);
2725
2781
  return jsxs("ul", {
2726
2782
  className: 'list-inline',
2727
2783
  children: [dateElementProps(state, time, options.yearsRange).map(function (elemProps, i) {
@@ -3365,6 +3421,26 @@ function TextWidget(props) {
3365
3421
  return jsx(BaseInputTemplate, _extends({}, props));
3366
3422
  }
3367
3423
 
3424
+ /** The `TimeWidget` component uses the `BaseInputTemplate` changing the type to `time` and transforms
3425
+ * the value to undefined when it is falsy during the `onChange` handling.
3426
+ *
3427
+ * @param props - The `WidgetProps` for this component
3428
+ */
3429
+ function TimeWidget(props) {
3430
+ var onChange = props.onChange,
3431
+ options = props.options,
3432
+ registry = props.registry;
3433
+ var BaseInputTemplate = getTemplate('BaseInputTemplate', registry, options);
3434
+ var handleChange = useCallback(function (value) {
3435
+ return onChange(value ? value + ":00" : undefined);
3436
+ }, [onChange]);
3437
+ return jsx(BaseInputTemplate, _extends({
3438
+ type: 'time'
3439
+ }, props, {
3440
+ onChange: handleChange
3441
+ }));
3442
+ }
3443
+
3368
3444
  /** The `URLWidget` component uses the `BaseInputTemplate` changing the type to `url`.
3369
3445
  *
3370
3446
  * @param props - The `WidgetProps` for this component
@@ -3393,24 +3469,25 @@ function UpDownWidget(props) {
3393
3469
 
3394
3470
  function widgets() {
3395
3471
  return {
3472
+ AltDateWidget: AltDateWidget,
3473
+ AltDateTimeWidget: AltDateTimeWidget,
3474
+ CheckboxWidget: CheckboxWidget,
3475
+ CheckboxesWidget: CheckboxesWidget,
3476
+ ColorWidget: ColorWidget,
3477
+ DateWidget: DateWidget,
3478
+ DateTimeWidget: DateTimeWidget,
3479
+ EmailWidget: EmailWidget,
3480
+ FileWidget: FileWidget,
3481
+ HiddenWidget: HiddenWidget,
3396
3482
  PasswordWidget: PasswordWidget,
3397
3483
  RadioWidget: RadioWidget,
3398
- UpDownWidget: UpDownWidget,
3399
3484
  RangeWidget: RangeWidget,
3400
3485
  SelectWidget: SelectWidget,
3401
3486
  TextWidget: TextWidget,
3402
- DateWidget: DateWidget,
3403
- DateTimeWidget: DateTimeWidget,
3404
- AltDateWidget: AltDateWidget,
3405
- AltDateTimeWidget: AltDateTimeWidget,
3406
- EmailWidget: EmailWidget,
3407
- URLWidget: URLWidget,
3408
3487
  TextareaWidget: TextareaWidget,
3409
- HiddenWidget: HiddenWidget,
3410
- ColorWidget: ColorWidget,
3411
- FileWidget: FileWidget,
3412
- CheckboxWidget: CheckboxWidget,
3413
- CheckboxesWidget: CheckboxesWidget
3488
+ TimeWidget: TimeWidget,
3489
+ UpDownWidget: UpDownWidget,
3490
+ URLWidget: URLWidget
3414
3491
  };
3415
3492
  }
3416
3493
 
@@ -3554,6 +3631,21 @@ var Form = /*#__PURE__*/function (_Component) {
3554
3631
  return onChange && onChange(_extends({}, _this.state, state), id);
3555
3632
  });
3556
3633
  };
3634
+ _this.reset = function () {
3635
+ var onChange = _this.props.onChange;
3636
+ var newState = _this.getStateFromProps(_this.props, undefined);
3637
+ var newFormData = newState.formData;
3638
+ var state = {
3639
+ formData: newFormData,
3640
+ errorSchema: {},
3641
+ errors: [],
3642
+ schemaValidationErrors: [],
3643
+ schemaValidationErrorSchema: {}
3644
+ };
3645
+ _this.setState(state, function () {
3646
+ return onChange && onChange(_extends({}, _this.state, state));
3647
+ });
3648
+ };
3557
3649
  _this.onBlur = function (id, data) {
3558
3650
  var onBlur = _this.props.onBlur;
3559
3651
  if (onBlur) {
@@ -3767,7 +3859,10 @@ var Form = /*#__PURE__*/function (_Component) {
3767
3859
  /** Returns the registry for the form */
3768
3860
  _proto.getRegistry = function getRegistry() {
3769
3861
  var _this$props$templates;
3770
- var customTranslateString = this.props.translateString;
3862
+ var _this$props4 = this.props,
3863
+ customTranslateString = _this$props4.translateString,
3864
+ _this$props4$uiSchema = _this$props4.uiSchema,
3865
+ uiSchema = _this$props4$uiSchema === void 0 ? {} : _this$props4$uiSchema;
3771
3866
  var schemaUtils = this.state.schemaUtils;
3772
3867
  var _getDefaultRegistry = getDefaultRegistry(),
3773
3868
  fields = _getDefaultRegistry.fields,
@@ -3784,7 +3879,8 @@ var Form = /*#__PURE__*/function (_Component) {
3784
3879
  rootSchema: this.props.schema,
3785
3880
  formContext: this.props.formContext || formContext,
3786
3881
  schemaUtils: schemaUtils,
3787
- translateString: customTranslateString || translateString
3882
+ translateString: customTranslateString || translateString,
3883
+ globalUiOptions: uiSchema[UI_GLOBAL_OPTIONS_KEY]
3788
3884
  };
3789
3885
  }
3790
3886
  /** Provides a function that can be used to programmatically submit the `Form` */;
@@ -3803,11 +3899,11 @@ var Form = /*#__PURE__*/function (_Component) {
3803
3899
  * @param error - The error on which to focus
3804
3900
  */;
3805
3901
  _proto.focusOnError = function focusOnError(error) {
3806
- var _this$props4 = this.props,
3807
- _this$props4$idPrefix = _this$props4.idPrefix,
3808
- idPrefix = _this$props4$idPrefix === void 0 ? 'root' : _this$props4$idPrefix,
3809
- _this$props4$idSepara = _this$props4.idSeparator,
3810
- idSeparator = _this$props4$idSepara === void 0 ? '_' : _this$props4$idSepara;
3902
+ var _this$props5 = this.props,
3903
+ _this$props5$idPrefix = _this$props5.idPrefix,
3904
+ idPrefix = _this$props5$idPrefix === void 0 ? 'root' : _this$props5$idPrefix,
3905
+ _this$props5$idSepara = _this$props5.idSeparator,
3906
+ idSeparator = _this$props5$idSepara === void 0 ? '_' : _this$props5$idSepara;
3811
3907
  var property = error.property;
3812
3908
  var path = _toPath(property);
3813
3909
  if (path[0] === '') {
@@ -3833,10 +3929,10 @@ var Form = /*#__PURE__*/function (_Component) {
3833
3929
  * @returns - True if the form is valid, false otherwise.
3834
3930
  */;
3835
3931
  _proto.validateForm = function validateForm() {
3836
- var _this$props5 = this.props,
3837
- extraErrors = _this$props5.extraErrors,
3838
- focusOnFirstError = _this$props5.focusOnFirstError,
3839
- onError = _this$props5.onError;
3932
+ var _this$props6 = this.props,
3933
+ extraErrors = _this$props6.extraErrors,
3934
+ focusOnFirstError = _this$props6.focusOnFirstError,
3935
+ onError = _this$props6.onError;
3840
3936
  var formData = this.state.formData;
3841
3937
  var schemaUtils = this.state.schemaUtils;
3842
3938
  var schemaValidation = this.validate(formData);
@@ -3873,31 +3969,31 @@ var Form = /*#__PURE__*/function (_Component) {
3873
3969
  * needed along with the submit button or any children of the form.
3874
3970
  */;
3875
3971
  _proto.render = function render() {
3876
- var _this$props6 = this.props,
3877
- children = _this$props6.children,
3878
- id = _this$props6.id,
3879
- idPrefix = _this$props6.idPrefix,
3880
- idSeparator = _this$props6.idSeparator,
3881
- _this$props6$classNam = _this$props6.className,
3882
- className = _this$props6$classNam === void 0 ? '' : _this$props6$classNam,
3883
- tagName = _this$props6.tagName,
3884
- name = _this$props6.name,
3885
- method = _this$props6.method,
3886
- target = _this$props6.target,
3887
- action = _this$props6.action,
3888
- autoComplete = _this$props6.autoComplete,
3889
- enctype = _this$props6.enctype,
3890
- acceptcharset = _this$props6.acceptcharset,
3891
- _this$props6$noHtml5V = _this$props6.noHtml5Validate,
3892
- noHtml5Validate = _this$props6$noHtml5V === void 0 ? false : _this$props6$noHtml5V,
3893
- _this$props6$disabled = _this$props6.disabled,
3894
- disabled = _this$props6$disabled === void 0 ? false : _this$props6$disabled,
3895
- _this$props6$readonly = _this$props6.readonly,
3896
- readonly = _this$props6$readonly === void 0 ? false : _this$props6$readonly,
3897
- formContext = _this$props6.formContext,
3898
- _this$props6$showErro = _this$props6.showErrorList,
3899
- showErrorList = _this$props6$showErro === void 0 ? 'top' : _this$props6$showErro,
3900
- _internalFormWrapper = _this$props6._internalFormWrapper;
3972
+ var _this$props7 = this.props,
3973
+ children = _this$props7.children,
3974
+ id = _this$props7.id,
3975
+ idPrefix = _this$props7.idPrefix,
3976
+ idSeparator = _this$props7.idSeparator,
3977
+ _this$props7$classNam = _this$props7.className,
3978
+ className = _this$props7$classNam === void 0 ? '' : _this$props7$classNam,
3979
+ tagName = _this$props7.tagName,
3980
+ name = _this$props7.name,
3981
+ method = _this$props7.method,
3982
+ target = _this$props7.target,
3983
+ action = _this$props7.action,
3984
+ autoComplete = _this$props7.autoComplete,
3985
+ enctype = _this$props7.enctype,
3986
+ acceptcharset = _this$props7.acceptcharset,
3987
+ _this$props7$noHtml5V = _this$props7.noHtml5Validate,
3988
+ noHtml5Validate = _this$props7$noHtml5V === void 0 ? false : _this$props7$noHtml5V,
3989
+ _this$props7$disabled = _this$props7.disabled,
3990
+ disabled = _this$props7$disabled === void 0 ? false : _this$props7$disabled,
3991
+ _this$props7$readonly = _this$props7.readonly,
3992
+ readonly = _this$props7$readonly === void 0 ? false : _this$props7$readonly,
3993
+ formContext = _this$props7.formContext,
3994
+ _this$props7$showErro = _this$props7.showErrorList,
3995
+ showErrorList = _this$props7$showErro === void 0 ? 'top' : _this$props7$showErro,
3996
+ _internalFormWrapper = _this$props7._internalFormWrapper;
3901
3997
  var _this$state4 = this.state,
3902
3998
  schema = _this$state4.schema,
3903
3999
  uiSchema = _this$state4.uiSchema,