@rjsf/utils 5.19.4 → 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 +27 -8
- package/dist/index.js.map +2 -2
- package/dist/utils.esm.js +27 -8
- package/dist/utils.esm.js.map +2 -2
- package/dist/utils.umd.js +27 -8
- package/lib/optionsList.d.ts +7 -4
- package/lib/optionsList.js +35 -12
- package/lib/optionsList.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types.d.ts +3 -1
- package/package.json +2 -2
- package/src/optionsList.ts +39 -14
- package/src/types.ts +3 -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,
|