Skip to content

Commit 843cfef

Browse files
Add LayoutGridField and LayoutMultiSchemaField
Added new `LayoutGridField` and `LayoutMultiSchemaField` with updates to `utils` to support them - Updated `@rjsf/utils` to support the new fields as follows: - Updated the `UIOptionsBaseType` to add the optional `optionsSchemaSelector?: string` prop - Updated `getDiscriminatorFieldFromSchema()` to use the `DISCRIMINATOR_PATH` constant - Updated `hashForSchema.ts` to expose the `sortedJSONStringify()` method adding it to the `index.ts` export - Also added unit tests for the exposed method - Updated `getTestIds()` to read the `NODE_ENV` from the `process.env` via lodash `get()` to avoid odd bug - Updated `optionsList()` to switch the order of the generics and to add support for drilling into a `anyOf/oneOf` schema with a discriminator or a `optionsSchemaSelector` - This resulted in a few updates to other methods - Updated the tests to match the new capabilities - Updated `findSelectedOptionInXxxOf()` to use `getDiscriminatorFieldFromSchema()` rather than `DISCRIMINATOR_PATH` - Updated `ensureFormDataMatchingSchema()` to add the missing generics on the functions that have them - In `rjsf/core` : - Updated `package.json` to add the necessary `@testing-library` packages needed for the new components tests - Updated `ArrayField`, `BooleanField` and `StringField` to fix the order of the generics for `optionsList()` - Updated `RadioWidget` to add `radiogroup` role and `SelectWidget` to add the `combobox` role - Added the `LayoutGridField` and `LayoutMultiSchemaField` to the `fields` and added full `@testing-library` tests for them - Updated the snapshots due to the `role` changes to the two widgets - Updated the `utility-functions.md` to add `sortedJSONStringify()` docs and updated the `optionsList()` docs - Updated the `v6.x upgrade guide.md` to add breaking changes for `optionsList()` and adding the new `sortedJSONStringify()`
1 parent 19e143c commit 843cfef

30 files changed

+3920
-87
lines changed

package-lock.json

Lines changed: 56 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/core/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@
5757
"@rjsf/snapshot-tests": "^6.0.0-alpha.0",
5858
"@rjsf/utils": "^6.0.0-alpha.0",
5959
"@rjsf/validator-ajv8": "^6.0.0-alpha.0",
60+
"@testing-library/jest-dom": "^6.6.3",
61+
"@testing-library/react": "^16.2.0",
62+
"@testing-library/user-event": "^14.6.1",
6063
"@types/jest": "^29.5.12",
6164
"@types/lodash": "^4.14.202",
6265
"@types/react": "^18.2.58",

packages/core/src/components/fields/ArrayField.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ class ArrayField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends For
612612
} = this.props;
613613
const { widgets, schemaUtils, formContext, globalUiOptions } = registry;
614614
const itemsSchema = schemaUtils.retrieveSchema(schema.items as S, items);
615-
const enumOptions = optionsList<S, T[], F>(itemsSchema, uiSchema);
615+
const enumOptions = optionsList<T[], S, F>(itemsSchema, uiSchema);
616616
const { widget = 'select', title: uiTitle, ...options } = getUiOptions<T[], S, F>(uiSchema, globalUiOptions);
617617
const Widget = getWidget<T[], S, F>(schema, widget, widgets);
618618
const label = uiTitle ?? schema.title ?? name;

packages/core/src/components/fields/BooleanField.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function BooleanField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extend
5252
let enumOptions: EnumOptionsType<S>[] | undefined;
5353
const label = uiTitle ?? schemaTitle ?? title ?? name;
5454
if (Array.isArray(schema.oneOf)) {
55-
enumOptions = optionsList<S, T, F>(
55+
enumOptions = optionsList<T, S, F>(
5656
{
5757
oneOf: schema.oneOf
5858
.map((option) => {
@@ -84,7 +84,7 @@ function BooleanField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extend
8484
},
8585
];
8686
} else {
87-
enumOptions = optionsList<S, T, F>(
87+
enumOptions = optionsList<T, S, F>(
8888
{
8989
enum: enums,
9090
// NOTE: enumNames is deprecated, but still supported for now.

0 commit comments

Comments
 (0)