@rjsf/core 5.0.0-beta.5 → 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.
- package/dist/core.cjs.development.js +85 -65
- 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 +85 -65
- package/dist/core.esm.js.map +1 -1
- package/dist/core.umd.development.js +85 -65
- 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/package.json +7 -6
package/dist/core.esm.js
CHANGED
|
@@ -768,7 +768,7 @@ class ArrayField extends Component {
|
|
|
768
768
|
} = this.props;
|
|
769
769
|
const {
|
|
770
770
|
fields: {
|
|
771
|
-
|
|
771
|
+
ArraySchemaField
|
|
772
772
|
}
|
|
773
773
|
} = registry;
|
|
774
774
|
const {
|
|
@@ -783,7 +783,7 @@ class ArrayField extends Component {
|
|
|
783
783
|
};
|
|
784
784
|
has.toolbar = Object.keys(has).some(key => has[key]);
|
|
785
785
|
return {
|
|
786
|
-
children: /*#__PURE__*/React.createElement(
|
|
786
|
+
children: /*#__PURE__*/React.createElement(ArraySchemaField, {
|
|
787
787
|
name: name,
|
|
788
788
|
index: index,
|
|
789
789
|
schema: itemSchema,
|
|
@@ -1579,58 +1579,6 @@ function getFieldComponent(schema, uiOptions, idSchema, registry) {
|
|
|
1579
1579
|
});
|
|
1580
1580
|
};
|
|
1581
1581
|
}
|
|
1582
|
-
/** The `Help` component renders any help desired for a field
|
|
1583
|
-
*
|
|
1584
|
-
* @param props - The id and help information to be rendered
|
|
1585
|
-
*/
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
function Help(props) {
|
|
1589
|
-
const {
|
|
1590
|
-
id,
|
|
1591
|
-
help
|
|
1592
|
-
} = props;
|
|
1593
|
-
|
|
1594
|
-
if (!help) {
|
|
1595
|
-
return null;
|
|
1596
|
-
}
|
|
1597
|
-
|
|
1598
|
-
if (typeof help === "string") {
|
|
1599
|
-
return /*#__PURE__*/React.createElement("p", {
|
|
1600
|
-
id: id,
|
|
1601
|
-
className: "help-block"
|
|
1602
|
-
}, help);
|
|
1603
|
-
}
|
|
1604
|
-
|
|
1605
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
1606
|
-
id: id,
|
|
1607
|
-
className: "help-block"
|
|
1608
|
-
}, help);
|
|
1609
|
-
}
|
|
1610
|
-
/** The `ErrorList` component renders the errors local to the particular field
|
|
1611
|
-
*
|
|
1612
|
-
* @param props - The list of errors to show
|
|
1613
|
-
*/
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
function ErrorList$1(props) {
|
|
1617
|
-
const {
|
|
1618
|
-
errors = []
|
|
1619
|
-
} = props;
|
|
1620
|
-
|
|
1621
|
-
if (errors.length === 0) {
|
|
1622
|
-
return null;
|
|
1623
|
-
}
|
|
1624
|
-
|
|
1625
|
-
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("ul", {
|
|
1626
|
-
className: "error-detail bs-callout bs-callout-info"
|
|
1627
|
-
}, errors.filter(elem => !!elem).map((error, index) => {
|
|
1628
|
-
return /*#__PURE__*/React.createElement("li", {
|
|
1629
|
-
className: "text-danger",
|
|
1630
|
-
key: index
|
|
1631
|
-
}, error);
|
|
1632
|
-
})));
|
|
1633
|
-
}
|
|
1634
1582
|
/** The `SchemaFieldRender` component is the work-horse of react-jsonschema-form, determining what kind of real field to
|
|
1635
1583
|
* render based on the `schema`, `uiSchema` and all the other props. It also deals with rendering the `anyOf` and
|
|
1636
1584
|
* `oneOf` fields.
|
|
@@ -1663,6 +1611,8 @@ function SchemaFieldRender(props) {
|
|
|
1663
1611
|
const uiOptions = getUiOptions(uiSchema);
|
|
1664
1612
|
const FieldTemplate = getTemplate("FieldTemplate", registry, uiOptions);
|
|
1665
1613
|
const DescriptionFieldTemplate = getTemplate("DescriptionFieldTemplate", registry, uiOptions);
|
|
1614
|
+
const FieldHelpTemplate = getTemplate("FieldHelpTemplate", registry, uiOptions);
|
|
1615
|
+
const FieldErrorTemplate = getTemplate("FieldErrorTemplate", registry, uiOptions);
|
|
1666
1616
|
const schema = schemaUtils.retrieveSchema(_schema, formData);
|
|
1667
1617
|
const idSchema = mergeObjects(schemaUtils.toIdSchema(schema, _idSchema.$id, formData, idPrefix, idSeparator), _idSchema);
|
|
1668
1618
|
const FieldComponent = getFieldComponent(schema, uiOptions, idSchema, registry);
|
|
@@ -1708,16 +1658,15 @@ function SchemaFieldRender(props) {
|
|
|
1708
1658
|
if (wasPropertyKeyModified) {
|
|
1709
1659
|
label = name;
|
|
1710
1660
|
} else {
|
|
1711
|
-
label = uiOptions.title || props.schema.title || schema.title || name;
|
|
1661
|
+
label = ADDITIONAL_PROPERTY_FLAG in schema ? name : uiOptions.title || props.schema.title || schema.title || name;
|
|
1712
1662
|
}
|
|
1713
1663
|
|
|
1714
1664
|
const description = uiOptions.description || props.schema.description || schema.description || "";
|
|
1715
|
-
const errors = __errors;
|
|
1716
1665
|
const help = uiOptions.help;
|
|
1717
1666
|
const hidden = uiOptions.widget === "hidden";
|
|
1718
1667
|
const classNames = ["form-group", "field", "field-" + schema.type];
|
|
1719
1668
|
|
|
1720
|
-
if (!hideError &&
|
|
1669
|
+
if (!hideError && __errors && __errors.length > 0) {
|
|
1721
1670
|
classNames.push("field-error has-error has-danger");
|
|
1722
1671
|
}
|
|
1723
1672
|
|
|
@@ -1733,6 +1682,22 @@ function SchemaFieldRender(props) {
|
|
|
1733
1682
|
classNames.push(uiOptions.classNames);
|
|
1734
1683
|
}
|
|
1735
1684
|
|
|
1685
|
+
const helpComponent = /*#__PURE__*/React.createElement(FieldHelpTemplate, {
|
|
1686
|
+
help: help,
|
|
1687
|
+
idSchema: idSchema,
|
|
1688
|
+
schema: schema,
|
|
1689
|
+
uiSchema: uiSchema,
|
|
1690
|
+
hasErrors: !hideError && __errors && __errors.length > 0,
|
|
1691
|
+
registry: registry
|
|
1692
|
+
});
|
|
1693
|
+
const errorsComponent = hideError ? undefined : /*#__PURE__*/React.createElement(FieldErrorTemplate, {
|
|
1694
|
+
errors: __errors,
|
|
1695
|
+
errorSchema: errorSchema,
|
|
1696
|
+
idSchema: idSchema,
|
|
1697
|
+
schema: schema,
|
|
1698
|
+
uiSchema: uiSchema,
|
|
1699
|
+
registry: registry
|
|
1700
|
+
});
|
|
1736
1701
|
const fieldProps = {
|
|
1737
1702
|
description: /*#__PURE__*/React.createElement(DescriptionFieldTemplate, {
|
|
1738
1703
|
id: id + "__description",
|
|
@@ -1740,15 +1705,10 @@ function SchemaFieldRender(props) {
|
|
|
1740
1705
|
registry: registry
|
|
1741
1706
|
}),
|
|
1742
1707
|
rawDescription: description,
|
|
1743
|
-
help:
|
|
1744
|
-
id: id + "__help",
|
|
1745
|
-
help: help
|
|
1746
|
-
}),
|
|
1708
|
+
help: helpComponent,
|
|
1747
1709
|
rawHelp: typeof help === "string" ? help : undefined,
|
|
1748
|
-
errors:
|
|
1749
|
-
|
|
1750
|
-
}),
|
|
1751
|
-
rawErrors: hideError ? undefined : errors,
|
|
1710
|
+
errors: errorsComponent,
|
|
1711
|
+
rawErrors: hideError ? undefined : __errors,
|
|
1752
1712
|
id,
|
|
1753
1713
|
label,
|
|
1754
1714
|
hidden,
|
|
@@ -1916,6 +1876,7 @@ function NullField(props) {
|
|
|
1916
1876
|
const fields = {
|
|
1917
1877
|
AnyOfField: AnyOfField,
|
|
1918
1878
|
ArrayField,
|
|
1879
|
+
ArraySchemaField: SchemaField,
|
|
1919
1880
|
BooleanField,
|
|
1920
1881
|
NumberField,
|
|
1921
1882
|
ObjectField,
|
|
@@ -2469,6 +2430,63 @@ function FieldTemplate(props) {
|
|
|
2469
2430
|
}), displayLabel && description ? description : null, children, errors, help);
|
|
2470
2431
|
}
|
|
2471
2432
|
|
|
2433
|
+
/** The `FieldErrorTemplate` component renders the errors local to the particular field
|
|
2434
|
+
*
|
|
2435
|
+
* @param props - The `FieldErrorProps` for the errors being rendered
|
|
2436
|
+
*/
|
|
2437
|
+
|
|
2438
|
+
function FieldErrorTemplate(props) {
|
|
2439
|
+
const {
|
|
2440
|
+
errors = [],
|
|
2441
|
+
idSchema
|
|
2442
|
+
} = props;
|
|
2443
|
+
|
|
2444
|
+
if (errors.length === 0) {
|
|
2445
|
+
return null;
|
|
2446
|
+
}
|
|
2447
|
+
|
|
2448
|
+
const id = idSchema.$id + "__error";
|
|
2449
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("ul", {
|
|
2450
|
+
id: id,
|
|
2451
|
+
className: "error-detail bs-callout bs-callout-info"
|
|
2452
|
+
}, errors.filter(elem => !!elem).map((error, index) => {
|
|
2453
|
+
return /*#__PURE__*/React.createElement("li", {
|
|
2454
|
+
className: "text-danger",
|
|
2455
|
+
key: index
|
|
2456
|
+
}, error);
|
|
2457
|
+
})));
|
|
2458
|
+
}
|
|
2459
|
+
|
|
2460
|
+
/** The `FieldHelpTemplate` component renders any help desired for a field
|
|
2461
|
+
*
|
|
2462
|
+
* @param props - The `FieldHelpProps` to be rendered
|
|
2463
|
+
*/
|
|
2464
|
+
|
|
2465
|
+
function FieldHelpTemplate(props) {
|
|
2466
|
+
const {
|
|
2467
|
+
idSchema,
|
|
2468
|
+
help
|
|
2469
|
+
} = props;
|
|
2470
|
+
|
|
2471
|
+
if (!help) {
|
|
2472
|
+
return null;
|
|
2473
|
+
}
|
|
2474
|
+
|
|
2475
|
+
const id = idSchema.$id + "__help";
|
|
2476
|
+
|
|
2477
|
+
if (typeof help === "string") {
|
|
2478
|
+
return /*#__PURE__*/React.createElement("p", {
|
|
2479
|
+
id: id,
|
|
2480
|
+
className: "help-block"
|
|
2481
|
+
}, help);
|
|
2482
|
+
}
|
|
2483
|
+
|
|
2484
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
2485
|
+
id: id,
|
|
2486
|
+
className: "help-block"
|
|
2487
|
+
}, help);
|
|
2488
|
+
}
|
|
2489
|
+
|
|
2472
2490
|
/** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
|
|
2473
2491
|
* title and description if available. If the object is expandable, then an `AddButton` is also rendered after all
|
|
2474
2492
|
* the properties.
|
|
@@ -2565,6 +2583,8 @@ const templates = {
|
|
|
2565
2583
|
DescriptionFieldTemplate: DescriptionField,
|
|
2566
2584
|
ErrorListTemplate: ErrorList,
|
|
2567
2585
|
FieldTemplate,
|
|
2586
|
+
FieldErrorTemplate,
|
|
2587
|
+
FieldHelpTemplate,
|
|
2568
2588
|
ObjectFieldTemplate,
|
|
2569
2589
|
TitleFieldTemplate: TitleField,
|
|
2570
2590
|
UnsupportedFieldTemplate: UnsupportedField
|