@kong-ui-public/table-data-grid 0.9.0 → 0.9.1-pr.4063.f9e4f8cdb.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.
- package/dist/style.css +2 -1
- package/dist/table-data-grid.es.js +639 -719
- package/dist/table-data-grid.umd.js +1 -1
- package/package.json +3 -3
|
@@ -1,722 +1,642 @@
|
|
|
1
|
-
import { computed as
|
|
2
|
-
import { AgGridVue as
|
|
3
|
-
import {
|
|
4
|
-
import { createI18n as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { computed as e, createBlock as t, createCommentVNode as n, createElementBlock as r, createElementVNode as i, createVNode as a, defineComponent as o, h as s, nextTick as c, normalizeClass as l, normalizeStyle as u, onBeforeUnmount as d, onMounted as f, onUnmounted as p, openBlock as m, readonly as h, ref as g, renderSlot as _, resolveComponent as v, resolveDynamicComponent as y, shallowReadonly as b, shallowRef as x, toDisplayString as S, toRef as C, unref as w, useSlots as T, useTemplateRef as E, watch as D, withCtx as O } from "vue";
|
|
2
|
+
import { AgGridVue as k } from "ag-grid-vue3";
|
|
3
|
+
import { AllCommunityModule as A, ClientSideRowModelModule as j, InfiniteRowModelModule as M, ModuleRegistry as N, themeQuartz as P } from "ag-grid-community";
|
|
4
|
+
import { createI18n as F, i18nTComponent as I } from "@kong-ui-public/i18n";
|
|
5
|
+
// src/composables/useFetchState.ts
|
|
6
|
+
var L = /* @__PURE__ */ function(e) {
|
|
7
|
+
return e.PENDING = "PENDING", e.LOADING = "LOADING", e.SUCCESS = "SUCCESS", e.ERROR = "ERROR", e;
|
|
8
|
+
}({}), R = (e) => !!e?.length;
|
|
9
|
+
function ee(t, n, r, i = R) {
|
|
10
|
+
let a = e(() => i(t.value));
|
|
11
|
+
return {
|
|
12
|
+
fetchState: L,
|
|
13
|
+
hasData: a,
|
|
14
|
+
state: e(() => {
|
|
15
|
+
let e = t.value !== void 0, i = n.value !== void 0 && n.value !== null;
|
|
16
|
+
return r.value ? "LOADING" : a.value ? "SUCCESS" : i ? "ERROR" : e ? "SUCCESS" : "PENDING";
|
|
17
|
+
})
|
|
18
|
+
};
|
|
17
19
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}) !== "ready" || !S(d, z)) {
|
|
166
|
-
C.failCallback(), O(y, N);
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
I();
|
|
170
|
-
try {
|
|
171
|
-
const i = y > 0 ? l.get(y - 1) : void 0, _ = await c({
|
|
172
|
-
mode: "infinite",
|
|
173
|
-
pageSize: k,
|
|
174
|
-
cursor: i,
|
|
175
|
-
// Always read the latest sort, not a stale one.
|
|
176
|
-
sort: t?.value
|
|
177
|
-
});
|
|
178
|
-
if (!S(d, z)) {
|
|
179
|
-
C.failCallback(), O(y, N);
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
h({
|
|
183
|
-
blockIndex: y,
|
|
184
|
-
currentBlockCompletion: N,
|
|
185
|
-
getRowsParams: C,
|
|
186
|
-
pageSize: k,
|
|
187
|
-
result: _
|
|
188
|
-
});
|
|
189
|
-
} catch (i) {
|
|
190
|
-
if (!S(d, z)) {
|
|
191
|
-
C.failCallback(), O(y, N);
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
x({
|
|
195
|
-
blockIndex: y,
|
|
196
|
-
currentBlockCompletion: N,
|
|
197
|
-
fetchError: i,
|
|
198
|
-
getRowsParams: C
|
|
199
|
-
});
|
|
200
|
-
} finally {
|
|
201
|
-
S(d, z) && P();
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
}, W = () => {
|
|
206
|
-
u.value = G();
|
|
207
|
-
};
|
|
208
|
-
return A(
|
|
209
|
-
[e, () => a?.value],
|
|
210
|
-
() => {
|
|
211
|
-
W();
|
|
212
|
-
},
|
|
213
|
-
{ immediate: !0 }
|
|
214
|
-
), A(
|
|
215
|
-
[() => t?.value?.sortColumnKey, () => t?.value?.sortColumnOrder],
|
|
216
|
-
() => E()
|
|
217
|
-
), {
|
|
218
|
-
datasource: X(u),
|
|
219
|
-
data: pe(r),
|
|
220
|
-
error: X(f),
|
|
221
|
-
isFetching: X(w)
|
|
222
|
-
};
|
|
223
|
-
}, Ae = { title: "No Data", message: "There is no data to display." }, Ve = { title: "An error occurred", message: "Data cannot be displayed due to an error." }, $e = {
|
|
224
|
-
emptyState: Ae,
|
|
225
|
-
errorState: Ve
|
|
20
|
+
// src/composables/useEmitState.ts
|
|
21
|
+
var te = ({ emitState: e, fetchLifecycleState: t, hasData: n }) => {
|
|
22
|
+
D(() => ({
|
|
23
|
+
hasData: n.value,
|
|
24
|
+
state: t.value
|
|
25
|
+
}), ({ hasData: t, state: n }) => {
|
|
26
|
+
n !== L.PENDING && (n === L.LOADING ? e({
|
|
27
|
+
hasData: t,
|
|
28
|
+
state: "loading"
|
|
29
|
+
}) : n === L.ERROR ? e({
|
|
30
|
+
hasData: t,
|
|
31
|
+
state: "error"
|
|
32
|
+
}) : e({
|
|
33
|
+
hasData: t,
|
|
34
|
+
state: "success"
|
|
35
|
+
}));
|
|
36
|
+
});
|
|
37
|
+
}, z = ({ startRow: e, endRow: t }) => {
|
|
38
|
+
let n = t - e;
|
|
39
|
+
return {
|
|
40
|
+
blockIndex: n > 0 ? Math.floor(e / n) : 0,
|
|
41
|
+
pageSize: n
|
|
42
|
+
};
|
|
43
|
+
}, B = ({ startRow: e, rowsLength: t, pageSize: n, total: r, hasMore: i }) => {
|
|
44
|
+
if (typeof r == "number") return r;
|
|
45
|
+
if (i !== !0 && (i === !1 || t < n)) return e + t;
|
|
46
|
+
}, V = ({ fetcher: e, resetKey: t, sort: n }) => {
|
|
47
|
+
let r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = g(0), o = g(0), s = x(), c = x(), l = x(), u = g(0), d = g(!1), f, p, m = n?.value?.sortColumnKey, _ = n?.value?.sortColumnOrder, v = (n) => n === a.value && f === e.value && p === t?.value, y = (e, t) => v(e) && t === o.value && m === n?.value?.sortColumnKey && _ === n?.value?.sortColumnOrder, S = (e) => {
|
|
48
|
+
if (!n) return !0;
|
|
49
|
+
let t = n.value;
|
|
50
|
+
return !t?.sortColumnKey || !t.sortColumnOrder ? e.length === 0 : e.length === 1 && e[0].colId === t.sortColumnKey && e[0].sort === t.sortColumnOrder;
|
|
51
|
+
}, C = () => {
|
|
52
|
+
d.value = u.value > 0;
|
|
53
|
+
}, w = () => {
|
|
54
|
+
o.value += 1, m = n?.value?.sortColumnKey, _ = n?.value?.sortColumnOrder;
|
|
55
|
+
for (let e of i.values()) e.resolve(!1);
|
|
56
|
+
r.clear(), i.clear(), c.value = void 0, l.value = void 0, u.value = 0, C();
|
|
57
|
+
}, T = () => {
|
|
58
|
+
l.value = void 0, u.value += 1, C();
|
|
59
|
+
}, E = () => {
|
|
60
|
+
u.value = Math.max(0, u.value - 1), C();
|
|
61
|
+
}, O = (e) => {
|
|
62
|
+
let t = i.get(e);
|
|
63
|
+
if (t) return t;
|
|
64
|
+
let n, r = {
|
|
65
|
+
promise: new Promise((e) => {
|
|
66
|
+
n = e;
|
|
67
|
+
}),
|
|
68
|
+
resolve: (e) => n(e)
|
|
69
|
+
};
|
|
70
|
+
return i.set(e, r), r;
|
|
71
|
+
}, k = (e, t) => {
|
|
72
|
+
t.resolve(!1), i.get(e) === t && i.delete(e);
|
|
73
|
+
}, A = async ({ blockIndex: e, currentBlockCompletion: t, datasourceId: n, requestGeneration: r }) => {
|
|
74
|
+
if (e === 0) return "ready";
|
|
75
|
+
let a = i.get(e - 1);
|
|
76
|
+
if (!a) return k(e, t), "failed";
|
|
77
|
+
let o = await a.promise;
|
|
78
|
+
return y(n, r) ? o ? "ready" : (k(e, t), "failed") : (k(e, t), "stale");
|
|
79
|
+
}, j = ({ blockIndex: e, currentBlockCompletion: t, getRowsParams: n, pageSize: i, result: a }) => {
|
|
80
|
+
a.cursor !== void 0 && r.set(e, a.cursor), n.successCallback(a.data, B({
|
|
81
|
+
startRow: n.startRow,
|
|
82
|
+
rowsLength: a.data.length,
|
|
83
|
+
pageSize: i,
|
|
84
|
+
total: a.total,
|
|
85
|
+
hasMore: a.hasMore
|
|
86
|
+
})), n.startRow === 0 && (c.value = a.data), t.resolve(!0);
|
|
87
|
+
}, M = ({ blockIndex: e, currentBlockCompletion: t, fetchError: n, getRowsParams: r }) => {
|
|
88
|
+
l.value = n, r.failCallback(), k(e, t);
|
|
89
|
+
}, N = () => {
|
|
90
|
+
let s = e.value;
|
|
91
|
+
if (!s) throw Error("TableDataGrid requires a fetcher in infinite mode");
|
|
92
|
+
f = s, p = t?.value;
|
|
93
|
+
let c = a.value + 1;
|
|
94
|
+
return a.value = c, w(), { async getRows(e) {
|
|
95
|
+
if (!v(c) || !S(e.sortModel)) {
|
|
96
|
+
e.failCallback();
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
let { blockIndex: t, pageSize: a } = z({
|
|
100
|
+
startRow: e.startRow,
|
|
101
|
+
endRow: e.endRow
|
|
102
|
+
});
|
|
103
|
+
t === 0 && i.has(0) && w();
|
|
104
|
+
let l = o.value, u = O(t);
|
|
105
|
+
if (await A({
|
|
106
|
+
blockIndex: t,
|
|
107
|
+
currentBlockCompletion: u,
|
|
108
|
+
datasourceId: c,
|
|
109
|
+
requestGeneration: l
|
|
110
|
+
}) !== "ready" || !y(c, l)) e.failCallback(), k(t, u);
|
|
111
|
+
else {
|
|
112
|
+
T();
|
|
113
|
+
try {
|
|
114
|
+
let i = t > 0 ? r.get(t - 1) : void 0, o = await s({
|
|
115
|
+
mode: "infinite",
|
|
116
|
+
pageSize: a,
|
|
117
|
+
cursor: i,
|
|
118
|
+
sort: n?.value
|
|
119
|
+
});
|
|
120
|
+
if (!y(c, l)) {
|
|
121
|
+
e.failCallback(), k(t, u);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
j({
|
|
125
|
+
blockIndex: t,
|
|
126
|
+
currentBlockCompletion: u,
|
|
127
|
+
getRowsParams: e,
|
|
128
|
+
pageSize: a,
|
|
129
|
+
result: o
|
|
130
|
+
});
|
|
131
|
+
} catch (n) {
|
|
132
|
+
if (!y(c, l)) {
|
|
133
|
+
e.failCallback(), k(t, u);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
M({
|
|
137
|
+
blockIndex: t,
|
|
138
|
+
currentBlockCompletion: u,
|
|
139
|
+
fetchError: n,
|
|
140
|
+
getRowsParams: e
|
|
141
|
+
});
|
|
142
|
+
} finally {
|
|
143
|
+
y(c, l) && E();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
} };
|
|
147
|
+
}, P = () => {
|
|
148
|
+
s.value = N();
|
|
149
|
+
};
|
|
150
|
+
return D([e, () => t?.value], () => {
|
|
151
|
+
P();
|
|
152
|
+
}, { immediate: !0 }), D([() => n?.value?.sortColumnKey, () => n?.value?.sortColumnOrder], () => w()), {
|
|
153
|
+
datasource: h(s),
|
|
154
|
+
data: b(c),
|
|
155
|
+
error: h(l),
|
|
156
|
+
isFetching: h(d)
|
|
157
|
+
};
|
|
158
|
+
}, H = {
|
|
159
|
+
emptyState: {
|
|
160
|
+
title: "No Data",
|
|
161
|
+
message: "There is no data to display."
|
|
162
|
+
},
|
|
163
|
+
errorState: {
|
|
164
|
+
title: "An error occurred",
|
|
165
|
+
message: "Data cannot be displayed due to an error."
|
|
166
|
+
}
|
|
226
167
|
};
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
168
|
+
// src/composables/useI18n.ts
|
|
169
|
+
function U() {
|
|
170
|
+
let e = F("en-us", H);
|
|
171
|
+
return {
|
|
172
|
+
i18n: e,
|
|
173
|
+
i18nT: I(e)
|
|
174
|
+
};
|
|
234
175
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
},
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
},
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
"suppress-multi-sort": !0,
|
|
703
|
-
theme: D($),
|
|
704
|
-
onBodyScroll: N,
|
|
705
|
-
onCellClicked: D(T),
|
|
706
|
-
onGridReady: oe,
|
|
707
|
-
onNewColumnsLoaded: k,
|
|
708
|
-
onRowClicked: D(E),
|
|
709
|
-
onSortChanged: D(s)
|
|
710
|
-
}, null, 8, ["cache-block-size", "column-defs", "context", "datasource", "dom-layout", "infinite-initial-row-count", "loading", "row-data", "row-model-type", "theme", "onCellClicked", "onRowClicked", "onSortChanged"]))
|
|
711
|
-
], 2);
|
|
712
|
-
};
|
|
713
|
-
}
|
|
714
|
-
}), ct = (e, a) => {
|
|
715
|
-
const t = e.__vccOpts || e;
|
|
716
|
-
for (const [l, o] of a)
|
|
717
|
-
t[l] = o;
|
|
718
|
-
return t;
|
|
719
|
-
}, Ct = /* @__PURE__ */ ct(ut, [["__scopeId", "data-v-82e410f3"]]);
|
|
720
|
-
export {
|
|
721
|
-
Ct as TableDataGrid
|
|
722
|
-
};
|
|
176
|
+
// src/utils/tableDataGridPresentation.ts
|
|
177
|
+
var { i18n: W } = U(), G = (e, t) => {
|
|
178
|
+
let n = Reflect.get(t, e.key);
|
|
179
|
+
return e.valueFormatter ? e.valueFormatter(n, t) : String(n ?? "");
|
|
180
|
+
}, K = (e) => typeof e == "number" && Number.isFinite(e) ? e : null, ne = (e, t) => e.reduce((e, n) => {
|
|
181
|
+
let r = K(Reflect.get(n, t.key));
|
|
182
|
+
return r === null ? e : {
|
|
183
|
+
sum: e.sum + r,
|
|
184
|
+
max: Math.max(e.max, r)
|
|
185
|
+
};
|
|
186
|
+
}, {
|
|
187
|
+
sum: 0,
|
|
188
|
+
max: 0
|
|
189
|
+
}), q = (e, t) => {
|
|
190
|
+
let n = (t ?? []).filter((t) => Number.isFinite(t.value) && e >= t.value);
|
|
191
|
+
if (!n.length) return;
|
|
192
|
+
let r = Math.max(...n.map((e) => e.value));
|
|
193
|
+
return n.filter((e) => e.value === r).some((e) => e.type === "error") ? "error" : "warning";
|
|
194
|
+
}, re = (e, t, n) => {
|
|
195
|
+
if (e === null) return 0;
|
|
196
|
+
let r = n === "relative" ? t.sum : t.max;
|
|
197
|
+
return r > 0 ? Math.min(Math.max(e / r, 0), 1) : 0;
|
|
198
|
+
}, ie = (e) => {
|
|
199
|
+
let t = (e) => W.formatNumber(e, { maximumFractionDigits: 2 });
|
|
200
|
+
return e > 0 && e < .01 ? `< ${t(.01)} %` : `${t(e)} %`;
|
|
201
|
+
}, J = ({ value: e, stats: t, header: n }) => {
|
|
202
|
+
if (e === null || t.sum <= 0) return;
|
|
203
|
+
let r = e / t.sum * 100;
|
|
204
|
+
return n.percentageFormatter?.(r) ?? ie(r);
|
|
205
|
+
}, Y = (e, t) => t !== void 0 && t.length > (e?.length ?? -1) ? t : e, ae = ({ rows: e, header: t, stats: n }) => e.reduce((e, r) => ({
|
|
206
|
+
value: Y(e.value, G(t, r)) ?? "",
|
|
207
|
+
relative: t.showPercentage ? Y(e.relative, J({
|
|
208
|
+
value: K(Reflect.get(r, t.key)),
|
|
209
|
+
stats: n,
|
|
210
|
+
header: t
|
|
211
|
+
})) : void 0
|
|
212
|
+
}), { value: "" }), oe = ["data-threshold"], se = { class: "table-data-grid-cell-label-track" }, X = { class: "table-data-grid-cell-label" }, Z = {
|
|
213
|
+
key: 0,
|
|
214
|
+
class: "table-data-grid-cell-relative",
|
|
215
|
+
"data-testid": "table-data-grid-cell-relative"
|
|
216
|
+
}, ce = {
|
|
217
|
+
key: 0,
|
|
218
|
+
"aria-hidden": "true",
|
|
219
|
+
class: "table-data-grid-cell-label table-data-grid-cell-label-sizer"
|
|
220
|
+
}, Q = ["data-text"], $ = ["data-text"], le = ["data-threshold"], ue = /* @__PURE__ */ o({
|
|
221
|
+
name: "TableDataGridCellRenderer",
|
|
222
|
+
__name: "TableDataGridCellRenderer",
|
|
223
|
+
props: { params: {} },
|
|
224
|
+
setup(o, { expose: d }) {
|
|
225
|
+
let h = x(o.params), b = g(null), C = g(!1), w = e(() => h.value.headerDef ?? {
|
|
226
|
+
key: "",
|
|
227
|
+
label: ""
|
|
228
|
+
}), T = e(() => h.value.context?.presentation), E = e(() => h.value.context?.cells?.tooltipTarget?.value ?? "body"), k = e(() => h.value.valueFormatted ?? String(h.value.value ?? "")), A = e(() => h.value.value), j = e(() => K(A.value)), M = e(() => T.value?.stats[w.value.key]), N = e(() => w.value.showPercentage && M.value ? J({
|
|
229
|
+
value: j.value,
|
|
230
|
+
stats: M.value,
|
|
231
|
+
header: w.value
|
|
232
|
+
}) : void 0), P = e(() => !!w.value.bar && !!M.value && (j.value !== null || A.value === null || A.value === void 0)), F = e(() => P.value && M.value ? re(j.value, M.value, w.value.bar) * 100 : 0), I = e(() => P.value ? T.value?.labelSizers[w.value.key] : void 0), L = e(() => w.value.thresholds?.length && j.value !== null ? q(j.value, w.value.thresholds) : void 0), R = e(() => ({
|
|
233
|
+
column: w.value,
|
|
234
|
+
refreshCell: () => {
|
|
235
|
+
let e = h.value.node;
|
|
236
|
+
e && h.value.api.refreshCells({
|
|
237
|
+
force: !0,
|
|
238
|
+
rowNodes: [e]
|
|
239
|
+
});
|
|
240
|
+
},
|
|
241
|
+
row: h.value.data ?? {},
|
|
242
|
+
rowIndex: h.value.node?.rowIndex ?? 0,
|
|
243
|
+
rowValue: h.value.value,
|
|
244
|
+
selected: h.value.node?.isSelected() ?? !1
|
|
245
|
+
})), ee = (e, { slots: t }) => {
|
|
246
|
+
let n = h.value.colDef?.colId, r = h.value.context?.cells?.slots;
|
|
247
|
+
return !n || n === "cell-icon" || !r?.[n] ? t.default?.() : s("span", { class: "table-data-grid-cell-slot-content" }, _(r, n, R.value, () => t.default?.() ?? []));
|
|
248
|
+
}, te = () => {
|
|
249
|
+
let e = h.value.context?.cells?.slots;
|
|
250
|
+
return e?.["cell-icon"] ? _(e, "cell-icon", R.value) : null;
|
|
251
|
+
}, z, B, V = !1, H = () => {
|
|
252
|
+
let e = b.value;
|
|
253
|
+
C.value = !!e && e.scrollWidth > e.clientWidth;
|
|
254
|
+
}, U = () => {
|
|
255
|
+
V || (B !== void 0 && cancelAnimationFrame(B), B = requestAnimationFrame(() => {
|
|
256
|
+
B = void 0, H();
|
|
257
|
+
}));
|
|
258
|
+
}, W = (e) => {
|
|
259
|
+
if (z?.disconnect(), e) {
|
|
260
|
+
z?.observe(e);
|
|
261
|
+
let t = e.closest(".ag-cell");
|
|
262
|
+
t && z?.observe(t);
|
|
263
|
+
}
|
|
264
|
+
U();
|
|
265
|
+
};
|
|
266
|
+
return f(() => {
|
|
267
|
+
z = new ResizeObserver(U), W(b.value);
|
|
268
|
+
}), D(b, W), p(() => {
|
|
269
|
+
V = !0, z?.disconnect(), B !== void 0 && cancelAnimationFrame(B);
|
|
270
|
+
}), d({ refresh(e) {
|
|
271
|
+
return h.value = e, c(U), !0;
|
|
272
|
+
} }), (e, o) => {
|
|
273
|
+
let s = v("KTooltip");
|
|
274
|
+
return m(), r("span", {
|
|
275
|
+
class: l(["table-data-grid-cell-renderer", {
|
|
276
|
+
"table-data-grid-cell-renderer--bar": P.value,
|
|
277
|
+
"table-data-grid-cell-renderer--percentage": !!N.value,
|
|
278
|
+
[`table-data-grid-cell-renderer--text-${L.value}`]: !P.value && !!L.value
|
|
279
|
+
}]),
|
|
280
|
+
"data-threshold": L.value
|
|
281
|
+
}, [i("span", se, [i("span", X, [
|
|
282
|
+
(m(), t(y(te))),
|
|
283
|
+
(m(), t(y(ee), null, {
|
|
284
|
+
default: O(() => [a(s, {
|
|
285
|
+
class: "table-data-grid-cell-tooltip",
|
|
286
|
+
disabled: !C.value,
|
|
287
|
+
"kpop-attributes": { popoverDelay: 400 },
|
|
288
|
+
"max-width": "300",
|
|
289
|
+
placement: "bottom-start",
|
|
290
|
+
target: E.value,
|
|
291
|
+
text: k.value
|
|
292
|
+
}, {
|
|
293
|
+
default: O(() => [i("span", {
|
|
294
|
+
ref_key: "contentElement",
|
|
295
|
+
ref: b,
|
|
296
|
+
class: "table-data-grid-cell-content"
|
|
297
|
+
}, S(k.value), 513)]),
|
|
298
|
+
_: 1
|
|
299
|
+
}, 8, [
|
|
300
|
+
"disabled",
|
|
301
|
+
"target",
|
|
302
|
+
"text"
|
|
303
|
+
])]),
|
|
304
|
+
_: 1
|
|
305
|
+
})),
|
|
306
|
+
N.value ? (m(), r("span", Z, "(" + S(N.value) + ")", 1)) : n("", !0)
|
|
307
|
+
]), I.value ? (m(), r("span", ce, [i("span", {
|
|
308
|
+
class: "table-data-grid-cell-sizer-value",
|
|
309
|
+
"data-text": I.value.value
|
|
310
|
+
}, null, 8, Q), I.value.relative ? (m(), r("span", {
|
|
311
|
+
key: 0,
|
|
312
|
+
class: "table-data-grid-cell-sizer-relative",
|
|
313
|
+
"data-text": `(${I.value.relative})`
|
|
314
|
+
}, null, 8, $)) : n("", !0)])) : n("", !0)]), P.value ? (m(), r("span", {
|
|
315
|
+
key: 0,
|
|
316
|
+
class: "table-data-grid-cell-bar",
|
|
317
|
+
"data-testid": "table-data-grid-cell-bar",
|
|
318
|
+
"data-threshold": L.value
|
|
319
|
+
}, [i("span", {
|
|
320
|
+
class: "table-data-grid-cell-bar-fill",
|
|
321
|
+
"data-testid": "table-data-grid-cell-bar-fill",
|
|
322
|
+
style: u({ width: `${F.value}%` })
|
|
323
|
+
}, null, 4)], 8, le)) : n("", !0)], 10, oe);
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
}), de = ({ headers: t, slots: n, initialSort: r, mode: i, rows: a, tooltipTarget: o }) => {
|
|
327
|
+
let s = i ?? "infinite", c = /* @__PURE__ */ new Set(), l = (e) => !!(e.showPercentage || e.bar || e.thresholds?.length);
|
|
328
|
+
D([t, () => a?.value], () => {
|
|
329
|
+
t.value.forEach((e) => {
|
|
330
|
+
if (!l(e)) return;
|
|
331
|
+
let t;
|
|
332
|
+
if (s === "infinite" && (e.showPercentage || e.bar) ? t = "percentage and bar presentation is only supported in unpaginated mode" : s === "unpaginated" && a?.value?.some((t) => {
|
|
333
|
+
let n = Reflect.get(t, e.key);
|
|
334
|
+
return n != null && K(n) === null;
|
|
335
|
+
}) && (t = "contains non-finite or nonnumeric values; numeric presentation skips those values"), !t) return;
|
|
336
|
+
let n = `${e.key}:${t}`;
|
|
337
|
+
c.has(n) || (c.add(n), console.warn(`[TableDataGrid] Column "${e.key}" ${t}.`));
|
|
338
|
+
});
|
|
339
|
+
}, { immediate: !0 });
|
|
340
|
+
let u = e(() => {
|
|
341
|
+
if (s !== "unpaginated") return {};
|
|
342
|
+
let e = a?.value ?? [];
|
|
343
|
+
return Object.fromEntries(t.value.filter((e) => e.showPercentage || e.bar).map((t) => [t.key, ne(e, t)]));
|
|
344
|
+
}), d = e(() => {
|
|
345
|
+
if (s !== "unpaginated") return {};
|
|
346
|
+
let e = a?.value ?? [];
|
|
347
|
+
return Object.fromEntries(t.value.filter((e) => e.bar).map((t) => [t.key, ae({
|
|
348
|
+
rows: e,
|
|
349
|
+
header: t,
|
|
350
|
+
stats: u.value[t.key]
|
|
351
|
+
})]));
|
|
352
|
+
}), f = e(() => ({
|
|
353
|
+
cells: {
|
|
354
|
+
slots: n,
|
|
355
|
+
tooltipTarget: o
|
|
356
|
+
},
|
|
357
|
+
presentation: {
|
|
358
|
+
stats: u.value,
|
|
359
|
+
labelSizers: d.value
|
|
360
|
+
}
|
|
361
|
+
})), p = (e) => {
|
|
362
|
+
let t = r?.sortColumnKey === e.key;
|
|
363
|
+
return {
|
|
364
|
+
colId: e.key,
|
|
365
|
+
flex: !e.width && !e.maxWidth ? 1 : void 0,
|
|
366
|
+
headerName: e.label,
|
|
367
|
+
maxWidth: e.maxWidth,
|
|
368
|
+
minWidth: e.minWidth,
|
|
369
|
+
sortable: e.sortable ?? !1,
|
|
370
|
+
unSortIcon: e.showSortIcon,
|
|
371
|
+
...t ? {
|
|
372
|
+
initialSort: r?.sortColumnOrder,
|
|
373
|
+
initialSortIndex: 0
|
|
374
|
+
} : {},
|
|
375
|
+
valueGetter: (t) => t.data?.[e.key],
|
|
376
|
+
valueFormatter: (t) => t.data ? G(e, t.data) : String(t.value ?? ""),
|
|
377
|
+
width: e.width,
|
|
378
|
+
cellRenderer: ue,
|
|
379
|
+
cellRendererParams: { headerDef: e }
|
|
380
|
+
};
|
|
381
|
+
};
|
|
382
|
+
return {
|
|
383
|
+
columnDefs: e(() => t.value.map(p)),
|
|
384
|
+
gridContext: f
|
|
385
|
+
};
|
|
386
|
+
}, fe = ({ config: e, headers: t, pageSize: n }) => {
|
|
387
|
+
let r = new Set(t.filter((e) => e.sortable).map((e) => e.key)), i = e?.sortColumnKey && r.has(e.sortColumnKey) ? e.sortColumnKey : void 0;
|
|
388
|
+
return {
|
|
389
|
+
sortColumnKey: i,
|
|
390
|
+
sortColumnOrder: i ? e?.sortColumnOrder : void 0,
|
|
391
|
+
pageSize: e?.pageSize ?? n,
|
|
392
|
+
...e?.fitToContent === void 0 ? {} : { fitToContent: e.fitToContent }
|
|
393
|
+
};
|
|
394
|
+
}, pe = (e, t) => e.sortColumnKey === t.sortColumnKey && e.sortColumnOrder === t.sortColumnOrder && e.pageSize === t.pageSize && e.fitToContent === t.fitToContent, me = ({ headers: t, pageSize: n, tableConfig: r, emitSort: i, emitTableConfigUpdate: a, onExternalConfigChange: o }) => {
|
|
395
|
+
let s = e(() => r.value ? fe({
|
|
396
|
+
config: r.value,
|
|
397
|
+
headers: t.value,
|
|
398
|
+
pageSize: n.value
|
|
399
|
+
}) : void 0), c = g(s.value ?? fe({
|
|
400
|
+
config: void 0,
|
|
401
|
+
headers: t.value,
|
|
402
|
+
pageSize: n.value
|
|
403
|
+
}));
|
|
404
|
+
D(s, (e) => {
|
|
405
|
+
e && !pe(e, c.value) && (c.value = e, o?.(e));
|
|
406
|
+
});
|
|
407
|
+
let l = (e) => {
|
|
408
|
+
let r = fe({
|
|
409
|
+
config: {
|
|
410
|
+
...c.value,
|
|
411
|
+
...e
|
|
412
|
+
},
|
|
413
|
+
headers: t.value,
|
|
414
|
+
pageSize: n.value
|
|
415
|
+
});
|
|
416
|
+
pe(r, c.value) || ((r.sortColumnKey !== c.value.sortColumnKey || r.sortColumnOrder !== c.value.sortColumnOrder) && i({
|
|
417
|
+
sortColumnKey: r.sortColumnKey,
|
|
418
|
+
sortColumnOrder: r.sortColumnOrder
|
|
419
|
+
}), c.value = r, a(r));
|
|
420
|
+
};
|
|
421
|
+
D(t, () => {
|
|
422
|
+
r.value || l({});
|
|
423
|
+
}, { deep: !0 });
|
|
424
|
+
let u = e(() => ({
|
|
425
|
+
sortColumnKey: c.value.sortColumnKey,
|
|
426
|
+
sortColumnOrder: c.value.sortColumnOrder
|
|
427
|
+
})), d = e(() => r.value?.pageSize ?? n.value);
|
|
428
|
+
return {
|
|
429
|
+
activeTableConfig: h(c),
|
|
430
|
+
activeSort: u,
|
|
431
|
+
activePageSize: d,
|
|
432
|
+
patchTableConfig: l
|
|
433
|
+
};
|
|
434
|
+
}, he = ({ cellClick: t, headers: n, rowClick: r }) => {
|
|
435
|
+
let i = e(() => new Set(n.value.filter((e) => e.disableRowClick).map((e) => e.key))), a = (e) => {
|
|
436
|
+
let t = e.event?.target;
|
|
437
|
+
return t instanceof Element ? t.closest(".ag-cell")?.getAttribute("col-id") ?? void 0 : void 0;
|
|
438
|
+
}, o = (e) => {
|
|
439
|
+
let t = a(e);
|
|
440
|
+
return !!(t && i.value.has(t));
|
|
441
|
+
};
|
|
442
|
+
return {
|
|
443
|
+
onCellClick: (e) => {
|
|
444
|
+
let n = e.colDef.colId;
|
|
445
|
+
e.data && n && t({
|
|
446
|
+
columnKey: n,
|
|
447
|
+
row: e.data,
|
|
448
|
+
value: e.value
|
|
449
|
+
});
|
|
450
|
+
},
|
|
451
|
+
onRowClick: (e) => {
|
|
452
|
+
e.data && !o(e) && r(e.data, e);
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
}, ge = ({ activeSort: e, patchTableConfig: t }) => {
|
|
456
|
+
let n = (e, t) => {
|
|
457
|
+
e.applyColumnState({
|
|
458
|
+
state: t.sortColumnKey ? [{
|
|
459
|
+
colId: t.sortColumnKey,
|
|
460
|
+
sort: t.sortColumnOrder ?? null,
|
|
461
|
+
sortIndex: 0
|
|
462
|
+
}] : [],
|
|
463
|
+
defaultState: {
|
|
464
|
+
sort: null,
|
|
465
|
+
sortIndex: null
|
|
466
|
+
}
|
|
467
|
+
});
|
|
468
|
+
};
|
|
469
|
+
return {
|
|
470
|
+
onSortChanged: (r) => {
|
|
471
|
+
let i = r.api.getColumnState().filter((e) => e.sort).sort((e, t) => (e.sortIndex ?? 0) - (t.sortIndex ?? 0)), a = i[i.length - 1], o = a ? {
|
|
472
|
+
sortColumnKey: a.colId,
|
|
473
|
+
sortColumnOrder: a.sort
|
|
474
|
+
} : {
|
|
475
|
+
sortColumnKey: void 0,
|
|
476
|
+
sortColumnOrder: void 0
|
|
477
|
+
};
|
|
478
|
+
(o.sortColumnKey !== e.value.sortColumnKey || o.sortColumnOrder !== e.value.sortColumnOrder) && t(o), i.length > 1 && n(r.api, o);
|
|
479
|
+
},
|
|
480
|
+
applySortToGrid: n
|
|
481
|
+
};
|
|
482
|
+
}, _e = {
|
|
483
|
+
key: 0,
|
|
484
|
+
class: "table-error-state",
|
|
485
|
+
"data-testid": "table-error-state"
|
|
486
|
+
}, ve = {
|
|
487
|
+
key: 1,
|
|
488
|
+
class: "table-empty-state",
|
|
489
|
+
"data-testid": "table-empty-state"
|
|
490
|
+
}, ye = /*#__PURE__*/ ((e, t) => {
|
|
491
|
+
let n = e.__vccOpts || e;
|
|
492
|
+
for (let [e, r] of t) n[e] = r;
|
|
493
|
+
return n;
|
|
494
|
+
})(/* @__PURE__ */ o({
|
|
495
|
+
__name: "TableDataGrid",
|
|
496
|
+
props: {
|
|
497
|
+
headers: {},
|
|
498
|
+
error: {
|
|
499
|
+
type: Boolean,
|
|
500
|
+
default: !1
|
|
501
|
+
},
|
|
502
|
+
tableConfig: {},
|
|
503
|
+
fetcher: { type: Function },
|
|
504
|
+
mode: {},
|
|
505
|
+
pageSize: { default: 25 },
|
|
506
|
+
refreshKey: { type: [
|
|
507
|
+
String,
|
|
508
|
+
Number,
|
|
509
|
+
Boolean
|
|
510
|
+
] },
|
|
511
|
+
rows: {}
|
|
512
|
+
},
|
|
513
|
+
emits: [
|
|
514
|
+
"grid:ready",
|
|
515
|
+
"state",
|
|
516
|
+
"row:click",
|
|
517
|
+
"cell:click",
|
|
518
|
+
"sort",
|
|
519
|
+
"update:tableConfig"
|
|
520
|
+
],
|
|
521
|
+
setup(n, { emit: i }) {
|
|
522
|
+
N.registerModules([
|
|
523
|
+
A,
|
|
524
|
+
j,
|
|
525
|
+
M
|
|
526
|
+
]);
|
|
527
|
+
let o = n.mode ?? "infinite", s = i, { i18n: c } = U(), { t: u } = c, p = T(), h = x(), y = E("rootElement"), b = x("body"), S = () => {
|
|
528
|
+
let e = document.fullscreenElement;
|
|
529
|
+
b.value = e instanceof HTMLElement && e.contains(y.value ?? null) ? e : "body";
|
|
530
|
+
};
|
|
531
|
+
f(() => {
|
|
532
|
+
S(), document.addEventListener("fullscreenchange", S);
|
|
533
|
+
}), d(() => {
|
|
534
|
+
document.removeEventListener("fullscreenchange", S);
|
|
535
|
+
});
|
|
536
|
+
let { activeTableConfig: O, activeSort: F, activePageSize: I, patchTableConfig: L } = me({
|
|
537
|
+
headers: C(() => n.headers),
|
|
538
|
+
pageSize: C(() => n.pageSize),
|
|
539
|
+
tableConfig: C(() => n.tableConfig),
|
|
540
|
+
emitSort: (e) => s("sort", e),
|
|
541
|
+
emitTableConfigUpdate: (e) => s("update:tableConfig", e),
|
|
542
|
+
onExternalConfigChange: (e) => {
|
|
543
|
+
h.value && z(h.value, e);
|
|
544
|
+
}
|
|
545
|
+
}), { onSortChanged: R, applySortToGrid: z } = ge({
|
|
546
|
+
activeSort: F,
|
|
547
|
+
patchTableConfig: L
|
|
548
|
+
}), B = e(() => o === "unpaginated" && !!O.value.fitToContent), H = P.withParams({ autoHeightMinBodyHeight: 0 }), { onCellClick: W, onRowClick: G } = he({
|
|
549
|
+
cellClick: (e) => s("cell:click", e),
|
|
550
|
+
headers: C(() => n.headers),
|
|
551
|
+
rowClick: (e, t) => s("row:click", e, t)
|
|
552
|
+
}), K = {
|
|
553
|
+
resizable: !1,
|
|
554
|
+
sortable: !1,
|
|
555
|
+
suppressMovable: !0
|
|
556
|
+
}, ne = e(() => [I.value, n.refreshKey]), q = o === "infinite" ? V({
|
|
557
|
+
fetcher: C(() => n.fetcher),
|
|
558
|
+
resetKey: ne,
|
|
559
|
+
sort: F
|
|
560
|
+
}) : void 0, re = q?.datasource, ie = e(() => q ? q.data.value : n.rows), J = e(() => q?.isFetching.value ?? !1), Y = e(() => n.rows ? Array.from(n.rows) : void 0), { columnDefs: ae, gridContext: oe } = de({
|
|
561
|
+
headers: C(() => n.headers),
|
|
562
|
+
mode: o,
|
|
563
|
+
rows: Y,
|
|
564
|
+
slots: p,
|
|
565
|
+
tooltipTarget: b,
|
|
566
|
+
initialSort: F.value
|
|
567
|
+
}), { fetchState: se, hasData: X, state: Z } = ee(ie, C(() => q?.error.value), J), ce = e(() => Z.value === se.SUCCESS && !X.value);
|
|
568
|
+
q && te({
|
|
569
|
+
emitState: (e) => s("state", e),
|
|
570
|
+
fetchLifecycleState: Z,
|
|
571
|
+
hasData: X
|
|
572
|
+
});
|
|
573
|
+
let Q = () => {
|
|
574
|
+
let e = h.value;
|
|
575
|
+
if (!e || e.isDestroyed()) return;
|
|
576
|
+
let t = F.value, n = e.getColumnState().find((e) => e.sort);
|
|
577
|
+
(n?.colId !== t.sortColumnKey || (n?.sort ?? void 0) !== t.sortColumnOrder) && z(e, t);
|
|
578
|
+
};
|
|
579
|
+
D([h, F], Q);
|
|
580
|
+
let $ = g(!1), le = (e) => {
|
|
581
|
+
e.direction === "vertical" && ($.value = e.top > 0);
|
|
582
|
+
}, ue = (e) => {
|
|
583
|
+
h.value = e.api, s("grid:ready", e.api);
|
|
584
|
+
};
|
|
585
|
+
return (e, i) => {
|
|
586
|
+
let s = v("KEmptyState");
|
|
587
|
+
return m(), r("div", {
|
|
588
|
+
ref_key: "rootElement",
|
|
589
|
+
ref: y,
|
|
590
|
+
class: l(["kong-ui-public-table-data-grid", {
|
|
591
|
+
"fit-to-content": B.value,
|
|
592
|
+
"is-scrolled": $.value
|
|
593
|
+
}]),
|
|
594
|
+
"data-testid": "table-data-grid"
|
|
595
|
+
}, [n.error ? (m(), r("div", _e, [_(e.$slots, "error-state", {}, () => [a(s, {
|
|
596
|
+
"icon-variant": "error",
|
|
597
|
+
message: w(u)("errorState.message"),
|
|
598
|
+
title: w(u)("errorState.title")
|
|
599
|
+
}, null, 8, ["message", "title"])], !0)])) : ce.value ? (m(), r("div", ve, [_(e.$slots, "empty-state", {}, () => [a(s, {
|
|
600
|
+
message: w(u)("emptyState.message"),
|
|
601
|
+
title: w(u)("emptyState.title")
|
|
602
|
+
}, null, 8, ["message", "title"])], !0)])) : (m(), t(w(k), {
|
|
603
|
+
key: 2,
|
|
604
|
+
"cache-block-size": w(o) === "infinite" ? w(I) : void 0,
|
|
605
|
+
class: "table-data-grid-grid",
|
|
606
|
+
"column-defs": w(ae),
|
|
607
|
+
context: w(oe),
|
|
608
|
+
datasource: w(o) === "infinite" ? w(re) : void 0,
|
|
609
|
+
"default-col-def": K,
|
|
610
|
+
"dom-layout": B.value ? "autoHeight" : "normal",
|
|
611
|
+
"infinite-initial-row-count": w(o) === "infinite" ? 1 : void 0,
|
|
612
|
+
loading: J.value,
|
|
613
|
+
"row-data": w(o) === "unpaginated" ? Y.value : void 0,
|
|
614
|
+
"row-model-type": w(o) === "unpaginated" ? "clientSide" : "infinite",
|
|
615
|
+
"suppress-cell-focus": !0,
|
|
616
|
+
"suppress-multi-sort": !0,
|
|
617
|
+
theme: w(H),
|
|
618
|
+
onBodyScroll: le,
|
|
619
|
+
onCellClicked: w(W),
|
|
620
|
+
onGridReady: ue,
|
|
621
|
+
onNewColumnsLoaded: Q,
|
|
622
|
+
onRowClicked: w(G),
|
|
623
|
+
onSortChanged: w(R)
|
|
624
|
+
}, null, 8, [
|
|
625
|
+
"cache-block-size",
|
|
626
|
+
"column-defs",
|
|
627
|
+
"context",
|
|
628
|
+
"datasource",
|
|
629
|
+
"dom-layout",
|
|
630
|
+
"infinite-initial-row-count",
|
|
631
|
+
"loading",
|
|
632
|
+
"row-data",
|
|
633
|
+
"row-model-type",
|
|
634
|
+
"theme",
|
|
635
|
+
"onCellClicked",
|
|
636
|
+
"onRowClicked",
|
|
637
|
+
"onSortChanged"
|
|
638
|
+
]))], 2);
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
}), [["__scopeId", "data-v-82e410f3"]]);
|
|
642
|
+
export { ye as TableDataGrid };
|