@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 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 = schemaWithEnumNames.enumNames && schemaWithEnumNames.enumNames[i] || String(value);
2398
+ const label = enumNames?.[i] || String(value);
2389
2399
  return { label, value };
2390
2400
  });
2391
2401
  }
2392
- const altSchemas = schema.oneOf || schema.anyOf;
2393
- return altSchemas && altSchemas.map((aSchemaDef) => {
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,