@rjsf/core 5.0.0-beta.1 → 5.0.0-beta.10

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.
Files changed (63) hide show
  1. package/README.md +2 -0
  2. package/dist/core.cjs.development.js +272 -202
  3. package/dist/core.cjs.development.js.map +1 -1
  4. package/dist/core.cjs.production.min.js +1 -1
  5. package/dist/core.cjs.production.min.js.map +1 -1
  6. package/dist/core.esm.js +272 -202
  7. package/dist/core.esm.js.map +1 -1
  8. package/dist/core.umd.development.js +272 -202
  9. package/dist/core.umd.development.js.map +1 -1
  10. package/dist/core.umd.production.min.js +1 -1
  11. package/dist/core.umd.production.min.js.map +1 -1
  12. package/dist/index.d.ts +303 -6
  13. package/package.json +9 -7
  14. package/dist/components/Form.d.ts +0 -277
  15. package/dist/components/fields/ArrayField.d.ts +0 -6
  16. package/dist/components/fields/BooleanField.d.ts +0 -8
  17. package/dist/components/fields/MultiSchemaField.d.ts +0 -44
  18. package/dist/components/fields/NullField.d.ts +0 -8
  19. package/dist/components/fields/NumberField.d.ts +0 -20
  20. package/dist/components/fields/ObjectField.d.ts +0 -73
  21. package/dist/components/fields/SchemaField.d.ts +0 -10
  22. package/dist/components/fields/StringField.d.ts +0 -7
  23. package/dist/components/fields/index.d.ts +0 -3
  24. package/dist/components/templates/ArrayFieldDescriptionTemplate.d.ts +0 -7
  25. package/dist/components/templates/ArrayFieldItemTemplate.d.ts +0 -6
  26. package/dist/components/templates/ArrayFieldTemplate.d.ts +0 -6
  27. package/dist/components/templates/ArrayFieldTitleTemplate.d.ts +0 -7
  28. package/dist/components/templates/BaseInputTemplate.d.ts +0 -8
  29. package/dist/components/templates/ButtonTemplates/AddButton.d.ts +0 -4
  30. package/dist/components/templates/ButtonTemplates/IconButton.d.ts +0 -5
  31. package/dist/components/templates/ButtonTemplates/SubmitButton.d.ts +0 -4
  32. package/dist/components/templates/ButtonTemplates/index.d.ts +0 -3
  33. package/dist/components/templates/DescriptionField.d.ts +0 -6
  34. package/dist/components/templates/ErrorList.d.ts +0 -6
  35. package/dist/components/templates/FieldTemplate/FieldTemplate.d.ts +0 -7
  36. package/dist/components/templates/FieldTemplate/Label.d.ts +0 -13
  37. package/dist/components/templates/FieldTemplate/WrapIfAdditional.d.ts +0 -12
  38. package/dist/components/templates/FieldTemplate/index.d.ts +0 -2
  39. package/dist/components/templates/ObjectFieldTemplate.d.ts +0 -8
  40. package/dist/components/templates/TitleField.d.ts +0 -6
  41. package/dist/components/templates/UnsupportedField.d.ts +0 -8
  42. package/dist/components/templates/index.d.ts +0 -3
  43. package/dist/components/widgets/AltDateTimeWidget.d.ts +0 -8
  44. package/dist/components/widgets/AltDateWidget.d.ts +0 -6
  45. package/dist/components/widgets/CheckboxWidget.d.ts +0 -8
  46. package/dist/components/widgets/CheckboxesWidget.d.ts +0 -8
  47. package/dist/components/widgets/ColorWidget.d.ts +0 -7
  48. package/dist/components/widgets/DateTimeWidget.d.ts +0 -7
  49. package/dist/components/widgets/DateWidget.d.ts +0 -7
  50. package/dist/components/widgets/EmailWidget.d.ts +0 -6
  51. package/dist/components/widgets/FileWidget.d.ts +0 -7
  52. package/dist/components/widgets/HiddenWidget.d.ts +0 -8
  53. package/dist/components/widgets/PasswordWidget.d.ts +0 -6
  54. package/dist/components/widgets/RadioWidget.d.ts +0 -8
  55. package/dist/components/widgets/RangeWidget.d.ts +0 -7
  56. package/dist/components/widgets/SelectWidget.d.ts +0 -8
  57. package/dist/components/widgets/TextWidget.d.ts +0 -6
  58. package/dist/components/widgets/TextareaWidget.d.ts +0 -13
  59. package/dist/components/widgets/URLWidget.d.ts +0 -6
  60. package/dist/components/widgets/UpDownWidget.d.ts +0 -6
  61. package/dist/components/widgets/index.d.ts +0 -3
  62. package/dist/getDefaultRegistry.d.ts +0 -6
  63. package/dist/withTheme.d.ts +0 -8
