@kong-ui-public/table-data-grid 0.3.4-pr.3598.efa3e41fa.0 → 0.3.4
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 +188 -245
- package/dist/table-data-grid.umd.js +1 -1
- package/dist/types/components/TableDataGrid.vue.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/types/components/TableDataGridCellRenderer.vue.d.ts +0 -11
- package/dist/types/components/TableDataGridCellRenderer.vue.d.ts.map +0 -1
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
.kong-ui-public-table-data-grid[data-v-87a96f8f]{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-87a96f8f]{--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}
|
|
@@ -1,275 +1,219 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AgGridVue as
|
|
3
|
-
import { ModuleRegistry as
|
|
4
|
-
import { createI18n as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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";
|
|
1
|
+
import { computed as C, watch as L, ref as I, shallowRef as F, readonly as R, defineComponent as U, resolveComponent as W, openBlock as w, createElementBlock as M, renderSlot as O, createVNode as A, unref as v, createBlock as V } from "vue";
|
|
2
|
+
import { AgGridVue as x } from "ag-grid-vue3";
|
|
3
|
+
import { ModuleRegistry as $, AllCommunityModule as j, InfiniteRowModelModule as H, themeQuartz as Q } from "ag-grid-community";
|
|
4
|
+
import { createI18n as q, i18nTComponent as J } from "@kong-ui-public/i18n";
|
|
5
|
+
var D = /* @__PURE__ */ ((e) => (e.PENDING = "PENDING", e.LOADING = "LOADING", e.SUCCESS = "SUCCESS", e.ERROR = "ERROR", e))(D || {});
|
|
6
|
+
const P = (e) => !!e?.length;
|
|
7
|
+
function X(e, c, o, a = P) {
|
|
8
|
+
const i = C(() => a(e.value)), p = C(() => {
|
|
9
|
+
const f = e.value !== void 0, d = c.value !== void 0 && c.value !== null;
|
|
10
|
+
return o.value ? "LOADING" : i.value ? "SUCCESS" : d ? "ERROR" : f ? "SUCCESS" : "PENDING";
|
|
67
11
|
});
|
|
68
12
|
return {
|
|
69
|
-
fetchState:
|
|
70
|
-
hasData:
|
|
71
|
-
state:
|
|
13
|
+
fetchState: D,
|
|
14
|
+
hasData: i,
|
|
15
|
+
state: p
|
|
72
16
|
};
|
|
73
17
|
}
|
|
74
|
-
const
|
|
18
|
+
const Y = ({
|
|
75
19
|
emitState: e,
|
|
76
|
-
fetchLifecycleState:
|
|
77
|
-
hasData:
|
|
20
|
+
fetchLifecycleState: c,
|
|
21
|
+
hasData: o
|
|
78
22
|
}) => {
|
|
79
|
-
|
|
23
|
+
L(
|
|
80
24
|
() => ({
|
|
81
|
-
hasData:
|
|
82
|
-
state:
|
|
25
|
+
hasData: o.value,
|
|
26
|
+
state: c.value
|
|
83
27
|
}),
|
|
84
|
-
({ hasData:
|
|
85
|
-
if (
|
|
86
|
-
if (
|
|
28
|
+
({ hasData: a, state: i }) => {
|
|
29
|
+
if (i !== D.PENDING) {
|
|
30
|
+
if (i === D.LOADING) {
|
|
87
31
|
e({
|
|
88
|
-
hasData:
|
|
32
|
+
hasData: a,
|
|
89
33
|
state: "loading"
|
|
90
34
|
});
|
|
91
35
|
return;
|
|
92
36
|
}
|
|
93
|
-
if (
|
|
37
|
+
if (i === D.ERROR) {
|
|
94
38
|
e({
|
|
95
|
-
hasData:
|
|
39
|
+
hasData: a,
|
|
96
40
|
state: "error"
|
|
97
41
|
});
|
|
98
42
|
return;
|
|
99
43
|
}
|
|
100
44
|
e({
|
|
101
|
-
hasData:
|
|
45
|
+
hasData: a,
|
|
102
46
|
state: "success"
|
|
103
47
|
});
|
|
104
48
|
}
|
|
105
49
|
}
|
|
106
50
|
);
|
|
107
|
-
},
|
|
108
|
-
const
|
|
51
|
+
}, Z = ({ startRow: e, endRow: c }) => {
|
|
52
|
+
const o = c - e;
|
|
109
53
|
return {
|
|
110
|
-
blockIndex:
|
|
111
|
-
pageSize:
|
|
54
|
+
blockIndex: o > 0 ? Math.floor(e / o) : 0,
|
|
55
|
+
pageSize: o
|
|
112
56
|
};
|
|
113
|
-
},
|
|
57
|
+
}, ee = ({
|
|
114
58
|
startRow: e,
|
|
115
|
-
rowsLength:
|
|
116
|
-
pageSize:
|
|
117
|
-
total:
|
|
118
|
-
hasMore:
|
|
59
|
+
rowsLength: c,
|
|
60
|
+
pageSize: o,
|
|
61
|
+
total: a,
|
|
62
|
+
hasMore: i
|
|
119
63
|
}) => {
|
|
120
|
-
if (typeof
|
|
121
|
-
return
|
|
122
|
-
if (
|
|
123
|
-
return e +
|
|
124
|
-
},
|
|
64
|
+
if (typeof a == "number")
|
|
65
|
+
return a;
|
|
66
|
+
if (i !== !0 && (i === !1 || c < o))
|
|
67
|
+
return e + c;
|
|
68
|
+
}, te = ({
|
|
125
69
|
fetcher: e,
|
|
126
|
-
resetKey:
|
|
70
|
+
resetKey: c
|
|
127
71
|
}) => {
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
},
|
|
131
|
-
|
|
132
|
-
},
|
|
133
|
-
|
|
134
|
-
},
|
|
135
|
-
const
|
|
136
|
-
if (
|
|
137
|
-
return
|
|
72
|
+
const o = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), i = I(0), p = F(), y = F(), f = F(), d = I(0), k = I(!1), h = (t) => t === i.value, S = () => {
|
|
73
|
+
k.value = d.value > 0;
|
|
74
|
+
}, b = () => {
|
|
75
|
+
f.value = void 0, d.value += 1, S();
|
|
76
|
+
}, E = () => {
|
|
77
|
+
d.value = Math.max(0, d.value - 1), S();
|
|
78
|
+
}, N = (t) => {
|
|
79
|
+
const r = a.get(t);
|
|
80
|
+
if (r)
|
|
81
|
+
return r;
|
|
138
82
|
let s;
|
|
139
|
-
const
|
|
140
|
-
promise: new Promise((
|
|
141
|
-
s =
|
|
83
|
+
const u = {
|
|
84
|
+
promise: new Promise((n) => {
|
|
85
|
+
s = n;
|
|
142
86
|
}),
|
|
143
|
-
resolve: (
|
|
87
|
+
resolve: (n) => s(n)
|
|
144
88
|
};
|
|
145
|
-
return
|
|
146
|
-
},
|
|
147
|
-
|
|
148
|
-
},
|
|
149
|
-
blockIndex:
|
|
150
|
-
currentBlockCompletion:
|
|
89
|
+
return a.set(t, u), u;
|
|
90
|
+
}, m = (t, r) => {
|
|
91
|
+
r.resolve(!1), a.get(t) === r && a.delete(t);
|
|
92
|
+
}, l = async ({
|
|
93
|
+
blockIndex: t,
|
|
94
|
+
currentBlockCompletion: r,
|
|
151
95
|
datasourceId: s
|
|
152
96
|
}) => {
|
|
153
|
-
if (
|
|
97
|
+
if (t === 0)
|
|
154
98
|
return "ready";
|
|
155
|
-
const
|
|
156
|
-
if (!
|
|
157
|
-
return
|
|
158
|
-
const
|
|
159
|
-
return
|
|
160
|
-
},
|
|
161
|
-
blockIndex:
|
|
162
|
-
currentBlockCompletion:
|
|
99
|
+
const u = a.get(t - 1);
|
|
100
|
+
if (!u)
|
|
101
|
+
return m(t, r), "failed";
|
|
102
|
+
const n = await u.promise;
|
|
103
|
+
return h(s) ? n ? "ready" : (m(t, r), "failed") : (m(t, r), "stale");
|
|
104
|
+
}, B = ({
|
|
105
|
+
blockIndex: t,
|
|
106
|
+
currentBlockCompletion: r,
|
|
163
107
|
getRowsParams: s,
|
|
164
|
-
pageSize:
|
|
165
|
-
result:
|
|
108
|
+
pageSize: u,
|
|
109
|
+
result: n
|
|
166
110
|
}) => {
|
|
167
|
-
|
|
111
|
+
n.cursor !== void 0 && o.set(t, n.cursor), s.successCallback(n.data, ee({
|
|
168
112
|
startRow: s.startRow,
|
|
169
|
-
rowsLength:
|
|
170
|
-
pageSize:
|
|
171
|
-
total:
|
|
172
|
-
hasMore:
|
|
173
|
-
})), s.startRow === 0 && (
|
|
174
|
-
},
|
|
175
|
-
blockIndex:
|
|
176
|
-
currentBlockCompletion:
|
|
113
|
+
rowsLength: n.data.length,
|
|
114
|
+
pageSize: u,
|
|
115
|
+
total: n.total,
|
|
116
|
+
hasMore: n.hasMore
|
|
117
|
+
})), s.startRow === 0 && (y.value = n.data), r.resolve(!0);
|
|
118
|
+
}, g = ({
|
|
119
|
+
blockIndex: t,
|
|
120
|
+
currentBlockCompletion: r,
|
|
177
121
|
fetchError: s,
|
|
178
|
-
getRowsParams:
|
|
122
|
+
getRowsParams: u
|
|
179
123
|
}) => {
|
|
180
|
-
|
|
181
|
-
},
|
|
182
|
-
const
|
|
183
|
-
return
|
|
184
|
-
async getRows(
|
|
124
|
+
f.value = s, u.failCallback(), m(t, r);
|
|
125
|
+
}, _ = () => {
|
|
126
|
+
const t = i.value + 1;
|
|
127
|
+
return i.value = t, o.clear(), a.clear(), y.value = void 0, f.value = void 0, d.value = 0, S(), {
|
|
128
|
+
async getRows(r) {
|
|
185
129
|
const {
|
|
186
130
|
blockIndex: s,
|
|
187
|
-
pageSize:
|
|
188
|
-
} =
|
|
189
|
-
startRow:
|
|
190
|
-
endRow:
|
|
191
|
-
}),
|
|
131
|
+
pageSize: u
|
|
132
|
+
} = Z({
|
|
133
|
+
startRow: r.startRow,
|
|
134
|
+
endRow: r.endRow
|
|
135
|
+
}), n = N(s), z = await l({
|
|
192
136
|
blockIndex: s,
|
|
193
|
-
currentBlockCompletion:
|
|
194
|
-
datasourceId:
|
|
137
|
+
currentBlockCompletion: n,
|
|
138
|
+
datasourceId: t
|
|
195
139
|
});
|
|
196
140
|
if (z !== "ready") {
|
|
197
|
-
z === "failed" &&
|
|
141
|
+
z === "failed" && r.failCallback();
|
|
198
142
|
return;
|
|
199
143
|
}
|
|
200
|
-
|
|
144
|
+
b();
|
|
201
145
|
try {
|
|
202
|
-
const
|
|
146
|
+
const G = s > 0 ? o.get(s - 1) : void 0, T = await e({
|
|
203
147
|
mode: "infinite",
|
|
204
|
-
pageSize:
|
|
205
|
-
cursor:
|
|
148
|
+
pageSize: u,
|
|
149
|
+
cursor: G
|
|
206
150
|
});
|
|
207
|
-
if (!
|
|
208
|
-
|
|
151
|
+
if (!h(t)) {
|
|
152
|
+
m(s, n);
|
|
209
153
|
return;
|
|
210
154
|
}
|
|
211
|
-
|
|
155
|
+
B({
|
|
212
156
|
blockIndex: s,
|
|
213
|
-
currentBlockCompletion:
|
|
214
|
-
getRowsParams:
|
|
215
|
-
pageSize:
|
|
216
|
-
result:
|
|
157
|
+
currentBlockCompletion: n,
|
|
158
|
+
getRowsParams: r,
|
|
159
|
+
pageSize: u,
|
|
160
|
+
result: T
|
|
217
161
|
});
|
|
218
|
-
} catch (
|
|
219
|
-
if (!
|
|
220
|
-
|
|
162
|
+
} catch (G) {
|
|
163
|
+
if (!h(t)) {
|
|
164
|
+
m(s, n);
|
|
221
165
|
return;
|
|
222
166
|
}
|
|
223
|
-
|
|
167
|
+
g({
|
|
224
168
|
blockIndex: s,
|
|
225
|
-
currentBlockCompletion:
|
|
226
|
-
fetchError:
|
|
227
|
-
getRowsParams:
|
|
169
|
+
currentBlockCompletion: n,
|
|
170
|
+
fetchError: G,
|
|
171
|
+
getRowsParams: r
|
|
228
172
|
});
|
|
229
173
|
} finally {
|
|
230
|
-
|
|
174
|
+
h(t) && E();
|
|
231
175
|
}
|
|
232
176
|
}
|
|
233
177
|
};
|
|
234
|
-
},
|
|
235
|
-
|
|
178
|
+
}, K = () => {
|
|
179
|
+
p.value = _();
|
|
236
180
|
};
|
|
237
|
-
return
|
|
238
|
-
() =>
|
|
181
|
+
return L(
|
|
182
|
+
() => c?.value,
|
|
239
183
|
() => {
|
|
240
|
-
|
|
184
|
+
K();
|
|
241
185
|
},
|
|
242
186
|
{ immediate: !0 }
|
|
243
187
|
), {
|
|
244
|
-
datasource:
|
|
245
|
-
data:
|
|
246
|
-
error:
|
|
247
|
-
isFetching:
|
|
188
|
+
datasource: R(p),
|
|
189
|
+
data: R(y),
|
|
190
|
+
error: R(f),
|
|
191
|
+
isFetching: R(k)
|
|
248
192
|
};
|
|
249
|
-
},
|
|
250
|
-
emptyState:
|
|
251
|
-
errorState:
|
|
193
|
+
}, ae = { title: "No Data", message: "There is no data to display." }, oe = { title: "An error occurred", message: "Data cannot be displayed due to an error." }, re = {
|
|
194
|
+
emptyState: ae,
|
|
195
|
+
errorState: oe
|
|
252
196
|
};
|
|
253
|
-
function
|
|
254
|
-
const e =
|
|
197
|
+
function se() {
|
|
198
|
+
const e = q("en-us", re);
|
|
255
199
|
return {
|
|
256
200
|
i18n: e,
|
|
257
|
-
i18nT:
|
|
201
|
+
i18nT: J(e)
|
|
258
202
|
// Translation component <i18n-t>
|
|
259
203
|
};
|
|
260
204
|
}
|
|
261
|
-
const
|
|
205
|
+
const ne = {
|
|
262
206
|
class: "kong-ui-public-table-data-grid",
|
|
263
207
|
"data-testid": "table-data-grid"
|
|
264
|
-
},
|
|
208
|
+
}, ie = {
|
|
265
209
|
key: 0,
|
|
266
210
|
class: "table-error-state",
|
|
267
211
|
"data-testid": "table-error-state"
|
|
268
|
-
},
|
|
212
|
+
}, le = {
|
|
269
213
|
key: 1,
|
|
270
214
|
class: "table-empty-state",
|
|
271
215
|
"data-testid": "table-empty-state"
|
|
272
|
-
},
|
|
216
|
+
}, ce = /* @__PURE__ */ U({
|
|
273
217
|
__name: "TableDataGrid",
|
|
274
218
|
props: {
|
|
275
219
|
headers: {},
|
|
@@ -279,84 +223,83 @@ const ve = {
|
|
|
279
223
|
refreshKey: { type: [String, Number, Boolean] }
|
|
280
224
|
},
|
|
281
225
|
emits: ["grid:ready", "state"],
|
|
282
|
-
setup(e, { emit:
|
|
283
|
-
|
|
284
|
-
const
|
|
285
|
-
cellRenderer: oe,
|
|
226
|
+
setup(e, { emit: c }) {
|
|
227
|
+
$.registerModules([j, H]);
|
|
228
|
+
const o = c, { i18n: { t: a } } = se(), i = {
|
|
286
229
|
resizable: !1,
|
|
287
230
|
sortable: !1,
|
|
288
231
|
suppressMovable: !0
|
|
289
|
-
},
|
|
290
|
-
colId:
|
|
232
|
+
}, p = C(() => e.headers.map((l) => ({
|
|
233
|
+
colId: l.key,
|
|
291
234
|
// Headers without explicit width constraints should fill available space.
|
|
292
|
-
flex: !
|
|
293
|
-
headerName:
|
|
294
|
-
maxWidth:
|
|
295
|
-
minWidth:
|
|
296
|
-
valueGetter: (
|
|
297
|
-
width:
|
|
298
|
-
}))),
|
|
299
|
-
data:
|
|
300
|
-
datasource:
|
|
301
|
-
error:
|
|
302
|
-
isFetching:
|
|
303
|
-
} =
|
|
235
|
+
flex: !l.width && !l.maxWidth ? 1 : void 0,
|
|
236
|
+
headerName: l.label,
|
|
237
|
+
maxWidth: l.maxWidth,
|
|
238
|
+
minWidth: l.minWidth,
|
|
239
|
+
valueGetter: (g) => g.data?.[l.key],
|
|
240
|
+
width: l.width
|
|
241
|
+
}))), y = C(() => [e.fetcher, e.pageSize, e.refreshKey]), {
|
|
242
|
+
data: f,
|
|
243
|
+
datasource: d,
|
|
244
|
+
error: k,
|
|
245
|
+
isFetching: h
|
|
246
|
+
} = te({
|
|
304
247
|
fetcher: e.fetcher,
|
|
305
|
-
resetKey:
|
|
248
|
+
resetKey: y
|
|
306
249
|
}), {
|
|
307
|
-
fetchState:
|
|
308
|
-
hasData:
|
|
309
|
-
state:
|
|
310
|
-
} =
|
|
311
|
-
|
|
312
|
-
emitState: (
|
|
313
|
-
fetchLifecycleState:
|
|
314
|
-
hasData:
|
|
250
|
+
fetchState: S,
|
|
251
|
+
hasData: b,
|
|
252
|
+
state: E
|
|
253
|
+
} = X(f, k, h), N = C(() => E.value === S.SUCCESS && !b.value);
|
|
254
|
+
Y({
|
|
255
|
+
emitState: (l) => o("state", l),
|
|
256
|
+
fetchLifecycleState: E,
|
|
257
|
+
hasData: b
|
|
315
258
|
});
|
|
316
|
-
const
|
|
317
|
-
|
|
259
|
+
const m = (l) => {
|
|
260
|
+
o("grid:ready", l.api);
|
|
318
261
|
};
|
|
319
|
-
return (
|
|
320
|
-
const
|
|
321
|
-
return w(),
|
|
322
|
-
e.error ? (w(),
|
|
323
|
-
|
|
324
|
-
|
|
262
|
+
return (l, B) => {
|
|
263
|
+
const g = W("KEmptyState");
|
|
264
|
+
return w(), M("div", ne, [
|
|
265
|
+
e.error ? (w(), M("div", ie, [
|
|
266
|
+
O(l.$slots, "error-state", {}, () => [
|
|
267
|
+
A(g, {
|
|
325
268
|
"icon-variant": "error",
|
|
326
|
-
message:
|
|
327
|
-
title:
|
|
269
|
+
message: v(a)("errorState.message"),
|
|
270
|
+
title: v(a)("errorState.title")
|
|
328
271
|
}, null, 8, ["message", "title"])
|
|
329
272
|
], !0)
|
|
330
|
-
])) :
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
message:
|
|
334
|
-
title:
|
|
273
|
+
])) : N.value ? (w(), M("div", le, [
|
|
274
|
+
O(l.$slots, "empty-state", {}, () => [
|
|
275
|
+
A(g, {
|
|
276
|
+
message: v(a)("emptyState.message"),
|
|
277
|
+
title: v(a)("emptyState.title")
|
|
335
278
|
}, null, 8, ["message", "title"])
|
|
336
279
|
], !0)
|
|
337
|
-
])) : (w(),
|
|
280
|
+
])) : (w(), V(v(x), {
|
|
338
281
|
key: 2,
|
|
339
282
|
"cache-block-size": e.pageSize,
|
|
340
283
|
class: "table-data-grid-grid",
|
|
341
|
-
"column-defs":
|
|
342
|
-
datasource:
|
|
343
|
-
"default-col-def":
|
|
284
|
+
"column-defs": p.value,
|
|
285
|
+
datasource: v(d),
|
|
286
|
+
"default-col-def": i,
|
|
344
287
|
"infinite-initial-row-count": 1,
|
|
345
|
-
loading:
|
|
288
|
+
loading: v(h),
|
|
346
289
|
"row-model-type": "infinite",
|
|
347
290
|
"suppress-cell-focus": !0,
|
|
348
|
-
theme:
|
|
349
|
-
onGridReady:
|
|
291
|
+
theme: v(Q),
|
|
292
|
+
onGridReady: m
|
|
350
293
|
}, null, 8, ["cache-block-size", "column-defs", "datasource", "loading", "theme"]))
|
|
351
294
|
]);
|
|
352
295
|
};
|
|
353
296
|
}
|
|
354
|
-
}),
|
|
355
|
-
const
|
|
356
|
-
for (const [
|
|
357
|
-
a
|
|
358
|
-
return
|
|
359
|
-
},
|
|
297
|
+
}), ue = (e, c) => {
|
|
298
|
+
const o = e.__vccOpts || e;
|
|
299
|
+
for (const [a, i] of c)
|
|
300
|
+
o[a] = i;
|
|
301
|
+
return o;
|
|
302
|
+
}, he = /* @__PURE__ */ ue(ce, [["__scopeId", "data-v-87a96f8f"]]);
|
|
360
303
|
export {
|
|
361
|
-
|
|
304
|
+
he as TableDataGrid
|
|
362
305
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(f,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):(f=typeof globalThis<"u"?globalThis:f||self,e(f["kong-ui-public-table-data-grid"]={},f.Vue,f.AgGridVue,f.agGridCommunity,f["kong-ui-public-i18n"]))})(this,(function(f,e,M,v,G){"use strict";var D=(t=>(t.PENDING="PENDING",t.LOADING="LOADING",t.SUCCESS="SUCCESS",t.ERROR="ERROR",t))(D||{});const F=t=>!!t?.length;function O(t,u,r,o=F){const c=e.computed(()=>o(t.value)),g=e.computed(()=>{const p=t.value!==void 0,m=u.value!==void 0&&u.value!==null;return r.value?"LOADING":c.value?"SUCCESS":m?"ERROR":p?"SUCCESS":"PENDING"});return{fetchState:D,hasData:c,state:g}}const _=({emitState:t,fetchLifecycleState:u,hasData:r})=>{e.watch(()=>({hasData:r.value,state:u.value}),({hasData:o,state:c})=>{if(c!==D.PENDING){if(c===D.LOADING){t({hasData:o,state:"loading"});return}if(c===D.ERROR){t({hasData:o,state:"error"});return}t({hasData:o,state:"success"})}})},z=({startRow:t,endRow:u})=>{const r=u-t;return{blockIndex:r>0?Math.floor(t/r):0,pageSize:r}},T=({startRow:t,rowsLength:u,pageSize:r,total:o,hasMore:c})=>{if(typeof o=="number")return o;if(c!==!0&&(c===!1||u<r))return t+u},A=({fetcher:t,resetKey:u})=>{const r=new Map,o=new Map,c=e.ref(0),g=e.shallowRef(),S=e.shallowRef(),p=e.shallowRef(),m=e.ref(0),C=e.ref(!1),y=a=>a===c.value,b=()=>{C.value=m.value>0},E=()=>{p.value=void 0,m.value+=1,b()},R=()=>{m.value=Math.max(0,m.value-1),b()},w=a=>{const n=o.get(a);if(n)return n;let s;const d={promise:new Promise(i=>{s=i}),resolve:i=>s(i)};return o.set(a,d),d},h=(a,n)=>{n.resolve(!1),o.get(a)===n&&o.delete(a)},l=async({blockIndex:a,currentBlockCompletion:n,datasourceId:s})=>{if(a===0)return"ready";const d=o.get(a-1);if(!d)return h(a,n),"failed";const i=await d.promise;return y(s)?i?"ready":(h(a,n),"failed"):(h(a,n),"stale")},B=({blockIndex:a,currentBlockCompletion:n,getRowsParams:s,pageSize:d,result:i})=>{i.cursor!==void 0&&r.set(a,i.cursor),s.successCallback(i.data,T({startRow:s.startRow,rowsLength:i.data.length,pageSize:d,total:i.total,hasMore:i.hasMore})),s.startRow===0&&(S.value=i.data),n.resolve(!0)},k=({blockIndex:a,currentBlockCompletion:n,fetchError:s,getRowsParams:d})=>{p.value=s,d.failCallback(),h(a,n)},q=()=>{const a=c.value+1;return c.value=a,r.clear(),o.clear(),S.value=void 0,p.value=void 0,m.value=0,b(),{async getRows(n){const{blockIndex:s,pageSize:d}=z({startRow:n.startRow,endRow:n.endRow}),i=w(s),I=await l({blockIndex:s,currentBlockCompletion:i,datasourceId:a});if(I!=="ready"){I==="failed"&&n.failCallback();return}E();try{const N=s>0?r.get(s-1):void 0,$=await t({mode:"infinite",pageSize:d,cursor:N});if(!y(a)){h(s,i);return}B({blockIndex:s,currentBlockCompletion:i,getRowsParams:n,pageSize:d,result:$})}catch(N){if(!y(a)){h(s,i);return}k({blockIndex:s,currentBlockCompletion:i,fetchError:N,getRowsParams:n})}finally{y(a)&&R()}}}},j=()=>{g.value=q()};return e.watch(()=>u?.value,()=>{j()},{immediate:!0}),{datasource:e.readonly(g),data:e.readonly(S),error:e.readonly(p),isFetching:e.readonly(C)}},L={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 V(){const t=G.createI18n("en-us",L);return{i18n:t,i18nT:G.i18nTComponent(t)}}const x={class:"kong-ui-public-table-data-grid","data-testid":"table-data-grid"},K={key:0,class:"table-error-state","data-testid":"table-error-state"},U={key:1,class:"table-empty-state","data-testid":"table-empty-state"},W=((t,u)=>{const r=t.__vccOpts||t;for(const[o,c]of u)r[o]=c;return r})(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:u}){v.ModuleRegistry.registerModules([v.AllCommunityModule,v.InfiniteRowModelModule]);const r=u,{i18n:{t:o}}=V(),c={resizable:!1,sortable:!1,suppressMovable:!0},g=e.computed(()=>t.headers.map(l=>({colId:l.key,flex:!l.width&&!l.maxWidth?1:void 0,headerName:l.label,maxWidth:l.maxWidth,minWidth:l.minWidth,valueGetter:k=>k.data?.[l.key],width:l.width}))),S=e.computed(()=>[t.fetcher,t.pageSize,t.refreshKey]),{data:p,datasource:m,error:C,isFetching:y}=A({fetcher:t.fetcher,resetKey:S}),{fetchState:b,hasData:E,state:R}=O(p,C,y),w=e.computed(()=>R.value===b.SUCCESS&&!E.value);_({emitState:l=>r("state",l),fetchLifecycleState:R,hasData:E});const h=l=>{r("grid:ready",l.api)};return(l,B)=>{const k=e.resolveComponent("KEmptyState");return e.openBlock(),e.createElementBlock("div",x,[t.error?(e.openBlock(),e.createElementBlock("div",K,[e.renderSlot(l.$slots,"error-state",{},()=>[e.createVNode(k,{"icon-variant":"error",message:e.unref(o)("errorState.message"),title:e.unref(o)("errorState.title")},null,8,["message","title"])],!0)])):w.value?(e.openBlock(),e.createElementBlock("div",U,[e.renderSlot(l.$slots,"empty-state",{},()=>[e.createVNode(k,{message:e.unref(o)("emptyState.message"),title:e.unref(o)("emptyState.title")},null,8,["message","title"])],!0)])):(e.openBlock(),e.createBlock(e.unref(M.AgGridVue),{key:2,"cache-block-size":t.pageSize,class:"table-data-grid-grid","column-defs":g.value,datasource:e.unref(m),"default-col-def":c,"infinite-initial-row-count":1,loading:e.unref(y),"row-model-type":"infinite","suppress-cell-focus":!0,theme:e.unref(v.themeQuartz),onGridReady:h},null,8,["cache-block-size","column-defs","datasource","loading","theme"]))])}}}),[["__scopeId","data-v-87a96f8f"]]);f.TableDataGrid=W,Object.defineProperty(f,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":"AAgMA,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAAU,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAc/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;WAoNO,OAAO,KAAK,EAAE,WAAW,GAAG,mBAAmB,CAAC;iBAhN7C,KAAK,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;iBAC/B,oBAAoB,CAAC,GAAG,CAAC;gBAC1B,OAAO;mBACJ,MAAM;qBACJ,MAAM,GAAG,MAAM,GAAG,OAAO;;;;KA4MmD,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;;uBAlMM,MAAM,OAAO;uBACb,MAAM,OAAO;;;YAKxB,YAAY,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,IAAI;YACpD,OAAO,WAAW,yBAAyB,GAAG,IAAI;;EA+LpD,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kong-ui-public/table-data-grid",
|
|
3
|
-
"version": "0.3.4
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/table-data-grid.umd.js",
|
|
6
6
|
"module": "./dist/table-data-grid.es.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"access": "public"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@kong/kongponents": "9.61.
|
|
24
|
+
"@kong/kongponents": "9.61.6",
|
|
25
25
|
"vue": "^3.5.35",
|
|
26
26
|
"@kong-ui-public/i18n": "^2.5.0"
|
|
27
27
|
},
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|