@dazhicheng/ui 1.5.265 → 1.6.0

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 (104) hide show
  1. package/dist/components/tt-area/TtArea.vue.js +1 -1
  2. package/dist/components/tt-drawer/src/components/DrawerHeader.vue.js +2 -2
  3. package/dist/components/tt-drawer/src/hooks/useResizable.js +2 -2
  4. package/dist/components/tt-form/src/components/FormElInput.vue.js +51 -38
  5. package/dist/components/tt-form/src/form-render/FormField.vue2.js +36 -36
  6. package/dist/components/tt-form/src/form-render/array-register/FormArrayRegister.d.ts +3 -3
  7. package/dist/components/tt-form/src/form-render/array-register/FormArrayRegister.js +3 -1
  8. package/dist/components/tt-icon/index.vue.js +2 -2
  9. package/dist/components/tt-loading/src/loading.vue.js +2 -2
  10. package/dist/components/tt-modal-form/index.vue.js +13 -12
  11. package/dist/components/tt-panel-select/src/components/PanelMiddle.vue.d.ts +2 -2
  12. package/dist/components/tt-panel-select/src/hooks/usePanelData.js +93 -86
  13. package/dist/components/tt-panel-select/src/index.vue.js +1 -0
  14. package/dist/components/tt-select/src/Select.vue.d.ts +4 -4
  15. package/dist/components/tt-select/src/components/Table.vue.d.ts +4 -4
  16. package/dist/components/tt-table/index.d.ts +523 -358
  17. package/dist/components/tt-table/index.js +7 -4
  18. package/dist/components/tt-table/src/Table.vue.d.ts +306 -216
  19. package/dist/components/tt-table/src/Table.vue.js +405 -618
  20. package/dist/components/tt-table/src/TableForm.vue.d.ts +384 -19
  21. package/dist/components/tt-table/src/TableForm.vue.js +219 -228
  22. package/dist/components/tt-table/src/components/TableAction.vue.js +108 -131
  23. package/dist/components/tt-table/src/components/TableButtons.js +25 -25
  24. package/dist/components/tt-table/src/components/TableColumnModal.vue2.js +88 -85
  25. package/dist/components/tt-table/src/components/TableToolbarTools.vue.d.ts +80 -0
  26. package/dist/components/tt-table/src/components/{TableToobalTools.vue.js → TableToolbarTools.vue.js} +29 -31
  27. package/dist/components/tt-table/src/components/TableToolbarTools.vue2.js +4 -0
  28. package/dist/components/tt-table/src/emits.js +2 -1
  29. package/dist/components/tt-table/src/hooks/useColumnPersistence.d.ts +19 -0
  30. package/dist/components/tt-table/src/hooks/useColumnPersistence.js +63 -0
  31. package/dist/components/tt-table/src/hooks/useColumns.d.ts +505 -21
  32. package/dist/components/tt-table/src/hooks/useColumns.js +100 -245
  33. package/dist/components/tt-table/src/hooks/useGridProps.d.ts +36 -0
  34. package/dist/components/tt-table/src/hooks/useGridProps.js +121 -0
  35. package/dist/components/tt-table/src/hooks/useKeyboardNav.d.ts +11 -0
  36. package/dist/components/tt-table/src/hooks/useKeyboardNav.js +97 -0
  37. package/dist/components/tt-table/src/hooks/usePagination.d.ts +14 -8
  38. package/dist/components/tt-table/src/hooks/usePagination.js +29 -33
  39. package/dist/components/tt-table/src/hooks/useQuery.d.ts +41 -0
  40. package/dist/components/tt-table/src/hooks/useQuery.js +147 -0
  41. package/dist/components/tt-table/src/hooks/useRowIdentity.d.ts +22 -0
  42. package/dist/components/tt-table/src/hooks/useRowIdentity.js +96 -0
  43. package/dist/components/tt-table/src/hooks/useRowSelection.d.ts +23 -7
  44. package/dist/components/tt-table/src/hooks/useRowSelection.js +95 -71
  45. package/dist/components/tt-table/src/hooks/{useLeftRightSlot.d.ts → useSideSlot.d.ts} +25 -17
  46. package/dist/components/tt-table/src/hooks/useSideSlot.js +77 -0
  47. package/dist/components/tt-table/src/hooks/useSyncProps.d.ts +12 -0
  48. package/dist/components/tt-table/src/hooks/useSyncProps.js +55 -0
  49. package/dist/components/tt-table/src/hooks/useTableData.d.ts +71 -0
  50. package/dist/components/tt-table/src/hooks/useTableData.js +307 -0
  51. package/dist/components/tt-table/src/hooks/useTableFooter.d.ts +15 -0
  52. package/dist/components/tt-table/src/hooks/useTableFooter.js +46 -0
  53. package/dist/components/tt-table/src/hooks/useTableForm.d.ts +10 -5
  54. package/dist/components/tt-table/src/hooks/useTableForm.js +55 -48
  55. package/dist/components/tt-table/src/hooks/useTableMethods.d.ts +165 -0
  56. package/dist/components/tt-table/src/hooks/useTableMethods.js +183 -0
  57. package/dist/components/tt-table/src/hooks/useTableRender.d.ts +24 -55
  58. package/dist/components/tt-table/src/props.d.ts +318 -151
  59. package/dist/components/tt-table/src/props.js +117 -270
  60. package/dist/components/tt-table/src/table-defaults.d.ts +25 -0
  61. package/dist/components/tt-table/src/table-defaults.js +71 -0
  62. package/dist/components/tt-table/src/table-mutation-events.d.ts +43 -0
  63. package/dist/components/tt-table/src/table-mutation-events.js +70 -0
  64. package/dist/components/tt-table/src/types/table.d.ts +207 -88
  65. package/dist/components/tt-table/src/types/tableAction.d.ts +23 -0
  66. package/dist/components/tt-table/src/types/tableForm.d.ts +15 -26
  67. package/dist/components/tt-table/src/utils/action-tab-index.d.ts +2 -0
  68. package/dist/components/tt-table/src/utils/action-tab-index.js +50 -0
  69. package/dist/components/tt-table/src/utils/context.js +25 -12
  70. package/dist/components/tt-table/src/utils/table-api.d.ts +136 -58
  71. package/dist/components/tt-table/src/utils/table-api.js +198 -165
  72. package/dist/components/tt-table/src/utils/table-form-api.d.ts +11 -11
  73. package/dist/components/tt-table/src/utils/table-form-api.js +41 -31
  74. package/dist/components/types.d.ts +0 -20
  75. package/dist/hooks/useSetup.js +0 -3
  76. package/dist/index.d.ts +1 -0
  77. package/dist/index.js +105 -101
  78. package/dist/packages/hooks/src/useDebounce.js +6 -6
  79. package/dist/packages/utils/src/is.js +20 -18
  80. package/dist/packages/utils/src/tool.js +76 -149
  81. package/dist/style.css +1 -1
  82. package/dist/utils/uppercaseInput.d.ts +29 -0
  83. package/dist/utils/uppercaseInput.js +16 -0
  84. package/package.json +3 -3
  85. package/dist/components/tt-table/src/components/TableToobalTools.vue.d.ts +0 -576
  86. package/dist/components/tt-table/src/components/TableToobalTools.vue2.js +0 -4
  87. package/dist/components/tt-table/src/enum.d.ts +0 -2
  88. package/dist/components/tt-table/src/hooks/useCellArea.d.ts +0 -15
  89. package/dist/components/tt-table/src/hooks/useCellArea.js +0 -15
  90. package/dist/components/tt-table/src/hooks/useCustomColumns.d.ts +0 -20
  91. package/dist/components/tt-table/src/hooks/useCustomColumns.js +0 -65
  92. package/dist/components/tt-table/src/hooks/useDataSource.d.ts +0 -29
  93. package/dist/components/tt-table/src/hooks/useDataSource.js +0 -232
  94. package/dist/components/tt-table/src/hooks/useLeftRightSlot.js +0 -64
  95. package/dist/components/tt-table/src/hooks/useTable.d.ts +0 -7
  96. package/dist/components/tt-table/src/hooks/useTableEvent.d.ts +0 -101
  97. package/dist/components/tt-table/src/hooks/useTableEvent.js +0 -197
  98. package/dist/components/tt-table/src/hooks/useTableFormEvent.d.ts +0 -10
  99. package/dist/components/tt-table/src/hooks/useTableHeight.d.ts +0 -15
  100. package/dist/components/tt-table/src/hooks/useTableSlot.d.ts +0 -11
  101. package/dist/components/tt-table/src/hooks/useTableSlot.js +0 -17
  102. package/dist/components/tt-table/src/utils/filters.d.ts +0 -109
  103. package/dist/components/tt-table/src/utils/vxeTable.d.ts +0 -28
  104. package/dist/packages/utils/src/check.js +0 -10
