Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 40 additions & 16 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,76 +20,99 @@ should change the heading of the (upcoming) version to include a major version b
## @rjsf/antd

- Updated most of the widgets to get `formContext` from the `registry` instead of the `props` since it will no longer be passed
- Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
- BREAKING CHANGE: Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
- Updated `BaseInputTemplate`, `CheckboxesWidget`, `CheckboxWidget`, `RadioWidget`, `SelectWidget`, and `TextareaWidget` to use `htmlName` for the HTML `name` attribute
- BREAKING CHANGE: Updated `ArrayFieldTemplate` to remove the `ArrayFieldItemTemplate` render in favor of simply using `items` due to `ArrayField` changes

## @rjsf/chakra-ui

- Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
- BREAKING CHANGE: Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
- Updated `BaseInputTemplate`, `CheckboxesWidget`, `CheckboxWidget`, `RadioWidget`, `SelectWidget`, and `TextareaWidget` to use `htmlName` for the HTML `name` attribute
- BREAKING CHANGE: Updated `ArrayFieldTemplate` to remove the `ArrayFieldItemTemplate` render in favor of simply using `items` due to `ArrayField` changes

## @rjsf/core

- Updated `MultiSchemaField` and `SchemaField` to properly display `anyOf`/`oneOf` optional data fields by hiding the label and selector control when it is an optional field AND there is no form data
- Updated `ArrayField`, `BooleanField`, `LayoutMultiSchemaField`, `MultiSchemaField`, `ObjectField`, `SchemaField`, `StringField` and `BaseInputTemplate` to remove `formContext` from the props
- Updated `ObjectField` to refactor the code from a class component to two stateless functional components, replacing the 3 generator-props with the 4 memoized props mentioned in the `@rjsf/utils` changes
- Updated `Form` to "memoize" the `fieldPathId` and `registry` into the `FormState`, adding a `toIChangeEvent()` helper to restrict the state returned on the `IChangeEvent` interface callbacks
- Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
- BREAKING CHANGE: Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
- Added `nameGenerator` prop to `Form` component to enable custom HTML `name` attribute generation for form fields
- Updated `ArrayField` to refactor code from a class component to seven stateless functional components, replacing the 4 generator-props with the 5 memoized props mentioned in the `@rjsf/utils` changes
- BREAKING CHANGE: The refactor included rendering the `ArrayFieldItemTemplate` directly by the `ArrayField` rather than deferring it to the `ArrayFieldTemplate`
- Updated the `ArrayField` tests to adjust for the rendering change AND to remove 2 tests due to them no longer being valid
- BREAKING CHANGE: Updated `ArrayFieldTemplate` to remove the `ArrayFieldItemTemplate` render in favor of simply using `items` due to `ArrayField` changes
- BREAKING CHANGE: Updated `ArrayFieldItemButtonsTemplate` to replace the old callback-generator functions with the new memoizable callback functions
- Fixed a bug in `Form` to avoid getting errors being reported at the root level via `onChange` when there aren't

## @rjsf/daisyui

- Updated the test mocks to remove `formContext` for the widget mock
- Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
- BREAKING CHANGE: Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
- Updated `BaseInputTemplate`, `CheckboxesWidget`, `CheckboxWidget`, `RadioWidget`, and `TextareaWidget` to use `htmlName` for the HTML `name` attribute
- BREAKING CHANGE: Updated `ArrayFieldTemplate` to remove the `ArrayFieldItemTemplate` render in favor of simply using `items` due to `ArrayField` changes
- BREAKING CHANGE: Updated `ArrayFieldItemButtonsTemplate` to replace the old callback-generator functions with the new memoizable callback functions

## @rjsf/fluentui-rc

- Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
- BREAKING CHANGE: Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
- Updated `BaseInputTemplate`, `CheckboxesWidget`, `CheckboxWidget`, `RadioWidget`, `SelectWidget`, and `TextareaWidget` to use `htmlName` for the HTML `name` attribute
- BREAKING CHANGE: Updated `ArrayFieldTemplate` to remove the `ArrayFieldItemTemplate` render in favor of simply using `items` due to `ArrayField` changes

## @rjsf/mantine

- Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
- BREAKING CHANGE: Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
- Updated `BaseInputTemplate`, `CheckboxesWidget`, `CheckboxWidget`, `RadioWidget`, `SelectWidget`, and `TextareaWidget` to use `htmlName` for the HTML `name` attribute
- BREAKING CHANGE: Updated `ArrayFieldTemplate` to remove the `ArrayFieldItemTemplate` render in favor of simply using `items` due to `ArrayField` changes

