Introducing KickStart — AI generated FormKit forms in seconds. Generate from a screenshot, edit with drag-and-drop or conversational AI, copy & paste as components or schema!
Try for free
FormKit的常见、可选、第一方附加功能。
您可以通过使用npm install @formkit/addons
或yarn add @formkit/addons
来添加此包。
自动为每个输入添加动画:
createAutoAnimatePlugin(options?: AutoAnimateOptions, animationTargets?: Record<string, string[]>): FormKitPlugin;
options
可选 — AutoAnimateOptionsanimationTargets
可选 — 输入类型的映射和应该被动画化的它们的部分的数组。import { createApp } from 'vue'
import App from 'App.vue'
import { createAutoAnimatePlugin } from '@formkit/addons'
import { plugin, defaultConfig } from '@formkit/vue'
createApp(app).use(plugin, defaultPlugin({
plugins: [
createAutoAnimatePlugin({
// 可选配置
duration: 250,
easing: 'ease-in-out',
delay: 0,
},
{
// 可选动画目标对象
global: ['outer', 'inner'],
form: ['form'],
repeater: ['items'],
})
]
}))
创建一个新的自动高度文本区插件。
createAutoHeightTextareaPlugin(): FormKitPlugin;
创建一个新的浮动标签插件。
createFloatingLabelsPlugin(FloatingLabelsOptions?: FloatingLabelsOptions): FormKitPlugin;
FloatingLabelsOptions
可选 — 传递给插件的FloatingLabelsOptions的选项创建一个新的保存到本地存储插件。
createLocalStoragePlugin(localStorageOptions?: LocalStorageOptions): FormKitPlugin;
localStorageOptions
可选创建一个新的多步插件。
createMultiStepPlugin(options?: MultiStepOptions): FormKitPlugin;
options
可选 — 传递给插件的 MultiStepOptions 的选项beforeStepChange 函数的类型。
interface BeforeStepChange {
(data: BeforeStepChangeData): any;
}
interface BeforeStepChangeData<T = unknown> {
currentStep: FormKitFrameworkContext<T>;
delta: number;
nextStep: FormKitFrameworkContext<T>;
}
传递给 createFloatingLabelsPlugin 的选项
interface FloatingLabelsOptions {
useAsDefault?: boolean;
}
interface FormKitMultiStepSlots<Props extends FormKitInputs<Props>> {
badge: FormKitSlotData<Props, MultiStepSlotData&{
step: FormKitFrameworkContext;
index: number;
}>;
default: FormKitSlotData<Props, MultiStepSlotData>;
multiStepOuter: FormKitSlotData<Props, MultiStepSlotData>;
steps: FormKitSlotData<Props, MultiStepSlotData>;
tab: FormKitSlotData<Props, MultiStepSlotData>;
tabLabel: FormKitSlotData<Props, MultiStepSlotData&{
step: FormKitFrameworkContext;
index: number;
}>;
tabs: FormKitSlotData<Props, MultiStepSlotData>;
validStepIcon: FormKitSlotData<Props, MultiStepSlotData&{
step: FormKitFrameworkContext;
index: number;
}>;
wrapper: FormKitSlotData<Props, MultiStepSlotData>;
}
interface FormKitStepSlots<Props extends FormKitInputs<Props>> {
default: FormKitSlotData<Props, StepSlotData>;
stepActions: FormKitSlotData<Props, StepSlotData>;
stepInner: FormKitSlotData<Props, StepSlotData>;
stepNext: FormKitSlotData<Props, StepSlotData>;
stepPrevious: FormKitSlotData<Props, StepSlotData>;
}
传递给 createLocalStoragePlugin 的选项
interface LocalStorageOptions {
beforeLoad?: (payload: any) => any;
beforeSave?: (payload: any) => any;
control?: string;
debounce?: number;
key?: string | number;
maxAge?: number;
prefix?: string;
}
interface MultiStepHandlers {
incrementStep: (delta: number, currentStep: FormKitFrameworkContext | undefined) => () => void;
setActiveStep: (step: FormKitFrameworkContext) => (e?: Event) => void;
showStepErrors: (step: FormKitFrameworkContext) => boolean | undefined;
triggerStepValidations: (step: FormKitFrameworkContext) => void;
}
添加到多步输入的FormKitNode的附加参数。
interface MultiStepNodeAdditions {
goTo: (target: number | string) => void;
next: () => void;
previous: () => void;
}
要传递给createMultiStepPlugin的选项
interface MultiStepOptions {
allowIncomplete?: boolean;
hideProgressLabels?: boolean;
tabStyle?:'tab' | 'progress';
}
interface MultiStepSlotData {
activeStep: string;
allowIncomplete?: boolean;
beforeStepChange?: BeforeStepChange;
handlers: FormKitFrameworkContext['handlers']&MultiStepHandlers;
hideProgressLabels: boolean;
node: FormKitMultiStepNode;
steps: Array<FormKitMultiStepSlotData>;
tabStyle:'tab' | 'progress';
validStepIcon: string | undefined;
}
interface StepHandlers {
incrementStep: (delta: number) => () => void;
next: () => void;
previous: () => void;
}
特定于步骤输入的插槽数据。
interface StepSlotData {
beforeStepChange?: BeforeStepChange;
blockingCount: number;
errorCount: number;
handlers: FormKitFrameworkContext['handlers']&StepHandlers;
hasBeenVisited: true | undefined;
isActiveStep: boolean;
isFirstStep: boolean;
isLastStep: boolean;
isValid: boolean;
makeActive: () => void;
nextAttrs?: Record<string, any>;
nextLabel?: string;
ordered: boolean;
previousAttrs?: Record<string, any>;
previousLabel?: string;
showStepErrors: boolean;
stepIndex: number;
stepName: string;
steps: Array<FormKitMultiStepSlotData>;
totalErrorCount: number;
validStepIcon?: string;
}
增强了下一步和上一步以及goTo函数的节点类型。
export type FormKitMultiStepNode = FormKitNode & MultiStepNodeAdditions;
FormKit多步输入的插槽数据的类型。
export type FormKitMultiStepSlotData = FormKitFrameworkContext<Record<string, any>> & StepSlotData;