@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 CHANGED
@@ -1 +1 @@
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
+ .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 { 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";
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: F,
70
- hasData: r,
71
- state: h
13
+ fetchState: D,
14
+ hasData: i,
15
+ state: p
72
16
  };
73
17
  }
74
- const se = ({
18
+ const Y = ({
75
19
  emitState: e,
76
- fetchLifecycleState: i,
77
- hasData: a
20
+ fetchLifecycleState: c,
21
+ hasData: o
78
22
  }) => {
79
- O(
23
+ L(
80
24
  () => ({
81
- hasData: a.value,
82
- state: i.value
25
+ hasData: o.value,
26
+ state: c.value
83
27
  }),
84
- ({ hasData: t, state: r }) => {
85
- if (r !== F.PENDING) {
86
- if (r === F.LOADING) {
28
+ ({ hasData: a, state: i }) => {
29
+ if (i !== D.PENDING) {
30
+ if (i === D.LOADING) {
87
31
  e({
88
- hasData: t,
32
+ hasData: a,
89
33
  state: "loading"
90
34
  });
91
35
  return;
92
36
  }
93
- if (r === F.ERROR) {
37
+ if (i === D.ERROR) {
94
38
  e({
95
- hasData: t,
39
+ hasData: a,
96
40
  state: "error"
97
41
  });
98
42
  return;
99
43
  }
100
44
  e({
101
- hasData: t,
45
+ hasData: a,
102
46
  state: "success"
103
47
  });
104
48
  }
105
49
  }
106
50
  );
107
- }, le = ({ startRow: e, endRow: i }) => {
108
- const a = i - e;
51
+ }, Z = ({ startRow: e, endRow: c }) => {
52
+ const o = c - e;
109
53
  return {
110
- blockIndex: a > 0 ? Math.floor(e / a) : 0,
111
- pageSize: a
54
+ blockIndex: o > 0 ? Math.floor(e / o) : 0,
55
+ pageSize: o
112
56
  };
113
- }, ie = ({
57
+ }, ee = ({
114
58
  startRow: e,
115
- rowsLength: i,
116
- pageSize: a,
117
- total: t,
118
- hasMore: r
59
+ rowsLength: c,
60
+ pageSize: o,
61
+ total: a,
62
+ hasMore: i
119
63
  }) => {
120
- if (typeof t == "number")
121
- return t;
122
- if (r !== !0 && (r === !1 || i < a))
123
- return e + i;
124
- }, ce = ({
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: i
70
+ resetKey: c
127
71
  }) => {
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;
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 v = {
140
- promise: new Promise((l) => {
141
- s = l;
83
+ const u = {
84
+ promise: new Promise((n) => {
85
+ s = n;
142
86
  }),
143
- resolve: (l) => s(l)
87
+ resolve: (n) => s(n)
144
88
  };
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,
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 (o === 0)
97
+ if (t === 0)
154
98
  return "ready";
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,
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: v,
165
- result: l
108
+ pageSize: u,
109
+ result: n
166
110
  }) => {
167
- l.cursor !== void 0 && a.set(o, l.cursor), s.successCallback(l.data, ie({
111
+ n.cursor !== void 0 && o.set(t, n.cursor), s.successCallback(n.data, ee({
168
112
  startRow: s.startRow,
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,
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: v
122
+ getRowsParams: u
179
123
  }) => {
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) {
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: v
188
- } = le({
189
- startRow: n.startRow,
190
- endRow: n.endRow
191
- }), l = k(s), z = await c({
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: l,
194
- datasourceId: o
137
+ currentBlockCompletion: n,
138
+ datasourceId: t
195
139
  });
196
140
  if (z !== "ready") {
197
- z === "failed" && n.failCallback();
141
+ z === "failed" && r.failCallback();
198
142
  return;
199
143
  }
200
- d();
144
+ b();
201
145
  try {
202
- const B = s > 0 ? a.get(s - 1) : void 0, U = await e({
146
+ const G = s > 0 ? o.get(s - 1) : void 0, T = await e({
203
147
  mode: "infinite",
204
- pageSize: v,
205
- cursor: B
148
+ pageSize: u,
149
+ cursor: G
206
150
  });
207
- if (!p(o)) {
208
- b(s, l);
151
+ if (!h(t)) {
152
+ m(s, n);
209
153
  return;
210
154
  }
211
- M({
155
+ B({
212
156
  blockIndex: s,
213
- currentBlockCompletion: l,
214
- getRowsParams: n,
215
- pageSize: v,
216
- result: U
157
+ currentBlockCompletion: n,
158
+ getRowsParams: r,
159
+ pageSize: u,
160
+ result: T
217
161
  });
218
- } catch (B) {
219
- if (!p(o)) {
220
- b(s, l);
162
+ } catch (G) {
163
+ if (!h(t)) {
164
+ m(s, n);
221
165
  return;
222
166
  }
223
- D({
167
+ g({
224
168
  blockIndex: s,
225
- currentBlockCompletion: l,
226
- fetchError: B,
227
- getRowsParams: n
169
+ currentBlockCompletion: n,
170
+ fetchError: G,
171
+ getRowsParams: r
228
172
  });
229
173
  } finally {
230
- p(o) && y();
174
+ h(t) && E();
231
175
  }
232
176
  }
233
177
  };
234
- }, L = () => {
235
- h.value = K();
178
+ }, K = () => {
179
+ p.value = _();
236
180
  };
237
- return O(
238
- () => i?.value,
181
+ return L(
182
+ () => c?.value,
239
183
  () => {
240
- L();
184
+ K();
241
185
  },
242
186
  { immediate: !0 }
243
187
  ), {
244
- datasource: _(h),
245
- data: _(f),
246
- error: _(u),
247
- isFetching: _(C)
188
+ datasource: R(p),
189
+ data: R(y),
190
+ error: R(f),
191
+ isFetching: R(k)
248
192
  };
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
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 me() {
254
- const e = ee("en-us", fe);
197
+ function se() {
198
+ const e = q("en-us", re);
255
199
  return {
256
200
  i18n: e,
257
- i18nT: te(e)
201
+ i18nT: J(e)
258
202
  // Translation component <i18n-t>
259
203
  };
260
204
  }
261
- const ve = {
205
+ const ne = {
262
206
  class: "kong-ui-public-table-data-grid",
263
207
  "data-testid": "table-data-grid"
264
- }, pe = {
208
+ }, ie = {
265
209
  key: 0,
266
210
  class: "table-error-state",
267
211
  "data-testid": "table-error-state"
268
- }, he = {
212
+ }, le = {
269
213
  key: 1,
270
214
  class: "table-empty-state",
271
215
  "data-testid": "table-empty-state"
272
- }, ge = /* @__PURE__ */ A({
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: i }) {
283
- J.registerModules([X, Y]);
284
- const a = i, { i18n: { t } } = me(), r = {
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
- }, h = E(() => e.headers.map((c) => ({
290
- colId: c.key,
232
+ }, p = C(() => e.headers.map((l) => ({
233
+ colId: l.key,
291
234
  // Headers without explicit width constraints should fill available space.
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({
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: f
248
+ resetKey: y
306
249
  }), {
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
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 b = (c) => {
317
- a("grid:ready", c.api);
259
+ const m = (l) => {
260
+ o("grid:ready", l.api);
318
261
  };
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, {
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: S(t)("errorState.message"),
327
- title: S(t)("errorState.title")
269
+ message: v(a)("errorState.message"),
270
+ title: v(a)("errorState.title")
328
271
  }, null, 8, ["message", "title"])
329
272
  ], !0)
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")
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(), P(S(Q), {
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": h.value,
342
- datasource: S(m),
343
- "default-col-def": r,
284
+ "column-defs": p.value,
285
+ datasource: v(d),
286
+ "default-col-def": i,
344
287
  "infinite-initial-row-count": 1,
345
- loading: S(p),
288
+ loading: v(h),
346
289
  "row-model-type": "infinite",
347
290
  "suppress-cell-focus": !0,
348
- theme: S(Z),
349
- onGridReady: b
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
- }), 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"]]);
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
- Ee as TableDataGrid
304
+ he as TableDataGrid
362
305
  };
@@ -1 +1 @@
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
+ (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":"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,GAA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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.5",
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"}