## @rjsf/mui

- Updated `BaseInputTemplate` and `SelectWidget` to remove `formContext` from the props
- Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
- BREAKING CHANGE: Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
- Updated `BaseInputTemplate`, `CheckboxesWidget`, `CheckboxWidget`, `RadioWidget`, `SelectWidget`, and `TextareaWidget` to use `htmlName` for the HTML `name` attribute
- BREAKING CHANGE: Updated `ArrayFieldTemplate` to remove the `ArrayFieldItemTemplate` render in favor of simply using `items` due to `ArrayField` changes

## @rjsf/primereact

- Updated `SelectWidget` to remove `formContext` from the props
- Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
- BREAKING CHANGE: Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
- Updated `BaseInputTemplate`, `CheckboxesWidget`, `CheckboxWidget`, `RadioWidget`, `SelectWidget`, and `TextareaWidget` to use `htmlName` for the HTML `name` attribute
- BREAKING CHANGE: Updated `ArrayFieldTemplate` to remove the `ArrayFieldItemTemplate` render in favor of simply using `items` due to `ArrayField` changes

## @rjsf/react-bootstrap

- Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
- BREAKING CHANGE: Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
- Updated `BaseInputTemplate`, `CheckboxesWidget`, `CheckboxWidget`, `RadioWidget`, `SelectWidget`, and `TextareaWidget` to use `htmlName` for the HTML `name` attribute
- BREAKING CHANGE: Updated `ArrayFieldTemplate` to remove the `ArrayFieldItemTemplate` render in favor of simply using `items` due to `ArrayField` changes

## @rjsf/semantic-ui

- Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
- BREAKING CHANGE: Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
- Updated `BaseInputTemplate`, `CheckboxesWidget`, `CheckboxWidget`, `RadioWidget`, `SelectWidget`, and `TextareaWidget` to use `htmlName` for the HTML `name` attribute
- BREAKING CHANGE: Updated `ArrayFieldTemplate` to remove the `ArrayFieldItemTemplate` render in favor of simply using `items` due to `ArrayField` changes
- Updated `ArrayFieldItemTemplate` to refactor the getting of the `semanticProps` from `ArrayFieldTemplate`, using the new `parentUiSchema` prop to maintain the feature

## @rjsf/shadcn

- Updated the test mocks to remove `formContext` for the widget mock and added `globalFormOptions` in the registry mock
- Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
- BREAKING CHANGE: Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
- Updated `BaseInputTemplate`, `CheckboxesWidget`, `CheckboxWidget`, `SelectWidget`, and `TextareaWidget` to use `htmlName` for the HTML `name` attribute (Note: `RadioWidget` does not support `htmlName` due to Radix UI RadioGroup limitations)
- BREAKING CHANGE: Updated `ArrayFieldTemplate` to remove the `ArrayFieldItemTemplate` render in favor of simply using `items` due to `ArrayField` changes

## @rjsf/utils

