@qin-ui/antd-vue-pro 2.1.3 → 2.1.5

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/form/index.js CHANGED
@@ -111,7 +111,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
111
111
  const componentProps = { slots: {} };
112
112
  const formItemSlots = {};
113
113
  if (isPlainObject(props.field)) {
114
- const { path, name, fields, formItemClass, formItemStyle, hidden, span, getFormItemRef, getComponentRef, getFormItemComputedProps, getComponentComputedProps, slots = {}, formItemDataAttrs = {}, componentDataAttrs = {}, ...rest } = props.field;
114
+ const { path, name, fields, formItemClass, formItemStyle, hidden, span, getFormItemRef, getComponentRef, getFormItemComputedProps, getComponentComputedProps, slots = {}, formItemDataAttrs = {}, componentDataAttrs = {}, extraProps, ...rest } = props.field;
115
115
  const {
116
116
  class: injectClassName,
117
117
  style: injectStyle,
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,11 @@ 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
+ /**
214
+ * @description 额外的自定义属性,不会被当作组件参数,仅用做给字段添加标识属性等功能
215
+ * @example { group: 'group-1' }
216
+ */
217
+ extraProps?: Record<string, any>;
189
218
  }
190
219
 
191
220
  declare interface BaseColumn<D extends Data = Data> {
@@ -289,7 +318,7 @@ export declare interface ComponentMap {
289
318
 
290
319
  export declare const componentMap: BaseComponentMap;
291
320
 
292
- export declare type ComponentName = keyof BaseComponentMap | keyof ComponentMap;
321
+ export declare type ComponentName = keyof BaseComponentMap | keyof ComponentMap | 'custom';
293
322
 
294
323
  export declare type ComponentVars = Partial<RequiredComponentVars>;
295
324
 
@@ -420,11 +449,7 @@ declare type ExtendWithAny<D> = {
420
449
  * @description 字段配置类型,包含所有字段属性和响应式支持
421
450
  * @template D - 数据对象类型
422
451
  */
423
- export declare type Field<D extends Data = Data> = WithAdditionalMethodsGetter<{
424
- [K in keyof FieldTypeMap]: {
425
- component?: K extends 'custom' ? FieldTypeMap<D>[K]['component'] : K;
426
- } & FieldTypeMap<D>[K];
427
- }[keyof FieldTypeMap]>;
452
+ export declare type Field<C extends ComponentName = ComponentName, D extends Data = Data> = FieldTypeMap<D>[C];
428
453
 
429
454
  declare type FieldFindBy<D extends Data, F extends BaseField_2<D> = BaseField_2<D>> = (field: Readonly<F>) => boolean;
430
455
 
@@ -432,29 +457,29 @@ declare type FieldFindBy<D extends Data, F extends BaseField_2<D> = BaseField_2<
432
457
  * @description 字段数组类型
433
458
  * @template D - 数据对象类型
434
459
  */
435
- export declare type Fields<D extends Data = Data> = Array<Field<D>>;
460
+ export declare type Fields<D extends Data = Data> = Array<Field<ComponentName, D>>;
436
461
 
437
462
  /**
438
463
  * @type {FieldTypeMap} 字段类型集合
439
464
  */
440
465
  export declare type FieldTypeMap<D extends Data = Data> = {
441
- /** 自定义组件 */
442
- custom: {
443
- component?: RenderComponentType | Raw<RenderComponentType>;
444
- } & WithCommon<{
466
+ [K in ComponentName]: K extends 'custom' ? WithCommon<{
445
467
  slots?: Slots;
446
- } & Record<string, any>, D>;
447
- } & {
448
- [K in ComponentName]: WithComponent<GetComponentType<K>, D>;
468
+ [x: string]: any;
469
+ }, D> & {
470
+ component?: RenderComponentType | Raw<RenderComponentType>;
471
+ } : WithComponent<GetComponentType<K>, D> & {
472
+ component?: K;
473
+ };
449
474
  };
450
475
 
451
476
  /**
452
477
  * 重新定义 Form 类型:
453
- * 1. 将第二个泛型参数 F 默认绑定为本地 Field<D>;
478
+ * 1. 将第二个泛型参数 F 默认绑定为本地 Field<ComponentName, D>;
454
479
  * 2. 将 core Form 的第三个泛型参数 I 绑定为本地 UI 库(Ant Design Vue)的 FormInstance,
455
480
  * 使 formRef 的类型变为 Ref<FormInstance | undefined>。
456
481
  */
457
- export declare type Form<D extends Data = Data, F extends Field<D> = Field<D>> = Form_2<D, F, FormInstance>;
482
+ export declare type Form<D extends Data = Data, F extends Field<ComponentName, D> = Field<ComponentName, D>> = Form_2<D, F, FormInstance>;
458
483
 
459
484
  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
485
 
@@ -736,8 +761,6 @@ export declare type ProTableInstance = ComponentExposed<typeof _default_2>;
736
761
 
737
762
  export declare type ProTableProps = ComponentProps<typeof _default_2>;
738
763
 
739
- declare type ReadonlyFormItemProps = ComponentProps<typeof FormItem>;
740
-
741
764
  /**
742
765
  * @description 自定义组件
743
766
  * @example (p, ctx) => h('div', ctx.attrs)
@@ -756,7 +779,7 @@ export declare type RequiredComponentVars = {
756
779
  'date-picker.year': FP<ComponentProps<GetComponentType<'date-picker'>>>;
757
780
  'date-picker.quarter': FP<ComponentProps<GetComponentType<'date-picker'>>>;
758
781
  } & {
759
- [K in ComponentName]: FP<ComponentProps<GetComponentType<K>>>;
782
+ [K in Exclude<ComponentName, 'custom'>]: FP<ComponentProps<GetComponentType<K>>>;
760
783
  };
761
784
 
762
785
  declare type SearchFormProps = {
@@ -823,23 +846,23 @@ export declare type UseFields<D extends Data = Data> = ReturnType<typeof useFiel
823
846
 
824
847
  /**
825
848
  * 类型断言 re-export @qin-ui/core 的 useFields,
826
- * 将泛型参数 F 的默认值覆盖为本地的 Field<D>,
849
+ * 将泛型参数 F 的默认值覆盖为本地的 Field<ComponentName, D>,
827
850
  * 使得 fields、getField 等方法的类型推断包含 Ant Design Vue 的完整属性签名。
828
851
  */
829
852
  export declare const useFields: {
830
- <D extends Data = Data>(initFields?: Fields<D>): ReturnType<typeof useFields_2<D, Field<D>>>;
853
+ <D extends Data = Data>(initFields?: Fields<D>): ReturnType<typeof useFields_2<D, Field<ComponentName, D>, FormItemInstance>>;
831
854
  };
832
855
 
833
- declare const useFields_2: <D extends Data = Data, F extends BaseField_2<D> = BaseField_2<D>>(initFields?: F[]) => {
856
+ declare const useFields_2: <D extends Data = Data, F extends BaseField_2<D> = BaseField_2<D>, FormInstance = any>(initFields?: F[]) => {
834
857
  fields: Ref<F[], F[]>;
835
858
  getField: {
836
- (path: Path<D> | FieldFindBy<D, F>): Readonly<F> | undefined;
859
+ (path: Path<D> | FieldFindBy<D, F>): Readonly<F & AdditionalMethods<FormInstance>> | undefined;
837
860
  (path: Path<D> | FieldFindBy<D, F>, options?: {
838
861
  all?: false;
839
- }): Readonly<F> | undefined;
862
+ }): Readonly<F & AdditionalMethods<FormInstance>> | undefined;
840
863
  (path: Path<D> | FieldFindBy<D, F>, options: {
841
864
  all: true;
842
- }): Readonly<F>[] | undefined;
865
+ }): Readonly<F & AdditionalMethods<FormInstance>>[] | undefined;
843
866
  };
844
867
  setField: (path: Path<D> | FieldFindBy<D, F>, field: F | ((preField: Readonly<F>) => F), options?: {
845
868
  updateType?: "rewrite" | "merge";
@@ -848,23 +871,23 @@ declare const useFields_2: <D extends Data = Data, F extends BaseField_2<D> = Ba
848
871
  appendField: (path: Path<D> | FieldFindBy<D, F> | undefined, field: F | F[], options?: UpdateFieldOptions) => void;
849
872
  prependField: (path: Path<D> | FieldFindBy<D, F> | undefined, field: F | F[], options?: UpdateFieldOptions) => void;
850
873
  getParentField: {
851
- (path: Path<D> | FieldFindBy<D, F>): F | undefined;
874
+ (path: Path<D> | FieldFindBy<D, F>): Readonly<F & AdditionalMethods<FormInstance>> | undefined;
852
875
  (path: Path<D> | FieldFindBy<D, F>, options: {
853
876
  all?: false;
854
- }): F | undefined;
877
+ }): Readonly<F & AdditionalMethods<FormInstance>> | undefined;
855
878
  (path: Path<D> | FieldFindBy<D, F>, options: {
856
879
  all: true;
857
- }): F[] | undefined;
880
+ }): Readonly<F & AdditionalMethods<FormInstance>>[] | undefined;
858
881
  };
