@canard/schema-form-antd-mobile-plugin
is a plugin for @canard/schema-form
that provides Ant Design Mobile components.
@canard/schema-form
in Ant Design Mobile 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.
yarn add @canard/schema-form @canard/schema-form-antd-mobile-plugin
import { SchemaForm, registerPlugin } from '@canard/schema-form';
import { plugin } from '@canard/schema-form-antd-mobile-plugin';
// Plugin will be registered globally
registerPlugin(plugin);
This plugin provides the following Ant Design Mobile components:
- Role: Display boolean type data as a Switch component
-
Applied when:
type
is"boolean"
andformType
is"switch"
-
Additional features: Support for custom labels for
checked
/unchecked
states
- Role: Display string arrays as checkbox groups
-
Applied when:
type
is"array"
,formType
is"checkbox"
,items.type
is"string"
, andenum
values exist - Additional features: Support for custom labels for each checkbox option
- Role: Toggle between two string values using a Switch
-
Applied when:
type
is"string"
,formType
is"switch"
, and theenum
array has exactly 2 values - Additional features: Support for custom labels per switch state
- Role: Display single selection of string or number as radio group
-
Applied when:
type
is"string"
,"number"
, or"integer"
,formType
is"radio"
or"radiogroup"
, andenum
values exist - Additional features: Support for custom labels for radio options
- Role: Display array data as a list with dynamic add/remove capabilities
-
Applied when:
type
is"array"
- Additional features: Add/remove buttons hidden in read-only mode
- Role: Input numeric values using a slider
-
Applied when:
-
type
is"number"
or"integer"
andformat
is"slider"
- or
type
is"array"
,items.type
is"number"
or"integer"
, andformat
is"slider"
(range slider)
-
- Additional features: Lazy update option, mark display, range slider support
- Role: Text area for multiline text input
-
Applied when:
type
is"string"
andformat
orformType
is"textarea"
-
Additional features: Support for automatic resizing via
minRows
,maxRows
- Role: Default string input field
-
Applied when:
type
is"string"
(fallback when other conditions don't match) -
Additional features: Operates as password input field when
format
is"password"
- Role: Stepper component for numeric input
-
Applied when:
type
is"number"
or"integer"
(fallback when other conditions don't match) -
Additional features: Support for
minimum
,maximum
,multipleOf
schema properties
- Role: Display boolean values as checkboxes
-
Applied when:
type
is"boolean"
(fallback when other conditions don't match) -
Additional features: Support for
indeterminate
state forundefined
values
Component selection is determined by the following priority order:
-
In-line component: Component specified as
FormType
property in the schema - FormTypeInputMap: Component explicitly mapped to a path
-
FormTypeInputDefinition: Automatic selection through each component's
test
condition - 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
→ FormTypeInputRadioGroup
→ FormTypeInputArray
→ FormTypeInputSlider
→ FormTypeInputTextarea
→ FormTypeInputString
→ FormTypeInputNumber
→ FormTypeInputBoolean
@canard/schema-form-antd-mobile-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+)
For legacy environment support: Please use a transpiler like Babel to transform the code for your target environment.
This repository is licensed under the MIT License. Please refer to the LICENSE
file for details.
For inquiries or suggestions related to the project, please create an issue.