@dazhicheng/ui 1.6.7 → 1.6.9

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 (95) hide show
  1. package/dist/components/tt-form/src/form-render/expandable.js +31 -32
  2. package/dist/components/tt-form/src/useFormContext.js +1 -1
  3. package/dist/components/tt-panel-select/src/index.vue.js +28 -28
  4. package/dist/components/tt-table/index.d.ts +3 -15
  5. package/dist/components/tt-table/index.js +5 -4
  6. package/dist/components/tt-table/src/Table.vue.d.ts +1 -1
  7. package/dist/components/tt-table/src/Table.vue.js +3 -3
  8. package/dist/components/tt-table/src/TableForm.vue.js +168 -159
  9. package/dist/components/tt-table/src/components/TableAction.vue.d.ts +2 -12
  10. package/dist/components/tt-table/src/components/TableAction.vue.js +78 -175
  11. package/dist/components/tt-table/src/hooks/useGridProps.js +64 -60
  12. package/dist/components/tt-table/src/hooks/useTableData.js +77 -74
  13. package/dist/components/tt-table/src/types/table.d.ts +2 -1
  14. package/dist/components/tt-table/src/utils/table-api.d.ts +2 -1
  15. package/dist/components/tt-table/src/utils/table-api.js +3 -2
  16. package/dist/components/tt-vtable/index.js +54 -0
  17. package/dist/components/tt-vtable/src/components/TtVTable.vue.d.ts +188 -0
  18. package/dist/components/tt-vtable/src/components/TtVTable.vue.js +227 -0
  19. package/dist/components/tt-vtable/src/components/TtVTable.vue2.js +4 -0
  20. package/dist/components/tt-vtable/src/components/TtVTableForm.vue.d.ts +32 -0
  21. package/dist/components/tt-vtable/src/components/TtVTableForm.vue.js +121 -0
  22. package/dist/components/tt-vtable/src/components/TtVTableForm.vue2.js +4 -0
  23. package/dist/components/tt-vtable/src/components/VTableEmpty.vue.d.ts +64 -0
  24. package/dist/components/tt-vtable/src/components/VTableEmpty.vue.js +97 -0
  25. package/dist/components/tt-vtable/src/components/VTableEmpty.vue2.js +4 -0
  26. package/dist/components/tt-vtable/src/components/VTablePagination.vue.d.ts +53 -0
  27. package/dist/components/tt-vtable/src/components/VTablePagination.vue.js +52 -0
  28. package/dist/components/tt-vtable/src/components/VTablePagination.vue2.js +4 -0
  29. package/dist/components/tt-vtable/src/components/VTableSelectionAlert.vue.d.ts +35 -0
  30. package/dist/components/tt-vtable/src/components/VTableSelectionAlert.vue.js +50 -0
  31. package/dist/components/tt-vtable/src/components/VTableSelectionAlert.vue2.js +4 -0
  32. package/dist/components/tt-vtable/src/components/VTableToolbar.vue.d.ts +63 -0
  33. package/dist/components/tt-vtable/src/components/VTableToolbar.vue.js +126 -0
  34. package/dist/components/tt-vtable/src/components/VTableToolbar.vue2.js +4 -0
  35. package/dist/components/tt-vtable/src/components/VTableViewport.vue.js +133 -0
  36. package/dist/components/tt-vtable/src/components/VTableViewport.vue2.js +4 -0
  37. package/dist/components/tt-vtable/src/composables/useVTable.d.ts +41 -0
  38. package/dist/components/tt-vtable/src/composables/useVTable.js +25 -0
  39. package/dist/components/tt-vtable/src/composables/useVTableFormRender.d.ts +13 -0
  40. package/dist/components/tt-vtable/src/composables/useVTableFormRender.js +92 -0
  41. package/dist/components/tt-vtable/src/composables/useVTableRender.d.ts +13 -0
  42. package/dist/components/tt-vtable/src/composables/useVTableRender.js +13 -0
  43. package/dist/components/tt-vtable/src/engine/visactor/createListTable.d.ts +10 -0
  44. package/dist/components/tt-vtable/src/engine/visactor/createListTable.js +63 -0
  45. package/dist/components/tt-vtable/src/engine/visactor/createVueCellLayout.d.ts +37 -0
  46. package/dist/components/tt-vtable/src/engine/visactor/createVueCellLayout.js +133 -0
  47. package/dist/components/tt-vtable/src/engine/visactor/index.d.ts +8 -0
  48. package/dist/components/tt-vtable/src/engine/visactor/native-boundaries.d.ts +23 -0
  49. package/dist/components/tt-vtable/src/engine/visactor/native-boundaries.js +70 -0
  50. package/dist/components/tt-vtable/src/engine/visactor/record-adapter.d.ts +38 -0
  51. package/dist/components/tt-vtable/src/engine/visactor/record-adapter.js +41 -0
  52. package/dist/components/tt-vtable/src/engine/visactor/toColumnDefinitions.d.ts +45 -0
  53. package/dist/components/tt-vtable/src/engine/visactor/toColumnDefinitions.js +73 -0
  54. package/dist/components/tt-vtable/src/engine/visactor/toListTableOptions.d.ts +25 -0
  55. package/dist/components/tt-vtable/src/engine/visactor/toListTableOptions.js +25 -0
  56. package/dist/components/tt-vtable/src/engine/visactor/types.d.ts +29 -0
  57. package/dist/components/tt-vtable/src/features/column-preferences/column-preference-storage.d.ts +5 -0
  58. package/dist/components/tt-vtable/src/features/column-preferences/column-preference-storage.js +52 -0
  59. package/dist/components/tt-vtable/src/features/column-preferences/useColumnPreferences.d.ts +74 -0
  60. package/dist/components/tt-vtable/src/features/column-preferences/useColumnPreferences.js +232 -0
  61. package/dist/components/tt-vtable/src/features/editing/useCellEditing.d.ts +48 -0
  62. package/dist/components/tt-vtable/src/features/editing/useCellEditing.js +102 -0
  63. package/dist/components/tt-vtable/src/features/form-integration/useVTableForm.d.ts +51 -0
  64. package/dist/components/tt-vtable/src/features/pagination/useTablePagination.d.ts +40 -0
  65. package/dist/components/tt-vtable/src/features/pagination/useTablePagination.js +51 -0
  66. package/dist/components/tt-vtable/src/features/querying/useRecordQuery.d.ts +38 -0
  67. package/dist/components/tt-vtable/src/features/querying/useRecordQuery.js +57 -0
  68. package/dist/components/tt-vtable/src/features/records/index.d.ts +3 -0
  69. package/dist/components/tt-vtable/src/features/records/record-index.d.ts +122 -0
  70. package/dist/components/tt-vtable/src/features/records/record-index.js +209 -0
  71. package/dist/components/tt-vtable/src/features/records/useRecordSource.d.ts +41 -0
  72. package/dist/components/tt-vtable/src/features/records/useRecordSource.js +249 -0
  73. package/dist/components/tt-vtable/src/features/selection/useRowSelection.d.ts +65 -0
  74. package/dist/components/tt-vtable/src/features/selection/useRowSelection.js +129 -0
  75. package/dist/components/tt-vtable/src/features/tree/useTreeRecords.d.ts +60 -0
  76. package/dist/components/tt-vtable/src/features/tree/useTreeRecords.js +125 -0
  77. package/dist/components/tt-vtable/src/public/column-preferences.d.ts +32 -0
  78. package/dist/components/tt-vtable/src/public/index.d.ts +8 -0
  79. package/dist/components/tt-vtable/src/public/table-api.d.ts +215 -0
  80. package/dist/components/tt-vtable/src/public/table-column.d.ts +123 -0
  81. package/dist/components/tt-vtable/src/public/table-errors.d.ts +26 -0
  82. package/dist/components/tt-vtable/src/public/table-errors.js +26 -0
  83. package/dist/components/tt-vtable/src/public/table-events.d.ts +69 -0
  84. package/dist/components/tt-vtable/src/public/table-props.d.ts +216 -0
  85. package/dist/components/tt-vtable/src/public/table-slots.d.ts +37 -0
  86. package/dist/components/tt-vtable/src/runtime/createVTableController.d.ts +12 -0
  87. package/dist/components/tt-vtable/src/runtime/createVTableController.js +238 -0
  88. package/dist/components/tt-vtable/src/runtime/createVTableRuntime.d.ts +79 -0
  89. package/dist/components/tt-vtable/src/runtime/createVTableRuntime.js +380 -0
  90. package/dist/index.d.ts +1 -0
  91. package/dist/index.js +129 -115
  92. package/dist/packages/utils/src/is.js +46 -37
  93. package/dist/style.css +1 -1
  94. package/package.json +3 -1
  95. package/dist/assets/svg/action_more.svg.js +0 -4
