@kong-ui-public/table-data-grid 0.3.4-pr.3596.41e70338d.0 → 0.3.4-pr.3598.efa3e41fa.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 +1 -1
- package/dist/table-data-grid.es.js +245 -188
- package/dist/table-data-grid.umd.js +1 -1
- package/dist/types/components/TableDataGrid.vue.d.ts.map +1 -1
- package/dist/types/components/TableDataGridCellRenderer.vue.d.ts +11 -0
- package/dist/types/components/TableDataGridCellRenderer.vue.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.kong-ui-public-table-data-grid[data-v-
|
|
1
|
+
.table-data-grid-cell-renderer,.table-data-grid-cell-tooltip,.table-data-grid-cell-content{display:block;min-width:0;width:100%}.table-data-grid-cell-content{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.kong-ui-public-table-data-grid[data-v-b8bd22c9]{border:none;border-radius:4px;border-radius:var(--kui-border-radius-20, 4px);box-sizing:border-box;display:flex;flex-direction:column;height:100%;min-height:0;overflow:hidden;width:100%}.table-data-grid-grid[data-v-b8bd22c9]{--ag-background-color: var(--kui-color-background, #ffffff);--ag-border-color: var(--kui-color-border, #e0e4ea);--ag-foreground-color: var(--kui-color-text, #000933);--ag-header-background-color: var(--kui-color-background, #ffffff);--ag-header-column-border: 1px solid var(--kui-color-border, #e0e4ea);--ag-header-column-border-height: 30%;--ag-header-column-resize-handle-color: transparent;--ag-header-font-weight: var(--kui-font-weight-semibold, 600);--ag-header-text-color: var(--kui-color-text-neutral, #6c7489);--ag-wrapper-border: none;--ag-wrapper-border-radius: 0;flex:1 1 auto;min-height:0;width:100%}.ag-cell{align-items:center;display:flex;min-width:0}.ag-cell-wrapper,.ag-cell-value{min-width:0;width:100%}
|
|
@@ -1,219 +1,275 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AgGridVue as
|
|
3
|
-
import { ModuleRegistry as
|
|
4
|
-
import { createI18n as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { defineComponent as A, shallowRef as N, ref as R, computed as E, onMounted as W, watch as O, onUnmounted as V, nextTick as $, resolveComponent as T, openBlock as w, createElementBlock as G, createVNode as I, withCtx as j, createElementVNode as q, toDisplayString as H, readonly as _, renderSlot as x, unref as S, createBlock as P } from "vue";
|
|
2
|
+
import { AgGridVue as Q } from "ag-grid-vue3";
|
|
3
|
+
import { ModuleRegistry as J, AllCommunityModule as X, InfiniteRowModelModule as Y, themeQuartz as Z } from "ag-grid-community";
|
|
4
|
+
import { createI18n as ee, i18nTComponent as te } from "@kong-ui-public/i18n";
|
|
5
|
+
const ae = { class: "table-data-grid-cell-renderer" }, oe = /* @__PURE__ */ A({
|
|
6
|
+
name: "TableDataGridCellRenderer",
|
|
7
|
+
__name: "TableDataGridCellRenderer",
|
|
8
|
+
props: {
|
|
9
|
+
params: {}
|
|
10
|
+
},
|
|
11
|
+
setup(e, { expose: i }) {
|
|
12
|
+
const a = N(e.params), t = R(null), r = R(!1), h = E(() => a.value.valueFormatted ?? String(a.value.value ?? ""));
|
|
13
|
+
let f, u, m = !1;
|
|
14
|
+
const C = () => {
|
|
15
|
+
const d = t.value;
|
|
16
|
+
r.value = !!d && d.scrollWidth > d.clientWidth;
|
|
17
|
+
}, p = () => {
|
|
18
|
+
m || (u !== void 0 && cancelAnimationFrame(u), u = requestAnimationFrame(() => {
|
|
19
|
+
u = void 0, C();
|
|
20
|
+
}));
|
|
21
|
+
}, g = (d) => {
|
|
22
|
+
if (f?.disconnect(), d) {
|
|
23
|
+
f?.observe(d);
|
|
24
|
+
const y = d.closest(".ag-cell");
|
|
25
|
+
y && f?.observe(y);
|
|
26
|
+
}
|
|
27
|
+
p();
|
|
28
|
+
};
|
|
29
|
+
return W(() => {
|
|
30
|
+
f = new ResizeObserver(p), g(t.value);
|
|
31
|
+
}), O(t, g, { flush: "post" }), V(() => {
|
|
32
|
+
m = !0, f?.disconnect(), u !== void 0 && cancelAnimationFrame(u);
|
|
33
|
+
}), i({
|
|
34
|
+
refresh(d) {
|
|
35
|
+
return a.value = d, $(p), !0;
|
|
36
|
+
}
|
|
37
|
+
}), (d, y) => {
|
|
38
|
+
const k = T("KTooltip");
|
|
39
|
+
return w(), G("span", ae, [
|
|
40
|
+
I(k, {
|
|
41
|
+
class: "table-data-grid-cell-tooltip",
|
|
42
|
+
disabled: !r.value,
|
|
43
|
+
"max-width": "300",
|
|
44
|
+
placement: "bottom-start",
|
|
45
|
+
target: "body",
|
|
46
|
+
text: h.value
|
|
47
|
+
}, {
|
|
48
|
+
default: j(() => [
|
|
49
|
+
q("span", {
|
|
50
|
+
ref_key: "contentElement",
|
|
51
|
+
ref: t,
|
|
52
|
+
class: "table-data-grid-cell-content"
|
|
53
|
+
}, H(h.value), 513)
|
|
54
|
+
]),
|
|
55
|
+
_: 1
|
|
56
|
+
}, 8, ["disabled", "text"])
|
|
57
|
+
]);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
var F = /* @__PURE__ */ ((e) => (e.PENDING = "PENDING", e.LOADING = "LOADING", e.SUCCESS = "SUCCESS", e.ERROR = "ERROR", e))(F || {});
|
|
62
|
+
const re = (e) => !!e?.length;
|
|
63
|
+
function ne(e, i, a, t = re) {
|
|
64
|
+
const r = E(() => t(e.value)), h = E(() => {
|
|
65
|
+
const u = e.value !== void 0, m = i.value !== void 0 && i.value !== null;
|
|
66
|
+
return a.value ? "LOADING" : r.value ? "SUCCESS" : m ? "ERROR" : u ? "SUCCESS" : "PENDING";
|
|
11
67
|
});
|
|
12
68
|
return {
|
|
13
|
-
fetchState:
|
|
14
|
-
hasData:
|
|
15
|
-
state:
|
|
69
|
+
fetchState: F,
|
|
70
|
+
hasData: r,
|
|
71
|
+
state: h
|
|
16
72
|
};
|
|
17
73
|
}
|
|
18
|
-
const
|
|
74
|
+
const se = ({
|
|
19
75
|
emitState: e,
|
|
20
|
-
fetchLifecycleState:
|
|
21
|
-
hasData:
|
|
76
|
+
fetchLifecycleState: i,
|
|
77
|
+
hasData: a
|
|
22
78
|
}) => {
|
|
23
|
-
|
|
79
|
+
O(
|
|
24
80
|
() => ({
|
|
25
|
-
hasData:
|
|
26
|
-
state:
|
|
81
|
+
hasData: a.value,
|
|
82
|
+
state: i.value
|
|
27
83
|
}),
|
|
28
|
-
({ hasData:
|
|
29
|
-
if (
|
|
30
|
-
if (
|
|
84
|
+
({ hasData: t, state: r }) => {
|
|
85
|
+
if (r !== F.PENDING) {
|
|
86
|
+
if (r === F.LOADING) {
|
|
31
87
|
e({
|
|
32
|
-
hasData:
|
|
88
|
+
hasData: t,
|
|
33
89
|
state: "loading"
|
|
34
90
|
});
|
|
35
91
|
return;
|
|
36
92
|
}
|
|
37
|
-
if (
|
|
93
|
+
if (r === F.ERROR) {
|
|
38
94
|
e({
|
|
39
|
-
hasData:
|
|
95
|
+
hasData: t,
|
|
40
96
|
state: "error"
|
|
41
97
|
});
|
|
42
98
|
return;
|
|
43
99
|
}
|
|
44
100
|
e({
|
|
45
|
-
hasData:
|
|
101
|
+
hasData: t,
|
|
46
102
|
state: "success"
|
|
47
103
|
});
|
|
48
104
|
}
|
|
49
105
|
}
|
|
50
106
|
);
|
|
51
|
-
},
|
|
52
|
-
const
|
|
107
|
+
}, le = ({ startRow: e, endRow: i }) => {
|
|
108
|
+
const a = i - e;
|
|
53
109
|
return {
|
|
54
|
-
blockIndex:
|
|
55
|
-
pageSize:
|
|
110
|
+
blockIndex: a > 0 ? Math.floor(e / a) : 0,
|
|
111
|
+
pageSize: a
|
|
56
112
|
};
|
|
57
|
-
},
|
|
113
|
+
}, ie = ({
|
|
58
114
|
startRow: e,
|
|
59
|
-
rowsLength:
|
|
60
|
-
pageSize:
|
|
61
|
-
total:
|
|
62
|
-
hasMore:
|
|
115
|
+
rowsLength: i,
|
|
116
|
+
pageSize: a,
|
|
117
|
+
total: t,
|
|
118
|
+
hasMore: r
|
|
63
119
|
}) => {
|
|
64
|
-
if (typeof
|
|
65
|
-
return
|
|
66
|
-
if (
|
|
67
|
-
return e +
|
|
68
|
-
},
|
|
120
|
+
if (typeof t == "number")
|
|
121
|
+
return t;
|
|
122
|
+
if (r !== !0 && (r === !1 || i < a))
|
|
123
|
+
return e + i;
|
|
124
|
+
}, ce = ({
|
|
69
125
|
fetcher: e,
|
|
70
|
-
resetKey:
|
|
126
|
+
resetKey: i
|
|
71
127
|
}) => {
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
},
|
|
79
|
-
const
|
|
80
|
-
if (
|
|
81
|
-
return
|
|
128
|
+
const a = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), r = R(0), h = N(), f = N(), u = N(), m = R(0), C = R(!1), p = (o) => o === r.value, g = () => {
|
|
129
|
+
C.value = m.value > 0;
|
|
130
|
+
}, d = () => {
|
|
131
|
+
u.value = void 0, m.value += 1, g();
|
|
132
|
+
}, y = () => {
|
|
133
|
+
m.value = Math.max(0, m.value - 1), g();
|
|
134
|
+
}, k = (o) => {
|
|
135
|
+
const n = t.get(o);
|
|
136
|
+
if (n)
|
|
137
|
+
return n;
|
|
82
138
|
let s;
|
|
83
|
-
const
|
|
84
|
-
promise: new Promise((
|
|
85
|
-
s =
|
|
139
|
+
const v = {
|
|
140
|
+
promise: new Promise((l) => {
|
|
141
|
+
s = l;
|
|
86
142
|
}),
|
|
87
|
-
resolve: (
|
|
143
|
+
resolve: (l) => s(l)
|
|
88
144
|
};
|
|
89
|
-
return
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
},
|
|
93
|
-
blockIndex:
|
|
94
|
-
currentBlockCompletion:
|
|
145
|
+
return t.set(o, v), v;
|
|
146
|
+
}, b = (o, n) => {
|
|
147
|
+
n.resolve(!1), t.get(o) === n && t.delete(o);
|
|
148
|
+
}, c = async ({
|
|
149
|
+
blockIndex: o,
|
|
150
|
+
currentBlockCompletion: n,
|
|
95
151
|
datasourceId: s
|
|
96
152
|
}) => {
|
|
97
|
-
if (
|
|
153
|
+
if (o === 0)
|
|
98
154
|
return "ready";
|
|
99
|
-
const
|
|
100
|
-
if (!
|
|
101
|
-
return
|
|
102
|
-
const
|
|
103
|
-
return
|
|
104
|
-
},
|
|
105
|
-
blockIndex:
|
|
106
|
-
currentBlockCompletion:
|
|
155
|
+
const v = t.get(o - 1);
|
|
156
|
+
if (!v)
|
|
157
|
+
return b(o, n), "failed";
|
|
158
|
+
const l = await v.promise;
|
|
159
|
+
return p(s) ? l ? "ready" : (b(o, n), "failed") : (b(o, n), "stale");
|
|
160
|
+
}, M = ({
|
|
161
|
+
blockIndex: o,
|
|
162
|
+
currentBlockCompletion: n,
|
|
107
163
|
getRowsParams: s,
|
|
108
|
-
pageSize:
|
|
109
|
-
result:
|
|
164
|
+
pageSize: v,
|
|
165
|
+
result: l
|
|
110
166
|
}) => {
|
|
111
|
-
|
|
167
|
+
l.cursor !== void 0 && a.set(o, l.cursor), s.successCallback(l.data, ie({
|
|
112
168
|
startRow: s.startRow,
|
|
113
|
-
rowsLength:
|
|
114
|
-
pageSize:
|
|
115
|
-
total:
|
|
116
|
-
hasMore:
|
|
117
|
-
})), s.startRow === 0 && (
|
|
118
|
-
},
|
|
119
|
-
blockIndex:
|
|
120
|
-
currentBlockCompletion:
|
|
169
|
+
rowsLength: l.data.length,
|
|
170
|
+
pageSize: v,
|
|
171
|
+
total: l.total,
|
|
172
|
+
hasMore: l.hasMore
|
|
173
|
+
})), s.startRow === 0 && (f.value = l.data), n.resolve(!0);
|
|
174
|
+
}, D = ({
|
|
175
|
+
blockIndex: o,
|
|
176
|
+
currentBlockCompletion: n,
|
|
121
177
|
fetchError: s,
|
|
122
|
-
getRowsParams:
|
|
178
|
+
getRowsParams: v
|
|
123
179
|
}) => {
|
|
124
|
-
|
|
125
|
-
},
|
|
126
|
-
const
|
|
127
|
-
return
|
|
128
|
-
async getRows(
|
|
180
|
+
u.value = s, v.failCallback(), b(o, n);
|
|
181
|
+
}, K = () => {
|
|
182
|
+
const o = r.value + 1;
|
|
183
|
+
return r.value = o, a.clear(), t.clear(), f.value = void 0, u.value = void 0, m.value = 0, g(), {
|
|
184
|
+
async getRows(n) {
|
|
129
185
|
const {
|
|
130
186
|
blockIndex: s,
|
|
131
|
-
pageSize:
|
|
132
|
-
} =
|
|
133
|
-
startRow:
|
|
134
|
-
endRow:
|
|
135
|
-
}),
|
|
187
|
+
pageSize: v
|
|
188
|
+
} = le({
|
|
189
|
+
startRow: n.startRow,
|
|
190
|
+
endRow: n.endRow
|
|
191
|
+
}), l = k(s), z = await c({
|
|
136
192
|
blockIndex: s,
|
|
137
|
-
currentBlockCompletion:
|
|
138
|
-
datasourceId:
|
|
193
|
+
currentBlockCompletion: l,
|
|
194
|
+
datasourceId: o
|
|
139
195
|
});
|
|
140
196
|
if (z !== "ready") {
|
|
141
|
-
z === "failed" &&
|
|
197
|
+
z === "failed" && n.failCallback();
|
|
142
198
|
return;
|
|
143
199
|
}
|
|
144
|
-
|
|
200
|
+
d();
|
|
145
201
|
try {
|
|
146
|
-
const
|
|
202
|
+
const B = s > 0 ? a.get(s - 1) : void 0, U = await e({
|
|
147
203
|
mode: "infinite",
|
|
148
|
-
pageSize:
|
|
149
|
-
cursor:
|
|
204
|
+
pageSize: v,
|
|
205
|
+
cursor: B
|
|
150
206
|
});
|
|
151
|
-
if (!
|
|
152
|
-
|
|
207
|
+
if (!p(o)) {
|
|
208
|
+
b(s, l);
|
|
153
209
|
return;
|
|
154
210
|
}
|
|
155
|
-
|
|
211
|
+
M({
|
|
156
212
|
blockIndex: s,
|
|
157
|
-
currentBlockCompletion:
|
|
158
|
-
getRowsParams:
|
|
159
|
-
pageSize:
|
|
160
|
-
result:
|
|
213
|
+
currentBlockCompletion: l,
|
|
214
|
+
getRowsParams: n,
|
|
215
|
+
pageSize: v,
|
|
216
|
+
result: U
|
|
161
217
|
});
|
|
162
|
-
} catch (
|
|
163
|
-
if (!
|
|
164
|
-
|
|
218
|
+
} catch (B) {
|
|
219
|
+
if (!p(o)) {
|
|
220
|
+
b(s, l);
|
|
165
221
|
return;
|
|
166
222
|
}
|
|
167
|
-
|
|
223
|
+
D({
|
|
168
224
|
blockIndex: s,
|
|
169
|
-
currentBlockCompletion:
|
|
170
|
-
fetchError:
|
|
171
|
-
getRowsParams:
|
|
225
|
+
currentBlockCompletion: l,
|
|
226
|
+
fetchError: B,
|
|
227
|
+
getRowsParams: n
|
|
172
228
|
});
|
|
173
229
|
} finally {
|
|
174
|
-
|
|
230
|
+
p(o) && y();
|
|
175
231
|
}
|
|
176
232
|
}
|
|
177
233
|
};
|
|
178
|
-
},
|
|
179
|
-
|
|
234
|
+
}, L = () => {
|
|
235
|
+
h.value = K();
|
|
180
236
|
};
|
|
181
|
-
return
|
|
182
|
-
() =>
|
|
237
|
+
return O(
|
|
238
|
+
() => i?.value,
|
|
183
239
|
() => {
|
|
184
|
-
|
|
240
|
+
L();
|
|
185
241
|
},
|
|
186
242
|
{ immediate: !0 }
|
|
187
243
|
), {
|
|
188
|
-
datasource:
|
|
189
|
-
data:
|
|
190
|
-
error:
|
|
191
|
-
isFetching:
|
|
244
|
+
datasource: _(h),
|
|
245
|
+
data: _(f),
|
|
246
|
+
error: _(u),
|
|
247
|
+
isFetching: _(C)
|
|
192
248
|
};
|
|
193
|
-
},
|
|
194
|
-
emptyState:
|
|
195
|
-
errorState:
|
|
249
|
+
}, ue = { title: "No Data", message: "There is no data to display." }, de = { title: "An error occurred", message: "Data cannot be displayed due to an error." }, fe = {
|
|
250
|
+
emptyState: ue,
|
|
251
|
+
errorState: de
|
|
196
252
|
};
|
|
197
|
-
function
|
|
198
|
-
const e =
|
|
253
|
+
function me() {
|
|
254
|
+
const e = ee("en-us", fe);
|
|
199
255
|
return {
|
|
200
256
|
i18n: e,
|
|
201
|
-
i18nT:
|
|
257
|
+
i18nT: te(e)
|
|
202
258
|
// Translation component <i18n-t>
|
|
203
259
|
};
|
|
204
260
|
}
|
|
205
|
-
const
|
|
261
|
+
const ve = {
|
|
206
262
|
class: "kong-ui-public-table-data-grid",
|
|
207
263
|
"data-testid": "table-data-grid"
|
|
208
|
-
},
|
|
264
|
+
}, pe = {
|
|
209
265
|
key: 0,
|
|
210
266
|
class: "table-error-state",
|
|
211
267
|
"data-testid": "table-error-state"
|
|
212
|
-
},
|
|
268
|
+
}, he = {
|
|
213
269
|
key: 1,
|
|
214
270
|
class: "table-empty-state",
|
|
215
271
|
"data-testid": "table-empty-state"
|
|
216
|
-
},
|
|
272
|
+
}, ge = /* @__PURE__ */ A({
|
|
217
273
|
__name: "TableDataGrid",
|
|
218
274
|
props: {
|
|
219
275
|
headers: {},
|
|
@@ -223,83 +279,84 @@ const ne = {
|
|
|
223
279
|
refreshKey: { type: [String, Number, Boolean] }
|
|
224
280
|
},
|
|
225
281
|
emits: ["grid:ready", "state"],
|
|
226
|
-
setup(e, { emit:
|
|
227
|
-
|
|
228
|
-
const
|
|
282
|
+
setup(e, { emit: i }) {
|
|
283
|
+
J.registerModules([X, Y]);
|
|
284
|
+
const a = i, { i18n: { t } } = me(), r = {
|
|
285
|
+
cellRenderer: oe,
|
|
229
286
|
resizable: !1,
|
|
230
287
|
sortable: !1,
|
|
231
288
|
suppressMovable: !0
|
|
232
|
-
},
|
|
233
|
-
colId:
|
|
289
|
+
}, h = E(() => e.headers.map((c) => ({
|
|
290
|
+
colId: c.key,
|
|
234
291
|
// Headers without explicit width constraints should fill available space.
|
|
235
|
-
flex: !
|
|
236
|
-
headerName:
|
|
237
|
-
maxWidth:
|
|
238
|
-
minWidth:
|
|
239
|
-
valueGetter: (
|
|
240
|
-
width:
|
|
241
|
-
}))),
|
|
242
|
-
data:
|
|
243
|
-
datasource:
|
|
244
|
-
error:
|
|
245
|
-
isFetching:
|
|
246
|
-
} =
|
|
292
|
+
flex: !c.width && !c.maxWidth ? 1 : void 0,
|
|
293
|
+
headerName: c.label,
|
|
294
|
+
maxWidth: c.maxWidth,
|
|
295
|
+
minWidth: c.minWidth,
|
|
296
|
+
valueGetter: (D) => D.data?.[c.key],
|
|
297
|
+
width: c.width
|
|
298
|
+
}))), f = E(() => [e.fetcher, e.pageSize, e.refreshKey]), {
|
|
299
|
+
data: u,
|
|
300
|
+
datasource: m,
|
|
301
|
+
error: C,
|
|
302
|
+
isFetching: p
|
|
303
|
+
} = ce({
|
|
247
304
|
fetcher: e.fetcher,
|
|
248
|
-
resetKey:
|
|
305
|
+
resetKey: f
|
|
249
306
|
}), {
|
|
250
|
-
fetchState:
|
|
251
|
-
hasData:
|
|
252
|
-
state:
|
|
253
|
-
} =
|
|
254
|
-
|
|
255
|
-
emitState: (
|
|
256
|
-
fetchLifecycleState:
|
|
257
|
-
hasData:
|
|
307
|
+
fetchState: g,
|
|
308
|
+
hasData: d,
|
|
309
|
+
state: y
|
|
310
|
+
} = ne(u, C, p), k = E(() => y.value === g.SUCCESS && !d.value);
|
|
311
|
+
se({
|
|
312
|
+
emitState: (c) => a("state", c),
|
|
313
|
+
fetchLifecycleState: y,
|
|
314
|
+
hasData: d
|
|
258
315
|
});
|
|
259
|
-
const
|
|
260
|
-
|
|
316
|
+
const b = (c) => {
|
|
317
|
+
a("grid:ready", c.api);
|
|
261
318
|
};
|
|
262
|
-
return (
|
|
263
|
-
const
|
|
264
|
-
return w(),
|
|
265
|
-
e.error ? (w(),
|
|
266
|
-
|
|
267
|
-
|
|
319
|
+
return (c, M) => {
|
|
320
|
+
const D = T("KEmptyState");
|
|
321
|
+
return w(), G("div", ve, [
|
|
322
|
+
e.error ? (w(), G("div", pe, [
|
|
323
|
+
x(c.$slots, "error-state", {}, () => [
|
|
324
|
+
I(D, {
|
|
268
325
|
"icon-variant": "error",
|
|
269
|
-
message:
|
|
270
|
-
title:
|
|
326
|
+
message: S(t)("errorState.message"),
|
|
327
|
+
title: S(t)("errorState.title")
|
|
271
328
|
}, null, 8, ["message", "title"])
|
|
272
329
|
], !0)
|
|
273
|
-
])) :
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
message:
|
|
277
|
-
title:
|
|
330
|
+
])) : k.value ? (w(), G("div", he, [
|
|
331
|
+
x(c.$slots, "empty-state", {}, () => [
|
|
332
|
+
I(D, {
|
|
333
|
+
message: S(t)("emptyState.message"),
|
|
334
|
+
title: S(t)("emptyState.title")
|
|
278
335
|
}, null, 8, ["message", "title"])
|
|
279
336
|
], !0)
|
|
280
|
-
])) : (w(),
|
|
337
|
+
])) : (w(), P(S(Q), {
|
|
281
338
|
key: 2,
|
|
282
339
|
"cache-block-size": e.pageSize,
|
|
283
340
|
class: "table-data-grid-grid",
|
|
284
|
-
"column-defs":
|
|
285
|
-
datasource:
|
|
286
|
-
"default-col-def":
|
|
341
|
+
"column-defs": h.value,
|
|
342
|
+
datasource: S(m),
|
|
343
|
+
"default-col-def": r,
|
|
287
344
|
"infinite-initial-row-count": 1,
|
|
288
|
-
loading:
|
|
345
|
+
loading: S(p),
|
|
289
346
|
"row-model-type": "infinite",
|
|
290
347
|
"suppress-cell-focus": !0,
|
|
291
|
-
theme:
|
|
292
|
-
onGridReady:
|
|
348
|
+
theme: S(Z),
|
|
349
|
+
onGridReady: b
|
|
293
350
|
}, null, 8, ["cache-block-size", "column-defs", "datasource", "loading", "theme"]))
|
|
294
351
|
]);
|
|
295
352
|
};
|
|
296
353
|
}
|
|
297
|
-
}),
|
|
298
|
-
const
|
|
299
|
-
for (const [
|
|
300
|
-
|
|
301
|
-
return
|
|
302
|
-
},
|
|
354
|
+
}), ye = (e, i) => {
|
|
355
|
+
const a = e.__vccOpts || e;
|
|
356
|
+
for (const [t, r] of i)
|
|
357
|
+
a[t] = r;
|
|
358
|
+
return a;
|
|
359
|
+
}, Ee = /* @__PURE__ */ ye(ge, [["__scopeId", "data-v-b8bd22c9"]]);
|
|
303
360
|
export {
|
|
304
|
-
|
|
361
|
+
Ee as TableDataGrid
|
|
305
362
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(y,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("ag-grid-vue3"),require("ag-grid-community"),require("@kong-ui-public/i18n")):typeof define=="function"&&define.amd?define(["exports","vue","ag-grid-vue3","ag-grid-community","@kong-ui-public/i18n"],e):(y=typeof globalThis<"u"?globalThis:y||self,e(y["kong-ui-public-table-data-grid"]={},y.Vue,y.AgGridVue,y.agGridCommunity,y["kong-ui-public-i18n"]))})(this,(function(y,e,G,R,N){"use strict";const M={class:"table-data-grid-cell-renderer"},O=e.defineComponent({name:"TableDataGridCellRenderer",__name:"TableDataGridCellRenderer",props:{params:{}},setup(t,{expose:c}){const o=e.shallowRef(t.params),a=e.ref(null),r=e.ref(!1),b=e.computed(()=>o.value.valueFormatted??String(o.value.value??""));let m,u,p=!1;const C=()=>{const f=a.value;r.value=!!f&&f.scrollWidth>f.clientWidth},g=()=>{p||(u!==void 0&&cancelAnimationFrame(u),u=requestAnimationFrame(()=>{u=void 0,C()}))},S=f=>{if(m?.disconnect(),f){m?.observe(f);const k=f.closest(".ag-cell");k&&m?.observe(k)}g()};return e.onMounted(()=>{m=new ResizeObserver(g),S(a.value)}),e.watch(a,S,{flush:"post"}),e.onUnmounted(()=>{p=!0,m?.disconnect(),u!==void 0&&cancelAnimationFrame(u)}),c({refresh(f){return o.value=f,e.nextTick(g),!0}}),(f,k)=>{const E=e.resolveComponent("KTooltip");return e.openBlock(),e.createElementBlock("span",M,[e.createVNode(E,{class:"table-data-grid-cell-tooltip",disabled:!r.value,"max-width":"300",placement:"bottom-start",target:"body",text:b.value},{default:e.withCtx(()=>[e.createElementVNode("span",{ref_key:"contentElement",ref:a,class:"table-data-grid-cell-content"},e.toDisplayString(b.value),513)]),_:1},8,["disabled","text"])])}}});var w=(t=>(t.PENDING="PENDING",t.LOADING="LOADING",t.SUCCESS="SUCCESS",t.ERROR="ERROR",t))(w||{});const I=t=>!!t?.length;function T(t,c,o,a=I){const r=e.computed(()=>a(t.value)),b=e.computed(()=>{const u=t.value!==void 0,p=c.value!==void 0&&c.value!==null;return o.value?"LOADING":r.value?"SUCCESS":p?"ERROR":u?"SUCCESS":"PENDING"});return{fetchState:w,hasData:r,state:b}}const x=({emitState:t,fetchLifecycleState:c,hasData:o})=>{e.watch(()=>({hasData:o.value,state:c.value}),({hasData:a,state:r})=>{if(r!==w.PENDING){if(r===w.LOADING){t({hasData:a,state:"loading"});return}if(r===w.ERROR){t({hasData:a,state:"error"});return}t({hasData:a,state:"success"})}})},z=({startRow:t,endRow:c})=>{const o=c-t;return{blockIndex:o>0?Math.floor(t/o):0,pageSize:o}},A=({startRow:t,rowsLength:c,pageSize:o,total:a,hasMore:r})=>{if(typeof a=="number")return a;if(r!==!0&&(r===!1||c<o))return t+c},V=({fetcher:t,resetKey:c})=>{const o=new Map,a=new Map,r=e.ref(0),b=e.shallowRef(),m=e.shallowRef(),u=e.shallowRef(),p=e.ref(0),C=e.ref(!1),g=n=>n===r.value,S=()=>{C.value=p.value>0},f=()=>{u.value=void 0,p.value+=1,S()},k=()=>{p.value=Math.max(0,p.value-1),S()},E=n=>{const s=a.get(n);if(s)return s;let l;const h={promise:new Promise(i=>{l=i}),resolve:i=>l(i)};return a.set(n,h),h},v=(n,s)=>{s.resolve(!1),a.get(n)===s&&a.delete(n)},d=async({blockIndex:n,currentBlockCompletion:s,datasourceId:l})=>{if(n===0)return"ready";const h=a.get(n-1);if(!h)return v(n,s),"failed";const i=await h.promise;return g(l)?i?"ready":(v(n,s),"failed"):(v(n,s),"stale")},_=({blockIndex:n,currentBlockCompletion:s,getRowsParams:l,pageSize:h,result:i})=>{i.cursor!==void 0&&o.set(n,i.cursor),l.successCallback(i.data,A({startRow:l.startRow,rowsLength:i.data.length,pageSize:h,total:i.total,hasMore:i.hasMore})),l.startRow===0&&(m.value=i.data),s.resolve(!0)},D=({blockIndex:n,currentBlockCompletion:s,fetchError:l,getRowsParams:h})=>{u.value=l,h.failCallback(),v(n,s)},j=()=>{const n=r.value+1;return r.value=n,o.clear(),a.clear(),m.value=void 0,u.value=void 0,p.value=0,S(),{async getRows(s){const{blockIndex:l,pageSize:h}=z({startRow:s.startRow,endRow:s.endRow}),i=E(l),F=await d({blockIndex:l,currentBlockCompletion:i,datasourceId:n});if(F!=="ready"){F==="failed"&&s.failCallback();return}f();try{const B=l>0?o.get(l-1):void 0,H=await t({mode:"infinite",pageSize:h,cursor:B});if(!g(n)){v(l,i);return}_({blockIndex:l,currentBlockCompletion:i,getRowsParams:s,pageSize:h,result:H})}catch(B){if(!g(n)){v(l,i);return}D({blockIndex:l,currentBlockCompletion:i,fetchError:B,getRowsParams:s})}finally{g(n)&&k()}}}},P=()=>{b.value=j()};return e.watch(()=>c?.value,()=>{P()},{immediate:!0}),{datasource:e.readonly(b),data:e.readonly(m),error:e.readonly(u),isFetching:e.readonly(C)}},K={emptyState:{title:"No Data",message:"There is no data to display."},errorState:{title:"An error occurred",message:"Data cannot be displayed due to an error."}};function L(){const t=N.createI18n("en-us",K);return{i18n:t,i18nT:N.i18nTComponent(t)}}const U={class:"kong-ui-public-table-data-grid","data-testid":"table-data-grid"},W={key:0,class:"table-error-state","data-testid":"table-error-state"},q={key:1,class:"table-empty-state","data-testid":"table-empty-state"},$=((t,c)=>{const o=t.__vccOpts||t;for(const[a,r]of c)o[a]=r;return o})(e.defineComponent({__name:"TableDataGrid",props:{headers:{},fetcher:{type:Function},error:{type:Boolean,default:!1},pageSize:{default:25},refreshKey:{type:[String,Number,Boolean]}},emits:["grid:ready","state"],setup(t,{emit:c}){R.ModuleRegistry.registerModules([R.AllCommunityModule,R.InfiniteRowModelModule]);const o=c,{i18n:{t:a}}=L(),r={cellRenderer:O,resizable:!1,sortable:!1,suppressMovable:!0},b=e.computed(()=>t.headers.map(d=>({colId:d.key,flex:!d.width&&!d.maxWidth?1:void 0,headerName:d.label,maxWidth:d.maxWidth,minWidth:d.minWidth,valueGetter:D=>D.data?.[d.key],width:d.width}))),m=e.computed(()=>[t.fetcher,t.pageSize,t.refreshKey]),{data:u,datasource:p,error:C,isFetching:g}=V({fetcher:t.fetcher,resetKey:m}),{fetchState:S,hasData:f,state:k}=T(u,C,g),E=e.computed(()=>k.value===S.SUCCESS&&!f.value);x({emitState:d=>o("state",d),fetchLifecycleState:k,hasData:f});const v=d=>{o("grid:ready",d.api)};return(d,_)=>{const D=e.resolveComponent("KEmptyState");return e.openBlock(),e.createElementBlock("div",U,[t.error?(e.openBlock(),e.createElementBlock("div",W,[e.renderSlot(d.$slots,"error-state",{},()=>[e.createVNode(D,{"icon-variant":"error",message:e.unref(a)("errorState.message"),title:e.unref(a)("errorState.title")},null,8,["message","title"])],!0)])):E.value?(e.openBlock(),e.createElementBlock("div",q,[e.renderSlot(d.$slots,"empty-state",{},()=>[e.createVNode(D,{message:e.unref(a)("emptyState.message"),title:e.unref(a)("emptyState.title")},null,8,["message","title"])],!0)])):(e.openBlock(),e.createBlock(e.unref(G.AgGridVue),{key:2,"cache-block-size":t.pageSize,class:"table-data-grid-grid","column-defs":b.value,datasource:e.unref(p),"default-col-def":r,"infinite-initial-row-count":1,loading:e.unref(g),"row-model-type":"infinite","suppress-cell-focus":!0,theme:e.unref(R.themeQuartz),onGridReady:v},null,8,["cache-block-size","column-defs","datasource","loading","theme"]))])}}}),[["__scopeId","data-v-b8bd22c9"]]);y.TableDataGrid=$,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableDataGrid.vue.d.ts","sourceRoot":"","sources":["../../../src/components/TableDataGrid.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TableDataGrid.vue.d.ts","sourceRoot":"","sources":["../../../src/components/TableDataGrid.vue"],"names":[],"mappings":"AAyMA,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAAU,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAe/D,QAAA,MAAM,YAAY,GAAK,GAAG,SAAS,MAAM,EACxC,aAAa,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,EAC9D,YAAY,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,EAC3G,gBAAgB,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,EAClE;WAyNO,OAAO,KAAK,EAAE,WAAW,GAAG,mBAAmB,CAAC;iBArN7C,KAAK,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;iBAC/B,oBAAoB,CAAC,GAAG,CAAC;gBAC1B,OAAO;mBACJ,MAAM;qBACJ,MAAM,GAAG,MAAM,GAAG,OAAO;;;;KAiNmD,CAAC,GAAG,CAAC,OAAO,UAAU,SAAS;QAAE,oBAAoB,EAAE,MAAM,CAAC,CAAA;KAAE,GAAG,CAAC,GAAG,EAAE,CAAC;YAC5J,CAAC,OAAO,EAAE,EAAE,KAAK,IAAI;WACtB,GAAG;;uBAvMM,MAAM,OAAO;uBACb,MAAM,OAAO;;;YAKxB,YAAY,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,IAAI;YACpD,OAAO,WAAW,yBAAyB,GAAG,IAAI;;EAoMpD,KACQ,OAAO,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC,OAAO,WAAW,CAAC,CAAA;CAAI,CAAC;wBACvD,OAAO,YAAY;AAAxC,wBAAyC;AACzC,KAAK,mBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,GAAG,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,CAAC,GAAG,EAAE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ICellRendererParams } from 'ag-grid-community';
|
|
2
|
+
type CellRendererParams = ICellRendererParams<Record<string, unknown>>;
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
params: CellRendererParams;
|
|
5
|
+
};
|
|
6
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
|
|
7
|
+
refresh(nextParams: CellRendererParams): boolean;
|
|
8
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
|
+
declare const _default: typeof __VLS_export;
|
|
10
|
+
export default _default;
|
|
11
|
+
//# sourceMappingURL=TableDataGridCellRenderer.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableDataGridCellRenderer.vue.d.ts","sourceRoot":"","sources":["../../../src/components/TableDataGridCellRenderer.vue"],"names":[],"mappings":"AAgIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAG5D,KAAK,kBAAkB,GAAG,mBAAmB,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;AAMtE,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,kBAAkB,CAAA;CAC3B,CAAC;AA2IF,QAAA,MAAM,YAAY;wBApEI,kBAAkB;oPAuEtC,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|