From a89711c06681f56870ac21ebd17196bd10edc9ed Mon Sep 17 00:00:00 2001 From: Heath C <51679588+heath-freenome@users.noreply.github.com> Date: Mon, 19 Dec 2022 10:31:40 -0800 Subject: [PATCH] fix: 3253 By adding schema to ArrayFieldTemplateItemType type (#3298) fix: #3253 by adding `schema` prop `ArrayFieldTemplateItemType` type to make it consistent with all the rest of the template types - In `@rjsf/utils`, updated `types.ts` to add `schema` to the `ArrayFieldTemplateItemType` type - In `@rjsf/core`, updated the `ArrayField` template to pass the `schema` to the props that are provided to the instance of the `ArrayFieldItemTemplate` - Updated `custom-templates.md` to add the `schema` to the documentation for `ArrayFieldItemTemplate` - Updated the `CHANGELOG.md` accordingly --- CHANGELOG.md | 11 +++++++++++ docs/advanced-customization/custom-templates.md | 1 + packages/core/src/components/fields/ArrayField.tsx | 1 + packages/utils/src/types.ts | 4 +++- 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 579948c3fd..4812d51571 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,17 @@ it according to semantic versioning. For example, if your PR adds a breaking cha should change the heading of the (upcoming) version to include a major version bump. --> +# 5.0.0-beta-15 + +# @rjsf/core +- Pass the `schema` along to the `ArrayFieldItemTemplate` as part of the fix for [#3253](https://github.com/rjsf-team/react-jsonschema-form/issues/3253) + +# @rjsf/utils +- Update the `ArrayFieldItemTemplate` to add `schema` as part of the fix for [#3253](https://github.com/rjsf-team/react-jsonschema-form/issues/3253) + +## Dev / docs / playground +- Fixed the documentation for `ArrayFieldItemTemplate` as part of the fix for [#3253](https://github.com/rjsf-team/react-jsonschema-form/issues/3253) + # 5.0.0-beta.14 ## @rjsf/antd diff --git a/docs/advanced-customization/custom-templates.md b/docs/advanced-customization/custom-templates.md index dfaaabb8ef..d1aad99166 100644 --- a/docs/advanced-customization/custom-templates.md +++ b/docs/advanced-customization/custom-templates.md @@ -222,6 +222,7 @@ The following props are passed to each `ArrayFieldItemTemplate`: - `onDropIndexClick: (index) => (event?) => void`: Returns a function that removes the item at `index`. - `onReorderClick: (index, newIndex) => (event?) => void`: Returns a function that swaps the items at `index` with `newIndex`. - `readonly`: A boolean value stating if the array item is read-only. +- `schema`: The schema object for this array item. - `uiSchema`: The uiSchema object for this array item. - `registry`: The `registry` object. diff --git a/packages/core/src/components/fields/ArrayField.tsx b/packages/core/src/components/fields/ArrayField.tsx index 432accc730..e97e415ae1 100644 --- a/packages/core/src/components/fields/ArrayField.tsx +++ b/packages/core/src/components/fields/ArrayField.tsx @@ -862,6 +862,7 @@ class ArrayField< onReorderClick: this.onReorderClick, readonly, registry, + schema: itemSchema, uiSchema: itemUiSchema, }; } diff --git a/packages/utils/src/types.ts b/packages/utils/src/types.ts index 7a2bf2ad17..88e25f674b 100644 --- a/packages/utils/src/types.ts +++ b/packages/utils/src/types.ts @@ -520,7 +520,9 @@ export type ArrayFieldTemplateItemType< readonly: boolean; /** A stable, unique key for the array item */ key: string; - /** The uiSchema object for this field */ + /** The schema object for this array item */ + schema: S; + /** The uiSchema object for this array item */ uiSchema?: UiSchema; /** The `registry` object */ registry: Registry;