官方的FormKit Inputs插件。该包含有所有原生HTML输入类型的源代码。阅读inputs文档以获取使用说明。
通过应用一个高阶函数将给定的一组属性合并到节点中,将属性应用于给定的模式部分。
$attrs(attrs: FormKitSchemaAttributes | (() => FormKitSchemaAttributes), section: FormKitSchemaExtendableSection): FormKitSchemaExtendableSection;
attrs
— 应用于FormKitSchemaExtendableSection的属性。section
— 要应用属性的部分。FormKitSchemaExtendableSection
使用给定的扩展来扩展模式节点。
$extend(section: FormKitSchemaExtendableSection, extendWith: Partial<FormKitSchemaNode>): FormKitSchemaExtendableSection;
section
— 要应用扩展的部分。extendWith
— 要应用于部分的部分模式片段。FormKitSchemaExtendableSection
将条件应用于给定的模式部分。
$for(varName: string, inName: string, section: FormKitSchemaExtendableSection): (extensions: Record<string, Partial<FormKitSchemaNode>>) => FormKitSchemaNode;
varName
— 保存当前实例的变量的名称。inName
— 我们正在迭代的变量。section
— 要重复的部分。FormKitSchemaExtendableSection
将条件应用于给定的模式部分。
$if(condition: string, then: FormKitSchemaExtendableSection, otherwise?: FormKitSchemaExtendableSection): FormKitSchemaExtendableSection;
condition
— 应用于部分的模式条件。then
— 如果条件为真,则应用的部分。otherwise
可选 —(否则)如果条件为假,则应用的部分。FormKitSchemaExtendableSection
创建一个根模式部分。
$root(section: FormKitSchemaExtendableSection): FormKitExtendableSchemaRoot;
section
— 要从中创建根的部分。FormKitSchemaExtendableSection
添加复选框选择支持的特性。
checkboxes(node: FormKitNode): void;
node
— FormKitNode。添加图标属性定义的特性。
defaultIcon(sectionKey: string, defaultIcon: string): (node: FormKitNode) => void;
sectionKey
— 图标应该加载的位置。defaultIcon
— 如果在用户的CSS中找到匹配项,则应加载的图标。向输入添加文件处理支持的特性。
files(node: FormKitNode): void;
node
— FormKitNode。确保输入具有initialValue
属性的特性。
initialValue(node: FormKitNode): void;
node
— FormKitNode。创建一个新的特性,为给定的组件生成类型为ui的本地化消息。
localize(key: string, value?: string): (node: FormKitNode) => void;
key
— 消息的键。value
可选 — 消息的值。规范化框类型(复选框,单选框)的特性。
normalizeBoxes(node: FormKitNode): FormKitMiddleware<{
prop: string | symbol;
value: any;
}>;
node
— FormKitNode。将选项属性转换为可用值的特性,供特性或插件使用。
options(node: FormKitNode): void;
node
— 一个 FormKitNode。一个用于检查被检查的值是否为当前值的功能。
radios(node: FormKitNode): void;
node
— 一个 FormKitNode。基于一组 FormKitLibrary 创建一个插件。
createLibraryPlugin(...libraries: FormKitLibrary[]): FormKitPlugin;
libraries
— 一个或多个 FormKitLibrary。创建一个新的可重用的部分。
createSection(section: string, el: string | null | (() => FormKitSchemaNode), fragment: true): FormKitSection<FormKitExtendableSchemaRoot>;
createSection(section: string, el: string | null | (() => FormKitSchemaNode)): FormKitSection<FormKitSchemaExtendableSection>;
createSection(section: string, el: string | (() => FormKitSchemaNode), fragment: false): FormKitSection<FormKitSchemaExtendableSection>;
section
— 一个单独的模式部分el
— 元素或返回模式节点的函数。fragment
返回一个 FormKitExtendableSchemaRoot 或 FormKitSchemaExtendableSection。
一个允许禁用此节点的子节点的功能。
disables(node: FormKitNode): void;
node
— 一个 FormKitNode。在模式中的每个部分上运行回调函数。如果 stopOnCallbackReturn 为 true,并且回调函数返回一个值,则循环将停止并返回该值。
eachSection<T>(schema: FormKitSchemaDefinition, callback: (section: FormKitSchemaComponent | FormKitSchemaDOMNode, schemaParent: FormKitSchemaNode[], schema: FormKitSchemaCondition) => T, stopOnCallbackReturn?: boolean, schemaParent?: FormKitSchemaNode[]): T | void;
schema
— 一个 FormKitSchemaNode 数组。callback
— 在每个部分上运行的回调函数。stopOnCallbackReturn
* 可选 * — 如果为 true,则循环将在回调函数返回一个值时停止。schemaParent
* 可选 * — 当前模式节点的父节点。使用扩展来扩展单个模式节点。扩展可以是任何部分节点,包括字符串。
extendSchema(schema: FormKitSchemaNode, extension?: Partial<FormKitSchemaNode>): FormKitSchemaNode;
schema
— 基本模式节点。extension
* 可选 * — 要扩展到基本模式节点上的值。在模式中按名称查找部分。
findSection(schema: FormKitSchemaDefinition, target: string): [false, false] | [FormKitSchemaNode[] | false, FormKitSchemaCondition];
schema
— 一个 FormKitSchemaDefinition 数组。target
— 要查找的部分的名称。模式和部分的元组,如果未找到则为 false
和 false
的元组。
一个添加提交处理程序和操作部分的功能。
form(node: FormKitNode): void;
node
— 一个 FormKitNode。一个默认应用 ignore="true"
的功能。
ignore(node: FormKitNode): void;
node
— 一个 FormKitNode。用于模式对象的类型保护。
isSchemaObject(schema: Partial<FormKitSchemaNode>): schema is FormKitSchemaDOMNode | FormKitSchemaComponent | FormKitSchemaFormKit;
schema
— 如果节点是模式节点但不是字符串或条件,则返回 true
。boolean
检查当前模式节点是否为插槽条件。
isSlotCondition(node: FormKitSchemaNode): node is {
if: string;
then: string;
else: FormKitSchemaNode | FormKitSchemaNode[];
};
node
— 一个FormKitSchemaNode。boolean
{
if: '$slot.name',
then: '$slot.name',
else: []
} // 这个模式节点将返回true。
一个函数,用于将对象数组、字符串数组或键值对对象规范化为使用具有value和label属性的对象数组。
normalizeOptions(options: FormKitOptionsProp): FormKitOptionsList;
options
— 一个未规范化的FormKitOptionsProp。将选项属性转换为可用的值。
select(node: FormKitNode): void;
node
— 一个formkit节点。创建一个包含所有包装基本模式的输入模式。
useSchema(inputSection: FormKitSection): FormKitSchemaExtendableSection;
inputSection
— 要存储在输入部分键位置的内容。FormKit合成的“FileList”中的单个文件对象。
interface FormKitFile {
file?: File;
name: string;
}
选项应始终格式化为具有label和value属性的对象数组。
interface FormKitOptionsItem {
__original?: any;
[index: string]: any;
attrs?:{
disabled?: boolean;
}&Record<string, any>;
label: string;
value: unknown;
}
允许通过使用键被忽略但值应用于联合类型的接口来定义prop扩展。这允许任何第三方代码通过使用模块扩展来向联合类型添加新值来扩展选项prop。
interface FormKitOptionsPropExtensions {
arrayOfNumbers: number[];
arrayOfStrings: string[];
optionsList: FormKitOptionsList;
valueLabelPojo: Record<string | number, string>;
}
一个使用扩展参数调用的函数,并返回一个有效的模式节点。
interface FormKitSchemaExtendableSection {
_s?: string;
(extensions: Record<string, Partial<FormKitSchemaNode>>): FormKitSchemaNode;
}
一个函数,当调用时,返回一个可以再次使用扩展参数调用的函数。
interface FormKitSection<T = FormKitSchemaExtendableSection> {
(...children: Array<FormKitSchemaExtendableSection | string>): T;
}
合成props是不明确声明为props,但应被视为对外界的props。
interface FormKitSyntheticPropsExtensions {
accept: string;
action: string;
actions: boolean;
dirtyBehavior:'touched' | 'compare';
disabled: string | boolean;
enctype: string;
help: string;
ignore: string | boolean;
label: string;
max: string | number;
method: string;
min: string | number;
multiple: string | boolean;
options: FormKitOptionsProp;
preserve: string | boolean;
preserveErrors: string | boolean;
step: string | number;
}
基于数组的合成“FileList”。
type FormKitFileValue = FormKitFile[];
模式节点或返回模式节点的函数。
type FormKitInputSchema = ((children?: FormKitSchemaDefinition) => FormKitSchemaNode) | FormKitSchemaNode;
选项项的数组。
type FormKitOptionsList = FormKitOptionsItem[];
可以传递给选项prop的选项类型。
type FormKitOptionsProp = FormKitOptionsPropExtensions[keyof FormKitOptionsPropExtensions];
合成prop类型。
type FormKitSyntheticProps = {
[Property in keyof FormKitSyntheticPropsExtensions]: FormKitSyntheticPropsExtensions[Property];
};