@rjsf/core 5.0.0-beta.6 → 5.0.0-beta.8

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.
@@ -784,7 +784,7 @@ class ArrayField extends React.Component {
784
784
  } = this.props;
785
785
  const {
786
786
  fields: {
787
- SchemaField
787
+ ArraySchemaField
788
788
  }
789
789
  } = registry;
790
790
  const {
@@ -799,7 +799,7 @@ class ArrayField extends React.Component {
799
799
  };
800
800
  has.toolbar = Object.keys(has).some(key => has[key]);
801
801
  return {
802
- children: /*#__PURE__*/React__default["default"].createElement(SchemaField, {
802
+ children: /*#__PURE__*/React__default["default"].createElement(ArraySchemaField, {
803
803
  name: name,
804
804
  index: index,
805
805
  schema: itemSchema,
@@ -1595,58 +1595,6 @@ function getFieldComponent(schema, uiOptions, idSchema, registry) {
1595
1595
  });
1596
1596
  };
1597
1597
  }
1598
- /** The `Help` component renders any help desired for a field
1599
- *
1600
- * @param props - The id and help information to be rendered
1601
- */
1602
-
1603
-
1604
- function Help(props) {
1605
- const {
1606
- id,
1607
- help
1608
- } = props;
1609
-
1610
- if (!help) {
1611
- return null;
1612
- }
1613
-
1614
- if (typeof help === "string") {
1615
- return /*#__PURE__*/React__default["default"].createElement("p", {
1616
- id: id,
1617
- className: "help-block"
1618
- }, help);
1619
- }
1620
-
1621
- return /*#__PURE__*/React__default["default"].createElement("div", {
1622
- id: id,
1623
- className: "help-block"
1624
- }, help);
1625
- }
1626
- /** The `ErrorList` component renders the errors local to the particular field
1627
- *
1628
- * @param props - The list of errors to show
1629
- */
1630
-
1631
-
1632
- function ErrorList$1(props) {
1633
- const {
1634
- errors = []
1635
- } = props;
1636
-
1637
- if (errors.length === 0) {
1638
- return null;
1639
- }
1640
-
1641
- return /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement("ul", {
1642
- className: "error-detail bs-callout bs-callout-info"
1643
- }, errors.filter(elem => !!elem).map((error, index) => {
1644
- return /*#__PURE__*/React__default["default"].createElement("li", {
1645
- className: "text-danger",
1646
- key: index
1647
- }, error);
1648
- })));
1649
- }
1650
1598
  /** The `SchemaFieldRender` component is the work-horse of react-jsonschema-form, determining what kind of real field to
1651
1599
  * render based on the `schema`, `uiSchema` and all the other props. It also deals with rendering the `anyOf` and
1652
1600
  * `oneOf` fields.
@@ -1679,6 +1627,8 @@ function SchemaFieldRender(props) {
1679
1627
  const uiOptions = utils.getUiOptions(uiSchema);
1680
1628
  const FieldTemplate = utils.getTemplate("FieldTemplate", registry, uiOptions);
1681
1629
  const DescriptionFieldTemplate = utils.getTemplate("DescriptionFieldTemplate", registry, uiOptions);
1630
+ const FieldHelpTemplate = utils.getTemplate("FieldHelpTemplate", registry, uiOptions);
1631
+ const FieldErrorTemplate = utils.getTemplate("FieldErrorTemplate", registry, uiOptions);
1682
1632
  const schema = schemaUtils.retrieveSchema(_schema, formData);
1683
1633
  const idSchema = utils.mergeObjects(schemaUtils.toIdSchema(schema, _idSchema.$id, formData, idPrefix, idSeparator), _idSchema);
1684
1634
  const FieldComponent = getFieldComponent(schema, uiOptions, idSchema, registry);
@@ -1724,16 +1674,15 @@ function SchemaFieldRender(props) {
1724
1674
  if (wasPropertyKeyModified) {
1725
1675
  label = name;
1726
1676
  } else {
1727
- label = uiOptions.title || props.schema.title || schema.title || name;
1677
+ label = utils.ADDITIONAL_PROPERTY_FLAG in schema ? name : uiOptions.title || props.schema.title || schema.title || name;
1728
1678
  }
1729
1679
 
1730
1680
  const description = uiOptions.description || props.schema.description || schema.description || "";
1731
- const errors = __errors;
1732
1681
  const help = uiOptions.help;
1733
1682
  const hidden = uiOptions.widget === "hidden";
1734
1683
  const classNames = ["form-group", "field", "field-" + schema.type];
1735
1684
 
1736
- if (!hideError && errors && errors.length > 0) {
1685
+ if (!hideError && __errors && __errors.length > 0) {
1737
1686
  classNames.push("field-error has-error has-danger");
1738
1687
  }
1739
1688
 
@@ -1749,6 +1698,22 @@ function SchemaFieldRender(props) {
1749
1698
  classNames.push(uiOptions.classNames);
1750
1699
  }
1751
1700
 
1701
+ const helpComponent = /*#__PURE__*/React__default["default"].createElement(FieldHelpTemplate, {
1702
+ help: help,
1703
+ idSchema: idSchema,
1704
+ schema: schema,
1705
+ uiSchema: uiSchema,
1706
+ hasErrors: !hideError && __errors && __errors.length > 0,
1707
+ registry: registry
1708
+ });
1709
+ const errorsComponent = hideError ? undefined : /*#__PURE__*/React__default["default"].createElement(FieldErrorTemplate, {
1710
+ errors: __errors,
1711
+ errorSchema: errorSchema,
1712
+ idSchema: idSchema,
1713
+ schema: schema,
1714
+ uiSchema: uiSchema,
1715
+ registry: registry
1716
+ });
1752
1717
  const fieldProps = {
1753
1718
  description: /*#__PURE__*/React__default["default"].createElement(DescriptionFieldTemplate, {
1754
1719
  id: id + "__description",
@@ -1756,15 +1721,10 @@ function SchemaFieldRender(props) {
1756
1721
  registry: registry
1757
1722
  }),
1758
1723
  rawDescription: description,
1759
- help: /*#__PURE__*/React__default["default"].createElement(Help, {
1760
- id: id + "__help",
1761
- help: help
1762
- }),
1724
+ help: helpComponent,
1763
1725
  rawHelp: typeof help === "string" ? help : undefined,
1764
- errors: hideError ? undefined : /*#__PURE__*/React__default["default"].createElement(ErrorList$1, {
1765
- errors: errors
1766
- }),
1767
- rawErrors: hideError ? undefined : errors,
1726
+ errors: errorsComponent,
1727
+ rawErrors: hideError ? undefined : __errors,
1768
1728
  id,
1769
1729
  label,
1770
1730
  hidden,
@@ -1932,6 +1892,7 @@ function NullField(props) {
1932
1892
  const fields = {
1933
1893
  AnyOfField: AnyOfField,
1934
1894
  ArrayField,
1895
+ ArraySchemaField: SchemaField,
1935
1896
  BooleanField,
1936
1897
  NumberField,
1937
1898
  ObjectField,
@@ -2485,6 +2446,63 @@ function FieldTemplate(props) {
2485
2446
  }), displayLabel && description ? description : null, children, errors, help);
2486
2447
  }
2487
2448
 
2449
+ /** The `FieldErrorTemplate` component renders the errors local to the particular field
2450
+ *
2451
+ * @param props - The `FieldErrorProps` for the errors being rendered
2452
+ */
2453
+
2454
+ function FieldErrorTemplate(props) {
2455
+ const {
2456
+ errors = [],
2457
+ idSchema
2458
+ } = props;
2459
+
2460
+ if (errors.length === 0) {
2461
+ return null;
2462
+ }
2463
+
2464
+ const id = idSchema.$id + "__error";
2465
+ return /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement("ul", {
2466
+ id: id,
2467
+ className: "error-detail bs-callout bs-callout-info"
2468
+ }, errors.filter(elem => !!elem).map((error, index) => {
2469
+ return /*#__PURE__*/React__default["default"].createElement("li", {
2470
+ className: "text-danger",
2471
+ key: index
2472
+ }, error);
2473
+ })));
2474
+ }
2475
+
2476
+ /** The `FieldHelpTemplate` component renders any help desired for a field
2477
+ *
2478
+ * @param props - The `FieldHelpProps` to be rendered
2479
+ */
2480
+
2481
+ function FieldHelpTemplate(props) {
2482
+ const {
2483
+ idSchema,
2484
+ help
2485
+ } = props;
2486
+
2487
+ if (!help) {
2488
+ return null;
2489
+ }
2490
+
2491
+ const id = idSchema.$id + "__help";
2492
+
2493
+ if (typeof help === "string") {
2494
+ return /*#__PURE__*/React__default["default"].createElement("p", {
2495
+ id: id,
2496
+ className: "help-block"
2497
+ }, help);
2498
+ }
2499
+
2500
+ return /*#__PURE__*/React__default["default"].createElement("div", {
2501
+ id: id,
2502
+ className: "help-block"
2503
+ }, help);
2504
+ }
2505
+
2488
2506
  /** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
2489
2507
  * title and description if available. If the object is expandable, then an `AddButton` is also rendered after all
2490
2508
  * the properties.
@@ -2581,6 +2599,8 @@ const templates = {
2581
2599
  DescriptionFieldTemplate: DescriptionField,
2582
2600
  ErrorListTemplate: ErrorList,
2583
2601
  FieldTemplate,
2602
+ FieldErrorTemplate,
2603
+ FieldHelpTemplate,
2584
2604
  ObjectFieldTemplate,
2585
2605
  TitleFieldTemplate: TitleField,
2586
2606
  UnsupportedFieldTemplate: UnsupportedField