@qin-ui/antd-vue-pro 2.0.19 → 2.0.21

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.
Files changed (2) hide show
  1. package/es/index.d.ts +153 -21
  2. package/package.json +1 -1
package/es/index.d.ts CHANGED
@@ -17,15 +17,10 @@ import { ComponentProvideOptions } from 'vue';
17
17
  import { ComputedRef } from 'vue';
18
18
  import { CreateComponentPublicInstanceWithMixins } from 'vue';
19
19
  import { CSSProperties } from 'vue';
20
- import { Data } from '@qin-ui/core';
21
20
  import { DatePickerProps } from 'ant-design-vue';
22
- import { DeepPartial } from '@qin-ui/core';
23
21
  import { DefineComponent } from 'vue';
24
- import { ExtendWithAny } from '@qin-ui/core';
25
22
  import { ExtractPropTypes } from 'vue';
26
23
  import { FieldData } from 'ant-design-vue/es/form/interface';
27
- import { Fields as Fields_2 } from '@qin-ui/core';
28
- import { Form as Form_2 } from '@qin-ui/core';
29
24
  import { FormInstance } from 'ant-design-vue';
30
25
  import { FormItemInstance } from 'ant-design-vue';
31
26
  import { FormItemProps } from 'ant-design-vue';
@@ -34,23 +29,19 @@ import { FormProps as FormProps_2 } from 'ant-design-vue';
34
29
  import { GlobalComponents } from 'vue';
35
30
  import { GlobalDirectives } from 'vue';
36
31
  import { HTMLAttributes } from 'vue';
37
- import { InjectionFormKey } from '@qin-ui/core';
38
32
  import { InjectionKey } from 'vue';
39
- import { InjectionPathKey } from '@qin-ui/core';
40
33
  import { InputNumberProps } from 'ant-design-vue';
41
34
  import { InputProps } from 'ant-design-vue';
42
- import { KeyExpandString } from '@qin-ui/core';
43
35
  import { MaybeRef } from 'vue';
44
36
  import { Options as Options_2 } from 'scroll-into-view-if-needed';
45
- import { PageParam } from '@qin-ui/core';
46
- import { Path } from '@qin-ui/core';
47
- import { Paths } from '@qin-ui/core';
48
37
  import { Plugin as Plugin_2 } from 'vue';
49
38
  import { PropType } from 'vue';
50
39
  import { PublicProps } from 'vue';
51
40
  import { RadioGroupProps } from 'ant-design-vue';
52
41
  import { RangePickerProps } from 'ant-design-vue/es/date-picker';
53
42
  import { Raw } from 'vue';
43
+ import { Reactive } from 'vue';
44
+ import { Ref } from 'vue';
54
45
  import { RenderExpandIconProps } from 'ant-design-vue/es/vc-table/interface';
55
46
  import { RequiredMark } from 'ant-design-vue/es/form/Form';
56
47
  import { RowProps } from 'ant-design-vue';
@@ -61,15 +52,11 @@ import { ShallowUnwrapRef } from 'vue';
61
52
  import { SliderProps } from 'ant-design-vue';
62
53
  import { Slot } from 'vue';
63
54
  import { SwitchProps } from 'ant-design-vue';
64
- import { Table as Table_2 } from '@qin-ui/core';
65
55
  import { TableProps } from 'ant-design-vue';
66
56
  import { TextAreaProps } from 'ant-design-vue';
67
57
  import { TimePickerProps } from 'ant-design-vue';
68
58
  import { TransferProps } from 'ant-design-vue';
69
59
  import { TreeSelectProps } from 'ant-design-vue';
70
- import { useFields as useFields_2 } from '@qin-ui/core';
71
- import { useFormData } from '@qin-ui/core';
72
- import { useFormRef as useFormRef_2 } from '@qin-ui/core';
73
60
  import { ValidateErrorEntity } from 'ant-design-vue/es/form/interface';
74
61
  import { ValidateMessages } from 'ant-design-vue/es/form/interface';
75
62
  import { VNode } from 'vue';
@@ -103,6 +90,10 @@ declare type __VLS_WithTemplateSlots<T, S> = T & {
103
90
  };
