@qin-ui/antd-vue-pro 1.0.12 → 1.0.14

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
@@ -1728,6 +1728,12 @@ const round$1 = round;
1728
1728
  function set$1(object4, path, value) {
1729
1729
  return object4 == null ? object4 : baseSet(object4, path, value);
1730
1730
  }
1731
+ function toPath(value) {
1732
+ if (isArray$2(value)) {
1733
+ return arrayMap(value, toKey);
1734
+ }
1735
+ return isSymbol(value) ? [value] : copyArray(stringToPath$1(toString(value)));
1736
+ }
1731
1737
  function _typeof$1(o2) {
1732
1738
  "@babel/helpers - typeof";
1733
1739
  return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o3) {
@@ -15862,7 +15868,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
15862
15868
  ref: (el) => setFormItemRef(el, field),
15863
15869
  class: field.className,
15864
15870
  style: field.style,
15865
- name: getPath(field.key),
15871
+ name: _ctx.path ? unref(toPath)(getPath(field.key)) : getPath(field.key),
15866
15872
  path: getPath(field.key)
15867
15873
  }), createSlots({
15868
15874
  default: withCtx(() => [
@@ -15916,7 +15922,12 @@ const generateFieldMap = (fields, prePath = "", preFieldPath = "", fieldMap = {}
15916
15922
  fieldMap[path] = { field, fieldPath };
15917
15923
  }
15918
15924
  if (field.fields) {
15919
- generateFieldMap(field.fields, path, `${fieldPath}.fields`, fieldMap);
15925
+ generateFieldMap(
15926
+ field.fields,
15927
+ path,
15928
+ `${fieldPath}.fields`,
15929
+ fieldMap
15930
+ );
15920
15931
  }
15921
15932
  });
15922
15933
  return fieldMap;
@@ -16004,6 +16015,8 @@ const useFormData = (initFormData) => {
16004
16015
  const formData = ref(initFormData);
16005
16016
  const activePath = ref(null);
16006
16017
  const getFormData = (path) => {
16018
+ if (!path)
16019
+ return void 0;
16007
16020
  return get$1(formData.value, path);
16008
16021
  };
16009
16022
  const setFormData = (path, value) => {
@@ -16026,10 +16039,10 @@ const useFormData = (initFormData) => {
16026
16039
  };
16027
16040
  return { formData, getFormData, setFormData, activePath };
16028
16041
  };
16029
- const useForm = (initFormData, initFields) => {
16042
+ const useForm = (initFormData = {}, initFields = []) => {
16030
16043
  return {
16031
- ...useFormData(initFormData || {}),
16032
- ...useFields(initFields || [])
16044
+ ...useFormData(initFormData),
16045
+ ...useFields(initFields)
16033
16046
  };
16034
16047
  };
16035
16048
  const isFunctionString = (param) => {
package/es/index.d.ts CHANGED
@@ -20,7 +20,6 @@ import { ExtractPropTypes } from 'vue';
20
20
  import { FieldData } from 'ant-design-vue/es/form/interface';
21
21
  import type { FormItemProps } from 'ant-design-vue';
22
22
  import { FormLabelAlign } from 'ant-design-vue/es/form/interface';
23
- import type { FunctionalComponent } from 'vue';
24
23
  import { HTMLAttributes } from 'vue';
25
24
  import { InjectionKey } from 'vue';
26
25
  import type { InputNumberProps } from 'ant-design-vue';
@@ -69,7 +68,7 @@ declare type __VLS_WithTemplateSlots_2<T, S> = T & {
69
68
  };
70
69
  };
71
70
 
72
- export declare type AppendField = (path: string, field: Field) => void;
71
+ export declare type AppendField = (path: string | undefined, field: Field) => void;
73
72
 
74
73
  /**
75
74
  * @description js箭头函数字符串正则
@@ -179,9 +178,9 @@ export declare type CommandTrigger = 'onInit' | 'onUpdateValue' | 'onBlur' | 'on
179
178
  /**
180
179
  * @type {Object} Common - 公共字段类型
181
180
  */
182
- declare interface Common {
181
+ declare interface Common<D extends FormData_2 = FormData_2> {
183
182
  /** 标识key */
184
- key?: string;
183
+ key?: keyof D & string;
185
184
  /** 中文名称 */
186
185
  label?: SlotComponentType;
187
186
  /** 插槽,可包含formItem插槽和component插槽 */
@@ -228,15 +227,15 @@ export declare type Condition = {
228
227
  disabled?: boolean;
229
228
  };
230
229
 
231
- export declare type ContainerComponent = FunctionalComponent<Pick<RenderProps, 'path'>> | DefineComponent<Pick<RenderProps, 'path'>>;
230
+ export declare type ContainerComponent = Component<DefaultProps>;
232
231
 
233
232
  export declare const ContainerFragment: __VLS_WithTemplateSlots_2<DefineComponent<{
234
233
  component: {
235
- type: PropType<any>;
234
+ type: PropType<ContainerComponent>;
236
235
  };
237
236
  }, {}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
238
237
  component: {
239
- type: PropType<any>;
238
+ type: PropType<ContainerComponent>;
240
239
  };
241
240
  }>>, {}, {}>, {
242
241
  default?(_: {}): any;
@@ -257,7 +256,7 @@ declare const _default_2: __VLS_WithTemplateSlots<DefineComponent<{
257
256
  type: PropType<string>;
258
257
  };
259
258
  size: {
260
- type: PropType<"small" | "middle" | "large">;
259
+ type: PropType<"middle" | "small" | "large">;
261
260
  };
262
261
  disabled: {
263
262
  type: PropType<boolean>;
@@ -434,7 +433,7 @@ declare const _default_2: __VLS_WithTemplateSlots<DefineComponent<{
434
433
  type: PropType<string>;
435
434
  };
436
435
  size: {
437
- type: PropType<"small" | "middle" | "large">;
436
+ type: PropType<"middle" | "small" | "large">;
438
437
  };
439
438
  disabled: {
440
439
  type: PropType<boolean>;
@@ -599,20 +598,25 @@ declare const _default_2: __VLS_WithTemplateSlots<DefineComponent<{
599
598
  default?(_: {}): any;
600
599
  }>;
601
600
 
602
- export declare type DeleteField = (path: string) => void;
601
+ declare type DefaultProps = {
602
+ path?: string;
603
+ [key: string]: any;
604
+ };
605
+
606
+ export declare type DeleteField = (path?: string) => void;
603
607
 
604
608
  /**
605
609
  * @type {string} Expression - 表达式字符串 需要是一个js表达式字符串或者一个函数字符串,表达式的执行结果或者函数的返回值将作为结果返回
606
610
  */
607
611
  export declare type Expression = string;
608
612
 
609
- export declare type Field = FieldType[keyof FieldType] & Omit<FormItemProps, 'label'> & ColProps & Common;
613
+ export declare type Field<D extends FormData_2 = FormData_2> = FieldType[keyof FieldType] & Omit<FormItemProps, 'label'> & ColProps & Common<D>;
610
614
 
611
615
  declare type FieldAttrsType = {
612
616
  [key in keyof FieldType]: FieldType[key] & Pick<Common, 'slots' | 'componentStyle' | 'componentClassName' | 'componentContainer' | 'autoCommand'>;
613
617
  };
614
618
 
615
- export declare type Fields = Array<Field>;
619
+ export declare type Fields<D extends FormData_2 = FormData_2> = Array<Field<D>>;
616
620
 
617
621
  declare type FieldSlot<T extends string> = Partial<Record<T, SlotComponentType>>;
618
622
 
@@ -703,13 +707,15 @@ export declare type FieldType = {
703
707
  } & Record<string, any>;
704
708
  };
705
709
 
706
- export declare type Form = ReturnType<UseFields> & ReturnType<UseFormData>;
710
+ export declare type Form<D extends FormData_2 = FormData_2> = ReturnType<UseFormData<D>> & ReturnType<UseFields>;
707
711
 
708
712
  export declare const FORM_DATA: InjectionKey<Record<string, any>>;
709
713
 
710
714
  export declare const FORM_ITEM_SLOT_KEYS: readonly ["label", "extra", "help"];
711
715
 
712
- declare type FormData_2 = Record<string, any>;
716
+ declare type FormData_2 = {
717
+ [key: string]: any;
718
+ };
713
719
  export { FormData_2 as FormData }
714
720
 
715
721
  /**
@@ -717,13 +723,13 @@ export { FormData_2 as FormData }
717
723
  */
718
724
  export declare const FunctionRegexp: RegExp;
719
725
 
720
- export declare type GetField = (path: string) => Field | undefined;
726
+ export declare type GetField = (path?: string) => Field | undefined;
721
727
 
722
- export declare type GetFieldPath = (path: string) => string | undefined;
728
+ export declare type GetFieldPath = (path?: string) => string | undefined;
723
729
 
724
- export declare type GetFormData = (path: string) => DeepReadonly<any>;
730
+ export declare type GetFormData = (path?: string) => DeepReadonly<any>;
725
731
 
726
- export declare type GetParentField = (path: string) => Field | undefined;
732
+ export declare type GetParentField = (path?: string) => Field | undefined;
727
733
 
728
734
  export declare type Grid = boolean | RowProps;
729
735
 
@@ -846,7 +852,7 @@ declare type Option_2 = {
846
852
 
847
853
  export declare type Options = Array<Option_2>;
848
854
 
849
- export declare type PrependField = (path: string, field: Field) => void;
855
+ export declare type PrependField = (path: string | undefined, field: Field) => void;
850
856
 
851
857
  export declare const ProComponentProvider: SFCWithInstall<{
852
858
  new (...args: any[]): {
@@ -969,7 +975,7 @@ export declare const ProForm: SFCWithInstall<{
969
975
  autoCommandDisabled?: boolean | undefined;
970
976
  readonly prefixCls?: string | undefined;
971
977
  readonly name?: string | undefined;
972
- readonly size?: "small" | "middle" | "large" | undefined;
978
+ readonly size?: "middle" | "small" | "large" | undefined;
973
979
  readonly disabled?: boolean | undefined;
974
980
  readonly labelCol?: (Partial<ExtractPropTypes<{
975
981
  span: (StringConstructor | NumberConstructor)[];
@@ -1126,7 +1132,7 @@ export declare const ProForm: SFCWithInstall<{
1126
1132
  type: PropType<string>;
1127
1133
  };
1128
1134
  size: {
1129
- type: PropType<"small" | "middle" | "large">;
1135
+ type: PropType<"middle" | "small" | "large">;
1130
1136
  };
1131
1137
  disabled: {
1132
1138
  type: PropType<boolean>;
@@ -1331,7 +1337,7 @@ export declare const ProForm: SFCWithInstall<{
1331
1337
  type: PropType<string>;
1332
1338
  };
1333
1339
  size: {
1334
- type: PropType<"small" | "middle" | "large">;
1340
+ type: PropType<"middle" | "small" | "large">;
1335
1341
  };
1336
1342
  disabled: {
1337
1343
  type: PropType<boolean>;
@@ -1512,7 +1518,7 @@ export declare const ProForm: SFCWithInstall<{
1512
1518
  type: PropType<string>;
1513
1519
  };
1514
1520
  size: {
1515
- type: PropType<"small" | "middle" | "large">;
1521
+ type: PropType<"middle" | "small" | "large">;
1516
1522
  };
1517
1523
  disabled: {
1518
1524
  type: PropType<boolean>;
@@ -1706,16 +1712,9 @@ export declare type Refs = {
1706
1712
 
1707
1713
  /**
1708
1714
  * @description 自定义组件
1709
- * @example (renderProps, ctx) => h('div', ctx.attrs)
1715
+ * @example (p, ctx) => h('div', ctx.attrs)
1710
1716
  */
1711
- export declare type RenderComponentType = FunctionalComponent<RenderProps> | DefineComponent<RenderProps>;
1712
-
1713
- declare type RenderProps = {
1714
- path: string;
1715
- value: unknown;
1716
- 'onUpdate:value': (val: unknown) => void;
1717
- [key: string]: any;
1718
- };
1717
+ export declare type RenderComponentType = Component<VModelProps & DefaultProps>;
1719
1718
 
1720
1719
  /**
1721
1720
  * @type {object} Rule - 逻辑运行规则
@@ -1749,9 +1748,9 @@ export declare type RuleType = 'value' | 'hidden' | 'disabled' | 'options' | 'va
1749
1748
 
1750
1749
  declare type SelectSlots = FieldSlot<keyof InstanceType<typeof Select>['$slots']>;
1751
1750
 
1752
- export declare type SetField = (path: string, field: Field | ((preField: ReturnType<GetField>) => Field)) => void;
1751
+ export declare type SetField = (path: string | undefined, field: Field | ((preField: ReturnType<GetField>) => Field)) => void;
1753
1752
 
1754
- export declare type SetFormData = (path: string, value: any | ((preValue: DeepReadonly<any>) => any)) => void;
1753
+ export declare type SetFormData = (path: string | undefined, value: any | ((preValue: DeepReadonly<any>) => any)) => void;
1755
1754
 
1756
1755
  declare type SFCWithInstall<T> = T & Plugin_2;
1757
1756
 
@@ -1772,7 +1771,7 @@ export declare const SlotComponent: DefineComponent<{
1772
1771
  };
1773
1772
  }>>, {}, {}>;
1774
1773
 
1775
- export declare type SlotComponentType = string | VNode | FunctionalComponent<Pick<RenderProps, 'path'>>;
1774
+ export declare type SlotComponentType = string | Component<DefaultProps>;
1776
1775
 
1777
1776
  declare type SwitchSlots = FieldSlot<'checkedChildren' | 'unCheckedChildren'>;
1778
1777
 
@@ -1823,7 +1822,7 @@ export declare type UseFields = (initFields: Fields) => {
1823
1822
 
1824
1823
  export declare const useFields: UseFields;
1825
1824
 
1826
- export declare type UseForm = <T extends FormData_2>(initFormData?: T, initFields?: Fields) => Form;
1825
+ export declare type UseForm<T extends FormData_2 = FormData_2> = <D extends T = T>(initFormData?: Partial<D>, initFields?: Fields<D>) => Form<D>;
1827
1826
 
1828
1827
  export declare const useForm: UseForm;
1829
1828
 
@@ -1832,9 +1831,9 @@ export declare const useForm: UseForm;
1832
1831
  * @param {array} initFormData - 初始化表单数据
1833
1832
  * @returns {Object}
1834
1833
  */
1835
- export declare type UseFormData = (initFormData: FormData_2) => {
1834
+ export declare type UseFormData<D extends FormData_2 = FormData_2> = (initFormData: Partial<D>) => {
1836
1835
  /** 表单数据Ref */
1837
- formData: Ref<FormData_2>;
1836
+ formData: Ref<D | FormData_2>;
1838
1837
  /** 获取指定字段数据路径的值 */
1839
1838
  getFormData: GetFormData;
1840
1839
  /** 设置指定字段数据路径的值 */
@@ -1849,4 +1848,9 @@ export declare const useInitProps: () => {
1849
1848
  getInitProps: (field: Field) => Record<string, any>;
1850
1849
  };
1851
1850
 
1851
+ declare type VModelProps = {
1852
+ value: unknown;
1853
+ 'onUpdate:value': (val: unknown) => void;
1854
+ };
1855
+
1852
1856
  export { }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qin-ui/antd-vue-pro",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "description": "二次封装antd vue组件",
5
5
  "type": "module",
6
6
  "main": "",