@qin-ui/antdv-next-pro 1.1.2 → 1.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 +53 -55
- package/package.json +1 -1
package/es/index.d.ts
CHANGED
|
@@ -97,6 +97,30 @@ declare type __VLS_WithTemplateSlots<T, S> = T & {
|
|
|
97
97
|
};
|
|
98
98
|
};
|
|
99
99
|
|
|
100
|
+
declare type AdditionalMethods<FormItemInstance> = {
|
|
101
|
+
/**
|
|
102
|
+
* @description 获取FormItem实例的方法
|
|
103
|
+
*/
|
|
104
|
+
getFormItemRef?: () => FormItemInstance;
|
|
105
|
+
/**
|
|
106
|
+
* @description 获取传入FormItem组件的属性
|
|
107
|
+
*/
|
|
108
|
+
getFormItemComputedProps?: () => Readonly<{
|
|
109
|
+
[x: string]: any;
|
|
110
|
+
}>;
|
|
111
|
+
/**
|
|
112
|
+
* @description 获取组件实例的方法
|
|
113
|
+
*/
|
|
114
|
+
getComponentRef?: () => any;
|
|
115
|
+
/**
|
|
116
|
+
* @description 获取传入Component组件的属性
|
|
117
|
+
*/
|
|
118
|
+
getComponentComputedProps?: () => Readonly<{
|
|
119
|
+
disabled?: boolean;
|
|
120
|
+
[x: string]: any;
|
|
121
|
+
}>;
|
|
122
|
+
};
|
|
123
|
+
|
|
100
124
|
declare type AllowStringKey<T, Prefix extends string = ''> = {
|
|
101
125
|
[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;
|
|
102
126
|
}[keyof T];
|
|
@@ -190,6 +214,7 @@ export declare interface Base<D extends Data = Data> {
|
|
|
190
214
|
* @description 组件v-model双向绑定更新属性名,默认'value'
|
|
191
215
|
*/
|
|
192
216
|
modelProp?: string;
|
|
217
|
+
[x: string]: any;
|
|
193
218
|
}
|
|
194
219
|
|
|
195
220
|
declare interface BaseColumn<D extends Data = Data> {
|
|
@@ -296,7 +321,7 @@ export declare interface ComponentMap {
|
|
|
296
321
|
|
|
297
322
|
export declare const componentMap: BaseComponentMap;
|
|
298
323
|
|
|
299
|
-
export declare type ComponentName = keyof BaseComponentMap | keyof ComponentMap;
|
|
324
|
+
export declare type ComponentName = keyof BaseComponentMap | keyof ComponentMap | 'custom';
|
|
300
325
|
|
|
301
326
|
export declare type ComponentVars = Partial<RequiredComponentVars>;
|
|
302
327
|
|
|
@@ -445,11 +470,9 @@ declare type ExtendWithAny<D> = {
|
|
|
445
470
|
* @description 字段配置类型,包含所有字段属性和响应式支持
|
|
446
471
|
* @template D - 数据对象类型
|
|
447
472
|
*/
|
|
448
|
-
export declare type Field<D extends Data = Data> =
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
} & FieldTypeMap<D>[K];
|
|
452
|
-
}[keyof FieldTypeMap]>;
|
|
473
|
+
export declare type Field<C extends ComponentName = ComponentName, D extends Data = Data> = FieldTypeMap<D>[C] & {
|
|
474
|
+
component?: C extends 'custom' ? FieldTypeMap<D>[C]['component'] : C;
|
|
475
|
+
};
|
|
453
476
|
|
|
454
477
|
declare type FieldFindBy<D extends Data, F extends BaseField_2<D> = BaseField_2<D>> = (field: Readonly<F>) => boolean;
|
|
455
478
|
|
|
@@ -457,31 +480,28 @@ declare type FieldFindBy<D extends Data, F extends BaseField_2<D> = BaseField_2<
|
|
|
457
480
|
* @description 字段数组类型
|
|
458
481
|
* @template D - 数据对象类型
|
|
459
482
|
*/
|
|
460
|
-
export declare type Fields<D extends Data = Data> = Array<Field<D>>;
|
|
461
|
-
|
|
462
|
-
declare type Fields_2<D extends Data = Data, F extends BaseField_2<D> = BaseField_2<D>> = F[];
|
|
483
|
+
export declare type Fields<D extends Data = Data> = Array<Field<ComponentName, D>>;
|
|
463
484
|
|
|
464
485
|
/**
|
|
465
486
|
* @type {FieldTypeMap} 字段类型集合
|
|
466
487
|
*/
|
|
467
488
|
export declare type FieldTypeMap<D extends Data = Data> = {
|
|
468
|
-
|
|
469
|
-
custom: {
|
|
470
|
-
component?: RenderComponentType | Raw<RenderComponentType>;
|
|
471
|
-
} & WithCommon<{
|
|
489
|
+
[K in ComponentName]: K extends 'custom' ? WithCommon<{
|
|
472
490
|
slots?: Slots;
|
|
473
|
-
} &
|
|
474
|
-
|
|
475
|
-
|
|
491
|
+
}, D> & {
|
|
492
|
+
component?: RenderComponentType | Raw<RenderComponentType>;
|
|
493
|
+
} : WithComponent<GetComponentType<K>, D> & {
|
|
494
|
+
component?: K;
|
|
495
|
+
};
|
|
476
496
|
};
|
|
477
497
|
|
|
478
498
|
/**
|
|
479
499
|
* 重新定义 Form 类型:
|
|
480
|
-
* 1. 将第二个泛型参数 F 默认绑定为本地 Field<D>;
|
|
500
|
+
* 1. 将第二个泛型参数 F 默认绑定为本地 Field<ComponentName, D>;
|
|
481
501
|
* 2. 将 core Form 的第三个泛型参数 I 绑定为本地 UI 库(antdv-next)的 FormInstance,
|
|
482
502
|
* 使 formRef 的类型变为 Ref<FormInstance | undefined>。
|
|
483
503
|
*/
|
|
484
|
-
export declare type Form<D extends Data = Data, F extends Field<D> = Field<D>> = Form_2<D, F, FormInstance>;
|
|
504
|
+
export declare type Form<D extends Data = Data, F extends Field<ComponentName, D> = Field<ComponentName, D>> = Form_2<D, F, FormInstance>;
|
|
485
505
|
|
|
486
506
|
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>>;
|
|
487
507
|
|
|
@@ -722,7 +742,7 @@ export declare type RequiredComponentVars = {
|
|
|
722
742
|
'date-picker.year': FP<ComponentProps<GetComponentType<'date-picker'>>>;
|
|
723
743
|
'date-picker.quarter': FP<ComponentProps<GetComponentType<'date-picker'>>>;
|
|
724
744
|
} & {
|
|
725
|
-
[K in ComponentName]: FP<ComponentProps<GetComponentType<K>>>;
|
|
745
|
+
[K in Exclude<ComponentName, 'custom'>]: FP<ComponentProps<GetComponentType<K>>>;
|
|
726
746
|
};
|
|
727
747
|
|
|
728
748
|
declare type SearchFormProps = {
|
|
@@ -793,19 +813,19 @@ export declare type UseFields<D extends Data = Data> = ReturnType<typeof useFiel
|
|
|
793
813
|
* 使得 fields、getField 等方法的类型推断包含 UI 库的完整属性签名。
|
|
794
814
|
*/
|
|
795
815
|
export declare const useFields: {
|
|
796
|
-
<D extends Data = Data>(initFields?: Fields<D>): ReturnType<typeof useFields_2<D, Field<D
|
|
816
|
+
<D extends Data = Data>(initFields?: Fields<D>): ReturnType<typeof useFields_2<D, Field<ComponentName, D>, FormItemInstance>>;
|
|
797
817
|
};
|
|
798
818
|
|
|
799
|
-
declare const useFields_2: <D extends Data = Data, F extends BaseField_2<D> = BaseField_2<D
|
|
819
|
+
declare const useFields_2: <D extends Data = Data, F extends BaseField_2<D> = BaseField_2<D>, FormInstance = any>(initFields?: F[]) => {
|
|
800
820
|
fields: Ref<F[], F[]>;
|
|
801
821
|
getField: {
|
|
802
|
-
(path: Path<D> | FieldFindBy<D, F>): Readonly<F
|
|
822
|
+
(path: Path<D> | FieldFindBy<D, F>): Readonly<F & AdditionalMethods<FormInstance>> | undefined;
|
|
803
823
|
(path: Path<D> | FieldFindBy<D, F>, options?: {
|
|
804
824
|
all?: false;
|
|
805
|
-
}): Readonly<F
|
|
825
|
+
}): Readonly<F & AdditionalMethods<FormInstance>> | undefined;
|
|
806
826
|
(path: Path<D> | FieldFindBy<D, F>, options: {
|
|
807
827
|
all: true;
|
|
808
|
-
}): Readonly<F
|
|
828
|
+
}): Readonly<F & AdditionalMethods<FormInstance>>[] | undefined;
|
|
809
829
|
};
|
|
810
830
|
setField: (path: Path<D> | FieldFindBy<D, F>, field: F | ((preField: Readonly<F>) => F), options?: {
|
|
811
831
|
updateType?: "rewrite" | "merge";
|
|
@@ -814,23 +834,23 @@ declare const useFields_2: <D extends Data = Data, F extends BaseField_2<D> = Ba
|
|
|
814
834
|
appendField: (path: Path<D> | FieldFindBy<D, F> | undefined, field: F | F[], options?: UpdateFieldOptions) => void;
|
|
815
835
|
prependField: (path: Path<D> | FieldFindBy<D, F> | undefined, field: F | F[], options?: UpdateFieldOptions) => void;
|
|
816
836
|
getParentField: {
|
|
817
|
-
(path: Path<D> | FieldFindBy<D, F>): F | undefined;
|
|
837
|
+
(path: Path<D> | FieldFindBy<D, F>): Readonly<F & AdditionalMethods<FormInstance>> | undefined;
|
|
818
838
|
(path: Path<D> | FieldFindBy<D, F>, options: {
|
|
819
839
|
all?: false;
|
|
820
|
-
}): F | undefined;
|
|
840
|
+
}): Readonly<F & AdditionalMethods<FormInstance>> | undefined;
|
|
821
841
|
(path: Path<D> | FieldFindBy<D, F>, options: {
|
|
822
842
|
all: true;
|
|
823
|
-
}): F[] | undefined;
|
|
843
|
+
}): Readonly<F & AdditionalMethods<FormInstance>>[] | undefined;
|
|
824
844
|
};
|
|
825
845
|
};
|
|
826
846
|
|
|
827
847
|
/**
|
|
828
848
|
* 类型断言 re-export @qin-ui/core 的 useForm,
|
|
829
|
-
* 将默认返回的 Form<D, BaseField<D>> 覆盖为本地的 Form<D, Field<D>>。
|
|
849
|
+
* 将默认返回的 Form<D, BaseField<D>> 覆盖为本地的 Form<D, Field<ComponentName, D>>。
|
|
830
850
|
*/
|
|
831
851
|
export declare const useForm: {
|
|
832
|
-
<D extends Data = Data>(initFormData?: ExtendWithAny<DeepPartial<D>>, initFields?: Field<D>[], root?: boolean): Form<D, Field<D>>;
|
|
833
|
-
<D extends Data = Data>(root?: boolean): Form<D, Field<D>>;
|
|
852
|
+
<D extends Data = Data>(initFormData?: ExtendWithAny<DeepPartial<D>>, initFields?: Field<ComponentName, D>[], root?: boolean): Form<D, Field<ComponentName, D>>;
|
|
853
|
+
<D extends Data = Data>(root?: boolean): Form<D, Field<ComponentName, D>>;
|
|
834
854
|
};
|
|
835
855
|
|
|
836
856
|
/**
|
|
@@ -875,7 +895,7 @@ export declare const useTable: <D extends Data = Data, T extends object = Extend
|
|
|
875
895
|
dataSource?: T[];
|
|
876
896
|
pageParam?: PageParam;
|
|
877
897
|
searchParam?: ExtendWithAny<DeepPartial<D>>;
|
|
878
|
-
searchFields?:
|
|
898
|
+
searchFields?: Fields<D>;
|
|
879
899
|
}) => Table<D, T>;
|
|
880
900
|
|
|
881
901
|
export declare type ValueFormatter = {
|
|
@@ -890,29 +910,7 @@ export declare type VModelProps<T = any> = {
|
|
|
890
910
|
'onUpdate:value'?: (val: T) => void;
|
|
891
911
|
};
|
|
892
912
|
|
|
893
|
-
|
|
894
|
-
/**
|
|
895
|
-
* @description 获取FormItem实例的方法
|
|
896
|
-
*/
|
|
897
|
-
getFormItemRef?: () => FormItemInstance;
|
|
898
|
-
/**
|
|
899
|
-
* @description 获取传入FormItem组件的属性
|
|
900
|
-
*/
|
|
901
|
-
getFormItemComputedProps?: () => Readonly<FormItemProps>;
|
|
902
|
-
/**
|
|
903
|
-
* @description 获取组件实例的方法
|
|
904
|
-
*/
|
|
905
|
-
getComponentRef?: () => any;
|
|
906
|
-
/**
|
|
907
|
-
* @description 获取传入Component组件的属性
|
|
908
|
-
*/
|
|
909
|
-
getComponentComputedProps?: () => Readonly<{
|
|
910
|
-
disabled?: boolean;
|
|
911
|
-
[x: string]: any;
|
|
912
|
-
}>;
|
|
913
|
-
};
|
|
914
|
-
|
|
915
|
-
declare type WithCommon<T, D extends Data = Data> = WithRef<T & FormItemProps & ColProps & Base<D>>;
|
|
913
|
+
declare type WithCommon<T, D extends Data = Data> = WithRef<T & Omit<FormItemProps, 'label'> & ColProps & Base<D>>;
|
|
916
914
|
|
|
917
915
|
/**
|
|
918
916
|
* @description 自动从 Vue 组件提取 Props 和 Slots,并加上公共表单字段属性
|
|
@@ -921,7 +919,7 @@ declare type WithCommon<T, D extends Data = Data> = WithRef<T & FormItemProps &
|
|
|
921
919
|
*/
|
|
922
920
|
declare type WithComponent<T extends abstract new (...args: any) => any, D extends Data = Data> = WithCommon<{
|
|
923
921
|
slots?: ComponentSlots<T>;
|
|
924
|
-
} & ComponentProps<T>, D>;
|
|
922
|
+
} & Omit<ComponentProps<T>, keyof VNodeProps>, D>;
|
|
925
923
|
|
|
926
924
|
/**
|
|
927
925
|
* @description 为对象属性添加响应式支持的类型
|