@qin-ui/antd-vue-pro 2.4.0 → 2.4.1

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 (39) hide show
  1. package/api.json +1 -1
  2. package/es/__tests__/cross-package.spec.d.ts +2 -0
  3. package/es/__tests__/cross-package.spec.d.ts.map +1 -0
  4. package/es/antd-vue-pro.css +11 -11
  5. package/es/index.js +95 -225
  6. package/es/index.js.map +1 -1
  7. package/es/src/components/component-provider/components/index.vue.d.ts.map +1 -1
  8. package/es/src/components/component-provider/constants/index.d.ts +2 -2
  9. package/es/src/components/component-provider/constants/index.d.ts.map +1 -1
  10. package/es/src/components/form/components/BaseField/index.vue.d.ts.map +1 -1
  11. package/es/src/components/form/components/BaseField/utils/index.d.ts +1 -0
  12. package/es/src/components/form/components/BaseField/utils/index.d.ts.map +1 -1
  13. package/es/src/components/form/components/BaseFormItem/index.vue.d.ts.map +1 -1
  14. package/es/src/components/form/components/ProForm/index.vue.d.ts.map +1 -1
  15. package/es/src/components/form/hooks/useGroupFieldAttrs.d.ts.map +1 -1
  16. package/es/src/components/table/components/ColumnControl.vue.d.ts.map +1 -1
  17. package/es/src/components/table/components/ProTable.vue.d.ts +4 -1
  18. package/es/src/components/table/components/ProTable.vue.d.ts.map +1 -1
  19. package/es/src/components/table/components/SearchForm.vue.d.ts.map +1 -1
  20. package/es/src/components/table/types/index.d.ts +1 -1
  21. package/es/src/components/table/types/index.d.ts.map +1 -1
  22. package/es/src/locale/index.d.ts +1 -1
  23. package/es/src/locale/index.d.ts.map +1 -1
  24. package/es/src/shared/core/index.d.ts +1 -1
  25. package/es/src/shared/core/index.d.ts.map +1 -1
  26. package/package.json +2 -2
  27. package/src/components/component-provider/components/index.vue +4 -3
  28. package/src/components/component-provider/constants/index.ts +4 -3
  29. package/src/components/form/components/BaseField/index.vue +3 -6
  30. package/src/components/form/components/BaseField/utils/index.ts +11 -0
  31. package/src/components/form/components/BaseFormItem/index.vue +2 -1
  32. package/src/components/form/components/ProForm/index.vue +23 -23
  33. package/src/components/form/hooks/useGroupFieldAttrs.ts +9 -3
  34. package/src/components/table/components/ColumnControl.vue +3 -9
  35. package/src/components/table/components/ProTable.vue +47 -28
  36. package/src/components/table/components/SearchForm.vue +8 -182
  37. package/src/components/table/types/index.ts +1 -1
  38. package/src/locale/index.ts +1 -1
  39. package/src/shared/core/index.ts +11 -0
@@ -60,10 +60,6 @@ import { Space, Button, FormProps } from '../../../shared/ui';
60
60
  import {
61
61
  AllowedComponentProps,
62
62
  computed,
63
- ref,
64
- watch,
65
- watchEffect,
66
- onBeforeUnmount,
67
63
  type Component,
68
64
  type DefineComponent,
69
65
  } from 'vue';
@@ -71,6 +67,7 @@ import ProForm from '../../form';
71
67
  import { type Form } from '../../form';
72
68
  import DownOutlined from './icons/DownOutlined.vue';
73
69
  import { useLocale } from '../../../locale';
70
+ import { useSearchFormExpand } from '../../../shared/core';
74
71
 
75
72
  defineOptions({ name: 'SearchForm' });
76
73
 
@@ -93,192 +90,21 @@ type Emits = {
93
90
  };
94
91
  const emit = defineEmits<Emits>();
95
92
 
