@kong-ui-public/table-data-grid 0.4.2-pr.3761.bed46084d.0 → 0.5.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/README.md CHANGED
@@ -3,8 +3,8 @@
3
3
  Reusable Vue wrapper around AG Grid for Kong table data grids.
4
4
 
5
5
  This package currently supports AG Grid infinite row loading with a cursor-first
6
- fetcher contract, basic column definitions, empty/error presentation states, and
7
- state lifecycle emits.
6
+ fetcher contract, basic column definitions, single-column sorting, empty/error
7
+ presentation states, and state lifecycle emits.
8
8
 
9
9
  ## Peer Dependencies
10
10
 
@@ -147,11 +147,11 @@ type TableDataGridFetcher<Row> = (
147
147
  `cursor` is an opaque token returned by the previous response. The first request
148
148
  uses `cursor: undefined`; later requests receive the previous response cursor.
149
149
 
150
- `sort` is the current single-column sort, or `undefined` when nothing is
151
- sorted. A sort change is a request-context change like `refreshKey` or
152
- `pageSize`: it rebuilds the datasource and restarts the cursor chain from the
153
- beginning, because a cursor produced under one sort order is not valid under
154
- another.
150
+ `sort` carries the current single-column sort, with `sortColumnKey` and
151
+ `sortColumnOrder` left `undefined` when nothing is sorted. A sort change is a
152
+ request-context change like `refreshKey` or `pageSize`: it rebuilds the
153
+ datasource and restarts the cursor chain from the beginning, because a cursor
154
+ produced under one sort order is not valid under another.
155
155
 
156
156
  AG Grid range details are datasource internals. Consumers should not depend on,
157
157
  or return, datasource request positions or AG Grid row-count callback values in
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-2bcd2d90]{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-2bcd2d90]{--ag-background-color: var(--kui-color-background, #ffffff);--ag-border-color: var(--kui-color-border, #e0e4ea);--ag-foreground-color: var(--kui-color-text, #0d0e14);--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
+ .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-d8328fe5]{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-d8328fe5]{--ag-background-color: var(--kui-color-background, #ffffff);--ag-border-color: var(--kui-color-border, #e0e4ea);--ag-foreground-color: var(--kui-color-text, #0d0e14);--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,40 +1,40 @@
1
- import { computed as h, watch as M, ref as N, shallowRef as G, readonly as T, defineComponent as $, onMounted as j, onUnmounted as H, nextTick as Q, resolveComponent as q, openBlock as I, createBlock as P, resolveDynamicComponent as J, createElementBlock as B, createVNode as A, withCtx as X, createElementVNode as Y, toDisplayString as Z, useSlots as ee, toRef as x, renderSlot as V, unref as g } from "vue";
1
+ import { computed as S, watch as B, ref as E, shallowRef as G, readonly as x, defineComponent as $, onMounted as j, onUnmounted as H, nextTick as Q, resolveComponent as q, openBlock as I, createBlock as P, resolveDynamicComponent as J, createElementBlock as N, createVNode as L, withCtx as X, createElementVNode as Y, toDisplayString as Z, useSlots as ee, toRef as O, renderSlot as V, unref as y } from "vue";
2
2
  import { AgGridVue as te } from "ag-grid-vue3";
3
3
  import { ModuleRegistry as oe, AllCommunityModule as ae, InfiniteRowModelModule as le, themeQuartz as re } from "ag-grid-community";
4
4
  import { createI18n as ne, i18nTComponent as se } from "@kong-ui-public/i18n";
5
- var z = /* @__PURE__ */ ((e) => (e.PENDING = "PENDING", e.LOADING = "LOADING", e.SUCCESS = "SUCCESS", e.ERROR = "ERROR", e))(z || {});
5
+ var T = /* @__PURE__ */ ((e) => (e.PENDING = "PENDING", e.LOADING = "LOADING", e.SUCCESS = "SUCCESS", e.ERROR = "ERROR", e))(T || {});
6
6
  const ie = (e) => !!e?.length;
7
- function ce(e, n, t, l = ie) {
8
- const r = h(() => l(e.value)), s = h(() => {
9
- const m = e.value !== void 0, a = n.value !== void 0 && n.value !== null;
10
- return t.value ? "LOADING" : r.value ? "SUCCESS" : a ? "ERROR" : m ? "SUCCESS" : "PENDING";
7
+ function ce(e, r, t, l = ie) {
8
+ const n = S(() => l(e.value)), i = S(() => {
9
+ const f = e.value !== void 0, a = r.value !== void 0 && r.value !== null;
10
+ return t.value ? "LOADING" : n.value ? "SUCCESS" : a ? "ERROR" : f ? "SUCCESS" : "PENDING";
11
11
  });
12
12
  return {
13
- fetchState: z,
14
- hasData: r,
15
- state: s
13
+ fetchState: T,
14
+ hasData: n,
15
+ state: i
16
16
  };
17
17
  }
18
18
  const ue = ({
19
19
  emitState: e,
20
- fetchLifecycleState: n,
20
+ fetchLifecycleState: r,
21
21
  hasData: t
22
22
  }) => {
23
- M(
23
+ B(
24
24
  () => ({
25
25
  hasData: t.value,
26
- state: n.value
26
+ state: r.value
27
27
  }),
28
- ({ hasData: l, state: r }) => {
29
- if (r !== z.PENDING) {
30
- if (r === z.LOADING) {
28
+ ({ hasData: l, state: n }) => {
29
+ if (n !== T.PENDING) {
30
+ if (n === T.LOADING) {
31
31
  e({
32
32
  hasData: l,
33
33
  state: "loading"
34
34
  });
35
35
  return;
36
36
  }
37
- if (r === z.ERROR) {
37
+ if (n === T.ERROR) {
38
38
  e({
39
39
  hasData: l,
40
40
  state: "error"
@@ -48,148 +48,150 @@ const ue = ({
48
48
  }
49
49
  }
50
50
  );
51
- }, de = ({ startRow: e, endRow: n }) => {
52
- const t = n - e;
51
+ }, de = ({ startRow: e, endRow: r }) => {
52
+ const t = r - e;
53
53
  return {
54
54
  blockIndex: t > 0 ? Math.floor(e / t) : 0,
55
55
  pageSize: t
56
56
  };
57
57
  }, me = ({
58
58
  startRow: e,
59
- rowsLength: n,
59
+ rowsLength: r,
60
60
  pageSize: t,
61
61
  total: l,
62
- hasMore: r
62
+ hasMore: n
63
63
  }) => {
64
64
  if (typeof l == "number")
65
65
  return l;
66
- if (r !== !0 && (r === !1 || n < t))
67
- return e + n;
66
+ if (n !== !0 && (n === !1 || r < t))
67
+ return e + r;
68
68
  }, fe = ({
69
69
  fetcher: e,
70
- resetKey: n,
70
+ resetKey: r,
71
71
  sort: t
72
72
  }) => {
73
- const l = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), s = N(0), o = G(), m = G(), a = G(), c = N(!1), d = (i) => i === s.value, S = (i) => {
74
- const v = r.get(i);
75
- if (v)
76
- return v;
77
- let y;
78
- const C = {
79
- promise: new Promise((u) => {
80
- y = u;
73
+ const l = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), i = E(0), o = G(), f = G(), a = G(), s = E(0), v = E(!1), g = (c) => c === i.value, k = () => {
74
+ v.value = s.value > 0;
75
+ }, D = () => {
76
+ a.value = void 0, s.value += 1, k();
77
+ }, w = () => {
78
+ s.value = Math.max(0, s.value - 1), k();
79
+ }, C = (c) => {
80
+ const u = n.get(c);
81
+ if (u)
82
+ return u;
83
+ let d;
84
+ const h = {
85
+ promise: new Promise((m) => {
86
+ d = m;
81
87
  }),
82
- resolve: (u) => y(u)
88
+ resolve: (m) => d(m)
83
89
  };
84
- return r.set(i, C), C;
85
- }, b = (i, v) => {
86
- v.resolve(!1), r.get(i) === v && r.delete(i);
87
- }, D = async ({
88
- blockIndex: i,
89
- currentBlockCompletion: v,
90
- datasourceId: y
90
+ return n.set(c, h), h;
91
+ }, b = (c, u) => {
92
+ u.resolve(!1), n.get(c) === u && n.delete(c);
93
+ }, K = async ({
94
+ blockIndex: c,
95
+ currentBlockCompletion: u,
96
+ datasourceId: d
91
97
  }) => {
92
- if (i === 0)
98
+ if (c === 0)
93
99
  return "ready";
94
- const C = r.get(i - 1);
95
- if (!C)
96
- return b(i, v), "failed";
97
- const u = await C.promise;
98
- return d(y) ? u ? "ready" : (b(i, v), "failed") : (b(i, v), "stale");
99
- }, R = ({
100
- blockIndex: i,
101
- currentBlockCompletion: v,
102
- getRowsParams: y,
103
- pageSize: C,
104
- result: u
100
+ const h = n.get(c - 1);
101
+ if (!h)
102
+ return b(c, u), "failed";
103
+ const m = await h.promise;
104
+ return g(d) ? m ? "ready" : (b(c, u), "failed") : (b(c, u), "stale");
105
+ }, M = ({
106
+ blockIndex: c,
107
+ currentBlockCompletion: u,
108
+ getRowsParams: d,
109
+ pageSize: h,
110
+ result: m
105
111
  }) => {
106
- u.cursor !== void 0 && l.set(i, u.cursor), y.successCallback(u.data, me({
107
- startRow: y.startRow,
108
- rowsLength: u.data.length,
109
- pageSize: C,
110
- total: u.total,
111
- hasMore: u.hasMore
112
- })), y.startRow === 0 && (m.value = u.data), v.resolve(!0);
113
- }, f = ({
114
- blockIndex: i,
115
- currentBlockCompletion: v,
116
- fetchError: y,
117
- getRowsParams: C
112
+ m.cursor !== void 0 && l.set(c, m.cursor), d.successCallback(m.data, me({
113
+ startRow: d.startRow,
114
+ rowsLength: m.data.length,
115
+ pageSize: h,
116
+ total: m.total,
117
+ hasMore: m.hasMore
118
+ })), d.startRow === 0 && (f.value = m.data), u.resolve(!0);
119
+ }, _ = ({
120
+ blockIndex: c,
121
+ currentBlockCompletion: u,
122
+ fetchError: d,
123
+ getRowsParams: h
118
124
  }) => {
119
- a.value = y, C.failCallback(), b(i, v);
120
- }, w = () => {
121
- const i = s.value + 1;
122
- s.value = i, l.clear(), r.clear(), m.value = void 0, a.value = void 0;
123
- let v = 0;
124
- const y = () => {
125
- d(i) && (c.value = v > 0);
126
- };
127
- return y(), {
128
- async getRows(C) {
125
+ a.value = d, h.failCallback(), b(c, u);
126
+ }, A = () => {
127
+ const c = i.value + 1;
128
+ return i.value = c, l.clear(), n.clear(), f.value = void 0, a.value = void 0, s.value = 0, k(), {
129
+ async getRows(u) {
129
130
  const {
130
- blockIndex: u,
131
- pageSize: F
131
+ blockIndex: d,
132
+ pageSize: h
132
133
  } = de({
133
- startRow: C.startRow,
134
- endRow: C.endRow
135
- }), k = S(u), E = await D({
136
- blockIndex: u,
137
- currentBlockCompletion: k,
138
- datasourceId: i
139
- });
140
- if (E !== "ready") {
141
- E === "failed" && C.failCallback();
134
+ startRow: u.startRow,
135
+ endRow: u.endRow
136
+ }), m = C(d);
137
+ if (await K({
138
+ blockIndex: d,
139
+ currentBlockCompletion: m,
140
+ datasourceId: c
141
+ }) !== "ready") {
142
+ u.failCallback();
142
143
  return;
143
144
  }
144
- d(i) && (a.value = void 0), v += 1, y();
145
+ g(c) && D();
145
146
  try {
146
- const O = u > 0 ? l.get(u - 1) : void 0, _ = await e({
147
+ const R = d > 0 ? l.get(d - 1) : void 0, z = await e({
147
148
  mode: "infinite",
148
- pageSize: F,
149
- cursor: O,
149
+ pageSize: h,
150
+ cursor: R,
151
+ // Always read the latest sort, not a stale one.
150
152
  sort: t?.value
151
153
  });
152
- if (!d(i)) {
153
- C.failCallback(), b(u, k);
154
+ if (!g(c)) {
155
+ u.failCallback(), b(d, m);
154
156
  return;
155
157
  }
156
- R({
157
- blockIndex: u,
158
- currentBlockCompletion: k,
159
- getRowsParams: C,
160
- pageSize: F,
161
- result: _
158
+ M({
159
+ blockIndex: d,
160
+ currentBlockCompletion: m,
161
+ getRowsParams: u,
162
+ pageSize: h,
163
+ result: z
162
164
  });
163
- } catch (O) {
164
- if (!d(i)) {
165
- C.failCallback(), b(u, k);
165
+ } catch (R) {
166
+ if (!g(c)) {
167
+ u.failCallback(), b(d, m);
166
168
  return;
167
169
  }
168
- f({
169
- blockIndex: u,
170
- currentBlockCompletion: k,
171
- fetchError: O,
172
- getRowsParams: C
170
+ _({
171
+ blockIndex: d,
172
+ currentBlockCompletion: m,
173
+ fetchError: R,
174
+ getRowsParams: u
173
175
  });
174
176
  } finally {
175
- v = Math.max(0, v - 1), y();
177
+ g(c) && w();
176
178
  }
177
179
  }
178
180
  };
179
- }, K = () => {
180
- o.value = w();
181
+ }, F = () => {
182
+ o.value = A();
181
183
  };
182
- return M(
183
- () => n?.value,
184
+ return B(
185
+ () => r?.value,
184
186
  () => {
185
- K();
187
+ F();
186
188
  },
187
189
  { immediate: !0 }
188
190
  ), {
189
- datasource: T(o),
190
- data: T(m),
191
- error: T(a),
192
- isFetching: T(c)
191
+ datasource: x(o),
192
+ data: x(f),
193
+ error: x(a),
194
+ isFetching: x(v)
193
195
  };
194
196
  }, ve = {
195
197
  key: 1,
@@ -200,63 +202,63 @@ const ue = ({
200
202
  props: {
201
203
  params: {}
202
204
  },
203
- setup(e, { expose: n }) {
204
- const t = G(e.params), l = N(null), r = N(!1), s = h(() => t.value.valueFormatted ?? String(t.value.value ?? "")), o = h(() => {
205
- const f = t.value.colDef?.colId;
206
- return f ? t.value.context?.cells?.slots?.[f] : void 0;
207
- }), m = h(() => ({
205
+ setup(e, { expose: r }) {
206
+ const t = G(e.params), l = E(null), n = E(!1), i = S(() => t.value.valueFormatted ?? String(t.value.value ?? "")), o = S(() => {
207
+ const C = t.value.colDef?.colId;
208
+ return C ? t.value.context?.cells?.slots?.[C] : void 0;
209
+ }), f = S(() => ({
208
210
  column: t.value.headerDef,
209
211
  refreshCell: () => {
210
- const f = t.value.node;
211
- f && t.value.api.refreshCells({ force: !0, rowNodes: [f] });
212
+ const C = t.value.node;
213
+ C && t.value.api.refreshCells({ force: !0, rowNodes: [C] });
212
214
  },
213
215
  row: t.value.data ?? {},
214
216
  rowIndex: t.value.node?.rowIndex ?? 0,
215
217
  rowValue: t.value.value,
216
218
  selected: t.value.node?.isSelected() ?? !1
217
- })), a = () => o.value?.(m.value);
218
- let c, d, S = !1;
219
- const b = () => {
220
- const f = l.value;
221
- r.value = !!f && f.scrollWidth > f.clientWidth;
219
+ })), a = () => o.value?.(f.value);
220
+ let s, v, g = !1;
221
+ const k = () => {
222
+ const C = l.value;
223
+ n.value = !!C && C.scrollWidth > C.clientWidth;
222
224
  }, D = () => {
223
- S || (d !== void 0 && cancelAnimationFrame(d), d = requestAnimationFrame(() => {
224
- d = void 0, b();
225
+ g || (v !== void 0 && cancelAnimationFrame(v), v = requestAnimationFrame(() => {
226
+ v = void 0, k();
225
227
  }));
226
- }, R = (f) => {
227
- if (c?.disconnect(), f) {
228
- c?.observe(f);
229
- const w = f.closest(".ag-cell");
230
- w && c?.observe(w);
228
+ }, w = (C) => {
229
+ if (s?.disconnect(), C) {
230
+ s?.observe(C);
231
+ const b = C.closest(".ag-cell");
232
+ b && s?.observe(b);
231
233
  }
232
234
  D();
233
235
  };
234
236
  return j(() => {
235
- c = new ResizeObserver(D), R(l.value);
236
- }), M(l, R, { flush: "post" }), H(() => {
237
- S = !0, c?.disconnect(), d !== void 0 && cancelAnimationFrame(d);
238
- }), n({
239
- refresh(f) {
240
- return t.value = f, Q(D), !0;
237
+ s = new ResizeObserver(D), w(l.value);
238
+ }), B(l, w, { flush: "post" }), H(() => {
239
+ g = !0, s?.disconnect(), v !== void 0 && cancelAnimationFrame(v);
240
+ }), r({
241
+ refresh(C) {
242
+ return t.value = C, Q(D), !0;
241
243
  }
242
- }), (f, w) => {
244
+ }), (C, b) => {
243
245
  const K = q("KTooltip");
244
- return o.value ? (I(), P(J(a), { key: 0 })) : (I(), B("span", ve, [
245
- A(K, {
246
+ return o.value ? (I(), P(J(a), { key: 0 })) : (I(), N("span", ve, [
247
+ L(K, {
246
248
  class: "table-data-grid-cell-tooltip",
247
- disabled: !r.value,
249
+ disabled: !n.value,
248
250
  "kpop-attributes": { popoverDelay: 400 },
249
251
  "max-width": "300",
250
252
  placement: "bottom-start",
251
253
  target: "body",
252
- text: s.value
254
+ text: i.value
253
255
  }, {
254
256
  default: X(() => [
255
257
  Y("span", {
256
258
  ref_key: "contentElement",
257
259
  ref: l,
258
260
  class: "table-data-grid-cell-content"
259
- }, Z(s.value), 513)
261
+ }, Z(i.value), 513)
260
262
  ]),
261
263
  _: 1
262
264
  }, 8, ["disabled", "text"])
@@ -265,13 +267,13 @@ const ue = ({
265
267
  }
266
268
  }), pe = ({
267
269
  headers: e,
268
- slots: n,
270
+ slots: r,
269
271
  initialSort: t
270
272
  }) => {
271
- const l = h(() => ({
272
- cells: { slots: n }
273
- })), r = (o) => {
274
- const m = t?.sortColumnKey === o.key;
273
+ const l = S(() => ({
274
+ cells: { slots: r }
275
+ })), n = (o) => {
276
+ const f = t?.sortColumnKey === o.key;
275
277
  return {
276
278
  colId: o.key,
277
279
  // Columns with no explicit width constraint share remaining space equally.
@@ -279,9 +281,9 @@ const ue = ({
279
281
  headerName: o.label,
280
282
  maxWidth: o.maxWidth,
281
283
  minWidth: o.minWidth,
282
- sortable: o.sortable,
284
+ sortable: o.sortable ?? !1,
283
285
  unSortIcon: o.showSortIcon,
284
- ...m ? { sort: t?.sortColumnOrder, sortIndex: 0 } : {},
286
+ ...f ? { initialSort: t?.sortColumnOrder, initialSortIndex: 0 } : {},
285
287
  valueGetter: (a) => a.data?.[o.key],
286
288
  width: o.width,
287
289
  cellRenderer: Ce,
@@ -290,106 +292,112 @@ const ue = ({
290
292
  };
291
293
  };
292
294
  return {
293
- columnDefs: h(() => e.value.map(r)),
295
+ columnDefs: S(() => e.value.map(n)),
294
296
  gridContext: l
295
297
  };
296
- }, ye = ({
298
+ }, U = ({
297
299
  config: e,
298
- headers: n,
300
+ headers: r,
299
301
  pageSize: t
300
302
  }) => {
301
- const l = new Set(n.filter((s) => s.sortable).map((s) => s.key)), r = e?.sortColumnKey && l.has(e.sortColumnKey) ? e.sortColumnKey : void 0;
303
+ const l = new Set(r.filter((i) => i.sortable).map((i) => i.key)), n = e?.sortColumnKey && l.has(e.sortColumnKey) ? e.sortColumnKey : void 0;
302
304
  return {
303
- sortColumnKey: r,
304
- sortColumnOrder: r ? e?.sortColumnOrder : void 0,
305
+ sortColumnKey: n,
306
+ sortColumnOrder: n ? e?.sortColumnOrder : void 0,
305
307
  pageSize: e?.pageSize ?? t
306
308
  };
307
- }, W = (e, n) => e.sortColumnKey === n.sortColumnKey && e.sortColumnOrder === n.sortColumnOrder && e.pageSize === n.pageSize, ge = ({
309
+ }, W = (e, r) => e.sortColumnKey === r.sortColumnKey && e.sortColumnOrder === r.sortColumnOrder && e.pageSize === r.pageSize, ge = ({
308
310
  headers: e,
309
- pageSize: n,
311
+ pageSize: r,
310
312
  tableConfig: t,
311
313
  emitTableConfigUpdate: l,
312
- onExternalConfigChange: r
314
+ onExternalConfigChange: n
313
315
  }) => {
314
- const s = (d) => ye({ config: d, headers: e.value, pageSize: n.value }), o = N(s(t.value));
315
- M(() => s(t.value), (d) => {
316
- W(d, o.value) || (o.value = d, r?.(d));
316
+ const i = S(() => t.value ? U({ config: t.value, headers: e.value, pageSize: r.value }) : void 0), o = E(
317
+ i.value ?? U({ config: void 0, headers: e.value, pageSize: r.value })
318
+ );
319
+ B(i, (v) => {
320
+ v && !W(v, o.value) && (o.value = v, n?.(v));
317
321
  });
318
- const m = (d) => {
319
- const S = s({ ...o.value, ...d });
320
- W(S, o.value) || (o.value = S, l(S));
321
- }, a = h(() => ({
322
+ const f = (v) => {
323
+ const g = U({
324
+ config: { ...o.value, ...v },
325
+ headers: e.value,
326
+ pageSize: r.value
327
+ });
328
+ W(g, o.value) || (o.value = g, l(g));
329
+ }, a = S(() => ({
322
330
  sortColumnKey: o.value.sortColumnKey,
323
331
  sortColumnOrder: o.value.sortColumnOrder
324
- })), c = h(() => o.value.pageSize ?? n.value);
332
+ })), s = S(() => t.value?.pageSize ?? r.value);
325
333
  return {
326
- activeTableConfig: T(o),
334
+ activeTableConfig: x(o),
327
335
  activeSort: a,
328
- activePageSize: c,
329
- patchTableConfig: m
336
+ activePageSize: s,
337
+ patchTableConfig: f
330
338
  };
331
339
  }, he = ({
332
340
  cellClick: e,
333
- headers: n,
341
+ headers: r,
334
342
  rowClick: t
335
343
  }) => {
336
- const l = h(() => new Set(
337
- n.value.filter((a) => a.disableRowClick).map((a) => a.key)
338
- )), r = (a) => {
339
- const c = a.event?.target;
340
- return c instanceof Element ? c.closest(".ag-cell")?.getAttribute("col-id") ?? void 0 : void 0;
341
- }, s = (a) => {
342
- const c = r(a);
343
- return !!(c && l.value.has(c));
344
+ const l = S(() => new Set(
345
+ r.value.filter((a) => a.disableRowClick).map((a) => a.key)
346
+ )), n = (a) => {
347
+ const s = a.event?.target;
348
+ return s instanceof Element ? s.closest(".ag-cell")?.getAttribute("col-id") ?? void 0 : void 0;
349
+ }, i = (a) => {
350
+ const s = n(a);
351
+ return !!(s && l.value.has(s));
344
352
  };
345
353
  return {
346
354
  onCellClick: (a) => {
347
- const c = a.colDef.colId;
348
- !a.data || !c || e({
349
- columnKey: c,
355
+ const s = a.colDef.colId;
356
+ !a.data || !s || e({
357
+ columnKey: s,
350
358
  row: a.data,
351
359
  value: a.value
352
360
  });
353
361
  },
354
362
  onRowClick: (a) => {
355
- a.data && !s(a) && t(a.data, a);
363
+ a.data && !i(a) && t(a.data, a);
356
364
  }
357
365
  };
358
- }, Se = ({
366
+ }, ye = ({
359
367
  activeSort: e,
360
- emitSort: n,
368
+ emitSort: r,
361
369
  patchTableConfig: t
362
370
  }) => {
363
- const l = (s, o) => {
364
- s.applyColumnState({
371
+ const l = (i, o) => {
372
+ i.applyColumnState({
365
373
  state: o.sortColumnKey ? [{ colId: o.sortColumnKey, sort: o.sortColumnOrder ?? null, sortIndex: 0 }] : [],
366
374
  defaultState: { sort: null, sortIndex: null }
367
375
  });
368
376
  };
369
- return { onSortChanged: (s) => {
370
- const o = s.api.getColumnState().filter((c) => c.sort).sort((c, d) => (c.sortIndex ?? 0) - (d.sortIndex ?? 0)), m = o[o.length - 1], a = m ? { sortColumnKey: m.colId, sortColumnOrder: m.sort } : {};
371
- a.sortColumnKey === e.value.sortColumnKey && a.sortColumnOrder === e.value.sortColumnOrder || (n(a), t(a), o.length > 1 && l(s.api, a));
377
+ return { onSortChanged: (i) => {
378
+ const o = i.api.getColumnState().filter((s) => s.sort).sort((s, v) => (s.sortIndex ?? 0) - (v.sortIndex ?? 0)), f = o[o.length - 1], a = f ? { sortColumnKey: f.colId, sortColumnOrder: f.sort } : { sortColumnKey: void 0, sortColumnOrder: void 0 };
379
+ a.sortColumnKey === e.value.sortColumnKey && a.sortColumnOrder === e.value.sortColumnOrder || (r(a), t(a), o.length > 1 && l(i.api, a));
372
380
  }, applySortToGrid: l };
373
- }, be = { title: "No Data", message: "There is no data to display." }, ke = { title: "An error occurred", message: "Data cannot be displayed due to an error." }, De = {
374
- emptyState: be,
375
- errorState: ke
381
+ }, Se = { title: "No Data", message: "There is no data to display." }, be = { title: "An error occurred", message: "Data cannot be displayed due to an error." }, ke = {
382
+ emptyState: Se,
383
+ errorState: be
376
384
  };
377
- function we() {
378
- const e = ne("en-us", De);
385
+ function De() {
386
+ const e = ne("en-us", ke);
379
387
  return {
380
388
  i18n: e,
381
389
  i18nT: se(e)
382
390
  // Translation component <i18n-t>
383
391
  };
384
392
  }
385
- const Re = {
393
+ const we = {
386
394
  class: "kong-ui-public-table-data-grid",
387
395
  "data-testid": "table-data-grid"
388
- }, Ie = {
396
+ }, Re = {
389
397
  key: 0,
390
398
  class: "table-error-state",
391
399
  "data-testid": "table-error-state"
392
- }, Ke = {
400
+ }, Ie = {
393
401
  key: 1,
394
402
  class: "table-empty-state",
395
403
  "data-testid": "table-empty-state"
@@ -404,109 +412,106 @@ const Re = {
404
412
  tableConfig: {}
405
413
  },
406
414
  emits: ["grid:ready", "state", "row:click", "cell:click", "sort", "update:tableConfig"],
407
- setup(e, { emit: n }) {
415
+ setup(e, { emit: r }) {
408
416
  oe.registerModules([ae, le]);
409
- const t = n, { i18n: { t: l } } = we(), r = ee(), s = G(), { activeTableConfig: o, activeSort: m, activePageSize: a, patchTableConfig: c } = ge({
410
- headers: x(() => e.headers),
411
- pageSize: x(() => e.pageSize),
412
- tableConfig: x(() => e.tableConfig),
417
+ const t = r, { i18n: { t: l } } = De(), n = ee(), i = G(), { activeTableConfig: o, activeSort: f, activePageSize: a, patchTableConfig: s } = ge({
418
+ headers: O(() => e.headers),
419
+ pageSize: O(() => e.pageSize),
420
+ tableConfig: O(() => e.tableConfig),
413
421
  emitTableConfigUpdate: (p) => t("update:tableConfig", p),
414
422
  onExternalConfigChange: (p) => {
415
- s.value && S(s.value, { sortColumnKey: p.sortColumnKey, sortColumnOrder: p.sortColumnOrder });
423
+ i.value && g(i.value, p);
416
424
  }
417
- }), { onSortChanged: d, applySortToGrid: S } = Se({
418
- activeSort: m,
425
+ }), { onSortChanged: v, applySortToGrid: g } = ye({
426
+ activeSort: f,
419
427
  emitSort: (p) => t("sort", p),
420
- patchTableConfig: c
421
- }), { columnDefs: b, gridContext: D } = pe({
422
- headers: x(() => e.headers),
423
- slots: r,
424
- // A snapshot, not the reactive activeSort: only the initial resolved sort
425
- // (e.g. from a host-controlled tableConfig prop at mount) needs seeding
426
- // into column defs. See useTableDataGridColumnDefs for why.
427
- initialSort: m.value
428
- }), { onCellClick: R, onRowClick: f } = he({
428
+ patchTableConfig: s
429
+ }), { columnDefs: k, gridContext: D } = pe({
430
+ headers: O(() => e.headers),
431
+ slots: n,
432
+ initialSort: f.value
433
+ }), { onCellClick: w, onRowClick: C } = he({
429
434
  cellClick: (p) => t("cell:click", p),
430
- headers: x(() => e.headers),
431
- rowClick: (p, U) => t("row:click", p, U)
432
- }), w = {
435
+ headers: O(() => e.headers),
436
+ rowClick: (p, R) => t("row:click", p, R)
437
+ }), b = {
433
438
  resizable: !1,
434
439
  sortable: !1,
435
440
  suppressMovable: !0
436
- }, K = h(() => [
441
+ }, K = S(() => [
437
442
  e.fetcher,
438
443
  a.value,
439
444
  e.refreshKey,
440
445
  o.value.sortColumnKey,
441
446
  o.value.sortColumnOrder
442
- ]), i = h(() => m.value.sortColumnKey ? m.value : void 0), {
443
- data: v,
444
- datasource: y,
445
- error: C,
446
- isFetching: u
447
+ ]), {
448
+ data: M,
449
+ datasource: _,
450
+ error: A,
451
+ isFetching: F
447
452
  } = fe({
448
453
  fetcher: e.fetcher,
449
454
  resetKey: K,
450
- sort: i
455
+ sort: f
451
456
  }), {
452
- fetchState: F,
453
- hasData: k,
454
- state: E
455
- } = ce(v, C, u), O = h(() => E.value === F.SUCCESS && !k.value);
457
+ fetchState: c,
458
+ hasData: u,
459
+ state: d
460
+ } = ce(M, A, F), h = S(() => d.value === c.SUCCESS && !u.value);
456
461
  ue({
457
462
  emitState: (p) => t("state", p),
458
- fetchLifecycleState: E,
459
- hasData: k
463
+ fetchLifecycleState: d,
464
+ hasData: u
460
465
  });
461
- const _ = (p) => {
462
- s.value = p.api, t("grid:ready", p.api);
466
+ const m = (p) => {
467
+ i.value = p.api, t("grid:ready", p.api);
463
468
  };
464
- return (p, U) => {
465
- const L = q("KEmptyState");
466
- return I(), B("div", Re, [
467
- e.error ? (I(), B("div", Ie, [
469
+ return (p, R) => {
470
+ const z = q("KEmptyState");
471
+ return I(), N("div", we, [
472
+ e.error ? (I(), N("div", Re, [
468
473
  V(p.$slots, "error-state", {}, () => [
469
- A(L, {
474
+ L(z, {
470
475
  "icon-variant": "error",
471
- message: g(l)("errorState.message"),
472
- title: g(l)("errorState.title")
476
+ message: y(l)("errorState.message"),
477
+ title: y(l)("errorState.title")
473
478
  }, null, 8, ["message", "title"])
474
479
  ], !0)
475
- ])) : O.value ? (I(), B("div", Ke, [
480
+ ])) : h.value ? (I(), N("div", Ie, [
476
481
  V(p.$slots, "empty-state", {}, () => [
477
- A(L, {
478
- message: g(l)("emptyState.message"),
479
- title: g(l)("emptyState.title")
482
+ L(z, {
483
+ message: y(l)("emptyState.message"),
484
+ title: y(l)("emptyState.title")
480
485
  }, null, 8, ["message", "title"])
481
486
  ], !0)
482
- ])) : (I(), P(g(te), {
487
+ ])) : (I(), P(y(te), {
483
488
  key: 2,
484
- "cache-block-size": g(a),
489
+ "cache-block-size": y(a),
485
490
  class: "table-data-grid-grid",
486
- "column-defs": g(b),
487
- context: g(D),
488
- datasource: g(y),
489
- "default-col-def": w,
491
+ "column-defs": y(k),
492
+ context: y(D),
493
+ datasource: y(_),
494
+ "default-col-def": b,
490
495
  "infinite-initial-row-count": 1,
491
- loading: g(u),
496
+ loading: y(F),
492
497
  "row-model-type": "infinite",
493
498
  "suppress-cell-focus": !0,
494
499
  "suppress-multi-sort": !0,
495
- theme: g(re),
496
- onCellClicked: g(R),
497
- onGridReady: _,
498
- onRowClicked: g(f),
499
- onSortChanged: g(d)
500
+ theme: y(re),
501
+ onCellClicked: y(w),
502
+ onGridReady: m,
503
+ onRowClicked: y(C),
504
+ onSortChanged: y(v)
500
505
  }, null, 8, ["cache-block-size", "column-defs", "context", "datasource", "loading", "theme", "onCellClicked", "onRowClicked", "onSortChanged"]))
501
506
  ]);
502
507
  };
503
508
  }
504
- }), Oe = (e, n) => {
509
+ }), Ke = (e, r) => {
505
510
  const t = e.__vccOpts || e;
506
- for (const [l, r] of n)
507
- t[l] = r;
511
+ for (const [l, n] of r)
512
+ t[l] = n;
508
513
  return t;
509
- }, Ne = /* @__PURE__ */ Oe(Ee, [["__scopeId", "data-v-2bcd2d90"]]);
514
+ }, Fe = /* @__PURE__ */ Ke(Ee, [["__scopeId", "data-v-d8328fe5"]]);
510
515
  export {
511
- Ne as TableDataGrid
516
+ Fe as TableDataGrid
512
517
  };
@@ -1 +1 @@
1
- (function(S,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):(S=typeof globalThis<"u"?globalThis:S||self,e(S["kong-ui-public-table-data-grid"]={},S.Vue,S.AgGridVue,S.agGridCommunity,S["kong-ui-public-i18n"]))})(this,(function(S,e,F,x,G){"use strict";var E=(t=>(t.PENDING="PENDING",t.LOADING="LOADING",t.SUCCESS="SUCCESS",t.ERROR="ERROR",t))(E||{});const M=t=>!!t?.length;function A(t,s,o,r=M){const l=e.computed(()=>r(t.value)),c=e.computed(()=>{const m=t.value!==void 0,n=s.value!==void 0&&s.value!==null;return o.value?"LOADING":l.value?"SUCCESS":n?"ERROR":m?"SUCCESS":"PENDING"});return{fetchState:E,hasData:l,state:c}}const V=({emitState:t,fetchLifecycleState:s,hasData:o})=>{e.watch(()=>({hasData:o.value,state:s.value}),({hasData:r,state:l})=>{if(l!==E.PENDING){if(l===E.LOADING){t({hasData:r,state:"loading"});return}if(l===E.ERROR){t({hasData:r,state:"error"});return}t({hasData:r,state:"success"})}})},U=({startRow:t,endRow:s})=>{const o=s-t;return{blockIndex:o>0?Math.floor(t/o):0,pageSize:o}},L=({startRow:t,rowsLength:s,pageSize:o,total:r,hasMore:l})=>{if(typeof r=="number")return r;if(l!==!0&&(l===!1||s<o))return t+s},W=({fetcher:t,resetKey:s,sort:o})=>{const r=new Map,l=new Map,c=e.ref(0),a=e.shallowRef(),m=e.shallowRef(),n=e.shallowRef(),d=e.ref(!1),f=i=>i===c.value,b=i=>{const p=l.get(i);if(p)return p;let y;const g={promise:new Promise(u=>{y=u}),resolve:u=>y(u)};return l.set(i,g),g},k=(i,p)=>{p.resolve(!1),l.get(i)===p&&l.delete(i)},w=async({blockIndex:i,currentBlockCompletion:p,datasourceId:y})=>{if(i===0)return"ready";const g=l.get(i-1);if(!g)return k(i,p),"failed";const u=await g.promise;return f(y)?u?"ready":(k(i,p),"failed"):(k(i,p),"stale")},R=({blockIndex:i,currentBlockCompletion:p,getRowsParams:y,pageSize:g,result:u})=>{u.cursor!==void 0&&r.set(i,u.cursor),y.successCallback(u.data,L({startRow:y.startRow,rowsLength:u.data.length,pageSize:g,total:u.total,hasMore:u.hasMore})),y.startRow===0&&(m.value=u.data),p.resolve(!0)},C=({blockIndex:i,currentBlockCompletion:p,fetchError:y,getRowsParams:g})=>{n.value=y,g.failCallback(),k(i,p)},D=()=>{const i=c.value+1;c.value=i,r.clear(),l.clear(),m.value=void 0,n.value=void 0;let p=0;const y=()=>{f(i)&&(d.value=p>0)};return y(),{async getRows(g){const{blockIndex:u,pageSize:T}=U({startRow:g.startRow,endRow:g.endRow}),v=b(u),K=await w({blockIndex:u,currentBlockCompletion:v,datasourceId:i});if(K!=="ready"){K==="failed"&&g.failCallback();return}f(i)&&(n.value=void 0),p+=1,y();try{const O=u>0?r.get(u-1):void 0,B=await t({mode:"infinite",pageSize:T,cursor:O,sort:o?.value});if(!f(i)){g.failCallback(),k(u,v);return}R({blockIndex:u,currentBlockCompletion:v,getRowsParams:g,pageSize:T,result:B})}catch(O){if(!f(i)){g.failCallback(),k(u,v);return}C({blockIndex:u,currentBlockCompletion:v,fetchError:O,getRowsParams:g})}finally{p=Math.max(0,p-1),y()}}}},I=()=>{a.value=D()};return e.watch(()=>s?.value,()=>{I()},{immediate:!0}),{datasource:e.readonly(a),data:e.readonly(m),error:e.readonly(n),isFetching:e.readonly(d)}},q={key:1,class:"table-data-grid-cell-renderer"},$=e.defineComponent({name:"TableDataGridCellRenderer",__name:"TableDataGridCellRenderer",props:{params:{}},setup(t,{expose:s}){const o=e.shallowRef(t.params),r=e.ref(null),l=e.ref(!1),c=e.computed(()=>o.value.valueFormatted??String(o.value.value??"")),a=e.computed(()=>{const C=o.value.colDef?.colId;return C?o.value.context?.cells?.slots?.[C]:void 0}),m=e.computed(()=>({column:o.value.headerDef,refreshCell:()=>{const C=o.value.node;C&&o.value.api.refreshCells({force:!0,rowNodes:[C]})},row:o.value.data??{},rowIndex:o.value.node?.rowIndex??0,rowValue:o.value.value,selected:o.value.node?.isSelected()??!1})),n=()=>a.value?.(m.value);let d,f,b=!1;const k=()=>{const C=r.value;l.value=!!C&&C.scrollWidth>C.clientWidth},w=()=>{b||(f!==void 0&&cancelAnimationFrame(f),f=requestAnimationFrame(()=>{f=void 0,k()}))},R=C=>{if(d?.disconnect(),C){d?.observe(C);const D=C.closest(".ag-cell");D&&d?.observe(D)}w()};return e.onMounted(()=>{d=new ResizeObserver(w),R(r.value)}),e.watch(r,R,{flush:"post"}),e.onUnmounted(()=>{b=!0,d?.disconnect(),f!==void 0&&cancelAnimationFrame(f)}),s({refresh(C){return o.value=C,e.nextTick(w),!0}}),(C,D)=>{const I=e.resolveComponent("KTooltip");return a.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n),{key:0})):(e.openBlock(),e.createElementBlock("span",q,[e.createVNode(I,{class:"table-data-grid-cell-tooltip",disabled:!l.value,"kpop-attributes":{popoverDelay:400},"max-width":"300",placement:"bottom-start",target:"body",text:c.value},{default:e.withCtx(()=>[e.createElementVNode("span",{ref_key:"contentElement",ref:r,class:"table-data-grid-cell-content"},e.toDisplayString(c.value),513)]),_:1},8,["disabled","text"])]))}}}),j=({headers:t,slots:s,initialSort:o})=>{const r=e.computed(()=>({cells:{slots:s}})),l=a=>{const m=o?.sortColumnKey===a.key;return{colId:a.key,flex:!a.width&&!a.maxWidth?1:void 0,headerName:a.label,maxWidth:a.maxWidth,minWidth:a.minWidth,sortable:a.sortable,unSortIcon:a.showSortIcon,...m?{sort:o?.sortColumnOrder,sortIndex:0}:{},valueGetter:n=>n.data?.[a.key],width:a.width,cellRenderer:$,cellRendererParams:{headerDef:a}}};return{columnDefs:e.computed(()=>t.value.map(l)),gridContext:r}},P=({config:t,headers:s,pageSize:o})=>{const r=new Set(s.filter(c=>c.sortable).map(c=>c.key)),l=t?.sortColumnKey&&r.has(t.sortColumnKey)?t.sortColumnKey:void 0;return{sortColumnKey:l,sortColumnOrder:l?t?.sortColumnOrder:void 0,pageSize:t?.pageSize??o}},N=(t,s)=>t.sortColumnKey===s.sortColumnKey&&t.sortColumnOrder===s.sortColumnOrder&&t.pageSize===s.pageSize,H=({headers:t,pageSize:s,tableConfig:o,emitTableConfigUpdate:r,onExternalConfigChange:l})=>{const c=f=>P({config:f,headers:t.value,pageSize:s.value}),a=e.ref(c(o.value));e.watch(()=>c(o.value),f=>{N(f,a.value)||(a.value=f,l?.(f))});const m=f=>{const b=c({...a.value,...f});N(b,a.value)||(a.value=b,r(b))},n=e.computed(()=>({sortColumnKey:a.value.sortColumnKey,sortColumnOrder:a.value.sortColumnOrder})),d=e.computed(()=>a.value.pageSize??s.value);return{activeTableConfig:e.readonly(a),activeSort:n,activePageSize:d,patchTableConfig:m}},Q=({cellClick:t,headers:s,rowClick:o})=>{const r=e.computed(()=>new Set(s.value.filter(n=>n.disableRowClick).map(n=>n.key))),l=n=>{const d=n.event?.target;return d instanceof Element?d.closest(".ag-cell")?.getAttribute("col-id")??void 0:void 0},c=n=>{const d=l(n);return!!(d&&r.value.has(d))};return{onCellClick:n=>{const d=n.colDef.colId;!n.data||!d||t({columnKey:d,row:n.data,value:n.value})},onRowClick:n=>{n.data&&!c(n)&&o(n.data,n)}}},J=({activeSort:t,emitSort:s,patchTableConfig:o})=>{const r=(c,a)=>{c.applyColumnState({state:a.sortColumnKey?[{colId:a.sortColumnKey,sort:a.sortColumnOrder??null,sortIndex:0}]:[],defaultState:{sort:null,sortIndex:null}})};return{onSortChanged:c=>{const a=c.api.getColumnState().filter(d=>d.sort).sort((d,f)=>(d.sortIndex??0)-(f.sortIndex??0)),m=a[a.length-1],n=m?{sortColumnKey:m.colId,sortColumnOrder:m.sort}:{};n.sortColumnKey===t.value.sortColumnKey&&n.sortColumnOrder===t.value.sortColumnOrder||(s(n),o(n),a.length>1&&r(c.api,n))},applySortToGrid:r}},X={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 Y(){const t=G.createI18n("en-us",X);return{i18n:t,i18nT:G.i18nTComponent(t)}}const Z={class:"kong-ui-public-table-data-grid","data-testid":"table-data-grid"},ee={key:0,class:"table-error-state","data-testid":"table-error-state"},te={key:1,class:"table-empty-state","data-testid":"table-empty-state"},oe=((t,s)=>{const o=t.__vccOpts||t;for(const[r,l]of s)o[r]=l;return o})(e.defineComponent({__name:"TableDataGrid",props:{headers:{},fetcher:{type:Function},error:{type:Boolean,default:!1},pageSize:{default:25},refreshKey:{type:[String,Number,Boolean]},tableConfig:{}},emits:["grid:ready","state","row:click","cell:click","sort","update:tableConfig"],setup(t,{emit:s}){x.ModuleRegistry.registerModules([x.AllCommunityModule,x.InfiniteRowModelModule]);const o=s,{i18n:{t:r}}=Y(),l=e.useSlots(),c=e.shallowRef(),{activeTableConfig:a,activeSort:m,activePageSize:n,patchTableConfig:d}=H({headers:e.toRef(()=>t.headers),pageSize:e.toRef(()=>t.pageSize),tableConfig:e.toRef(()=>t.tableConfig),emitTableConfigUpdate:h=>o("update:tableConfig",h),onExternalConfigChange:h=>{c.value&&b(c.value,{sortColumnKey:h.sortColumnKey,sortColumnOrder:h.sortColumnOrder})}}),{onSortChanged:f,applySortToGrid:b}=J({activeSort:m,emitSort:h=>o("sort",h),patchTableConfig:d}),{columnDefs:k,gridContext:w}=j({headers:e.toRef(()=>t.headers),slots:l,initialSort:m.value}),{onCellClick:R,onRowClick:C}=Q({cellClick:h=>o("cell:click",h),headers:e.toRef(()=>t.headers),rowClick:(h,z)=>o("row:click",h,z)}),D={resizable:!1,sortable:!1,suppressMovable:!0},I=e.computed(()=>[t.fetcher,n.value,t.refreshKey,a.value.sortColumnKey,a.value.sortColumnOrder]),i=e.computed(()=>m.value.sortColumnKey?m.value:void 0),{data:p,datasource:y,error:g,isFetching:u}=W({fetcher:t.fetcher,resetKey:I,sort:i}),{fetchState:T,hasData:v,state:K}=A(p,g,u),O=e.computed(()=>K.value===T.SUCCESS&&!v.value);V({emitState:h=>o("state",h),fetchLifecycleState:K,hasData:v});const B=h=>{c.value=h.api,o("grid:ready",h.api)};return(h,z)=>{const _=e.resolveComponent("KEmptyState");return e.openBlock(),e.createElementBlock("div",Z,[t.error?(e.openBlock(),e.createElementBlock("div",ee,[e.renderSlot(h.$slots,"error-state",{},()=>[e.createVNode(_,{"icon-variant":"error",message:e.unref(r)("errorState.message"),title:e.unref(r)("errorState.title")},null,8,["message","title"])],!0)])):O.value?(e.openBlock(),e.createElementBlock("div",te,[e.renderSlot(h.$slots,"empty-state",{},()=>[e.createVNode(_,{message:e.unref(r)("emptyState.message"),title:e.unref(r)("emptyState.title")},null,8,["message","title"])],!0)])):(e.openBlock(),e.createBlock(e.unref(F.AgGridVue),{key:2,"cache-block-size":e.unref(n),class:"table-data-grid-grid","column-defs":e.unref(k),context:e.unref(w),datasource:e.unref(y),"default-col-def":D,"infinite-initial-row-count":1,loading:e.unref(u),"row-model-type":"infinite","suppress-cell-focus":!0,"suppress-multi-sort":!0,theme:e.unref(x.themeQuartz),onCellClicked:e.unref(R),onGridReady:B,onRowClicked:e.unref(C),onSortChanged:e.unref(f)},null,8,["cache-block-size","column-defs","context","datasource","loading","theme","onCellClicked","onRowClicked","onSortChanged"]))])}}}),[["__scopeId","data-v-2bcd2d90"]]);S.TableDataGrid=oe,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(b,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):(b=typeof globalThis<"u"?globalThis:b||self,e(b["kong-ui-public-table-data-grid"]={},b.Vue,b.AgGridVue,b.agGridCommunity,b["kong-ui-public-i18n"]))})(this,(function(b,e,_,K,F){"use strict";var E=(t=>(t.PENDING="PENDING",t.LOADING="LOADING",t.SUCCESS="SUCCESS",t.ERROR="ERROR",t))(E||{});const M=t=>!!t?.length;function A(t,r,o,l=M){const s=e.computed(()=>l(t.value)),i=e.computed(()=>{const C=t.value!==void 0,n=r.value!==void 0&&r.value!==null;return o.value?"LOADING":s.value?"SUCCESS":n?"ERROR":C?"SUCCESS":"PENDING"});return{fetchState:E,hasData:s,state:i}}const V=({emitState:t,fetchLifecycleState:r,hasData:o})=>{e.watch(()=>({hasData:o.value,state:r.value}),({hasData:l,state:s})=>{if(s!==E.PENDING){if(s===E.LOADING){t({hasData:l,state:"loading"});return}if(s===E.ERROR){t({hasData:l,state:"error"});return}t({hasData:l,state:"success"})}})},U=({startRow:t,endRow:r})=>{const o=r-t;return{blockIndex:o>0?Math.floor(t/o):0,pageSize:o}},L=({startRow:t,rowsLength:r,pageSize:o,total:l,hasMore:s})=>{if(typeof l=="number")return l;if(s!==!0&&(s===!1||r<o))return t+r},W=({fetcher:t,resetKey:r,sort:o})=>{const l=new Map,s=new Map,i=e.ref(0),a=e.shallowRef(),C=e.shallowRef(),n=e.shallowRef(),c=e.ref(0),p=e.ref(!1),y=d=>d===i.value,v=()=>{p.value=c.value>0},w=()=>{n.value=void 0,c.value+=1,v()},D=()=>{c.value=Math.max(0,c.value-1),v()},g=d=>{const u=s.get(d);if(u)return u;let f;const S={promise:new Promise(m=>{f=m}),resolve:m=>f(m)};return s.set(d,S),S},k=(d,u)=>{u.resolve(!1),s.get(d)===u&&s.delete(d)},I=async({blockIndex:d,currentBlockCompletion:u,datasourceId:f})=>{if(d===0)return"ready";const S=s.get(d-1);if(!S)return k(d,u),"failed";const m=await S.promise;return y(f)?m?"ready":(k(d,u),"failed"):(k(d,u),"stale")},B=({blockIndex:d,currentBlockCompletion:u,getRowsParams:f,pageSize:S,result:m})=>{m.cursor!==void 0&&l.set(d,m.cursor),f.successCallback(m.data,L({startRow:f.startRow,rowsLength:m.data.length,pageSize:S,total:m.total,hasMore:m.hasMore})),f.startRow===0&&(C.value=m.data),u.resolve(!0)},G=({blockIndex:d,currentBlockCompletion:u,fetchError:f,getRowsParams:S})=>{n.value=f,S.failCallback(),k(d,u)},N=()=>{const d=i.value+1;return i.value=d,l.clear(),s.clear(),C.value=void 0,n.value=void 0,c.value=0,v(),{async getRows(u){const{blockIndex:f,pageSize:S}=U({startRow:u.startRow,endRow:u.endRow}),m=g(f);if(await I({blockIndex:f,currentBlockCompletion:m,datasourceId:d})!=="ready"){u.failCallback();return}y(d)&&w();try{const R=f>0?l.get(f-1):void 0,x=await t({mode:"infinite",pageSize:S,cursor:R,sort:o?.value});if(!y(d)){u.failCallback(),k(f,m);return}B({blockIndex:f,currentBlockCompletion:m,getRowsParams:u,pageSize:S,result:x})}catch(R){if(!y(d)){u.failCallback(),k(f,m);return}G({blockIndex:f,currentBlockCompletion:m,fetchError:R,getRowsParams:u})}finally{y(d)&&D()}}}},O=()=>{a.value=N()};return e.watch(()=>r?.value,()=>{O()},{immediate:!0}),{datasource:e.readonly(a),data:e.readonly(C),error:e.readonly(n),isFetching:e.readonly(p)}},q={key:1,class:"table-data-grid-cell-renderer"},$=e.defineComponent({name:"TableDataGridCellRenderer",__name:"TableDataGridCellRenderer",props:{params:{}},setup(t,{expose:r}){const o=e.shallowRef(t.params),l=e.ref(null),s=e.ref(!1),i=e.computed(()=>o.value.valueFormatted??String(o.value.value??"")),a=e.computed(()=>{const g=o.value.colDef?.colId;return g?o.value.context?.cells?.slots?.[g]:void 0}),C=e.computed(()=>({column:o.value.headerDef,refreshCell:()=>{const g=o.value.node;g&&o.value.api.refreshCells({force:!0,rowNodes:[g]})},row:o.value.data??{},rowIndex:o.value.node?.rowIndex??0,rowValue:o.value.value,selected:o.value.node?.isSelected()??!1})),n=()=>a.value?.(C.value);let c,p,y=!1;const v=()=>{const g=l.value;s.value=!!g&&g.scrollWidth>g.clientWidth},w=()=>{y||(p!==void 0&&cancelAnimationFrame(p),p=requestAnimationFrame(()=>{p=void 0,v()}))},D=g=>{if(c?.disconnect(),g){c?.observe(g);const k=g.closest(".ag-cell");k&&c?.observe(k)}w()};return e.onMounted(()=>{c=new ResizeObserver(w),D(l.value)}),e.watch(l,D,{flush:"post"}),e.onUnmounted(()=>{y=!0,c?.disconnect(),p!==void 0&&cancelAnimationFrame(p)}),r({refresh(g){return o.value=g,e.nextTick(w),!0}}),(g,k)=>{const I=e.resolveComponent("KTooltip");return a.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n),{key:0})):(e.openBlock(),e.createElementBlock("span",q,[e.createVNode(I,{class:"table-data-grid-cell-tooltip",disabled:!s.value,"kpop-attributes":{popoverDelay:400},"max-width":"300",placement:"bottom-start",target:"body",text:i.value},{default:e.withCtx(()=>[e.createElementVNode("span",{ref_key:"contentElement",ref:l,class:"table-data-grid-cell-content"},e.toDisplayString(i.value),513)]),_:1},8,["disabled","text"])]))}}}),j=({headers:t,slots:r,initialSort:o})=>{const l=e.computed(()=>({cells:{slots:r}})),s=a=>{const C=o?.sortColumnKey===a.key;return{colId:a.key,flex:!a.width&&!a.maxWidth?1:void 0,headerName:a.label,maxWidth:a.maxWidth,minWidth:a.minWidth,sortable:a.sortable??!1,unSortIcon:a.showSortIcon,...C?{initialSort:o?.sortColumnOrder,initialSortIndex:0}:{},valueGetter:n=>n.data?.[a.key],width:a.width,cellRenderer:$,cellRendererParams:{headerDef:a}}};return{columnDefs:e.computed(()=>t.value.map(s)),gridContext:l}},T=({config:t,headers:r,pageSize:o})=>{const l=new Set(r.filter(i=>i.sortable).map(i=>i.key)),s=t?.sortColumnKey&&l.has(t.sortColumnKey)?t.sortColumnKey:void 0;return{sortColumnKey:s,sortColumnOrder:s?t?.sortColumnOrder:void 0,pageSize:t?.pageSize??o}},z=(t,r)=>t.sortColumnKey===r.sortColumnKey&&t.sortColumnOrder===r.sortColumnOrder&&t.pageSize===r.pageSize,P=({headers:t,pageSize:r,tableConfig:o,emitTableConfigUpdate:l,onExternalConfigChange:s})=>{const i=e.computed(()=>o.value?T({config:o.value,headers:t.value,pageSize:r.value}):void 0),a=e.ref(i.value??T({config:void 0,headers:t.value,pageSize:r.value}));e.watch(i,p=>{p&&!z(p,a.value)&&(a.value=p,s?.(p))});const C=p=>{const y=T({config:{...a.value,...p},headers:t.value,pageSize:r.value});z(y,a.value)||(a.value=y,l(y))},n=e.computed(()=>({sortColumnKey:a.value.sortColumnKey,sortColumnOrder:a.value.sortColumnOrder})),c=e.computed(()=>o.value?.pageSize??r.value);return{activeTableConfig:e.readonly(a),activeSort:n,activePageSize:c,patchTableConfig:C}},H=({cellClick:t,headers:r,rowClick:o})=>{const l=e.computed(()=>new Set(r.value.filter(n=>n.disableRowClick).map(n=>n.key))),s=n=>{const c=n.event?.target;return c instanceof Element?c.closest(".ag-cell")?.getAttribute("col-id")??void 0:void 0},i=n=>{const c=s(n);return!!(c&&l.value.has(c))};return{onCellClick:n=>{const c=n.colDef.colId;!n.data||!c||t({columnKey:c,row:n.data,value:n.value})},onRowClick:n=>{n.data&&!i(n)&&o(n.data,n)}}},Q=({activeSort:t,emitSort:r,patchTableConfig:o})=>{const l=(i,a)=>{i.applyColumnState({state:a.sortColumnKey?[{colId:a.sortColumnKey,sort:a.sortColumnOrder??null,sortIndex:0}]:[],defaultState:{sort:null,sortIndex:null}})};return{onSortChanged:i=>{const a=i.api.getColumnState().filter(c=>c.sort).sort((c,p)=>(c.sortIndex??0)-(p.sortIndex??0)),C=a[a.length-1],n=C?{sortColumnKey:C.colId,sortColumnOrder:C.sort}:{sortColumnKey:void 0,sortColumnOrder:void 0};n.sortColumnKey===t.value.sortColumnKey&&n.sortColumnOrder===t.value.sortColumnOrder||(r(n),o(n),a.length>1&&l(i.api,n))},applySortToGrid:l}},J={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 X(){const t=F.createI18n("en-us",J);return{i18n:t,i18nT:F.i18nTComponent(t)}}const Y={class:"kong-ui-public-table-data-grid","data-testid":"table-data-grid"},Z={key:0,class:"table-error-state","data-testid":"table-error-state"},ee={key:1,class:"table-empty-state","data-testid":"table-empty-state"},te=((t,r)=>{const o=t.__vccOpts||t;for(const[l,s]of r)o[l]=s;return o})(e.defineComponent({__name:"TableDataGrid",props:{headers:{},fetcher:{type:Function},error:{type:Boolean,default:!1},pageSize:{default:25},refreshKey:{type:[String,Number,Boolean]},tableConfig:{}},emits:["grid:ready","state","row:click","cell:click","sort","update:tableConfig"],setup(t,{emit:r}){K.ModuleRegistry.registerModules([K.AllCommunityModule,K.InfiniteRowModelModule]);const o=r,{i18n:{t:l}}=X(),s=e.useSlots(),i=e.shallowRef(),{activeTableConfig:a,activeSort:C,activePageSize:n,patchTableConfig:c}=P({headers:e.toRef(()=>t.headers),pageSize:e.toRef(()=>t.pageSize),tableConfig:e.toRef(()=>t.tableConfig),emitTableConfigUpdate:h=>o("update:tableConfig",h),onExternalConfigChange:h=>{i.value&&y(i.value,h)}}),{onSortChanged:p,applySortToGrid:y}=Q({activeSort:C,emitSort:h=>o("sort",h),patchTableConfig:c}),{columnDefs:v,gridContext:w}=j({headers:e.toRef(()=>t.headers),slots:s,initialSort:C.value}),{onCellClick:D,onRowClick:g}=H({cellClick:h=>o("cell:click",h),headers:e.toRef(()=>t.headers),rowClick:(h,R)=>o("row:click",h,R)}),k={resizable:!1,sortable:!1,suppressMovable:!0},I=e.computed(()=>[t.fetcher,n.value,t.refreshKey,a.value.sortColumnKey,a.value.sortColumnOrder]),{data:B,datasource:G,error:N,isFetching:O}=W({fetcher:t.fetcher,resetKey:I,sort:C}),{fetchState:d,hasData:u,state:f}=A(B,N,O),S=e.computed(()=>f.value===d.SUCCESS&&!u.value);V({emitState:h=>o("state",h),fetchLifecycleState:f,hasData:u});const m=h=>{i.value=h.api,o("grid:ready",h.api)};return(h,R)=>{const x=e.resolveComponent("KEmptyState");return e.openBlock(),e.createElementBlock("div",Y,[t.error?(e.openBlock(),e.createElementBlock("div",Z,[e.renderSlot(h.$slots,"error-state",{},()=>[e.createVNode(x,{"icon-variant":"error",message:e.unref(l)("errorState.message"),title:e.unref(l)("errorState.title")},null,8,["message","title"])],!0)])):S.value?(e.openBlock(),e.createElementBlock("div",ee,[e.renderSlot(h.$slots,"empty-state",{},()=>[e.createVNode(x,{message:e.unref(l)("emptyState.message"),title:e.unref(l)("emptyState.title")},null,8,["message","title"])],!0)])):(e.openBlock(),e.createBlock(e.unref(_.AgGridVue),{key:2,"cache-block-size":e.unref(n),class:"table-data-grid-grid","column-defs":e.unref(v),context:e.unref(w),datasource:e.unref(G),"default-col-def":k,"infinite-initial-row-count":1,loading:e.unref(O),"row-model-type":"infinite","suppress-cell-focus":!0,"suppress-multi-sort":!0,theme:e.unref(K.themeQuartz),onCellClicked:e.unref(D),onGridReady:m,onRowClicked:e.unref(g),onSortChanged:e.unref(p)},null,8,["cache-block-size","column-defs","context","datasource","loading","theme","onCellClicked","onRowClicked","onSortChanged"]))])}}}),[["__scopeId","data-v-d8328fe5"]]);b.TableDataGrid=te,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})}));
@@ -1 +1 @@
1
- {"version":3,"file":"TableDataGrid.vue.d.ts","sourceRoot":"","sources":["../../../src/components/TableDataGrid.vue"],"names":[],"mappings":"AAkQA,OAAO,KAAK,EACV,6BAA6B,EAC7B,0BAA0B,EAC1B,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,yBAAyB,EAC1B,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAEV,OAAO,EACP,cAAc,EACd,eAAe,EAChB,MAAM,mBAAmB,CAAA;AAkB1B,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;WA4RO,OAAO,KAAK,EAAE,WAAW,GAAG,mBAAmB,CAAC;iBAxR7C,KAAK,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;iBAC/B,oBAAoB,CAAC,GAAG,CAAC;gBAC1B,OAAO;mBACJ,MAAM;qBACJ,MAAM,GAAG,MAAM,GAAG,OAAO;sBACxB,mBAAmB;;;;;;;;KAmRwD,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;;qCAtQoB,0BAA0B,CAAC,GAAG,CAAC,KAAK,OAAO;uBAFzD,MAAM,OAAO;uBACb,MAAM,OAAO;;;YAMxB,YAAY,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,IAAI;YACpD,OAAO,WAAW,yBAAyB,GAAG,IAAI;YAClD,WAAW,OAAO,GAAG,SAAS,eAAe,CAAC,GAAG,CAAC,GAAG,IAAI;YACzD,YAAY,WAAW,6BAA6B,CAAC,GAAG,CAAC,GAAG,IAAI;YAChE,MAAM,WAAW,iBAAiB,GAAG,IAAI;YACzC,oBAAoB,WAAW,mBAAmB,GAAG,IAAI;;EAgQ3D,KACQ,OAAO,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAA;CAAI,CAAC;wBACpE,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"}
1
+ {"version":3,"file":"TableDataGrid.vue.d.ts","sourceRoot":"","sources":["../../../src/components/TableDataGrid.vue"],"names":[],"mappings":"AAgQA,OAAO,KAAK,EACV,6BAA6B,EAC7B,0BAA0B,EAC1B,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,yBAAyB,EAC1B,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAEV,OAAO,EACP,cAAc,EACd,eAAe,EAChB,MAAM,mBAAmB,CAAA;AAkB1B,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;WA0RO,OAAO,KAAK,EAAE,WAAW,GAAG,mBAAmB,CAAC;iBAtR7C,KAAK,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;iBAC/B,oBAAoB,CAAC,GAAG,CAAC;gBAC1B,OAAO;mBACJ,MAAM;qBACJ,MAAM,GAAG,MAAM,GAAG,OAAO;sBACxB,mBAAmB;;;;;;;;KAiRwD,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;;qCApQoB,0BAA0B,CAAC,GAAG,CAAC,KAAK,OAAO;uBAFzD,MAAM,OAAO;uBACb,MAAM,OAAO;;;YAMxB,YAAY,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,IAAI;YACpD,OAAO,WAAW,yBAAyB,GAAG,IAAI;YAClD,WAAW,OAAO,GAAG,SAAS,eAAe,CAAC,GAAG,CAAC,GAAG,IAAI;YACzD,YAAY,WAAW,6BAA6B,CAAC,GAAG,CAAC,GAAG,IAAI;YAChE,MAAM,WAAW,iBAAiB,GAAG,IAAI;YACzC,oBAAoB,WAAW,mBAAmB,GAAG,IAAI;;EA8P3D,KACQ,OAAO,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAA;CAAI,CAAC;wBACpE,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"}
@@ -13,9 +13,7 @@ interface UseFetchInfiniteOptions<Row extends object = TableDataGridRow> {
13
13
  */
14
14
  resetKey?: Readonly<Ref<unknown>>;
15
15
  /**
16
- * Current resolved sort. Read once per datasource build (the component
17
- * layer includes sort in `resetKey`, so a sort change always rebuilds the
18
- * datasource) and forwarded to every fetcher call for that generation.
16
+ * Current resolved sort, forwarded to the fetcher.
19
17
  */
20
18
  sort?: Readonly<Ref<TableDataGridSort | undefined>>;
21
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useFetchInfinite.d.ts","sourceRoot":"","sources":["../../../src/composables/useFetchInfinite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EAEpB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAAe,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACpE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAW9B,UAAU,uBAAuB,CAAC,GAAG,SAAS,MAAM,GAAG,gBAAgB;IACrE;;;OAGG;IACH,OAAO,EAAE,oBAAoB,CAAC,GAAG,CAAC,CAAA;IAClC;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAA;IACjC;;;;OAIG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAAC,CAAA;CACpD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,gBAAgB,GAAI,GAAG,SAAS,MAAM,GAAG,gBAAgB,EAAE,8BAIrE,uBAAuB,CAAC,GAAG,CAAC;;;;;;;;;;;;;CAmV9B,CAAA"}
1
+ {"version":3,"file":"useFetchInfinite.d.ts","sourceRoot":"","sources":["../../../src/composables/useFetchInfinite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EAEpB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAAe,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACpE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAW9B,UAAU,uBAAuB,CAAC,GAAG,SAAS,MAAM,GAAG,gBAAgB;IACrE;;;OAGG;IACH,OAAO,EAAE,oBAAoB,CAAC,GAAG,CAAC,CAAA;IAClC;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAA;IACjC;;OAEG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAAC,CAAA;CACpD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,gBAAgB,GAAI,GAAG,SAAS,MAAM,GAAG,gBAAgB,EAAE,8BAIrE,uBAAuB,CAAC,GAAG,CAAC;;;;;;;;;;;;;CAsU9B,CAAA"}
@@ -8,16 +8,6 @@ import type { Ref, Slots } from 'vue';
8
8
  export declare const useTableDataGridColumnDefs: <Row extends object = TableDataGridRow>({ headers, slots, initialSort, }: {
9
9
  headers: Readonly<Ref<Array<TableDataGridHeader<Row>>>>;
10
10
  slots: Slots;
11
- /**
12
- * Sort to seed into AG Grid's initial column state, captured once (not a
13
- * reactive ref). This only covers the very first render, e.g. a
14
- * host-controlled `tableConfig` prop supplied at mount. Ongoing sort sync
15
- * after mount goes through `applyColumnState` (see `useTableDataGridSort`),
16
- * not through recomputing column defs — AG Grid already reflects a
17
- * grid-driven sort change internally, and re-pushing column defs on every
18
- * such change would redundantly re-trigger AG Grid's own column state
19
- * handling.
20
- */
21
11
  initialSort?: TableDataGridSort;
22
12
  }) => {
23
13
  columnDefs: import("vue").ComputedRef<ColDef<Row, any>[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"useTableDataGridColumnDefs.d.ts","sourceRoot":"","sources":["../../../src/composables/useTableDataGridColumnDefs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AACxF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,KAAK,CAAA;AAIrC;;;GAGG;AACH,eAAO,MAAM,0BAA0B,GAAI,GAAG,SAAS,MAAM,GAAG,gBAAgB,EAAE,kCAI/E;IACD,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IACvD,KAAK,EAAE,KAAK,CAAA;IACZ;;;;;;;;;OASG;IACH,WAAW,CAAC,EAAE,iBAAiB,CAAA;CAChC;;;;;;;;;CAiCA,CAAA"}
1
+ {"version":3,"file":"useTableDataGridColumnDefs.d.ts","sourceRoot":"","sources":["../../../src/composables/useTableDataGridColumnDefs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AACxF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,KAAK,CAAA;AAIrC;;;GAGG;AACH,eAAO,MAAM,0BAA0B,GAAI,GAAG,SAAS,MAAM,GAAG,gBAAgB,EAAE,kCAI/E;IACD,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IACvD,KAAK,EAAE,KAAK,CAAA;IACZ,WAAW,CAAC,EAAE,iBAAiB,CAAA;CAChC;;;;;;;;;CAiCA,CAAA"}
@@ -1,17 +1,9 @@
1
1
  import type { TableDataGridConfig, TableDataGridHeader, TableDataGridRow, TableDataGridSort } from '../types';
2
2
  import type { Ref } from 'vue';
3
3
  /**
4
- * Owns `TableDataGrid`'s current `tableConfig` state: resolves the
5
- * host-supplied (or absent) `tableConfig` prop against the current headers
6
- * and page size, mirrors it into an internal ref, and exposes a single
7
- * write path (`patchTableConfig`) for grid-driven changes.
8
- *
9
- * Grid-driven writes go through `patchTableConfig`, which mutates
10
- * `activeTableConfig` directly and never touches the prop, so they can
11
- * never re-trigger the prop watcher below. Host-driven writes (a changed
12
- * `tableConfig` prop) go through that watcher, which calls
13
- * `onExternalConfigChange` so the caller can push the change into AG Grid
14
- * imperatively, since it didn't originate from a grid interaction.
4
+ * Owns `TableDataGrid`'s current `tableConfig` state, controlled or
5
+ * uncontrolled, with `patchTableConfig` as the single write path for
6
+ * grid-driven changes.
15
7
  *
16
8
  * @param headers Current column headers, used to validate the resolved sort key.
17
9
  * @param pageSize Reactive component-level page size default.
@@ -1 +1 @@
1
- {"version":3,"file":"useTableDataGridConfig.d.ts","sourceRoot":"","sources":["../../../src/composables/useTableDataGridConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAC7G,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAI9B;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,sBAAsB,GAAI,GAAG,SAAS,MAAM,GAAG,gBAAgB,EAAE,qGAM3E;IACD,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IACvD,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;IAC/B,WAAW,EAAE,QAAQ,CAAC,GAAG,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAAC,CAAA;IAC3D,qBAAqB,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAA;IAC5D,sBAAsB,CAAC,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAA;CAC/D;;;;;;;;;;;;8BAckC,OAAO,CAAC,mBAAmB,CAAC;CAwB9D,CAAA"}
1
+ {"version":3,"file":"useTableDataGridConfig.d.ts","sourceRoot":"","sources":["../../../src/composables/useTableDataGridConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAC7G,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAI9B;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,GAAI,GAAG,SAAS,MAAM,GAAG,gBAAgB,EAAE,qGAM3E;IACD,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IACvD,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;IAC/B,WAAW,EAAE,QAAQ,CAAC,GAAG,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAAC,CAAA;IAC3D,qBAAqB,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAA;IAC5D,sBAAsB,CAAC,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAA;CAC/D;;;;;;;;;;;;8BAsBkC,OAAO,CAAC,mBAAmB,CAAC;CA8B9D,CAAA"}
@@ -2,15 +2,8 @@ import type { TableDataGridRow, TableDataGridSort } from '../types';
2
2
  import type { GridApi, SortChangedEvent } from 'ag-grid-community';
3
3
  import type { Ref } from 'vue';
4
4
  /**
5
- * Translates AG Grid's `sortChanged` event into `TableDataGrid`'s
6
- * package-owned `sort` shape, and pushes a host- or package-driven sort
7
- * back onto the grid.
8
- *
9
- * A grid-driven event is only acted on when it actually changes the
10
- * current sort — comparing against `activeSort` (rather than a mutable
11
- * re-entrancy flag) makes this idempotent, so it also absorbs the echo
12
- * `sortChanged` event that `applySortToGrid`'s own `applyColumnState` call
13
- * fires.
5
+ * Translates AG Grid's `sortChanged` event into `TableDataGrid`'s `sort`
6
+ * shape, and pushes a sort back onto the grid.
14
7
  *
15
8
  * @param activeSort Current resolved sort, read from `useTableDataGridConfig`.
16
9
  * @param emitSort Called with the new sort whenever a grid interaction changes it.
@@ -1 +1 @@
1
- {"version":3,"file":"useTableDataGridSort.d.ts","sourceRoot":"","sources":["../../../src/composables/useTableDataGridSort.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAA8B,MAAM,UAAU,CAAA;AAC/F,OAAO,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAE9B;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB,GAAI,GAAG,SAAS,MAAM,GAAG,gBAAgB,EAAE,6CAIzE;IACD,UAAU,EAAE,QAAQ,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAA;IAC5C,QAAQ,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,CAAA;IAC3C,gBAAgB,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAA;CAC9D;2BAU+B,gBAAgB,CAAC,GAAG,CAAC;2BATrB,OAAO,CAAC,GAAG,CAAC,QAAQ,iBAAiB;CAqCpE,CAAA"}
1
+ {"version":3,"file":"useTableDataGridSort.d.ts","sourceRoot":"","sources":["../../../src/composables/useTableDataGridSort.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAA8B,MAAM,UAAU,CAAA;AAC/F,OAAO,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAE9B;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,GAAI,GAAG,SAAS,MAAM,GAAG,gBAAgB,EAAE,6CAIzE;IACD,UAAU,EAAE,QAAQ,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAA;IAC5C,QAAQ,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,CAAA;IAC3C,gBAAgB,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAA;CAC9D;2BAU+B,gBAAgB,CAAC,GAAG,CAAC;2BATrB,OAAO,CAAC,GAAG,CAAC,QAAQ,iBAAiB;CAqCpE,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kong-ui-public/table-data-grid",
3
- "version": "0.4.2-pr.3761.bed46084d.0",
3
+ "version": "0.5.0",
4
4
  "type": "module",
5
5
  "main": "./dist/table-data-grid.umd.js",
6
6
  "module": "./dist/table-data-grid.es.js",
@@ -21,9 +21,9 @@
21
21
  "access": "public"
22
22
  },
23
23
  "devDependencies": {
24
+ "@kong-ui-public/i18n": "^2.5.1",
24
25
  "@kong/kongponents": "9.64.10",
25
- "vue": "^3.5.41",
26
- "@kong-ui-public/i18n": "^2.5.1"
26
+ "vue": "^3.5.41"
27
27
  },
28
28
  "repository": {
29
29
  "type": "git",
@@ -43,9 +43,9 @@
43
43
  "errorLimit": "500KB"
44
44
  },
45
45
  "peerDependencies": {
46
+ "@kong-ui-public/i18n": "^2.5.1",
46
47
  "@kong/kongponents": "^9.63.0",
47
- "vue": "^3.5.35",
48
- "@kong-ui-public/i18n": "^2.5.1"
48
+ "vue": "^3.5.35"
49
49
  },
50
50
  "dependencies": {
51
51
  "ag-grid-community": "^36.1.0",