859
882
  };
860
883
 
861
884
  /**
862
885
  * 类型断言 re-export @qin-ui/core 的 useForm,
863
- * 将默认返回的 Form<D, BaseField<D>> 覆盖为本地的 Form<D, Field<D>>。
886
+ * 将默认返回的 Form<D, BaseField<D>> 覆盖为本地的 Form<D, Field<ComponentName, D>>。
864
887
  */
865
888
  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>>;
889
+ <D extends Data = Data>(initFormData?: ExtendWithAny<DeepPartial<D>>, initFields?: Field<ComponentName, D>[], root?: boolean): Form<D, Field<ComponentName, D>>;
890
+ <D extends Data = Data>(root?: boolean): Form<D, Field<ComponentName, D>>;
868
891
  };
869
892
 
870
893
  /**
@@ -925,31 +948,7 @@ export declare type VModelProps<T = any> = {
925
948
  'onUpdate:value'?: (val: T) => void;
926
949
  };
927
950
 
928
- export declare type WithAdditionalMethodsGetter<T> = T & {
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>>;
951
+ declare type WithCommon<T, D extends Data = Data> = WithRef<T & Omit<FormItemProps, 'label'> & ColProps & Base<D>>;
953
952
 
954
953
  /**
955
954
  * @description 自动从 Vue 组件提取 Props 和 Slots,并加上公共表单字段属性
@@ -958,7 +957,7 @@ declare type WithCommon<T, D extends Data = Data> = WithRef<T & Omit<ReadonlyFor
958
957
  */
959
958
  declare type WithComponent<T extends abstract new (...args: any) => any, D extends Data = Data> = WithCommon<{
960
959
  slots?: ComponentSlots<T>;
961
- } & ComponentProps<T>, D>;
960
+ } & Omit<ComponentProps<T>, keyof VNodeProps>, D>;
962
961
 
963
962
  /**
964
963
  * @description 为对象属性添加响应式支持的类型
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qin-ui/antd-vue-pro",
3
- "version": "2.1.3",
3
+ "version": "2.1.5",
4
4
  "description": "二次封装antd vue组件",
5
5
  "type": "module",
6
6
  "module": "es/index.js",