@qin-ui/antd-vue-pro 2.1.3 → 2.1.4
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.
- package/es/index.d.ts +51 -57
- package/package.json +1 -1
package/es/index.d.ts
CHANGED
|
@@ -93,6 +93,30 @@ declare type __VLS_WithTemplateSlots<T, S> = T & {
|
|
|
93
93
|
};
|
|
94
94
|
};
|
|
95
95
|
|
|
96
|
+
declare type AdditionalMethods<FormItemInstance> = {
|
|
97
|
+
/**
|
|
98
|
+
* @description 获取FormItem实例的方法
|
|
99
|
+
*/
|
|
100
|
+
getFormItemRef?: () => FormItemInstance;
|
|
101
|
+
/**
|
|
102
|
+
* @description 获取传入FormItem组件的属性
|
|
103
|
+
*/
|
|
104
|
+
getFormItemComputedProps?: () => Readonly<{
|
|
105
|
+
[x: string]: any;
|
|
106
|
+
}>;
|
|
107
|
+
/**
|
|
108
|
+
* @description 获取组件实例的方法
|
|
109
|
+
*/
|
|
110
|
+
getComponentRef?: () => any;
|
|
111
|
+
/**
|
|
112
|
+
* @description 获取传入Component组件的属性
|
|
113
|
+
*/
|
|
114
|
+
getComponentComputedProps?: () => Readonly<{
|
|
115
|
+
disabled?: boolean;
|
|
116
|
+
[x: string]: any;
|
|
117
|
+
}>;
|
|
118
|
+
};
|
|
119
|
+
|
|
96
120
|
declare type AllowStringKey<T, Prefix extends string = ''> = {
|
|
97
121
|
[K in keyof T]: K extends string ? T[K] extends (infer U)[] ? `${Prefix}${K}` | (IsRecord<U> extends true ? AllowStringKey<U, `${Prefix}${K}[index].`> : never) : IsRecord<T[K]> extends true ? `${Prefix}${K}` | AllowStringKey<T[K], `${Prefix}${K}.`> : `${Prefix}${K}` : never;
|
|
98
122
|
}[keyof T];
|
|
@@ -186,6 +210,7 @@ export declare interface Base<D extends Data = Data> {
|
|
|
186
210
|
* @example { 'data-test': 'input-value', 'aria-label': 'name' }
|
|
187
211
|
*/
|
|
188
212
|
componentDataAttrs?: Record<string, string>;
|
|
213
|
+
[x: string]: any;
|
|
189
214
|
}
|
|
190
215
|
|
|
191
216
|
declare interface BaseColumn<D extends Data = Data> {
|
|
@@ -289,7 +314,7 @@ export declare interface ComponentMap {
|
|
|
289
314
|
|
|
290
315
|
export declare const componentMap: BaseComponentMap;
|
|
291
316
|
|
|
292
|
-
export declare type ComponentName = keyof BaseComponentMap | keyof ComponentMap;
|
|
317
|
+
export declare type ComponentName = keyof BaseComponentMap | keyof ComponentMap | 'custom';
|
|
293
318
|
|
|
294
319
|
export declare type ComponentVars = Partial<RequiredComponentVars>;
|
|
295
320
|
|
|
@@ -420,11 +445,7 @@ declare type ExtendWithAny<D> = {
|
|
|
420
445
|
* @description 字段配置类型,包含所有字段属性和响应式支持
|
|
421
446
|
* @template D - 数据对象类型
|
|
422
447
|
*/
|
|
423
|
-
export declare type Field<D extends Data = Data> =
|
|
424
|
-
[K in keyof FieldTypeMap]: {
|
|
425
|
-
component?: K extends 'custom' ? FieldTypeMap<D>[K]['component'] : K;
|
|
426
|
-
} & FieldTypeMap<D>[K];
|
|
427
|
-
}[keyof FieldTypeMap]>;
|
|
448
|
+
export declare type Field<C extends ComponentName = ComponentName, D extends Data = Data> = FieldTypeMap<D>[C];
|
|
428
449
|
|
|
429
450
|
declare type FieldFindBy<D extends Data, F extends BaseField_2<D> = BaseField_2<D>> = (field: Readonly<F>) => boolean;
|
|
430
451
|
|
|
@@ -432,29 +453,28 @@ declare type FieldFindBy<D extends Data, F extends BaseField_2<D> = BaseField_2<
|
|
|
432
453
|
* @description 字段数组类型
|
|
433
454
|
* @template D - 数据对象类型
|
|
434
455
|
*/
|
|
435
|
-
export declare type Fields<D extends Data = Data> = Array<Field<D>>;
|
|
456
|
+
export declare type Fields<D extends Data = Data> = Array<Field<ComponentName, D>>;
|
|
436
457
|
|
|
437
458
|
/**
|
|
438
459
|
* @type {FieldTypeMap} 字段类型集合
|
|
439
460
|
*/
|
|
440
461
|
export declare type FieldTypeMap<D extends Data = Data> = {
|
|
441
|
-
|
|
442
|
-
custom: {
|
|
443
|
-
component?: RenderComponentType | Raw<RenderComponentType>;
|
|
444
|
-
} & WithCommon<{
|
|
462
|
+
[K in ComponentName]: K extends 'custom' ? WithCommon<{
|
|
445
463
|
slots?: Slots;
|
|
446
|
-
} &
|
|
447
|
-
|
|
448
|
-
|
|
464
|
+
}, D> & {
|
|
465
|
+
component?: RenderComponentType | Raw<RenderComponentType>;
|
|
466
|
+
} : WithComponent<GetComponentType<K>, D> & {
|
|
467
|
+
component?: K;
|
|
468
|
+
};
|
|
449
469
|
};
|
|
450
470
|
|
|
451
471
|
/**
|
|
452
472
|
* 重新定义 Form 类型:
|
|
453
|
-
* 1. 将第二个泛型参数 F 默认绑定为本地 Field<D>;
|
|
473
|
+
* 1. 将第二个泛型参数 F 默认绑定为本地 Field<ComponentName, D>;
|
|
454
474
|
* 2. 将 core Form 的第三个泛型参数 I 绑定为本地 UI 库(Ant Design Vue)的 FormInstance,
|
|
455
475
|
* 使 formRef 的类型变为 Ref<FormInstance | undefined>。
|
|
456
476
|
*/
|
|
457
|
-
export declare type Form<D extends Data = Data, F extends Field<D> = Field<D>> = Form_2<D, F, FormInstance>;
|
|
477
|
+
export declare type Form<D extends Data = Data, F extends Field<ComponentName, D> = Field<ComponentName, D>> = Form_2<D, F, FormInstance>;
|
|
458
478
|
|
|
459
479
|
declare type Form_2<D extends Data = Data, F extends BaseField_2<D> = BaseField_2<D>, I = any> = ReturnType<typeof useFormData<D>> & ReturnType<typeof useFields_2<D, F>> & ReturnType<typeof useFormRef_2<I>>;
|
|
460
480
|
|
|
@@ -736,8 +756,6 @@ export declare type ProTableInstance = ComponentExposed<typeof _default_2>;
|
|
|
736
756
|
|
|
737
757
|
export declare type ProTableProps = ComponentProps<typeof _default_2>;
|
|
738
758
|
|
|
739
|
-
declare type ReadonlyFormItemProps = ComponentProps<typeof FormItem>;
|
|
740
|
-
|
|
741
759
|
/**
|
|
742
760
|
* @description 自定义组件
|
|
743
761
|
* @example (p, ctx) => h('div', ctx.attrs)
|
|
@@ -756,7 +774,7 @@ export declare type RequiredComponentVars = {
|
|
|
756
774
|
'date-picker.year': FP<ComponentProps<GetComponentType<'date-picker'>>>;
|
|
757
775
|
'date-picker.quarter': FP<ComponentProps<GetComponentType<'date-picker'>>>;
|
|
758
776
|
} & {
|
|
759
|
-
[K in ComponentName]: FP<ComponentProps<GetComponentType<K>>>;
|
|
777
|
+
[K in Exclude<ComponentName, 'custom'>]: FP<ComponentProps<GetComponentType<K>>>;
|
|
760
778
|
};
|
|
761
779
|
|
|
762
780
|
declare type SearchFormProps = {
|
|
@@ -823,23 +841,23 @@ export declare type UseFields<D extends Data = Data> = ReturnType<typeof useFiel
|
|
|
823
841
|
|
|
824
842
|
/**
|
|
825
843
|
* 类型断言 re-export @qin-ui/core 的 useFields,
|
|
826
|
-
* 将泛型参数 F 的默认值覆盖为本地的 Field<D>,
|
|
844
|
+
* 将泛型参数 F 的默认值覆盖为本地的 Field<ComponentName, D>,
|
|
827
845
|
* 使得 fields、getField 等方法的类型推断包含 Ant Design Vue 的完整属性签名。
|
|
828
846
|
*/
|
|
829
847
|
export declare const useFields: {
|
|
830
|
-
<D extends Data = Data>(initFields?: Fields<D>): ReturnType<typeof useFields_2<D, Field<D
|
|
848
|
+
<D extends Data = Data>(initFields?: Fields<D>): ReturnType<typeof useFields_2<D, Field<ComponentName, D>, FormItemInstance>>;
|
|
831
849
|
};
|
|
832
850
|
|
|
833
|
-
declare const useFields_2: <D extends Data = Data, F extends BaseField_2<D> = BaseField_2<D
|
|
851
|
+
declare const useFields_2: <D extends Data = Data, F extends BaseField_2<D> = BaseField_2<D>, FormInstance = any>(initFields?: F[]) => {
|
|
834
852
|
fields: Ref<F[], F[]>;
|
|
835
853
|
getField: {
|
|
836
|
-
(path: Path<D> | FieldFindBy<D, F>): Readonly<F
|
|
854
|
+
(path: Path<D> | FieldFindBy<D, F>): Readonly<F & AdditionalMethods<FormInstance>> | undefined;
|
|
837
855
|
(path: Path<D> | FieldFindBy<D, F>, options?: {
|
|
838
856
|
all?: false;
|
|
839
|
-
}): Readonly<F
|
|
857
|
+
}): Readonly<F & AdditionalMethods<FormInstance>> | undefined;
|
|
840
858
|
(path: Path<D> | FieldFindBy<D, F>, options: {
|
|
841
859
|
all: true;
|
|
842
|
-
}): Readonly<F
|
|
860
|
+
}): Readonly<F & AdditionalMethods<FormInstance>>[] | undefined;
|
|
843
861
|
};
|
|
844
862
|
setField: (path: Path<D> | FieldFindBy<D, F>, field: F | ((preField: Readonly<F>) => F), options?: {
|
|
845
863
|
updateType?: "rewrite" | "merge";
|
|
@@ -848,23 +866,23 @@ declare const useFields_2: <D extends Data = Data, F extends BaseField_2<D> = Ba
|
|
|
848
866
|
appendField: (path: Path<D> | FieldFindBy<D, F> | undefined, field: F | F[], options?: UpdateFieldOptions) => void;
|
|
849
867
|
prependField: (path: Path<D> | FieldFindBy<D, F> | undefined, field: F | F[], options?: UpdateFieldOptions) => void;
|
|
850
868
|
getParentField: {
|
|
851
|
-
(path: Path<D> | FieldFindBy<D, F>): F | undefined;
|
|
869
|
+
(path: Path<D> | FieldFindBy<D, F>): Readonly<F & AdditionalMethods<FormInstance>> | undefined;
|
|
852
870
|
(path: Path<D> | FieldFindBy<D, F>, options: {
|
|
853
871
|
all?: false;
|
|
854
|
-
}): F | undefined;
|
|
872
|
+
}): Readonly<F & AdditionalMethods<FormInstance>> | undefined;
|
|
855
873
|
(path: Path<D> | FieldFindBy<D, F>, options: {
|
|
856
874
|
all: true;
|
|
857
|
-
}): F[] | undefined;
|
|
875
|
+
}): Readonly<F & AdditionalMethods<FormInstance>>[] | undefined;
|
|
858
876
|
};
|
|
859
877
|
};
|
|
860
878
|
|
|
861
879
|
/**
|
|
862
880
|
* 类型断言 re-export @qin-ui/core 的 useForm,
|
|
863
|
-
* 将默认返回的 Form<D, BaseField<D>> 覆盖为本地的 Form<D, Field<D>>。
|
|
881
|
+
* 将默认返回的 Form<D, BaseField<D>> 覆盖为本地的 Form<D, Field<ComponentName, D>>。
|
|
864
882
|
*/
|
|
865
883
|
export declare const useForm: {
|
|
866
|
-
<D extends Data = Data>(initFormData?: ExtendWithAny<DeepPartial<D>>, initFields?: Field<D>[], root?: boolean): Form<D, Field<D>>;
|
|
867
|
-
<D extends Data = Data>(root?: boolean): Form<D, Field<D>>;
|
|
884
|
+
<D extends Data = Data>(initFormData?: ExtendWithAny<DeepPartial<D>>, initFields?: Field<ComponentName, D>[], root?: boolean): Form<D, Field<ComponentName, D>>;
|
|
885
|
+
<D extends Data = Data>(root?: boolean): Form<D, Field<ComponentName, D>>;
|
|
868
886
|
};
|
|
869
887
|
|
|
870
888
|
/**
|
|
@@ -925,31 +943,7 @@ export declare type VModelProps<T = any> = {
|
|
|
925
943
|
'onUpdate:value'?: (val: T) => void;
|
|
926
944
|
};
|
|
927
945
|
|
|
928
|
-
|
|
929
|
-
/**
|
|
930
|
-
* @description 获取FormItem实例的方法
|
|
931
|
-
*/
|
|
932
|
-
getFormItemRef?: () => FormItemInstance;
|
|
933
|
-
/**
|
|
934
|
-
* @description 获取传入FormItem组件的属性
|
|
935
|
-
*/
|
|
936
|
-
getFormItemComputedProps?: () => Readonly<{
|
|
937
|
-
[x: string]: any;
|
|
938
|
-
}>;
|
|
939
|
-
/**
|
|
940
|
-
* @description 获取组件实例的方法
|
|
941
|
-
*/
|
|
942
|
-
getComponentRef?: () => any;
|
|
943
|
-
/**
|
|
944
|
-
* @description 获取传入Component组件的属性
|
|
945
|
-
*/
|
|
946
|
-
getComponentComputedProps?: () => Readonly<{
|
|
947
|
-
disabled?: boolean;
|
|
948
|
-
[x: string]: any;
|
|
949
|
-
}>;
|
|
950
|
-
};
|
|
951
|
-
|
|
952
|
-
declare type WithCommon<T, D extends Data = Data> = WithRef<T & Omit<ReadonlyFormItemProps, 'label'> & ColProps & Base<D>>;
|
|
946
|
+
declare type WithCommon<T, D extends Data = Data> = WithRef<T & Omit<FormItemProps, 'label'> & ColProps & Base<D>>;
|
|
953
947
|
|
|
954
948
|
/**
|
|
955
949
|
* @description 自动从 Vue 组件提取 Props 和 Slots,并加上公共表单字段属性
|
|
@@ -958,7 +952,7 @@ declare type WithCommon<T, D extends Data = Data> = WithRef<T & Omit<ReadonlyFor
|
|
|
958
952
|
*/
|
|
959
953
|
declare type WithComponent<T extends abstract new (...args: any) => any, D extends Data = Data> = WithCommon<{
|
|
960
954
|
slots?: ComponentSlots<T>;
|
|
961
|
-
} & ComponentProps<T>, D>;
|
|
955
|
+
} & Omit<ComponentProps<T>, keyof VNodeProps>, D>;
|
|
962
956
|
|
|
963
957
|
/**
|
|
964
958
|
* @description 为对象属性添加响应式支持的类型
|