@@ -1,11 +1,19 @@
1
+ import { ComputedRef, Ref, nextTick } from 'vue';
1
2
  import { VxeGridInstance } from 'vxe-table';
2
- import { TtTableLeftRightRowNode, TtTableProps } from '../types/table';
3
3
  import { Recordable } from '../../../../../../utils/src';
4
- import { ComputedRef, Ref } from 'vue';
5
- export declare function useLeftRightSlot(propsRef: ComputedRef<TtTableProps>, xGridRef: Ref<VxeGridInstance<Recordable>>, tableData: Ref<Recordable[]>): {
6
- handleLeftRightSlotScroll: (scrollTop?: number) => Promise<void>;
7
- handleLeftRightSlotInit: (isScrollInit?: boolean) => Promise<void>;
8
- leftRightSlotRows: Ref<{
4
+ import { TtTableLeftRightRowNode, TtTableProps } from '../types/table';
5
+ /**
6
+ * 表格左右两侧自定义插槽
7
+ *
8
+ * 通过读取 vxe 的 body DOM 尺寸,让两侧插槽与表格行保持同高、同步滚动。
9
+ * @param propsRef 表格 props
10
+ * @param grid vxe-grid 实例
11
+ * @param rows 当前表格数据
12
+ */
13
+ export declare function useSideSlot(propsRef: ComputedRef<TtTableProps>, grid: Ref<undefined | VxeGridInstance<Recordable>>, rows: Ref<Recordable[]>): {
14
+ refresh: (resetScroll?: boolean) => Promise<void>;
15
+ syncScroll: (scrollTop?: number) => Promise<void>;
16
+ rowNodes: Ref<{
9
17
  offsetTop?: number | undefined;
10
18
  rowid?: string | undefined;
11
19
  item?: any;
@@ -20,8 +28,12 @@ export declare function useLeftRightSlot(propsRef: ComputedRef<TtTableProps>, xG
20
28
  index?: number | undefined;
21
29
  parent?: any;
22
30
  }[]>;
23
- tableHeaderHight: import('vue').ShallowRef<number, number>;
24
- leftSlotScrollbarRef: Ref<({
31
+ headerHeight: import('vue').ShallowRef<number, number>;
32
+ bodyHeight: import('vue').ShallowRef<number, number>;
33
+ bodyWrapperHeight: import('vue').ShallowRef<number, number>;
34
+ bodyOffsetTop: import('vue').ShallowRef<number, number>;
35
+ bodyScrollHeight: import('vue').ShallowRef<number, number>;
36
+ leftScrollbarRef: Ref<({
25
37
  $: import('vue').ComponentInternalInstance;
26
38
  $data: {};
27
39
  $props: {
@@ -116,7 +128,7 @@ export declare function useLeftRightSlot(propsRef: ComputedRef<TtTableProps>, xG
116
128
  errorCaptured?: ((err: unknown, instance: import('vue').ComponentPublicInstance | null, info: string) => boolean | void) | ((err: unknown, instance: import('vue').ComponentPublicInstance | null, info: string) => boolean | void)[];
117
129
  };
118
130
  $forceUpdate: () => void;
119
- $nextTick: typeof import('vue').nextTick;
131
+ $nextTick: typeof nextTick;
120
132
  $watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (...args: [R, R, import('@vue/reactivity').OnCleanup]) => any : (...args: [any, any, import('@vue/reactivity').OnCleanup]) => any, options?: import('vue').WatchOptions): import('vue').WatchStopHandle;
121
133
  } & Readonly<{
122
134
  tabindex: number | string;
@@ -244,7 +256,7 @@ export declare function useLeftRightSlot(propsRef: ComputedRef<TtTableProps>, xG
244
256
  errorCaptured?: ((err: unknown, instance: import('vue').ComponentPublicInstance | null, info: string) => boolean | void) | ((err: unknown, instance: import('vue').ComponentPublicInstance | null, info: string) => boolean | void)[];
245
257
  };
246
258
  $forceUpdate: () => void;
247
- $nextTick: typeof import('vue').nextTick;
259
+ $nextTick: typeof nextTick;
248
260
  $watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (...args: [R, R, import('@vue/reactivity').OnCleanup]) => any : (...args: [any, any, import('@vue/reactivity').OnCleanup]) => any, options?: import('vue').WatchOptions): import('vue').WatchStopHandle;
249
261
  } & Readonly<{
250
262
  tabindex: number | string;
@@ -278,7 +290,7 @@ export declare function useLeftRightSlot(propsRef: ComputedRef<TtTableProps>, xG
278
290
  default?: (props: {}) => any;
279
291
  };
280
292
  }) | undefined>;
281
- rightSlotScrollbarRef: Ref<({
293
+ rightScrollbarRef: Ref<({
282
294
  $: import('vue').ComponentInternalInstance;
283
295
  $data: {};
284
296
  $props: {
@@ -373,7 +385,7 @@ export declare function useLeftRightSlot(propsRef: ComputedRef<TtTableProps>, xG
373
385
  errorCaptured?: ((err: unknown, instance: import('vue').ComponentPublicInstance | null, info: string) => boolean | void) | ((err: unknown, instance: import('vue').ComponentPublicInstance | null, info: string) => boolean | void)[];
374
386
  };
375
387
  $forceUpdate: () => void;
376
- $nextTick: typeof import('vue').nextTick;
388
+ $nextTick: typeof nextTick;
377
389
  $watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (...args: [R, R, import('@vue/reactivity').OnCleanup]) => any : (...args: [any, any, import('@vue/reactivity').OnCleanup]) => any, options?: import('vue').WatchOptions): import('vue').WatchStopHandle;
378
390
  } & Readonly<{
379
391
  tabindex: number | string;
@@ -501,7 +513,7 @@ export declare function useLeftRightSlot(propsRef: ComputedRef<TtTableProps>, xG
501
513
  errorCaptured?: ((err: unknown, instance: import('vue').ComponentPublicInstance | null, info: string) => boolean | void) | ((err: unknown, instance: import('vue').ComponentPublicInstance | null, info: string) => boolean | void)[];
502
514
  };
503
515
  $forceUpdate: () => void;
504
- $nextTick: typeof import('vue').nextTick;
516
+ $nextTick: typeof nextTick;
505
517
  $watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (...args: [R, R, import('@vue/reactivity').OnCleanup]) => any : (...args: [any, any, import('@vue/reactivity').OnCleanup]) => any, options?: import('vue').WatchOptions): import('vue').WatchStopHandle;
506
518
  } & Readonly<{
507
519
  tabindex: number | string;
@@ -535,8 +547,4 @@ export declare function useLeftRightSlot(propsRef: ComputedRef<TtTableProps>, xG
535
547
  default?: (props: {}) => any;
536
548
  };
537
549
  }) | undefined>;
538
- tableBodyHeight: import('vue').ShallowRef<number, number>;
539
- tableBodyWrapHeight: import('vue').ShallowRef<number, number>;
540
- tableBodyScrollTop: import('vue').ShallowRef<number, number>;
541
- tableBodyScrollHeight: import('vue').ShallowRef<number, number>;
542
550
  };
@@ -0,0 +1,77 @@
1
+ import "axios";
2
+ import "element-plus";
3
+ import { isUndefined as A, isServer as T } from "../../../../packages/utils/src/is.js";
4
+ import { computed as E, unref as t, ref as b, shallowRef as u, watch as W, onScopeDispose as R, nextTick as k } from "vue";
5
+ import "xe-utils";
6
+ import "dayjs";
7
+ import "dayjs/plugin/utc";
8
+ import "dayjs/plugin/timezone";
9
+ import "../../../../node_modules/.pnpm/decimal.js@10.6.0/node_modules/decimal.js/decimal.js";
10
+ import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/aes.js";
11
+ import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-utf8.js";
12
+ import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ecb.js";
13
+ import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-pkcs7.js";
14
+ import "lodash-es";
15
+ function Q(c, s, N) {
16
+ const f = E(() => !!(t(c).leftSlotWidth || t(c).rightSlotWidth)), w = b(), g = b(), d = u(0), m = u(0), p = u(0), h = u(0), y = u(0), v = b([]), a = /* @__PURE__ */ new Set();
17
+ function q() {
18
+ return new Promise((r) => {
19
+ let e = !1, o;
20
+ const n = (l) => {
21
+ e || (e = !0, a.delete(i), r(l));
22
+ }, i = () => {
23
+ e || (e = !0, !A(o) && !T && window.cancelAnimationFrame(o), a.delete(i), r(!1));
24
+ };
25
+ a.add(i), k(() => {
26
+ if (!e) {
27
+ if (T || !window.requestAnimationFrame) {
28
+ n(!0);
29
+ return;
30
+ }
31
+ o = window.requestAnimationFrame(() => n(!0));
32
+ }
33
+ });
34
+ });
35
+ }
36
+ async function x(r) {
37
+ var o, n, i, l;
38
+ if (!t(f) || !await q()) return;
39
+ const e = (n = (o = t(s)) == null ? void 0 : o.$el) == null ? void 0 : n.querySelector(".vxe-table--body");
40
+ e && (m.value = e.clientHeight, y.value = Number.parseFloat(e.style.marginTop) || 0, v.value = Array.from(e.querySelectorAll(".vxe-body--row")).map((H) => {
41
+ var F;
42
+ return {
43
+ ...(F = t(s)) == null ? void 0 : F.getRowNode(H),
44
+ offsetTop: H.offsetTop
45
+ };
46
+ }), !A(r) && ((i = t(w)) == null || i.scrollTo({ top: r }), (l = t(g)) == null || l.scrollTo({ top: r })));
47
+ }
48
+ async function S(r = !0) {
49
+ var o, n, i, l;
50
+ if (!t(f) || !await q()) return;
51
+ const e = (o = t(s)) == null ? void 0 : o.$el;
52
+ d.value = ((n = e == null ? void 0 : e.querySelector(".vxe-table--body-wrapper")) == null ? void 0 : n.clientHeight) || 0, p.value = ((i = e == null ? void 0 : e.querySelector(".vxe-table--header")) == null ? void 0 : i.clientHeight) || 0, h.value = Number.parseFloat((l = e == null ? void 0 : e.querySelector(".vxe-body--y-space")) == null ? void 0 : l.style.height) || 0, x(r ? 0 : void 0);
53
+ }
54
+ return W(N, () => S()), W([() => t(c).leftSlotWidth, () => t(c).rightSlotWidth], () => {
55
+ if (t(f)) {
56
+ S();
57
+ return;
58
+ }
59
+ d.value = 0, m.value = 0, p.value = 0, y.value = 0, h.value = 0, v.value = [];
60
+ }), R(() => {
61
+ a.forEach((r) => r()), a.clear();
62
+ }), {
63
+ refresh: S,
64
+ syncScroll: x,
65
+ rowNodes: v,
66
+ headerHeight: p,
67
+ bodyHeight: m,
68
+ bodyWrapperHeight: d,
69
+ bodyOffsetTop: y,
70
+ bodyScrollHeight: h,
71
+ leftScrollbarRef: w,
72
+ rightScrollbarRef: g
73
+ };
74
+ }
75
+ export {
76
+ Q as useSideSlot
77
+ };
@@ -0,0 +1,12 @@
1
+ import { Recordable } from '../../../../../../utils/src';
2
+ /**
3
+ * 将父组件显式传入的 props 同步到内部 store。
4
+ *
5
+ * 配置项按 key 建立独立 watcher,外部变化时直接写入对应 key,不保存快照,也不做
6
+ * 内容快照或其他比较。这样内部 API 对 store 的改动不会被无关的父组件更新覆盖,
7
+ * v-model、data 与 columns 也不会被配置 watcher 深度遍历。
8
+ * @param props 组件 props
9
+ * @param setState store 写入方法
10
+ * @param exclude 不参与同步的 props
11
+ */
12
+ export declare function useSyncProps(props: Recordable, setState: (state: Recordable) => void, exclude?: string[]): void;
@@ -0,0 +1,55 @@
1
+ import { kebabToCamelCase as a } from "../../../../packages/utils/src/string.js";
2
+ import "axios";
3
+ import "element-plus";
4
+ import { isObject as h, isArray as b } from "../../../../packages/utils/src/is.js";
5
+ import { getCurrentInstance as P, watch as p, toValue as g } from "vue";
6
+ import "xe-utils";
7
+ import "dayjs";
8
+ import "dayjs/plugin/utc";
9
+ import "dayjs/plugin/timezone";
10
+ import "../../../../node_modules/.pnpm/decimal.js@10.6.0/node_modules/decimal.js/decimal.js";
11
+ import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/aes.js";
12
+ import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-utf8.js";
13
+ import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ecb.js";
14
+ import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-pkcs7.js";
15
+ import "lodash-es";
16
+ const f = ["data"], j = ["columns"];
17
+ function B(t, m, l = []) {
18
+ var c;
19
+ const i = P();
20
+ function u(o) {
21
+ var s;
22
+ const r = ((s = i == null ? void 0 : i.vnode) == null ? void 0 : s.props) || {};
23
+ return Object.keys(r).some((d) => a(d) === o);
24
+ }
25
+ const e = Array.from(
26
+ new Set(
27
+ Object.keys(((c = i == null ? void 0 : i.vnode) == null ? void 0 : c.props) || {}).map(a).filter((o) => !o.startsWith("on") && o in t).filter((o) => !l.includes(o) && !f.includes(o))
28
+ )
29
+ ), n = {};
30
+ e.forEach((o) => {
31
+ n[o] = t[o];
32
+ }), Object.keys(n).length && m(n), e.forEach((o) => {
33
+ p(
34
+ () => t[o],
35
+ (r) => m({ [o]: r }),
36
+ // 逐 key 写入是「内部改动不被父组件覆盖」的必要条件,不能合并成一个 deep watcher:
37
+ // 合并后任意一个配置变化都会整包回写,把内部通过 setState 改过的其他 key 冲掉。
38
+ { deep: !j.includes(o) && (h(t[o]) || b(t[o])) }
39
+ );
40
+ }), f.forEach((o) => {
41
+ p(
42
+ [() => t[o], () => {
43
+ var r;
44
+ return (r = g(t[o])) == null ? void 0 : r.length;
45
+ }],
46
+ ([r]) => {
47
+ u(o) && m({ [o]: r });
48
+ },
49
+ { immediate: !0 }
50
+ );
51
+ });
52
+ }
53
+ export {
54
+ B as useSyncProps
55
+ };
@@ -0,0 +1,71 @@
1
+ import { MaybeRefOrGetter, ModelRef, Ref } from 'vue';
2
+ import { VxeGridInstance } from 'vxe-table';
3
+ import { Recordable } from '../../../../../../utils/src';
4
+ import { TtTableProps } from '../types/table';
5
+ import { RowsCommitSource } from '../table-mutation-events';
6
+ /** 表格数据相关事件 */
7
+ type DataEmit = {
8
+ (e: "load-data"): void;
9
+ };
10
+ /** 判断当前异步落表任务是否仍可提交。 */
11
+ type RowsCommitGuard = () => boolean;
12
+ /** 表格数据源的独立 store 选择器,避免无关配置变化触发数据监听。 */
13
+ type TableDataSources = {
14
+ api: MaybeRefOrGetter<TtTableProps["api"] | undefined>;
15
+ data: MaybeRefOrGetter<TtTableProps["data"] | undefined>;
16
+ /** 数据进入 VXE 前的行身份预处理。 */
17
+ prepareRows?: (rows: Recordable | Recordable[]) => void;
18
+ /** 通过公开实例调用 VXE 选中方法后,重新读取选中态。 */
19
+ onSelectionMutated?: () => void;
20
+ };
21
+ /** VXE 方法调用的统一类型。 */
22
+ type TableDataOperation<T> = () => Promise<T> | T;
23
+ /**
24
+ * 读取外部传入的表格数据源的当前值。
25
+ *
26
+ * 表格内部的数据源可能来自一个 getter,也可能是 `data: ref(rows)`。
27
+ * 先读取外层 MaybeRefOrGetter,再显式处理 getter 返回的 Ref,避免在业务逻辑中出现
28
+ * 隐晦的嵌套 `toValue`。空数组是有效数据,只有外层数据源不存在时才返回 undefined。
29
+ * @param source 外层数据源
30
+ */
31
+ export declare function getExternalRowsValue(source: MaybeRefOrGetter<TtTableProps["data"] | undefined>): undefined | Recordable[];
32
+ /**
33
+ * 在操作前后保留树形展开状态
34
+ * @param grid vxe-grid 实例
35
+ * @param reserve 是否需要保留(treeConfig.reserve)
36
+ * @param handler 需要执行的操作
37
+ * @param guard 操作完成后是否仍允许恢复展开状态
38
+ */
39
+ export declare function withTreeExpand<T>(grid: undefined | VxeGridInstance<Recordable>, reserve: boolean | undefined, handler: () => Promise<T> | T, guard?: () => boolean): Promise<T>;
40
+ /**
41
+ * 表格数据落表的唯一出口
42
+ *
43
+ * 外部 data / v-model 只经由 loadRows 写入 vxe-grid;请求结果和表格内部操作再通过 emitRows 回写 v-model,
44
+ * 避免把输入和输出混在同一条链路里。
45
+ *
46
+ * 外部数据的变化监听只追踪到「行引用」这一层,不进入行对象内部做字段对比:
47
+ * 表格写回时附加一次内部事件版本,外部原样传回时消费版本并跳过重复落表;
48
+ * 换数组、增删行、整行替换都会重新落表,只改行内字段不会 ——
49
+ * 行对象与外部共享,改字段单元格会自己更新,无需重新落表。
50
+ * @param propsRef 表格 props
51
+ * @param grid vxe-grid 实例
52
+ * @param modelValue v-model 数据
53
+ * @param emit 组件 emit
54
+ * @param sources 从 store 独立选择的数据与接口来源
55
+ */
56
+ export declare function useTableData(propsRef: Ref<TtTableProps>, grid: Ref<undefined | VxeGridInstance<Recordable>>, modelValue: ModelRef<Recordable[] | undefined>, emit: DataEmit, sources: TableDataSources): {
57
+ rows: import('vue').ShallowRef<Recordable[], Recordable[]>;
58
+ loadRows: (nextRows: Recordable[], guard?: RowsCommitGuard) => Promise<boolean>;
59
+ applyRows: (nextRows: Recordable[], guard?: RowsCommitGuard) => Promise<boolean>;
60
+ emitRows: (nextRows: Recordable[]) => void;
61
+ getDataSource: <T = Recordable>() => T[];
62
+ runDataOperation: <T>(operation: TableDataOperation<T>, source?: RowsCommitSource) => Promise<T>;
63
+ scheduleRowsCommit: (source?: RowsCommitSource) => void;
64
+ cancelRowsCommit: () => void;
65
+ onDataChange: () => void;
66
+ commitRows: (source?: RowsCommitSource) => boolean;
67
+ createTableInstanceFacade: (instance: undefined | VxeGridInstance<Recordable>) => VxeGridInstance<Recordable> | undefined;
68
+ /** 判断表格作用域是否仍然有效。 */
69
+ isActive: () => boolean;
70
+ };
71
+ export {};
@@ -0,0 +1,307 @@
1
+ import "axios";
2
+ import "element-plus";
3
+ import { isString as L, isFunction as N, isObject as Re } from "../../../../packages/utils/src/is.js";
4
+ import { getCurrentInstance as he, shallowRef as J, watch as Q, unref as d, onBeforeUpdate as ve, getCurrentScope as Ce, onScopeDispose as Me, toValue as S, nextTick as P, isRef as be } from "vue";
5
+ import "xe-utils";
6
+ import "dayjs";
7
+ import "dayjs/plugin/utc";
8
+ import "dayjs/plugin/timezone";
9
+ import "../../../../node_modules/.pnpm/decimal.js@10.6.0/node_modules/decimal.js/decimal.js";
10
+ import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/aes.js";
11
+ import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-utf8.js";
12
+ import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ecb.js";
13
+ import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-pkcs7.js";
14
+ import "lodash-es";
15
+ const De = /* @__PURE__ */ new Set([
16
+ "syncData",
17
+ "loadData",
18
+ "reloadData",
19
+ "setRow",
20
+ "revertData",
21
+ "reloadRow",
22
+ "loadTreeChildren",
23
+ "clearData",
24
+ "removeInsertRow",
25
+ "moveRowTo",
26
+ "reloadTreeExpand",
27
+ "undo",
28
+ "redo",
29
+ "pasteCellArea",
30
+ "importData",
31
+ "importByFile",
32
+ "insert",
33
+ "insertAt",
34
+ "insertNextAt",
35
+ "insertChild",
36
+ "insertChildAt",
37
+ "insertChildNextAt",
38
+ "remove",
39
+ "removeCheckboxRow",
40
+ "removeRadioRow",
41
+ "removeCurrentRow",
42
+ "commitProxy"
43
+ ]), Te = /* @__PURE__ */ new Set(["insert", "insert_edit", "insert_actived", "remove"]), xe = /* @__PURE__ */ new Set([
44
+ "setCheckboxRow",
45
+ "toggleCheckboxRow",
46
+ "setAllCheckboxRow",
47
+ "toggleAllCheckboxRow",
48
+ "clearCheckboxRow",
49
+ "clearCheckboxReserve",
50
+ "setRadioRow",
51
+ "clearRadioRow",
52
+ "clearRadioReserve"
53
+ ]), ye = /* @__PURE__ */ new Set(["loadData", "reloadData"]);
54
+ function X(l) {
55
+ const f = S(l);
56
+ if (f)
57
+ return be(f) ? f.value ?? [] : f;
58
+ }
59
+ function x(l) {
60
+ return !l || l();
61
+ }
62
+ async function _e(l, f, C, g = () => !0) {
63
+ const i = (l == null ? void 0 : l.getTreeExpandRecords()) || [], R = await C();
64
+ return f && i.length && g() && await (l == null ? void 0 : l.setTreeExpand(i, !0)), R;
65
+ }
66
+ function ke(l, f, C, g, i) {
67
+ const R = he(), b = J([]), D = J();
68
+ let A = !1, s = !1, M = 0, h;
69
+ const q = Symbol("tt-table-emitted-rows-event");
70
+ let Y = 0, m, v = !1, T = 0, U = Promise.resolve();
71
+ function p() {
72
+ var t;
73
+ const e = ((t = R == null ? void 0 : R.vnode) == null ? void 0 : t.props) || {};
74
+ return "modelValue" in e || "model-value" in e;
75
+ }
76
+ function Z() {
77
+ var t;
78
+ const e = ((t = R == null ? void 0 : R.vnode) == null ? void 0 : t.props) || {};
79
+ return p() && ("onUpdate:modelValue" in e || "onUpdate:model-value" in e);
80
+ }
81
+ function _() {
82
+ const e = p() ? d(C) : void 0;
83
+ if (e != null && e.length) return "model";
84
+ const t = X(i.data);
85
+ return t != null && t.length ? "data" : p() ? "model" : "data";
86
+ }
87
+ function y(e) {
88
+ const t = U.then(e);
89
+ return U = t.then(
90
+ () => {
91
+ },
92
+ () => {
93
+ }
94
+ ), t;
95
+ }
96
+ function ee(e, t) {
97
+ return new Proxy(e, {
98
+ get(o, a, r) {
99
+ return a === q ? t : Reflect.get(o, a, r);
100
+ },
101
+ set(o, a, r) {
102
+ const u = Reflect.set(o, a, r);
103
+ return u && t === m && (v = !0), u;
104
+ },
105
+ deleteProperty(o, a) {
106
+ const r = Reflect.deleteProperty(o, a);
107
+ return r && t === m && (v = !0), r;
108
+ },
109
+ defineProperty(o, a, r) {
110
+ const u = Reflect.defineProperty(o, a, r);
111
+ return u && t === m && (v = !0), u;
112
+ }
113
+ });
114
+ }
115
+ function te(e) {
116
+ const t = e == null ? void 0 : e[q], n = m;
117
+ if (n === void 0 || t !== n) return !1;
118
+ const o = v;
119
+ return m = void 0, v = !1, !o;
120
+ }
121
+ function ne(e) {
122
+ P(() => {
123
+ m === e && (m = void 0, v = !1);
124
+ });
125
+ }
126
+ function V(e) {
127
+ const t = S(i.api), n = p(), o = Z(), a = o && !t;
128
+ o && (D.value = "model");
129
+ const r = a ? ++Y : void 0, u = r ? ee(e, r) : e;
130
+ m = r, v = !1, b.value = u, (o || !n) && (C.value = u, r && ne(r));
131
+ }
132
+ function k(e) {
133
+ var n;
134
+ const t = (n = d(f)) == null ? void 0 : n.getTableData();
135
+ return (e === "visible" ? t == null ? void 0 : t.visibleData : t == null ? void 0 : t.fullData) || [];
136
+ }
137
+ function O(e = "full") {
138
+ return s || !d(f) ? !1 : (h = void 0, V(k(e)), !0);
139
+ }
140
+ function j(e = "full") {
141
+ if (s || M || !d(b).length && !k(e).length) return;
142
+ if (h) {
143
+ e === "visible" && (h.source = e);
144
+ return;
145
+ }
146
+ const t = { inputVersion: T, source: e };
147
+ h = t, P().then(() => {
148
+ h === t && (h = void 0, !(s || M || t.inputVersion !== T) && O(t.source));
149
+ });
150
+ }
151
+ function z() {
152
+ h = void 0;
153
+ }
154
+ function oe() {
155
+ j();
156
+ }
157
+ async function F(e, t = "full") {
158
+ const n = T;
159
+ return y(async () => {
160
+ if (!s) {
161
+ M += 1;
162
+ try {
163
+ const o = await e();
164
+ return await P(), !s && n === T && O(t), o;
165
+ } finally {
166
+ M -= 1;
167
+ }
168
+ }
169
+ });
170
+ }
171
+ const K = /* @__PURE__ */ new WeakMap();
172
+ function re(e) {
173
+ const t = Reflect.get(e, "getRefMaps");
174
+ if (!N(t)) return;
175
+ const n = Reflect.apply(t, e, []);
176
+ return S(n.refTable);
177
+ }
178
+ function ie(e) {
179
+ if (L(e)) return e;
180
+ if (Re(e) && L(e.code)) return e.code;
181
+ }
182
+ function ae(e) {
183
+ return e.updateData();
184
+ }
185
+ function le(e, t) {
186
+ var n, o;
187
+ ye.has(e) && t[0] && ((n = i.prepareRows) == null || n.call(i, t[0])), e === "loadTreeChildren" && t[1] && ((o = i.prepareRows) == null || o.call(i, t[1]));
188
+ }
189
+ function se(e) {
190
+ if (!e) return;
191
+ const t = K.get(e);
192
+ if (t) return t;
193
+ const n = /* @__PURE__ */ new Map(), o = new Proxy(e, {
194
+ get(a, r, u) {
195
+ let c = Reflect.get(a, r, u);
196
+ if (!L(r)) return c;
197
+ const W = xe.has(r);
198
+ if (!W && !De.has(r)) return c;
199
+ let E = a;
200
+ if (!N(c)) {
201
+ const w = re(a);
202
+ w && (E = w, c = Reflect.get(w, r));
203
+ }
204
+ if (!N(c)) return c;
205
+ const $ = n.get(r);
206
+ if ($) return $;
207
+ const me = r === "undo" || r === "redo" ? "visible" : "full", G = (...w) => {
208
+ if (W) {
209
+ const B = Reflect.apply(c, E, w);
210
+ return Promise.resolve(B).then((we) => {
211
+ var H;
212
+ return (H = i.onSelectionMutated) == null || H.call(i), we;
213
+ });
214
+ }
215
+ if (le(r, w), r === "syncData") return F(() => ae(a));
216
+ if (r === "commitProxy") {
217
+ const B = ie(w[0]);
218
+ if (!Te.has(B || ""))
219
+ return Reflect.apply(c, E, w);
220
+ }
221
+ return F(() => Reflect.apply(c, E, w), me);
222
+ };
223
+ return n.set(r, G), G;
224
+ }
225
+ });
226
+ return K.set(e, o), o;
227
+ }
228
+ async function I(e, t) {
229
+ var c;
230
+ if (s || !x(t)) return !1;
231
+ const n = d(f);
232
+ if (!n) return !1;
233
+ const { treeConfig: o, clearTreeExpand: a, mergeCells: r } = d(l), u = n.getTreeExpandRecords();
234
+ M += 1;
235
+ try {
236
+ return (c = i.prepareRows) == null || c.call(i, e), await n.loadData(e), s || !x(t) || r && (await n.setMergeCells(r), s || !x(t)) || (a ? await n.clearTreeExpand() : u.length && (o != null && o.reserve) && await n.setTreeExpand(u, !0), s || !x(t)) ? !1 : (b.value = e, g("load-data"), !0);
237
+ } finally {
238
+ M -= 1;
239
+ }
240
+ }
241
+ function ue(e, t) {
242
+ return y(() => I(e, t));
243
+ }
244
+ function fe(e, t) {
245
+ return y(async () => !await I(e, t) || s || !x(t) ? !1 : (V(e), !0));
246
+ }
247
+ function ce(e, t) {
248
+ return y(async () => {
249
+ var o;
250
+ if (await P(), s || !t()) return !1;
251
+ const n = ((o = d(f)) == null ? void 0 : o.getTableData().fullData) || [];
252
+ return !e.length && !d(b).length && !n.length ? !1 : I(e, t);
253
+ });
254
+ }
255
+ function de() {
256
+ var e;
257
+ return ((e = d(f)) == null ? void 0 : e.getTableData().visibleData) || [];
258
+ }
259
+ function pe() {
260
+ const { api: e, data: t } = i;
261
+ if (S(e)) return;
262
+ if (D.value === "model" && p()) return d(C) || [];
263
+ const n = X(t);
264
+ return n !== void 0 ? n : p() ? d(C) || [] : void 0;
265
+ }
266
+ return D.value = _(), A = p(), Q(
267
+ () => p() ? d(C) : void 0,
268
+ () => {
269
+ p() && (D.value = "model");
270
+ },
271
+ { deep: 1, flush: "post" }
272
+ ), Q(
273
+ pe,
274
+ (e, t, n) => {
275
+ let o = !0;
276
+ n(() => {
277
+ o = !1;
278
+ }), !te(e) && (T += 1, z(), e && ce(e, () => o).catch((a) => {
279
+ }));
280
+ },
281
+ { immediate: !0, deep: 1, flush: "post" }
282
+ ), ve(() => {
283
+ const e = p();
284
+ e !== A && (A = e, D.value = _());
285
+ }), Ce() && Me(() => {
286
+ s = !0, h = void 0, m = void 0, v = !1;
287
+ }), {
288
+ rows: b,
289
+ loadRows: ue,
290
+ applyRows: fe,
291
+ emitRows: V,
292
+ getDataSource: de,
293
+ runDataOperation: F,
294
+ scheduleRowsCommit: j,
295
+ cancelRowsCommit: z,
296
+ onDataChange: oe,
297
+ commitRows: O,
298
+ createTableInstanceFacade: se,
299
+ /** 判断表格作用域是否仍然有效。 */
300
+ isActive: () => !s
301
+ };
302
+ }
303
+ export {
304
+ X as getExternalRowsValue,
305
+ ke as useTableData,
306
+ _e as withTreeExpand
307
+ };
@@ -0,0 +1,15 @@
1
+ import { ComputedRef } from 'vue';
2
+ import { VxeTablePropTypes } from 'vxe-table';
3
+ import { TtColumnOptions } from '../types/table';
4
+ /**
5
+ * 由列上的 `summary` 声明生成 vxe 的 `footerMethod`。
6
+ *
7
+ * vxe 要求 `footerMethod` 返回二维数组并按可见列顺序逐格对齐,而列顺序会被列设置与列拖拽改变,
8
+ * 所以对齐必须在 vxe 每次调用时按它传入的运行时可见列算,不能让调用方按下标写死。
9
+ * vxe 传入的 `data` 是 `afterFullData`(筛选排序后的完整数据),与 `getDataSource()` 口径一致,
10
+ * 与虚拟滚动的可视区无关。
11
+ * @param columnsRef 当前最终列配置
12
+ */
13
+ export declare function useTableFooter(columnsRef: ComputedRef<TtColumnOptions[]>): {
14
+ footerSummaryMethod: ComputedRef<VxeTablePropTypes.FooterMethod<any> | undefined>;
15
+ };