@@ -774,9 +774,11 @@
774
774
  } = this.props;
775
775
  const {
776
776
  fields: {
777
+ ArraySchemaField,
777
778
  SchemaField
778
779
  }
779
780
  } = registry;
781
+ const ItemSchemaField = ArraySchemaField || SchemaField;
780
782
  const {
781
783
  orderable = true,
782
784
  removable = true
@@ -789,7 +791,7 @@
789
791
  };
790
792
  has.toolbar = Object.keys(has).some(key => has[key]);
791
793
  return {
792
- children: /*#__PURE__*/React__default["default"].createElement(SchemaField, {
794
+ children: /*#__PURE__*/React__default["default"].createElement(ItemSchemaField, {
793
795
  name: name,
794
796
  index: index,
795
797
  schema: itemSchema,
@@ -823,7 +825,8 @@
823
825
  onDropIndexClick: this.onDropIndexClick,
824
826
  onReorderClick: this.onReorderClick,
825
827
  readonly,
826
- registry
828
+ registry,
829
+ uiSchema: itemUiSchema
827
830
  };
828
831
  }
829
832
 
@@ -1585,58 +1588,6 @@
1585
1588
  });
1586
1589
  };
1587
1590
  }
1588
- /** The `Help` component renders any help desired for a field
1589
- *
1590
- * @param props - The id and help information to be rendered
1591
- */
1592
-
1593
-
1594
- function Help(props) {
1595
- const {
1596
- id,
1597
- help
1598
- } = props;
1599
-
1600
- if (!help) {
1601
- return null;
1602
- }
1603
-
1604
- if (typeof help === "string") {
1605
- return /*#__PURE__*/React__default["default"].createElement("p", {
1606
- id: id,
1607
- className: "help-block"
1608
- }, help);
1609
- }
1610
-
1611
- return /*#__PURE__*/React__default["default"].createElement("div", {
1612
- id: id,
1613
- className: "help-block"
1614
- }, help);
1615
- }
1616
- /** The `ErrorList` component renders the errors local to the particular field
1617
- *
1618
- * @param props - The list of errors to show
1619
- */
1620
-
1621
-
1622
- function ErrorList$1(props) {
1623
- const {
1624
- errors = []
1625
- } = props;
1626
-
1627
- if (errors.length === 0) {
1628
- return null;
1629
- }
1630
-
1631
- return /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement("ul", {
1632
- className: "error-detail bs-callout bs-callout-info"
1633
- }, errors.filter(elem => !!elem).map((error, index) => {
1634
- return /*#__PURE__*/React__default["default"].createElement("li", {
1635
- className: "text-danger",
1636
- key: index
1637
- }, error);
1638
- })));
1639
- }
1640
1591
  /** The `SchemaFieldRender` component is the work-horse of react-jsonschema-form, determining what kind of real field to
1641
1592
  * render based on the `schema`, `uiSchema` and all the other props. It also deals with rendering the `anyOf` and
1642
1593
  * `oneOf` fields.
@@ -1669,6 +1620,8 @@
1669
1620
  const uiOptions = utils.getUiOptions(uiSchema);
1670
1621
  const FieldTemplate = utils.getTemplate("FieldTemplate", registry, uiOptions);
1671
1622
  const DescriptionFieldTemplate = utils.getTemplate("DescriptionFieldTemplate", registry, uiOptions);
1623
+ const FieldHelpTemplate = utils.getTemplate("FieldHelpTemplate", registry, uiOptions);
1624
+ const FieldErrorTemplate = utils.getTemplate("FieldErrorTemplate", registry, uiOptions);
1672
1625
  const schema = schemaUtils.retrieveSchema(_schema, formData);
1673
1626
  const idSchema = utils.mergeObjects(schemaUtils.toIdSchema(schema, _idSchema.$id, formData, idPrefix, idSeparator), _idSchema);
1674
1627
  const FieldComponent = getFieldComponent(schema, uiOptions, idSchema, registry);
@@ -1714,16 +1667,15 @@
1714
1667
  if (wasPropertyKeyModified) {
1715
1668
  label = name;
1716
1669
  } else {
1717
- label = uiOptions.title || props.schema.title || schema.title || name;
1670
+ label = utils.ADDITIONAL_PROPERTY_FLAG in schema ? name : uiOptions.title || props.schema.title || schema.title || name;
1718
1671
  }
1719
1672
 
1720
1673
  const description = uiOptions.description || props.schema.description || schema.description || "";
1721
- const errors = __errors;
1722
1674
  const help = uiOptions.help;
1723
1675
  const hidden = uiOptions.widget === "hidden";
1724
1676
  const classNames = ["form-group", "field", "field-" + schema.type];
1725
1677
 
1726
- if (!hideError && errors && errors.length > 0) {
1678
+ if (!hideError && __errors && __errors.length > 0) {
1727
1679
  classNames.push("field-error has-error has-danger");
1728
1680
  }
1729
1681
 
@@ -1739,6 +1691,22 @@
1739
1691
  classNames.push(uiOptions.classNames);
1740
1692
  }
1741
1693
 
1694
+ const helpComponent = /*#__PURE__*/React__default["default"].createElement(FieldHelpTemplate, {
1695
+ help: help,
1696
+ idSchema: idSchema,
1697
+ schema: schema,
1698
+ uiSchema: uiSchema,
1699
+ hasErrors: !hideError && __errors && __errors.length > 0,
1700
+ registry: registry
1701
+ });
1702
+ const errorsComponent = hideError ? undefined : /*#__PURE__*/React__default["default"].createElement(FieldErrorTemplate, {
1703
+ errors: __errors,
1704
+ errorSchema: errorSchema,
1705
+ idSchema: idSchema,
1706
+ schema: schema,
1707
+ uiSchema: uiSchema,
1708
+ registry: registry
1709
+ });
1742
1710
  const fieldProps = {
1743
1711
  description: /*#__PURE__*/React__default["default"].createElement(DescriptionFieldTemplate, {
1744
1712
  id: id + "__description",
@@ -1746,15 +1714,10 @@
1746
1714
  registry: registry
1747
1715
  }),
1748
1716
  rawDescription: description,
1749
- help: /*#__PURE__*/React__default["default"].createElement(Help, {
1750
- id: id + "__help",
1751
- help: help
1752
- }),
1717
+ help: helpComponent,
1753
1718
  rawHelp: typeof help === "string" ? help : undefined,
1754
- errors: hideError ? undefined : /*#__PURE__*/React__default["default"].createElement(ErrorList$1, {
1755
- errors: errors
1756
- }),
1757
- rawErrors: hideError ? undefined : errors,
1719
+ errors: errorsComponent,
1720
+ rawErrors: hideError ? undefined : __errors,
1758
1721
  id,
1759
1722
  label,
1760
1723
  hidden,
@@ -1922,6 +1885,7 @@
1922
1885
  const fields = {
1923
1886
  AnyOfField: AnyOfField,
1924
1887
  ArrayField,
1888
+ // ArrayField falls back to SchemaField if ArraySchemaField is not defined, which it isn't by default
1925
1889
  BooleanField,
1926
1890
  NumberField,
1927
1891
  ObjectField,
@@ -1977,7 +1941,8 @@
1977
1941
  onDropIndexClick,
1978
1942
  onReorderClick,
1979
1943
  readonly,
1980
- registry
1944
+ registry,
1945
+ uiSchema
1981
1946
  } = props;
1982
1947
  const {
1983
1948
  MoveDownButton,
@@ -2005,15 +1970,18 @@
2005
1970
  }, (hasMoveUp || hasMoveDown) && /*#__PURE__*/React__default["default"].createElement(MoveUpButton, {
2006
1971
  style: btnStyle,
2007
1972
  disabled: disabled || readonly || !hasMoveUp,
2008
- onClick: onReorderClick(index, index - 1)
1973
+ onClick: onReorderClick(index, index - 1),
1974
+ uiSchema: uiSchema
2009
1975
  }), (hasMoveUp || hasMoveDown) && /*#__PURE__*/React__default["default"].createElement(MoveDownButton, {
2010
1976
  style: btnStyle,
2011
1977
  disabled: disabled || readonly || !hasMoveDown,
2012
- onClick: onReorderClick(index, index + 1)
1978
+ onClick: onReorderClick(index, index + 1),
1979
+ uiSchema: uiSchema
2013
1980
  }), hasRemove && /*#__PURE__*/React__default["default"].createElement(RemoveButton, {
2014
1981
  style: btnStyle,
2015
1982
  disabled: disabled || readonly,
2016
- onClick: onDropIndexClick(index)
1983
+ onClick: onDropIndexClick(index),
1984
+ uiSchema: uiSchema
2017
1985
  }))));
