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