@veltra/utils 1.7.9 → 1.7.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -38,8 +38,10 @@ type DIContext = {
|
|
|
38
38
|
validateFields?: (keys?: string[]) => Promise<boolean>;
|
|
39
39
|
/** 是否需要校验 */
|
|
40
40
|
shouldValidate?: () => boolean;
|
|
41
|
-
/**
|
|
42
|
-
|
|
41
|
+
/** 处理字段 model 更新(watch 触发) */
|
|
42
|
+
handleFieldUpdate: (field: string, value: any) => void;
|
|
43
|
+
/** 处理控件 change 事件 */
|
|
44
|
+
handleFieldChange: (field: string, ...args: any[]) => void;
|
|
43
45
|
};
|
|
44
46
|
declare function provideFormContext(context: DIContext): void;
|
|
45
47
|
declare function injectFormContext(): {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-context.js","names":[],"sources":["../../src/types/form-context.ts"],"sourcesContent":["import { type InjectionKey, inject, provide } from 'vue'\n\nimport type { ComponentSize } from './component-common'\n\nexport interface FormContextModel {\n errors: Map<any, string[] | undefined>\n fields: Record<string, { required?: unknown }>\n}\n\nexport interface FormContextProps {\n /** 表单列宽 */\n labelWidth?: string | number\n /** 表单项 label 位置 */\n labelPosition?: 'top' | 'left'\n /** 表单尺寸 */\n size?: ComponentSize\n /** 是否禁用 */\n disabled?: boolean\n /** 是否只读 */\n readonly?: boolean\n /** 是否隐藏提示 */\n noTips?: boolean\n /** 表单数据 */\n model?: Record<string, any>\n}\n\ntype FormPropsLike = Partial<FormContextProps> & Record<string, any>\n\nexport interface FormFieldItem {\n validate: () => Promise<boolean>\n clearValidate?: () => void\n}\n\ntype DIContext = {\n /** 表单属性 */\n formProps: FormPropsLike\n /** 注册表单字段 */\n registerField: (field: string, item: FormFieldItem) => void\n /** 注销表单字段 */\n unregisterField: (field: string) => void\n /** 校验指定字段,未传 keys 时校验全部已注册字段 */\n validateFields?: (keys?: string[]) => Promise<boolean>\n /** 是否需要校验 */\n shouldValidate?: () => boolean\n /**
|
|
1
|
+
{"version":3,"file":"form-context.js","names":[],"sources":["../../src/types/form-context.ts"],"sourcesContent":["import { type InjectionKey, inject, provide } from 'vue'\n\nimport type { ComponentSize } from './component-common'\n\nexport interface FormContextModel {\n errors: Map<any, string[] | undefined>\n fields: Record<string, { required?: unknown }>\n}\n\nexport interface FormContextProps {\n /** 表单列宽 */\n labelWidth?: string | number\n /** 表单项 label 位置 */\n labelPosition?: 'top' | 'left'\n /** 表单尺寸 */\n size?: ComponentSize\n /** 是否禁用 */\n disabled?: boolean\n /** 是否只读 */\n readonly?: boolean\n /** 是否隐藏提示 */\n noTips?: boolean\n /** 表单数据 */\n model?: Record<string, any>\n}\n\ntype FormPropsLike = Partial<FormContextProps> & Record<string, any>\n\nexport interface FormFieldItem {\n validate: () => Promise<boolean>\n clearValidate?: () => void\n}\n\ntype DIContext = {\n /** 表单属性 */\n formProps: FormPropsLike\n /** 注册表单字段 */\n registerField: (field: string, item: FormFieldItem) => void\n /** 注销表单字段 */\n unregisterField: (field: string) => void\n /** 校验指定字段,未传 keys 时校验全部已注册字段 */\n validateFields?: (keys?: string[]) => Promise<boolean>\n /** 是否需要校验 */\n shouldValidate?: () => boolean\n /** 处理字段 model 更新(watch 触发) */\n handleFieldUpdate: (field: string, value: any) => void\n /** 处理控件 change 事件 */\n handleFieldChange: (field: string, ...args: any[]) => void\n}\n\nconst FormComponentDIKey: InjectionKey<DIContext> = Symbol('FormComponentDIKey')\n\nexport function provideFormContext(context: DIContext): void {\n provide(FormComponentDIKey, context)\n}\n\nexport function injectFormContext(): {\n /** 是否在表单中 */\n inForm: boolean\n} & Partial<DIContext> {\n const context = inject(FormComponentDIKey, undefined) || {}\n return { inForm: !!context, ...context }\n}\n"],"mappings":";;AAkDA,MAAM,qBAA8C,OAAO,oBAAoB;AAE/E,SAAgB,mBAAmB,SAA0B;CAC3D,QAAQ,oBAAoB,OAAO;AACrC;AAEA,SAAgB,oBAGO;CACrB,MAAM,UAAU,OAAO,oBAAoB,KAAA,CAAS,KAAK,CAAC;CAC1D,OAAO;EAAE,QAAQ,CAAC,CAAC;EAAS,GAAG;CAAQ;AACzC"}
|
package/package.json
CHANGED
|
@@ -42,8 +42,10 @@ type DIContext = {
|
|
|
42
42
|
validateFields?: (keys?: string[]) => Promise<boolean>
|
|
43
43
|
/** 是否需要校验 */
|
|
44
44
|
shouldValidate?: () => boolean
|
|
45
|
-
/**
|
|
46
|
-
|
|
45
|
+
/** 处理字段 model 更新(watch 触发) */
|
|
46
|
+
handleFieldUpdate: (field: string, value: any) => void
|
|
47
|
+
/** 处理控件 change 事件 */
|
|
48
|
+
handleFieldChange: (field: string, ...args: any[]) => void
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
const FormComponentDIKey: InjectionKey<DIContext> = Symbol('FormComponentDIKey')
|