@rjsf/core 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/core.umd.js +64 -24
- package/dist/index.esm.js +61 -20
- package/dist/index.esm.js.map +2 -2
- package/dist/index.js +61 -20
- package/dist/index.js.map +3 -3
- package/lib/components/Form.d.ts +1 -0
- package/lib/components/Form.js +40 -1
- package/lib/components/Form.js.map +1 -1
- package/lib/components/fields/ArrayField.js +1 -1
- package/lib/components/fields/ArrayField.js.map +1 -1
- package/lib/components/fields/BooleanField.js +2 -2
- package/lib/components/fields/BooleanField.js.map +1 -1
- package/lib/components/fields/StringField.js +1 -1
- package/lib/components/fields/StringField.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/src/components/Form.tsx +42 -1
- package/src/components/fields/ArrayField.tsx +1 -1
- package/src/components/fields/BooleanField.tsx +24 -18
- package/src/components/fields/StringField.tsx +1 -1
|
@@ -52,19 +52,22 @@ function BooleanField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extend
|
|
|
52
52
|
let enumOptions: EnumOptionsType<S>[] | undefined;
|
|
53
53
|
const label = uiTitle ?? schemaTitle ?? title ?? name;
|
|
54
54
|
if (Array.isArray(schema.oneOf)) {
|
|
55
|
-
enumOptions = optionsList<S>(
|
|
56
|
-
|
|
57
|
-
.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
55
|
+
enumOptions = optionsList<S, T, F>(
|
|
56
|
+
{
|
|
57
|
+
oneOf: schema.oneOf
|
|
58
|
+
.map((option) => {
|
|
59
|
+
if (isObject(option)) {
|
|
60
|
+
return {
|
|
61
|
+
...option,
|
|
62
|
+
title: option.title || (option.const === true ? yes : no),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return undefined;
|
|
66
|
+
})
|
|
67
|
+
.filter((o: any) => o) as S[], // cast away the error that typescript can't grok is fixed
|
|
68
|
+
} as unknown as S,
|
|
69
|
+
uiSchema
|
|
70
|
+
);
|
|
68
71
|
} else {
|
|
69
72
|
// We deprecated enumNames in v5. It's intentionally omitted from RSJFSchema type, so we need to cast here.
|
|
70
73
|
const schemaWithEnumNames = schema as S & { enumNames?: string[] };
|
|
@@ -81,11 +84,14 @@ function BooleanField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extend
|
|
|
81
84
|
},
|
|
82
85
|
];
|
|
83
86
|
} else {
|
|
84
|
-
enumOptions = optionsList<S>(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
enumOptions = optionsList<S, T, F>(
|
|
88
|
+
{
|
|
89
|
+
enum: enums,
|
|
90
|
+
// NOTE: enumNames is deprecated, but still supported for now.
|
|
91
|
+
enumNames: schemaWithEnumNames.enumNames,
|
|
92
|
+
} as unknown as S,
|
|
93
|
+
uiSchema
|
|
94
|
+
);
|
|
89
95
|
}
|
|
90
96
|
}
|
|
91
97
|
|
|
@@ -35,7 +35,7 @@ function StringField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
|
|
|
35
35
|
} = props;
|
|
36
36
|
const { title, format } = schema;
|
|
37
37
|
const { widgets, formContext, schemaUtils, globalUiOptions } = registry;
|
|
38
|
-
const enumOptions = schemaUtils.isSelect(schema) ? optionsList(schema) : undefined;
|
|
38
|
+
const enumOptions = schemaUtils.isSelect(schema) ? optionsList<S, T, F>(schema, uiSchema) : undefined;
|
|
39
39
|
let defaultWidget = enumOptions ? 'select' : 'text';
|
|
40
40
|
if (format && hasWidget<T, S, F>(schema, format, widgets)) {
|
|
41
41
|
defaultWidget = format;
|