@rjsf/utils 6.0.0-beta.13 → 6.0.0-beta.15
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/index.js +8 -5
- package/dist/index.js.map +3 -3
- package/dist/utils.esm.js +8 -5
- package/dist/utils.esm.js.map +2 -2
- package/dist/utils.umd.js +11 -8
- package/lib/createSchemaUtils.js +3 -1
- package/lib/createSchemaUtils.js.map +1 -1
- package/lib/getTestIds.js +2 -2
- package/lib/getTestIds.js.map +1 -1
- package/lib/getUiOptions.js +4 -0
- package/lib/getUiOptions.js.map +1 -1
- package/lib/schema/getDisplayLabel.js +2 -2
- package/lib/schema/getDisplayLabel.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types.d.ts +18 -3
- package/package.json +5 -6
- package/src/createSchemaUtils.ts +4 -1
- package/src/getTestIds.ts +2 -2
- package/src/getUiOptions.ts +4 -0
- package/src/schema/getDisplayLabel.ts +2 -2
- package/src/types.ts +21 -3
package/dist/utils.esm.js
CHANGED
|
@@ -80,6 +80,9 @@ var JSON_SCHEMA_DRAFT_2020_12 = "https://json-schema.org/draft/2020-12/schema";
|
|
|
80
80
|
|
|
81
81
|
// src/getUiOptions.ts
|
|
82
82
|
function getUiOptions(uiSchema = {}, globalOptions = {}) {
|
|
83
|
+
if (!uiSchema) {
|
|
84
|
+
return { ...globalOptions };
|
|
85
|
+
}
|
|
83
86
|
return Object.keys(uiSchema).filter((key) => key.indexOf("ui:") === 0).reduce(
|
|
84
87
|
(options, key) => {
|
|
85
88
|
const value = uiSchema[key];
|
|
@@ -1866,10 +1869,10 @@ function getDisplayLabel(validator, schema, uiSchema = {}, rootSchema, globalOpt
|
|
|
1866
1869
|
if (schemaType === "object") {
|
|
1867
1870
|
displayLabel = false;
|
|
1868
1871
|
}
|
|
1869
|
-
if (schemaType === "boolean" && !uiSchema[UI_WIDGET_KEY]) {
|
|
1872
|
+
if (schemaType === "boolean" && uiSchema && !uiSchema[UI_WIDGET_KEY]) {
|
|
1870
1873
|
displayLabel = false;
|
|
1871
1874
|
}
|
|
1872
|
-
if (uiSchema[UI_FIELD_KEY]) {
|
|
1875
|
+
if (uiSchema && uiSchema[UI_FIELD_KEY]) {
|
|
1873
1876
|
displayLabel = false;
|
|
1874
1877
|
}
|
|
1875
1878
|
return displayLabel;
|
|
@@ -2205,7 +2208,7 @@ var SchemaUtils = class {
|
|
|
2205
2208
|
* @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
|
|
2206
2209
|
*/
|
|
2207
2210
|
constructor(validator, rootSchema, experimental_defaultFormStateBehavior, experimental_customMergeAllOf) {
|
|
2208
|
-
if (rootSchema[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2020_12) {
|
|
2211
|
+
if (rootSchema && rootSchema[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2020_12) {
|
|
2209
2212
|
this.rootSchema = makeAllReferencesAbsolute(rootSchema, get16(rootSchema, ID_KEY, "#"));
|
|
2210
2213
|
} else {
|
|
2211
2214
|
this.rootSchema = rootSchema;
|
|
@@ -2840,8 +2843,8 @@ function getTemplate(name, registry, uiOptions = {}) {
|
|
|
2840
2843
|
}
|
|
2841
2844
|
|
|
2842
2845
|
// src/getTestIds.ts
|
|
2843
|
-
import { nanoid } from "nanoid";
|
|
2844
2846
|
import get18 from "lodash/get";
|
|
2847
|
+
import uniqueId from "lodash/uniqueId";
|
|
2845
2848
|
function getTestIds() {
|
|
2846
2849
|
if (typeof process === "undefined" || get18(process, "env.NODE_ENV") !== "test") {
|
|
2847
2850
|
return {};
|
|
@@ -2852,7 +2855,7 @@ function getTestIds() {
|
|
|
2852
2855
|
{
|
|
2853
2856
|
get(_obj, prop) {
|
|
2854
2857
|
if (!ids.has(prop)) {
|
|
2855
|
-
ids.set(prop,
|
|
2858
|
+
ids.set(prop, uniqueId("test-id-"));
|
|
2856
2859
|
}
|
|
2857
2860
|
return ids.get(prop);
|
|
2858
2861
|
}
|