@qin-ui/antd-vue-pro 2.4.3 → 2.4.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.
Files changed (29) hide show
  1. package/AI-CONTEXT.md +4 -4
  2. package/README.md +4 -3
  3. package/api.json +2 -2
  4. package/es/antd-vue-pro.css +11 -11
  5. package/es/components/form/components/BaseField/index.vue.d.ts.map +1 -1
  6. package/es/components/form/components/BaseFormItem/index.vue.d.ts.map +1 -1
  7. package/es/components/form/components/ProForm/index.vue.d.ts.map +1 -1
  8. package/es/components/form/hooks/useGroupFieldAttrs.d.ts +1 -1
  9. package/es/components/form/hooks/useGroupFieldAttrs.d.ts.map +1 -1
  10. package/es/components/form/types/index.d.ts +2 -2
  11. package/es/components/form/types/index.d.ts.map +1 -1
  12. package/es/components/table/components/ProTable.vue.d.ts.map +1 -1
  13. package/es/components/table/hooks/useTable.d.ts +1 -1
  14. package/es/index.js +19 -7
  15. package/es/index.js.map +1 -1
  16. package/es/shared/core/index.d.ts +1 -2
  17. package/es/shared/core/index.d.ts.map +1 -1
  18. package/package.json +3 -3
  19. package/src/components/form/components/BaseField/index.vue +14 -2
  20. package/src/components/form/components/BaseField/utils/index.ts +1 -1
  21. package/src/components/form/components/BaseFormItem/index.vue +5 -0
  22. package/src/components/form/components/ProForm/index.vue +6 -2
  23. package/src/components/form/hooks/useGroupFieldAttrs.ts +3 -2
  24. package/src/components/form/types/index.ts +2 -8
  25. package/src/components/table/components/ColumnControl.vue +1 -1
  26. package/src/components/table/components/ProTable.vue +3 -2
  27. package/src/components/table/components/SearchForm.vue +1 -1
  28. package/src/components/table/hooks/useTable.ts +1 -1
  29. package/src/shared/core/index.ts +1 -2
@@ -1,6 +1,5 @@
1
1
  /**
2
- * 统一 re-export @qin-ui/pro-components-core,包内所有文件通过此文件引入 core 内容,
3
- * 避免直接散列依赖 @qin-ui/pro-components-core,便于将来统一维护。
2
+ * 统一 re-export @qin-ui/pro-components-core,包内所有文件通过此文件引入 core 内容。
4
3
  */
5
4
  export { useForm, createFormProxy, useTable, useSearchFormExpand, useFields, useFormData, useFormRef, InjectionFormKey, InjectionFormSlotsKey, getObject, get, set, normalizePathKey, toPath, camelizeProperties, cloneDeep, pick, isPlainObject, isPromise, zhCN, zhTW, enUS, format, resolveLocaleName, type ProLocale, type ProLocaleName, type ProLocaleKey, type Data, type Path, type Paths, type KeyExpandString, type ExtendWithAny, type DeepPartial, type PageParam, type Fields, type Form, type Table, type UseFieldsReturn, type UseFormDataReturn, type UseFormRefReturn, } from '@qin-ui/pro-components-core';
6
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shared/core/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAEL,OAAO,EACP,eAAe,EACf,QAAQ,EACR,mBAAmB,EACnB,SAAS,EACT,WAAW,EACX,UAAU,EAEV,gBAAgB,EAChB,qBAAqB,EAErB,SAAS,EACT,GAAG,EACH,GAAG,EACH,gBAAgB,EAChB,MAAM,EACN,kBAAkB,EAClB,SAAS,EACT,IAAI,EACJ,aAAa,EACb,SAAS,EAET,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,iBAAiB,EACjB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,YAAY,EAEjB,KAAK,IAAI,EACT,KAAK,IAAI,EACT,KAAK,KAAK,EACV,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,MAAM,EACX,KAAK,IAAI,EACT,KAAK,KAAK,EACV,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,GACtB,MAAM,6BAA6B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shared/core/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAEL,OAAO,EACP,eAAe,EACf,QAAQ,EACR,mBAAmB,EACnB,SAAS,EACT,WAAW,EACX,UAAU,EAEV,gBAAgB,EAChB,qBAAqB,EAErB,SAAS,EACT,GAAG,EACH,GAAG,EACH,gBAAgB,EAChB,MAAM,EACN,kBAAkB,EAClB,SAAS,EACT,IAAI,EACJ,aAAa,EACb,SAAS,EAET,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,iBAAiB,EACjB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,YAAY,EAEjB,KAAK,IAAI,EACT,KAAK,IAAI,EACT,KAAK,KAAK,EACV,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,MAAM,EACX,KAAK,IAAI,EACT,KAAK,KAAK,EACV,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,GACtB,MAAM,6BAA6B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qin-ui/antd-vue-pro",
3
- "version": "2.4.3",
3
+ "version": "2.4.4",
4
4
  "description": "二次封装antd vue组件",