104
91
  };
105
92
 
93
+ declare type AllowStringKey<T, Prefix extends string = ''> = {
94
+ [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;
95
+ }[keyof T];
96
+
106
97
  /**
107
98
  * @type {Object} Base - 基础公共字段类型
108
99
  */
@@ -194,6 +185,13 @@ export declare interface Base<D extends Data = Data> {
194
185
  [key: `data-component-${string}`]: string;
195
186
  }
196
187
 
188
+ declare interface BaseColumn<D extends Data = Data> {
189
+ key?: Path<D>;
190
+ dataIndex?: Path<D> | Path<D>[];
191
+ children?: BaseColumn<D>[];
192
+ [key: string]: any;
193
+ }
194
+
197
195
  /**
198
196
  * @description 基础组件字符串名称类型
199
197
  */
@@ -206,6 +204,13 @@ getComponentComputedProps: () => any;
206
204
  componentRef: unknown;
207
205
  }, any>;
208
206
 
207
+ declare interface BaseField_2<D extends Data = Data> {
208
+ path?: Path<D> | any;
209
+ name?: any;
210
+ fields?: any[];
211
+ [key: string]: any;
212
+ }
213
+
209
214
  export declare const BaseForm: <F extends Form<any> = Form>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal_2<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
210
215
  props: __VLS_PrettifyLocal_2<Pick<Partial<{}> & Omit<{} & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>, never> & ({
211
216
  grid?: Grid;
@@ -247,8 +252,12 @@ export declare type Column<D extends Data = Data> = Omit<ColumnType, 'dataIndex'
247
252
  hidden?: boolean;
248
253
  };
249
254
 
255
+ declare type ColumnFindBy<D extends Data, C extends BaseColumn<D> = BaseColumn<D>> = (column: Readonly<C>) => boolean;
256
+
250
257
  export declare type Columns<D extends Data = Data> = Array<Column<D>>;
251
258
 
259
+ declare type Columns_2<D extends Data = Data, C extends BaseColumn<D> = BaseColumn<D>> = Array<C>;
260
+
252
261
  export declare const COMPONENT_MAP: Map<BaseComponentStringName, Component>;
253
262
 
254
263
  export declare type ComponentVars = Partial<RequiredComponentVars>;
@@ -266,8 +275,14 @@ export declare type ContainerComponent = Component<PathProps>;
266
275
 
267
276
  export declare const ContainerFragment: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
268
277
 
278
+ declare type Data = Record<string, any>;
279
+
269
280
  declare type DatePickerSlots = CompSlot<'dateRender' | 'renderExtraFooter' | 'separator' | 'monthCellRender'>;
270
281
 
282
+ declare type DeepPartial<T> = T extends object ? {
283
+ [P in keyof T]?: DeepPartial<T[P]>;
284
+ } : T;
285
+
271
286
  declare const _default: {
272
287
  install(app: App): void;
273
288
  };
@@ -372,6 +387,10 @@ declare type ExpandButtonProps = ButtonProps & {
372
387
  expandStatus: boolean;
373
388
  };
374
389
 
390
+ declare type ExtendWithAny<D> = {
391
+ [K in keyof D]: IsRecord<D[K]> extends true ? ExtendWithAny<D[K]> : D[K];
392
+ } & Record<string, any>;
393
+
375
394
  /**
376
395
  * @description 字段配置类型,包含所有字段属性和响应式支持
377
396
  * @template D - 数据对象类型
@@ -382,12 +401,16 @@ export declare type Field<D extends Data = Data> = {
382
401
  } & FieldTypeMap<D>[K];
383
402
  }[keyof FieldTypeMap];
384
403
 
404
+ declare type FieldFindBy<D extends Data, F extends BaseField_2<D> = BaseField_2<D>> = (field: Readonly<F>) => boolean;
405
+
385
406
  /**
386
407
  * @description 字段数组类型
387
408
  * @template D - 数据对象类型
388
409
  */
389
410
  export declare type Fields<D extends Data = Data> = Array<Field<D>>;
390
411
 
412
+ declare type Fields_2<D extends Data = Data, F extends BaseField_2<D> = BaseField_2<D>> = F[];
413
+
391
414
  /**
392
415
  * @type {FieldTypeMap} 字段类型集合
393
416
  */
@@ -468,6 +491,8 @@ export declare type FieldTypeMap<D extends Data = Data> = {
468
491
  */
469
492
  export declare type Form<D extends Data = Data, F extends Field<D> = Field<D>> = Form_2<D, F, FormInstance>;
470
493
 
494
+ 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>>;
495
+
471
496
  export declare const FORM_ITEM_SLOT_KEYS: readonly ["label", "extra", "help", "tooltip"];
472
497
 
473
498
  export { FormInstance }
@@ -491,16 +516,31 @@ export declare const INJECT_CONFIG: {
491
516
  };
492
517
  };
493
518
 
494
- export { InjectionFormKey }
519
+ export declare const InjectionFormKey: InjectionKey<any>;
495
520
 
496
- export { InjectionPathKey }
521
+ export declare const InjectionPathKey: InjectionKey<ComputedRef<string | undefined>>;
497
522
 
498
523
  declare type InputNumberSlots = CompSlot<'addonAfter' | 'addonBefore' | 'prefix' | 'upIcon' | 'downIcon'>;
499
524
 
500
525
  declare type InputSlots = CompSlot<'addonAfter' | 'addonBefore' | 'clearIcon' | 'prefix' | 'suffix'>;
501
526
 
527
+ declare type IsRecord<T> = T extends object ? T extends ((...args: any[]) => any) | any[] | null ? false : true : false;
528
+
529
+ declare type JoinPath<Prefix extends any[], Key extends PropertyKey> = [
530
+ ...Prefix,
531
+ KeyExpandString<Extract<Key, string>>
532
+ ];
533
+
534
+ declare type KeyExpandString<T extends string> = T | (string & {});
535
+
536
+ declare type KeyPathString<D extends Data> = KeyExpandString<AllowStringKey<D>>;
537
+
502
538
  declare type MaybeRefOrComputedRef<T = any> = MaybeRef<T> | ComputedRef<T>;
503
539
 
540
+ declare type NormalizeField<D extends Data, F extends Field<D>> = [F] extends [never] ? Field<D> : F;
541
+
542
+ declare type NormalizeField_2<D extends Data, F extends Field<D>> = [F] extends [never] ? Field<D> : F;
543
+
504
544
  /**
505
545
  * @description 不支持响应式的属性名
506
546
  */
@@ -515,10 +555,23 @@ export { Option_2 as Option }
515
555
 
516
556
  export declare type Options = Array<Option_2>;
517
557
 
558
+ declare interface PageParam {
559
+ current: number;
560
+ pageSize: number;
561
+ total: number;
562
+ [key: string]: any;
563
+ }
564
+
565
+ declare type Path<D extends Data = Data> = KeyPathString<D>;
566
+
518
567
  export declare type PathProps = {
519
568
  path?: string;
520
569
  } & Data;
521
570
 
571
+ declare type Paths<T, Prefix extends any[] = []> = T extends object ? {
572
+ [K in keyof T]: IsRecord<T[K]> extends true ? JoinPath<Prefix, K> | Paths<T[K], JoinPath<Prefix, K>> : JoinPath<Prefix, K>;
573
+ }[keyof T] : never;
574
+
522
575
  declare type PP<T extends Record<string, any>> = Partial<T & AllowedComponentProps>;
523
576
 
524
577
  export declare const ProComponentProvider: SFCWithInstall<{
@@ -760,6 +813,12 @@ declare type SearchFormProps = {
760
813
 
761
814
  declare type SelectSlots = CompSlot<keyof InstanceType<typeof Select>['$slots']>;
762
815
 
816
+ declare type SetColumn<D extends Data = Data, C extends BaseColumn<D> = BaseColumn<D>> = (key: Path<D>, column: C | ((pre: Readonly<C>) => C), options?: {
817
+ updateType?: 'rewrite' | 'merge';
818
+ } & UpdateColumnOptions) => void;
819
+
820
+ declare type SetPageParam = (pageParam: Partial<PageParam> | ((pre: Readonly<PageParam>) => Partial<PageParam>)) => void;
821
+
763
822
  declare type SFCWithInstall<T> = T & Plugin_2;
764
823
 
765
824
  declare type SliderSlots = CompSlot<'mark'>;
@@ -785,6 +844,19 @@ declare type SwitchSlots = CompSlot<'checkedChildren' | 'unCheckedChildren'>;
785
844
  */
786
845
  export declare type Table<D extends Data = Data, T extends object = ExtendWithAny<D>> = Table_2<D, T, Column<D>>;
787
846
 
847
+ declare type Table_2<D extends Data = Data, T extends object = ExtendWithAny<D>, C extends BaseColumn<D> = BaseColumn<D>> = {
848
+ columns: Ref<Columns_2<D, C>>;
849
+ dataSource: Ref<T[]>;
850
+ pageParam: Reactive<PageParam>;
851
+ searchForm: Form_2<D>;
852
+ setColumn: SetColumn<D, C>;
853
+ deleteColumn: (path: Path<D> | ColumnFindBy<D, C>, options?: UpdateColumnOptions) => void;
854
+ appendColumn: (path: Path<D> | ColumnFindBy<D, C> | undefined, column: C | Columns_2<D, C>, options?: UpdateColumnOptions) => void;
855
+ prependColumn: (path: Path<D> | ColumnFindBy<D, C> | undefined, column: C | Columns_2<D, C>, options?: UpdateColumnOptions) => void;
856
+ setPageParam: SetPageParam;
857
+ resetQueryParams: () => void;
858
+ };
859
+
788
860
  export declare const TeleportComponentNamePrefix = "TeleportComponent_";
789
861
 
790
862
  declare type TimePickerSlots = CompSlot<'clearIcon' | 'renderExtraFooter' | 'suffixIcon'>;
@@ -793,6 +865,14 @@ declare type TransferSlots = CompSlot<'footer' | 'render'>;
793
865
 
794
866
  declare type TreeSelectSlots = CompSlot<'maxTagPlaceholder' | 'notFoundContent' | 'placeholder' | 'searchPlaceholder' | 'suffixIcon' | 'tagRender' | 'title'>;
795
867
 
868
+ declare type UpdateColumnOptions = {
869
+ all?: boolean;
870
+ };
871
+
872
+ declare type UpdateFieldOptions = {
873
+ all?: boolean;
874
+ };
875
+
796
876
  /** useFields 返回值类型,F 默认绑定为本地 Field<D> */
797
877
  export declare type UseFields<D extends Data = Data, F extends Field<D> = Field<D>> = ReturnType<typeof useFields<D, F>>;
798
878
 
@@ -802,7 +882,35 @@ export declare type UseFields<D extends Data = Data, F extends Field<D> = Field<
802
882
  * 使得 fields、getField 等方法的类型推断包含 Ant Design Vue 的完整属性签名。
803
883
  */
804
884
  export declare const useFields: {
805
- <D extends Data = Data, F extends Field<D> = Field<D>>(initFields?: F[]): ReturnType<typeof useFields_2<D, F>>;
885
+ <D extends Data = Data, F extends Field<D> = Field<D>>(initFields?: F[]): ReturnType<typeof useFields_2<D, NormalizeField_2<D, F>>>;
886
+ };
887
+
888
+ declare const useFields_2: <D extends Data = Data, F extends BaseField_2<D> = BaseField_2<D>>(initFields?: F[]) => {
889
+ fields: Ref<F[], F[]>;
890
+ getField: {
891
+ (path: Path<D> | FieldFindBy<D, F>): Readonly<F> | undefined;
892
+ (path: Path<D> | FieldFindBy<D, F>, options?: {
893
+ all?: false;
894
+ }): Readonly<F> | undefined;
895
+ (path: Path<D> | FieldFindBy<D, F>, options: {
896
+ all: true;
897
+ }): Readonly<F>[] | undefined;
898
+ };
899
+ setField: (path: Path<D> | FieldFindBy<D, F>, field: F | ((preField: Readonly<F>) => F), options?: {
900
+ updateType?: "rewrite" | "merge";
901
+ } & UpdateFieldOptions) => void;
902
+ deleteField: (path: Path<D> | FieldFindBy<D, F>, options?: UpdateFieldOptions) => void;
903
+ appendField: (path: Path<D> | FieldFindBy<D, F> | undefined, field: F | F[], options?: UpdateFieldOptions) => void;
904
+ prependField: (path: Path<D> | FieldFindBy<D, F> | undefined, field: F | F[], options?: UpdateFieldOptions) => void;
905
+ getParentField: {
906
+ (path: Path<D> | FieldFindBy<D, F>): F | undefined;
907
+ (path: Path<D> | FieldFindBy<D, F>, options: {
908
+ all?: false;
909
+ }): F | undefined;
910
+ (path: Path<D> | FieldFindBy<D, F>, options: {
911
+ all: true;
912
+ }): F[] | undefined;
913
+ };
806
914
  };
807
915
 
808
916
  /**
@@ -810,11 +918,30 @@ export declare const useFields: {
810
918
  * 将默认返回的 Form<D, BaseField<D>> 覆盖为本地的 Form<D, Field<D>>。
811
919
  */
812
920
  export declare const useForm: {
813
- <D extends Data = Data, F extends Field<D> = Field<D>>(initFormData?: ExtendWithAny<DeepPartial<D>>, initFields?: F[], root?: boolean): Form<D, F>;
814
- <D extends Data = Data, F extends Field<D> = Field<D>>(root?: boolean): Form<D, F>;
921
+ <D extends Data = Data, F extends Field<D> = Field<D>>(initFormData?: ExtendWithAny<DeepPartial<D>>, initFields?: F[], root?: boolean): Form<D, NormalizeField<D, F>>;
922
+ <D extends Data = Data, F extends Field<D> = Field<D>>(root?: boolean): Form<D, NormalizeField<D, F>>;
815
923
  };
816
924
 
817
- export { useFormData }
925
+ /**
926
+ * 表单数据处理hook
927
+ * @param initFormData 初始表单数据
928
+ * @returns {Object} { formData, getFormData, setFormData }
929
+ */
930
+ export declare const useFormData: <D extends Data = Data>(initFormData?: ExtendWithAny<DeepPartial<D>>) => {
931
+ formData: Reactive<ExtendWithAny<D>>;
932
+ getFormData: {
933
+ <K extends keyof D>(path: K): D[K];
934
+ <K extends keyof D & string, K1 extends keyof D[K] & string>(path: `${K}.${K1}`): D[K][K1];
935
+ <K extends keyof D & string, K1_1 extends keyof D[K] & string, K2 extends keyof D[K][K1_1] & string>(path: `${K}.${K1_1}.${K2}`): D[K][K1_1][K2];
936
+ (path: Path<D>): any;
937
+ };
938
+ setFormData: {
939
+ (path: Path<D>, value: any): void;
940
+ (path: Path<D>, value: (v: any) => any): void;
941
+ (value: ExtendWithAny<DeepPartial<D>>): void;
942
+ (value: (v: ExtendWithAny<DeepPartial<D>>) => ExtendWithAny<DeepPartial<D>>): void;
943
+ };
944
+ };
818
945
 
819
946
  /**
820
947
  * 类型断言 re-export @qin-ui/core 的 useFormRef,
@@ -824,6 +951,11 @@ export declare const useFormRef: {
824
951
  (): ReturnType<typeof useFormRef_2<FormInstance>>;
825
952
  };
826
953
 
954
+ declare const useFormRef_2: <F = any>() => {
955
+ formRef: Ref<F | undefined, F | undefined>;
956
+ setFormRef: (inst: F) => void;
957
+ };
958
+
827
959
  /**
828
960
  * 类型断言 re-export @qin-ui/core 的 useTable,
829
961
  * 将默认的 BaseColumn<D> 覆盖为本地的 Column<D>。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qin-ui/antd-vue-pro",
3
- "version": "2.0.19",
3
+ "version": "2.0.21",
4
4
  "description": "二次封装antd vue组件",
5
5
  "type": "module",
6
6
  "module": "es/index.js",