96
- const proFormHeight = ref<'unset' | number>('unset');
97
- const collapseHeight = ref(0);
98
- const rowHeight = ref(32);
99
-
100
- let resizeObserver: ResizeObserver | null = null;
101
- let intersectionObserver: IntersectionObserver | null = null;
102
-
103
- const cleanupObservers = () => {
104
- if (resizeObserver) {
105
- resizeObserver.disconnect();
106
- resizeObserver = null;
107
- }
108
- if (intersectionObserver) {
109
- intersectionObserver.disconnect();
110
- intersectionObserver = null;
111
- }
112
- };
113
-
114
- onBeforeUnmount(() => {
115
- cleanupObservers();
116
- });
117
-
118
- const computedExpand = computed(() => {
119
- if (!props.expand) return false;
120
- if (props.expand === true) return { minExpandRows: 2, expandStatus: false };
121
- return {
122
- minExpandRows: Math.max(Math.floor(props.expand.minExpandRows ?? 2), 1),
123
- expandStatus: props.expand.expandStatus ?? false,
124
- };
125
- });
126
-
127
- const showExpandToggle = ref(false);
128
-
129
- const expandStatus = ref(true);
130
-
131
- const updateHeights = () => {
132
- if (!props.expand || !props.form?.formRef?.value) return;
133
- const proFormEl = (props.form.formRef.value as any)?.$el;
134
- if (!proFormEl) return;
135
-
136
- const itemHeight = proFormEl
137
- ?.querySelector("[class*='-form-item']")
138
- ?.getBoundingClientRect?.()?.height;
139
- if (itemHeight && itemHeight > 0) {
140
- rowHeight.value = itemHeight;
141
- }
142
-
143
- // 使用 scrollHeight 测量自然展开高度,突破固定高度与 overflow: hidden 样式的自引用限制
144
- const naturalHeight =
145
- proFormEl.scrollHeight || proFormEl.getBoundingClientRect?.()?.height || 0;
146
- if (naturalHeight > 0) {
147
- proFormHeight.value = naturalHeight;
148
- }
149
- };
150
-
151
- // 手动展开/收起标记:置位后自动测量不再覆盖用户操作
152
- const isManualToggle = ref(false);
153
-
154
- const changeExpandStatus = () => {
155
- isManualToggle.value = true;
156
- expandStatus.value = !expandStatus.value;
157
- };
158
-
159
- const hasFieldValue = (val: any) =>
160
- val !== null &&
161
- val !== undefined &&
162
- val !== '' &&
163
- !(Array.isArray(val) && val.length === 0) &&
164
- !(typeof val === 'object' && Object.keys(val).length === 0);
165
-
166
- /*
167
- * 使用 IntersectionObserver 检测折叠状态下隐藏字段是否有值
168
- * 如果有值则自动展开,让用户看到已填写的搜索条件
169
- */
170
- const setInitExpandStatus = () => {
171
- if (isManualToggle.value) return;
172
- const initStatus = computedExpand.value
173
- ? computedExpand.value.expandStatus
174
- : false;
175
- expandStatus.value = initStatus;
176
- if (props.form?.formRef?.value && computedExpand.value) {
177
- const formEl = (props.form.formRef.value as any).$el;
178
- const formItemsEl = formEl?.querySelectorAll?.(
179
- "[class*='-form-item'] > [path]"
180
- );
181
- if (!formItemsEl || formItemsEl.length === 0) return;
182
- if (intersectionObserver) {
183
- intersectionObserver.disconnect();
184
- }
185
- intersectionObserver = new IntersectionObserver(
186
- entries => {
187
- if (isManualToggle.value) return;
188
- expandStatus.value = entries.some(e => {
189
- // 如果隐藏字段(intersectionRatio === 0)有值,则自动展开
190
- if (e.intersectionRatio === 0) {
191
- const path = e.target.getAttribute('path');
192
- const searchFieldValue = path
193
- ? props.form?.getFormData?.(path)
194
- : undefined;
195
- return hasFieldValue(searchFieldValue);
196
- }
197
- return computedExpand.value
198
- ? computedExpand.value.expandStatus
199
- : false;
200
- });
201
- intersectionObserver?.disconnect();
202
- },
203
- { root: formEl }
204
- );
205
- formItemsEl.forEach((element: Element) => {
206
- intersectionObserver?.observe(element);
207
- });
208
- }
209
- };
210
-
211
- watch(
212
- [
213
- () => props.form?.fields.value?.filter(f => !f.hidden)?.length,
214
- () => props.form?.formRef?.value,
215
- () => props.expand,
216
- ],
217
- () => {
218
- updateHeights();
219
- },
220
- { flush: 'post', immediate: true }
221
- );
222
-
223
- watch(
224
- () => props.form?.formRef?.value,
225
- val => {
226
- if (resizeObserver) {
227
- resizeObserver.disconnect();
228
- resizeObserver = null;
229
- }
230
- const formEl = (val as any)?.$el;
231
- if (formEl && typeof ResizeObserver !== 'undefined') {
232
- resizeObserver = new ResizeObserver(() => {
233
- updateHeights();
234
- });
235
- resizeObserver.observe(formEl);
236
- }
237
- },
238
- { immediate: true }
239
- );
240
-
241
- /*
242
- * 计算折叠高度和是否显示展开按钮
243
- * 折叠高度 = minExpandRows * 行高 + (minExpandRows - 1) * 行间距
244
- * 如果实际高度与折叠高度差异 > 1px,说明有字段溢出,显示展开按钮
245
- */
246
- watchEffect(
247
- () => {
248
- if (typeof proFormHeight.value !== 'number') return;
249
- if (props.layout === 'grid' && computedExpand.value) {
250
- const { minExpandRows } = computedExpand.value;
251
- collapseHeight.value = Math.min(
252
- minExpandRows * rowHeight.value + (minExpandRows - 1) * props.rowGap,
253
- +proFormHeight.value
254
- );
255
- showExpandToggle.value = +proFormHeight.value - collapseHeight.value > 1;
256
- if (showExpandToggle.value) {
257
- setInitExpandStatus();
258
- }
259
- } else {
260
- showExpandToggle.value = false;
261
- }
262
- },
263
- { flush: 'post' }
264
- );
93
+ const { showExpandToggle, expandStatus, changeExpandStatus, heightStyle } =
94
+ useSearchFormExpand(props);
265
95
 
