@rjsf/utils 5.19.3 → 5.20.0
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 +36 -12
- package/dist/index.js.map +2 -2
- package/dist/utils.esm.js +36 -12
- package/dist/utils.esm.js.map +2 -2
- package/dist/utils.umd.js +36 -12
- package/lib/enums.d.ts +15 -8
- package/lib/enums.js +15 -8
- package/lib/enums.js.map +1 -1
- package/lib/optionsList.d.ts +7 -4
- package/lib/optionsList.js +35 -12
- package/lib/optionsList.js.map +1 -1
- package/lib/parser/ParserValidator.d.ts +3 -0
- package/lib/parser/ParserValidator.js +5 -0
- package/lib/parser/ParserValidator.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types.d.ts +7 -1
- package/package.json +2 -2
- package/src/enums.ts +15 -8
- package/src/optionsList.ts +39 -14
- package/src/parser/ParserValidator.ts +6 -0
- package/src/types.ts +7 -1
package/dist/utils.umd.js
CHANGED
|
@@ -2155,22 +2155,41 @@
|
|
|
2155
2155
|
}
|
|
2156
2156
|
|
|
2157
2157
|
// src/optionsList.ts
|
|
2158
|
-
function optionsList(schema) {
|
|
2158
|
+
function optionsList(schema, uiSchema) {
|
|
2159
2159
|
const schemaWithEnumNames = schema;
|
|
2160
|
-
if (schemaWithEnumNames.enumNames && true) {
|
|
2161
|
-
console.warn("The enumNames property is deprecated and may be removed in a future major release.");
|
|
2162
|
-
}
|
|
2163
2160
|
if (schema.enum) {
|
|
2161
|
+
let enumNames;
|
|
2162
|
+
if (uiSchema) {
|
|
2163
|
+
const { enumNames: uiEnumNames } = getUiOptions(uiSchema);
|
|
2164
|
+
enumNames = uiEnumNames;
|
|
2165
|
+
}
|
|
2166
|
+
if (!enumNames && schemaWithEnumNames.enumNames) {
|
|
2167
|
+
{
|
|
2168
|
+
console.warn(
|
|
2169
|
+
'The "enumNames" property in the schema is deprecated and will be removed in a future major release. Use the "ui:enumNames" property in the uiSchema instead.'
|
|
2170
|
+
);
|
|
2171
|
+
}
|
|
2172
|
+
enumNames = schemaWithEnumNames.enumNames;
|
|
2173
|
+
}
|
|
2164
2174
|
return schema.enum.map((value, i) => {
|
|
2165
|
-
const label =
|
|
2175
|
+
const label = enumNames?.[i] || String(value);
|
|
2166
2176
|
return { label, value };
|
|
2167
2177
|
});
|
|
2168
2178
|
}
|
|
2169
|
-
|
|
2170
|
-
|
|
2179
|
+
let altSchemas = void 0;
|
|
2180
|
+
let altUiSchemas = void 0;
|
|
2181
|
+
if (schema.anyOf) {
|
|
2182
|
+
altSchemas = schema.anyOf;
|
|
2183
|
+
altUiSchemas = uiSchema?.anyOf;
|
|
2184
|
+
} else if (schema.oneOf) {
|
|
2185
|
+
altSchemas = schema.oneOf;
|
|
2186
|
+
altUiSchemas = uiSchema?.oneOf;
|
|
2187
|
+
}
|
|
2188
|
+
return altSchemas && altSchemas.map((aSchemaDef, index) => {
|
|
2189
|
+
const { title } = getUiOptions(altUiSchemas?.[index]);
|
|
2171
2190
|
const aSchema = aSchemaDef;
|
|
2172
2191
|
const value = toConstant(aSchema);
|
|
2173
|
-
const label = aSchema.title || String(value);
|
|
2192
|
+
const label = title || aSchema.title || String(value);
|
|
2174
2193
|
return {
|
|
2175
2194
|
schema: aSchema,
|
|
2176
2195
|
label,
|
|
@@ -2410,11 +2429,11 @@
|
|
|
2410
2429
|
TranslatableString2["OptionPrefix"] = "Option %1";
|
|
2411
2430
|
TranslatableString2["TitleOptionPrefix"] = "%1 option %2";
|
|
2412
2431
|
TranslatableString2["KeyLabel"] = "%1 Key";
|
|
2413
|
-
TranslatableString2["InvalidObjectField"] = 'Invalid "%1" object field configuration:
|
|
2432
|
+
TranslatableString2["InvalidObjectField"] = 'Invalid "%1" object field configuration: _%2_.';
|
|
2414
2433
|
TranslatableString2["UnsupportedField"] = "Unsupported field schema.";
|
|
2415
|
-
TranslatableString2["UnsupportedFieldWithId"] = "Unsupported field schema for field
|
|
2416
|
-
TranslatableString2["UnsupportedFieldWithReason"] = "Unsupported field schema:
|
|
2417
|
-
TranslatableString2["UnsupportedFieldWithIdAndReason"] = "Unsupported field schema for field
|
|
2434
|
+
TranslatableString2["UnsupportedFieldWithId"] = "Unsupported field schema for field `%1`.";
|
|
2435
|
+
TranslatableString2["UnsupportedFieldWithReason"] = "Unsupported field schema: _%1_.";
|
|
2436
|
+
TranslatableString2["UnsupportedFieldWithIdAndReason"] = "Unsupported field schema for field `%1`: _%2_.";
|
|
2418
2437
|
TranslatableString2["FilesInfo"] = "**%1** (%2, %3 bytes)";
|
|
2419
2438
|
return TranslatableString2;
|
|
2420
2439
|
})(TranslatableString || {});
|
|
@@ -2430,6 +2449,11 @@
|
|
|
2430
2449
|
this.rootSchema = rootSchema;
|
|
2431
2450
|
this.addSchema(rootSchema, hashForSchema(rootSchema));
|
|
2432
2451
|
}
|
|
2452
|
+
/** Resets the internal AJV validator to clear schemas from it. Can be helpful for resetting the validator for tests.
|
|
2453
|
+
*/
|
|
2454
|
+
reset() {
|
|
2455
|
+
this.schemaMap = {};
|
|
2456
|
+
}
|
|
2433
2457
|
/** Adds the given `schema` to the `schemaMap` keyed by the `hash` or `ID_KEY` if present on the `schema`. If the
|
|
2434
2458
|
* schema does not have an `ID_KEY`, then the `hash` will be added as the `ID_KEY` to allow the schema to be
|
|
2435
2459
|
* associated with it's `hash` for future use (by a schema compiler).
|
package/lib/enums.d.ts
CHANGED
|
@@ -53,18 +53,25 @@ export declare enum TranslatableString {
|
|
|
53
53
|
TitleOptionPrefix = "%1 option %2",
|
|
54
54
|
/** Key label, where %1 will be replaced by the label as provided by WrapIfAdditionalTemplate */
|
|
55
55
|
KeyLabel = "%1 Key",
|
|
56
|
-
/** Invalid object field configuration as provided by the ObjectField
|
|
57
|
-
|
|
56
|
+
/** Invalid object field configuration as provided by the ObjectField.
|
|
57
|
+
* NOTE: Use markdown notation rather than html tags.
|
|
58
|
+
*/
|
|
59
|
+
InvalidObjectField = "Invalid \"%1\" object field configuration: _%2_.",
|
|
58
60
|
/** Unsupported field schema, used by UnsupportedField */
|
|
59
61
|
UnsupportedField = "Unsupported field schema.",
|
|
60
|
-
/** Unsupported field schema, where %1 will be replaced by the idSchema.$id as provided by UnsupportedField
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
/** Unsupported field schema, where %1 will be replaced by the idSchema.$id as provided by UnsupportedField.
|
|
63
|
+
* NOTE: Use markdown notation rather than html tags.
|
|
64
|
+
*/
|
|
65
|
+
UnsupportedFieldWithId = "Unsupported field schema for field `%1`.",
|
|
66
|
+
/** Unsupported field schema, where %1 will be replaced by the reason string as provided by UnsupportedField.
|
|
67
|
+
* NOTE: Use markdown notation rather than html tags.
|
|
68
|
+
*/
|
|
69
|
+
UnsupportedFieldWithReason = "Unsupported field schema: _%1_.",
|
|
64
70
|
/** Unsupported field schema, where %1 and %2 will be replaced by the idSchema.$id and reason strings, respectively,
|
|
65
|
-
* as provided by UnsupportedField
|
|
71
|
+
* as provided by UnsupportedField.
|
|
72
|
+
* NOTE: Use markdown notation rather than html tags.
|
|
66
73
|
*/
|
|
67
|
-
UnsupportedFieldWithIdAndReason = "Unsupported field schema for field
|
|
74
|
+
UnsupportedFieldWithIdAndReason = "Unsupported field schema for field `%1`: _%2_.",
|
|
68
75
|
/** File name, type and size info, where %1, %2 and %3 will be replaced by the file name, file type and file size as
|
|
69
76
|
* provided by FileWidget
|
|
70
77
|
*/
|
package/lib/enums.js
CHANGED
|
@@ -56,18 +56,25 @@ export var TranslatableString;
|
|
|
56
56
|
/** Key label, where %1 will be replaced by the label as provided by WrapIfAdditionalTemplate */
|
|
57
57
|
TranslatableString["KeyLabel"] = "%1 Key";
|
|
58
58
|
// Strings with replaceable parameters AND/OR that support markdown and html
|
|
59
|
-
/** Invalid object field configuration as provided by the ObjectField
|
|
60
|
-
|
|
59
|
+
/** Invalid object field configuration as provided by the ObjectField.
|
|
60
|
+
* NOTE: Use markdown notation rather than html tags.
|
|
61
|
+
*/
|
|
62
|
+
TranslatableString["InvalidObjectField"] = "Invalid \"%1\" object field configuration: _%2_.";
|
|
61
63
|
/** Unsupported field schema, used by UnsupportedField */
|
|
62
64
|
TranslatableString["UnsupportedField"] = "Unsupported field schema.";
|
|
63
|
-
/** Unsupported field schema, where %1 will be replaced by the idSchema.$id as provided by UnsupportedField
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
TranslatableString["
|
|
65
|
+
/** Unsupported field schema, where %1 will be replaced by the idSchema.$id as provided by UnsupportedField.
|
|
66
|
+
* NOTE: Use markdown notation rather than html tags.
|
|
67
|
+
*/
|
|
68
|
+
TranslatableString["UnsupportedFieldWithId"] = "Unsupported field schema for field `%1`.";
|
|
69
|
+
/** Unsupported field schema, where %1 will be replaced by the reason string as provided by UnsupportedField.
|
|
70
|
+
* NOTE: Use markdown notation rather than html tags.
|
|
71
|
+
*/
|
|
72
|
+
TranslatableString["UnsupportedFieldWithReason"] = "Unsupported field schema: _%1_.";
|
|
67
73
|
/** Unsupported field schema, where %1 and %2 will be replaced by the idSchema.$id and reason strings, respectively,
|
|
68
|
-
* as provided by UnsupportedField
|
|
74
|
+
* as provided by UnsupportedField.
|
|
75
|
+
* NOTE: Use markdown notation rather than html tags.
|
|
69
76
|
*/
|
|
70
|
-
TranslatableString["UnsupportedFieldWithIdAndReason"] = "Unsupported field schema for field
|
|
77
|
+
TranslatableString["UnsupportedFieldWithIdAndReason"] = "Unsupported field schema for field `%1`: _%2_.";
|
|
71
78
|
/** File name, type and size info, where %1, %2 and %3 will be replaced by the file name, file type and file size as
|
|
72
79
|
* provided by FileWidget
|
|
73
80
|
*/
|
package/lib/enums.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../src/enums.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../src/enums.ts"],"names":[],"mappings":"AAAA;;;;;GAK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chema, EnumOptionsType, StrictRJSFSchema } from './types';
|
|
2
|
-
/** Gets the list of options from the schema
|
|
1
|
+
import { RJSFSchema, EnumOptionsType, StrictRJSFSchema, FormContextType, UiSchema } from './types';
|
|
2
|
+
/** Gets the list of options from the `schema`. If the schema has an enum list, then those enum values are returned. The
|
|
3
3
|
* labels for the options will be extracted from the non-standard, RJSF-deprecated `enumNames` if it exists, otherwise
|
|
4
4
|
* the label will be the same as the `value`. If the schema has a `oneOf` or `anyOf`, then the value is the list of
|
|
5
|
-
* `const` values from the schema and the label is either the `schema.title` or the value.
|
|
5
|
+
* `const` values from the schema and the label is either the `schema.title` or the value. If a `uiSchema` is provided
|
|
6
|
+
* and it has the `ui:enumNames` matched with `enum` or it has an associated `oneOf` or `anyOf` with a list of objects
|
|
7
|
+
* containing `ui:title` then the UI schema values will replace the values from the schema.
|
|
6
8
|
*
|
|
7
9
|
* @param schema - The schema from which to extract the options list
|
|
10
|
+
* @param [uiSchema] - The optional uiSchema from which to get alternate labels for the options
|
|
8
11
|
* @returns - The list of options from the schema
|
|
9
12
|
*/
|
|
10
|
-
export default function optionsList<S extends StrictRJSFSchema = RJSFSchema>(schema: S): EnumOptionsType<S>[] | undefined;
|
|
13
|
+
export default function optionsList<S extends StrictRJSFSchema = RJSFSchema, T = any, F extends FormContextType = any>(schema: S, uiSchema?: UiSchema<T, S, F>): EnumOptionsType<S>[] | undefined;
|
package/lib/optionsList.js
CHANGED
|
@@ -1,31 +1,54 @@
|
|
|
1
1
|
import toConstant from './toConstant';
|
|
2
|
-
|
|
2
|
+
import getUiOptions from './getUiOptions';
|
|
3
|
+
/** Gets the list of options from the `schema`. If the schema has an enum list, then those enum values are returned. The
|
|
3
4
|
* labels for the options will be extracted from the non-standard, RJSF-deprecated `enumNames` if it exists, otherwise
|
|
4
5
|
* the label will be the same as the `value`. If the schema has a `oneOf` or `anyOf`, then the value is the list of
|
|
5
|
-
* `const` values from the schema and the label is either the `schema.title` or the value.
|
|
6
|
+
* `const` values from the schema and the label is either the `schema.title` or the value. If a `uiSchema` is provided
|
|
7
|
+
* and it has the `ui:enumNames` matched with `enum` or it has an associated `oneOf` or `anyOf` with a list of objects
|
|
8
|
+
* containing `ui:title` then the UI schema values will replace the values from the schema.
|
|
6
9
|
*
|
|
7
10
|
* @param schema - The schema from which to extract the options list
|
|
11
|
+
* @param [uiSchema] - The optional uiSchema from which to get alternate labels for the options
|
|
8
12
|
* @returns - The list of options from the schema
|
|
9
13
|
*/
|
|
10
|
-
export default function optionsList(schema) {
|
|
11
|
-
//
|
|
12
|
-
// Cast the type to include enumNames so the feature still works.
|
|
14
|
+
export default function optionsList(schema, uiSchema) {
|
|
15
|
+
// TODO flip generics to move T first in v6
|
|
13
16
|
const schemaWithEnumNames = schema;
|
|
14
|
-
if (schemaWithEnumNames.enumNames && process.env.NODE_ENV !== 'production') {
|
|
15
|
-
console.warn('The enumNames property is deprecated and may be removed in a future major release.');
|
|
16
|
-
}
|
|
17
17
|
if (schema.enum) {
|
|
18
|
+
let enumNames;
|
|
19
|
+
if (uiSchema) {
|
|
20
|
+
const { enumNames: uiEnumNames } = getUiOptions(uiSchema);
|
|
21
|
+
enumNames = uiEnumNames;
|
|
22
|
+
}
|
|
23
|
+
if (!enumNames && schemaWithEnumNames.enumNames) {
|
|
24
|
+
// enumNames was deprecated in v5 and is intentionally omitted from the RJSFSchema type.
|
|
25
|
+
// Cast the type to include enumNames so the feature still works.
|
|
26
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
27
|
+
console.warn('The "enumNames" property in the schema is deprecated and will be removed in a future major release. Use the "ui:enumNames" property in the uiSchema instead.');
|
|
28
|
+
}
|
|
29
|
+
enumNames = schemaWithEnumNames.enumNames;
|
|
30
|
+
}
|
|
18
31
|
return schema.enum.map((value, i) => {
|
|
19
|
-
const label = (
|
|
32
|
+
const label = (enumNames === null || enumNames === void 0 ? void 0 : enumNames[i]) || String(value);
|
|
20
33
|
return { label, value };
|
|
21
34
|
});
|
|
22
35
|
}
|
|
23
|
-
|
|
36
|
+
let altSchemas = undefined;
|
|
37
|
+
let altUiSchemas = undefined;
|
|
38
|
+
if (schema.anyOf) {
|
|
39
|
+
altSchemas = schema.anyOf;
|
|
40
|
+
altUiSchemas = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema.anyOf;
|
|
41
|
+
}
|
|
42
|
+
else if (schema.oneOf) {
|
|
43
|
+
altSchemas = schema.oneOf;
|
|
44
|
+
altUiSchemas = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema.oneOf;
|
|
45
|
+
}
|
|
24
46
|
return (altSchemas &&
|
|
25
|
-
altSchemas.map((aSchemaDef) => {
|
|
47
|
+
altSchemas.map((aSchemaDef, index) => {
|
|
48
|
+
const { title } = getUiOptions(altUiSchemas === null || altUiSchemas === void 0 ? void 0 : altUiSchemas[index]);
|
|
26
49
|
const aSchema = aSchemaDef;
|
|
27
50
|
const value = toConstant(aSchema);
|
|
28
|
-
const label = aSchema.title || String(value);
|
|
51
|
+
const label = title || aSchema.title || String(value);
|
|
29
52
|
return {
|
|
30
53
|
schema: aSchema,
|
|
31
54
|
label,
|
package/lib/optionsList.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optionsList.js","sourceRoot":"","sources":["../src/optionsList.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"optionsList.js","sourceRoot":"","sources":["../src/optionsList.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CACjC,MAAS,EACT,QAA4B;IAE5B,2CAA2C;IAC3C,MAAM,mBAAmB,GAAG,MAAsC,CAAC;IACnE,IAAI,MAAM,CAAC,IAAI,EAAE;QACf,IAAI,SAA+B,CAAC;QACpC,IAAI,QAAQ,EAAE;YACZ,MA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,MAAM,OAAO,GAAG,UAAe,CAAC;YAChC,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;YAClC,MAAM,KAAK,GAAG,KAAK,IAAI,OAAO,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;YACtD,OAAO;gBACL,MAAM,EAAE,OAAO;gBACf,KAAK;gBACL,KAAK;aACN,CAAC;QACJ,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -22,6 +22,9 @@ export default class ParserValidator<T = any, S extends StrictRJSFSchema = RJSFS
|
|
|
22
22
|
* @param rootSchema - The root schema against which this validator will be executed
|
|
23
23
|
*/
|
|
24
24
|
constructor(rootSchema: S);
|
|
25
|
+
/** Resets the internal AJV validator to clear schemas from it. Can be helpful for resetting the validator for tests.
|
|
26
|
+
*/
|
|
27
|
+
reset(): void;
|
|
25
28
|
/** Adds the given `schema` to the `schemaMap` keyed by the `hash` or `ID_KEY` if present on the `schema`. If the
|
|
26
29
|
* schema does not have an `ID_KEY`, then the `hash` will be added as the `ID_KEY` to allow the schema to be
|
|
27
30
|
* associated with it's `hash` for future use (by a schema compiler).
|
|
@@ -21,6 +21,11 @@ export default class ParserValidator {
|
|
|
21
21
|
this.rootSchema = rootSchema;
|
|
22
22
|
this.addSchema(rootSchema, hashForSchema(rootSchema));
|
|
23
23
|
}
|
|
24
|
+
/** Resets the internal AJV validator to clear schemas from it. Can be helpful for resetting the validator for tests.
|
|
25
|
+
*/
|
|
26
|
+
reset() {
|
|
27
|
+
this.schemaMap = {};
|
|
28
|
+
}
|
|
24
29
|
/** Adds the given `schema` to the `schemaMap` keyed by the `hash` or `ID_KEY` if present on the `schema`. If the
|
|
25
30
|
* schema does not have an `ID_KEY`, then the `hash` will be added as the `ID_KEY` to allow the schema to be
|
|
26
31
|
* associated with it's `hash` for future use (by a schema compiler).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParserValidator.js","sourceRoot":"","sources":["../../src/parser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