- BREAKING CHANGE: Updated `FieldTemplateProps` and `WrapIfAdditionalTemplateProps` to replace the `onKeyChange()` and `onDropPropertyClick()` callback generator props with the `onKeyRename()`, `onKeyRenameBlur()` and `onRemoveProperty()` callback props
- BREAKING CHANGE: Updated `ObjectFieldTemplateProps` to replace the `onAddClick()` callback generator prop with the `onAddProperty()` callback prop
- BREAKING CHANGE: Updated `FieldTemplateProps` and `WrapIfAdditionalTemplateProps` to replace the `onKeyChange()` and `onDropPropertyClick()` callback-generator props with the `onKeyRename()`, `onKeyRenameBlur()` and `onRemoveProperty()` callback props
- BREAKING CHANGE: Updated `ObjectFieldTemplateProps` to replace the `onAddClick()` callback-generator prop with the `onAddProperty()` callback prop
- Added new hook `useDeepCompareMemo()` and its associated tests
- Added `NameGeneratorFunction` type and two built-in name generators: `bracketNameGenerator` and `dotNotationNameGenerator`
- Updated `GlobalFormOptions` type to include optional `nameGenerator` field
- Updated `toFieldPathId()` function to support name generation via the `nameGenerator` option in `GlobalFormOptions`
- Added `htmlName` field to `WidgetProps` interface to provide the generated HTML `name` attribute to widgets
- BREAKING CHANGE: Renamed `ArrayFieldItemTemplateType` to `ArrayFieldItemTemplateProps` and updated it to change `key: string` to `itemKey: string` to avoid a name collision with React
- BREAKING CHANGE: Updated `ArrayFieldTemplateProps` to change the type of the `items` prop from `ArrayFieldItemTemplateType<T, S, F>[]` to `ReactElement[]`
- BREAKING CHANGE: Updated `ArrayFieldItemButtonsTemplateType` to replace the `onAddIndexClick()`, `onCopyIndexClick()`, `onDropIndexClick()` and `onReorderClick()` callback-generator props with the `onAddItem()`, `onCopyItem()`, `onMoveUpItem()`, `onMoveDownItem()` and `onRemoveItem()` callback props
- BREAKING CHANGE: Updated `ArrayFieldItemTemplateType` to change `key: string` to `itemKey: string` to avoid a name collision with React
- BREAKING CHANGE: Renamed `ArrayFieldItemButtonsTemplateType` to `ArrayFieldItemButtonsTemplateProps` and updated it to replace the `onAddIndexClick()`, `onCopyIndexClick()`, `onDropIndexClick()` and `onReorderClick()` callback-generator props with the `onAddItem()`, `onCopyItem()`, `onMoveUpItem()`, `onMoveDownItem()` and `onRemoveItem()` callback props

## Dev / docs / playground
- Updated the `formTests.tsx` snapshots to add an `anyOf` of all arrays with different item types and removed the disabling of the optional data controls feature for the optional object with oneOfs
Expand All @@ -98,9 +121,10 @@ should change the heading of the (upcoming) version to include a major version b
- Updated the `Sample` and `LiveSettings` types to support the `liveSettings` inside of a sample
- Updated the `Playground`'s `onSampleSelected` callback to merge any `liveSettings` in the sample on top of those already used in the playground
- Updated the `customFieldAnyOf` sample to switch `IdSchema` to `FieldPathId`
- Updated the `custom-templates.md` documentation to reflect the `additionalProperties`-based interface props replacement
- Updated the `utility-functions.mf` documenation to add the new `useDeepCompareMemo()` hook
- Updated the `v6.x upgrade guide.md` documentation to add the BREAKING CHANGES to the `FieldTemplateProps`, `ObjectFieldTemplateProps` and `WrapIfAdditionalTemplateProps` interface props changes and the `useDeepCompareMemo()` hook
- Updated the `customArray` sample to refactor out a `ArrayFieldItemButtonsTemplate`
- Updated the `custom-templates.md` documentation to reflect the `additionalProperties`-based interface props replacement and `ArrayField` conversion changes
- Updated the `utility-functions.md` documentation to add the new `useDeepCompareMemo()` hook
- Updated the `v6.x upgrade guide.md` documentation to add the BREAKING CHANGES to the `ArrayFieldTemplateProps`, `ArrayFieldItemTemplateType`, `ArrayFieldItemButtonsTemplateType`, `FieldTemplateProps`, `ObjectFieldTemplateProps` and `WrapIfAdditionalTemplateProps` interface props changes and the `useDeepCompareMemo()` hook
- Added documentation for the `nameGenerator` prop in `form-props.md` and v6.x upgrade guide