266
96
  const layoutProps = computed(() => {
267
- const currentHeight = expandStatus.value
268
- ? proFormHeight.value
269
- : collapseHeight.value;
270
- const heightStyle =
271
- currentHeight !== 'unset' && currentHeight !== undefined
272
- ? `${currentHeight}px`
273
- : undefined;
274
-
275
97
  return props.layout === 'grid'
276
98
  ? {
277
99
  grid: {
278
100
  gutter: [props.columnGap, props.rowGap] as [number, number],
279
101
  style: { flex: 1, marginRight: '12px' },
280
102
  },
281
- style: { display: 'flex', overflow: 'hidden', height: heightStyle },
103
+ style: {
104
+ display: 'flex',
105
+ overflow: 'hidden',
106
+ height: heightStyle.value,
107
+ },
282
108
  }
283
109
  : {
284
110
  layout: 'inline',
@@ -89,7 +89,7 @@ export type Columns<D extends Data = Data> = Array<Column<D>>;
89
89
  * ```
90
90
  */
91
91
  export type ColumnControlConfig<K extends string | number = string | number> = {
92
- /** 列在下拉中的显示名称映射,key 为列 key/dataIndex,用于 title 为 vnode 时无法正常渲染 */
92
+ /** 列在下拉中的自定义显示名称映射(key 为列标识),用于定制展示文案或覆盖非字符串标题 */
93
93
  labels?: Partial<Record<K, string>>;
94
94
  /** 不在下拉中出现的列 keys(始终展示,不参与勾选) */
95
95
  excludedKeys?: K[];
@@ -20,7 +20,7 @@ import {
20
20
  resolveLocaleName,
21
21
  type ProLocale,
22
22
  type ProLocaleName,
23
- } from '@qin-ui/pro-components-core';
23
+ } from '../shared/core';
24
24
  import { useConfigContextInject } from '../shared/ui';
25
25
 
26
26
  export { zhCN, zhTW, enUS };
@@ -5,7 +5,9 @@
5
5
  export {
6
6
  // hooks
7
7
  useForm,
8
+ createFormProxy,
8
9
  useTable,
10
+ useSearchFormExpand,
9
11
  useFields,
10
12
  useFormData,
11
13
  useFormRef,
@@ -23,6 +25,15 @@ export {
23
25
  pick,
24
26
  isPlainObject,
25
27
  isPromise,
28
+ // locale
29
+ zhCN,
30
+ zhTW,
31
+ enUS,
32
+ format,
33
+ resolveLocaleName,
34
+ type ProLocale,
35
+ type ProLocaleName,
36
+ type ProLocaleKey,
26
37
  // types
27
38
  type Data,
28
39
  type Path,