@rjsf/utils 6.0.0-beta.2 → 6.0.0-beta.20
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 → index.cjs} +241 -205
- package/dist/index.cjs.map +7 -0
- package/dist/utils.esm.js +240 -204
- package/dist/utils.esm.js.map +4 -4
- package/dist/utils.umd.js +235 -200
- package/lib/canExpand.d.ts +1 -1
- package/lib/constants.d.ts +3 -0
- package/lib/constants.js +3 -0
- package/lib/constants.js.map +1 -1
- package/lib/createSchemaUtils.js +19 -14
- package/lib/createSchemaUtils.js.map +1 -1
- package/lib/enums.d.ts +3 -3
- package/lib/enums.js +3 -3
- package/lib/findSchemaDefinition.d.ts +7 -1
- package/lib/findSchemaDefinition.js +48 -6
- package/lib/findSchemaDefinition.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/getWidget.js +3 -3
- package/lib/getWidget.js.map +1 -1
- package/lib/idGenerators.d.ts +15 -15
- package/lib/idGenerators.js +8 -8
- package/lib/idGenerators.js.map +1 -1
- package/lib/index.d.ts +4 -1
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/mergeDefaultsWithFormData.js +14 -2
- package/lib/mergeDefaultsWithFormData.js.map +1 -1
- package/lib/schema/findFieldInSchema.d.ts +1 -1
- package/lib/schema/findFieldInSchema.js +1 -1
- package/lib/schema/getDefaultFormState.d.ts +11 -2
- package/lib/schema/getDefaultFormState.js +59 -22
- package/lib/schema/getDefaultFormState.js.map +1 -1
- package/lib/schema/getDisplayLabel.js +2 -2
- package/lib/schema/getDisplayLabel.js.map +1 -1
- package/lib/schema/index.d.ts +1 -2
- package/lib/schema/index.js +1 -2
- package/lib/schema/index.js.map +1 -1
- package/lib/schema/retrieveSchema.d.ts +1 -1
- package/lib/schema/retrieveSchema.js +6 -6
- package/lib/schema/retrieveSchema.js.map +1 -1
- package/lib/shallowEquals.d.ts +8 -0
- package/lib/shallowEquals.js +36 -0
- package/lib/shallowEquals.js.map +1 -0
- package/lib/shouldRender.d.ts +8 -2
- package/lib/shouldRender.js +17 -2
- package/lib/shouldRender.js.map +1 -1
- package/lib/toFieldPathId.d.ts +12 -0
- package/lib/toFieldPathId.js +19 -0
- package/lib/toFieldPathId.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types.d.ts +97 -66
- package/package.json +13 -14
- package/src/constants.ts +3 -0
- package/src/createSchemaUtils.ts +19 -25
- package/src/enums.ts +3 -3
- package/src/findSchemaDefinition.ts +55 -6
- package/src/getTestIds.ts +2 -2
- package/src/getUiOptions.ts +4 -0
- package/src/getWidget.tsx +3 -3
- package/src/idGenerators.ts +25 -25
- package/src/index.ts +6 -0
- package/src/mergeDefaultsWithFormData.ts +16 -2
- package/src/schema/findFieldInSchema.ts +1 -1
- package/src/schema/getDefaultFormState.ts +76 -32
- package/src/schema/getDisplayLabel.ts +2 -2
- package/src/schema/index.ts +0 -2
- package/src/schema/retrieveSchema.ts +7 -5
- package/src/shallowEquals.ts +41 -0
- package/src/shouldRender.ts +27 -2
- package/src/toFieldPathId.ts +24 -0
- package/src/types.ts +107 -70
- package/dist/index.js.map +0 -7
- package/lib/schema/toIdSchema.d.ts +0 -14
- package/lib/schema/toIdSchema.js +0 -62
- package/lib/schema/toIdSchema.js.map +0 -1
- package/src/schema/toIdSchema.ts +0 -131
package/lib/canExpand.d.ts
CHANGED
|
@@ -8,4 +8,4 @@ import { FormContextType, RJSFSchema, StrictRJSFSchema, UiSchema } from './types
|
|
|
8
8
|
* @param [formData] - The formData for the field
|
|
9
9
|
* @returns - True if the schema element has additionalProperties, is expandable, and not at the maxProperties limit
|
|
10
10
|
*/
|
|
11
|
-
export default function canExpand<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(schema: RJSFSchema, uiSchema?: UiSchema<T, S, F>, formData?: T):
|
|
11
|
+
export default function canExpand<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(schema: RJSFSchema, uiSchema?: UiSchema<T, S, F>, formData?: T): any;
|
package/lib/constants.d.ts
CHANGED
|
@@ -26,6 +26,8 @@ export declare const REQUIRED_KEY = "required";
|
|
|
26
26
|
export declare const SUBMIT_BTN_OPTIONS_KEY = "submitButtonOptions";
|
|
27
27
|
export declare const REF_KEY = "$ref";
|
|
28
28
|
export declare const SCHEMA_KEY = "$schema";
|
|
29
|
+
export declare const DEFAULT_ID_PREFIX = "root";
|
|
30
|
+
export declare const DEFAULT_ID_SEPARATOR = "_";
|
|
29
31
|
/** The path of the discriminator value returned by the schema endpoint.
|
|
30
32
|
* The discriminator is the value in a `oneOf` that determines which option is selected.
|
|
31
33
|
*/
|
|
@@ -44,4 +46,5 @@ export declare const UI_OPTIONS_KEY = "ui:options";
|
|
|
44
46
|
export declare const UI_GLOBAL_OPTIONS_KEY = "ui:globalOptions";
|
|
45
47
|
/** The JSON Schema version strings
|
|
46
48
|
*/
|
|
49
|
+
export declare const JSON_SCHEMA_DRAFT_2019_09 = "https://json-schema.org/draft/2019-09/schema";
|
|
47
50
|
export declare const JSON_SCHEMA_DRAFT_2020_12 = "https://json-schema.org/draft/2020-12/schema";
|
package/lib/constants.js
CHANGED
|
@@ -26,6 +26,8 @@ export const REQUIRED_KEY = 'required';
|
|
|
26
26
|
export const SUBMIT_BTN_OPTIONS_KEY = 'submitButtonOptions';
|
|
27
27
|
export const REF_KEY = '$ref';
|
|
28
28
|
export const SCHEMA_KEY = '$schema';
|
|
29
|
+
export const DEFAULT_ID_PREFIX = 'root';
|
|
30
|
+
export const DEFAULT_ID_SEPARATOR = '_';
|
|
29
31
|
/** The path of the discriminator value returned by the schema endpoint.
|
|
30
32
|
* The discriminator is the value in a `oneOf` that determines which option is selected.
|
|
31
33
|
*/
|
|
@@ -44,5 +46,6 @@ export const UI_OPTIONS_KEY = 'ui:options';
|
|
|
44
46
|
export const UI_GLOBAL_OPTIONS_KEY = 'ui:globalOptions';
|
|
45
47
|
/** The JSON Schema version strings
|
|
46
48
|
*/
|
|
49
|
+
export const JSON_SCHEMA_DRAFT_2019_09 = 'https://json-schema.org/draft/2019-09/schema';
|
|
47
50
|
export const JSON_SCHEMA_DRAFT_2020_12 = 'https://json-schema.org/draft/2020-12/schema';
|
|
48
51
|
//# sourceMappingURL=constants.js.map
|
package/lib/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,uBAAuB,CAAC;AAChE,MAAM,CAAC,MAAM,yBAAyB,GAAG,sBAAsB,CAAC;AAChE,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC;AAClC,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC;AAClC,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,CAAC;AACjC,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC;AACrC,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAC;AAC7C,MAAM,CAAC,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAC/C,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC;AAC/B,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAAC;AACrC,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,CAAC;AAC5B,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,CAAC;AAC3B,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,CAAC;AACjC,MAAM,CAAC,MAAM,cAAc,GAAG,2BAA2B,CAAC;AAC1D,MAAM,CAAC,MAAM,QAAQ,GAAG,OAAO,CAAC;AAChC,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC;AAClC,MAAM,CAAC,MAAM,sBAAsB,GAAG,mBAAmB,CA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6B,CAAC;AAC7E,MAAM,CAAC,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AACtD,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CAAC;AACvC,MAAM,CAAC,MAAM,aAAa,GAAG,WAAW,CAAC;AACzC,MAAM,CAAC,MAAM,cAAc,GAAG,YAAY,CAAC;AAC3C,MAAM,CAAC,MAAM,qBAAqB,GAAG,kBAAkB,CAAC;AAExD;GACG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,8CAA8C,CAAC;AACxF,MAAM,CAAC,MAAM,yBAAyB,GAAG,8CAA8C,CAAC"}
|
package/lib/createSchemaUtils.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import deepEquals from './deepEquals.js';
|
|
2
|
-
import { findFieldInSchema, findSelectedOptionInXxxOf, getDefaultFormState, getDisplayLabel, getClosestMatchingOption, getFirstMatchingOption, getFromSchema, isFilesArray, isMultiSelect, isSelect, retrieveSchema, sanitizeDataForNewSchema,
|
|
2
|
+
import { findFieldInSchema, findSelectedOptionInXxxOf, getDefaultFormState, getDisplayLabel, getClosestMatchingOption, getFirstMatchingOption, getFromSchema, isFilesArray, isMultiSelect, isSelect, retrieveSchema, sanitizeDataForNewSchema, toPathSchema, } from './schema/index.js';
|
|
3
|
+
import { makeAllReferencesAbsolute } from './findSchemaDefinition.js';
|
|
4
|
+
import { ID_KEY, JSON_SCHEMA_DRAFT_2020_12, SCHEMA_KEY } from './constants.js';
|
|
5
|
+
import get from 'lodash-es/get.js';
|
|
3
6
|
/** The `SchemaUtils` class provides a wrapper around the publicly exported APIs in the `utils/schema` directory such
|
|
4
7
|
* that one does not have to explicitly pass the `validator`, `rootSchema`, `experimental_defaultFormStateBehavior` or
|
|
5
8
|
* `experimental_customMergeAllOf` to each method. Since these generally do not change across a `Form`, this allows for
|
|
@@ -15,11 +18,23 @@ class SchemaUtils {
|
|
|
15
18
|
* @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
|
|
16
19
|
*/
|
|
17
20
|
constructor(validator, rootSchema, experimental_defaultFormStateBehavior, experimental_customMergeAllOf) {
|
|
18
|
-
|
|
21
|
+
if (rootSchema && rootSchema[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2020_12) {
|
|
22
|
+
this.rootSchema = makeAllReferencesAbsolute(rootSchema, get(rootSchema, ID_KEY, '#'));
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
this.rootSchema = rootSchema;
|
|
26
|
+
}
|
|
19
27
|
this.validator = validator;
|
|
20
28
|
this.experimental_defaultFormStateBehavior = experimental_defaultFormStateBehavior;
|
|
21
29
|
this.experimental_customMergeAllOf = experimental_customMergeAllOf;
|
|
22
30
|
}
|
|
31
|
+
/** Returns the `rootSchema` in the `SchemaUtilsType`
|
|
32
|
+
*
|
|
33
|
+
* @returns - The `rootSchema`
|
|
34
|
+
*/
|
|
35
|
+
getRootSchema() {
|
|
36
|
+
return this.rootSchema;
|
|
37
|
+
}
|
|
23
38
|
/** Returns the `ValidatorType` in the `SchemaUtilsType`
|
|
24
39
|
*
|
|
25
40
|
* @returns - The `ValidatorType`
|
|
@@ -38,6 +53,8 @@ class SchemaUtils {
|
|
|
38
53
|
* @returns - True if the `SchemaUtilsType` differs from the given `validator` or `rootSchema`
|
|
39
54
|
*/
|
|
40
55
|
doesSchemaUtilsDiffer(validator, rootSchema, experimental_defaultFormStateBehavior = {}, experimental_customMergeAllOf) {
|
|
56
|
+
// If either validator or rootSchema are falsy, return false to prevent the creation
|
|
57
|
+
// of a new SchemaUtilsType with incomplete properties.
|
|
41
58
|
if (!validator || !rootSchema) {
|
|
42
59
|
return false;
|
|
43
60
|
}
|
|
@@ -179,18 +196,6 @@ class SchemaUtils {
|
|
|
179
196
|
sanitizeDataForNewSchema(newSchema, oldSchema, data) {
|
|
180
197
|
return sanitizeDataForNewSchema(this.validator, this.rootSchema, newSchema, oldSchema, data, this.experimental_customMergeAllOf);
|
|
181
198
|
}
|
|
182
|
-
/** Generates an `IdSchema` object for the `schema`, recursively
|
|
183
|
-
*
|
|
184
|
-
* @param schema - The schema for which the display label flag is desired
|
|
185
|
-
* @param [id] - The base id for the schema
|
|
186
|
-
* @param [formData] - The current formData, if any, onto which to provide any missing defaults
|
|
187
|
-
* @param [idPrefix='root'] - The prefix to use for the id
|
|
188
|
-
* @param [idSeparator='_'] - The separator to use for the path segments in the id
|
|
189
|
-
* @returns - The `IdSchema` object for the `schema`
|
|
190
|
-
*/
|
|
191
|
-
toIdSchema(schema, id, formData, idPrefix = 'root', idSeparator = '_') {
|
|
192
|
-
return toIdSchema(this.validator, schema, id, this.rootSchema, formData, idPrefix, idSeparator, this.experimental_customMergeAllOf);
|
|
193
|
-
}
|
|
194
199
|
/** Generates an `PathSchema` object for the `schema`, recursively
|
|
195
200
|
*
|
|
196
201
|
* @param schema - The schema for which the display label flag is desired
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSchemaUtils.js","sourceRoot":"","sources":["../src/createSchemaUtils.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"createSchemaUtils.js","sourceRoot":"","sources":["../src/createSchemaUtils.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,CAAC;AActC,OAAO,EACL,iBAAiB,EACjB,yBAAyB,EACzB,mBAAmB,EACnB,eAAe,EACf,wBAAwB,EACxB,sBAAsB,EACtB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,cAAc,EACd,wBAAwB,EACxB,YAAY,GACb,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,yBAAyB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,GAAG,MAAM,YAAY,CAAC;AAE7B;;;;;GAKG;AACH,MAAM,WAAW;IAQf;;;;;;OAMG;IACH,YACE,SA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AAO,YAAY,CACjB,IAAI,CAAC,SAAS,EACd,MAAM,EACN,IAAI,EACJ,IAAI,CAAC,UAAU,EACf,QAAQ,EACR,IAAI,CAAC,6BAA6B,CACnC,CAAC;IACJ,CAAC;CACF;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAKvC,SAAiC,EACjC,UAAa,EACb,qCAAqC,GAAG,EAAE,EAC1C,6BAAgE;IAEhE,OAAO,IAAI,WAAW,CACpB,SAAS,EACT,UAAU,EACV,qCAAqC,EACrC,6BAA6B,CAC9B,CAAC;AACJ,CAAC"}
|
package/lib/enums.d.ts
CHANGED
|
@@ -61,7 +61,7 @@ export declare enum TranslatableString {
|
|
|
61
61
|
InvalidObjectField = "Invalid \"%1\" object field configuration: _%2_.",
|
|
62
62
|
/** Unsupported field schema, used by UnsupportedField */
|
|
63
63
|
UnsupportedField = "Unsupported field schema.",
|
|
64
|
-
/** Unsupported field schema, where %1 will be replaced by the
|
|
64
|
+
/** Unsupported field schema, where %1 will be replaced by the FieldPathId.$id as provided by UnsupportedField.
|
|
65
65
|
* NOTE: Use markdown notation rather than html tags.
|
|
66
66
|
*/
|
|
67
67
|
UnsupportedFieldWithId = "Unsupported field schema for field `%1`.",
|
|
@@ -69,8 +69,8 @@ export declare enum TranslatableString {
|
|
|
69
69
|
* NOTE: Use markdown notation rather than html tags.
|
|
70
70
|
*/
|
|
71
71
|
UnsupportedFieldWithReason = "Unsupported field schema: _%1_.",
|
|
72
|
-
/** Unsupported field schema, where %1 and %2 will be replaced by the
|
|
73
|
-
* as provided by UnsupportedField.
|
|
72
|
+
/** Unsupported field schema, where %1 and %2 will be replaced by the FieldPathId.$id and reason strings,
|
|
73
|
+
* respectively, as provided by UnsupportedField.
|
|
74
74
|
* NOTE: Use markdown notation rather than html tags.
|
|
75
75
|
*/
|
|
76
76
|
UnsupportedFieldWithIdAndReason = "Unsupported field schema for field `%1`: _%2_.",
|
package/lib/enums.js
CHANGED
|
@@ -64,7 +64,7 @@ export var TranslatableString;
|
|
|
64
64
|
TranslatableString["InvalidObjectField"] = "Invalid \"%1\" object field configuration: _%2_.";
|
|
65
65
|
/** Unsupported field schema, used by UnsupportedField */
|
|
66
66
|
TranslatableString["UnsupportedField"] = "Unsupported field schema.";
|
|
67
|
-
/** Unsupported field schema, where %1 will be replaced by the
|
|
67
|
+
/** Unsupported field schema, where %1 will be replaced by the FieldPathId.$id as provided by UnsupportedField.
|
|
68
68
|
* NOTE: Use markdown notation rather than html tags.
|
|
69
69
|
*/
|
|
70
70
|
TranslatableString["UnsupportedFieldWithId"] = "Unsupported field schema for field `%1`.";
|
|
@@ -72,8 +72,8 @@ export var TranslatableString;
|
|
|
72
72
|
* NOTE: Use markdown notation rather than html tags.
|
|
73
73
|
*/
|
|
74
74
|
TranslatableString["UnsupportedFieldWithReason"] = "Unsupported field schema: _%1_.";
|
|
75
|
-
/** Unsupported field schema, where %1 and %2 will be replaced by the
|
|
76
|
-
* as provided by UnsupportedField.
|
|
75
|
+
/** Unsupported field schema, where %1 and %2 will be replaced by the FieldPathId.$id and reason strings,
|
|
76
|
+
* respectively, as provided by UnsupportedField.
|
|
77
77
|
* NOTE: Use markdown notation rather than html tags.
|
|
78
78
|
*/
|
|
79
79
|
TranslatableString["UnsupportedFieldWithIdAndReason"] = "Unsupported field schema for field `%1`: _%2_.";
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { GenericObjectType, RJSFSchema, StrictRJSFSchema } from './types.js';
|
|
2
|
+
/** Parses a JSONSchema and makes all references absolute with respect to
|
|
3
|
+
* the `baseURI` argument
|
|
4
|
+
* @param schema - The schema to be processed
|
|
5
|
+
* @param baseURI - The base URI to be used for resolving relative references
|
|
6
|
+
*/
|
|
7
|
+
export declare function makeAllReferencesAbsolute<S extends StrictRJSFSchema = RJSFSchema>(schema: S, baseURI: string): S;
|
|
2
8
|
/** Splits out the value at the `key` in `object` from the `object`, returning an array that contains in the first
|
|
3
9
|
* location, the `object` minus the `key: value` and in the second location the `value`.
|
|
4
10
|
*
|
|
@@ -16,7 +22,7 @@ export declare function splitKeyElementFromObject(key: string, object: GenericOb
|
|
|
16
22
|
* @param $ref - The ref string for which the schema definition is desired
|
|
17
23
|
* @param [rootSchema={}] - The root schema in which to search for the definition
|
|
18
24
|
* @param recurseList - List of $refs already resolved to prevent recursion
|
|
19
|
-
* @param baseURI - The base URI to be used for resolving relative references
|
|
25
|
+
* @param [baseURI=rootSchema['$id']] - The base URI to be used for resolving relative references
|
|
20
26
|
* @returns - The sub-schema within the `rootSchema` which matches the `$ref` if it exists
|
|
21
27
|
* @throws - Error indicating that no schema for that reference could be resolved
|
|
22
28
|
*/
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import jsonpointer from 'jsonpointer';
|
|
2
2
|
import omit from 'lodash-es/omit.js';
|
|
3
|
-
import { ID_KEY, JSON_SCHEMA_DRAFT_2020_12, REF_KEY, SCHEMA_KEY } from './constants.js';
|
|
3
|
+
import { ALL_OF_KEY, ID_KEY, JSON_SCHEMA_DRAFT_2019_09, JSON_SCHEMA_DRAFT_2020_12, REF_KEY, SCHEMA_KEY, } from './constants.js';
|
|
4
4
|
import isObject from 'lodash-es/isObject.js';
|
|
5
5
|
import isEmpty from 'lodash-es/isEmpty.js';
|
|
6
6
|
import UriResolver from 'fast-uri';
|
|
7
|
+
import get from 'lodash-es/get.js';
|
|
7
8
|
/** Looks for the `$id` pointed by `ref` in the schema definitions embedded in
|
|
8
9
|
* a JSON Schema bundle
|
|
9
10
|
*
|
|
@@ -16,7 +17,17 @@ function findEmbeddedSchemaRecursive(schema, ref) {
|
|
|
16
17
|
return schema;
|
|
17
18
|
}
|
|
18
19
|
for (const subSchema of Object.values(schema)) {
|
|
19
|
-
if (
|
|
20
|
+
if (Array.isArray(subSchema)) {
|
|
21
|
+
for (const item of subSchema) {
|
|
22
|
+
if (isObject(item)) {
|
|
23
|
+
const result = findEmbeddedSchemaRecursive(item, ref);
|
|
24
|
+
if (result !== undefined) {
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else if (isObject(subSchema)) {
|
|
20
31
|
const result = findEmbeddedSchemaRecursive(subSchema, ref);
|
|
21
32
|
if (result !== undefined) {
|
|
22
33
|
return result;
|
|
@@ -25,6 +36,31 @@ function findEmbeddedSchemaRecursive(schema, ref) {
|
|
|
25
36
|
}
|
|
26
37
|
return undefined;
|
|
27
38
|
}
|
|
39
|
+
/** Parses a JSONSchema and makes all references absolute with respect to
|
|
40
|
+
* the `baseURI` argument
|
|
41
|
+
* @param schema - The schema to be processed
|
|
42
|
+
* @param baseURI - The base URI to be used for resolving relative references
|
|
43
|
+
*/
|
|
44
|
+
export function makeAllReferencesAbsolute(schema, baseURI) {
|
|
45
|
+
const currentURI = get(schema, ID_KEY, baseURI);
|
|
46
|
+
// Make all other references absolute
|
|
47
|
+
if (REF_KEY in schema) {
|
|
48
|
+
schema = { ...schema, [REF_KEY]: UriResolver.resolve(currentURI, schema[REF_KEY]) };
|
|
49
|
+
}
|
|
50
|
+
// Look for references in nested subschemas
|
|
51
|
+
for (const [key, subSchema] of Object.entries(schema)) {
|
|
52
|
+
if (Array.isArray(subSchema)) {
|
|
53
|
+
schema = {
|
|
54
|
+
...schema,
|
|
55
|
+
[key]: subSchema.map((item) => (isObject(item) ? makeAllReferencesAbsolute(item, currentURI) : item)),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
else if (isObject(subSchema)) {
|
|
59
|
+
schema = { ...schema, [key]: makeAllReferencesAbsolute(subSchema, currentURI) };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return schema;
|
|
63
|
+
}
|
|
28
64
|
/** Splits out the value at the `key` in `object` from the `object`, returning an array that contains in the first
|
|
29
65
|
* location, the `object` minus the `key: value` and in the second location the `value`.
|
|
30
66
|
*
|
|
@@ -46,11 +82,11 @@ export function splitKeyElementFromObject(key, object) {
|
|
|
46
82
|
* @param $ref - The ref string for which the schema definition is desired
|
|
47
83
|
* @param [rootSchema={}] - The root schema in which to search for the definition
|
|
48
84
|
* @param recurseList - List of $refs already resolved to prevent recursion
|
|
49
|
-
* @param baseURI - The base URI to be used for resolving relative references
|
|
85
|
+
* @param [baseURI=rootSchema['$id']] - The base URI to be used for resolving relative references
|
|
50
86
|
* @returns - The sub-schema within the `rootSchema` which matches the `$ref` if it exists
|
|
51
87
|
* @throws - Error indicating that no schema for that reference could be resolved
|
|
52
88
|
*/
|
|
53
|
-
export function findSchemaDefinitionRecursive($ref, rootSchema = {}, recurseList = [], baseURI =
|
|
89
|
+
export function findSchemaDefinitionRecursive($ref, rootSchema = {}, recurseList = [], baseURI = get(rootSchema, [ID_KEY])) {
|
|
54
90
|
const ref = $ref || '';
|
|
55
91
|
let current = undefined;
|
|
56
92
|
if (ref.startsWith('#')) {
|
|
@@ -94,7 +130,13 @@ export function findSchemaDefinitionRecursive($ref, rootSchema = {}, recurseList
|
|
|
94
130
|
const [remaining, theRef] = splitKeyElementFromObject(REF_KEY, current);
|
|
95
131
|
const subSchema = findSchemaDefinitionRecursive(theRef, rootSchema, [...recurseList, ref], baseURI);
|
|
96
132
|
if (Object.keys(remaining).length > 0) {
|
|
97
|
-
|
|
133
|
+
if (rootSchema[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2019_09 ||
|
|
134
|
+
rootSchema[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2020_12) {
|
|
135
|
+
return { [ALL_OF_KEY]: [remaining, subSchema] };
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
return { ...remaining, ...subSchema };
|
|
139
|
+
}
|
|
98
140
|
}
|
|
99
141
|
return subSchema;
|
|
100
142
|
}
|
|
@@ -111,7 +153,7 @@ export function findSchemaDefinitionRecursive($ref, rootSchema = {}, recurseList
|
|
|
111
153
|
* @returns - The sub-schema within the `rootSchema` which matches the `$ref` if it exists
|
|
112
154
|
* @throws - Error indicating that no schema for that reference could be resolved
|
|
113
155
|
*/
|
|
114
|
-
export default function findSchemaDefinition($ref, rootSchema = {}, baseURI =
|
|
156
|
+
export default function findSchemaDefinition($ref, rootSchema = {}, baseURI = get(rootSchema, [ID_KEY])) {
|
|
115
157
|
const recurseList = [];
|
|
116
158
|
return findSchemaDefinitionRecursive($ref, rootSchema, recurseList, baseURI);
|
|
117
159
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findSchemaDefinition.js","sourceRoot":"","sources":["../src/findSchemaDefinition.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,aAAa,CAAC;AACtC,OAAO,IAAI,MAAM,aAAa,CAAC;AAE/B,OAAO,
|
|
1
|
+
{"version":3,"file":"findSchemaDefinition.js","sourceRoot":"","sources":["../src/findSchemaDefinition.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,aAAa,CAAC;AACtC,OAAO,IAAI,MAAM,aAAa,CAAC;AAE/B,OAAO,EACL,UAAU,EACV,MAAM,EACN,yBAAyB,EACzB,yBAAyB,EACzB,OAAO,EACP,UAAU,GACX,MAAM,aAAa,CAAC;AAErB,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,OAAO,MAAM,gBAAgB,CAAC;AACrC,OAAO,WAAW,MAAM,UAAU,CAAC;AACnC,OAAO,GAAG,MAAM,YAAY,CAAC;AAE7B;;;;;;GAMG;AACH,SAAS,2BAA2B,CAA0C,MAAS,EAAE,GAAW;IAClG,IAAI,MAAM,IAAI,MAAM,IAAI,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAW,EAAE,GAAG,CAAC,EAAE,CAAC;QACzE,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QAC9C,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;YAC7B,KAAK,MAAM,IAAI,IAAI,SAAS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G,CAAC,UAAU,EAAE,CAAC,MAAM,CAAC,CAAC;IAEvD,MAAM,WAAW,GAAa,EAAE,CAAC;IACjC,OAAO,6BAA6B,CAAC,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;AAC/E,CAAC"}
|
package/lib/getTestIds.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { nanoid } from 'nanoid';
|
|
2
1
|
import get from 'lodash-es/get.js';
|
|
2
|
+
import uniqueId from 'lodash-es/uniqueId.js';
|
|
3
3
|
/** Returns an object of test IDs that can only be used in test mode. If the function is called in a test environment
|
|
4
4
|
* (`NODE_ENV === 'test'`, this is set by jest) then a Proxy object will be returned. If a key within the returned
|
|
5
5
|
* object is accessed, if the value already exists the object will return that value, otherwise it will create that key
|
|
@@ -25,7 +25,7 @@ export default function getTestIds() {
|
|
|
25
25
|
return new Proxy({}, {
|
|
26
26
|
get(_obj, prop) {
|
|
27
27
|
if (!ids.has(prop)) {
|
|
28
|
-
ids.set(prop,
|
|
28
|
+
ids.set(prop, uniqueId('test-id-'));
|
|
29
29
|
}
|
|
30
30
|
return ids.get(prop);
|
|
31
31
|
},
|
package/lib/getTestIds.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTestIds.js","sourceRoot":"","sources":["../src/getTestIds.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"getTestIds.js","sourceRoot":"","sources":["../src/getTestIds.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,YAAY,CAAC;AAC7B,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAIvC;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU;IAChC,oHAAoH;IACpH,8EAA8E;IAC9E,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,GAAG,CAAC,OAAO,EAAE,cAAc,CAAC,KAAK,MAAM,EAAE,CAAC;QAC9E,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;IACtB,OAAO,IAAI,KAAK,CACd,EAAE,EACF;QACE,GAAG,CAAC,IAAI,EAAE,IAAI;YACZ,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBACnB,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;YACtC,CAAC;YACD,OAAO,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;KACF,CACF,CAAC;AACJ,CAAC"}
|
package/lib/getUiOptions.js
CHANGED
|
@@ -8,6 +8,10 @@ import isObject from './isObject.js';
|
|
|
8
8
|
* @returns - An object containing all the `ui:xxx` options with the `ui:` stripped off along with all `globalOptions`
|
|
9
9
|
*/
|
|
10
10
|
export default function getUiOptions(uiSchema = {}, globalOptions = {}) {
|
|
11
|
+
// Handle null or undefined uiSchema
|
|
12
|
+
if (!uiSchema) {
|
|
13
|
+
return { ...globalOptions };
|
|
14
|
+
}
|
|
11
15
|
return Object.keys(uiSchema)
|
|
12
16
|
.filter((key) => key.indexOf('ui:') === 0)
|
|
13
17
|
.reduce((options, key) => {
|
package/lib/getUiOptions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getUiOptions.js","sourceRoot":"","sources":["../src/getUiOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,QAAQ,MAAM,YAAY,CAAC;AAGlC;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,WAA8B,EAAE,EAChC,gBAAuC,EAAE;IAEzC,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;SACzB,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,C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AAG,CAAC,CAAC;QAC5B,IAAI,GAAG,KAAK,aAAa,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAC7C,OAAO,CAAC,KAAK,CAAC,qFAAqF,CAAC,CAAC;YACrG,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,IAAI,GAAG,KAAK,cAAc,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9C,OAAO,EAAE,GAAG,OAAO,EAAE,GAAG,KAAK,EAAE,CAAC;QAClC,CAAC;QACD,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;IACnD,CAAC,EACD,EAAE,GAAG,aAAa,EAAE,CACrB,CAAC;AACN,CAAC"}
|
package/lib/getWidget.js
CHANGED
|
@@ -96,7 +96,7 @@ export default function getWidget(schema, widget, registeredWidgets = {}) {
|
|
|
96
96
|
return mergeWidgetOptions(widget);
|
|
97
97
|
}
|
|
98
98
|
if (typeof widget !== 'string') {
|
|
99
|
-
throw new Error(`Unsupported widget definition: ${typeof widget}`);
|
|
99
|
+
throw new Error(`Unsupported widget definition: ${typeof widget} in schema: ${JSON.stringify(schema)}`);
|
|
100
100
|
}
|
|
101
101
|
if (widget in registeredWidgets) {
|
|
102
102
|
const registeredWidget = registeredWidgets[widget];
|
|
@@ -104,13 +104,13 @@ export default function getWidget(schema, widget, registeredWidgets = {}) {
|
|
|
104
104
|
}
|
|
105
105
|
if (typeof type === 'string') {
|
|
106
106
|
if (!(type in widgetMap)) {
|
|
107
|
-
throw new Error(`No widget for type '${type}'`);
|
|
107
|
+
throw new Error(`No widget for type '${type}' in schema: ${JSON.stringify(schema)}`);
|
|
108
108
|
}
|
|
109
109
|
if (widget in widgetMap[type]) {
|
|
110
110
|
const registeredWidget = registeredWidgets[widgetMap[type][widget]];
|
|
111
111
|
return getWidget(schema, registeredWidget, registeredWidgets);
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
-
throw new Error(`No widget '${widget}' for type '${type}'`);
|
|
114
|
+
throw new Error(`No widget '${widget}' for type '${type}' in schema: ${JSON.stringify(schema)}`);
|
|
115
115
|
}
|
|
116
116
|
//# sourceMappingURL=getWidget.js.map
|
package/lib/getWidget.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getWidget.js","sourceRoot":"","sources":["../src/getWidget.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,OAAO,MAAM,UAAU,CAAC;AAC/B,OAAO,GAAG,MAAM,YAAY,CAAC;AAC7B,OAAO,GAAG,MAAM,YAAY,CAAC;AAG7B,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C;GACG;AACH,MAAM,SAAS,GAA6C;IAC1D,OAAO,EAAE;QACP,QAAQ,EAAE,gBAAgB;QAC1B,KAAK,EAAE,aAAa;QACpB,MAAM,EAAE,cAAc;QACtB,MAAM,EAAE,cAAc;KACvB;IACD,MAAM,EAAE;QACN,IAAI,EAAE,YAAY;QAClB,QAAQ,EAAE,gBAAgB;QAC1B,KAAK,EAAE,aAAa;QACpB,QAAQ,EAAE,YAAY;QACtB,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,YAAY;QAClB,GAAG,EAAE,WAAW;QAChB,UAAU,EAAE,YAAY;QACxB,KAAK,EAAE,aAAa;QACpB,MAAM,EAAE,cAAc;QACtB,QAAQ,EAAE,gBAAgB;QAC1B,MAAM,EAAE,cAAc;QACtB,IAAI,EAAE,YAAY;QAClB,QAAQ,EAAE,gBAAgB;QAC1B,WAAW,EAAE,gBAAgB;QAC7B,UAAU,EAAE,eAAe;QAC3B,cAAc,EAAE,mBAAmB;QACnC,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,aAAa;QACpB,IAAI,EAAE,YAAY;KACnB;IACD,MAAM,EAAE;QACN,IAAI,EAAE,YAAY;QAClB,MAAM,EAAE,cA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|
1
|
-
import {
|
|
1
|
+
import { FieldPathId } from './types.js';
|
|
2
2
|
/** Return a consistent `id` for the field description element
|
|
3
3
|
*
|
|
4
|
-
* @param id - Either simple string id or an
|
|
4
|
+
* @param id - Either simple string id or an FieldPathId from which to extract it
|
|
5
5
|
* @returns - The consistent id for the field description element from the given `id`
|
|
6
6
|
*/
|
|
7
|
-
export declare function descriptionId
|
|
7
|
+
export declare function descriptionId(id: FieldPathId | string): string;
|
|
8
8
|
/** Return a consistent `id` for the field error element
|
|
9
9
|
*
|
|
10
|
-
* @param id - Either simple string id or an
|
|
10
|
+
* @param id - Either simple string id or an FieldPathId from which to extract it
|
|
11
11
|
* @returns - The consistent id for the field error element from the given `id`
|
|
12
12
|
*/
|
|
13
|
-
export declare function errorId
|
|
13
|
+
export declare function errorId(id: FieldPathId | string): string;
|
|
14
14
|
/** Return a consistent `id` for the field examples element
|
|
15
15
|
*
|
|
16
|
-
* @param id - Either simple string id or an
|
|
16
|
+
* @param id - Either simple string id or an FieldPathId from which to extract it
|
|
17
17
|
* @returns - The consistent id for the field examples element from the given `id`
|
|
18
18
|
*/
|
|
19
|
-
export declare function examplesId
|
|
19
|
+
export declare function examplesId(id: FieldPathId | string): string;
|
|
20
20
|
/** Return a consistent `id` for the field help element
|
|
21
21
|
*
|
|
22
|
-
* @param id - Either simple string id or an
|
|
22
|
+
* @param id - Either simple string id or an FieldPathId from which to extract it
|
|
23
23
|
* @returns - The consistent id for the field help element from the given `id`
|
|
24
24
|
*/
|
|
25
|
-
export declare function helpId
|
|
25
|
+
export declare function helpId(id: FieldPathId | string): string;
|
|
26
26
|
/** Return a consistent `id` for the field title element
|
|
27
27
|
*
|
|
28
|
-
* @param id - Either simple string id or an
|
|
28
|
+
* @param id - Either simple string id or an FieldPathId from which to extract it
|
|
29
29
|
* @returns - The consistent id for the field title element from the given `id`
|
|
30
30
|
*/
|
|
31
|
-
export declare function titleId
|
|
31
|
+
export declare function titleId(id: FieldPathId | string): string;
|
|
32
32
|
/** Return a list of element ids that contain additional information about the field that can be used to as the aria
|
|
33
33
|
* description of the field. This is correctly omitting `titleId` which would be "labeling" rather than "describing" the
|
|
34
34
|
* element.
|
|
35
35
|
*
|
|
36
|
-
* @param id - Either simple string id or an
|
|
36
|
+
* @param id - Either simple string id or an FieldPathId from which to extract it
|
|
37
37
|
* @param [includeExamples=false] - Optional flag, if true, will add the `examplesId` into the list
|
|
38
38
|
* @returns - The string containing the list of ids for use in an `aria-describedBy` attribute
|
|
39
39
|
*/
|
|
40
|
-
export declare function ariaDescribedByIds
|
|
40
|
+
export declare function ariaDescribedByIds(id: FieldPathId | string, includeExamples?: boolean): string;
|
|
41
41
|
/** Return a consistent `id` for the `optionIndex`s of a `Radio` or `Checkboxes` widget
|
|
42
42
|
*
|
|
43
43
|
* @param id - The id of the parent component for the option
|
|
@@ -47,8 +47,8 @@ export declare function ariaDescribedByIds<T = any>(id: IdSchema<T> | string, in
|
|
|
47
47
|
export declare function optionId(id: string, optionIndex: number): string;
|
|
48
48
|
/** Return a consistent `id` for the `btn` button element
|
|
49
49
|
*
|
|
50
|
-
* @param id - Either simple string id or an
|
|
50
|
+
* @param id - Either simple string id or an FieldPathId from which to extract it
|
|
51
51
|
* @param btn - The button type for which to generate the id
|
|
52
52
|
* @returns - The consistent id for the button from the given `id` and `btn` type
|
|
53
53
|
*/
|
|
54
|
-
export declare function buttonId
|
|
54
|
+
export declare function buttonId(id: FieldPathId | string, btn: 'add' | 'copy' | 'moveDown' | 'moveUp' | 'remove'): string;
|
package/lib/idGenerators.js
CHANGED
|
@@ -2,7 +2,7 @@ import isString from 'lodash-es/isString.js';
|
|
|
2
2
|
import { ID_KEY } from './constants.js';
|
|
3
3
|
/** Generates a consistent `id` pattern for a given `id` and a `suffix`
|
|
4
4
|
*
|
|
5
|
-
* @param id - Either simple string id or an
|
|
5
|
+
* @param id - Either simple string id or an FieldPathId from which to extract it
|
|
6
6
|
* @param suffix - The suffix to append to the id
|
|
7
7
|
*/
|
|
8
8
|
function idGenerator(id, suffix) {
|
|
@@ -11,7 +11,7 @@ function idGenerator(id, suffix) {
|
|
|
11
11
|
}
|
|
12
12
|
/** Return a consistent `id` for the field description element
|
|
13
13
|
*
|
|
14
|
-
* @param id - Either simple string id or an
|
|
14
|
+
* @param id - Either simple string id or an FieldPathId from which to extract it
|
|
15
15
|
* @returns - The consistent id for the field description element from the given `id`
|
|
16
16
|
*/
|
|
17
17
|
export function descriptionId(id) {
|
|
@@ -19,7 +19,7 @@ export function descriptionId(id) {
|
|
|
19
19
|
}
|
|
20
20
|
/** Return a consistent `id` for the field error element
|
|
21
21
|
*
|
|
22
|
-
* @param id - Either simple string id or an
|
|
22
|
+
* @param id - Either simple string id or an FieldPathId from which to extract it
|
|
23
23
|
* @returns - The consistent id for the field error element from the given `id`
|
|
24
24
|
*/
|
|
25
25
|
export function errorId(id) {
|
|
@@ -27,7 +27,7 @@ export function errorId(id) {
|
|
|
27
27
|
}
|
|
28
28
|
/** Return a consistent `id` for the field examples element
|
|
29
29
|
*
|
|
30
|
-
* @param id - Either simple string id or an
|
|
30
|
+
* @param id - Either simple string id or an FieldPathId from which to extract it
|
|
31
31
|
* @returns - The consistent id for the field examples element from the given `id`
|
|
32
32
|
*/
|
|
33
33
|
export function examplesId(id) {
|
|
@@ -35,7 +35,7 @@ export function examplesId(id) {
|
|
|
35
35
|
}
|
|
36
36
|
/** Return a consistent `id` for the field help element
|
|
37
37
|
*
|
|
38
|
-
* @param id - Either simple string id or an
|
|
38
|
+
* @param id - Either simple string id or an FieldPathId from which to extract it
|
|
39
39
|
* @returns - The consistent id for the field help element from the given `id`
|
|
40
40
|
*/
|
|
41
41
|
export function helpId(id) {
|
|
@@ -43,7 +43,7 @@ export function helpId(id) {
|
|
|
43
43
|
}
|
|
44
44
|
/** Return a consistent `id` for the field title element
|
|
45
45
|
*
|
|
46
|
-
* @param id - Either simple string id or an
|
|
46
|
+
* @param id - Either simple string id or an FieldPathId from which to extract it
|
|
47
47
|
* @returns - The consistent id for the field title element from the given `id`
|
|
48
48
|
*/
|
|
49
49
|
export function titleId(id) {
|
|
@@ -53,7 +53,7 @@ export function titleId(id) {
|
|
|
53
53
|
* description of the field. This is correctly omitting `titleId` which would be "labeling" rather than "describing" the
|
|
54
54
|
* element.
|
|
55
55
|
*
|
|
56
|
-
* @param id - Either simple string id or an
|
|
56
|
+
* @param id - Either simple string id or an FieldPathId from which to extract it
|
|
57
57
|
* @param [includeExamples=false] - Optional flag, if true, will add the `examplesId` into the list
|
|
58
58
|
* @returns - The string containing the list of ids for use in an `aria-describedBy` attribute
|
|
59
59
|
*/
|
|
@@ -72,7 +72,7 @@ export function optionId(id, optionIndex) {
|
|
|
72
72
|
}
|
|
73
73
|
/** Return a consistent `id` for the `btn` button element
|
|
74
74
|
*
|
|
75
|
-
* @param id - Either simple string id or an
|
|
75
|
+
* @param id - Either simple string id or an FieldPathId from which to extract it
|
|
76
76
|
* @param btn - The button type for which to generate the id
|
|
77
77
|
* @returns - The consistent id for the button from the given `id` and `btn` type
|
|
78
78
|
*/
|
package/lib/idGenerators.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idGenerators.js","sourceRoot":"","sources":["../src/idGenerators.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAGvC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;GAIG;AACH,SAAS,WAAW,
|
|
1
|
+
{"version":3,"file":"idGenerators.js","sourceRoot":"","sources":["../src/idGenerators.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAGvC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;GAIG;AACH,SAAS,WAAW,CAAC,EAAwB,EAAE,MAAc;IAC3D,MAAM,KAAK,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,C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AAC,CAAC;AAC9B,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import createSchemaUtils from './createSchemaUtils.js';
|
|
|
6
6
|
import dataURItoBlob from './dataURItoBlob.js';
|
|
7
7
|
import dateRangeOptions from './dateRangeOptions.js';
|
|
8
8
|
import deepEquals from './deepEquals.js';
|
|
9
|
+
import shallowEquals from './shallowEquals.js';
|
|
9
10
|
import englishStringTranslator from './englishStringTranslator.js';
|
|
10
11
|
import enumOptionsDeselectValue from './enumOptionsDeselectValue.js';
|
|
11
12
|
import enumOptionsIndexForValue from './enumOptionsIndexForValue.js';
|
|
@@ -49,6 +50,7 @@ import toConstant from './toConstant.js';
|
|
|
49
50
|
import toDateString from './toDateString.js';
|
|
50
51
|
import toErrorList from './toErrorList.js';
|
|
51
52
|
import toErrorSchema from './toErrorSchema.js';
|
|
53
|
+
import toFieldPathId from './toFieldPathId.js';
|
|
52
54
|
import unwrapErrorHandler from './unwrapErrorHandler.js';
|
|
53
55
|
import utcToLocal from './utcToLocal.js';
|
|
54
56
|
import validationDataMerge from './validationDataMerge.js';
|
|
@@ -60,4 +62,5 @@ export * from './enums.js';
|
|
|
60
62
|
export * from './constants.js';
|
|
61
63
|
export * from './parser/index.js';
|
|
62
64
|
export * from './schema/index.js';
|
|
63
|
-
export { allowAdditionalItems, ariaDescribedByIds, asNumber, buttonId, canExpand, createErrorHandler, createSchemaUtils, DateElementFormat, dataURItoBlob, dateRangeOptions, deepEquals, descriptionId, englishStringTranslator, enumOptionsDeselectValue, enumOptionsIndexForValue, enumOptionsIsSelected, enumOptionsSelectValue, enumOptionsValueForIndex, errorId, examplesId, ErrorSchemaBuilder, findSchemaDefinition, getChangedFields, getDateElementProps, getDiscriminatorFieldFromSchema, getInputProps, getOptionMatchingSimpleDiscriminator, getSchemaType, getSubmitButtonOptions, getTemplate, getTestIds, getUiOptions, getWidget, guessType, hasWidget, hashForSchema, hashObject, hashString, helpId, isConstant, isCustomWidget, isFixedItems, isObject, labelValue, localToUTC, lookupFromFormContext, mergeDefaultsWithFormData, mergeObjects, mergeSchemas, optionId, optionsList, orderProperties, pad, parseDateString, rangeSpec, replaceStringParameters, schemaRequiresTrueValue, shouldRender, sortedJSONStringify, titleId, toConstant, toDateString, toErrorList, toErrorSchema, unwrapErrorHandler, utcToLocal, validationDataMerge, withIdRefPrefix, };
|
|
65
|
+
export { allowAdditionalItems, ariaDescribedByIds, asNumber, buttonId, canExpand, createErrorHandler, createSchemaUtils, DateElementFormat, dataURItoBlob, dateRangeOptions, deepEquals, descriptionId, englishStringTranslator, enumOptionsDeselectValue, enumOptionsIndexForValue, enumOptionsIsSelected, enumOptionsSelectValue, enumOptionsValueForIndex, errorId, examplesId, ErrorSchemaBuilder, findSchemaDefinition, getChangedFields, getDateElementProps, getDiscriminatorFieldFromSchema, getInputProps, getOptionMatchingSimpleDiscriminator, getSchemaType, getSubmitButtonOptions, getTemplate, getTestIds, getUiOptions, getWidget, guessType, hasWidget, hashForSchema, hashObject, hashString, helpId, isConstant, isCustomWidget, isFixedItems, isObject, labelValue, localToUTC, lookupFromFormContext, mergeDefaultsWithFormData, mergeObjects, mergeSchemas, optionId, optionsList, orderProperties, pad, parseDateString, rangeSpec, replaceStringParameters, schemaRequiresTrueValue, shallowEquals, shouldRender, sortedJSONStringify, titleId, toConstant, toDateString, toErrorList, toErrorSchema, toFieldPathId, unwrapErrorHandler, utcToLocal, validationDataMerge, withIdRefPrefix, };
|
|
66
|
+
export type { ComponentUpdateStrategy } from './shouldRender.js';
|
package/lib/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import createSchemaUtils from './createSchemaUtils.js';
|
|
|
6
6
|
import dataURItoBlob from './dataURItoBlob.js';
|
|
7
7
|
import dateRangeOptions from './dateRangeOptions.js';
|
|
8
8
|
import deepEquals from './deepEquals.js';
|
|
9
|
+
import shallowEquals from './shallowEquals.js';
|
|
9
10
|
import englishStringTranslator from './englishStringTranslator.js';
|
|
10
11
|
import enumOptionsDeselectValue from './enumOptionsDeselectValue.js';
|
|
11
12
|
import enumOptionsIndexForValue from './enumOptionsIndexForValue.js';
|
|
@@ -49,6 +50,7 @@ import toConstant from './toConstant.js';
|
|
|
49
50
|
import toDateString from './toDateString.js';
|
|
50
51
|
import toErrorList from './toErrorList.js';
|
|
51
52
|
import toErrorSchema from './toErrorSchema.js';
|
|
53
|
+
import toFieldPathId from './toFieldPathId.js';
|
|
52
54
|
import unwrapErrorHandler from './unwrapErrorHandler.js';
|
|
53
55
|
import utcToLocal from './utcToLocal.js';
|
|
54
56
|
import validationDataMerge from './validationDataMerge.js';
|
|
@@ -60,5 +62,5 @@ export * from './enums.js';
|
|
|
60
62
|
export * from './constants.js';
|
|
61
63
|
export * from './parser/index.js';
|
|
62
64
|
export * from './schema/index.js';
|
|
63
|
-
export { allowAdditionalItems, ariaDescribedByIds, asNumber, buttonId, canExpand, createErrorHandler, createSchemaUtils, dataURItoBlob, dateRangeOptions, deepEquals, descriptionId, englishStringTranslator, enumOptionsDeselectValue, enumOptionsIndexForValue, enumOptionsIsSelected, enumOptionsSelectValue, enumOptionsValueForIndex, errorId, examplesId, ErrorSchemaBuilder, findSchemaDefinition, getChangedFields, getDateElementProps, getDiscriminatorFieldFromSchema, getInputProps, getOptionMatchingSimpleDiscriminator, getSchemaType, getSubmitButtonOptions, getTemplate, getTestIds, getUiOptions, getWidget, guessType, hasWidget, hashForSchema, hashObject, hashString, helpId, isConstant, isCustomWidget, isFixedItems, isObject, labelValue, localToUTC, lookupFromFormContext, mergeDefaultsWithFormData, mergeObjects, mergeSchemas, optionId, optionsList, orderProperties, pad, parseDateString, rangeSpec, replaceStringParameters, schemaRequiresTrueValue, shouldRender, sortedJSONStringify, titleId, toConstant, toDateString, toErrorList, toErrorSchema, unwrapErrorHandler, utcToLocal, validationDataMerge, withIdRefPrefix, };
|
|
65
|
+
export { allowAdditionalItems, ariaDescribedByIds, asNumber, buttonId, canExpand, createErrorHandler, createSchemaUtils, dataURItoBlob, dateRangeOptions, deepEquals, descriptionId, englishStringTranslator, enumOptionsDeselectValue, enumOptionsIndexForValue, enumOptionsIsSelected, enumOptionsSelectValue, enumOptionsValueForIndex, errorId, examplesId, ErrorSchemaBuilder, findSchemaDefinition, getChangedFields, getDateElementProps, getDiscriminatorFieldFromSchema, getInputProps, getOptionMatchingSimpleDiscriminator, getSchemaType, getSubmitButtonOptions, getTemplate, getTestIds, getUiOptions, getWidget, guessType, hasWidget, hashForSchema, hashObject, hashString, helpId, isConstant, isCustomWidget, isFixedItems, isObject, labelValue, localToUTC, lookupFromFormContext, mergeDefaultsWithFormData, mergeObjects, mergeSchemas, optionId, optionsList, orderProperties, pad, parseDateString, rangeSpec, replaceStringParameters, schemaRequiresTrueValue, shallowEquals, shouldRender, sortedJSONStringify, titleId, toConstant, toDateString, toErrorList, toErrorSchema, toFieldPathId, unwrapErrorHandler, utcToLocal, validationDataMerge, withIdRefPrefix, };
|
|
64
66
|
//# sourceMappingURL=index.js.map
|