2018
1986
  }
2019
1987
 
@@ -2075,7 +2043,8 @@
2075
2043
  })), canAdd && /*#__PURE__*/React__default["default"].createElement(AddButton, {
2076
2044
  className: "array-item-add",
2077
2045
  onClick: onAddClick,
2078
- disabled: disabled || readonly
2046
+ disabled: disabled || readonly,
2047
+ uiSchema: uiSchema
2079
2048
  }));
2080
2049
  }
2081
2050
 
@@ -2182,8 +2151,8 @@
2182
2151
  }, [onFocus, id]);
2183
2152
 
2184
2153
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("input", {
2185
- key: id,
2186
2154
  id: id,
2155
+ name: id,
2187
2156
  className: "form-control",
2188
2157
  readOnly: readonly,
2189
2158
  disabled: disabled,
@@ -2232,6 +2201,7 @@
2232
2201
  iconType = "default",
2233
2202
  icon,
2234
2203
  className,
2204
+ uiSchema,
2235
2205
  ...otherProps
2236
2206
  } = props;
2237
2207
  return /*#__PURE__*/React__default["default"].createElement("button", {
@@ -2377,71 +2347,6 @@
2377
2347
  }, REQUIRED_FIELD_SYMBOL$1));
2378
2348
  }
2379
2349
 
