@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/index.js
CHANGED
|
@@ -2378,22 +2378,41 @@ function toConstant(schema) {
|
|
|
2378
2378
|
}
|
|
2379
2379
|
|
|
2380
2380
|
// src/optionsList.ts
|
|
2381
|
-
function optionsList(schema) {
|
|
2381
|
+
function optionsList(schema, uiSchema) {
|
|
2382
2382
|
const schemaWithEnumNames = schema;
|
|
2383
|
-
if (schemaWithEnumNames.enumNames && true) {
|
|
2384
|
-
console.warn("The enumNames property is deprecated and may be removed in a future major release.");
|
|
2385
|
-
}
|
|
2386
2383
|
if (schema.enum) {
|
|
2384
|
+
let enumNames;
|
|
2385
|
+
if (uiSchema) {
|
|
2386
|
+
const { enumNames: uiEnumNames } = getUiOptions(uiSchema);
|
|
2387
|
+
enumNames = uiEnumNames;
|
|
2388
|
+
}
|
|
2389
|
+
if (!enumNames && schemaWithEnumNames.enumNames) {
|
|
2390
|
+
if (true) {
|
|
2391
|
+
console.warn(
|
|
2392
|
+
'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.'
|
|
2393
|
+
);
|
|
2394
|
+
}
|
|
2395
|
+
enumNames = schemaWithEnumNames.enumNames;
|
|
2396
|
+
}
|
|
2387
2397
|
return schema.enum.map((value, i) => {
|
|
2388
|
-
const label =
|
|
2398
|
+
const label = enumNames?.[i] || String(value);
|
|
2389
2399
|
return { label, value };
|
|
2390
2400
|
});
|
|
2391
2401
|
}
|
|
2392
|
-
|
|
2393
|
-
|
|
2402
|
+
let altSchemas = void 0;
|
|
2403
|
+
let altUiSchemas = void 0;
|
|
2404
|
+
if (schema.anyOf) {
|
|
2405
|
+
altSchemas = schema.anyOf;
|
|
2406
|
+
altUiSchemas = uiSchema?.anyOf;
|
|
2407
|
+
} else if (schema.oneOf) {
|
|
2408
|
+
altSchemas = schema.oneOf;
|
|
2409
|
+
altUiSchemas = uiSchema?.oneOf;
|
|
2410
|
+
}
|
|
2411
|
+
return altSchemas && altSchemas.map((aSchemaDef, index) => {
|
|
2412
|
+
const { title } = getUiOptions(altUiSchemas?.[index]);
|
|
2394
2413
|
const aSchema = aSchemaDef;
|
|
2395
2414
|
const value = toConstant(aSchema);
|
|
2396
|
-
const label = aSchema.title || String(value);
|
|
2415
|
+
const label = title || aSchema.title || String(value);
|
|
2397
2416
|
return {
|
|
2398
2417
|
schema: aSchema,
|
|
2399
2418
|
label,
|
|
@@ -2648,11 +2667,11 @@ var TranslatableString = /* @__PURE__ */ ((TranslatableString2) => {
|
|
|
2648
2667
|
TranslatableString2["OptionPrefix"] = "Option %1";
|
|
2649
2668
|
TranslatableString2["TitleOptionPrefix"] = "%1 option %2";
|
|
2650
2669
|
TranslatableString2["KeyLabel"] = "%1 Key";
|
|
2651
|
-
TranslatableString2["InvalidObjectField"] = 'Invalid "%1" object field configuration:
|
|
2670
|
+
TranslatableString2["InvalidObjectField"] = 'Invalid "%1" object field configuration: _%2_.';
|
|
2652
2671
|
TranslatableString2["UnsupportedField"] = "Unsupported field schema.";
|
|
2653
|
-
TranslatableString2["UnsupportedFieldWithId"] = "Unsupported field schema for field
|
|
2654
|
-
TranslatableString2["UnsupportedFieldWithReason"] = "Unsupported field schema:
|
|
2655
|
-
TranslatableString2["UnsupportedFieldWithIdAndReason"] = "Unsupported field schema for field
|
|
2672
|
+
TranslatableString2["UnsupportedFieldWithId"] = "Unsupported field schema for field `%1`.";
|
|
2673
|
+
TranslatableString2["UnsupportedFieldWithReason"] = "Unsupported field schema: _%1_.";
|
|
2674
|
+
TranslatableString2["UnsupportedFieldWithIdAndReason"] = "Unsupported field schema for field `%1`: _%2_.";
|
|
2656
2675
|
TranslatableString2["FilesInfo"] = "**%1** (%2, %3 bytes)";
|
|
2657
2676
|
return TranslatableString2;
|
|
2658
2677
|
})(TranslatableString || {});
|
|
@@ -2676,6 +2695,11 @@ var ParserValidator = class {
|
|
|
2676
2695
|
this.rootSchema = rootSchema;
|
|
2677
2696
|
this.addSchema(rootSchema, hashForSchema(rootSchema));
|
|
2678
2697
|
}
|
|
2698
|
+
/** Resets the internal AJV validator to clear schemas from it. Can be helpful for resetting the validator for tests.
|
|
2699
|
+
*/
|
|
2700
|
+
reset() {
|
|
2701
|
+
this.schemaMap = {};
|
|
2702
|
+
}
|
|
2679
2703
|
/** Adds the given `schema` to the `schemaMap` keyed by the `hash` or `ID_KEY` if present on the `schema`. If the
|
|
2680
2704
|
* schema does not have an `ID_KEY`, then the `hash` will be added as the `ID_KEY` to allow the schema to be
|
|
2681
2705
|
* associated with it's `hash` for future use (by a schema compiler).
|