5
5
  "bin": {
6
6
  "antd-vue-pro": "./bin/init-ai.mjs"
@@ -43,11 +43,11 @@
43
43
  "dependencies": {
44
44
  "scroll-into-view-if-needed": "^3.1.0",
45
45
  "vue-component-type-helpers": "^3.2.5",
46
- "@qin-ui/pro-components-core": "^2.0.2"
46
+ "@qin-ui/pro-components-core": "^2.0.3"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@vue/test-utils": "^2.4.11",
50
- "ant-design-vue": "^4",
50
+ "ant-design-vue": "^4.2.6",
51
51
  "happy-dom": "^20.11.6",
52
52
  "vitest": "^4.1.11"
53
53
  },
@@ -76,7 +76,11 @@ const triggerFormItemChange = () => {
76
76
 
77
77
  const attrs: any = useAttrs();
78
78
 
79
- // 全局默认配置注入:key = 组件名 + picker 修饰段;inject 须在 setup 同步期调用
79
+ /**
80
+ * 全局默认配置注入:key = 组件名 + picker 修饰段,inject 须在 setup 同步期调用。
81
+ * 组件名与 `picker` 仅取 setup 期初始值——运行期变更不会切换 Provider 的默认值预设
82
+ * (`date-picker.month` 等子类型预设需在初始渲染前确定)。
83
+ */
80
84
  const pickerVal = attrs.picker;
81
85
  const injectConfigKey =
82
86
  typeof props.component === 'string'
@@ -123,6 +127,13 @@ const value = computed({
123
127
  }
124
128
  form.setFormData?.(props.path, newVal);
125
129
  triggerFormItemChange();
130
+ // 字段配置/attrs 传入的 onUpdate:* 监听器与内部写值组合回放,参数为组件原始 emit 值
131
+ const { onUpdateValue } = groupedAttrs.value;
132
+ if (typeof onUpdateValue === 'function') {
133
+ onUpdateValue(val);
134
+ } else if (Array.isArray(onUpdateValue)) {
135
+ onUpdateValue.forEach(listener => listener(val));
136
+ }
126
137
  },
127
138
  });
128
139
 