# 6.0.0-beta.21
Expand Down
6 changes: 3 additions & 3 deletions packages/antd/src/templates/ArrayFieldItemTemplate/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Col, Row, Space } from 'antd';
import {
ArrayFieldItemTemplateType,
ArrayFieldItemTemplateProps,
FormContextType,
getUiOptions,
getTemplate,
Expand All @@ -18,13 +18,13 @@ const BTN_STYLE = {

/** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.
*
* @param props - The `ArrayFieldItemTemplateType` props for the component
* @param props - The `ArrayFieldItemTemplateProps` props for the component
*/
export default function ArrayFieldItemTemplate<
T = any,
S extends StrictRJSFSchema = RJSFSchema,
F extends FormContextType = any,
>(props: ArrayFieldItemTemplateType<T, S, F>) {
>(props: ArrayFieldItemTemplateProps<T, S, F>) {
const { children, buttonsProps, hasToolbar, index, registry, uiSchema } = props;
const uiOptions = getUiOptions<T, S, F>(uiSchema);
const ArrayFieldItemButtonsTemplate = getTemplate<'ArrayFieldItemButtonsTemplate', T, S, F>(
Expand Down
12 changes: 2 additions & 10 deletions packages/antd/src/templates/ArrayFieldTemplate/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
getTemplate,
getUiOptions,
ArrayFieldTemplateProps,
ArrayFieldItemTemplateType,
FormContextType,
GenericObjectType,
RJSFSchema,
Expand All @@ -19,7 +18,7 @@ const DESCRIPTION_COL_STYLE = {

/** The `ArrayFieldTemplate` component is the template used to render all items in an array.
*
* @param props - The `ArrayFieldItemTemplateType` props for the component
* @param props - The `ArrayFieldTemplateProps` props for the component
*/
export default function ArrayFieldTemplate<
T = any,
Expand Down Expand Up @@ -47,11 +46,6 @@ export default function ArrayFieldTemplate<
registry,
uiOptions,
);
const ArrayFieldItemTemplate = getTemplate<'ArrayFieldItemTemplate', T, S, F>(
'ArrayFieldItemTemplate',
registry,
uiOptions,
);
const ArrayFieldTitleTemplate = getTemplate<'ArrayFieldTitleTemplate', T, S, F>(
'ArrayFieldTitleTemplate',
registry,
Expand Down Expand Up @@ -103,9 +97,7 @@ export default function ArrayFieldTemplate<
)}
<Col className='row array-item-list' span={24}>
{!showOptionalDataControlInTitle ? optionalDataControl : undefined}
{items.map(({ key, ...itemProps }: ArrayFieldItemTemplateType<T, S, F>) => (
<ArrayFieldItemTemplate key={key} {...itemProps} />
))}
{items}
</Col>
{canAdd && (
<Col span={24}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Box, ButtonGroup, HStack } from '@chakra-ui/react';
import {
ArrayFieldItemTemplateType,
ArrayFieldItemTemplateProps,
FormContextType,
getTemplate,
getUiOptions,
Expand All @@ -12,7 +12,7 @@ export default function ArrayFieldItemTemplate<
T = any,
S extends StrictRJSFSchema = RJSFSchema,
F extends FormContextType = any,
>(props: ArrayFieldItemTemplateType<T, S, F>) {
>(props: ArrayFieldItemTemplateProps<T, S, F>) {
const { children, buttonsProps, hasToolbar, uiSchema, registry } = props;
const uiOptions = getUiOptions<T, S, F>(uiSchema);
const ArrayFieldItemButtonsTemplate = getTemplate<'ArrayFieldItemButtonsTemplate', T, S, F>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Box, Grid, GridItem } from '@chakra-ui/react';
import {
getTemplate,
getUiOptions,
ArrayFieldItemTemplateType,
ArrayFieldTemplateProps,
StrictRJSFSchema,
RJSFSchema,
Expand Down Expand Up @@ -35,11 +34,6 @@ export default function ArrayFieldTemplate<
registry,
uiOptions,
);
const ArrayFieldItemTemplate = getTemplate<'ArrayFieldItemTemplate', T, S, F>(
'ArrayFieldItemTemplate',
registry,
uiOptions,
);
const ArrayFieldTitleTemplate = getTemplate<'ArrayFieldTitleTemplate', T, S, F>(
'ArrayFieldTitleTemplate',
registry,
Expand Down Expand Up @@ -71,9 +65,7 @@ export default function ArrayFieldTemplate<
<Grid key={`array-item-list-${fieldPathId.$id}`}>
<GridItem>
{!showOptionalDataControlInTitle ? optionalDataControl : undefined}
{items.map(({ key, ...itemProps }: ArrayFieldItemTemplateType<T, S, F>) => (
<ArrayFieldItemTemplate key={key} {...itemProps} />
))}
{items}
</GridItem>
{canAdd && (
<GridItem justifySelf='flex-end'>
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/components/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,11 @@ export default class Form<
customErrors = new ErrorSchemaBuilder<T>();
}
if (isRootPath) {
customErrors.setErrors(_get(newErrorSchema, ERRORS_KEY, ''));
const errors = _get(newErrorSchema, ERRORS_KEY);
if (errors) {
// only set errors when there are some
customErrors.setErrors(errors);
}
} else {
_set(customErrors.ErrorSchema, path, newErrorSchema);
}
Expand Down
Loading
Loading