@@ -0,0 +1,249 @@
1
+ import "axios";
2
+ import "element-plus";
3
+ import { isArray as _, isString as J } from "../../../../../packages/utils/src/is.js";
4
+ import { shallowRef as Q, computed as B, triggerRef as h } from "vue";
5
+ import "dayjs";
6
+ import "numeral";
7
+ import "xe-utils";
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
+ import { createTtVTableError as y } from "../../public/table-errors.js";
17
+ import { TtVTableRecordIndex as S, getRecordAtPath as N, getRecordFieldValue as p, toRecordWithFieldValue as I, replaceRecordAtPath as A } from "./record-index.js";
18
+ function F(o) {
19
+ return _(o) ? [...o] : [o];
20
+ }
21
+ function x(o) {
22
+ const u = o[0];
23
+ if (u === void 0)
24
+ throw y("TT_VTABLE_RECORD_NOT_FOUND", "记录索引路径不能为空。", {});
25
+ return o.length === 1 ? u : [...o];
26
+ }
27
+ function X(o) {
28
+ return J(o) && o.includes(".");
29
+ }
30
+ function Z(o, u) {
31
+ if (o.length !== u.length) return u.length - o.length;
32
+ for (let a = 0; a < o.length; a += 1) {
33
+ const c = o[a], i = u[a];
34
+ if (!(c === void 0 || i === void 0) && c !== i)
35
+ return i - c;
36
+ }
37
+ return 0;
38
+ }
39
+ function C(o, u, a) {
40
+ if (u.length === 1) {
41
+ const v = u[0];
42
+ v !== void 0 && o.splice(v, 1);
43
+ return;
44
+ }
45
+ const c = u.slice(0, -1), i = N(o, c, a);
46
+ if (!i) return;
47
+ const w = p(i, a);
48
+ if (!_(w)) return;
49
+ const g = [...w], K = u[u.length - 1];
50
+ if (K === void 0) return;
51
+ g.splice(K, 1);
52
+ const f = I(i, a, g);
53
+ A(o, c, f, a);
54
+ }
55
+ function ee(o, u, a) {
56
+ if (u.length <= 1) return;
57
+ const c = u.slice(0, -1), i = N(o, c, a);
58
+ if (!i) return;
59
+ const w = p(i, a);
60
+ if (!_(w)) return;
61
+ const g = I(i, a, [...w]);
62
+ A(o, c, g, a);
63
+ }
64
+ function xe(o) {
65
+ const u = o.childrenField || "children", a = o.mutationMode ?? "copy-on-write", c = Q([]), i = new S(o.rowKey, u);
66
+ let w = !1;
67
+ const g = B(() => c.value), K = B(() => c.value.length);
68
+ function f() {
69
+ if (w)
70
+ throw y("TT_VTABLE_RELEASED", "records feature 已经释放。", {});
71
+ }
72
+ function v() {
73
+ return c.value;
74
+ }
75
+ function U(e) {
76
+ return i.getRecord(e);
77
+ }
78
+ function m(e) {
79
+ return i.getRowKey(e);
80
+ }
81
+ function M(e) {
82
+ const t = i.getLocation(e);
83
+ return t ? x(t.path) : void 0;
84
+ }
85
+ function L(e) {
86
+ var s;
87
+ f();
88
+ const t = [...e];
89
+ i.replace(t), c.value = t, o.engine.setRecords(t), (s = o.onRecordsReplaced) == null || s.call(o, t);
90
+ }
91
+ function V(e, t) {
92
+ const s = [...c.value], n = t ?? s.length;
93
+ s.splice(n, 0, ...e), new S(o.rowKey, u).replace(s), c.value.splice(n, 0, ...e), o.engine.getInstance() && o.engine.addRecords(e, n), i.replace(c.value), h(c);
94
+ }
95
+ function P(e) {
96
+ f();
97
+ const t = F(e);
98
+ t.length && V(t);
99
+ }
100
+ function b(e, t) {
101
+ f();
102
+ const s = Number.isFinite(e) ? Math.max(0, Math.min(Math.floor(e), c.value.length)) : c.value.length, n = F(t);
103
+ n.length && V(n, s);
104
+ }
105
+ function $(e, t) {
106
+ return { ...e, ...t };
107
+ }
108
+ function O(e, t, s) {
109
+ const n = i.getLocation(e);
110
+ if (!n)
111
+ throw y("TT_VTABLE_RECORD_NOT_FOUND", `未找到 rowKey ${String(e)}。`, { rowKey: e });
112
+ const l = a === "shared" ? { ...n.record } : n.record, R = $(n.record, t), r = m(R), d = Object.keys(t);
113
+ return {
114
+ location: n,
115
+ previousRecord: l,
116
+ nextRecord: R,
117
+ previousRowKey: e,
118
+ nextRowKey: r,
119
+ changedFields: d,
120
+ source: s
121
+ };
122
+ }
123
+ function T(e, t = !0) {
124
+ a === "copy-on-write" ? A(c.value, e.location.path, e.nextRecord, u) : (Object.assign(e.location.record, e.nextRecord), e.nextRecord = e.location.record), t && (i.replaceLocation(
125
+ e.previousRowKey,
126
+ e.nextRowKey,
127
+ e.nextRecord,
128
+ e.location.path
129
+ ), i.refreshBranch(c.value, e.location.path));
130
+ }
131
+ function E(e) {
132
+ var t;
133
+ e.source === "editing" || e.source === "tree" || (t = o.onRecordChange) == null || t.call(o, {
134
+ rowKey: e.previousRowKey,
135
+ nextRowKey: e.nextRowKey,
136
+ record: e.nextRecord,
137
+ previousRecord: e.previousRecord,
138
+ changedFields: e.changedFields,
139
+ source: e.source
140
+ });
141
+ }
142
+ function W(e, t, s = "api") {
143
+ f();
144
+ const n = O(e, t, s);
145
+ if (n.nextRowKey !== e && i.has(n.nextRowKey))
146
+ throw y("TT_VTABLE_DUPLICATE_ROW_KEY", `rowKey ${String(n.nextRowKey)} 已存在。`, {
147
+ rowKey: n.nextRowKey
148
+ });
149
+ T(n), o.engine.updateRecords([n.nextRecord], [x(n.location.path)]), n.changedFields.includes(u) && i.replace(c.value), h(c), E(n);
150
+ }
151
+ function Y(e) {
152
+ if (f(), !e.length) return;
153
+ const t = /* @__PURE__ */ new Map();
154
+ e.forEach((r) => {
155
+ const d = t.get(r.rowKey);
156
+ t.set(r.rowKey, {
157
+ rowKey: r.rowKey,
158
+ changes: { ...d == null ? void 0 : d.changes, ...r.changes },
159
+ source: r.source ?? (d == null ? void 0 : d.source) ?? "api"
160
+ });
161
+ });
162
+ const s = [...t.values()].map(
163
+ (r) => O(r.rowKey, r.changes, r.source ?? "api")
164
+ ), n = new Set(s.map((r) => r.previousRowKey)), l = /* @__PURE__ */ new Set();
165
+ s.forEach((r) => {
166
+ if (l.has(r.nextRowKey) || i.has(r.nextRowKey) && !n.has(r.nextRowKey))
167
+ throw y(
168
+ "TT_VTABLE_DUPLICATE_ROW_KEY",
169
+ `rowKey ${String(r.nextRowKey)} 在批量更新后重复。`,
170
+ { rowKey: r.nextRowKey }
171
+ );
172
+ l.add(r.nextRowKey);
173
+ });
174
+ const R = s.some(
175
+ (r) => r.previousRowKey !== r.nextRowKey || r.changedFields.includes(u)
176
+ );
177
+ s.forEach((r) => T(r, !R)), R && i.replace(c.value), o.engine.updateRecords(
178
+ s.map((r) => r.nextRecord),
179
+ s.map((r) => x(r.location.path))
180
+ ), h(c), s.forEach(E);
181
+ }
182
+ function j(e, t, s, n) {
183
+ const l = i.getLocation(e);
184
+ if (!l)
185
+ throw y("TT_VTABLE_RECORD_NOT_FOUND", `未找到 rowKey ${String(e)}。`, { rowKey: e });
186
+ const R = a === "shared" ? { ...l.record } : l.record;
187
+ if (p(R, t) === s) return;
188
+ const d = I(l.record, t, s), H = m(d);
189
+ return {
190
+ location: l,
191
+ previousRecord: R,
192
+ nextRecord: d,
193
+ previousRowKey: e,
194
+ nextRowKey: H,
195
+ changedFields: [t],
196
+ source: n
197
+ };
198
+ }
199
+ function D(e, t, s, n = "api") {
200
+ f();
201
+ const l = j(e, t, s, n);
202
+ if (!l) return;
203
+ if (l.nextRowKey !== e && i.has(l.nextRowKey))
204
+ throw y("TT_VTABLE_DUPLICATE_ROW_KEY", `rowKey ${String(l.nextRowKey)} 已存在。`, {
205
+ rowKey: l.nextRowKey
206
+ });
207
+ T(l);
208
+ const R = x(l.location.path);
209
+ (X(t) ? !1 : o.engine.changeCellValue(R, t, s)) || o.engine.updateRecords([l.nextRecord], [R]), t === u && i.replace(c.value), h(c), E(l);
210
+ }
211
+ function k(e) {
212
+ f();
213
+ const t = [...new Set(e)].map((n) => i.getLocation(n)).filter((n) => !!n).sort((n, l) => Z(n.path, l.path));
214
+ if (!t.length) return;
215
+ const s = t.map((n) => x(n.path));
216
+ a === "copy-on-write" && t.forEach((n) => ee(c.value, n.path, u)), t.forEach((n) => C(c.value, n.path, u)), o.engine.getInstance() && o.engine.deleteRecords(s), i.replace(c.value), h(c);
217
+ }
218
+ function z(e, t) {
219
+ D(e, u, [...t], "tree");
220
+ }
221
+ function q() {
222
+ f(), o.engine.setRecords(c.value);
223
+ }
224
+ function G() {
225
+ w || (w = !0);
226
+ }
227
+ return L(o.records ?? []), {
228
+ records: g,
229
+ count: K,
230
+ getAll: v,
231
+ getByKey: U,
232
+ replaceAll: L,
233
+ append: P,
234
+ insertAt: b,
235
+ patchByKey: W,
236
+ patchMany: Y,
237
+ setCellValue: D,
238
+ removeByKeys: k,
239
+ recordIndex: i,
240
+ getRowKey: m,
241
+ getRecordIndex: M,
242
+ setChildren: z,
243
+ syncToEngine: q,
244
+ release: G
245
+ };
246
+ }
247
+ export {
248
+ xe as useRecordSource
249
+ };
@@ -0,0 +1,65 @@
1
+ import { ComputedRef, MaybeRefOrGetter, Ref } from 'vue';
2
+ import { TtVTableRowKey } from '../../public/table-api';
3
+ import { TtVTableSelectionOptions } from '../../public/table-props';
4
+ /** 支持的行选择模式。 */
5
+ export type VTableSelectionMode = NonNullable<TtVTableSelectionOptions<unknown>["mode"]>;
6
+ /** 暴露给表格 runtime 的选择状态。 */
7
+ export interface VTableSelectionState<Row, Key extends TtVTableRowKey> {
8
+ /** 按选择顺序稳定排列的主键。 */
9
+ keys: ComputedRef<readonly Key[]>;
10
+ /** 当前 runtime 数据源中仍存在的已选记录。 */
11
+ loadedRows: ComputedRef<readonly Row[]>;
12
+ /** 当前 runtime 数据源中不存在的已选主键。 */
13
+ missingKeys: ComputedRef<readonly Key[]>;
14
+ /** 是否正在把公共 model 同步到原生选择状态。 */
15
+ isSyncingNative: Readonly<Ref<boolean>>;
16
+ }
17
+ /** 挂载到表格命名空间 API 的选择动作。 */
18
+ export interface VTableSelectionActions<Row, Key extends TtVTableRowKey> {
19
+ /** 替换全部已选主键。 */
20
+ setKeys: (keys: readonly Key[]) => void;
21
+ /** 按主键切换一条记录的选择状态。 */
22
+ toggleKey: (key: Key, selected?: boolean) => void;
23
+ /** 选择当前页全部可选记录。 */
24
+ selectCurrentPage: () => void;
25
+ /** 选择 runtime 当前已加载的全部可选记录。 */
26
+ selectLoadedRecords: () => void;
27
+ /** 清空选择。 */
28
+ clear: () => void;
29
+ /** 判断记录是否允许选择。 */
30
+ isSelectable: (record: Row) => boolean;
31
+ }
32
+ /** 完整的选择 feature 契约。 */
33
+ export interface VTableRowSelection<Row, Key extends TtVTableRowKey> extends VTableSelectionState<Row, Key>, VTableSelectionActions<Row, Key> {
34
+ /** 接收并应用 VTable 的 checkbox 或 radio 变化。 */
35
+ onNativeSelectionChange: (record: Row, selected: boolean) => void;
36
+ /** runtime 记录源变化后校正已选主键。 */
37
+ reconcileRecords: () => void;
38
+ /** 原生实例 ready 后同步最终选择状态。 */
39
+ syncNativeState: () => Promise<void>;
40
+ }
41
+ /** 行选择 feature 所需依赖。 */
42
+ export interface UseRowSelectionOptions<Row, Key extends TtVTableRowKey> {
43
+ /** 选择模式。 */
44
+ mode: MaybeRefOrGetter<VTableSelectionMode>;
45
+ /** 公共 selected-row-keys model。 */
46
+ selectedRowKeys: Ref<Key[]>;
47
+ /** 读取 runtime 当前加载的全部记录。 */
48
+ getLoadedRecords: () => readonly Row[];
49
+ /** 读取当前本地页或远程页记录。 */
50
+ getCurrentPageRecords: () => readonly Row[];
51
+ /** 按业务主键读取一条已加载记录。 */
52
+ getRecordByKey: (key: Key) => Row | undefined;
53
+ /** 读取记录的稳定业务主键。 */
54
+ getRowKey: (record: Row) => Key;
55
+ /** 可选的业务可选性判断函数。 */
56
+ isRowSelectable?: (record: Row) => boolean;
57
+ /** 是否跨远程分页保留未加载主键。 */
58
+ reserveAcrossPages?: MaybeRefOrGetter<boolean>;
59
+ /** 返回参与树级联的记录,结果包含源记录。 */
60
+ getCascadeRecords?: (record: Row) => readonly Row[];
61
+ /** 把公共主键同步到原生 checkbox 或 radio 视觉状态。 */
62
+ syncNativeSelection?: (keys: readonly Key[]) => Promise<void> | void;
63
+ }
64
+ /** 创建受控的单选或多选行选择 feature。 */
65
+ export declare function useRowSelection<Row, Key extends TtVTableRowKey = TtVTableRowKey>(options: UseRowSelectionOptions<Row, Key>): VTableRowSelection<Row, Key>;
@@ -0,0 +1,129 @@
1
+ import "axios";
2
+ import "element-plus";
3
+ import { isNumber as L, isString as V } from "../../../../../packages/utils/src/is.js";
4
+ import { shallowRef as F, computed as o, toValue as K, watch as S } from "vue";
5
+ import "dayjs";
6
+ import "numeral";
7
+ import "xe-utils";
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
+ function M(e) {
17
+ return V(e) ? !!e : L(e) && Number.isFinite(e);
18
+ }
19
+ function w(e, n) {
20
+ return e.length === n.length && e.every((u, c) => u === n[c]);
21
+ }
22
+ function O(e) {
23
+ const n = /* @__PURE__ */ new Set(), u = [];
24
+ return e.forEach((c) => {
25
+ !M(c) || n.has(c) || (n.add(c), u.push(c));
26
+ }), u;
27
+ }
28
+ function p(e) {
29
+ const n = F(!1);
30
+ let u = 0;
31
+ const c = o(() => K(e.mode)), s = o(() => d(e.selectedRowKeys.value)), h = o(() => {
32
+ const t = [];
33
+ return s.value.forEach((r) => {
34
+ const l = e.getRecordByKey(r);
35
+ l && t.push(l);
36
+ }), t;
37
+ }), N = o(() => s.value.filter((t) => !e.getRecordByKey(t)));
38
+ function d(t) {
39
+ const r = O(t);
40
+ return c.value === "none" ? [] : c.value === "single" ? r.slice(0, 1) : r;
41
+ }
42
+ function i(t) {
43
+ return e.isRowSelectable ? e.isRowSelectable(t) : !0;
44
+ }
45
+ function a(t) {
46
+ const r = d(t);
47
+ w(e.selectedRowKeys.value, r) || (e.selectedRowKeys.value = r);
48
+ }
49
+ function b(t) {
50
+ var l;
51
+ return (((l = e.getCascadeRecords) == null ? void 0 : l.call(e, t)) ?? [t]).filter(i).map(e.getRowKey);
52
+ }
53
+ function m(t, r) {
54
+ const l = e.getRecordByKey(t);
55
+ if (!l || !i(l) || c.value === "none") return;
56
+ const x = s.value.includes(t), R = r ?? !x, A = c.value === "single" ? [t] : b(l);
57
+ if (c.value === "single") {
58
+ a(R ? [t] : []);
59
+ return;
60
+ }
61
+ const f = new Set(s.value);
62
+ A.forEach((g) => {
63
+ R ? f.add(g) : f.delete(g);
64
+ }), a([...f]);
65
+ }
66
+ function v(t) {
67
+ if (c.value === "none") return;
68
+ const r = t.filter(i).map(e.getRowKey);
69
+ if (c.value === "single") {
70
+ a(r.slice(0, 1));
71
+ return;
72
+ }
73
+ a([...s.value, ...r]);
74
+ }
75
+ function z() {
76
+ v(e.getCurrentPageRecords());
77
+ }
78
+ function B() {
79
+ v(e.getLoadedRecords());
80
+ }
81
+ function C() {
82
+ a([]);
83
+ }
84
+ function q(t, r) {
85
+ n.value || m(e.getRowKey(t), r);
86
+ }
87
+ function E() {
88
+ K(e.reserveAcrossPages ?? !1) || a(s.value.filter((t) => !!e.getRecordByKey(t)));
89
+ }
90
+ async function y(t) {
91
+ if (!e.syncNativeSelection) return;
92
+ u += 1;
93
+ const r = u;
94
+ n.value = !0;
95
+ try {
96
+ await e.syncNativeSelection(t);
97
+ } finally {
98
+ r === u && (n.value = !1);
99
+ }
100
+ }
101
+ function P() {
102
+ return y(s.value);
103
+ }
104
+ return S(
105
+ e.selectedRowKeys,
106
+ (t) => {
107
+ const r = d(t);
108
+ w(t, r) || (e.selectedRowKeys.value = r), y(r);
109
+ },
110
+ { immediate: !0 }
111
+ ), S(c, () => a(e.selectedRowKeys.value)), {
112
+ keys: s,
113
+ loadedRows: h,
114
+ missingKeys: N,
115
+ isSyncingNative: n,
116
+ setKeys: a,
117
+ toggleKey: m,
118
+ selectCurrentPage: z,
119
+ selectLoadedRecords: B,
120
+ clear: C,
121
+ isSelectable: i,
122
+ onNativeSelectionChange: q,
123
+ reconcileRecords: E,
124
+ syncNativeState: P
125
+ };
126
+ }
127
+ export {
128
+ p as useRowSelection
129
+ };
@@ -0,0 +1,60 @@
1
+ import { ComputedRef, MaybeRefOrGetter, Ref } from 'vue';
2
+ import { TtVTableRowKey } from '../../public/table-api';
3
+ import { TtVTableTreeLoadError, TtVTableTreeLoadSuccess } from '../../public/table-events';
4
+ import { TtVTableTreeChildrenRequest } from '../../public/table-props';
5
+ /** 暴露给 runtime 的树状态与动作。 */
6
+ export interface VTableTreeRecords<Row, Key extends TtVTableRowKey> {
7
+ /** 已展开业务主键。 */
8
+ expandedKeys: Readonly<Ref<readonly Key[]>>;
9
+ /** 正在加载子节点的业务主键。 */
10
+ loadingKeys: Readonly<Ref<readonly Key[]>>;
11
+ /** 最近一次未中止的树请求错误。 */
12
+ error: Readonly<Ref<Error | undefined>>;
13
+ /** 是否至少有一个树请求进行中。 */
14
+ isLoading: ComputedRef<boolean>;
15
+ /** 展开节点并在需要时懒加载子节点。 */
16
+ expand: (key: Key) => Promise<void>;
17
+ /** 折叠节点且不丢弃已缓存子节点。 */
18
+ collapse: (key: Key) => void;
19
+ /** 切换节点展开状态。 */
20
+ toggle: (key: Key) => Promise<void>;
21
+ /** 加载节点子记录并复用重复请求。 */
22
+ fetchChildren: (key: Key) => Promise<readonly Row[]>;
23
+ /** 应用原生层级状态事件。 */
24
+ onNativeHierarchyChange: (record: Row, expanded: boolean) => Promise<void>;
25
+ /** records 根引用变化后使进行中的请求失效。 */
26
+ onRecordsReplaced: () => void;
27
+ /** 返回树选择级联使用的已加载后代记录。 */
28
+ getCascadeRecords: (record: Row) => readonly Row[];
29
+ /** 原生实例 ready 后同步最终展开快照。 */
30
+ syncExpandedState: () => Promise<void>;
31
+ /** 释放进行中的请求和状态。 */
32
+ release: () => void;
33
+ }
34
+ /** 树记录 feature 所需依赖。 */
35
+ export interface UseTreeRecordsOptions<Row, Key extends TtVTableRowKey> {
36
+ /** 初始展开主键。 */
37
+ defaultExpandedKeys?: readonly Key[];
38
+ /** 按主键读取一条 runtime 记录。 */
39
+ getRecordByKey: (key: Key) => Row | undefined;
40
+ /** 读取记录的稳定业务主键。 */
41
+ getRowKey: (record: Row) => Key;
42
+ /** 从 runtime 记录读取已加载子记录。 */
43
+ getChildren: (record: Row) => readonly Row[] | undefined;
44
+ /** 通过 records feature 写入复制后的子记录。 */
45
+ setChildren: (parentKey: Key, children: readonly Row[]) => Promise<void> | void;
46
+ /** 可选的子节点懒加载请求回调。 */
47
+ fetchTreeChildren?: (request: TtVTableTreeChildrenRequest<Row, Key>) => Promise<readonly Row[]>;
48
+ /** 后续展开时是否复用已加载子记录。 */
49
+ cacheChildren?: MaybeRefOrGetter<boolean>;
50
+ /** 同步一个原生层级状态。 */
51
+ setNativeExpanded?: (key: Key, expanded: boolean) => Promise<void> | void;
52
+ /** 同步一个原生层级加载状态。 */
53
+ setNativeLoading?: (key: Key, loading: boolean) => Promise<void> | void;
54
+ /** 当前子记录被接纳后调用一次。 */
55
+ onLoadSuccess?: (change: TtVTableTreeLoadSuccess<Row, Key>) => void;
56
+ /** 当前未中止请求失败后调用一次。 */
57
+ onLoadError?: (failure: TtVTableTreeLoadError<Key>) => void;
58
+ }
59
+ /** 创建树展开和可防竞态的懒加载 feature。 */
60
+ export declare function useTreeRecords<Row, Key extends TtVTableRowKey = TtVTableRowKey>(options: UseTreeRecordsOptions<Row, Key>): VTableTreeRecords<Row, Key>;
@@ -0,0 +1,125 @@
1
+ import "axios";
2
+ import "element-plus";
3
+ import { isArray as G, isError as j } from "../../../../../packages/utils/src/is.js";
4
+ import { shallowRef as E, computed as D, onScopeDispose as H, toValue as M } from "vue";
5
+ import "dayjs";
6
+ import "numeral";
7
+ import "xe-utils";
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
+ function V(r) {
17
+ return new Error(j(r) ? String(r).replace(/^Error:\s*/, "") : String(r));
18
+ }
19
+ function x(r, n) {
20
+ return r.includes(n) ? [...r] : [...r, n];
21
+ }
22
+ function T(r, n) {
23
+ return r.filter((i) => i !== n);
24
+ }
25
+ function re(r) {
26
+ const n = E([...new Set(r.defaultExpandedKeys ?? [])]), i = E([]), v = E(), u = /* @__PURE__ */ new Map();
27
+ let s = 0, h = !1;
28
+ const L = D(() => i.value.length > 0);
29
+ async function w(e, t, a = !0) {
30
+ var c;
31
+ n.value = t ? x(n.value, e) : T(n.value, e), a && await ((c = r.setNativeExpanded) == null ? void 0 : c.call(r, e, t));
32
+ }
33
+ async function K(e, t) {
34
+ var a;
35
+ i.value = t ? x(i.value, e) : T(i.value, e), await ((a = r.setNativeLoading) == null ? void 0 : a.call(r, e, t));
36
+ }
37
+ function m(e) {
38
+ const t = u.get(e);
39
+ if (t) return t.promise;
40
+ const a = r.getRecordByKey(e);
41
+ if (!a) return Promise.reject(new Error(`Cannot load children for missing record "${String(e)}".`));
42
+ const c = r.getChildren(a);
43
+ if (M(r.cacheChildren ?? !0) && (c != null && c.length) || !r.fetchTreeChildren)
44
+ return Promise.resolve(c ?? []);
45
+ const l = new AbortController(), d = s, g = {}, S = (async () => {
46
+ var q, b;
47
+ try {
48
+ await K(e, !0), v.value = void 0;
49
+ const o = await r.fetchTreeChildren({ parent: a, parentKey: e, signal: l.signal });
50
+ if (l.signal.aborted || d !== s || h) return [];
51
+ if (!G(o)) throw new Error("Tree child request must return an array.");
52
+ const f = [...o];
53
+ return await r.setChildren(e, f), l.signal.aborted || d !== s || h ? [] : ((q = r.onLoadSuccess) == null || q.call(r, { parentKey: e, children: f }), f);
54
+ } catch (o) {
55
+ const f = V(o);
56
+ if (l.signal.aborted || d !== s || h) return [];
57
+ throw v.value = f, (b = r.onLoadError) == null || b.call(r, { parentKey: e, error: f }), f;
58
+ } finally {
59
+ const o = u.get(e);
60
+ (o == null ? void 0 : o.token) === g && u.delete(e), d === s && !h && await K(e, !1);
61
+ }
62
+ })();
63
+ return u.set(e, { controller: l, promise: S, token: g }), S;
64
+ }
65
+ async function R(e) {
66
+ await w(e, !0);
67
+ try {
68
+ await m(e);
69
+ } catch (t) {
70
+ throw await w(e, !1), t;
71
+ }
72
+ }
73
+ function C(e) {
74
+ w(e, !1);
75
+ }
76
+ function N(e) {
77
+ return n.value.includes(e) ? (C(e), Promise.resolve()) : R(e);
78
+ }
79
+ async function p(e, t) {
80
+ const a = r.getRowKey(e);
81
+ if (await w(a, t, !1), !!t)
82
+ try {
83
+ await m(a);
84
+ } catch (c) {
85
+ throw await w(a, !1), c;
86
+ }
87
+ }
88
+ function P() {
89
+ s += 1, u.forEach((e) => e.controller.abort()), u.clear(), i.value = [], v.value = void 0, n.value = n.value.filter((e) => !!r.getRecordByKey(e));
90
+ }
91
+ function A(e) {
92
+ const t = /* @__PURE__ */ new Set(), a = [];
93
+ function c(l) {
94
+ var g;
95
+ const d = r.getRowKey(l);
96
+ t.has(d) || (t.add(d), a.push(l), (g = r.getChildren(l)) == null || g.forEach(c));
97
+ }
98
+ return c(e), a;
99
+ }
100
+ async function B() {
101
+ var e;
102
+ for (const t of n.value) await ((e = r.setNativeExpanded) == null ? void 0 : e.call(r, t, !0));
103
+ }
104
+ function y() {
105
+ h || (h = !0, s += 1, u.forEach((e) => e.controller.abort()), u.clear(), i.value = []);
106
+ }
107
+ return H(y), {
108
+ expandedKeys: n,
109
+ loadingKeys: i,
110
+ error: v,
111
+ isLoading: L,
112
+ expand: R,
113
+ collapse: C,
114
+ toggle: N,
115
+ fetchChildren: m,
116
+ onNativeHierarchyChange: p,
117
+ onRecordsReplaced: P,
118
+ getCascadeRecords: A,
119
+ syncExpandedState: B,
120
+ release: y
121
+ };
122
+ }
123
+ export {
124
+ re as useTreeRecords
125
+ };
@@ -0,0 +1,32 @@
1
+ import { TtVTableColumn } from './table-column';
2
+ /** 封装层支持持久化的冻结列位置。 */
3
+ export type VTableColumnFrozen = NonNullable<TtVTableColumn["frozen"]>;
4
+ /** 一个语义列主键的持久化偏好。 */
5
+ export interface VTableColumnPreference {
6
+ /** 稳定语义列主键。 */
7
+ key: string;
8
+ /** 列是否可见。 */
9
+ visible: boolean;
10
+ /** 在同级列中从 0 开始的顺序。 */
11
+ order: number;
12
+ /** 可选数字列宽。 */
13
+ width?: number;
14
+ /** 可选冻结位置。 */
15
+ frozen?: VTableColumnFrozen;
16
+ }
17
+ /** 带版本的列偏好载荷。 */
18
+ export interface VTableColumnPreferenceSnapshot {
19
+ /** 用于后续迁移的 schema 版本。 */
20
+ schemaVersion: number;
21
+ /** 按语义列主键索引的偏好。 */
22
+ columns: readonly VTableColumnPreference[];
23
+ }
24
+ /** 本地或服务端列偏好的异步持久化边界。 */
25
+ export interface VTableColumnPreferenceStorage {
26
+ /** 读取已保存快照。 */
27
+ read: (key: string) => Promise<VTableColumnPreferenceSnapshot | undefined>;
28
+ /** 写入完整快照。 */
29
+ write: (key: string, snapshot: VTableColumnPreferenceSnapshot) => Promise<void>;
30
+ /** 删除已保存快照。 */
31
+ remove: (key: string) => Promise<void>;
32
+ }
@@ -0,0 +1,8 @@
1
+ /** TtVTable 公共 API、列、事件、props、slots 与错误类型。 */
2
+ export * from './column-preferences';
3
+ export * from './table-api';
4
+ export * from './table-column';
5
+ export * from './table-errors';
6
+ export * from './table-events';
7
+ export * from './table-props';
8
+ export * from './table-slots';