2380
- /** The `WrapIfAdditional` component is used by the `FieldTemplate` to rename, or remove properties that are
2381
- * part of an `additionalProperties` part of a schema.
2382
- *
2383
- * @param props - The `WrapIfAdditionalProps` for this component
2384
- */
2385
-
2386
- function WrapIfAdditional(props) {
2387
- const {
2388
- id,
2389
- classNames,
2390
- disabled,
2391
- label,
2392
- onKeyChange,
2393
- onDropPropertyClick,
2394
- readonly,
2395
- required,
2396
- schema,
2397
- children,
2398
- registry
2399
- } = props;
2400
- const {
2401
- RemoveButton
2402
- } = registry.templates.ButtonTemplates;
2403
- const keyLabel = label + " Key"; // i18n ?
2404
-
2405
- const additional = (utils.ADDITIONAL_PROPERTY_FLAG in schema);
2406
-
2407
- if (!additional) {
2408
- return /*#__PURE__*/React__default["default"].createElement("div", {
2409
- className: classNames
2410
- }, children);
2411
- }
2412
-
2413
- return /*#__PURE__*/React__default["default"].createElement("div", {
2414
- className: classNames
2415
- }, /*#__PURE__*/React__default["default"].createElement("div", {
2416
- className: "row"
2417
- }, /*#__PURE__*/React__default["default"].createElement("div", {
2418
- className: "col-xs-5 form-additional"
2419
- }, /*#__PURE__*/React__default["default"].createElement("div", {
2420
- className: "form-group"
2421
- }, /*#__PURE__*/React__default["default"].createElement(Label, {
2422
- label: keyLabel,
2423
- required: required,
2424
- id: id + "-key"
2425
- }), /*#__PURE__*/React__default["default"].createElement("input", {
2426
- className: "form-control",
2427
- type: "text",
2428
- id: id + "-key",
2429
- onBlur: event => onKeyChange(event.target.value),
2430
- defaultValue: label
2431
- }))), /*#__PURE__*/React__default["default"].createElement("div", {
2432
- className: "form-additional form-group col-xs-5"
2433
- }, children), /*#__PURE__*/React__default["default"].createElement("div", {
2434
- className: "col-xs-2"
2435
- }, /*#__PURE__*/React__default["default"].createElement(RemoveButton, {
2436
- className: "array-item-remove btn-block",
2437
- style: {
2438
- border: "0"
2439
- },
2440
- disabled: disabled || readonly,
2441
- onClick: onDropPropertyClick(label)
2442
- }))));
2443
- }
2444
-
2445
2350
  /** The `FieldTemplate` component is the template used by `SchemaField` to render any field. It renders the field
2446
2351
  * content, (label, description, children, errors and help) inside of a `WrapIfAdditional` component.
2447
2352
  *
@@ -2458,8 +2363,12 @@
2458
2363
  description,
2459
2364
  hidden,
2460
2365
  required,
2461
- displayLabel
2366
+ displayLabel,
2367
+ registry,
2368
+ uiSchema
2462
2369
  } = props;
2370
+ const uiOptions = utils.getUiOptions(uiSchema);
2371
+ const WrapIfAdditionalTemplate = utils.getTemplate("WrapIfAdditionalTemplate", registry, uiOptions);
2463
2372
 
2464
2373
  if (hidden) {
2465
2374
  return /*#__PURE__*/React__default["default"].createElement("div", {
@@ -2467,7 +2376,7 @@
2467
2376
  }, children);
2468
2377
  }
2469
2378
 
