@qin-ui/antdv-next-pro 1.1.3 → 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 +52 -52
- 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,29 +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>>;
|
|
483
|
+
export declare type Fields<D extends Data = Data> = Array<Field<ComponentName, D>>;
|
|
461
484
|
|
|
462
485
|
/**
|
|
463
486
|
* @type {FieldTypeMap} 字段类型集合
|
|
464
487
|
*/
|
|
465
488
|
export declare type FieldTypeMap<D extends Data = Data> = {
|
|
466
|
-
|
|
467
|
-
custom: {
|
|
468
|
-
component?: RenderComponentType | Raw<RenderComponentType>;
|
|
469
|
-
} & WithCommon<{
|
|
489
|
+
[K in ComponentName]: K extends 'custom' ? WithCommon<{
|
|
470
490
|
slots?: Slots;
|
|
471
|
-
} &
|
|
472
|
-
|
|
473
|
-
|
|
491
|
+
}, D> & {
|
|
492
|
+
component?: RenderComponentType | Raw<RenderComponentType>;
|
|
493
|
+
} : WithComponent<GetComponentType<K>, D> & {
|
|
494
|
+
component?: K;
|
|
495
|
+
};
|
|
474
496
|
};
|
|
475
497
|
|
|
476
498
|
/**
|
|
477
499
|
* 重新定义 Form 类型:
|
|
478
|
-
* 1. 将第二个泛型参数 F 默认绑定为本地 Field<D>;
|
|
500
|
+
* 1. 将第二个泛型参数 F 默认绑定为本地 Field<ComponentName, D>;
|
|
479
501
|
* 2. 将 core Form 的第三个泛型参数 I 绑定为本地 UI 库(antdv-next)的 FormInstance,
|
|
480
502
|
* 使 formRef 的类型变为 Ref<FormInstance | undefined>。
|
|
481
503
|
*/
|
|
482
|
-
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>;
|
|
483
505
|
|
|
484
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>>;
|
|
485
507
|
|
|
@@ -720,7 +742,7 @@ export declare type RequiredComponentVars = {
|
|
|
720
742
|
'date-picker.year': FP<ComponentProps<GetComponentType<'date-picker'>>>;
|
|
721
743
|
'date-picker.quarter': FP<ComponentProps<GetComponentType<'date-picker'>>>;
|
|
722
744
|
} & {
|
|
723
|
-
[K in ComponentName]: FP<ComponentProps<GetComponentType<K>>>;
|
|
745
|
+
[K in Exclude<ComponentName, 'custom'>]: FP<ComponentProps<GetComponentType<K>>>;
|
|
724
746
|
};
|
|
725
747
|
|
|
726
748
|
declare type SearchFormProps = {
|
|
@@ -791,19 +813,19 @@ export declare type UseFields<D extends Data = Data> = ReturnType<typeof useFiel
|
|
|
791
813
|
* 使得 fields、getField 等方法的类型推断包含 UI 库的完整属性签名。
|
|
792
814
|
*/
|
|
793
815
|
export declare const useFields: {
|
|
794
|
-
<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>>;
|
|
795
817
|
};
|
|
796
818
|
|
|
797
|
-
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[]) => {
|
|
798
820
|
fields: Ref<F[], F[]>;
|
|
799
821
|
getField: {
|
|
800
|
-
(path: Path<D> | FieldFindBy<D, F>): Readonly<F
|
|
822
|
+
(path: Path<D> | FieldFindBy<D, F>): Readonly<F & AdditionalMethods<FormInstance>> | undefined;
|
|
801
823
|
(path: Path<D> | FieldFindBy<D, F>, options?: {
|
|
802
824
|
all?: false;
|
|
803
|
-
}): Readonly<F
|
|
825
|
+
}): Readonly<F & AdditionalMethods<FormInstance>> | undefined;
|
|
804
826
|
(path: Path<D> | FieldFindBy<D, F>, options: {
|
|
805
827
|
all: true;
|
|
806
|
-
}): Readonly<F
|
|
828
|
+
}): Readonly<F & AdditionalMethods<FormInstance>>[] | undefined;
|
|
807
829
|
};
|
|
808
830
|
setField: (path: Path<D> | FieldFindBy<D, F>, field: F | ((preField: Readonly<F>) => F), options?: {
|
|
809
831
|
updateType?: "rewrite" | "merge";
|
|
@@ -812,23 +834,23 @@ declare const useFields_2: <D extends Data = Data, F extends BaseField_2<D> = Ba
|
|
|
812
834
|
appendField: (path: Path<D> | FieldFindBy<D, F> | undefined, field: F | F[], options?: UpdateFieldOptions) => void;
|
|
813
835
|
prependField: (path: Path<D> | FieldFindBy<D, F> | undefined, field: F | F[], options?: UpdateFieldOptions) => void;
|
|
814
836
|
getParentField: {
|
|
815
|
-
(path: Path<D> | FieldFindBy<D, F>): F | undefined;
|
|
837
|
+
(path: Path<D> | FieldFindBy<D, F>): Readonly<F & AdditionalMethods<FormInstance>> | undefined;
|
|
816
838
|
(path: Path<D> | FieldFindBy<D, F>, options: {
|
|
817
839
|
all?: false;
|
|
818
|
-
}): F | undefined;
|
|
840
|
+
}): Readonly<F & AdditionalMethods<FormInstance>> | undefined;
|
|
819
841
|
(path: Path<D> | FieldFindBy<D, F>, options: {
|
|
820
842
|
all: true;
|
|
821
|
-
}): F[] | undefined;
|
|
843
|
+
}): Readonly<F & AdditionalMethods<FormInstance>>[] | undefined;
|
|
822
844
|
};
|
|
823
845
|
};
|
|
824
846
|
|
|
825
847
|
/**
|
|
826
848
|
* 类型断言 re-export @qin-ui/core 的 useForm,
|
|
827
|
-
* 将默认返回的 Form<D, BaseField<D>> 覆盖为本地的 Form<D, Field<D>>。
|
|
849
|
+
* 将默认返回的 Form<D, BaseField<D>> 覆盖为本地的 Form<D, Field<ComponentName, D>>。
|
|
828
850
|
*/
|
|
829
851
|
export declare const useForm: {
|
|
830
|
-
<D extends Data = Data>(initFormData?: ExtendWithAny<DeepPartial<D>>, initFields?: Field<D>[], root?: boolean): Form<D, Field<D>>;
|
|
831
|
-
<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>>;
|
|
832
854
|
};
|
|
833
855
|
|
|
834
856
|
/**
|
|
@@ -888,29 +910,7 @@ export declare type VModelProps<T = any> = {
|
|
|
888
910
|
'onUpdate:value'?: (val: T) => void;
|
|
889
911
|
};
|
|
890
912
|
|
|
891
|
-
|
|
892
|
-
/**
|
|
893
|
-
* @description 获取FormItem实例的方法
|
|
894
|
-
*/
|
|
895
|
-
getFormItemRef?: () => FormItemInstance;
|
|
896
|
-
/**
|
|
897
|
-
* @description 获取传入FormItem组件的属性
|
|
898
|
-
*/
|
|
899
|
-
getFormItemComputedProps?: () => Readonly<FormItemProps>;
|
|
900
|
-
/**
|
|
901
|
-
* @description 获取组件实例的方法
|
|
902
|
-
*/
|
|
903
|
-
getComponentRef?: () => any;
|
|
904
|
-
/**
|
|
905
|
-
* @description 获取传入Component组件的属性
|
|
906
|
-
*/
|
|
907
|
-
getComponentComputedProps?: () => Readonly<{
|
|
908
|
-
disabled?: boolean;
|
|
909
|
-
[x: string]: any;
|
|
910
|
-
}>;
|
|
911
|
-
};
|
|
912
|
-
|
|
913
|
-
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>>;
|
|
914
914
|
|
|
915
915
|
/**
|
|
916
916
|
* @description 自动从 Vue 组件提取 Props 和 Slots,并加上公共表单字段属性
|
|
@@ -919,7 +919,7 @@ declare type WithCommon<T, D extends Data = Data> = WithRef<T & FormItemProps &
|
|
|
919
919
|
*/
|
|
920
920
|
declare type WithComponent<T extends abstract new (...args: any) => any, D extends Data = Data> = WithCommon<{
|
|
921
921
|
slots?: ComponentSlots<T>;
|
|
922
|
-
} & ComponentProps<T>, D>;
|
|
922
|
+
} & Omit<ComponentProps<T>, keyof VNodeProps>, D>;
|
|
923
923
|
|
|
924
924
|
/**
|
|
925
925
|
* @description 为对象属性添加响应式支持的类型
|