diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b3761884c..81253550e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,12 +17,32 @@ should change the heading of the (upcoming) version to include a major version b --> # 5.0.0-beta.12 +## @rjsf/antd +- Updated the tests to use the `@rjsf/validator-ajv8` fixing [#3110](https://github.com/rjsf-team/react-jsonschema-form/issues/3110) + +## @rjsf/bootstrap +- Updated the tests to use the `@rjsf/validator-ajv8` fixing [#3110](https://github.com/rjsf-team/react-jsonschema-form/issues/3110) + ## @rjsf/chakra-ui - Automatically close single-choice Select widget on selection +- Updated the tests to use the `@rjsf/validator-ajv8` fixing [#3110](https://github.com/rjsf-team/react-jsonschema-form/issues/3110) ## @rjsf/core - BREAKING CHANGE: ShowErrorList prop changed to support `false`, `top` or `bottom`; `true` is no longer a valid value as the default changed from `true` to `top` [#634](https://github.com/rjsf-team/react-jsonschema-form/issues/634) - Added the new generic, `S extends StrictRJSFSchema = RJSFSchema`, for `schema`/`rootSchema` to every component that needed it. +- Updated the tests to use the `@rjsf/validator-ajv8` fixing [#3110](https://github.com/rjsf-team/react-jsonschema-form/issues/3110) + +## @rjsf/fluent-ui +- Updated the tests to use the `@rjsf/validator-ajv8` fixing [#3110](https://github.com/rjsf-team/react-jsonschema-form/issues/3110) + +## @rjsf/material-ui +- Updated the tests to use the `@rjsf/validator-ajv8` fixing [#3110](https://github.com/rjsf-team/react-jsonschema-form/issues/3110) + +## @rjsf/mui +- Updated the tests to use the `@rjsf/validator-ajv8` fixing [#3110](https://github.com/rjsf-team/react-jsonschema-form/issues/3110) + +## @rjsf/semantic-ui +- Updated the tests to use the `@rjsf/validator-ajv8` fixing [#3110](https://github.com/rjsf-team/react-jsonschema-form/issues/3110) ## @rjsf/utils - Beta-only potentially BREAKING CHANGE: Changed all types that directly or indirectly defined `schema`/`rootSchema` to add the generic `S extends StrictRJSFSchema = RJSFSchema` and use `S` as the type for them. @@ -32,15 +52,17 @@ should change the heading of the (upcoming) version to include a major version b ## @rjsf/validator-ajv6 - Fixed a few type casts given the new expanded definition of the `RJSFSchema` type change +- Deprecated this library in favor of the `@rjsf/validator-ajv8` ## @rjsf/validator-ajv8 - Updated the typing to add the new `S extends StrictRJSFSchema = RJSFSchema` generic and fixed up type casts - Added the `AjvClass` prop to the `CustomValidatorOptionsType` to support using the `Ajv2019` or `Ajv2020` class implementation instead of the default `Ajv` class; fixing [#3189](https://github.com/rjsf-team/react-jsonschema-form/issues/3189) ## Dev / docs / playground -- Updated the `5.x upgrade guide` to document the new `StrictRJSFSchema` and `S` generic -- Updated the `validation` guide to document the new `AjvClass` prop on `CustomValidatorOptionsType` -- Updated the playground to add support for using the AJV 8 validator with the `draft-2019-09` and `draft-2020-12` schemas +- Updated the `5.x upgrade guide` and `utility-functions.md` to document the new `StrictRJSFSchema` and `S` generic +- Updated the `validation` guide to document the new `AjvClass` prop on `CustomValidatorOptionsType` and mentioning the deprecation of `@rjsf/validator-ajv6` +- Updated the playground to add support for using the AJV 8 validator with the `draft-2019-09` and `draft-2020-12` schemas and to make the `AJV8` validator the default validator, marking `AJV6` as deprecated +- Updated all the documentation to switch to Typescript notation where missing along with switching to using the `@rjsf/validator-ajv8` validator as the default # 5.0.0-beta.11 diff --git a/docs/5.x upgrade guide.md b/docs/5.x upgrade guide.md index b4729efcde..62686f5f79 100644 --- a/docs/5.x upgrade guide.md +++ b/docs/5.x upgrade guide.md @@ -28,9 +28,9 @@ There are three new packages added in RJSF version 5: - `@rjsf/utils`: All of the [utility functions](https://react-jsonschema-form.readthedocs.io/en/stable/api-reference/utiltity-functions) previously imported from `@rjsf/core/utils` as well as the Typescript types for RJSF version 5. - The following new utility functions were added: `createSchemaUtils()`, `getInputProps()`, `mergeValidationData()` and `processSelectValue()` -- `@rjsf/validator-ajv6`: The [ajv](https://github.com/ajv-validator/ajv)-v6-based validator refactored out of `@rjsf/core@4.x`, that implements the `ValidatorType` interface defined in `@rjsf/utils`. +- `@rjsf/validator-ajv8`: The [ajv](https://github.com/ajv-validator/ajv)-v6-based validator refactored out of `@rjsf/core@4.x`, that implements the `ValidatorType` interface defined in `@rjsf/utils`. +- `@rjsf/validator-ajv8`: The [ajv](https://github.com/ajv-validator/ajv)-v8-based validator that is an upgrade of the `@rjsf/validator-ajv8`, that implements the `ValidatorType` interface defined in `@rjsf/utils`. See the ajv 6 to 8 [migration guide](https://ajv.js.org/v6-to-v8-migration.html) for more information. - `@rjsf/mui`: Previously `@rjsf/material-ui/v5`, now provided as its own theme. -- `@rjsf/validator-ajv8`: The [ajv](https://github.com/ajv-validator/ajv)-v8-based validator that is an upgrade of the `@rjsf/validator-ajv6`, that implements the `ValidatorType` interface defined in `@rjsf/utils`. See the ajv 6 to 8 [migration guide](https://ajv.js.org/v6-to-v8-migration.html) for more information. ### `@rjsf/core` BREAKING CHANGES @@ -63,7 +63,8 @@ You can view all these [types](https://github.com/rjsf-team/react-jsonschema-for #### Form props In version 5, the `Form` component's two optional props `additionalMetaSchemas` and `customFormats` were replaced with the new, required `validator` prop, in order to support the decoupling of the validation implementation. This new `validator` prop is expected to be an implementation of the `ValidatorType` interface. -The new `@rjsf/validator-ajv6` package contains the refactored implementation of the version 4 validator. +The new `@rjsf/validator-ajv6` package contains the refactored implementation of the version 4 validator; It was provided for backwards compatibility with RJSF v4, and it is deprecated. +The new `@rjsf/validator-ajv8` package contains the refactored implementation of the version 4 validator, that has been converted to use the `Ajv 8` validator and has more capabilities than the `Ajv 6` one There are two ways to use this new package to provide a `validator` for a `Form`. First, you can simply import the default validator from the package and pass it to a `Form`. @@ -71,7 +72,7 @@ First, you can simply import the default validator from the package and pass it ```tsx import { RJSFSchema } from "@rjsf/utils"; import Form from "@rjsf/core"; -import validator from "@rjsf/validator-ajv6"; +import validator from "@rjsf/validator-ajv8"; // Your schema const schema: RJSFSchema = { ... }; @@ -86,7 +87,7 @@ Second, if you were actually providing one (or both) of the removed optional pro ```tsx import { RJSFSchema } from "@rjsf/utils"; import Form from "@rjsf/core"; -import { customizeValidator, CustomValidatorOptionsType } from "@rjsf/validator-ajv6"; +import { customizeValidator, CustomValidatorOptionsType } from "@rjsf/validator-ajv8"; // Your schema, additionalMetaSchemas and/or customFormats const schema: RJSFSchema = { ... }; @@ -107,7 +108,7 @@ As a result, if you were using the `formElement` ref, you will need to update it ```tsx import { RJSFSchema } from "@rjsf/utils"; import Form from "@rjsf/core"; -import validator from "@rjsf/validator-ajv6"; +import validator from "@rjsf/validator-ajv8"; // Your schema const schema: RJSFSchema = { ... }; @@ -136,7 +137,7 @@ If you were previously overriding any (or all) of these components, you can over ```tsx import { DescriptionFieldProps, RJSFSchema, TitleFieldProps } from "@rjsf/utils"; import Form from "@rjsf/core"; -import validator from "@rjsf/validator-ajv6"; +import validator from "@rjsf/validator-ajv8"; // Your schema const schema: RJSFSchema = { ... }; @@ -165,7 +166,7 @@ If you were previously overriding any (or all) of these templates, you can simpl ```tsx import { ArrayFieldTemplateProps, ErrorListProps, FieldTemplateProps, ObjectFieldTemplateProps, RJSFSchema } from "@rjsf/utils"; import Form from "@rjsf/core"; -import validator from "@rjsf/validator-ajv6"; +import validator from "@rjsf/validator-ajv8"; // Your schema const schema: RJSFSchema = { ... }; @@ -200,7 +201,7 @@ If you were previously overriding this component, you can override it now via th ```tsx import { RJSFSchema, SubmitButtonProps } from "@rjsf/utils"; import Form from "@rjsf/core"; -import validator from "@rjsf/validator-ajv6"; +import validator from "@rjsf/validator-ajv8"; // Your schema const schema: RJSFSchema = { ... }; @@ -263,7 +264,7 @@ function YourWidget(props: WidgetProps) { ``` #### validator.js -Because of the decoupling of validation from `@rjsf/core` this file was refactored into its own `@rjsf/validator-ajv6` package. +Because of the decoupling of validation from `@rjsf/core` this file was refactored into its own `@rjsf/validator-ajv8` package. During that refactor a few **breaking changes** were made to how it works related to custom validation and `ErrorSchema` conversion. ##### toErrorList param changed diff --git a/docs/advanced-customization/custom-templates.md b/docs/advanced-customization/custom-templates.md index 0dd953529d..dfaaabb8ef 100644 --- a/docs/advanced-customization/custom-templates.md +++ b/docs/advanced-customization/custom-templates.md @@ -51,10 +51,10 @@ If you only want to customize how the array's title, description or how the arra You can also customize arrays by specifying a widget in the relevant `ui:widget` schema, more details over on [Custom Widgets](../usage/arrays.md#custom-widgets). ```tsx -import { ArrayFieldTemplateProps } from "@rjsf/utils"; -import validator from '@rjsf/validator-ajv6'; +import { ArrayFieldTemplateProps, RJSFSchema } from "@rjsf/utils"; +import validator from '@rjsf/validator-ajv8'; -const schema = { +const schema: RJSFSchema = { type: "array", items: { type: "string" @@ -77,8 +77,10 @@ render(( You also can provide your own field template to a uiSchema by specifying a `ui:ArrayFieldTemplate` property. -```js -const uiSchema = { +```tsx +import { UiSchema } from "@rjsf/utils"; + +const uiSchema: UiSchema = { "ui:ArrayFieldTemplate": ArrayFieldTemplate } ``` @@ -131,10 +133,10 @@ If you want different behavior for the rendering of the description of an array If you want a different behavior for the rendering of ALL descriptions in the `Form`, see [DescriptionFieldTemplate](#descriptionfieldtemplate) ```tsx -import { ArrayFieldDescriptionProps } from "@rjsf/utils"; -import validator from '@rjsf/validator-ajv6'; +import { ArrayFieldDescriptionProps, RJSFSchema } from "@rjsf/utils"; +import validator from '@rjsf/validator-ajv8'; -const schema = { +const schema: RJSFSchema = { type: "array", items: { type: "string" @@ -159,8 +161,10 @@ render(( You also can provide your own template to a uiSchema by specifying a `ui:ArrayFieldDescriptionTemplate` property. -```js -const uiSchema = { +```tsx +import { UiSchema } from "@rjsf/utils"; + +const uiSchema: UiSchema = { "ui:ArrayFieldDescriptionTemplate": ArrayFieldDescriptionTemplate } ``` @@ -181,10 +185,10 @@ Each theme has an implementation of the `ArrayFieldItemTemplate` to render an ar If you want to change how an array field item is rendered you can customize this template (for instance to remove the move up/down and remove buttons). ```tsx -import { ArrayFieldTemplateItemType } from "@rjsf/utils"; -import validator from '@rjsf/validator-ajv6'; +import { ArrayFieldTemplateItemType, RJSFSchema } from "@rjsf/utils"; +import validator from '@rjsf/validator-ajv8'; -const schema = { +const schema: RJSFSchema = { type: "array", items: { type: "string" @@ -228,10 +232,10 @@ If you want a different behavior for the rendering of the title of an array fiel If you want a different behavior for the rendering of ALL titles in the `Form`, see [TitleFieldTemplate](#titlefieldtemplate) ```tsx -import { ArrayFieldTitleTemplateProps } from "@rjsf/utils"; -import validator from '@rjsf/validator-ajv6'; +import { ArrayFieldTitleTemplateProps, RJSFSchema } from "@rjsf/utils"; +import validator from '@rjsf/validator-ajv8'; -const schema = { +const schema: RJSFSchema = { type: "array", items: { type: "string" @@ -255,8 +259,10 @@ render(( You also can provide your own template to a uiSchema by specifying a `ui:ArrayFieldDescriptionTemplate` property. -```js -const uiSchema = { +```tsx +import { UiSchema } from "@rjsf/utils"; + +const uiSchema: UiSchema = { "ui:ArrayFieldTitleTemplate": ArrayFieldTitleTemplate } ``` @@ -281,12 +287,12 @@ If you desire a different implementation for the `` based widgets, you ca For instance, say you have a `CustomTextInput` component that you want to integrate: ```tsx -import { getInputProps, WidgetProps } from "@rjsf/utils"; -import validator from '@rjsf/validator-ajv6'; +import { getInputProps, RJSFSchema, WidgetProps } from "@rjsf/utils"; +import validator from '@rjsf/validator-ajv8'; import CustomTextInput from '../CustomTextInput'; -const schema = { +const schema: RJSFSchema = { type: "string", title: "My input", description: "input description" @@ -379,10 +385,10 @@ Each theme implements a `DescriptionFieldTemplate` used to render the descriptio If you want to customize how descriptions are rendered you can. ```tsx -import { DescriptionFieldProps } from "@rjsf/utils"; -import validator from '@rjsf/validator-ajv6'; +import { DescriptionFieldProps, RJSFSchema } from "@rjsf/utils"; +import validator from '@rjsf/validator-ajv8'; -const schema = { +const schema: RJSFSchema = { type: "string", title: "My input", description: "input description" @@ -418,10 +424,10 @@ Each theme implements a `ErrorListTemplate` used to render its errors using comp If you want to customize how all the errors are rendered you can. ```tsx -import { ErrorListProps, RJSFValidationError } from "@rjsf/utils"; -import validator from '@rjsf/validator-ajv6'; +import { ErrorListProps, RJSFValidationError, RJSFSchema } from "@rjsf/utils"; +import validator from '@rjsf/validator-ajv8'; -const schema = { +const schema: RJSFSchema = { type: "string", title: "My input", description: "input description" @@ -463,10 +469,10 @@ The `FieldErrorTemplate` is the template that renders all the errors associated If you want to customize how the errors are rendered you can. ```tsx -import { FieldErrorProps } from "@rjsf/utils"; -import validator from '@rjsf/validator-ajv6'; +import { FieldErrorProps, RJSFSchema } from "@rjsf/utils"; +import validator from '@rjsf/validator-ajv8'; -const schema = { +const schema: RJSFSchema = { type: "string", title: "My input", description: "input description" @@ -509,10 +515,10 @@ The `FieldHelpTemplate` is the template that renders the help associated a singl If you want to customize how the help is rendered you can. ```tsx -import { FieldHelpProps } from "@rjsf/utils"; -import validator from '@rjsf/validator-ajv6'; +import { FieldHelpProps, RJSFSchema } from "@rjsf/utils"; +import validator from '@rjsf/validator-ajv8'; -const schema = { +const schema: RJSFSchema = { type: "string", title: "My input", description: "input description" @@ -544,10 +550,10 @@ To take control over the inner organization of each field (each form row), you c A field template is basically a React stateless component being passed field-related props, allowing you to structure your form row as you like. ```tsx -import { FieldTemplateProps } from "@rjsf/utils"; -import validator from "@rjsf/validator-ajv6"; +import { FieldTemplateProps, RJSFSchema } from "@rjsf/utils"; +import validator from "@rjsf/validator-ajv8"; -const schema = { +const schema: RJSFSchema = { type: "string" }; @@ -571,8 +577,10 @@ render(( You also can provide your own field template to a uiSchema by specifying a `ui:FieldTemplate` property. -```js -const uiSchema = { +```tsx +import { UiSchema } from "@rjsf/utils"; + +const uiSchema: UiSchema = { "ui:FieldTemplate": CustomFieldTemplate } ``` @@ -610,10 +618,10 @@ The following props are passed to a custom field template component: ## ObjectFieldTemplate ```tsx -import { ObjectFieldTemplateProps } from "@rjsf/utils"; -import validator from "@rjsf/validator-ajv6"; +import { ObjectFieldTemplateProps, RJSFSchema } from "@rjsf/utils"; +import validator from "@rjsf/validator-ajv8"; -const schema = { +const schema: RJSFSchema = { type: "object", title: "Object title", description: "Object description", @@ -644,8 +652,10 @@ render(( You also can provide your own field template to a uiSchema by specifying a `ui:ObjectFieldTemplate` property. -```js -const uiSchema = { +```tsx +import { UiSchema } from "@rjsf/utils"; + +const uiSchema: UiSchema = { "ui:ObjectFieldTemplate": ObjectFieldTemplate }; ``` @@ -685,10 +695,10 @@ Each theme implements a `TitleFieldTemplate` used to render the title of a field If you want to customize how titles are rendered you can. ```tsx -import { TitleFieldProps } from "@rjsf/utils"; -import validator from '@rjsf/validator-ajv6'; +import { RJSFSchema, TitleFieldProps } from "@rjsf/utils"; +import validator from '@rjsf/validator-ajv8'; -const schema = { +const schema: RJSFSchema = { type: "string", title: "My input", description: "input description" @@ -724,11 +734,11 @@ The `UnsupportedField` component is used to render a field in the schema is one If you want to customize how an unsupported field is rendered (perhaps for localization purposes) you can. ```tsx -import { UnsupportedFieldProps } from "@rjsf/utils"; +import { RJSFSchema, UnsupportedFieldProps } from "@rjsf/utils"; import { FormattedMessage } from "react-intl"; -import validator from '@rjsf/validator-ajv6'; +import validator from '@rjsf/validator-ajv8'; -const schema = { +const schema: RJSFSchema = { type: "invalid" }; @@ -760,10 +770,16 @@ The `WrapIfAdditionalTemplate` is used by the `FieldTemplate` to conditionally r You may customize `WrapIfAdditionalTemplate` if you wish to change the layout or behavior of user-controlled `additionalProperties`. ```tsx -import { WrapIfAdditionalTemplateProps } from "@rjsf/utils"; +import { RJSFSchema, WrapIfAdditionalTemplateProps } from "@rjsf/utils"; +import validator from '@rjsf/validator-ajv8'; + +const schema: RJSFSchema = { + type: "object", + additionalProperties: true +}; -function WrapIfAdditionalTemplate( - props: WrapIfAdditionalTemplateProps +function WrapIfAdditionalTemplate( + props: WrapIfAdditionalTemplateProps ) { const { id, @@ -840,11 +856,11 @@ You can customize the `AddButton` to render something other than the icon button ```tsx import React from "react"; -import { IconButtonProps } from "@rjsf/utils"; +import { IconButtonProps, RJSFSchema } from "@rjsf/utils"; import { FormattedMessage } from "react-intl"; -import validator from '@rjsf/validator-ajv6'; +import validator from '@rjsf/validator-ajv8'; -const schema = { +const schema: RJSFSchema = { type: "string" }; @@ -869,11 +885,11 @@ You can customize the `MoveDownButton` to render something other than the icon b ```tsx import React from "react"; -import { IconButtonProps } from "@rjsf/utils"; +import { IconButtonProps, RJSFSchema } from "@rjsf/utils"; import { FormattedMessage } from "react-intl"; -import validator from '@rjsf/validator-ajv6'; +import validator from '@rjsf/validator-ajv8'; -const schema = { +const schema: RJSFSchema = { type: "string" }; @@ -898,11 +914,11 @@ You can customize the `MoveUpButton` to render something other than the icon but ```tsx import React from "react"; -import { IconButtonProps } from "@rjsf/utils"; +import { IconButtonProps, RJSFSchema } from "@rjsf/utils"; import { FormattedMessage } from "react-intl"; -import validator from '@rjsf/validator-ajv6'; +import validator from '@rjsf/validator-ajv8'; -const schema = { +const schema: RJSFSchema = { type: "string" }; @@ -927,11 +943,11 @@ You can customize the `RemoveButton` to render something other than the icon but ```tsx import React from "react"; -import { IconButtonProps } from "@rjsf/utils"; +import { IconButtonProps, RJSFSchema } from "@rjsf/utils"; import { FormattedMessage } from "react-intl"; -import validator from '@rjsf/validator-ajv6'; +import validator from '@rjsf/validator-ajv8'; -const schema = { +const schema: RJSFSchema = { type: "string" }; @@ -957,11 +973,11 @@ The `SubmitButton` is already very customizable via the `UISchemaSubmitButtonOpt ```tsx import React from "react"; -import { getSubmitButtonOptions, SubmitButtonProps } from "@rjsf/utils"; +import { getSubmitButtonOptions, RJSFSchema, SubmitButtonProps } from "@rjsf/utils"; import { FormattedMessage } from "react-intl"; -import validator from '@rjsf/validator-ajv6'; +import validator from '@rjsf/validator-ajv8'; -const schema = { +const schema: RJSFSchema = { type: "string" }; diff --git a/docs/advanced-customization/custom-themes.md b/docs/advanced-customization/custom-themes.md index ac2e493196..c91e7a1f1b 100644 --- a/docs/advanced-customization/custom-themes.md +++ b/docs/advanced-customization/custom-themes.md @@ -5,12 +5,12 @@ This theme-defining object is passed as the only parameter to the HOC (`withThem ## Usage -```jsx +```tsx import React, { Component } from 'react'; -import validator from '@rjsf/validator-ajv6'; -import { withTheme } from '@rjsf/core'; +import validator from '@rjsf/validator-ajv8'; +import { withTheme, ThemeProps } from '@rjsf/core'; -const theme = { widgets: {test: () => (
test
) } }; +const theme: ThemeProps = { widgets: {test: () => (
test
) } }; const ThemedForm = withTheme(theme); @@ -31,8 +31,11 @@ you can essentially redefine the default Form by simply doing `const Form = with **widgets** and **fields** should be in the same format as shown [here](/advanced-customization/#custom-widgets-and-fields). Example theme with custom widget: -```jsx -const MyCustomWidget = (props) => { +```tsx +import { WidgetProps, RegistryWidgetsType } from "@rjsf/utils"; +import { ThemeProps } from "@rjsf/core"; + +const MyCustomWidget = (props: WidgetProps) => { return ( { ); }; -const myWidgets = { +const myWidgets: RegistryWidgetsType = { myCustomWidget: MyCustomWidget }; -const ThemeObject = { widgets: myWidgets }; +const ThemeObject: ThemeProps = { widgets: myWidgets }; export default ThemeObject; ``` @@ -54,8 +57,11 @@ The above can be similarly done for **fields** and **templates**. ### Templates Each template should be passed into the theme object via the **templates** object just as you would into the rjsf Form component. Here is an example of how to use a custom [ArrayFieldTemplate](/advanced-customization/#array-field-template) and [ErrorListTemplate](/advanced-customization/#error-list-template) in the theme object: -```jsx -function MyArrayFieldTemplate(props) { +```tsx +import { ArrayFieldTemplateProps, ErrorListProps } from "@rjsf/utils"; +import { ThemeProps } from "@rjsf/core"; + +function MyArrayFieldTemplate(props: ArrayFieldTemplateProps) { return (
{props.items.map(element => element.children)} @@ -64,7 +70,7 @@ function MyArrayFieldTemplate(props) { ); } -function MyErrorListTemplate(props) { +function MyErrorListTemplate(props: ErrorListProps) { const {errors} = props; return (
    @@ -77,7 +83,7 @@ function MyErrorListTemplate(props) { ); } -const ThemeObject = { +const ThemeObject: ThemeProps = { templates: { ArrayFieldTemplate: MyArrayFieldTemplate, ErrorListTemplate: MyErrorListTemplate, @@ -90,8 +96,10 @@ export default ThemeObject; ## Overriding other Form props Just as the theme can override **widgets**, **fields**, any of the **templates**, and set default values to properties like **showErrorList**, you can do the same with the instance of the withTheme() Form component. -```jsx -const ThemeObject = { +```tsx +import { ThemeProps } from "@rjsf/core"; + +const ThemeObject: ThemeProps = { templates: { ArrayFieldTemplate: MyArrayFieldTemplate, }, diff --git a/docs/advanced-customization/custom-widgets-fields.md b/docs/advanced-customization/custom-widgets-fields.md index 377befe779..cd8620635d 100644 --- a/docs/advanced-customization/custom-widgets-fields.md +++ b/docs/advanced-customization/custom-widgets-fields.md @@ -9,19 +9,20 @@ The API allows to specify your own custom *widget* and *field* components: You can override any default field and widget, including the internal widgets like the `CheckboxWidget` that `ObjectField` renders for boolean values. You can override any field and widget just by providing the customized fields/widgets in the `fields` and `widgets` props: -```jsx -import validator from '@rjsf/validator-ajv6'; +```tsx +import { RJSFSchema, UiSchema, WidgetProps, RegistryWidgetsType } from "@rjsf/utils"; +import validator from '@rjsf/validator-ajv8'; -const schema = { +const schema: RJSFSchema = { type: "boolean", default: true }; -const uiSchema = { +const uiSchema: UiSchema = { "ui:widget": "checkbox" }; -const CustomCheckbox = function(props) { +const CustomCheckbox = function(props: WidgetProps) { return (