2470
- return /*#__PURE__*/React__default["default"].createElement(WrapIfAdditional, { ...props
2379
+ return /*#__PURE__*/React__default["default"].createElement(WrapIfAdditionalTemplate, { ...props
2471
2380
  }, displayLabel && /*#__PURE__*/React__default["default"].createElement(Label, {
2472
2381
  label: label,
2473
2382
  required: required,
@@ -2475,6 +2384,63 @@
2475
2384
  }), displayLabel && description ? description : null, children, errors, help);
2476
2385
  }
2477
2386
 
2387
+ /** The `FieldErrorTemplate` component renders the errors local to the particular field
2388
+ *
2389
+ * @param props - The `FieldErrorProps` for the errors being rendered
2390
+ */
2391
+
2392
+ function FieldErrorTemplate(props) {
2393
+ const {
2394
+ errors = [],
2395
+ idSchema
2396
+ } = props;
2397
+
2398
+ if (errors.length === 0) {
2399
+ return null;
2400
+ }
2401
+
2402
+ const id = idSchema.$id + "__error";
2403
+ return /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement("ul", {
2404
+ id: id,
2405
+ className: "error-detail bs-callout bs-callout-info"
2406
+ }, errors.filter(elem => !!elem).map((error, index) => {
2407
+ return /*#__PURE__*/React__default["default"].createElement("li", {
2408
+ className: "text-danger",
2409
+ key: index
2410
+ }, error);
2411
+ })));
2412
+ }
2413
+
2414
+ /** The `FieldHelpTemplate` component renders any help desired for a field
2415
+ *
2416
+ * @param props - The `FieldHelpProps` to be rendered
2417
+ */
2418
+
2419
+ function FieldHelpTemplate(props) {
2420
+ const {
2421
+ idSchema,
2422
+ help
2423
+ } = props;
2424
+
2425
+ if (!help) {
2426
+ return null;
2427
+ }
2428
+
2429
+ const id = idSchema.$id + "__help";
2430
+
2431
+ if (typeof help === "string") {
2432
+ return /*#__PURE__*/React__default["default"].createElement("p", {
2433
+ id: id,
2434
+ className: "help-block"
2435
+ }, help);
2436
+ }
2437
+
2438
+ return /*#__PURE__*/React__default["default"].createElement("div", {
2439
+ id: id,
2440
+ className: "help-block"
2441
+ }, help);
2442
+ }
2443
+
2478
2444
  /** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
2479
2445
  * title and description if available. If the object is expandable, then an `AddButton` is also rendered after all
2480
2446
  * the properties.
@@ -2521,7 +2487,8 @@
2521
2487
  }), properties.map(prop => prop.content), utils.canExpand(schema, uiSchema, formData) && /*#__PURE__*/React__default["default"].createElement(AddButton, {
2522
2488
  className: "object-property-expand",
2523
2489
  onClick: onAddClick(schema),
2524
- disabled: disabled || readonly
2490
+ disabled: disabled || readonly,
2491
+ uiSchema: uiSchema
2525
2492
  }));
2526
2493
  }
2527
2494
 
@@ -2561,6 +2528,74 @@
2561
2528
  }, /*#__PURE__*/React__default["default"].createElement("p", null, "Unsupported field schema", idSchema && idSchema.$id && /*#__PURE__*/React__default["default"].createElement("span", null, " for", " field ", /*#__PURE__*/React__default["default"].createElement("code", null, idSchema.$id)), reason && /*#__PURE__*/React__default["default"].createElement("em", null, ": ", reason), "."), schema && /*#__PURE__*/React__default["default"].createElement("pre", null, JSON.stringify(schema, null, 2)));
2562
2529
  }
2563
2530
 
2531
+ /** The `WrapIfAdditional` component is used by the `FieldTemplate` to rename, or remove properties that are
2532
+ * part of an `additionalProperties` part of a schema.
2533
+ *
2534
+ * @param props - The `WrapIfAdditionalProps` for this component
2535
+ */
2536
+
2537
+ function WrapIfAdditionalTemplate(props) {
2538
+ const {
2539
+ id,
2540
+ classNames,
2541
+ disabled,
2542
+ label,
2543
+ onKeyChange,
2544
+ onDropPropertyClick,
2545
+ readonly,
2546
+ required,
2547
+ schema,
2548
+ children,
2549
+ uiSchema,
2550
+ registry
2551
+ } = props; // Button templates are not overridden in the uiSchema
2552
+
2553
+ const {
2554
+ RemoveButton
2555
+ } = registry.templates.ButtonTemplates;
2556
+ const keyLabel = label + " Key"; // i18n ?
2557
+
2558
+ const additional = (utils.ADDITIONAL_PROPERTY_FLAG in schema);
2559
+
2560
+ if (!additional) {
2561
+ return /*#__PURE__*/React__default["default"].createElement("div", {
2562
+ className: classNames
2563
+ }, children);
2564
+ }
2565
+
2566
+ return /*#__PURE__*/React__default["default"].createElement("div", {
2567
+ className: classNames
2568
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
2569
+ className: "row"
2570
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
2571
+ className: "col-xs-5 form-additional"
2572
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
2573
+ className: "form-group"
2574
+ }, /*#__PURE__*/React__default["default"].createElement(Label, {
2575
+ label: keyLabel,
2576
+ required: required,
2577
+ id: id + "-key"
2578
+ }), /*#__PURE__*/React__default["default"].createElement("input", {
2579
+ className: "form-control",
2580
+ type: "text",
2581
+ id: id + "-key",
2582
+ onBlur: event => onKeyChange(event.target.value),
2583
+ defaultValue: label
2584
+ }))), /*#__PURE__*/React__default["default"].createElement("div", {
2585
+ className: "form-additional form-group col-xs-5"
2586
+ }, children), /*#__PURE__*/React__default["default"].createElement("div", {
2587
+ className: "col-xs-2"
2588
+ }, /*#__PURE__*/React__default["default"].createElement(RemoveButton, {
2589
+ className: "array-item-remove btn-block",
2590
+ style: {
2591
+ border: "0"
2592
+ },
2593
+ disabled: disabled || readonly,
2594
+ onClick: onDropPropertyClick(label),
2595
+ uiSchema: uiSchema
2596
+ }))));
2597
+ }
2598
+
2564
2599
  const templates = {
2565
2600
  ArrayFieldDescriptionTemplate,
2566
2601
  ArrayFieldItemTemplate,
@@ -2571,9 +2606,12 @@
2571
2606
  DescriptionFieldTemplate: DescriptionField,
2572
2607
  ErrorListTemplate: ErrorList,
2573
2608
  FieldTemplate,
2609
+ FieldErrorTemplate,
2610
+ FieldHelpTemplate,
2574
2611
  ObjectFieldTemplate,
2575
2612
  TitleFieldTemplate: TitleField,
2576
- UnsupportedFieldTemplate: UnsupportedField
2613
+ UnsupportedFieldTemplate: UnsupportedField,
2614
+ WrapIfAdditionalTemplate
2577
2615
  };
