@qin-ui/antd-vue-pro 2.1.2 → 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 +52 -60
- 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,31 +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>>;
|
|
436
|
-
|
|
437
|
-
declare type Fields_2<D extends Data = Data, F extends BaseField_2<D> = BaseField_2<D>> = F[];
|
|
456
|
+
export declare type Fields<D extends Data = Data> = Array<Field<ComponentName, D>>;
|
|
438
457
|
|
|
439
458
|
/**
|
|
440
459
|
* @type {FieldTypeMap} 字段类型集合
|
|
441
460
|
*/
|
|
442
461
|
export declare type FieldTypeMap<D extends Data = Data> = {
|
|
443
|
-
|
|
444
|
-
custom: {
|
|
445
|
-
component?: RenderComponentType | Raw<RenderComponentType>;
|
|
446
|
-
} & WithCommon<{
|
|
462
|
+
[K in ComponentName]: K extends 'custom' ? WithCommon<{
|
|
447
463
|
slots?: Slots;
|
|
448
|
-
} &
|
|
449
|
-
|
|
450
|
-
|
|
464
|
+
}, D> & {
|
|
465
|
+
component?: RenderComponentType | Raw<RenderComponentType>;
|
|
466
|
+
} : WithComponent<GetComponentType<K>, D> & {
|
|
467
|
+
component?: K;
|
|
468
|
+
};
|
|
451
469
|
};
|
|
452
470
|
|
|
453
471
|
/**
|
|
454
472
|
* 重新定义 Form 类型:
|
|
455
|
-
* 1. 将第二个泛型参数 F 默认绑定为本地 Field<D>;
|
|
473
|
+
* 1. 将第二个泛型参数 F 默认绑定为本地 Field<ComponentName, D>;
|
|
456
474
|
* 2. 将 core Form 的第三个泛型参数 I 绑定为本地 UI 库(Ant Design Vue)的 FormInstance,
|
|
457
475
|
* 使 formRef 的类型变为 Ref<FormInstance | undefined>。
|
|
458
476
|
*/
|
|
459
|
-
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>;
|
|
460
478
|
|
|
461
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>>;
|
|
462
480
|
|
|
@@ -738,8 +756,6 @@ export declare type ProTableInstance = ComponentExposed<typeof _default_2>;
|
|
|
738
756
|
|
|
739
757
|
export declare type ProTableProps = ComponentProps<typeof _default_2>;
|
|
740
758
|
|
|
741
|
-
declare type ReadonlyFormItemProps = ComponentProps<typeof FormItem>;
|
|
742
|
-
|
|
743
759
|
/**
|
|
744
760
|
* @description 自定义组件
|
|
745
761
|
* @example (p, ctx) => h('div', ctx.attrs)
|
|
@@ -758,7 +774,7 @@ export declare type RequiredComponentVars = {
|
|
|
758
774
|
'date-picker.year': FP<ComponentProps<GetComponentType<'date-picker'>>>;
|
|
759
775
|
'date-picker.quarter': FP<ComponentProps<GetComponentType<'date-picker'>>>;
|
|
760
776
|
} & {
|
|
761
|
-
[K in ComponentName]: FP<ComponentProps<GetComponentType<K>>>;
|
|
777
|
+
[K in Exclude<ComponentName, 'custom'>]: FP<ComponentProps<GetComponentType<K>>>;
|
|
762
778
|
};
|
|
763
779
|
|
|
764
780
|
declare type SearchFormProps = {
|
|
@@ -825,23 +841,23 @@ export declare type UseFields<D extends Data = Data> = ReturnType<typeof useFiel
|
|
|
825
841
|
|
|
826
842
|
/**
|
|
827
843
|
* 类型断言 re-export @qin-ui/core 的 useFields,
|
|
828
|
-
* 将泛型参数 F 的默认值覆盖为本地的 Field<D>,
|
|
844
|
+
* 将泛型参数 F 的默认值覆盖为本地的 Field<ComponentName, D>,
|
|
829
845
|
* 使得 fields、getField 等方法的类型推断包含 Ant Design Vue 的完整属性签名。
|
|
830
846
|
*/
|
|
831
847
|
export declare const useFields: {
|
|
832
|
-
<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>>;
|
|
833
849
|
};
|
|
834
850
|
|
|
835
|
-
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[]) => {
|
|
836
852
|
fields: Ref<F[], F[]>;
|
|
837
853
|
getField: {
|
|
838
|
-
(path: Path<D> | FieldFindBy<D, F>): Readonly<F
|
|
854
|
+
(path: Path<D> | FieldFindBy<D, F>): Readonly<F & AdditionalMethods<FormInstance>> | undefined;
|
|
839
855
|
(path: Path<D> | FieldFindBy<D, F>, options?: {
|
|
840
856
|
all?: false;
|
|
841
|
-
}): Readonly<F
|
|
857
|
+
}): Readonly<F & AdditionalMethods<FormInstance>> | undefined;
|
|
842
858
|
(path: Path<D> | FieldFindBy<D, F>, options: {
|
|
843
859
|
all: true;
|
|
844
|
-
}): Readonly<F
|
|
860
|
+
}): Readonly<F & AdditionalMethods<FormInstance>>[] | undefined;
|
|
845
861
|
};
|
|
846
862
|
setField: (path: Path<D> | FieldFindBy<D, F>, field: F | ((preField: Readonly<F>) => F), options?: {
|
|
847
863
|
updateType?: "rewrite" | "merge";
|
|
@@ -850,23 +866,23 @@ declare const useFields_2: <D extends Data = Data, F extends BaseField_2<D> = Ba
|
|
|
850
866
|
appendField: (path: Path<D> | FieldFindBy<D, F> | undefined, field: F | F[], options?: UpdateFieldOptions) => void;
|
|
851
867
|
prependField: (path: Path<D> | FieldFindBy<D, F> | undefined, field: F | F[], options?: UpdateFieldOptions) => void;
|
|
852
868
|
getParentField: {
|
|
853
|
-
(path: Path<D> | FieldFindBy<D, F>): F | undefined;
|
|
869
|
+
(path: Path<D> | FieldFindBy<D, F>): Readonly<F & AdditionalMethods<FormInstance>> | undefined;
|
|
854
870
|
(path: Path<D> | FieldFindBy<D, F>, options: {
|
|
855
871
|
all?: false;
|
|
856
|
-
}): F | undefined;
|
|
872
|
+
}): Readonly<F & AdditionalMethods<FormInstance>> | undefined;
|
|
857
873
|
(path: Path<D> | FieldFindBy<D, F>, options: {
|
|
858
874
|
all: true;
|
|
859
|
-
}): F[] | undefined;
|
|
875
|
+
}): Readonly<F & AdditionalMethods<FormInstance>>[] | undefined;
|
|
860
876
|
};
|
|
861
877
|
};
|
|
862
878
|
|
|
863
879
|
/**
|
|
864
880
|
* 类型断言 re-export @qin-ui/core 的 useForm,
|
|
865
|
-
* 将默认返回的 Form<D, BaseField<D>> 覆盖为本地的 Form<D, Field<D>>。
|
|
881
|
+
* 将默认返回的 Form<D, BaseField<D>> 覆盖为本地的 Form<D, Field<ComponentName, D>>。
|
|
866
882
|
*/
|
|
867
883
|
export declare const useForm: {
|
|
868
|
-
<D extends Data = Data>(initFormData?: ExtendWithAny<DeepPartial<D>>, initFields?: Field<D>[], root?: boolean): Form<D, Field<D>>;
|
|
869
|
-
<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>>;
|
|
870
886
|
};
|
|
871
887
|
|
|
872
888
|
/**
|
|
@@ -912,7 +928,7 @@ export declare const useTable: <D extends Data = Data, T extends object = Extend
|
|
|
912
928
|
dataSource?: T[];
|
|
913
929
|
pageParam?: PageParam;
|
|
914
930
|
searchParam?: ExtendWithAny<DeepPartial<D>>;
|
|
915
|
-
searchFields?:
|
|
931
|
+
searchFields?: Fields<D>;
|
|
916
932
|
}) => Table<D, T>;
|
|
917
933
|
|
|
918
934
|
export declare type ValueFormatter = {
|
|
@@ -927,31 +943,7 @@ export declare type VModelProps<T = any> = {
|
|
|
927
943
|
'onUpdate:value'?: (val: T) => void;
|
|
928
944
|
};
|
|
929
945
|
|
|
930
|
-
|
|
931
|
-
/**
|
|
932
|
-
* @description 获取FormItem实例的方法
|
|
933
|
-
*/
|
|
934
|
-
getFormItemRef?: () => FormItemInstance;
|
|
935
|
-
/**
|
|
936
|
-
* @description 获取传入FormItem组件的属性
|
|
937
|
-
*/
|
|
938
|
-
getFormItemComputedProps?: () => Readonly<{
|
|
939
|
-
[x: string]: any;
|
|
940
|
-
}>;
|
|
941
|
-
/**
|
|
942
|
-
* @description 获取组件实例的方法
|
|
943
|
-
*/
|
|
944
|
-
getComponentRef?: () => any;
|
|
945
|
-
/**
|
|
946
|
-
* @description 获取传入Component组件的属性
|
|
947
|
-
*/
|
|
948
|
-
getComponentComputedProps?: () => Readonly<{
|
|
949
|
-
disabled?: boolean;
|
|
950
|
-
[x: string]: any;
|
|
951
|
-
}>;
|
|
952
|
-
};
|
|
953
|
-
|
|
954
|
-
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>>;
|
|
955
947
|
|
|
956
948
|
/**
|
|
957
949
|
* @description 自动从 Vue 组件提取 Props 和 Slots,并加上公共表单字段属性
|
|
@@ -960,7 +952,7 @@ declare type WithCommon<T, D extends Data = Data> = WithRef<T & Omit<ReadonlyFor
|
|
|
960
952
|
*/
|
|
961
953
|
declare type WithComponent<T extends abstract new (...args: any) => any, D extends Data = Data> = WithCommon<{
|
|
962
954
|
slots?: ComponentSlots<T>;
|
|
963
|
-
} & ComponentProps<T>, D>;
|
|
955
|
+
} & Omit<ComponentProps<T>, keyof VNodeProps>, D>;
|
|
964
956
|
|
|
965
957
|
/**
|
|
966
958
|
* @description 为对象属性添加响应式支持的类型
|