@dazhicheng/ui 1.6.10 → 1.6.11

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 (87) 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-form/src/useFormContext.js +1 -1
  4. package/dist/components/tt-icon/index.vue.js +2 -2
  5. package/dist/components/tt-loading/src/loading.vue.js +2 -2
  6. package/dist/components/tt-table/index.js +4 -5
  7. package/dist/components/tt-table/src/TableForm.vue.js +2 -3
  8. package/dist/hooks/useBasicDataOptions.js +110 -91
  9. package/dist/index.d.ts +0 -1
  10. package/dist/index.js +115 -129
  11. package/dist/packages/utils/src/is.js +37 -46
  12. package/dist/style.css +1 -1
  13. package/package.json +1 -3
  14. package/dist/components/tt-vtable/index.js +0 -54
  15. package/dist/components/tt-vtable/src/components/TtVTable.vue.d.ts +0 -188
  16. package/dist/components/tt-vtable/src/components/TtVTable.vue.js +0 -227
  17. package/dist/components/tt-vtable/src/components/TtVTable.vue2.js +0 -4
  18. package/dist/components/tt-vtable/src/components/TtVTableForm.vue.d.ts +0 -32
  19. package/dist/components/tt-vtable/src/components/TtVTableForm.vue.js +0 -121
  20. package/dist/components/tt-vtable/src/components/TtVTableForm.vue2.js +0 -4
  21. package/dist/components/tt-vtable/src/components/VTableEmpty.vue.d.ts +0 -64
  22. package/dist/components/tt-vtable/src/components/VTableEmpty.vue.js +0 -97
  23. package/dist/components/tt-vtable/src/components/VTableEmpty.vue2.js +0 -4
  24. package/dist/components/tt-vtable/src/components/VTablePagination.vue.d.ts +0 -53
  25. package/dist/components/tt-vtable/src/components/VTablePagination.vue.js +0 -52
  26. package/dist/components/tt-vtable/src/components/VTablePagination.vue2.js +0 -4
  27. package/dist/components/tt-vtable/src/components/VTableSelectionAlert.vue.d.ts +0 -35
  28. package/dist/components/tt-vtable/src/components/VTableSelectionAlert.vue.js +0 -50
  29. package/dist/components/tt-vtable/src/components/VTableSelectionAlert.vue2.js +0 -4
  30. package/dist/components/tt-vtable/src/components/VTableToolbar.vue.d.ts +0 -63
  31. package/dist/components/tt-vtable/src/components/VTableToolbar.vue.js +0 -126
  32. package/dist/components/tt-vtable/src/components/VTableToolbar.vue2.js +0 -4
  33. package/dist/components/tt-vtable/src/components/VTableViewport.vue.js +0 -133
  34. package/dist/components/tt-vtable/src/components/VTableViewport.vue2.js +0 -4
  35. package/dist/components/tt-vtable/src/composables/useVTable.d.ts +0 -41
  36. package/dist/components/tt-vtable/src/composables/useVTable.js +0 -25
  37. package/dist/components/tt-vtable/src/composables/useVTableFormRender.d.ts +0 -13
  38. package/dist/components/tt-vtable/src/composables/useVTableFormRender.js +0 -92
  39. package/dist/components/tt-vtable/src/composables/useVTableRender.d.ts +0 -13
  40. package/dist/components/tt-vtable/src/composables/useVTableRender.js +0 -13
  41. package/dist/components/tt-vtable/src/engine/visactor/createListTable.d.ts +0 -10
  42. package/dist/components/tt-vtable/src/engine/visactor/createListTable.js +0 -63
  43. package/dist/components/tt-vtable/src/engine/visactor/createVueCellLayout.d.ts +0 -37
  44. package/dist/components/tt-vtable/src/engine/visactor/createVueCellLayout.js +0 -133
  45. package/dist/components/tt-vtable/src/engine/visactor/index.d.ts +0 -8
  46. package/dist/components/tt-vtable/src/engine/visactor/native-boundaries.d.ts +0 -23
  47. package/dist/components/tt-vtable/src/engine/visactor/native-boundaries.js +0 -70
  48. package/dist/components/tt-vtable/src/engine/visactor/record-adapter.d.ts +0 -38
  49. package/dist/components/tt-vtable/src/engine/visactor/record-adapter.js +0 -41
  50. package/dist/components/tt-vtable/src/engine/visactor/toColumnDefinitions.d.ts +0 -45
  51. package/dist/components/tt-vtable/src/engine/visactor/toColumnDefinitions.js +0 -73
  52. package/dist/components/tt-vtable/src/engine/visactor/toListTableOptions.d.ts +0 -25
  53. package/dist/components/tt-vtable/src/engine/visactor/toListTableOptions.js +0 -25
  54. package/dist/components/tt-vtable/src/engine/visactor/types.d.ts +0 -29
  55. package/dist/components/tt-vtable/src/features/column-preferences/column-preference-storage.d.ts +0 -5
  56. package/dist/components/tt-vtable/src/features/column-preferences/column-preference-storage.js +0 -52
  57. package/dist/components/tt-vtable/src/features/column-preferences/useColumnPreferences.d.ts +0 -74
  58. package/dist/components/tt-vtable/src/features/column-preferences/useColumnPreferences.js +0 -232
  59. package/dist/components/tt-vtable/src/features/editing/useCellEditing.d.ts +0 -48
  60. package/dist/components/tt-vtable/src/features/editing/useCellEditing.js +0 -102
  61. package/dist/components/tt-vtable/src/features/form-integration/useVTableForm.d.ts +0 -51
  62. package/dist/components/tt-vtable/src/features/pagination/useTablePagination.d.ts +0 -40
  63. package/dist/components/tt-vtable/src/features/pagination/useTablePagination.js +0 -51
  64. package/dist/components/tt-vtable/src/features/querying/useRecordQuery.d.ts +0 -38
  65. package/dist/components/tt-vtable/src/features/querying/useRecordQuery.js +0 -57
  66. package/dist/components/tt-vtable/src/features/records/index.d.ts +0 -3
  67. package/dist/components/tt-vtable/src/features/records/record-index.d.ts +0 -122
  68. package/dist/components/tt-vtable/src/features/records/record-index.js +0 -209
  69. package/dist/components/tt-vtable/src/features/records/useRecordSource.d.ts +0 -41
  70. package/dist/components/tt-vtable/src/features/records/useRecordSource.js +0 -249
  71. package/dist/components/tt-vtable/src/features/selection/useRowSelection.d.ts +0 -65
  72. package/dist/components/tt-vtable/src/features/selection/useRowSelection.js +0 -129
  73. package/dist/components/tt-vtable/src/features/tree/useTreeRecords.d.ts +0 -60
  74. package/dist/components/tt-vtable/src/features/tree/useTreeRecords.js +0 -125
  75. package/dist/components/tt-vtable/src/public/column-preferences.d.ts +0 -32
  76. package/dist/components/tt-vtable/src/public/index.d.ts +0 -8
  77. package/dist/components/tt-vtable/src/public/table-api.d.ts +0 -215
  78. package/dist/components/tt-vtable/src/public/table-column.d.ts +0 -123
  79. package/dist/components/tt-vtable/src/public/table-errors.d.ts +0 -26
  80. package/dist/components/tt-vtable/src/public/table-errors.js +0 -26
  81. package/dist/components/tt-vtable/src/public/table-events.d.ts +0 -69
  82. package/dist/components/tt-vtable/src/public/table-props.d.ts +0 -216
  83. package/dist/components/tt-vtable/src/public/table-slots.d.ts +0 -37
  84. package/dist/components/tt-vtable/src/runtime/createVTableController.d.ts +0 -12
  85. package/dist/components/tt-vtable/src/runtime/createVTableController.js +0 -238
  86. package/dist/components/tt-vtable/src/runtime/createVTableRuntime.d.ts +0 -79
  87. package/dist/components/tt-vtable/src/runtime/createVTableRuntime.js +0 -380
