@rjsf/utils 5.0.0-beta.5 → 5.0.0-beta.6
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/README.md +11 -9
- package/dist/utils.cjs.development.js +5 -5
- package/dist/utils.cjs.development.js.map +1 -1
- package/dist/utils.cjs.production.min.js +1 -1
- package/dist/utils.cjs.production.min.js.map +1 -1
- package/dist/utils.esm.js +4 -4
- package/dist/utils.esm.js.map +1 -1
- package/dist/utils.umd.development.js +8 -8
- package/dist/utils.umd.development.js.map +1 -1
- package/dist/utils.umd.production.min.js +1 -1
- package/dist/utils.umd.production.min.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
<br />
|
|
9
9
|
<p align="center">
|
|
10
10
|
<a href="https://github.com/rjsf-team/react-jsonschema-form">
|
|
11
|
-
<img src="https://raw.githubusercontent.com/rjsf-team/react-jsonschema-form/
|
|
11
|
+
<img src="https://raw.githubusercontent.com/rjsf-team/react-jsonschema-form/7ebc86621d8df8c21f0c39bcca6d476f6f7a2051/packages/utils/logo.png" alt="Logo" width="120" height="120">
|
|
12
12
|
</a>
|
|
13
13
|
|
|
14
14
|
<h3 align="center">@rjsf/utils</h3>
|
|
15
15
|
|
|
16
16
|
<p align="center">
|
|
17
|
-
|
|
17
|
+
Utility functions for <a href="https://github.com/rjsf-team/react-jsonschema-form/"><code>react-jsonschema-form</code></a>.
|
|
18
18
|
<br />
|
|
19
19
|
<a href="https://react-jsonschema-form.readthedocs.io/en/stable/"><strong>Explore the docs »</strong></a>
|
|
20
20
|
<br />
|
|
@@ -46,12 +46,11 @@
|
|
|
46
46
|
|
|
47
47
|
## About The Project
|
|
48
48
|
|
|
49
|
-
Exports `utils`
|
|
49
|
+
Exports `utils` functions for `react-jsonschema-form`.
|
|
50
50
|
|
|
51
51
|
### Built With
|
|
52
52
|
|
|
53
53
|
- [react-jsonschema-form](https://github.com/rjsf-team/react-jsonschema-form/)
|
|
54
|
-
- [AJV](https://github.com/ajv-validator/ajv/)
|
|
55
54
|
- [TypeScript](https://www.typescriptlang.org/)
|
|
56
55
|
|
|
57
56
|
<!-- GETTING STARTED -->
|
|
@@ -72,6 +71,10 @@ yarn add @rjsf/utils
|
|
|
72
71
|
import * as Utils from '@rjsf/utils';
|
|
73
72
|
```
|
|
74
73
|
|
|
74
|
+
## Documentation
|
|
75
|
+
|
|
76
|
+
[Utility function documentation](https://react-jsonschema-form.readthedocs.io/en/stable/api-reference/utility-functions/)
|
|
77
|
+
|
|
75
78
|
<!-- ROADMAP -->
|
|
76
79
|
|
|
77
80
|
## Roadmap
|
|
@@ -101,8 +104,7 @@ GitHub repository: [https://github.com/rjsf-team/react-jsonschema-form](https://
|
|
|
101
104
|
[contributors-url]: https://github.com/rjsf-team/react-jsonschema-form/graphs/contributors
|
|
102
105
|
[license-shield]: https://img.shields.io/badge/license-Apache%202.0-blue.svg?style=flat-square
|
|
103
106
|
[license-url]: https://choosealicense.com/licenses/apache-2.0/
|
|
104
|
-
[npm-shield]: https://img.shields.io/npm/v/@rjsf/
|
|
105
|
-
[npm-url]: https://www.npmjs.com/package/@rjsf/
|
|
106
|
-
[npm-dl-shield]: https://img.shields.io/npm/dm/@rjsf/
|
|
107
|
-
[npm-dl-url]: https://www.npmjs.com/package/@rjsf/
|
|
108
|
-
[product-screenshot]: https://raw.githubusercontent.com/rjsf-team/react-jsonschema-form/e2e1181d1020f18cad0c80c661ddae28edb9794e/packages/material-ui/screenshot5.png
|
|
107
|
+
[npm-shield]: https://img.shields.io/npm/v/@rjsf/utils/latest.svg?style=flat-square
|
|
108
|
+
[npm-url]: https://www.npmjs.com/package/@rjsf/utils
|
|
109
|
+
[npm-dl-shield]: https://img.shields.io/npm/dm/@rjsf/utils.svg?style=flat-square
|
|
110
|
+
[npm-dl-url]: https://www.npmjs.com/package/@rjsf/utils
|
|
@@ -4,12 +4,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var isEqualWith = require('lodash/isEqualWith');
|
|
6
6
|
var get = require('lodash/get');
|
|
7
|
+
var isEmpty = require('lodash/isEmpty');
|
|
7
8
|
var jsonpointer = require('jsonpointer');
|
|
8
9
|
var omit = require('lodash/omit');
|
|
9
10
|
var set = require('lodash/set');
|
|
10
11
|
var mergeAllOf = require('json-schema-merge-allof');
|
|
11
12
|
var union = require('lodash/union');
|
|
12
|
-
var isEmpty = require('lodash/isEmpty');
|
|
13
13
|
var React = require('react');
|
|
14
14
|
var ReactIs = require('react-is');
|
|
15
15
|
|
|
@@ -17,12 +17,12 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
17
17
|
|
|
18
18
|
var isEqualWith__default = /*#__PURE__*/_interopDefaultLegacy(isEqualWith);
|
|
19
19
|
var get__default = /*#__PURE__*/_interopDefaultLegacy(get);
|
|
20
|
+
var isEmpty__default = /*#__PURE__*/_interopDefaultLegacy(isEmpty);
|
|
20
21
|
var jsonpointer__default = /*#__PURE__*/_interopDefaultLegacy(jsonpointer);
|
|
21
22
|
var omit__default = /*#__PURE__*/_interopDefaultLegacy(omit);
|
|
22
23
|
var set__default = /*#__PURE__*/_interopDefaultLegacy(set);
|
|
23
24
|
var mergeAllOf__default = /*#__PURE__*/_interopDefaultLegacy(mergeAllOf);
|
|
24
25
|
var union__default = /*#__PURE__*/_interopDefaultLegacy(union);
|
|
25
|
-
var isEmpty__default = /*#__PURE__*/_interopDefaultLegacy(isEmpty);
|
|
26
26
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
27
27
|
var ReactIs__default = /*#__PURE__*/_interopDefaultLegacy(ReactIs);
|
|
28
28
|
|
|
@@ -991,7 +991,7 @@ function getInnerSchemaForArrayItem(schema, additionalItems, idx) {
|
|
|
991
991
|
return {};
|
|
992
992
|
}
|
|
993
993
|
/** Computes the defaults for the current `schema` given the `rawFormData` and `parentDefaults` if any. This drills into
|
|
994
|
-
*
|
|
994
|
+
* each level of the schema, recursively, to fill out every level of defaults provided by the schema.
|
|
995
995
|
*
|
|
996
996
|
* @param validator - an implementation of the `ValidatorType` interface that will be used when necessary
|
|
997
997
|
* @param schema - The schema for which the default state is desired
|
|
@@ -1031,9 +1031,9 @@ function computeDefaults(validator, schema, parentDefaults, rootSchema, rawFormD
|
|
|
1031
1031
|
} else if (isFixedItems(schema)) {
|
|
1032
1032
|
defaults = schema.items.map((itemSchema, idx) => computeDefaults(validator, itemSchema, Array.isArray(parentDefaults) ? parentDefaults[idx] : undefined, rootSchema, formData, includeUndefinedValues));
|
|
1033
1033
|
} else if (ONE_OF_KEY in schema) {
|
|
1034
|
-
schema = schema.oneOf[getMatchingOption(validator, undefined, schema.oneOf, rootSchema)];
|
|
1034
|
+
schema = schema.oneOf[getMatchingOption(validator, isEmpty__default["default"](formData) ? undefined : formData, schema.oneOf, rootSchema)];
|
|
1035
1035
|
} else if (ANY_OF_KEY in schema) {
|
|
1036
|
-
schema = schema.anyOf[getMatchingOption(validator, undefined, schema.anyOf, rootSchema)];
|
|
1036
|
+
schema = schema.anyOf[getMatchingOption(validator, isEmpty__default["default"](formData) ? undefined : formData, schema.anyOf, rootSchema)];
|
|
1037
1037
|
} // Not defaults defined for this node, fallback to generic typed ones.
|
|
1038
1038
|
|
|
1039
1039
|
|