2578
2616
 
2579
2617
  function rangeOptions(start, stop) {
@@ -2821,6 +2859,7 @@
2821
2859
  }), /*#__PURE__*/React__default["default"].createElement("label", null, /*#__PURE__*/React__default["default"].createElement("input", {
2822
2860
  type: "checkbox",
2823
2861
  id: id,
2862
+ name: id,
2824
2863
  checked: typeof value === "undefined" ? false : value,
2825
2864
  required: required,
2826
2865
  disabled: disabled || readonly,
@@ -2868,7 +2907,7 @@
2868
2907
  id: id
2869
2908
  }, Array.isArray(enumOptions) && enumOptions.map((option, index) => {
2870
2909
  const checked = value.indexOf(option.value) !== -1;
2871
- const itemDisabled = enumDisabled && enumDisabled.indexOf(option.value) != -1;
2910
+ const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) != -1;
2872
2911
  const disabledCls = disabled || itemDisabled || readonly ? "disabled" : "";
2873
2912
 
2874
2913
  const handleChange = event => {
@@ -2888,17 +2927,18 @@
2888
2927
 
2889
2928
  const checkbox = /*#__PURE__*/React__default["default"].createElement("span", null, /*#__PURE__*/React__default["default"].createElement("input", {
2890
2929
  type: "checkbox",
2891
- id: id + "_" + index,
2930
+ id: id + "-" + option.value,
2931
+ name: id,
2892
2932
  checked: checked,
2893
2933
  disabled: disabled || itemDisabled || readonly,
2894
2934
  autoFocus: autofocus && index === 0,
2895
2935
  onChange: handleChange
2896
2936
  }), /*#__PURE__*/React__default["default"].createElement("span", null, option.label));
2897
2937
  return inline ? /*#__PURE__*/React__default["default"].createElement("label", {
2898
- key: index,
2938
+ key: option.value,
2899
2939
  className: "checkbox-inline " + disabledCls
2900
2940
  }, checkbox) : /*#__PURE__*/React__default["default"].createElement("div", {
2901
- key: index,
2941
+ key: option.value,
2902
2942
  className: "checkbox " + disabledCls
2903
2943
  }, /*#__PURE__*/React__default["default"].createElement("label", null, checkbox));
2904
2944
  }));
@@ -3104,6 +3144,7 @@
3104
3144
  }, [multiple, onChange]);
