@kong-ui-public/table-data-grid 0.4.1 → 0.4.2-pr.3761.40358052a.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
 
@@ -115,8 +115,9 @@ const handleState = (payload: TableDataGridStatePayload) => {
115
115
  | `headers` | `Array<TableDataGridHeader<Row>>` | Yes | - | Basic column definitions mapped to AG Grid columns. |
116
116
  | `fetcher` | `TableDataGridFetcher<Row>` | Yes | - | Async row loader called by the AG Grid infinite datasource. |
117
117
  | `error` | `boolean` | No | `false` | Host-controlled visible error state. Internal fetch failures emit state but do not render error UI unless this prop is true. |
118
- | `pageSize` | `number` | No | `25` | AG Grid cache block size and fetcher request size. |
118
+ | `pageSize` | `number` | No | `25` | AG Grid cache block size and fetcher request size. `tableConfig.pageSize` wins when present. |
119
119
  | `refreshKey` | `string \| number \| boolean` | No | - | Parent invalidation signal that rebuilds the datasource from the beginning. |
120
+ | `tableConfig` | `TableDataGridConfig` | No | - | Host-controlled current sort and page size. Restores a previously-chosen sort on mount, or moves it after mount, without a click. Uncontrolled (internal state) when omitted. |
120
121
 
121
122
  ## Fetcher Contract
122
123
 
@@ -128,6 +129,7 @@ type TableDataGridInfiniteFetcherParams = {
128
129
  mode: 'infinite'
129
130
  pageSize: number
130
131
  cursor?: unknown
132
+ sort?: TableDataGridSort
131
133
  }
132
134
 
133
135
  type TableDataGridFetcherResult<Row> = {
@@ -145,6 +147,12 @@ type TableDataGridFetcher<Row> = (
145
147
  `cursor` is an opaque token returned by the previous response. The first request
146
148
  uses `cursor: undefined`; later requests receive the previous response cursor.
147
149
 
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
+
148
156
  AG Grid range details are datasource internals. Consumers should not depend on,
149
157
  or return, datasource request positions or AG Grid row-count callback values in
150
158
  the public fetcher contract.
@@ -213,6 +221,36 @@ should opt out of the default flexible fill behavior.
213
221
  | `minWidth` | `number` | No | Minimum AG Grid column width in pixels. Columns with only `minWidth` still fill available width by default. |
214
222
  | `maxWidth` | `number` | No | Maximum AG Grid column width in pixels. Columns with `maxWidth` do not receive default flex sizing. |
215
223
  | `disableRowClick` | `boolean` | No | Suppresses `row:click` for clicks landing in this column's cells, e.g. an actions column. `cell:click` still fires. |
224
+ | `sortable` | `boolean` | No | Enables sorting on this column via AG Grid's built-in header sort control. Only one column can be sorted at a time. |
225
+ | `showSortIcon` | `boolean` | No | Shows the unsorted sort icon on this column even when it isn't the active sort, instead of only on hover or once sorted. Only relevant when `sortable` is true. |
226
+
227
+ ## Sorting
228
+
229
+ `TableDataGrid` supports sorting by a single column at a time. Mark a column
230
+ sortable with `header.sortable`, and AG Grid renders its built-in sort icon
231
+ and handles the click. Sorting a second column replaces the first; AG Grid's
232
+ shift-click multi-sort gesture is disabled.
233
+
234
+ ```vue
235
+ <TableDataGrid
236
+ :fetcher="fetchRows"
237
+ :headers="[
238
+ { key: 'name', label: 'Name', sortable: true },
239
+ { key: 'status', label: 'Status', sortable: true },
240
+ ]"
241
+ :table-config="tableConfig"
242
+ @sort="handleSort"
243
+ @update:table-config="tableConfig = $event"
244
+ />
245
+ ```
246
+
247
+ The current sort lives in `tableConfig` (`sortColumnKey`, `sortColumnOrder`),
248
+ alongside `pageSize`. Pass `tableConfig` to restore a previously-chosen sort
249
+ on mount, or to move the sort after mount without a click; omit it to let the
250
+ component own the sort internally. A sort change emits `sort` (the narrower,
251
+ sort-only payload) and then `update:tableConfig` (the full current config),
252
+ and rebuilds the infinite datasource from the beginning — a cursor produced
253
+ under one sort order is not valid under another.
216
254
 
217
255
  ## Custom Cell Content
218
256
 
@@ -249,6 +287,8 @@ Columns without a matching slot render their raw `rowValue`.
249
287
  | `state` | `{ state: 'loading' \| 'success' \| 'error', hasData: boolean }` | Internal fetch lifecycle changes after the datasource starts requesting rows. |
250
288
  | `row:click` | `(row: TableDataGridRowClickPayload<Row>, event: RowClickedEvent<Row>)` | A row is clicked, unless the click landed in a `disableRowClick` column. |
251
289
  | `cell:click` | `TableDataGridCellClickPayload<Row>` | Any cell is clicked, including cells in `disableRowClick` columns. |
290
+ | `sort` | `TableDataGridSort` | The current single-column sort changes. Fires before `update:tableConfig`. |
291
+ | `update:tableConfig` | `TableDataGridConfig` | A meaningful change to the current table configuration (sort or page size). |
252
292
 
253
293
  ## Slots
254
294
 
@@ -272,3 +312,6 @@ Columns without a matching slot render their raw `rowValue`.
272
312
  - `TableDataGridFetcherResult`
273
313
  - `TableDataGridFetcher`
274
314
  - `TableDataGridReadyPayload`
315
+ - `TableDataGridSortDirection`
316
+ - `TableDataGridSort`
317
+ - `TableDataGridConfig`
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-e14d8346]{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-e14d8346]{--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,428 +1,517 @@
1
- import { computed as g, watch as T, ref as I, shallowRef as N, readonly as G, defineComponent as L, onMounted as $, onUnmounted as P, nextTick as j, resolveComponent as U, openBlock as R, createBlock as V, resolveDynamicComponent as q, createElementBlock as x, createVNode as O, withCtx as H, createElementVNode as Q, toDisplayString as J, useSlots as X, toRef as A, renderSlot as K, unref as C } from "vue";
2
- import { AgGridVue as Y } from "ag-grid-vue3";
3
- import { ModuleRegistry as Z, AllCommunityModule as ee, InfiniteRowModelModule as te, themeQuartz as ae } from "ag-grid-community";
4
- import { createI18n as oe, i18nTComponent as le } from "@kong-ui-public/i18n";
5
- var F = /* @__PURE__ */ ((e) => (e.PENDING = "PENDING", e.LOADING = "LOADING", e.SUCCESS = "SUCCESS", e.ERROR = "ERROR", e))(F || {});
6
- const ne = (e) => !!e?.length;
7
- function re(e, c, t, a = ne) {
8
- const r = g(() => a(e.value)), i = g(() => {
9
- const y = e.value !== void 0, o = c.value !== void 0 && c.value !== null;
10
- return t.value ? "LOADING" : r.value ? "SUCCESS" : o ? "ERROR" : y ? "SUCCESS" : "PENDING";
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
+ import { AgGridVue as te } from "ag-grid-vue3";
3
+ import { ModuleRegistry as oe, AllCommunityModule as ae, InfiniteRowModelModule as le, themeQuartz as re } from "ag-grid-community";
4
+ import { createI18n as ne, i18nTComponent as se } from "@kong-ui-public/i18n";
5
+ var T = /* @__PURE__ */ ((e) => (e.PENDING = "PENDING", e.LOADING = "LOADING", e.SUCCESS = "SUCCESS", e.ERROR = "ERROR", e))(T || {});
6
+ const ie = (e) => !!e?.length;
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: F,
14
- hasData: r,
13
+ fetchState: T,
14
+ hasData: n,
15
15
  state: i
16
16
  };
17
17
  }
18
- const se = ({
18
+ const ue = ({
19
19
  emitState: e,
20
- fetchLifecycleState: c,
20
+ fetchLifecycleState: r,
21
21
  hasData: t
22
22
  }) => {
23
- T(
23
+ B(
24
24
  () => ({
25
25
  hasData: t.value,
26
- state: c.value
26
+ state: r.value
27
27
  }),
28
- ({ hasData: a, state: r }) => {
29
- if (r !== F.PENDING) {
30
- if (r === F.LOADING) {
28
+ ({ hasData: l, state: n }) => {
29
+ if (n !== T.PENDING) {
30
+ if (n === T.LOADING) {
31
31
  e({
32
- hasData: a,
32
+ hasData: l,
33
33
  state: "loading"
34
34
  });
35
35
  return;
36
36
  }
37
- if (r === F.ERROR) {
37
+ if (n === T.ERROR) {
38
38
  e({
39
- hasData: a,
39
+ hasData: l,
40
40
  state: "error"
41
41
  });
42
42
  return;
43
43
  }
44
44
  e({
45
- hasData: a,
45
+ hasData: l,
46
46
  state: "success"
47
47
  });
48
48
  }
49
49
  }
50
50
  );
51
- }, ce = ({ startRow: e, endRow: c }) => {
52
- const t = c - 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
- }, ie = ({
57
+ }, me = ({
58
58
  startRow: e,
59
- rowsLength: c,
59
+ rowsLength: r,
60
60
  pageSize: t,
61
- total: a,
62
- hasMore: r
61
+ total: l,
62
+ hasMore: n
63
63
  }) => {
64
- if (typeof a == "number")
65
- return a;
66
- if (r !== !0 && (r === !1 || c < t))
67
- return e + c;
68
- }, ue = ({
64
+ if (typeof l == "number")
65
+ return l;
66
+ if (n !== !0 && (n === !1 || r < t))
67
+ return e + r;
68
+ }, fe = ({
69
69
  fetcher: e,
70
- resetKey: c
70
+ resetKey: r,
71
+ sort: t
71
72
  }) => {
72
- const t = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), r = I(0), i = N(), v = N(), y = N(), o = I(0), u = I(!1), m = (l) => l === r.value, k = () => {
73
- u.value = o.value > 0;
74
- }, E = () => {
75
- y.value = void 0, o.value += 1, k();
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();
76
77
  }, w = () => {
77
- o.value = Math.max(0, o.value - 1), k();
78
- }, D = (l) => {
79
- const s = a.get(l);
80
- if (s)
81
- return s;
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;
82
83
  let d;
83
84
  const h = {
84
- promise: new Promise((f) => {
85
- d = f;
85
+ promise: new Promise((m) => {
86
+ d = m;
86
87
  }),
87
- resolve: (f) => d(f)
88
+ resolve: (m) => d(m)
88
89
  };
89
- return a.set(l, h), h;
90
- }, n = (l, s) => {
91
- s.resolve(!1), a.get(l) === s && a.delete(l);
92
- }, b = async ({
93
- blockIndex: l,
94
- currentBlockCompletion: s,
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,
95
96
  datasourceId: d
96
97
  }) => {
97
- if (l === 0)
98
+ if (c === 0)
98
99
  return "ready";
99
- const h = a.get(l - 1);
100
+ const h = n.get(c - 1);
100
101
  if (!h)
101
- return n(l, s), "failed";
102
- const f = await h.promise;
103
- return m(d) ? f ? "ready" : (n(l, s), "failed") : (n(l, s), "stale");
104
- }, S = ({
105
- blockIndex: l,
106
- currentBlockCompletion: s,
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,
107
108
  getRowsParams: d,
108
109
  pageSize: h,
109
- result: f
110
+ result: m
110
111
  }) => {
111
- f.cursor !== void 0 && t.set(l, f.cursor), d.successCallback(f.data, ie({
112
+ m.cursor !== void 0 && l.set(c, m.cursor), d.successCallback(m.data, me({
112
113
  startRow: d.startRow,
113
- rowsLength: f.data.length,
114
+ rowsLength: m.data.length,
114
115
  pageSize: h,
115
- total: f.total,
116
- hasMore: f.hasMore
117
- })), d.startRow === 0 && (v.value = f.data), s.resolve(!0);
116
+ total: m.total,
117
+ hasMore: m.hasMore
118
+ })), d.startRow === 0 && (f.value = m.data), u.resolve(!0);
118
119
  }, _ = ({
119
- blockIndex: l,
120
- currentBlockCompletion: s,
120
+ blockIndex: c,
121
+ currentBlockCompletion: u,
121
122
  fetchError: d,
122
123
  getRowsParams: h
123
124
  }) => {
124
- y.value = d, h.failCallback(), n(l, s);
125
- }, B = () => {
126
- const l = r.value + 1;
127
- return r.value = l, t.clear(), a.clear(), v.value = void 0, y.value = void 0, o.value = 0, k(), {
128
- async getRows(s) {
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
131
  blockIndex: d,
131
132
  pageSize: h
132
- } = ce({
133
- startRow: s.startRow,
134
- endRow: s.endRow
135
- }), f = D(d), z = await b({
133
+ } = de({
134
+ startRow: u.startRow,
135
+ endRow: u.endRow
136
+ }), m = C(d);
137
+ if (await K({
136
138
  blockIndex: d,
137
- currentBlockCompletion: f,
138
- datasourceId: l
139
- });
140
- if (z !== "ready") {
141
- z === "failed" && s.failCallback();
139
+ currentBlockCompletion: m,
140
+ datasourceId: c
141
+ }) !== "ready") {
142
+ u.failCallback();
142
143
  return;
143
144
  }
144
- E();
145
+ g(c) && D();
145
146
  try {
146
- const M = d > 0 ? t.get(d - 1) : void 0, W = await e({
147
+ const R = d > 0 ? l.get(d - 1) : void 0, z = await e({
147
148
  mode: "infinite",
148
149
  pageSize: h,
149
- cursor: M
150
+ cursor: R,
151
+ // Always read the latest sort, not a stale one.
152
+ sort: t?.value
150
153
  });
151
- if (!m(l)) {
152
- n(d, f);
154
+ if (!g(c)) {
155
+ u.failCallback(), b(d, m);
153
156
  return;
154
157
  }
155
- S({
158
+ M({
156
159
  blockIndex: d,
157
- currentBlockCompletion: f,
158
- getRowsParams: s,
160
+ currentBlockCompletion: m,
161
+ getRowsParams: u,
159
162
  pageSize: h,
160
- result: W
163
+ result: z
161
164
  });
162
- } catch (M) {
163
- if (!m(l)) {
164
- n(d, f);
165
+ } catch (R) {
166
+ if (!g(c)) {
167
+ u.failCallback(), b(d, m);
165
168
  return;
166
169
  }
167
170
  _({
168
171
  blockIndex: d,
169
- currentBlockCompletion: f,
170
- fetchError: M,
171
- getRowsParams: s
172
+ currentBlockCompletion: m,
173
+ fetchError: R,
174
+ getRowsParams: u
172
175
  });
173
176
  } finally {
174
- m(l) && w();
177
+ g(c) && w();
175
178
  }
176
179
  }
177
180
  };
178
- }, p = () => {
179
- i.value = B();
181
+ }, F = () => {
182
+ o.value = A();
180
183
  };
181
- return T(
182
- () => c?.value,
184
+ return B(
185
+ () => r?.value,
183
186
  () => {
184
- p();
187
+ F();
185
188
  },
186
189
  { immediate: !0 }
187
190
  ), {
188
- datasource: G(i),
189
- data: G(v),
190
- error: G(y),
191
- isFetching: G(u)
191
+ datasource: x(o),
192
+ data: x(f),
193
+ error: x(a),
194
+ isFetching: x(v)
192
195
  };
193
- }, de = {
196
+ }, ve = {
194
197
  key: 1,
195
198
  class: "table-data-grid-cell-renderer"
196
- }, fe = /* @__PURE__ */ L({
199
+ }, Ce = /* @__PURE__ */ $({
197
200
  name: "TableDataGridCellRenderer",
198
201
  __name: "TableDataGridCellRenderer",
199
202
  props: {
200
203
  params: {}
201
204
  },
202
- setup(e, { expose: c }) {
203
- const t = N(e.params), a = I(null), r = I(!1), i = g(() => t.value.valueFormatted ?? String(t.value.value ?? "")), v = g(() => {
204
- const n = t.value.colDef?.colId;
205
- return n ? t.value.context?.cells?.slots?.[n] : void 0;
206
- }), y = g(() => ({
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(() => ({
207
210
  column: t.value.headerDef,
208
211
  refreshCell: () => {
209
- const n = t.value.node;
210
- n && t.value.api.refreshCells({ force: !0, rowNodes: [n] });
212
+ const C = t.value.node;
213
+ C && t.value.api.refreshCells({ force: !0, rowNodes: [C] });
211
214
  },
212
215
  row: t.value.data ?? {},
213
216
  rowIndex: t.value.node?.rowIndex ?? 0,
214
217
  rowValue: t.value.value,
215
218
  selected: t.value.node?.isSelected() ?? !1
216
- })), o = () => v.value?.(y.value);
217
- let u, m, k = !1;
218
- const E = () => {
219
- const n = a.value;
220
- r.value = !!n && n.scrollWidth > n.clientWidth;
221
- }, w = () => {
222
- k || (m !== void 0 && cancelAnimationFrame(m), m = requestAnimationFrame(() => {
223
- m = void 0, E();
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;
224
+ }, D = () => {
225
+ g || (v !== void 0 && cancelAnimationFrame(v), v = requestAnimationFrame(() => {
226
+ v = void 0, k();
224
227
  }));
225
- }, D = (n) => {
226
- if (u?.disconnect(), n) {
227
- u?.observe(n);
228
- const b = n.closest(".ag-cell");
229
- b && u?.observe(b);
228
+ }, w = (C) => {
229
+ if (s?.disconnect(), C) {
230
+ s?.observe(C);
231
+ const b = C.closest(".ag-cell");
232
+ b && s?.observe(b);
230
233
  }
231
- w();
234
+ D();
232
235
  };
233
- return $(() => {
234
- u = new ResizeObserver(w), D(a.value);
235
- }), T(a, D, { flush: "post" }), P(() => {
236
- k = !0, u?.disconnect(), m !== void 0 && cancelAnimationFrame(m);
237
- }), c({
238
- refresh(n) {
239
- return t.value = n, j(w), !0;
236
+ return j(() => {
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;
240
243
  }
241
- }), (n, b) => {
242
- const S = U("KTooltip");
243
- return v.value ? (R(), V(q(o), { key: 0 })) : (R(), x("span", de, [
244
- O(S, {
244
+ }), (C, b) => {
245
+ const K = q("KTooltip");
246
+ return o.value ? (I(), P(J(a), { key: 0 })) : (I(), N("span", ve, [
247
+ L(K, {
245
248
  class: "table-data-grid-cell-tooltip",
246
- disabled: !r.value,
249
+ disabled: !n.value,
247
250
  "kpop-attributes": { popoverDelay: 400 },
248
251
  "max-width": "300",
249
252
  placement: "bottom-start",
250
253
  target: "body",
251
254
  text: i.value
252
255
  }, {
253
- default: H(() => [
254
- Q("span", {
256
+ default: X(() => [
257
+ Y("span", {
255
258
  ref_key: "contentElement",
256
- ref: a,
259
+ ref: l,
257
260
  class: "table-data-grid-cell-content"
258
- }, J(i.value), 513)
261
+ }, Z(i.value), 513)
259
262
  ]),
260
263
  _: 1
261
264
  }, 8, ["disabled", "text"])
262
265
  ]));
263
266
  };
264
267
  }
265
- }), me = ({
268
+ }), pe = ({
269
+ headers: e,
270
+ slots: r,
271
+ initialSort: t
272
+ }) => {
273
+ const l = S(() => ({
274
+ cells: { slots: r }
275
+ })), n = (o) => {
276
+ const f = t?.sortColumnKey === o.key;
277
+ return {
278
+ colId: o.key,
279
+ // Columns with no explicit width constraint share remaining space equally.
280
+ flex: !o.width && !o.maxWidth ? 1 : void 0,
281
+ headerName: o.label,
282
+ maxWidth: o.maxWidth,
283
+ minWidth: o.minWidth,
284
+ sortable: o.sortable ?? !1,
285
+ unSortIcon: o.showSortIcon,
286
+ ...f ? { initialSort: t?.sortColumnOrder, initialSortIndex: 0 } : {},
287
+ valueGetter: (a) => a.data?.[o.key],
288
+ width: o.width,
289
+ cellRenderer: Ce,
290
+ // custom params passed to the cell renderer.
291
+ cellRendererParams: { headerDef: o }
292
+ };
293
+ };
294
+ return {
295
+ columnDefs: S(() => e.value.map(n)),
296
+ gridContext: l
297
+ };
298
+ }, U = ({
299
+ config: e,
300
+ headers: r,
301
+ pageSize: t
302
+ }) => {
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;
304
+ return {
305
+ sortColumnKey: n,
306
+ sortColumnOrder: n ? e?.sortColumnOrder : void 0,
307
+ pageSize: e?.pageSize ?? t
308
+ };
309
+ }, W = (e, r) => e.sortColumnKey === r.sortColumnKey && e.sortColumnOrder === r.sortColumnOrder && e.pageSize === r.pageSize, ge = ({
266
310
  headers: e,
267
- slots: c
311
+ pageSize: r,
312
+ tableConfig: t,
313
+ emitTableConfigUpdate: l,
314
+ onExternalConfigChange: n
268
315
  }) => {
269
- const t = g(() => ({
270
- cells: { slots: c }
271
- })), a = (i) => ({
272
- colId: i.key,
273
- // Columns with no explicit width constraint share remaining space equally.
274
- flex: !i.width && !i.maxWidth ? 1 : void 0,
275
- headerName: i.label,
276
- maxWidth: i.maxWidth,
277
- minWidth: i.minWidth,
278
- valueGetter: (v) => v.data?.[i.key],
279
- width: i.width,
280
- cellRenderer: fe,
281
- // custom params passed to the cell renderer.
282
- cellRendererParams: { headerDef: i }
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));
283
321
  });
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(() => ({
330
+ sortColumnKey: o.value.sortColumnKey,
331
+ sortColumnOrder: o.value.sortColumnOrder
332
+ })), s = S(() => t.value?.pageSize ?? r.value);
284
333
  return {
285
- columnDefs: g(() => e.value.map(a)),
286
- gridContext: t
334
+ activeTableConfig: x(o),
335
+ activeSort: a,
336
+ activePageSize: s,
337
+ patchTableConfig: f
287
338
  };
288
- }, ve = ({
339
+ }, he = ({
289
340
  cellClick: e,
290
- headers: c,
341
+ headers: r,
291
342
  rowClick: t
292
343
  }) => {
293
- const a = g(() => new Set(
294
- c.value.filter((o) => o.disableRowClick).map((o) => o.key)
295
- )), r = (o) => {
296
- const u = o.event?.target;
297
- return u instanceof Element ? u.closest(".ag-cell")?.getAttribute("col-id") ?? void 0 : void 0;
298
- }, i = (o) => {
299
- const u = r(o);
300
- return !!(u && a.value.has(u));
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));
301
352
  };
302
353
  return {
303
- onCellClick: (o) => {
304
- const u = o.colDef.colId;
305
- !o.data || !u || e({
306
- columnKey: u,
307
- row: o.data,
308
- value: o.value
354
+ onCellClick: (a) => {
355
+ const s = a.colDef.colId;
356
+ !a.data || !s || e({
357
+ columnKey: s,
358
+ row: a.data,
359
+ value: a.value
309
360
  });
310
361
  },
311
- onRowClick: (o) => {
312
- o.data && !i(o) && t(o.data, o);
362
+ onRowClick: (a) => {
363
+ a.data && !i(a) && t(a.data, a);
313
364
  }
314
365
  };
315
- }, pe = { title: "No Data", message: "There is no data to display." }, he = { title: "An error occurred", message: "Data cannot be displayed due to an error." }, Ce = {
316
- emptyState: pe,
317
- errorState: he
366
+ }, ye = ({
367
+ activeSort: e,
368
+ emitSort: r,
369
+ patchTableConfig: t
370
+ }) => {
371
+ const l = (i, o) => {
372
+ i.applyColumnState({
373
+ state: o.sortColumnKey ? [{ colId: o.sortColumnKey, sort: o.sortColumnOrder ?? null, sortIndex: 0 }] : [],
374
+ defaultState: { sort: null, sortIndex: null }
375
+ });
376
+ };
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));
380
+ }, applySortToGrid: l };
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
318
384
  };
319
- function ye() {
320
- const e = oe("en-us", Ce);
385
+ function De() {
386
+ const e = ne("en-us", ke);
321
387
  return {
322
388
  i18n: e,
323
- i18nT: le(e)
389
+ i18nT: se(e)
324
390
  // Translation component <i18n-t>
325
391
  };
326
392
  }
327
- const ge = {
393
+ const we = {
328
394
  class: "kong-ui-public-table-data-grid",
329
395
  "data-testid": "table-data-grid"
330
- }, ke = {
396
+ }, Re = {
331
397
  key: 0,
332
398
  class: "table-error-state",
333
399
  "data-testid": "table-error-state"
334
- }, be = {
400
+ }, Ie = {
335
401
  key: 1,
336
402
  class: "table-empty-state",
337
403
  "data-testid": "table-empty-state"
338
- }, we = /* @__PURE__ */ L({
404
+ }, Ee = /* @__PURE__ */ $({
339
405
  __name: "TableDataGrid",
340
406
  props: {
341
407
  headers: {},
342
408
  fetcher: { type: Function },
343
409
  error: { type: Boolean, default: !1 },
344
410
  pageSize: { default: 25 },
345
- refreshKey: { type: [String, Number, Boolean] }
411
+ refreshKey: { type: [String, Number, Boolean] },
412
+ tableConfig: {}
346
413
  },
347
- emits: ["grid:ready", "state", "row:click", "cell:click"],
348
- setup(e, { emit: c }) {
349
- Z.registerModules([ee, te]);
350
- const t = c, { i18n: { t: a } } = ye(), r = X(), { columnDefs: i, gridContext: v } = me({
351
- headers: A(() => e.headers),
352
- slots: r
353
- }), { onCellClick: y, onRowClick: o } = ve({
414
+ emits: ["grid:ready", "state", "row:click", "cell:click", "sort", "update:tableConfig"],
415
+ setup(e, { emit: r }) {
416
+ oe.registerModules([ae, le]);
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),
421
+ emitTableConfigUpdate: (p) => t("update:tableConfig", p),
422
+ onExternalConfigChange: (p) => {
423
+ i.value && g(i.value, p);
424
+ }
425
+ }), { onSortChanged: v, applySortToGrid: g } = ye({
426
+ activeSort: f,
427
+ emitSort: (p) => t("sort", p),
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({
354
434
  cellClick: (p) => t("cell:click", p),
355
- headers: A(() => e.headers),
356
- rowClick: (p, l) => t("row:click", p, l)
357
- }), u = {
435
+ headers: O(() => e.headers),
436
+ rowClick: (p, R) => t("row:click", p, R)
437
+ }), b = {
358
438
  resizable: !1,
359
439
  sortable: !1,
360
440
  suppressMovable: !0
361
- }, m = g(() => [e.fetcher, e.pageSize, e.refreshKey]), {
362
- data: k,
363
- datasource: E,
364
- error: w,
365
- isFetching: D
366
- } = ue({
441
+ }, K = S(() => [
442
+ e.fetcher,
443
+ a.value,
444
+ e.refreshKey,
445
+ o.value.sortColumnKey,
446
+ o.value.sortColumnOrder
447
+ ]), {
448
+ data: M,
449
+ datasource: _,
450
+ error: A,
451
+ isFetching: F
452
+ } = fe({
367
453
  fetcher: e.fetcher,
368
- resetKey: m
454
+ resetKey: K,
455
+ sort: f
369
456
  }), {
370
- fetchState: n,
371
- hasData: b,
372
- state: S
373
- } = re(k, w, D), _ = g(() => S.value === n.SUCCESS && !b.value);
374
- se({
457
+ fetchState: c,
458
+ hasData: u,
459
+ state: d
460
+ } = ce(M, A, F), h = S(() => d.value === c.SUCCESS && !u.value);
461
+ ue({
375
462
  emitState: (p) => t("state", p),
376
- fetchLifecycleState: S,
377
- hasData: b
463
+ fetchLifecycleState: d,
464
+ hasData: u
378
465
  });
379
- const B = (p) => {
380
- t("grid:ready", p.api);
466
+ const m = (p) => {
467
+ i.value = p.api, t("grid:ready", p.api);
381
468
  };
382
- return (p, l) => {
383
- const s = U("KEmptyState");
384
- return R(), x("div", ge, [
385
- e.error ? (R(), x("div", ke, [
386
- K(p.$slots, "error-state", {}, () => [
387
- O(s, {
469
+ return (p, R) => {
470
+ const z = q("KEmptyState");
471
+ return I(), N("div", we, [
472
+ e.error ? (I(), N("div", Re, [
473
+ V(p.$slots, "error-state", {}, () => [
474
+ L(z, {
388
475
  "icon-variant": "error",
389
- message: C(a)("errorState.message"),
390
- title: C(a)("errorState.title")
476
+ message: y(l)("errorState.message"),
477
+ title: y(l)("errorState.title")
391
478
  }, null, 8, ["message", "title"])
392
479
  ], !0)
393
- ])) : _.value ? (R(), x("div", be, [
394
- K(p.$slots, "empty-state", {}, () => [
395
- O(s, {
396
- message: C(a)("emptyState.message"),
397
- title: C(a)("emptyState.title")
480
+ ])) : h.value ? (I(), N("div", Ie, [
481
+ V(p.$slots, "empty-state", {}, () => [
482
+ L(z, {
483
+ message: y(l)("emptyState.message"),
484
+ title: y(l)("emptyState.title")
398
485
  }, null, 8, ["message", "title"])
399
486
  ], !0)
400
- ])) : (R(), V(C(Y), {
487
+ ])) : (I(), P(y(te), {
401
488
  key: 2,
402
- "cache-block-size": e.pageSize,
489
+ "cache-block-size": y(a),
403
490
  class: "table-data-grid-grid",
404
- "column-defs": C(i),
405
- context: C(v),
406
- datasource: C(E),
407
- "default-col-def": u,
491
+ "column-defs": y(k),
492
+ context: y(D),
493
+ datasource: y(_),
494
+ "default-col-def": b,
408
495
  "infinite-initial-row-count": 1,
409
- loading: C(D),
496
+ loading: y(F),
410
497
  "row-model-type": "infinite",
411
498
  "suppress-cell-focus": !0,
412
- theme: C(ae),
413
- onCellClicked: C(y),
414
- onGridReady: B,
415
- onRowClicked: C(o)
416
- }, null, 8, ["cache-block-size", "column-defs", "context", "datasource", "loading", "theme", "onCellClicked", "onRowClicked"]))
499
+ "suppress-multi-sort": !0,
500
+ theme: y(re),
501
+ onCellClicked: y(w),
502
+ onGridReady: m,
503
+ onRowClicked: y(C),
504
+ onSortChanged: y(v)
505
+ }, null, 8, ["cache-block-size", "column-defs", "context", "datasource", "loading", "theme", "onCellClicked", "onRowClicked", "onSortChanged"]))
417
506
  ]);
418
507
  };
419
508
  }
420
- }), De = (e, c) => {
509
+ }), Ke = (e, r) => {
421
510
  const t = e.__vccOpts || e;
422
- for (const [a, r] of c)
423
- t[a] = r;
511
+ for (const [l, n] of r)
512
+ t[l] = n;
424
513
  return t;
425
- }, Fe = /* @__PURE__ */ De(we, [["__scopeId", "data-v-e14d8346"]]);
514
+ }, Fe = /* @__PURE__ */ Ke(Ee, [["__scopeId", "data-v-d8328fe5"]]);
426
515
  export {
427
516
  Fe as TableDataGrid
428
517
  };
@@ -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,B,x){"use strict";var v=(t=>(t.PENDING="PENDING",t.LOADING="LOADING",t.SUCCESS="SUCCESS",t.ERROR="ERROR",t))(v||{});const M=t=>!!t?.length;function T(t,i,o,a=M){const s=e.computed(()=>a(t.value)),d=e.computed(()=>{const k=t.value!==void 0,n=i.value!==void 0&&i.value!==null;return o.value?"LOADING":s.value?"SUCCESS":n?"ERROR":k?"SUCCESS":"PENDING"});return{fetchState:v,hasData:s,state:d}}const O=({emitState:t,fetchLifecycleState:i,hasData:o})=>{e.watch(()=>({hasData:o.value,state:i.value}),({hasData:a,state:s})=>{if(s!==v.PENDING){if(s===v.LOADING){t({hasData:a,state:"loading"});return}if(s===v.ERROR){t({hasData:a,state:"error"});return}t({hasData:a,state:"success"})}})},A=({startRow:t,endRow:i})=>{const o=i-t;return{blockIndex:o>0?Math.floor(t/o):0,pageSize:o}},z=({startRow:t,rowsLength:i,pageSize:o,total:a,hasMore:s})=>{if(typeof a=="number")return a;if(s!==!0&&(s===!1||i<o))return t+i},K=({fetcher:t,resetKey:i})=>{const o=new Map,a=new Map,s=e.ref(0),d=e.shallowRef(),h=e.shallowRef(),k=e.shallowRef(),n=e.ref(0),u=e.ref(!1),p=l=>l===s.value,b=()=>{u.value=n.value>0},E=()=>{k.value=void 0,n.value+=1,b()},S=()=>{n.value=Math.max(0,n.value-1),b()},D=l=>{const c=a.get(l);if(c)return c;let f;const g={promise:new Promise(m=>{f=m}),resolve:m=>f(m)};return a.set(l,g),g},r=(l,c)=>{c.resolve(!1),a.get(l)===c&&a.delete(l)},w=async({blockIndex:l,currentBlockCompletion:c,datasourceId:f})=>{if(l===0)return"ready";const g=a.get(l-1);if(!g)return r(l,c),"failed";const m=await g.promise;return p(f)?m?"ready":(r(l,c),"failed"):(r(l,c),"stale")},R=({blockIndex:l,currentBlockCompletion:c,getRowsParams:f,pageSize:g,result:m})=>{m.cursor!==void 0&&o.set(l,m.cursor),f.successCallback(m.data,z({startRow:f.startRow,rowsLength:m.data.length,pageSize:g,total:m.total,hasMore:m.hasMore})),f.startRow===0&&(h.value=m.data),c.resolve(!0)},I=({blockIndex:l,currentBlockCompletion:c,fetchError:f,getRowsParams:g})=>{k.value=f,g.failCallback(),r(l,c)},N=()=>{const l=s.value+1;return s.value=l,o.clear(),a.clear(),h.value=void 0,k.value=void 0,n.value=0,b(),{async getRows(c){const{blockIndex:f,pageSize:g}=A({startRow:c.startRow,endRow:c.endRow}),m=D(f),F=await w({blockIndex:f,currentBlockCompletion:m,datasourceId:l});if(F!=="ready"){F==="failed"&&c.failCallback();return}E();try{const _=f>0?o.get(f-1):void 0,J=await t({mode:"infinite",pageSize:g,cursor:_});if(!p(l)){r(f,m);return}R({blockIndex:f,currentBlockCompletion:m,getRowsParams:c,pageSize:g,result:J})}catch(_){if(!p(l)){r(f,m);return}I({blockIndex:f,currentBlockCompletion:m,fetchError:_,getRowsParams:c})}finally{p(l)&&S()}}}},C=()=>{d.value=N()};return e.watch(()=>i?.value,()=>{C()},{immediate:!0}),{datasource:e.readonly(d),data:e.readonly(h),error:e.readonly(k),isFetching:e.readonly(u)}},V={key:1,class:"table-data-grid-cell-renderer"},L=e.defineComponent({name:"TableDataGridCellRenderer",__name:"TableDataGridCellRenderer",props:{params:{}},setup(t,{expose:i}){const o=e.shallowRef(t.params),a=e.ref(null),s=e.ref(!1),d=e.computed(()=>o.value.valueFormatted??String(o.value.value??"")),h=e.computed(()=>{const r=o.value.colDef?.colId;return r?o.value.context?.cells?.slots?.[r]:void 0}),k=e.computed(()=>({column:o.value.headerDef,refreshCell:()=>{const r=o.value.node;r&&o.value.api.refreshCells({force:!0,rowNodes:[r]})},row:o.value.data??{},rowIndex:o.value.node?.rowIndex??0,rowValue:o.value.value,selected:o.value.node?.isSelected()??!1})),n=()=>h.value?.(k.value);let u,p,b=!1;const E=()=>{const r=a.value;s.value=!!r&&r.scrollWidth>r.clientWidth},S=()=>{b||(p!==void 0&&cancelAnimationFrame(p),p=requestAnimationFrame(()=>{p=void 0,E()}))},D=r=>{if(u?.disconnect(),r){u?.observe(r);const w=r.closest(".ag-cell");w&&u?.observe(w)}S()};return e.onMounted(()=>{u=new ResizeObserver(S),D(a.value)}),e.watch(a,D,{flush:"post"}),e.onUnmounted(()=>{b=!0,u?.disconnect(),p!==void 0&&cancelAnimationFrame(p)}),i({refresh(r){return o.value=r,e.nextTick(S),!0}}),(r,w)=>{const R=e.resolveComponent("KTooltip");return h.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n),{key:0})):(e.openBlock(),e.createElementBlock("span",V,[e.createVNode(R,{class:"table-data-grid-cell-tooltip",disabled:!s.value,"kpop-attributes":{popoverDelay:400},"max-width":"300",placement:"bottom-start",target:"body",text:d.value},{default:e.withCtx(()=>[e.createElementVNode("span",{ref_key:"contentElement",ref:a,class:"table-data-grid-cell-content"},e.toDisplayString(d.value),513)]),_:1},8,["disabled","text"])]))}}}),U=({headers:t,slots:i})=>{const o=e.computed(()=>({cells:{slots:i}})),a=d=>({colId:d.key,flex:!d.width&&!d.maxWidth?1:void 0,headerName:d.label,maxWidth:d.maxWidth,minWidth:d.minWidth,valueGetter:h=>h.data?.[d.key],width:d.width,cellRenderer:L,cellRendererParams:{headerDef:d}});return{columnDefs:e.computed(()=>t.value.map(a)),gridContext:o}},W=({cellClick:t,headers:i,rowClick:o})=>{const a=e.computed(()=>new Set(i.value.filter(n=>n.disableRowClick).map(n=>n.key))),s=n=>{const u=n.event?.target;return u instanceof Element?u.closest(".ag-cell")?.getAttribute("col-id")??void 0:void 0},d=n=>{const u=s(n);return!!(u&&a.value.has(u))};return{onCellClick:n=>{const u=n.colDef.colId;!n.data||!u||t({columnKey:u,row:n.data,value:n.value})},onRowClick:n=>{n.data&&!d(n)&&o(n.data,n)}}},q={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 $(){const t=x.createI18n("en-us",q);return{i18n:t,i18nT:x.i18nTComponent(t)}}const P={class:"kong-ui-public-table-data-grid","data-testid":"table-data-grid"},j={key:0,class:"table-error-state","data-testid":"table-error-state"},H={key:1,class:"table-empty-state","data-testid":"table-empty-state"},Q=((t,i)=>{const o=t.__vccOpts||t;for(const[a,s]of i)o[a]=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]}},emits:["grid:ready","state","row:click","cell:click"],setup(t,{emit:i}){B.ModuleRegistry.registerModules([B.AllCommunityModule,B.InfiniteRowModelModule]);const o=i,{i18n:{t:a}}=$(),s=e.useSlots(),{columnDefs:d,gridContext:h}=U({headers:e.toRef(()=>t.headers),slots:s}),{onCellClick:k,onRowClick:n}=W({cellClick:C=>o("cell:click",C),headers:e.toRef(()=>t.headers),rowClick:(C,l)=>o("row:click",C,l)}),u={resizable:!1,sortable:!1,suppressMovable:!0},p=e.computed(()=>[t.fetcher,t.pageSize,t.refreshKey]),{data:b,datasource:E,error:S,isFetching:D}=K({fetcher:t.fetcher,resetKey:p}),{fetchState:r,hasData:w,state:R}=T(b,S,D),I=e.computed(()=>R.value===r.SUCCESS&&!w.value);O({emitState:C=>o("state",C),fetchLifecycleState:R,hasData:w});const N=C=>{o("grid:ready",C.api)};return(C,l)=>{const c=e.resolveComponent("KEmptyState");return e.openBlock(),e.createElementBlock("div",P,[t.error?(e.openBlock(),e.createElementBlock("div",j,[e.renderSlot(C.$slots,"error-state",{},()=>[e.createVNode(c,{"icon-variant":"error",message:e.unref(a)("errorState.message"),title:e.unref(a)("errorState.title")},null,8,["message","title"])],!0)])):I.value?(e.openBlock(),e.createElementBlock("div",H,[e.renderSlot(C.$slots,"empty-state",{},()=>[e.createVNode(c,{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":e.unref(d),context:e.unref(h),datasource:e.unref(E),"default-col-def":u,"infinite-initial-row-count":1,loading:e.unref(D),"row-model-type":"infinite","suppress-cell-focus":!0,theme:e.unref(B.themeQuartz),onCellClicked:e.unref(k),onGridReady:N,onRowClicked:e.unref(n)},null,8,["cache-block-size","column-defs","context","datasource","loading","theme","onCellClicked","onRowClicked"]))])}}}),[["__scopeId","data-v-e14d8346"]]);y.TableDataGrid=Q,Object.defineProperty(y,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,5 +1,5 @@
1
- import type { TableDataGridCellClickPayload, TableDataGridCellSlotProps, TableDataGridFetcher, TableDataGridHeader, TableDataGridStatePayload } from '../types';
2
- import type { GridReadyEvent, RowClickedEvent } from 'ag-grid-community';
1
+ import type { TableDataGridCellClickPayload, TableDataGridCellSlotProps, TableDataGridConfig, TableDataGridFetcher, TableDataGridHeader, TableDataGridSort, TableDataGridStatePayload } from '../types';
2
+ import type { GridApi, GridReadyEvent, RowClickedEvent } from 'ag-grid-community';
3
3
  declare const __VLS_export: <Row extends object>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
4
4
  props: import("vue").PublicProps & __VLS_PrettifyLocal<{
5
5
  headers: Array<TableDataGridHeader<Row>>;
@@ -7,10 +7,13 @@ declare const __VLS_export: <Row extends object>(__VLS_props: NonNullable<Awaite
7
7
  error?: boolean;
8
8
  pageSize?: number;
9
9
  refreshKey?: string | number | boolean;
10
+ tableConfig?: TableDataGridConfig;
10
11
  } & {
11
12
  onState?: ((payload: TableDataGridStatePayload) => any) | undefined;
12
- "onGrid:ready"?: ((api: import("ag-grid-community").GridApi<Row>) => any) | undefined;
13
+ onSort?: ((payload: TableDataGridSort) => any) | undefined;
14
+ "onGrid:ready"?: ((api: GridApi<Row>) => any) | undefined;
13
15
  "onCell:click"?: ((payload: TableDataGridCellClickPayload<Row>) => any) | undefined;
16
+ "onUpdate:tableConfig"?: ((payload: TableDataGridConfig) => any) | undefined;
14
17
  "onRow:click"?: ((row: Row, event: RowClickedEvent<Row, any>) => any) | undefined;
15
18
  }> & (typeof globalThis extends {
16
19
  __VLS_PROPS_FALLBACK: infer P;
@@ -27,6 +30,8 @@ declare const __VLS_export: <Row extends object>(__VLS_props: NonNullable<Awaite
27
30
  (e: "state", payload: TableDataGridStatePayload): void;
28
31
  (e: "row:click", row: Row, event: RowClickedEvent<Row>): void;
29
32
  (e: "cell:click", payload: TableDataGridCellClickPayload<Row>): void;
33
+ (e: "sort", payload: TableDataGridSort): void;
34
+ (e: "update:tableConfig", payload: TableDataGridConfig): void;
30
35
  };
31
36
  }>) => import("vue").VNode & {
32
37
  __ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
@@ -1 +1 @@
1
- {"version":3,"file":"TableDataGrid.vue.d.ts","sourceRoot":"","sources":["../../../src/components/TableDataGrid.vue"],"names":[],"mappings":"AAmNA,OAAO,KAAK,EACV,6BAA6B,EAC7B,0BAA0B,EAC1B,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAEV,cAAc,EACd,eAAe,EAChB,MAAM,mBAAmB,CAAA;AAgB1B,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;WA0OO,OAAO,KAAK,EAAE,WAAW,GAAG,mBAAmB,CAAC;iBAtO7C,KAAK,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;iBAC/B,oBAAoB,CAAC,GAAG,CAAC;gBAC1B,OAAO;mBACJ,MAAM;qBACJ,MAAM,GAAG,MAAM,GAAG,OAAO;;;;;;KAkOmD,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;;qCAtNoB,0BAA0B,CAAC,GAAG,CAAC,KAAK,OAAO;uBAFzD,MAAM,OAAO;u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AC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,CAAC,GAAG,EAAE,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { TableDataGridFetcher, TableDataGridRow } from '../types';
1
+ import type { TableDataGridFetcher, TableDataGridRow, TableDataGridSort } from '../types';
2
2
  import type { IGetRowsParams } from 'ag-grid-community';
3
3
  import type { Ref } from 'vue';
4
4
  interface UseFetchInfiniteOptions<Row extends object = TableDataGridRow> {
@@ -12,6 +12,10 @@ interface UseFetchInfiniteOptions<Row extends object = TableDataGridRow> {
12
12
  * the datasource and clears cursor/block state back to block 0.
13
13
  */
14
14
  resetKey?: Readonly<Ref<unknown>>;
15
+ /**
16
+ * Current resolved sort, forwarded to the fetcher.
17
+ */
18
+ sort?: Readonly<Ref<TableDataGridSort | undefined>>;
15
19
  }
16
20
  /**
17
21
  * Owns AG Grid infinite datasource creation and cursor-backed fetch
@@ -30,7 +34,7 @@ interface UseFetchInfiniteOptions<Row extends object = TableDataGridRow> {
30
34
  * @returns Readonly datasource, first-block data, error, and fetching state
31
35
  * refs for the active AG Grid infinite datasource.
32
36
  */
33
- export declare const useFetchInfinite: <Row extends object = TableDataGridRow>({ fetcher, resetKey, }: UseFetchInfiniteOptions<Row>) => {
37
+ export declare const useFetchInfinite: <Row extends object = TableDataGridRow>({ fetcher, resetKey, sort, }: UseFetchInfiniteOptions<Row>) => {
34
38
  datasource: Readonly<Ref<{
35
39
  readonly rowCount?: number | undefined;
36
40
  readonly getRows: (params: IGetRowsParams) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"useFetchInfinite.d.ts","sourceRoot":"","sources":["../../../src/composables/useFetchInfinite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EAEpB,gBAAgB,EACjB,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;CAClC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,gBAAgB,GAAI,GAAG,SAAS,MAAM,GAAG,gBAAgB,EAAE,wBAGrE,uBAAuB,CAAC,GAAG,CAAC;;;;;;;;;;;;;CA6T9B,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"}
@@ -1,13 +1,14 @@
1
- import type { TableDataGridHeader, TableDataGridRow } from '../types';
1
+ import type { TableDataGridHeader, TableDataGridRow, TableDataGridSort } from '../types';
2
2
  import type { ColDef } from 'ag-grid-community';
3
3
  import type { Ref, Slots } from 'vue';
4
4
  /**
5
5
  * Converts `headers` into what AG Grid needs to render the table's columns:
6
6
  * the column definitions themselves, and the shared grid `context`.
7
7
  */
8
- export declare const useTableDataGridColumnDefs: <Row extends object = TableDataGridRow>({ headers, slots, }: {
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
+ initialSort?: TableDataGridSort;
11
12
  }) => {
12
13
  columnDefs: import("vue").ComputedRef<ColDef<Row, any>[]>;
13
14
  gridContext: import("vue").ComputedRef<{
@@ -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,MAAM,UAAU,CAAA;AACrE,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,qBAG/E;IACD,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IACvD,KAAK,EAAE,KAAK,CAAA;CACb;;;;;;;;;CA0BA,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"}
@@ -0,0 +1,34 @@
1
+ import type { TableDataGridConfig, TableDataGridHeader, TableDataGridRow, TableDataGridSort } from '../types';
2
+ import type { Ref } from 'vue';
3
+ /**
4
+ * Owns `TableDataGrid`'s current `tableConfig` state, controlled or
5
+ * uncontrolled, with `patchTableConfig` as the single write path for
6
+ * grid-driven changes.
7
+ *
8
+ * @param headers Current column headers, used to validate the resolved sort key.
9
+ * @param pageSize Reactive component-level page size default.
10
+ * @param tableConfig Host-supplied `tableConfig` prop, or `undefined` when uncontrolled.
11
+ * @param emitTableConfigUpdate Called with the resolved config whenever `patchTableConfig` changes it.
12
+ * @param onExternalConfigChange Called when the host-supplied prop changes the resolved config.
13
+ */
14
+ export declare const useTableDataGridConfig: <Row extends object = TableDataGridRow>({ headers, pageSize, tableConfig: tableConfigProp, emitTableConfigUpdate, onExternalConfigChange, }: {
15
+ headers: Readonly<Ref<Array<TableDataGridHeader<Row>>>>;
16
+ pageSize: Readonly<Ref<number>>;
17
+ tableConfig: Readonly<Ref<TableDataGridConfig | undefined>>;
18
+ emitTableConfigUpdate: (config: TableDataGridConfig) => void;
19
+ onExternalConfigChange?: (config: TableDataGridConfig) => void;
20
+ }) => {
21
+ activeTableConfig: Readonly<Ref<{
22
+ readonly sortColumnKey?: string | undefined;
23
+ readonly sortColumnOrder?: import("..").TableDataGridSortDirection | undefined;
24
+ readonly pageSize?: number | undefined;
25
+ }, {
26
+ readonly sortColumnKey?: string | undefined;
27
+ readonly sortColumnOrder?: import("..").TableDataGridSortDirection | undefined;
28
+ readonly pageSize?: number | undefined;
29
+ }>>;
30
+ activeSort: import("vue").ComputedRef<TableDataGridSort>;
31
+ activePageSize: import("vue").ComputedRef<number>;
32
+ patchTableConfig: (patch: Partial<TableDataGridConfig>) => void;
33
+ };
34
+ //# sourceMappingURL=useTableDataGridConfig.d.ts.map
@@ -0,0 +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;;;;;;;;;;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"}
@@ -0,0 +1,20 @@
1
+ import type { TableDataGridRow, TableDataGridSort } from '../types';
2
+ import type { GridApi, SortChangedEvent } from 'ag-grid-community';
3
+ import type { Ref } from 'vue';
4
+ /**
5
+ * Translates AG Grid's `sortChanged` event into `TableDataGrid`'s `sort`
6
+ * shape, and pushes a sort back onto the grid.
7
+ *
8
+ * @param activeSort Current resolved sort, read from `useTableDataGridConfig`.
9
+ * @param emitSort Called with the new sort whenever a grid interaction changes it.
10
+ * @param patchTableConfig Writes the new sort into the current `tableConfig`.
11
+ */
12
+ export declare const useTableDataGridSort: <Row extends object = TableDataGridRow>({ activeSort, emitSort, patchTableConfig, }: {
13
+ activeSort: Readonly<Ref<TableDataGridSort>>;
14
+ emitSort: (sort: TableDataGridSort) => void;
15
+ patchTableConfig: (patch: Partial<TableDataGridSort>) => void;
16
+ }) => {
17
+ onSortChanged: (event: SortChangedEvent<Row>) => void;
18
+ applySortToGrid: (api: GridApi<Row>, sort: TableDataGridSort) => void;
19
+ };
20
+ //# sourceMappingURL=useTableDataGridSort.d.ts.map
@@ -0,0 +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;;;;;;;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"}
@@ -33,11 +33,28 @@ export type TableDataGridHeader<Row extends object = TableDataGridRow> = {
33
33
  * selection/click mechanics are unaffected.
34
34
  */
35
35
  disableRowClick?: boolean;
36
+ /** Enables sorting on this column via AG Grid's built-in header sort control. */
37
+ sortable?: boolean;
38
+ /**
39
+ * Shows the unsorted sort icon on this column's header even when it isn't
40
+ * the active sort, instead of only on hover or once sorted. Only relevant
41
+ * when `sortable` is true.
42
+ */
43
+ showSortIcon?: boolean;
44
+ };
45
+ export type TableDataGridSortDirection = 'asc' | 'desc';
46
+ export type TableDataGridSort = {
47
+ sortColumnKey?: string;
48
+ sortColumnOrder?: TableDataGridSortDirection;
49
+ };
50
+ export type TableDataGridConfig = TableDataGridSort & {
51
+ pageSize?: number;
36
52
  };
37
53
  export interface TableDataGridInfiniteFetcherParams {
38
54
  mode: 'infinite';
39
55
  pageSize: number;
40
56
  cursor?: unknown;
57
+ sort?: TableDataGridSort;
41
58
  }
42
59
  export type TableDataGridFetcherResult<Row extends object = TableDataGridRow> = {
43
60
  data: Row[];
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAEhD,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAA;AAC1C,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AACtD,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAA;AAEhE,MAAM,MAAM,yBAAyB,GAAG;IACtC,KAAK,EAAE,kBAAkB,CAAA;IACzB,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,4BAA4B,CAAC,GAAG,SAAS,MAAM,GAAG,gBAAgB,IAAI,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M,MAAM,yBAAyB,CAAC,GAAG,SAAS,MAAM,GAAG,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC,CAAA"}
@@ -0,0 +1,25 @@
1
+ import type { TableDataGridConfig, TableDataGridHeader, TableDataGridRow } from '../types';
2
+ /**
3
+ * Resolves a host-supplied (or absent) `tableConfig` into a config the
4
+ * component can trust: drops a `sortColumnKey` that no longer matches a
5
+ * `sortable` header, and falls back `pageSize` to the component default.
6
+ *
7
+ * @param config Host-supplied table config, or `undefined` when uncontrolled.
8
+ * @param headers Current column headers, used to validate the sort key.
9
+ * @param pageSize Component-level page size default.
10
+ * @returns A fully-resolved `TableDataGridConfig`.
11
+ */
12
+ export declare const resolveTableConfig: <Row extends object = TableDataGridRow>({ config, headers, pageSize, }: {
13
+ config: TableDataGridConfig | undefined;
14
+ headers: Array<TableDataGridHeader<Row>>;
15
+ pageSize: number;
16
+ }) => TableDataGridConfig;
17
+ /**
18
+ * Structural equality for two resolved `TableDataGridConfig` values.
19
+ *
20
+ * @param a First config to compare.
21
+ * @param b Second config to compare.
22
+ * @returns Whether every field matches, including `undefined` values.
23
+ */
24
+ export declare const tableConfigsEqual: (a: TableDataGridConfig, b: TableDataGridConfig) => boolean;
25
+ //# sourceMappingURL=tableConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tableConfig.d.ts","sourceRoot":"","sources":["../../../src/utils/tableConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAE1F;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,GAAI,GAAG,SAAS,MAAM,GAAG,gBAAgB,EAAE,gCAIvE;IACD,MAAM,EAAE,mBAAmB,GAAG,SAAS,CAAA;IACvC,OAAO,EAAE,KAAK,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAA;IACxC,QAAQ,EAAE,MAAM,CAAA;CACjB,KAAG,mBAWH,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAI,GAAG,mBAAmB,EAAE,GAAG,mBAAmB,KAAG,OAIlF,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kong-ui-public/table-data-grid",
3
- "version": "0.4.1",
3
+ "version": "0.4.2-pr.3761.40358052a.0",
4
4
  "type": "module",
5
5
  "main": "./dist/table-data-grid.umd.js",
6
6
  "module": "./dist/table-data-grid.es.js",