@@ -150,7 +161,7 @@ const groupedAttrs = computed(() => {
150
161
 
151
162
  // prettier-ignore
152
163
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
153
- const { valueFormatter, modelProp, slots, componentClass, componentStyle, componentContainer, [effectiveModelProp]: _modelVal, [`onUpdate:${effectiveModelProp}`]: _onUpdateModelVal, ...bindAttrs } = mergedProps as any;
164
+ const { valueFormatter, modelProp, slots, componentClass, componentStyle, componentContainer, [effectiveModelProp]: _modelVal, [`onUpdate:${effectiveModelProp}`]: onUpdateValue, ...bindAttrs } = mergedProps as any;
154
165
 
155
166
  return {
156
167
  attrs: bindAttrs,
@@ -158,6 +169,7 @@ const groupedAttrs = computed(() => {
158
169
  componentContainer,
159
170
  modelProp,
160
171
  valueFormatter,
172
+ onUpdateValue,
161
173
  };
162
174
  });
163
175
 
@@ -40,7 +40,7 @@ export const getInitProps = (
40
40
  return {};
41
41
  };
42
42
 
43
- /** 已告警过的未知组件名(模块级去重,避免 computed 重算导致刷屏) */
43
+ /** 已告警过的未知组件名(模块级去重集合) */
44
44
  const warnedUnknownComponents = new Set<string>();
45
45
 
46
46
  export function warnUnknownComponent(name: string) {
@@ -55,6 +55,7 @@ const validFields = computed(() =>
55
55
  (props.fields ?? []).filter(field => !toValue(field.hidden))
56
56
  );
57
57
 
58
+ // 向下注入表单级禁用上下文,BaseField 经 useInjectDisabled 消费
58
59
  useProviderDisabled(computed(() => props.disabled));
59
60
 
60
61
  const config = INJECT_CONFIG['pro-form'];
@@ -88,6 +89,8 @@ const setFormItemRef = (field: any, el: any, formItemProps?: any) => {
88
89
  raw.getFormItemComputedProps = () => formItemProps;
89
90
  } else {
90
91
  formItemInstanceMap.delete(raw);
92
+ delete raw.getFormItemRef;
93
+ delete raw.getFormItemComputedProps;
91
94
  }
92
95
  };
93
96
 
@@ -102,6 +105,8 @@ const setComponentRef = (field: any, el: any) => {
102
105
  componentInstanceMap.get(raw)?.getComponentComputedProps();
103
106
  } else {
104
107
  componentInstanceMap.delete(raw);
108
+ delete raw.getComponentRef;
109
+ delete raw.getComponentComputedProps;
105
110
  }
106
111
  };
107
112
 
@@ -9,8 +9,8 @@
9
9
  *
10
10
  * 1. 数据隔离:ProForm 本身不负责存储和管理表单状态,所有核心状态(formData, fields, 校验规则)
11
11
  * 均交由底层的 `useForm`(@qin-ui/pro-components-core)驱动。
12
- * 2. 上下文透传:通过 `provide` 将核心状态下发给子组件,避免了深层嵌套的 Props 传递。
13
- * 3. 递归渲染:网格布局和具体字段的解析交由 `<BaseFormItem>` 递归完成,实现了 UI 布局与表单逻辑的解耦。
12
+ * 2. 上下文透传:通过 `provide` 将核心状态下发给子组件。
13
+ * 3. 递归渲染:网格布局和具体字段的解析交由 `<BaseFormItem>` 递归完成。
14
14
  *
15
15
  * @public
16
16
  *
@@ -98,6 +98,10 @@ const fields = computed(() => {
98
98
  const formData = computed(() => currentForm.value?.formData);
99
99
  const setFormRef = (el: any) => currentForm.value?.setFormRef?.(el);
100
100
 
101
+ /*
102
+ * formKey 子树重挂载契约:以 WeakMap 为每个 form 实例生成自增 key,绑定到原生 Form 的 :key
103
+ * :form 运行期替换为全新实例时强制整棵表单子树重新挂载,重置宿主校验状态与深层字段非受控状态
104
+ */
101
105
  let formInstanceCounter = 0;
102
106
  const formInstanceKeyMap = new WeakMap<object, number>();
103
107
  const getFormKey = (f: object) => {
@@ -17,6 +17,7 @@ const gridItemPropKeys = Object.keys(gridItemProps());
17
17
  // 模块级 Set:字段循环内 O(1) 命中,替代数组 includes 线性扫描
18
18
  const gridItemPropKeySet = new Set<string>(gridItemPropKeys);
19
19
  const formItemPropKeySet = new Set<string>(formItemPropKeys);
20
+ const formItemSlotKeySet = new Set<string>(FORM_ITEM_SLOT_KEYS);
20
21
 
21
22
  export interface GroupedField {
22
23
  path: string;
@@ -33,7 +34,7 @@ export interface GroupedField {
33
34
  *
34
35
  * @description
35
36
  * 1. 响应式集成 ProComponentProvider 的 `pro-form-item` 全局变量配置;
36
- * 2. 剥离 `extraProps`(用户自定义字段标识袋):保留在字段原始对象上供业务层存取,渲染层经解构剥离,避免落入 componentProps 透传为无效 DOM 属性。
37
+ * 2. 剥离 `extraProps`(用户自定义字段标识袋):保留在字段原始对象上供业务层存取,渲染层经解构剥离,不落入 componentProps 透传。
37
38
  */
38
39
  export function useGroupFieldAttrs(validFields: ComputedRef<Field[]>) {
39
40
  const config = INJECT_CONFIG['pro-form-item'];
@@ -95,7 +96,7 @@ export function useGroupFieldAttrs(validFields: ComputedRef<Field[]>) {
95
96
 
96
97
  Object.assign(componentProps, componentDataAttrs);
97
98
  Object.keys(slots).forEach(k => {
98
- if (FORM_ITEM_SLOT_KEYS.includes(k as any)) {
99
+ if (formItemSlotKeySet.has(k)) {
99
100
  formItemSlots[k] = slots[k];
100
101
  } else {
101
102
  componentProps.slots[k] = slots[k];
@@ -267,10 +267,7 @@ type WithFields<D extends Data = Data> = WithRef<
267
267
  /**
268
268
  * @description 合并 FormItem 插槽与组件插槽
269
269
  */
270
- export type MergeSlots<
271
- T extends abstract new (...args: any) => any,
272
- CS = ComponentSlots<T>,
273
- > = Partial<{
270
+ export type MergeSlots<T, CS = ComponentSlots<T>> = Partial<{
274
271
  [K in keyof FormItemSlots | keyof CS]: K extends keyof FormItemSlots
275
272
  ? FormItemSlots[K]
276
273
  : K extends keyof CS
@@ -283,10 +280,7 @@ export type MergeSlots<
283
280
  * @template T - Vue 组件类型
284
281
  * @template D - 数据对象类型
285
282
  */
286
- type WithComponent<
287
- T extends abstract new (...args: any) => any,
288
- D extends Data = Data,
289
- > = Omit<
283
+ type WithComponent<T, D extends Data = Data> = Omit<
290
284
  WithCommon<Partial<ComponentProps<T>>, D>,
291
285
  keyof VNodeProps | 'slots'
292
286
  > & {
@@ -55,7 +55,7 @@ const checkedColumnsOptions = computed<
55
55
  const disabled =
56
56
  props.columnControl?.disabledKeys?.some(dk => String(dk) === key) ??
57
57
  false;
58
- // labels 优先;title 为字符串时直接使用;vnode 等其他类型降级为 key,避免渲染异常
58
+ // labels 优先;title 为字符串时直接使用;vnode 等其他类型降级为 key
59
59
  const label =
60
60
  (props.columnControl?.labels?.[key] as string) ??
61
61
  (typeof item.title === 'string' ? item.title : key);
@@ -206,7 +206,7 @@ const columnRequiredSlotNames = new Set([
206
206
  /**
207
207
  * 判定插槽是否具备渲染条件(守卫过渡状态或空列下 column 为 undefined 的情况)
208
208
  * 当列被动态隐藏或所有列均隐藏时,旧单元格销毁过渡帧或空占位中 column 可能为 undefined,
209
- * 此时直接阻断依赖 column 的业务插槽调用,防止访问 column 属性抛出 TypeError;
209
+ * 此时阻断依赖 column 的业务插槽调用;
210
210
  * 非列依赖的表格级插槽(如 emptyText、footer、summary 等)始终正常渲染。
211
211
  */
212
212
  const isSlotRenderable = (name: string, scoped: any) => {
@@ -306,7 +306,8 @@ const computedPagination = computed<PaginationProps | false>(() => {
306
306
 
307
307
  const onTableChange: TableProps['onChange'] = (...args) => {
308
308
  props.table?.setPageParam?.(args[0]);
309
- attrs.onChange?.(...args);
309
+ // change 回放:模板监听器优先,未绑定时回退 Provider 全局配置
310
+ (attrs.onChange ?? injectProps.value.onChange)?.(...args);
310
311
  _search();
311
312
  };
312
313
 
@@ -46,7 +46,7 @@ export type SearchFormProps = {
46
46
  *
47
47
  * 1. 内部渲染 ProForm,使用 table.searchForm 管理搜索条件
48
48
  * 2. 支持 grid(网格)和 inline(行内)两种布局
49
- * 3. 网格布局下支持展开/折叠:通过 IntersectionObserver 自动检测哪些字段溢出
49
+ * 3. 网格布局下支持展开/折叠(溢出检测与初值自动展开见下方机制说明)
50
50
  * 4. 提供搜索、重置、展开/折叠按钮(支持自定义)
51
51
  *
52
52
  * ## 展开/折叠机制
@@ -29,7 +29,7 @@ import { Fields } from '../../form/types';
29
29
  * @property appendColumn - 在指定列后追加新列,传 undefined 在末尾追加
30
30
  * @property prependColumn - 在指定列前插入新列,传 undefined 在开头插入
31
31
  * @property setPageParam - 设置分页参数,支持部分更新和函数式更新
32
- * @property resetQueryParams - 重置分页到第一页并恢复搜索条件到初始值
32
+ * @property resetQueryParams - 恢复分页与搜索条件到初始化时的快照(含自定义分页键,非固定回到第一页)
33
33
  *
34
34
  * @example
35
35
  * ```ts
@@ -1,6 +1,5 @@
1
1
  /**
2
- * 统一 re-export @qin-ui/pro-components-core,包内所有文件通过此文件引入 core 内容,
3
- * 避免直接散列依赖 @qin-ui/pro-components-core,便于将来统一维护。
2
+ * 统一 re-export @qin-ui/pro-components-core,包内所有文件通过此文件引入 core 内容。
4
3
  */
5
4
  export {
6
5
  // hooks