@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.esm.js
CHANGED
|
@@ -2241,22 +2241,41 @@ function toConstant(schema) {
|
|
|
2241
2241
|
}
|
|
2242
2242
|
|
|
2243
2243
|
// src/optionsList.ts
|
|
2244
|
-
function optionsList(schema) {
|
|
2244
|
+
function optionsList(schema, uiSchema) {
|
|
2245
2245
|
const schemaWithEnumNames = schema;
|
|
2246
|
-
if (schemaWithEnumNames.enumNames && true) {
|
|
2247
|
-
console.warn("The enumNames property is deprecated and may be removed in a future major release.");
|
|
2248
|
-
}
|
|
2249
2246
|
if (schema.enum) {
|
|
2247
|
+
let enumNames;
|
|
2248
|
+
if (uiSchema) {
|
|
2249
|
+
const { enumNames: uiEnumNames } = getUiOptions(uiSchema);
|
|
2250
|
+
enumNames = uiEnumNames;
|
|
2251
|
+
}
|
|
2252
|
+
if (!enumNames && schemaWithEnumNames.enumNames) {
|
|
2253
|
+
if (true) {
|
|
2254
|
+
console.warn(
|
|
2255
|
+
'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.'
|
|
2256
|
+
);
|
|
2257
|
+
}
|
|
2258
|
+
enumNames = schemaWithEnumNames.enumNames;
|
|
2259
|
+
}
|
|
2250
2260
|
return schema.enum.map((value, i) => {
|
|
2251
|
-
const label =
|
|
2261
|
+
const label = enumNames?.[i] || String(value);
|
|
2252
2262
|
return { label, value };
|
|
2253
2263
|
});
|
|
2254
2264
|
}
|
|
2255
|
-
|
|
2256
|
-
|
|
2265
|
+
let altSchemas = void 0;
|
|
2266
|
+
let altUiSchemas = void 0;
|
|
2267
|
+
if (schema.anyOf) {
|
|
2268
|
+
altSchemas = schema.anyOf;
|
|
2269
|
+
altUiSchemas = uiSchema?.anyOf;
|
|
2270
|
+
} else if (schema.oneOf) {
|
|
2271
|
+
altSchemas = schema.oneOf;
|
|
2272
|
+
altUiSchemas = uiSchema?.oneOf;
|
|
2273
|
+
}
|
|
2274
|
+
return altSchemas && altSchemas.map((aSchemaDef, index) => {
|
|
2275
|
+
const { title } = getUiOptions(altUiSchemas?.[index]);
|
|
2257
2276
|
const aSchema = aSchemaDef;
|
|
2258
2277
|
const value = toConstant(aSchema);
|
|
2259
|
-
const label = aSchema.title || String(value);
|
|
2278
|
+
const label = title || aSchema.title || String(value);
|
|
2260
2279
|
return {
|
|
2261
2280
|
schema: aSchema,
|
|
2262
2281
|
label,
|
|
@@ -2511,11 +2530,11 @@ var TranslatableString = /* @__PURE__ */ ((TranslatableString2) => {
|
|
|
2511
2530
|
TranslatableString2["OptionPrefix"] = "Option %1";
|
|
2512
2531
|
TranslatableString2["TitleOptionPrefix"] = "%1 option %2";
|
|
2513
2532
|
TranslatableString2["KeyLabel"] = "%1 Key";
|
|
2514
|
-
TranslatableString2["InvalidObjectField"] = 'Invalid "%1" object field configuration:
|
|
2533
|
+
TranslatableString2["InvalidObjectField"] = 'Invalid "%1" object field configuration: _%2_.';
|
|
2515
2534
|
TranslatableString2["UnsupportedField"] = "Unsupported field schema.";
|
|
2516
|
-
TranslatableString2["UnsupportedFieldWithId"] = "Unsupported field schema for field
|
|
2517
|
-
TranslatableString2["UnsupportedFieldWithReason"] = "Unsupported field schema:
|
|
2518
|
-
TranslatableString2["UnsupportedFieldWithIdAndReason"] = "Unsupported field schema for field
|
|
2535
|
+
TranslatableString2["UnsupportedFieldWithId"] = "Unsupported field schema for field `%1`.";
|
|
2536
|
+
TranslatableString2["UnsupportedFieldWithReason"] = "Unsupported field schema: _%1_.";
|
|
2537
|
+
TranslatableString2["UnsupportedFieldWithIdAndReason"] = "Unsupported field schema for field `%1`: _%2_.";
|
|
2519
2538
|
TranslatableString2["FilesInfo"] = "**%1** (%2, %3 bytes)";
|
|
2520
2539
|
return TranslatableString2;
|
|
2521
2540
|
})(TranslatableString || {});
|
|
@@ -2539,6 +2558,11 @@ var ParserValidator = class {
|
|
|
2539
2558
|
this.rootSchema = rootSchema;
|
|
2540
2559
|
this.addSchema(rootSchema, hashForSchema(rootSchema));
|
|
2541
2560
|
}
|
|
2561
|
+
/** Resets the internal AJV validator to clear schemas from it. Can be helpful for resetting the validator for tests.
|
|
2562
|
+
*/
|
|
2563
|
+
reset() {
|
|
2564
|
+
this.schemaMap = {};
|
|
2565
|
+
}
|
|
2542
2566
|
/** Adds the given `schema` to the `schemaMap` keyed by the `hash` or `ID_KEY` if present on the `schema`. If the
|
|
2543
2567
|
* schema does not have an `ID_KEY`, then the `hash` will be added as the `ID_KEY` to allow the schema to be
|
|
2544
2568
|
* associated with it's `hash` for future use (by a schema compiler).
|