@@ -1,41 +0,0 @@
1
- import { TtVTableMutationMode, TtVTableRecordChange, TtVTableRecordsApi, TtVTableRowKey, TtVTableRowKeySource } from '../../public';
2
- import { VisactorRecordIndex, VisactorTableEngine } from '../../engine/visactor';
3
- import { TtVTableRecordIndex } from './record-index';
4
- /** records feature 依赖。 */
5
- export interface UseRecordSourceOptions<Row extends Record<string, unknown>, Key extends TtVTableRowKey = TtVTableRowKey> {
6
- /** 初始本地或远程记录。 */
7
- records?: readonly Row[];
8
- /** 业务主键字段路径或读取函数。 */
9
- rowKey: TtVTableRowKeySource<Row, Key>;
10
- /** 子节点字段路径。 */
11
- childrenField?: string;
12
- /** 记录所有权策略。 */
13
- mutationMode?: TtVTableMutationMode;
14
- /** 稳定 VisActor 适配器。 */
15
- engine: VisactorTableEngine<Row>;
16
- /** 接收 API 或 renderer 产生的精确记录变化。 */
17
- onRecordChange?: (change: TtVTableRecordChange<Row, Key>) => void;
18
- /** 根记录替换后的协调回调。 */
19
- onRecordsReplaced?: (records: readonly Row[]) => void;
20
- }
21
- /** records feature 提供给 runtime 和其他 feature 的完整契约。 */
22
- export interface TtVTableRecordSource<Row extends Record<string, unknown>, Key extends TtVTableRowKey = TtVTableRowKey> extends TtVTableRecordsApi<Row, Key> {
23
- /** 当前 rowKey 索引。 */
24
- recordIndex: TtVTableRecordIndex<Row, Key>;
25
- /** 从记录读取并校验业务主键。 */
26
- getRowKey: (record: Row) => Key;
27
- /** 按主键读取原生源索引。 */
28
- getRecordIndex: (rowKey: Key) => VisactorRecordIndex | undefined;
29
- /** 为树 feature 写入 copy-on-write 子节点。 */
30
- setChildren: (parentKey: Key, children: readonly Row[]) => void;
31
- /** 原生实例 ready 后只同步最终记录快照。 */
32
- syncToEngine: () => void;
33
- /** 幂等释放 feature。 */
34
- release: () => void;
35
- }
36
- /**
37
- * 创建浅层运行时 records、rowKey 索引和增量更新动作。
38
- * @param options 初始记录、主键、所有权策略和 VisActor 适配器
39
- * @returns records feature
40
- */
41
- export declare function useRecordSource<Row extends Record<string, unknown>, Key extends TtVTableRowKey = TtVTableRowKey>(options: UseRecordSourceOptions<Row, Key>): TtVTableRecordSource<Row, Key>;
@@ -1,249 +0,0 @@
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
- };
@@ -1,65 +0,0 @@
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>;
@@ -1,129 +0,0 @@
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
- };
@@ -1,60 +0,0 @@
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>;
@@ -1,125 +0,0 @@
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
- };