@canard/schema-form-antd6-plugin
v0.13.1
Published
Ant Design v6 components plugin for @canard/schema-form providing pre-built form inputs with advanced components like date pickers, sliders, and file uploads
Downloads
380
Maintainers
Readme
@canard/schema-form-antd6-plugin
About This Package
@canard/schema-form-antd6-plugin is the Ant Design v6 version of the schema-form plugin.
If you're using Ant Design v5, please use @canard/schema-form-antd5-plugin instead.
Overview
@canard/schema-form-antd6-plugin is a plugin for @canard/schema-form that provides Ant Design v6 components.
Requirements
- React: 18 or higher (required for Ant Design v6)
- Ant Design: 6.0.0 or higher
- @ant-design/icons: 6.0.0 or higher
Notice
⚠️ This plugin provides pre-implemented core components commonly needed when using @canard/schema-form in Ant Design environments.
📌 As the plugin's purpose is to enhance development convenience, it does not include every possible component.
💡 If you need FormTypeInput components not included in this plugin, you can freely implement them following the official @canard/schema-form guidelines.
How to use
yarn add @canard/schema-form @canard/schema-form-antd6-pluginimport { SchemaForm, registerPlugin } from '@canard/schema-form';
import { plugin } from '@canard/schema-form-antd6-plugin';
// Plugin will be registered globally
registerPlugin(plugin);Migrating from antd5-plugin
If you're migrating from @canard/schema-form-antd5-plugin:
# Remove old package
yarn remove @canard/schema-form-antd5-plugin
# Install new package
yarn add @canard/schema-form-antd6-pluginUpdate your imports:
- import { plugin } from '@canard/schema-form-antd5-plugin';
+ import { plugin } from '@canard/schema-form-antd6-plugin';Supported Components
This plugin provides the following Ant Design v6 components:
FormTypeInputBooleanSwitch.tsx
- Role: Display boolean type data as a Switch component
- Applied when:
typeis"boolean"andformTypeis"switch" - Additional features: Support for custom labels for
checked/uncheckedstates, adjustable switch size
FormTypeInputStringCheckbox.tsx
- Role: Display string arrays as checkbox groups
- Applied when:
typeis"array",formTypeis"checkbox",items.typeis"string", andenumvalues exist - Additional features: Support for custom labels for each checkbox option
FormTypeInputStringSwitch.tsx
- Role: Toggle between two string values using a Switch
- Applied when:
typeis"string",formTypeis"switch", and theenumarray has exactly 2 values - Additional features: Support for custom labels per switch state, adjustable switch size
FormTypeInputUri.tsx
- Role: Special input field for URI entry (with protocol dropdown)
- Applied when:
typeis"string"andformatorformTypeis"uri" - Additional features: Protocol selection dropdown, default protocol list support (http, https, ftp, mailto, tel), configurable custom protocol list
FormTypeInputMonth.tsx
- Role: DatePicker for month selection (month mode)
- Applied when:
typeis"string"andformatis"month" - Additional features: Support for
minimum,maximumrange limits, YYYY-MM format
FormTypeInputDate.tsx
- Role: DatePicker for date selection
- Applied when:
typeis"string"andformatis"date" - Additional features: Support for
minimum,maximumdate range limits, YYYY-MM-DD format
FormTypeInputTime.tsx
- Role: TimePicker for time selection
- Applied when:
typeis"string"andformatis"time" - Additional features: Time stored in HH:mm:00Z format
FormTypeInputMonthRange.tsx
- Role: DatePicker RangePicker for month range selection (month mode)
- Applied when:
typeis"array",formatis"month-range"orformTypeis"monthRange", anditems.typeis"string" - Additional features: Support for month range limits, returns array in [start month, end month] format
FormTypeInputDateRange.tsx
- Role: DatePicker RangePicker for date range selection
- Applied when:
typeis"array",formatis"date-range"orformTypeis"dateRange", anditems.typeis"string" - Additional features: Support for date range limits, returns array in [start date, end date] format
FormTypeInputTimeRange.tsx
- Role: DatePicker RangePicker for time range selection (time mode)
- Applied when:
typeis"array",formatis"time-range"orformTypeis"timeRange", anditems.typeis"string" - Additional features: Support for time range limits, returns array in [start time, end time] format
FormTypeInputRadioGroup.tsx
- Role: Display single selection of string or number as radio group
- Applied when:
typeis"string","number", or"integer",formTypeis"radio"or"radiogroup", andenumvalues exist - Additional features: Support for custom labels for radio options, adjustable radio group size
FormTypeInputStringEnum.tsx
- Role: Display string or string array selection as Select dropdown
- Applied when:
typeis"string"andenumvalues exist- or
typeis"array",items.typeis"string", anditems.enumvalues exist
- Additional features: Automatic single/multiple selection detection, support for custom labels per option
FormTypeInputArray.tsx
- Role: Display array data as a list with dynamic add/remove capabilities
- Applied when:
typeis"array" - Additional features: Add/Remove buttons with Ant Design icons, add/remove buttons hidden in read-only mode
FormTypeInputSlider.tsx
- Role: Input numeric values using a slider
- Applied when:
typeis"number"or"integer"andformTypeis"slider" - Additional features: Support for
minimum,maximum,multipleOfschema properties, lazy update option
FormTypeInputTextarea.tsx
- Role: Text area for multiline text input
- Applied when:
typeis"string"andformatorformTypeis"textarea" - Additional features: Support for automatic resizing via
minRows,maxRows
FormTypeInputString.tsx
- Role: Default string input field
- Applied when:
typeis"string"(fallback when other conditions don't match) - Additional features: Operates as password input field when
formatis"password", adjustable input field size
FormTypeInputNumber.tsx
- Role: InputNumber component for numeric input
- Applied when:
typeis"number"or"integer"(fallback when other conditions don't match) - Additional features: Support for
minimum,maximum,multipleOfschema properties, support for custom formatter/parser
FormTypeInputBoolean.tsx
- Role: Display boolean values as checkboxes
- Applied when:
typeis"boolean"(fallback when other conditions don't match) - Additional features: Support for
indeterminatestate forundefinedvalues
Component Priority
Component selection is determined by the following priority order:
- In-line component: Component specified as
FormTypeInputproperty in the schema - FormTypeInputMap: Component explicitly mapped to a path
- FormTypeInputDefinition: Automatic selection through each component's
testcondition - Provider FormTypeInputDefinition: Component definitions provided by parent Provider
- Plugin: Components from registered plugins (including this plugin)
- Fallback: Default fallback components
Within the same priority level, earlier items in the array take precedence. Components in this plugin are defined in the following order:
FormTypeInputBooleanSwitch → FormTypeInputStringCheckbox → FormTypeInputStringSwitch → FormTypeInputUri → FormTypeInputMonth → FormTypeInputDate → FormTypeInputTime → FormTypeInputMonthRange → FormTypeInputDateRange → FormTypeInputTimeRange → FormTypeInputRadioGroup → FormTypeInputStringEnum → FormTypeInputArray → FormTypeInputSlider → FormTypeInputTextarea → FormTypeInputString → FormTypeInputNumber → FormTypeInputBoolean
Compatibility
@canard/schema-form-antd6-plugin is built with ECMAScript 2020 (ES2020) syntax.
If you're using a JavaScript environment that doesn't support ES2020, you'll need to include this package in your transpilation process.
Supported environments:
- Node.js 14.17.0 or later
- Modern browsers (Chrome 91+, Firefox 90+, Safari 14+)
- React 18 or higher (required for Ant Design v6)
For legacy environment support: Please use a transpiler like Babel to transform the code for your target environment.
Ant Design v6 Notes
This plugin is built for Ant Design v6, which includes the following changes from v5:
- CSS Variables are enabled by default
- React 18+ is required
@ant-design/iconsv6 is required (not compatible with antd v5)
For more information about Ant Design v6 changes, see the official migration guide.
License
This repository is licensed under the MIT License. Please refer to the LICENSE file for details.
Contact
For inquiries or suggestions related to the project, please create an issue.