3105
3145
  return /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement("p", null, /*#__PURE__*/React__default["default"].createElement("input", {
3106
3146
  id: id,
3147
+ name: id,
3107
3148
  type: "file",
3108
3149
  disabled: readonly || disabled,
3109
3150
  onChange: handleChange,
@@ -3130,6 +3171,7 @@
3130
3171
  return /*#__PURE__*/React__default["default"].createElement("input", {
3131
3172
  type: "hidden",
3132
3173
  id: id,
3174
+ name: id,
3133
3175
  value: typeof value === "undefined" ? "" : value
3134
3176
  });
3135
3177
  }
@@ -3186,14 +3228,14 @@
3186
3228
  id: id
3187
3229
  }, Array.isArray(enumOptions) && enumOptions.map((option, i) => {
3188
3230
  const checked = option.value === value;
3189
- const itemDisabled = enumDisabled && enumDisabled.indexOf(option.value) != -1;
3231
+ const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) != -1;
3190
3232
  const disabledCls = disabled || itemDisabled || readonly ? "disabled" : "";
3191
3233
 
3192
3234
  const handleChange = () => onChange(option.value);
3193
3235
 
3194
3236
  const radio = /*#__PURE__*/React__default["default"].createElement("span", null, /*#__PURE__*/React__default["default"].createElement("input", {
3195
3237
  type: "radio",
3196
- id: id + "_" + i,
3238
+ id: id + "-" + option.value,
3197
3239
  checked: checked,
3198
3240
  name: name,
3199
3241
  required: required,
@@ -3205,10 +3247,10 @@
3205
3247
  onFocus: handleFocus
3206
3248
  }), /*#__PURE__*/React__default["default"].createElement("span", null, option.label));
3207
3249
  return inline ? /*#__PURE__*/React__default["default"].createElement("label", {
3208
- key: i,
3250
+ key: option.value,
3209
3251
  className: "radio-inline " + disabledCls
3210
3252
  }, radio) : /*#__PURE__*/React__default["default"].createElement("div", {
3211
- key: i,
3253
+ key: option.value,
3212
3254
  className: "radio " + disabledCls
3213
3255
  }, /*#__PURE__*/React__default["default"].createElement("label", null, radio));
3214
3256
  }));
@@ -3288,6 +3330,7 @@
3288
3330
  }, [onChange, schema, multiple, options]);
3289
3331
  return /*#__PURE__*/React__default["default"].createElement("select", {
3290
3332
  id: id,
3333
+ name: id,
3291
3334
  multiple: multiple,
3292
3335
  className: "form-control",
3293
3336
  value: typeof value === "undefined" ? emptyValue : value,
@@ -3358,6 +3401,7 @@
3358
3401
  }, [id, onFocus]);
