UNPKG

@skiyee/uni-ui

Version:

一个由原子化CSS驱动、符合直觉设计、高度定制化、面向AI时代的移动端 UI 库,助力开发者打造独特且差异化的移动端应用程序

42 lines (41 loc) 1.24 kB
/** * @skiyee/uni-ui v1.0.0 * @author skiyee(https://github.com/skiyee) * @license Apache License 2.0 * @copyright 2025-present skiyee All rights reserved. **/ import { SkFieldUcvProps } from "../styles/sk-field.cjs"; import { Schema, SchemaInferInput } from "../validator/schema.type.cjs"; //#region src/types/form.d.ts interface FormFieldState { name: string; value: unknown; touched: boolean; errors: string[]; dirty: boolean; validating: boolean; valid: boolean; } interface FormContext<TSchema extends Schema = Schema> { props: { schema?: TSchema; values?: Partial<SchemaInferInput<TSchema>>; labelWidth?: string | number; orientation?: SkFieldUcvProps['orientation']; size?: SkFieldUcvProps['size']; disabled?: boolean; validateOn?: ('change' | 'blur' | 'focus')[]; debounceTime?: number; }; state: { isSubmitted: boolean; isGlobalValid: boolean; }; getFieldState: (name: string) => FormFieldState; handleFieldChange: (name: string, value: unknown) => void; handleFieldFocus: (name: string, value: unknown) => void; handleFieldBlur: (name: string, value: unknown) => void; handleSubmit: () => Promise<void>; } //#endregion export { FormContext, FormFieldState };