@extclp/vexip-ui
Version:
A Vue 3 UI library, Highly customizability, full TypeScript, performance pretty good
1 lines • 3.24 kB
Source Map (JSON)
{"version":3,"file":"symbol.mjs","sources":["../../../components/form/symbol.ts"],"sourcesContent":["import type { InjectionKey, Ref } from 'vue'\r\nimport type { ComponentSize, ComponentState } from '@vexip-ui/config'\r\nimport type { EventEmitter } from '@vexip-ui/utils'\r\nimport type { Rule } from './validator'\r\n\r\nexport type FormLabelAlign = 'right' | 'top' | 'left'\r\nexport type SubmitMethod = 'get' | 'post' | 'put' | 'delete'\r\n\r\nexport interface FormProps {\r\n method: SubmitMethod,\r\n action: string,\r\n model: Record<string, any>,\r\n rules: Record<string, any>,\r\n labelWidth: number | 'auto',\r\n labelAlign: FormLabelAlign,\r\n allRequired: boolean,\r\n labelSuffix: string,\r\n hideAsterisk: boolean,\r\n validateAll: boolean,\r\n hideLabel: boolean,\r\n disabled: boolean,\r\n loading: boolean,\r\n size: ComponentSize,\r\n inline: boolean,\r\n}\r\n\r\nexport interface FormItemProps {\r\n label: string,\r\n prop: string,\r\n rules: Rule | Rule[],\r\n labelWidth: number | 'auto',\r\n required: boolean,\r\n htmlFor: string,\r\n errorTransition: string,\r\n defaultValue: unknown,\r\n hideErrorTip: boolean,\r\n validateAll: boolean,\r\n hideAsterisk: boolean,\r\n}\r\n\r\nexport interface FormItemSlots {\r\n default?: (parmas: { isError: boolean }) => any,\r\n help?: () => any,\r\n label?: () => any,\r\n error?: (params: { tip: string }) => any,\r\n}\r\n\r\nexport interface FieldOptions {\r\n prop: Ref<string>,\r\n idFor: Ref<string>,\r\n labelId: Ref<string>,\r\n state: Ref<ComponentState>,\r\n disabled: Ref<boolean>,\r\n loading: Ref<boolean>,\r\n size: Ref<ComponentSize>,\r\n emitter: EventEmitter,\r\n labelWidth: Ref<number>,\r\n validate: () => Promise<string[] | null>,\r\n reset: () => boolean,\r\n clearError: () => void,\r\n getValue: (defaultValue?: unknown) => unknown,\r\n setValue: (value: unknown, strict?: boolean) => void,\r\n sync: (instance: any) => void,\r\n unSync: (instance: any) => void,\r\n}\r\n\r\nexport interface FormActions {\r\n getLabelWidth: () => number,\r\n validate: () => Promise<string[]>,\r\n validateFields: (props: string | string[]) => Promise<string[]>,\r\n reset: () => void,\r\n resetFields: (props: string | string[]) => void,\r\n clearError: () => void,\r\n clearFieldsError: (props: string | string[]) => void,\r\n}\r\n\r\n// form\r\nexport const FORM_PROPS = '__VXP_FORM_PROPS' as unknown as InjectionKey<Partial<FormProps>>\r\nexport const FORM_FIELDS = '__VXP_FORM_FIELDS' as unknown as InjectionKey<Set<FieldOptions>>\r\nexport const FORM_ACTIONS = '__VXP_FORM_ACTIONS' as unknown as InjectionKey<FormActions>\r\n\r\n// form-item\r\nexport const FIELD_OPTIONS = '__VXP_FIELD_OPTIONS' as unknown as InjectionKey<FieldOptions | null>\r\n\r\nexport const submitMethods = Object.freeze<SubmitMethod[]>(['get', 'post', 'put', 'delete'])\r\nexport const labelAligns = Object.freeze<FormLabelAlign[]>(['right', 'top', 'left'])\r\n"],"names":["FORM_PROPS","FORM_FIELDS","FORM_ACTIONS","FIELD_OPTIONS","submitMethods","labelAligns"],"mappings":"AA6EO,MAAMA,IAAa,oBACbC,IAAc,qBACdC,IAAe,sBAGfC,IAAgB,uBAEhBC,IAAgB,OAAO,OAAuB,CAAC,OAAO,QAAQ,OAAO,QAAQ,CAAC,GAC9EC,IAAc,OAAO,OAAyB,CAAC,SAAS,OAAO,MAAM,CAAC;"}