3359
3402
  return /*#__PURE__*/React__default["default"].createElement("textarea", {
3360
3403
  id: id,
3404
+ name: id,
3361
3405
  className: "form-control",
3362
3406
  value: value ? value : "",
3363
3407
  placeholder: placeholder,
@@ -3570,7 +3614,7 @@
3570
3614
  }
3571
3615
 
3572
3616
  if (mustValidate) {
3573
- const schemaValidation = this.validate(schemaUtils, newFormData);
3617
+ const schemaValidation = this.validate(newFormData);
3574
3618
  let errors = schemaValidation.errors;
3575
3619
  let errorSchema = schemaValidation.errorSchema;
3576
3620
  const schemaValidationErrors = errors;
@@ -3635,8 +3679,7 @@
3635
3679
  omitExtraData,
3636
3680
  extraErrors,
3637
3681
  noValidate,
3638
- onSubmit,
3639
- onError
3682
+ onSubmit
3640
3683
  } = this.props;
3641
3684
  let {
3642
3685
  formData: newFormData
@@ -3653,56 +3696,32 @@
3653
3696
  newFormData = this.getUsedFormData(newFormData, fieldNames);
3654
3697
  }
3655
3698
 
3656
- if (!noValidate) {
3657
- const schemaValidation = this.validate(schemaUtils, newFormData);
3658
- let errors = schemaValidation.errors;
3659
- let errorSchema = schemaValidation.errorSchema;
3660
- const schemaValidationErrors = errors;
3661
- const schemaValidationErrorSchema = errorSchema;
3662
-
3663
- if (errors.length > 0) {
3664
- if (extraErrors) {
3665
- const merged = schemaUtils.mergeValidationData(schemaValidation, extraErrors);
3666
- errorSchema = merged.errorSchema;
3667
- errors = merged.errors;
3699
+ if (noValidate || this.validateForm()) {
3700
+ // There are no errors generated through schema validation.
3701
+ // Check for user provided errors and update state accordingly.
3702
+ const errorSchema = extraErrors || {};
3703
+ const errors = extraErrors ? schemaUtils.getValidator().toErrorList(extraErrors) : [];
3704
+ this.setState({
3705
+ formData: newFormData,
3706
+ errors,
3707
+ errorSchema,
3708
+ schemaValidationErrors: [],
3709
+ schemaValidationErrorSchema: {}
3710
+ }, () => {
3711
+ if (onSubmit) {
3712
+ onSubmit({ ...this.state,
3713
+ formData: newFormData,
3714
+ status: "submitted"
3715
+ }, event);
3668
3716
  }
3669
-
3670
- this.setState({
3671
- errors,
3672
- errorSchema,
3673
- schemaValidationErrors,
3674
- schemaValidationErrorSchema
3675
- }, () => {
3676
- if (onError) {
3677
- onError(errors);
3678
- } else {
3679
- console.error("Form validation failed", errors);
3680
- }
3681
- });
3682
- return;
3683
- }
3684
- } // There are no errors generated through schema validation.
3685
- // Check for user provided errors and update state accordingly.
3686
-
3687
-
3688
- const errorSchema = extraErrors || {};
3689
- const errors = extraErrors ? schemaUtils.getValidator().toErrorList(extraErrors) : [];
3690
- this.setState({
3691
- formData: newFormData,
3692
- errors,
3693
- errorSchema,
3694
- schemaValidationErrors: [],
3695
- schemaValidationErrorSchema: {}
3696
- }, () => {
3697
- if (onSubmit) {
3698
- onSubmit({ ...this.state,
3699
- formData: newFormData,
3700
- status: "submitted"
3701
- }, event);
3702
- }
3703
- });
3717
+ });
3718
+ }
3704
3719
  };
3705
3720
 
3721
+ if (!props.validator) {
3722
+ throw new Error("A validator is required for Form functionality to work");
3723
+ }
3724
+
3706
3725
  this.state = this.getStateFromProps(props, props.formData);
3707
3726
 
3708
3727
  if (this.props.onChange && !utils.deepEquals(this.state.formData, this.props.formData)) {
@@ -3780,7 +3799,7 @@
3780
3799
  let schemaValidationErrorSchema = state.schemaValidationErrorSchema;
3781
3800
 
3782
3801
  if (mustValidate) {
3783
- const schemaValidation = this.validate(schemaUtils, formData, schema);
3802
+ const schemaValidation = this.validate(formData, schema, schemaUtils);
3784
3803
  errors = schemaValidation.errors;
3785
3804
  errorSchema = schemaValidation.errorSchema;
3786
3805
  schemaValidationErrors = errors;
@@ -3826,19 +3845,21 @@
3826
3845
  shouldComponentUpdate(nextProps, nextState) {
3827
3846
  return utils.shouldRender(this, nextProps, nextState);
3828
3847
  }
3829
- /** Validates the `formData` against the `schema` using the `schemaUtils`, returning the results.
3848
+ /** Validates the `formData` against the `schema` using the `altSchemaUtils` (if provided otherwise it uses the
3849
+ * `schemaUtils` in the state), returning the results.
3830
3850
  *
3831
- * @param schemaUtils - The schemaUtils to use for validation
3832
3851
  * @param formData - The new form data to validate
3833
3852
  * @param schema - The schema used to validate against
3853
+ * @param altSchemaUtils - The alternate schemaUtils to use for validation
3834
3854
  */
3835
3855
 
3836
3856
 
3837
- validate(schemaUtils, formData, schema) {
3857
+ validate(formData, schema, altSchemaUtils) {
3838
3858
  if (schema === void 0) {
3839
3859
  schema = this.props.schema;
3840
3860
  }
3841
3861
 
3862
+ const schemaUtils = altSchemaUtils ? altSchemaUtils : this.state.schemaUtils;
3842
3863
  const {
3843
3864
  customValidate,
3844
3865
  transformErrors
@@ -3921,8 +3942,57 @@
3921
3942
  this.formElement.current.dispatchEvent(new CustomEvent("submit", {
3922
3943
  cancelable: true
3923
3944
  }));
3945
+ this.formElement.current.requestSubmit();
3924
3946
  }
3925
3947
  }
3948
+ /** Programmatically validate the form. If `onError` is provided, then it will be called with the list of errors the
3949
+ * same way as would happen on form submission.
3950
+ *
3951
+ * @returns - True if the form is valid, false otherwise.
3952
+ */
3953
+
3954
+
3955
+ validateForm() {
3956
+ const {
3957
+ extraErrors,
3958
+ onError
3959
+ } = this.props;
3960
+ const {
3961
+ formData
3962
+ } = this.state;
3963
+ const {
3964
+ schemaUtils
3965
+ } = this.state;
3966
+ const schemaValidation = this.validate(formData);
3967
+ let errors = schemaValidation.errors;
3968
+ let errorSchema = schemaValidation.errorSchema;
3969
+ const schemaValidationErrors = errors;
3970
+ const schemaValidationErrorSchema = errorSchema;
3971
+
3972
+ if (errors.length > 0) {
3973
+ if (extraErrors) {
3974
+ const merged = schemaUtils.mergeValidationData(schemaValidation, extraErrors);
3975
+ errorSchema = merged.errorSchema;
3976
+ errors = merged.errors;
3977
+ }
3978
+
3979
+ this.setState({
3980
+ errors,
3981
+ errorSchema,
3982
+ schemaValidationErrors,
3983
+ schemaValidationErrorSchema
3984
+ }, () => {
3985
+ if (onError) {
3986
+ onError(errors);
3987
+ } else {
3988
+ console.error("Form validation failed", errors);
3989
+ }
3990
+ });
3991
+ return false;
3992
+ }
3993
+
3994
+ return true;
3995
+ }
3926
3996
  /** Renders the `Form` fields inside the <form> | `tagName` or `_internalFormWrapper`, rendering any errors if
3927
3997
  * needed along with the submit button or any children of the form.
3928
3998
  */