@kong-ui-public/table-data-grid 0.5.3-pr.3854.e369e8f09.0 → 0.5.3
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 +8 -39
- package/dist/style.css +1 -1
- package/dist/table-data-grid.es.js +308 -365
- package/dist/table-data-grid.umd.js +1 -1
- package/dist/types/components/TableDataGrid.vue.d.ts +9 -2
- package/dist/types/components/TableDataGrid.vue.d.ts.map +1 -1
- package/dist/types/composables/useEmitState.d.ts +1 -2
- package/dist/types/composables/useEmitState.d.ts.map +1 -1
- package/dist/types/composables/useFetchState.d.ts +1 -4
- package/dist/types/composables/useFetchState.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +1 -21
- package/dist/types/types/index.d.ts.map +1 -1
- package/package.json +3 -4
- package/dist/types/composables/useFetchUnpaginated.d.ts +0 -23
- package/dist/types/composables/useFetchUnpaginated.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Reusable Vue wrapper around AG Grid for Kong table data grids.
|
|
4
4
|
|
|
5
|
-
This package supports AG Grid infinite row loading with a cursor-first
|
|
6
|
-
contract
|
|
7
|
-
provides basic column definitions, single-column sorting, empty/error
|
|
5
|
+
This package currently supports AG Grid infinite row loading with a cursor-first
|
|
6
|
+
fetcher contract, basic column definitions, single-column sorting, empty/error
|
|
8
7
|
presentation states, and state lifecycle emits.
|
|
9
8
|
|
|
10
9
|
## Peer Dependencies
|
|
@@ -114,11 +113,10 @@ const handleState = (payload: TableDataGridStatePayload) => {
|
|
|
114
113
|
| Prop | Type | Required | Default | Notes |
|
|
115
114
|
| --- | --- | --- | --- | --- |
|
|
116
115
|
| `headers` | `Array<TableDataGridHeader<Row>>` | Yes | - | Basic column definitions mapped to AG Grid columns. |
|
|
117
|
-
| `fetcher` | `TableDataGridFetcher<Row
|
|
118
|
-
| `mode` | `'infinite' \| 'unpaginated'` | No | `'infinite'` | Selects the fetcher contract and AG Grid row model. |
|
|
116
|
+
| `fetcher` | `TableDataGridFetcher<Row>` | Yes | - | Async row loader called by the AG Grid infinite datasource. |
|
|
119
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. |
|
|
120
118
|
| `pageSize` | `number` | No | `25` | AG Grid cache block size and fetcher request size. `tableConfig.pageSize` wins when present. |
|
|
121
|
-
| `refreshKey` | `string \| number \| boolean` | No | - | Parent invalidation signal that
|
|
119
|
+
| `refreshKey` | `string \| number \| boolean` | No | - | Parent invalidation signal that rebuilds the datasource from the beginning. |
|
|
122
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. |
|
|
123
121
|
|
|
124
122
|
## Fetcher Contract
|
|
@@ -163,36 +161,11 @@ the public fetcher contract.
|
|
|
163
161
|
is omitted, `hasMore: false` or a response shorter than `pageSize` marks the last
|
|
164
162
|
loaded row as the end of the dataset.
|
|
165
163
|
|
|
166
|
-
For a complete result that must be loaded once and rendered without pagination,
|
|
167
|
-
set `mode="unpaginated"`. The fetcher receives no page size, cursor, sort, or
|
|
168
|
-
other pagination values, and its complete result is passed to AG Grid's internal
|
|
169
|
-
client-side row model. Changing `refreshKey` or the fetcher starts one new
|
|
170
|
-
request; scrolling through the result does not call the fetcher again.
|
|
171
|
-
|
|
172
|
-
```vue
|
|
173
|
-
<TableDataGrid
|
|
174
|
-
mode="unpaginated"
|
|
175
|
-
:fetcher="fetchTopRows"
|
|
176
|
-
:headers="headers"
|
|
177
|
-
:refresh-key="refreshKey"
|
|
178
|
-
/>
|
|
179
|
-
|
|
180
|
-
<script setup lang="ts">
|
|
181
|
-
import type { TableDataGridUnpaginatedFetcher } from '@kong-ui-public/table-data-grid'
|
|
182
|
-
|
|
183
|
-
const fetchTopRows: TableDataGridUnpaginatedFetcher<Row> = async () => ({
|
|
184
|
-
data: await loadAllRows(),
|
|
185
|
-
})
|
|
186
|
-
</script>
|
|
187
|
-
```
|
|
188
|
-
|
|
189
164
|
## Refresh Behavior
|
|
190
165
|
|
|
191
166
|
`refreshKey` is a parent-owned invalidation signal. Changing it rebuilds the
|
|
192
167
|
infinite datasource, clears stored cursors, and starts again from the first
|
|
193
|
-
block with `cursor: undefined`.
|
|
194
|
-
complete-result request instead and keeps the previous rows visible while that
|
|
195
|
-
request is pending.
|
|
168
|
+
block with `cursor: undefined`.
|
|
196
169
|
|
|
197
170
|
This reset is required for cursor APIs because cursor values are only valid
|
|
198
171
|
relative to the response and query chain that produced them. Reusing a later
|
|
@@ -302,7 +275,7 @@ Columns without a matching slot render their raw `rowValue`.
|
|
|
302
275
|
| `row` | `Row` | The full row record backing this cell. |
|
|
303
276
|
| `rowValue` | `unknown` | `row[header.key]`. |
|
|
304
277
|
| `column` | `TableDataGridHeader<Row>` | The header definition for this column. |
|
|
305
|
-
| `rowIndex` | `number` | The row's index in the currently loaded
|
|
278
|
+
| `rowIndex` | `number` | The row's index in the currently loaded block. |
|
|
306
279
|
| `selected` | `boolean` | Whether the row is currently selected. |
|
|
307
280
|
| `refreshCell` | `() => void` | Forces AG Grid to re-render this cell. |
|
|
308
281
|
|
|
@@ -311,7 +284,7 @@ Columns without a matching slot render their raw `rowValue`.
|
|
|
311
284
|
| Event | Payload | When it fires |
|
|
312
285
|
| --- | --- | --- |
|
|
313
286
|
| `grid:ready` | `GridApi<Row>` | AG Grid is ready. |
|
|
314
|
-
| `state` | `{ state: 'loading' \| 'success' \| 'error', hasData: boolean }` | Internal fetch lifecycle changes after
|
|
287
|
+
| `state` | `{ state: 'loading' \| 'success' \| 'error', hasData: boolean }` | Internal fetch lifecycle changes after the datasource starts requesting rows. |
|
|
315
288
|
| `row:click` | `(row: TableDataGridRowClickPayload<Row>, event: RowClickedEvent<Row>)` | A row is clicked, unless the click landed in a `disableRowClick` column. |
|
|
316
289
|
| `cell:click` | `TableDataGridCellClickPayload<Row>` | Any cell is clicked, including cells in `disableRowClick` columns. |
|
|
317
290
|
| `sort` | `TableDataGridSort` | The current single-column sort changes. Fires before `update:tableConfig`. |
|
|
@@ -321,7 +294,7 @@ Columns without a matching slot render their raw `rowValue`.
|
|
|
321
294
|
|
|
322
295
|
| Slot | Purpose |
|
|
323
296
|
| --- | --- |
|
|
324
|
-
| `empty-state` | Replaces the default empty state after a successful empty
|
|
297
|
+
| `empty-state` | Replaces the default empty state after a successful empty first block. |
|
|
325
298
|
| `error-state` | Replaces the default visible error state when `error` is true. |
|
|
326
299
|
| `[columnKey]` | Renders custom cell content for the column matching `header.key`. See [Custom Cell Content](#custom-cell-content). |
|
|
327
300
|
|
|
@@ -335,13 +308,9 @@ Columns without a matching slot render their raw `rowValue`.
|
|
|
335
308
|
- `TableDataGridCellClickPayload`
|
|
336
309
|
- `TableDataGridCellSlotProps`
|
|
337
310
|
- `TableDataGridHeader`
|
|
338
|
-
- `TableDataGridProps`
|
|
339
311
|
- `TableDataGridInfiniteFetcherParams`
|
|
340
|
-
- `TableDataGridUnpaginatedFetcherParams`
|
|
341
312
|
- `TableDataGridFetcherResult`
|
|
342
313
|
- `TableDataGridFetcher`
|
|
343
|
-
- `TableDataGridUnpaginatedFetcherResult`
|
|
344
|
-
- `TableDataGridUnpaginatedFetcher`
|
|
345
314
|
- `TableDataGridReadyPayload`
|
|
346
315
|
- `TableDataGridSortDirection`
|
|
347
316
|
- `TableDataGridSort`
|
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-
|
|
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,41 +1,40 @@
|
|
|
1
|
-
import { computed as
|
|
2
|
-
import { AgGridVue as
|
|
3
|
-
import { ModuleRegistry as
|
|
4
|
-
import { createI18n as
|
|
5
|
-
var
|
|
6
|
-
const
|
|
7
|
-
function
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
return t.value ? "LOADING" :
|
|
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:
|
|
14
|
-
hasData:
|
|
15
|
-
state:
|
|
13
|
+
fetchState: T,
|
|
14
|
+
hasData: n,
|
|
15
|
+
state: i
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
const
|
|
18
|
+
const ue = ({
|
|
19
19
|
emitState: e,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
hasData: a
|
|
20
|
+
fetchLifecycleState: r,
|
|
21
|
+
hasData: t
|
|
23
22
|
}) => {
|
|
24
|
-
|
|
23
|
+
B(
|
|
25
24
|
() => ({
|
|
26
|
-
hasData:
|
|
27
|
-
state:
|
|
25
|
+
hasData: t.value,
|
|
26
|
+
state: r.value
|
|
28
27
|
}),
|
|
29
|
-
({ hasData: l, state:
|
|
30
|
-
if (
|
|
31
|
-
if (
|
|
28
|
+
({ hasData: l, state: n }) => {
|
|
29
|
+
if (n !== T.PENDING) {
|
|
30
|
+
if (n === T.LOADING) {
|
|
32
31
|
e({
|
|
33
32
|
hasData: l,
|
|
34
33
|
state: "loading"
|
|
35
34
|
});
|
|
36
35
|
return;
|
|
37
36
|
}
|
|
38
|
-
if (
|
|
37
|
+
if (n === T.ERROR) {
|
|
39
38
|
e({
|
|
40
39
|
hasData: l,
|
|
41
40
|
state: "error"
|
|
@@ -47,218 +46,167 @@ const ke = ({
|
|
|
47
46
|
state: "success"
|
|
48
47
|
});
|
|
49
48
|
}
|
|
50
|
-
}
|
|
51
|
-
{ immediate: i }
|
|
49
|
+
}
|
|
52
50
|
);
|
|
53
|
-
},
|
|
54
|
-
const t =
|
|
51
|
+
}, de = ({ startRow: e, endRow: r }) => {
|
|
52
|
+
const t = r - e;
|
|
55
53
|
return {
|
|
56
54
|
blockIndex: t > 0 ? Math.floor(e / t) : 0,
|
|
57
55
|
pageSize: t
|
|
58
56
|
};
|
|
59
|
-
},
|
|
57
|
+
}, me = ({
|
|
60
58
|
startRow: e,
|
|
61
|
-
rowsLength:
|
|
59
|
+
rowsLength: r,
|
|
62
60
|
pageSize: t,
|
|
63
|
-
total:
|
|
64
|
-
hasMore:
|
|
61
|
+
total: l,
|
|
62
|
+
hasMore: n
|
|
65
63
|
}) => {
|
|
66
|
-
if (typeof
|
|
67
|
-
return
|
|
68
|
-
if (
|
|
69
|
-
return e +
|
|
70
|
-
},
|
|
64
|
+
if (typeof l == "number")
|
|
65
|
+
return l;
|
|
66
|
+
if (n !== !0 && (n === !1 || r < t))
|
|
67
|
+
return e + r;
|
|
68
|
+
}, fe = ({
|
|
71
69
|
fetcher: e,
|
|
72
|
-
resetKey:
|
|
70
|
+
resetKey: r,
|
|
73
71
|
sort: t
|
|
74
72
|
}) => {
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
}, w = () => {
|
|
78
|
-
n.value = void 0, r.value += 1, b();
|
|
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;
|
|
79
75
|
}, D = () => {
|
|
80
|
-
|
|
76
|
+
a.value = void 0, s.value += 1, k();
|
|
77
|
+
}, w = () => {
|
|
78
|
+
s.value = Math.max(0, s.value - 1), k();
|
|
81
79
|
}, C = (c) => {
|
|
82
|
-
const
|
|
83
|
-
if (
|
|
84
|
-
return
|
|
85
|
-
let
|
|
86
|
-
const
|
|
87
|
-
promise: new Promise((
|
|
88
|
-
|
|
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;
|
|
89
87
|
}),
|
|
90
|
-
resolve: (
|
|
88
|
+
resolve: (m) => d(m)
|
|
91
89
|
};
|
|
92
|
-
return
|
|
93
|
-
},
|
|
94
|
-
|
|
95
|
-
},
|
|
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 ({
|
|
96
94
|
blockIndex: c,
|
|
97
|
-
currentBlockCompletion:
|
|
98
|
-
datasourceId:
|
|
95
|
+
currentBlockCompletion: u,
|
|
96
|
+
datasourceId: d
|
|
99
97
|
}) => {
|
|
100
98
|
if (c === 0)
|
|
101
99
|
return "ready";
|
|
102
|
-
const
|
|
103
|
-
if (!
|
|
104
|
-
return
|
|
105
|
-
const
|
|
106
|
-
return g(
|
|
107
|
-
},
|
|
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 = ({
|
|
108
106
|
blockIndex: c,
|
|
109
|
-
currentBlockCompletion:
|
|
110
|
-
getRowsParams:
|
|
111
|
-
pageSize:
|
|
112
|
-
result:
|
|
107
|
+
currentBlockCompletion: u,
|
|
108
|
+
getRowsParams: d,
|
|
109
|
+
pageSize: h,
|
|
110
|
+
result: m
|
|
113
111
|
}) => {
|
|
114
|
-
|
|
115
|
-
startRow:
|
|
116
|
-
rowsLength:
|
|
117
|
-
pageSize:
|
|
118
|
-
total:
|
|
119
|
-
hasMore:
|
|
120
|
-
})),
|
|
121
|
-
},
|
|
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
|
+
}, _ = ({
|
|
122
120
|
blockIndex: c,
|
|
123
|
-
currentBlockCompletion:
|
|
124
|
-
fetchError:
|
|
125
|
-
getRowsParams:
|
|
121
|
+
currentBlockCompletion: u,
|
|
122
|
+
fetchError: d,
|
|
123
|
+
getRowsParams: h
|
|
126
124
|
}) => {
|
|
127
|
-
|
|
128
|
-
},
|
|
129
|
-
const c =
|
|
130
|
-
return
|
|
131
|
-
async getRows(
|
|
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) {
|
|
132
130
|
const {
|
|
133
|
-
blockIndex:
|
|
134
|
-
pageSize:
|
|
135
|
-
} =
|
|
136
|
-
startRow:
|
|
137
|
-
endRow:
|
|
138
|
-
}),
|
|
139
|
-
if (await
|
|
140
|
-
blockIndex:
|
|
141
|
-
currentBlockCompletion:
|
|
131
|
+
blockIndex: d,
|
|
132
|
+
pageSize: h
|
|
133
|
+
} = de({
|
|
134
|
+
startRow: u.startRow,
|
|
135
|
+
endRow: u.endRow
|
|
136
|
+
}), m = C(d);
|
|
137
|
+
if (await K({
|
|
138
|
+
blockIndex: d,
|
|
139
|
+
currentBlockCompletion: m,
|
|
142
140
|
datasourceId: c
|
|
143
141
|
}) !== "ready") {
|
|
144
|
-
|
|
142
|
+
u.failCallback();
|
|
145
143
|
return;
|
|
146
144
|
}
|
|
147
|
-
g(c) &&
|
|
145
|
+
g(c) && D();
|
|
148
146
|
try {
|
|
149
|
-
const
|
|
147
|
+
const R = d > 0 ? l.get(d - 1) : void 0, z = await e({
|
|
150
148
|
mode: "infinite",
|
|
151
|
-
pageSize:
|
|
152
|
-
cursor:
|
|
149
|
+
pageSize: h,
|
|
150
|
+
cursor: R,
|
|
153
151
|
// Always read the latest sort, not a stale one.
|
|
154
152
|
sort: t?.value
|
|
155
153
|
});
|
|
156
154
|
if (!g(c)) {
|
|
157
|
-
|
|
155
|
+
u.failCallback(), b(d, m);
|
|
158
156
|
return;
|
|
159
157
|
}
|
|
160
|
-
|
|
161
|
-
blockIndex:
|
|
162
|
-
currentBlockCompletion:
|
|
163
|
-
getRowsParams:
|
|
164
|
-
pageSize:
|
|
165
|
-
result:
|
|
158
|
+
M({
|
|
159
|
+
blockIndex: d,
|
|
160
|
+
currentBlockCompletion: m,
|
|
161
|
+
getRowsParams: u,
|
|
162
|
+
pageSize: h,
|
|
163
|
+
result: z
|
|
166
164
|
});
|
|
167
|
-
} catch (
|
|
165
|
+
} catch (R) {
|
|
168
166
|
if (!g(c)) {
|
|
169
|
-
|
|
167
|
+
u.failCallback(), b(d, m);
|
|
170
168
|
return;
|
|
171
169
|
}
|
|
172
|
-
|
|
173
|
-
blockIndex:
|
|
174
|
-
currentBlockCompletion:
|
|
175
|
-
fetchError:
|
|
176
|
-
getRowsParams:
|
|
170
|
+
_({
|
|
171
|
+
blockIndex: d,
|
|
172
|
+
currentBlockCompletion: m,
|
|
173
|
+
fetchError: R,
|
|
174
|
+
getRowsParams: u
|
|
177
175
|
});
|
|
178
176
|
} finally {
|
|
179
|
-
g(c) &&
|
|
177
|
+
g(c) && w();
|
|
180
178
|
}
|
|
181
179
|
}
|
|
182
180
|
};
|
|
183
|
-
},
|
|
184
|
-
o.value =
|
|
181
|
+
}, F = () => {
|
|
182
|
+
o.value = A();
|
|
185
183
|
};
|
|
186
|
-
return
|
|
187
|
-
() =>
|
|
184
|
+
return B(
|
|
185
|
+
() => r?.value,
|
|
188
186
|
() => {
|
|
189
|
-
|
|
187
|
+
F();
|
|
190
188
|
},
|
|
191
189
|
{ immediate: !0 }
|
|
192
190
|
), {
|
|
193
|
-
datasource:
|
|
194
|
-
data:
|
|
195
|
-
error:
|
|
196
|
-
isFetching:
|
|
197
|
-
};
|
|
198
|
-
}, Ie = ({
|
|
199
|
-
fetcher: e,
|
|
200
|
-
resetKey: i
|
|
201
|
-
}) => {
|
|
202
|
-
const t = E(), a = E(), l = I(!1);
|
|
203
|
-
let s = 0, o = !1, m = !1, n = !1;
|
|
204
|
-
const r = async () => {
|
|
205
|
-
if (m)
|
|
206
|
-
return;
|
|
207
|
-
const g = ++s;
|
|
208
|
-
l.value = !0, a.value = void 0;
|
|
209
|
-
try {
|
|
210
|
-
const b = await e.value({ mode: "unpaginated" });
|
|
211
|
-
if (g !== s)
|
|
212
|
-
return;
|
|
213
|
-
t.value = b.data;
|
|
214
|
-
} catch (b) {
|
|
215
|
-
g === s && (a.value = b);
|
|
216
|
-
} finally {
|
|
217
|
-
g === s && (l.value = !1);
|
|
218
|
-
}
|
|
219
|
-
}, u = () => {
|
|
220
|
-
s += 1, l.value = !0, a.value = void 0, !o && (o = !0, queueMicrotask(() => {
|
|
221
|
-
o = !1, r();
|
|
222
|
-
}));
|
|
191
|
+
datasource: x(o),
|
|
192
|
+
data: x(f),
|
|
193
|
+
error: x(a),
|
|
194
|
+
isFetching: x(v)
|
|
223
195
|
};
|
|
224
|
-
|
|
225
|
-
[
|
|
226
|
-
() => i?.value,
|
|
227
|
-
e
|
|
228
|
-
],
|
|
229
|
-
() => {
|
|
230
|
-
if (!n) {
|
|
231
|
-
n = !0, r();
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
u();
|
|
235
|
-
},
|
|
236
|
-
{ flush: "sync", immediate: !0 }
|
|
237
|
-
), oe() && ae(() => {
|
|
238
|
-
m = !0, s += 1;
|
|
239
|
-
}), {
|
|
240
|
-
data: R(t),
|
|
241
|
-
// The client-side row model has no AG Grid datasource. Keeping this
|
|
242
|
-
// explicit lets the component bind one common fetch-result shape without
|
|
243
|
-
// creating the infinite cursor machinery for this mode.
|
|
244
|
-
datasource: void 0,
|
|
245
|
-
error: R(a),
|
|
246
|
-
isFetching: R(l)
|
|
247
|
-
};
|
|
248
|
-
}, Ee = {
|
|
196
|
+
}, ve = {
|
|
249
197
|
key: 1,
|
|
250
198
|
class: "table-data-grid-cell-renderer"
|
|
251
|
-
},
|
|
199
|
+
}, Ce = /* @__PURE__ */ $({
|
|
252
200
|
name: "TableDataGridCellRenderer",
|
|
253
201
|
__name: "TableDataGridCellRenderer",
|
|
254
202
|
props: {
|
|
255
203
|
params: {}
|
|
256
204
|
},
|
|
257
|
-
setup(e, { expose:
|
|
258
|
-
const t =
|
|
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(() => {
|
|
259
207
|
const C = t.value.colDef?.colId;
|
|
260
208
|
return C ? t.value.context?.cells?.slots?.[C] : void 0;
|
|
261
|
-
}),
|
|
209
|
+
}), f = S(() => ({
|
|
262
210
|
column: t.value.headerDef,
|
|
263
211
|
refreshCell: () => {
|
|
264
212
|
const C = t.value.node;
|
|
@@ -268,64 +216,64 @@ const ke = ({
|
|
|
268
216
|
rowIndex: t.value.node?.rowIndex ?? 0,
|
|
269
217
|
rowValue: t.value.value,
|
|
270
218
|
selected: t.value.node?.isSelected() ?? !1
|
|
271
|
-
})),
|
|
272
|
-
let
|
|
273
|
-
const
|
|
274
|
-
const C =
|
|
275
|
-
|
|
276
|
-
},
|
|
277
|
-
g || (
|
|
278
|
-
|
|
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();
|
|
279
227
|
}));
|
|
280
|
-
},
|
|
281
|
-
if (
|
|
282
|
-
|
|
283
|
-
const
|
|
284
|
-
|
|
228
|
+
}, w = (C) => {
|
|
229
|
+
if (s?.disconnect(), C) {
|
|
230
|
+
s?.observe(C);
|
|
231
|
+
const b = C.closest(".ag-cell");
|
|
232
|
+
b && s?.observe(b);
|
|
285
233
|
}
|
|
286
|
-
|
|
234
|
+
D();
|
|
287
235
|
};
|
|
288
|
-
return
|
|
289
|
-
|
|
290
|
-
}),
|
|
291
|
-
g = !0,
|
|
292
|
-
}),
|
|
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({
|
|
293
241
|
refresh(C) {
|
|
294
|
-
return t.value = C,
|
|
242
|
+
return t.value = C, Q(D), !0;
|
|
295
243
|
}
|
|
296
|
-
}), (C,
|
|
297
|
-
const
|
|
298
|
-
return o.value ? (
|
|
299
|
-
L(
|
|
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, {
|
|
300
248
|
class: "table-data-grid-cell-tooltip",
|
|
301
|
-
disabled: !
|
|
249
|
+
disabled: !n.value,
|
|
302
250
|
"kpop-attributes": { popoverDelay: 400 },
|
|
303
251
|
"max-width": "300",
|
|
304
252
|
placement: "bottom-start",
|
|
305
253
|
target: "body",
|
|
306
|
-
text:
|
|
254
|
+
text: i.value
|
|
307
255
|
}, {
|
|
308
|
-
default:
|
|
309
|
-
|
|
256
|
+
default: X(() => [
|
|
257
|
+
Y("span", {
|
|
310
258
|
ref_key: "contentElement",
|
|
311
|
-
ref:
|
|
259
|
+
ref: l,
|
|
312
260
|
class: "table-data-grid-cell-content"
|
|
313
|
-
},
|
|
261
|
+
}, Z(i.value), 513)
|
|
314
262
|
]),
|
|
315
263
|
_: 1
|
|
316
264
|
}, 8, ["disabled", "text"])
|
|
317
265
|
]));
|
|
318
266
|
};
|
|
319
267
|
}
|
|
320
|
-
}),
|
|
268
|
+
}), pe = ({
|
|
321
269
|
headers: e,
|
|
322
|
-
slots:
|
|
270
|
+
slots: r,
|
|
323
271
|
initialSort: t
|
|
324
272
|
}) => {
|
|
325
|
-
const
|
|
326
|
-
cells: { slots:
|
|
327
|
-
})),
|
|
328
|
-
const
|
|
273
|
+
const l = S(() => ({
|
|
274
|
+
cells: { slots: r }
|
|
275
|
+
})), n = (o) => {
|
|
276
|
+
const f = t?.sortColumnKey === o.key;
|
|
329
277
|
return {
|
|
330
278
|
colId: o.key,
|
|
331
279
|
// Columns with no explicit width constraint share remaining space equally.
|
|
@@ -335,240 +283,235 @@ const ke = ({
|
|
|
335
283
|
minWidth: o.minWidth,
|
|
336
284
|
sortable: o.sortable ?? !1,
|
|
337
285
|
unSortIcon: o.showSortIcon,
|
|
338
|
-
...
|
|
339
|
-
valueGetter: (
|
|
286
|
+
...f ? { initialSort: t?.sortColumnOrder, initialSortIndex: 0 } : {},
|
|
287
|
+
valueGetter: (a) => a.data?.[o.key],
|
|
340
288
|
width: o.width,
|
|
341
|
-
cellRenderer:
|
|
289
|
+
cellRenderer: Ce,
|
|
342
290
|
// custom params passed to the cell renderer.
|
|
343
291
|
cellRendererParams: { headerDef: o }
|
|
344
292
|
};
|
|
345
293
|
};
|
|
346
294
|
return {
|
|
347
|
-
columnDefs:
|
|
348
|
-
gridContext:
|
|
295
|
+
columnDefs: S(() => e.value.map(n)),
|
|
296
|
+
gridContext: l
|
|
349
297
|
};
|
|
350
298
|
}, U = ({
|
|
351
299
|
config: e,
|
|
352
|
-
headers:
|
|
300
|
+
headers: r,
|
|
353
301
|
pageSize: t
|
|
354
302
|
}) => {
|
|
355
|
-
const
|
|
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;
|
|
356
304
|
return {
|
|
357
|
-
sortColumnKey:
|
|
358
|
-
sortColumnOrder:
|
|
305
|
+
sortColumnKey: n,
|
|
306
|
+
sortColumnOrder: n ? e?.sortColumnOrder : void 0,
|
|
359
307
|
pageSize: e?.pageSize ?? t
|
|
360
308
|
};
|
|
361
|
-
},
|
|
309
|
+
}, W = (e, r) => e.sortColumnKey === r.sortColumnKey && e.sortColumnOrder === r.sortColumnOrder && e.pageSize === r.pageSize, ge = ({
|
|
362
310
|
headers: e,
|
|
363
|
-
pageSize:
|
|
311
|
+
pageSize: r,
|
|
364
312
|
tableConfig: t,
|
|
365
|
-
emitTableConfigUpdate:
|
|
366
|
-
onExternalConfigChange:
|
|
313
|
+
emitTableConfigUpdate: l,
|
|
314
|
+
onExternalConfigChange: n
|
|
367
315
|
}) => {
|
|
368
|
-
const
|
|
369
|
-
|
|
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 })
|
|
370
318
|
);
|
|
371
|
-
|
|
372
|
-
|
|
319
|
+
B(i, (v) => {
|
|
320
|
+
v && !W(v, o.value) && (o.value = v, n?.(v));
|
|
373
321
|
});
|
|
374
|
-
const
|
|
322
|
+
const f = (v) => {
|
|
375
323
|
const g = U({
|
|
376
|
-
config: { ...o.value, ...
|
|
324
|
+
config: { ...o.value, ...v },
|
|
377
325
|
headers: e.value,
|
|
378
|
-
pageSize:
|
|
326
|
+
pageSize: r.value
|
|
379
327
|
});
|
|
380
|
-
|
|
381
|
-
},
|
|
328
|
+
W(g, o.value) || (o.value = g, l(g));
|
|
329
|
+
}, a = S(() => ({
|
|
382
330
|
sortColumnKey: o.value.sortColumnKey,
|
|
383
331
|
sortColumnOrder: o.value.sortColumnOrder
|
|
384
|
-
})),
|
|
332
|
+
})), s = S(() => t.value?.pageSize ?? r.value);
|
|
385
333
|
return {
|
|
386
|
-
activeTableConfig:
|
|
387
|
-
activeSort:
|
|
388
|
-
activePageSize:
|
|
389
|
-
patchTableConfig:
|
|
334
|
+
activeTableConfig: x(o),
|
|
335
|
+
activeSort: a,
|
|
336
|
+
activePageSize: s,
|
|
337
|
+
patchTableConfig: f
|
|
390
338
|
};
|
|
391
|
-
},
|
|
339
|
+
}, he = ({
|
|
392
340
|
cellClick: e,
|
|
393
|
-
headers:
|
|
341
|
+
headers: r,
|
|
394
342
|
rowClick: t
|
|
395
343
|
}) => {
|
|
396
|
-
const
|
|
397
|
-
|
|
398
|
-
)),
|
|
399
|
-
const
|
|
400
|
-
return
|
|
401
|
-
},
|
|
402
|
-
const
|
|
403
|
-
return !!(
|
|
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));
|
|
404
352
|
};
|
|
405
353
|
return {
|
|
406
|
-
onCellClick: (
|
|
407
|
-
const
|
|
408
|
-
!
|
|
409
|
-
columnKey:
|
|
410
|
-
row:
|
|
411
|
-
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
|
|
412
360
|
});
|
|
413
361
|
},
|
|
414
|
-
onRowClick: (
|
|
415
|
-
|
|
362
|
+
onRowClick: (a) => {
|
|
363
|
+
a.data && !i(a) && t(a.data, a);
|
|
416
364
|
}
|
|
417
365
|
};
|
|
418
|
-
},
|
|
366
|
+
}, ye = ({
|
|
419
367
|
activeSort: e,
|
|
420
|
-
emitSort:
|
|
368
|
+
emitSort: r,
|
|
421
369
|
patchTableConfig: t
|
|
422
370
|
}) => {
|
|
423
|
-
const
|
|
424
|
-
|
|
371
|
+
const l = (i, o) => {
|
|
372
|
+
i.applyColumnState({
|
|
425
373
|
state: o.sortColumnKey ? [{ colId: o.sortColumnKey, sort: o.sortColumnOrder ?? null, sortIndex: 0 }] : [],
|
|
426
374
|
defaultState: { sort: null, sortIndex: null }
|
|
427
375
|
});
|
|
428
376
|
};
|
|
429
|
-
return { onSortChanged: (
|
|
430
|
-
const o =
|
|
431
|
-
|
|
432
|
-
}, applySortToGrid:
|
|
433
|
-
},
|
|
434
|
-
emptyState:
|
|
435
|
-
errorState:
|
|
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
|
|
436
384
|
};
|
|
437
|
-
function
|
|
438
|
-
const e =
|
|
385
|
+
function De() {
|
|
386
|
+
const e = ne("en-us", ke);
|
|
439
387
|
return {
|
|
440
388
|
i18n: e,
|
|
441
|
-
i18nT:
|
|
389
|
+
i18nT: se(e)
|
|
442
390
|
// Translation component <i18n-t>
|
|
443
391
|
};
|
|
444
392
|
}
|
|
445
|
-
const
|
|
393
|
+
const we = {
|
|
446
394
|
class: "kong-ui-public-table-data-grid",
|
|
447
395
|
"data-testid": "table-data-grid"
|
|
448
|
-
},
|
|
396
|
+
}, Re = {
|
|
449
397
|
key: 0,
|
|
450
398
|
class: "table-error-state",
|
|
451
399
|
"data-testid": "table-error-state"
|
|
452
|
-
},
|
|
400
|
+
}, Ie = {
|
|
453
401
|
key: 1,
|
|
454
402
|
class: "table-empty-state",
|
|
455
403
|
"data-testid": "table-empty-state"
|
|
456
|
-
},
|
|
404
|
+
}, Ee = /* @__PURE__ */ $({
|
|
457
405
|
__name: "TableDataGrid",
|
|
458
406
|
props: {
|
|
459
407
|
headers: {},
|
|
460
|
-
error: { type: Boolean },
|
|
461
|
-
pageSize: {},
|
|
462
|
-
refreshKey: { type: [String, Number, Boolean] },
|
|
463
|
-
tableConfig: {},
|
|
464
408
|
fetcher: { type: Function },
|
|
465
|
-
|
|
409
|
+
error: { type: Boolean, default: !1 },
|
|
410
|
+
pageSize: { default: 25 },
|
|
411
|
+
refreshKey: { type: [String, Number, Boolean] },
|
|
412
|
+
tableConfig: {}
|
|
466
413
|
},
|
|
467
414
|
emits: ["grid:ready", "state", "row:click", "cell:click", "sort", "update:tableConfig"],
|
|
468
|
-
setup(e, { emit:
|
|
469
|
-
|
|
470
|
-
const t =
|
|
471
|
-
headers:
|
|
472
|
-
pageSize:
|
|
473
|
-
tableConfig:
|
|
474
|
-
emitTableConfigUpdate: (
|
|
475
|
-
onExternalConfigChange: (
|
|
476
|
-
|
|
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);
|
|
477
424
|
}
|
|
478
|
-
}), { onSortChanged:
|
|
479
|
-
activeSort:
|
|
480
|
-
emitSort: (
|
|
481
|
-
patchTableConfig:
|
|
482
|
-
}), { columnDefs:
|
|
483
|
-
headers:
|
|
484
|
-
slots:
|
|
485
|
-
initialSort:
|
|
486
|
-
}), { onCellClick:
|
|
487
|
-
cellClick: (
|
|
488
|
-
headers:
|
|
489
|
-
rowClick: (
|
|
490
|
-
}),
|
|
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({
|
|
434
|
+
cellClick: (p) => t("cell:click", p),
|
|
435
|
+
headers: O(() => e.headers),
|
|
436
|
+
rowClick: (p, R) => t("row:click", p, R)
|
|
437
|
+
}), b = {
|
|
491
438
|
resizable: !1,
|
|
492
439
|
sortable: !1,
|
|
493
440
|
suppressMovable: !0
|
|
494
|
-
},
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
]),
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
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({
|
|
453
|
+
fetcher: e.fetcher,
|
|
454
|
+
resetKey: K,
|
|
455
|
+
sort: f
|
|
507
456
|
}), {
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
} =
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
ke({
|
|
517
|
-
emitState: (h) => r("state", h),
|
|
518
|
-
emitInitialState: a === "unpaginated",
|
|
519
|
-
fetchLifecycleState: q,
|
|
520
|
-
hasData: W
|
|
457
|
+
fetchState: c,
|
|
458
|
+
hasData: u,
|
|
459
|
+
state: d
|
|
460
|
+
} = ce(M, A, F), h = S(() => d.value === c.SUCCESS && !u.value);
|
|
461
|
+
ue({
|
|
462
|
+
emitState: (p) => t("state", p),
|
|
463
|
+
fetchLifecycleState: d,
|
|
464
|
+
hasData: u
|
|
521
465
|
});
|
|
522
|
-
const
|
|
523
|
-
|
|
466
|
+
const m = (p) => {
|
|
467
|
+
i.value = p.api, t("grid:ready", p.api);
|
|
524
468
|
};
|
|
525
|
-
return (
|
|
526
|
-
const
|
|
527
|
-
return
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
L(
|
|
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, {
|
|
531
475
|
"icon-variant": "error",
|
|
532
|
-
message:
|
|
533
|
-
title:
|
|
476
|
+
message: y(l)("errorState.message"),
|
|
477
|
+
title: y(l)("errorState.title")
|
|
534
478
|
}, null, 8, ["message", "title"])
|
|
535
479
|
], !0)
|
|
536
|
-
])) :
|
|
537
|
-
|
|
538
|
-
L(
|
|
539
|
-
message:
|
|
540
|
-
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")
|
|
541
485
|
}, null, 8, ["message", "title"])
|
|
542
486
|
], !0)
|
|
543
|
-
])) : (
|
|
544
|
-
key:
|
|
545
|
-
"cache-block-size":
|
|
487
|
+
])) : (I(), P(y(te), {
|
|
488
|
+
key: 2,
|
|
489
|
+
"cache-block-size": y(a),
|
|
546
490
|
class: "table-data-grid-grid",
|
|
547
|
-
"column-defs":
|
|
548
|
-
context:
|
|
549
|
-
datasource:
|
|
550
|
-
"default-col-def":
|
|
551
|
-
"infinite-initial-row-count":
|
|
552
|
-
loading:
|
|
553
|
-
"row-
|
|
554
|
-
"row-model-type": p(a) === "unpaginated" ? "clientSide" : "infinite",
|
|
491
|
+
"column-defs": y(k),
|
|
492
|
+
context: y(D),
|
|
493
|
+
datasource: y(_),
|
|
494
|
+
"default-col-def": b,
|
|
495
|
+
"infinite-initial-row-count": 1,
|
|
496
|
+
loading: y(F),
|
|
497
|
+
"row-model-type": "infinite",
|
|
555
498
|
"suppress-cell-focus": !0,
|
|
556
499
|
"suppress-multi-sort": !0,
|
|
557
|
-
theme:
|
|
558
|
-
onCellClicked:
|
|
559
|
-
onGridReady:
|
|
560
|
-
onRowClicked:
|
|
561
|
-
onSortChanged:
|
|
562
|
-
}, null, 8, ["cache-block-size", "column-defs", "context", "datasource", "
|
|
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"]))
|
|
563
506
|
]);
|
|
564
507
|
};
|
|
565
508
|
}
|
|
566
|
-
}),
|
|
509
|
+
}), Ke = (e, r) => {
|
|
567
510
|
const t = e.__vccOpts || e;
|
|
568
|
-
for (const [
|
|
569
|
-
t[
|
|
511
|
+
for (const [l, n] of r)
|
|
512
|
+
t[l] = n;
|
|
570
513
|
return t;
|
|
571
|
-
},
|
|
514
|
+
}, Fe = /* @__PURE__ */ Ke(Ee, [["__scopeId", "data-v-d8328fe5"]]);
|
|
572
515
|
export {
|
|
573
|
-
|
|
516
|
+
Fe as TableDataGrid
|
|
574
517
|
};
|
|
@@ -1 +1 @@
|
|
|
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,U,E,G){"use strict";var _=(t=>(t.PENDING="PENDING",t.LOADING="LOADING",t.SUCCESS="SUCCESS",t.ERROR="ERROR",t))(_||{});const L=t=>!!t?.length;function W(t,c,o,n=L,l=!1){const i=e.computed(()=>n(t.value)),a=e.computed(()=>{const r=t.value!==void 0,s=c.value!==void 0&&c.value!==null;return o.value?"LOADING":s&&l?"ERROR":i.value?"SUCCESS":s?"ERROR":r?"SUCCESS":"PENDING"});return{fetchState:_,hasData:i,state:a}}const $=({emitState:t,emitInitialState:c=!1,fetchLifecycleState:o,hasData:n})=>{e.watch(()=>({hasData:n.value,state:o.value}),({hasData:l,state:i})=>{if(i!==_.PENDING){if(i===_.LOADING){t({hasData:l,state:"loading"});return}if(i===_.ERROR){t({hasData:l,state:"error"});return}t({hasData:l,state:"success"})}},{immediate:c})},j=({startRow:t,endRow:c})=>{const o=c-t;return{blockIndex:o>0?Math.floor(t/o):0,pageSize:o}},P=({startRow:t,rowsLength:c,pageSize:o,total:n,hasMore:l})=>{if(typeof n=="number")return n;if(l!==!0&&(l===!1||c<o))return t+c},H=({fetcher:t,resetKey:c,sort:o})=>{const n=new Map,l=new Map,i=e.ref(0),a=e.shallowRef(),C=e.shallowRef(),r=e.shallowRef(),s=e.ref(0),u=e.ref(!1),g=d=>d===i.value,v=()=>{u.value=s.value>0},w=()=>{r.value=void 0,s.value+=1,v()},R=()=>{s.value=Math.max(0,s.value-1),v()},h=d=>{const f=l.get(d);if(f)return f;let p;const S={promise:new Promise(m=>{p=m}),resolve:m=>p(m)};return l.set(d,S),S},k=(d,f)=>{f.resolve(!1),l.get(d)===f&&l.delete(d)},I=async({blockIndex:d,currentBlockCompletion:f,datasourceId:p})=>{if(d===0)return"ready";const S=l.get(d-1);if(!S)return k(d,f),"failed";const m=await S.promise;return g(p)?m?"ready":(k(d,f),"failed"):(k(d,f),"stale")},O=({blockIndex:d,currentBlockCompletion:f,getRowsParams:p,pageSize:S,result:m})=>{m.cursor!==void 0&&n.set(d,m.cursor),p.successCallback(m.data,P({startRow:p.startRow,rowsLength:m.data.length,pageSize:S,total:m.total,hasMore:m.hasMore})),p.startRow===0&&(C.value=m.data),f.resolve(!0)},x=({blockIndex:d,currentBlockCompletion:f,fetchError:p,getRowsParams:S})=>{r.value=p,S.failCallback(),k(d,f)},T=()=>{const d=i.value+1;return i.value=d,n.clear(),l.clear(),C.value=void 0,r.value=void 0,s.value=0,v(),{async getRows(f){const{blockIndex:p,pageSize:S}=j({startRow:f.startRow,endRow:f.endRow}),m=h(p);if(await I({blockIndex:p,currentBlockCompletion:m,datasourceId:d})!=="ready"){f.failCallback();return}g(d)&&w();try{const D=p>0?n.get(p-1):void 0,F=await t({mode:"infinite",pageSize:S,cursor:D,sort:o?.value});if(!g(d)){f.failCallback(),k(p,m);return}O({blockIndex:p,currentBlockCompletion:m,getRowsParams:f,pageSize:S,result:F})}catch(D){if(!g(d)){f.failCallback(),k(p,m);return}x({blockIndex:p,currentBlockCompletion:m,fetchError:D,getRowsParams:f})}finally{g(d)&&R()}}}},B=()=>{a.value=T()};return e.watch(()=>c?.value,()=>{B()},{immediate:!0}),{datasource:e.readonly(a),data:e.readonly(C),error:e.readonly(r),isFetching:e.readonly(u)}},Q=({fetcher:t,resetKey:c})=>{const o=e.shallowRef(),n=e.shallowRef(),l=e.ref(!1);let i=0,a=!1,C=!1,r=!1;const s=async()=>{if(C)return;const g=++i;l.value=!0,n.value=void 0;try{const v=await t.value({mode:"unpaginated"});if(g!==i)return;o.value=v.data}catch(v){g===i&&(n.value=v)}finally{g===i&&(l.value=!1)}},u=()=>{i+=1,l.value=!0,n.value=void 0,!a&&(a=!0,queueMicrotask(()=>{a=!1,s()}))};return e.watch([()=>c?.value,t],()=>{if(!r){r=!0,s();return}u()},{flush:"sync",immediate:!0}),e.getCurrentScope()&&e.onScopeDispose(()=>{C=!0,i+=1}),{data:e.readonly(o),datasource:void 0,error:e.readonly(n),isFetching:e.readonly(l)}},J={key:1,class:"table-data-grid-cell-renderer"},X=e.defineComponent({name:"TableDataGridCellRenderer",__name:"TableDataGridCellRenderer",props:{params:{}},setup(t,{expose:c}){const o=e.shallowRef(t.params),n=e.ref(null),l=e.ref(!1),i=e.computed(()=>o.value.valueFormatted??String(o.value.value??"")),a=e.computed(()=>{const h=o.value.colDef?.colId;return h?o.value.context?.cells?.slots?.[h]:void 0}),C=e.computed(()=>({column:o.value.headerDef,refreshCell:()=>{const h=o.value.node;h&&o.value.api.refreshCells({force:!0,rowNodes:[h]})},row:o.value.data??{},rowIndex:o.value.node?.rowIndex??0,rowValue:o.value.value,selected:o.value.node?.isSelected()??!1})),r=()=>a.value?.(C.value);let s,u,g=!1;const v=()=>{const h=n.value;l.value=!!h&&h.scrollWidth>h.clientWidth},w=()=>{g||(u!==void 0&&cancelAnimationFrame(u),u=requestAnimationFrame(()=>{u=void 0,v()}))},R=h=>{if(s?.disconnect(),h){s?.observe(h);const k=h.closest(".ag-cell");k&&s?.observe(k)}w()};return e.onMounted(()=>{s=new ResizeObserver(w),R(n.value)}),e.watch(n,R,{flush:"post"}),e.onUnmounted(()=>{g=!0,s?.disconnect(),u!==void 0&&cancelAnimationFrame(u)}),c({refresh(h){return o.value=h,e.nextTick(w),!0}}),(h,k)=>{const I=e.resolveComponent("KTooltip");return a.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(r),{key:0})):(e.openBlock(),e.createElementBlock("span",J,[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:i.value},{default:e.withCtx(()=>[e.createElementVNode("span",{ref_key:"contentElement",ref:n,class:"table-data-grid-cell-content"},e.toDisplayString(i.value),513)]),_:1},8,["disabled","text"])]))}}}),Y=({headers:t,slots:c,initialSort:o})=>{const n=e.computed(()=>({cells:{slots:c}})),l=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:r=>r.data?.[a.key],width:a.width,cellRenderer:X,cellRendererParams:{headerDef:a}}};return{columnDefs:e.computed(()=>t.value.map(l)),gridContext:n}},K=({config:t,headers:c,pageSize:o})=>{const n=new Set(c.filter(i=>i.sortable).map(i=>i.key)),l=t?.sortColumnKey&&n.has(t.sortColumnKey)?t.sortColumnKey:void 0;return{sortColumnKey:l,sortColumnOrder:l?t?.sortColumnOrder:void 0,pageSize:t?.pageSize??o}},N=(t,c)=>t.sortColumnKey===c.sortColumnKey&&t.sortColumnOrder===c.sortColumnOrder&&t.pageSize===c.pageSize,Z=({headers:t,pageSize:c,tableConfig:o,emitTableConfigUpdate:n,onExternalConfigChange:l})=>{const i=e.computed(()=>o.value?K({config:o.value,headers:t.value,pageSize:c.value}):void 0),a=e.ref(i.value??K({config:void 0,headers:t.value,pageSize:c.value}));e.watch(i,u=>{u&&!N(u,a.value)&&(a.value=u,l?.(u))});const C=u=>{const g=K({config:{...a.value,...u},headers:t.value,pageSize:c.value});N(g,a.value)||(a.value=g,n(g))},r=e.computed(()=>({sortColumnKey:a.value.sortColumnKey,sortColumnOrder:a.value.sortColumnOrder})),s=e.computed(()=>o.value?.pageSize??c.value);return{activeTableConfig:e.readonly(a),activeSort:r,activePageSize:s,patchTableConfig:C}},ee=({cellClick:t,headers:c,rowClick:o})=>{const n=e.computed(()=>new Set(c.value.filter(r=>r.disableRowClick).map(r=>r.key))),l=r=>{const s=r.event?.target;return s instanceof Element?s.closest(".ag-cell")?.getAttribute("col-id")??void 0:void 0},i=r=>{const s=l(r);return!!(s&&n.value.has(s))};return{onCellClick:r=>{const s=r.colDef.colId;!r.data||!s||t({columnKey:s,row:r.data,value:r.value})},onRowClick:r=>{r.data&&!i(r)&&o(r.data,r)}}},te=({activeSort:t,emitSort:c,patchTableConfig:o})=>{const n=(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(s=>s.sort).sort((s,u)=>(s.sortIndex??0)-(u.sortIndex??0)),C=a[a.length-1],r=C?{sortColumnKey:C.colId,sortColumnOrder:C.sort}:{sortColumnKey:void 0,sortColumnOrder:void 0};r.sortColumnKey===t.value.sortColumnKey&&r.sortColumnOrder===t.value.sortColumnOrder||(c(r),o(r),a.length>1&&n(i.api,r))},applySortToGrid:n}},oe={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 ae(){const t=G.createI18n("en-us",oe);return{i18n:t,i18nT:G.i18nTComponent(t)}}const ne={class:"kong-ui-public-table-data-grid","data-testid":"table-data-grid"},re={key:0,class:"table-error-state","data-testid":"table-error-state"},le={key:1,class:"table-empty-state","data-testid":"table-empty-state"},se=((t,c)=>{const o=t.__vccOpts||t;for(const[n,l]of c)o[n]=l;return o})(e.defineComponent({__name:"TableDataGrid",props:{headers:{},error:{type:Boolean},pageSize:{},refreshKey:{type:[String,Number,Boolean]},tableConfig:{},fetcher:{type:Function},mode:{}},emits:["grid:ready","state","row:click","cell:click","sort","update:tableConfig"],setup(t,{emit:c}){E.ModuleRegistry.registerModules([E.AllCommunityModule,E.ClientSideRowModelModule,E.InfiniteRowModelModule]);const o=t,n=o.mode??"infinite",l=e.toRef(o,"headers"),i=e.computed(()=>o.error??!1),a=e.computed(()=>o.pageSize??25),C=e.toRef(o,"refreshKey"),r=e.toRef(o,"tableConfig"),s=c,{i18n:{t:u}}=ae(),g=e.useSlots(),v=e.shallowRef(),{activeTableConfig:w,activeSort:R,activePageSize:h,patchTableConfig:k}=Z({headers:l,pageSize:a,tableConfig:r,emitTableConfigUpdate:y=>s("update:tableConfig",y),onExternalConfigChange:y=>{v.value&&O(v.value,y)}}),{onSortChanged:I,applySortToGrid:O}=te({activeSort:R,emitSort:y=>s("sort",y),patchTableConfig:k}),{columnDefs:x,gridContext:T}=Y({headers:l,slots:g,initialSort:R.value}),{onCellClick:B,onRowClick:d}=ee({cellClick:y=>s("cell:click",y),headers:l,rowClick:(y,V)=>s("row:click",y,V)}),f={resizable:!1,sortable:!1,suppressMovable:!0},p=e.computed(()=>n==="unpaginated"?[o.fetcher,C.value]:[o.fetcher,h.value,C.value,w.value.sortColumnKey,w.value.sortColumnOrder]),S=o.mode==="unpaginated"?Q({fetcher:e.toRef(()=>o.fetcher),resetKey:p}):H({fetcher:o.fetcher,resetKey:p,sort:R}),{data:m,error:z,isFetching:D}=S,{datasource:F}=S,ie=e.computed(()=>m.value?Array.from(m.value):void 0),{fetchState:ce,hasData:M,state:A}=W(m,z,D,void 0,n==="unpaginated"),de=e.computed(()=>A.value===ce.SUCCESS&&!M.value);$({emitState:y=>s("state",y),emitInitialState:n==="unpaginated",fetchLifecycleState:A,hasData:M});const ue=y=>{v.value=y.api,s("grid:ready",y.api)};return(y,V)=>{const q=e.resolveComponent("KEmptyState");return e.openBlock(),e.createElementBlock("div",ne,[i.value?(e.openBlock(),e.createElementBlock("div",re,[e.renderSlot(y.$slots,"error-state",{},()=>[e.createVNode(q,{"icon-variant":"error",message:e.unref(u)("errorState.message"),title:e.unref(u)("errorState.title")},null,8,["message","title"])],!0)])):de.value?(e.openBlock(),e.createElementBlock("div",le,[e.renderSlot(y.$slots,"empty-state",{},()=>[e.createVNode(q,{message:e.unref(u)("emptyState.message"),title:e.unref(u)("emptyState.title")},null,8,["message","title"])],!0)])):(e.openBlock(),e.createBlock(e.unref(U.AgGridVue),{key:e.unref(n),"cache-block-size":e.unref(n)==="infinite"?e.unref(h):void 0,class:"table-data-grid-grid","column-defs":e.unref(x),context:e.unref(T),datasource:e.unref(n)==="infinite"?e.unref(F):void 0,"default-col-def":f,"infinite-initial-row-count":e.unref(n)==="infinite"?1:void 0,loading:e.unref(D),"row-data":e.unref(n)==="unpaginated"?ie.value:void 0,"row-model-type":e.unref(n)==="unpaginated"?"clientSide":"infinite","suppress-cell-focus":!0,"suppress-multi-sort":!0,theme:e.unref(E.themeQuartz),onCellClicked:e.unref(B),onGridReady:ue,onRowClicked:e.unref(d),onSortChanged:e.unref(I)},null,8,["cache-block-size","column-defs","context","datasource","infinite-initial-row-count","loading","row-data","row-model-type","theme","onCellClicked","onRowClicked","onSortChanged"]))])}}}),[["__scopeId","data-v-0ff95391"]]);b.TableDataGrid=se,Object.defineProperty(b,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,7 +1,14 @@
|
|
|
1
|
-
import type { TableDataGridCellClickPayload, TableDataGridCellSlotProps, TableDataGridConfig,
|
|
1
|
+
import type { TableDataGridCellClickPayload, TableDataGridCellSlotProps, TableDataGridConfig, TableDataGridFetcher, TableDataGridHeader, TableDataGridSort, TableDataGridStatePayload } from '../types';
|
|
2
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
|
-
props: import("vue").PublicProps & __VLS_PrettifyLocal<
|
|
4
|
+
props: import("vue").PublicProps & __VLS_PrettifyLocal<{
|
|
5
|
+
headers: Array<TableDataGridHeader<Row>>;
|
|
6
|
+
fetcher: TableDataGridFetcher<Row>;
|
|
7
|
+
error?: boolean;
|
|
8
|
+
pageSize?: number;
|
|
9
|
+
refreshKey?: string | number | boolean;
|
|
10
|
+
tableConfig?: TableDataGridConfig;
|
|
11
|
+
} & {
|
|
5
12
|
onState?: ((payload: TableDataGridStatePayload) => any) | undefined;
|
|
6
13
|
onSort?: ((payload: TableDataGridSort) => any) | undefined;
|
|
7
14
|
"onGrid:ready"?: ((api: GridApi<Row>) => any) | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableDataGrid.vue.d.ts","sourceRoot":"","sources":["../../../src/components/TableDataGrid.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TableDataGrid.vue.d.ts","sourceRoot":"","sources":["../../../src/components/TableDataGrid.vue"],"names":[],"mappings":"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"}
|
|
@@ -3,10 +3,9 @@ import type { Ref } from 'vue';
|
|
|
3
3
|
import { fetchState } from './useFetchState';
|
|
4
4
|
type UseEmitStateOptions = {
|
|
5
5
|
emitState: (payload: TableDataGridStatePayload) => void;
|
|
6
|
-
emitInitialState?: boolean;
|
|
7
6
|
fetchLifecycleState: Readonly<Ref<fetchState>>;
|
|
8
7
|
hasData: Readonly<Ref<boolean>>;
|
|
9
8
|
};
|
|
10
|
-
export declare const useEmitState: ({ emitState,
|
|
9
|
+
export declare const useEmitState: ({ emitState, fetchLifecycleState, hasData, }: UseEmitStateOptions) => void;
|
|
11
10
|
export {};
|
|
12
11
|
//# sourceMappingURL=useEmitState.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEmitState.d.ts","sourceRoot":"","sources":["../../../src/composables/useEmitState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAA;AACzD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAE9B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,KAAK,mBAAmB,GAAG;IACzB,SAAS,EAAE,CAAC,OAAO,EAAE,yBAAyB,KAAK,IAAI,CAAA;IACvD,
|
|
1
|
+
{"version":3,"file":"useEmitState.d.ts","sourceRoot":"","sources":["../../../src/composables/useEmitState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAA;AACzD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAE9B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,KAAK,mBAAmB,GAAG;IACzB,SAAS,EAAE,CAAC,OAAO,EAAE,yBAAyB,KAAK,IAAI,CAAA;IACvD,mBAAmB,EAAE,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAA;IAC9C,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAA;CAChC,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,8CAI1B,mBAAmB,SAmCrB,CAAA"}
|
|
@@ -24,10 +24,7 @@ type FetchStateData<Row> = readonly Row[] | undefined;
|
|
|
24
24
|
* @param isFetching Whether at least one fetch request is currently pending.
|
|
25
25
|
* @param hasDataCallback Optional row detector for callers that need a custom
|
|
26
26
|
* definition of meaningful data.
|
|
27
|
-
* @param errorTakesPrecedence Whether a settled error should remain visible
|
|
28
|
-
* when rows from an earlier request are still available. Infinite consumers
|
|
29
|
-
* retain their existing data-first behavior by default.
|
|
30
27
|
*/
|
|
31
|
-
export default function useFetchState<Row>(data: Readonly<Ref<FetchStateData<Row>>>, error: Readonly<Ref<unknown>>, isFetching: Readonly<Ref<boolean>>, hasDataCallback?: (data: FetchStateData<Row>) => boolean
|
|
28
|
+
export default function useFetchState<Row>(data: Readonly<Ref<FetchStateData<Row>>>, error: Readonly<Ref<unknown>>, isFetching: Readonly<Ref<boolean>>, hasDataCallback?: (data: FetchStateData<Row>) => boolean): UseFetchStateResult;
|
|
32
29
|
export {};
|
|
33
30
|
//# sourceMappingURL=useFetchState.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFetchState.d.ts","sourceRoot":"","sources":["../../../src/composables/useFetchState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAG9B,oBAAY,UAAU;IACpB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,KAAK,UAAU;CAChB;AAED,KAAK,mBAAmB,GAAG;IACzB,UAAU,EAAE,OAAO,UAAU,CAAA;IAC7B,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAA;IAC/B,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAA;CACjC,CAAA;AAED,KAAK,cAAc,CAAC,GAAG,IAAI,SAAS,GAAG,EAAE,GAAG,SAAS,CAAA;AAMrD
|
|
1
|
+
{"version":3,"file":"useFetchState.d.ts","sourceRoot":"","sources":["../../../src/composables/useFetchState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAG9B,oBAAY,UAAU;IACpB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,KAAK,UAAU;CAChB;AAED,KAAK,mBAAmB,GAAG;IACzB,UAAU,EAAE,OAAO,UAAU,CAAA;IAC7B,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAA;IAC/B,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAA;CACjC,CAAA;AAED,KAAK,cAAc,CAAC,GAAG,IAAI,SAAS,GAAG,EAAE,GAAG,SAAS,CAAA;AAMrD;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,GAAG,EACvC,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EACxC,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAC7B,UAAU,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAClC,eAAe,GAAE,CAAC,IAAI,EAAE,cAAc,CAAC,GAAG,CAAC,KAAK,OAAwB,GACvE,mBAAmB,CAgCrB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GridApi } from 'ag-grid-community';
|
|
2
|
-
export type TableDataGridMode = 'infinite'
|
|
2
|
+
export type TableDataGridMode = 'infinite';
|
|
3
3
|
export type TableDataGridRow = Record<string, unknown>;
|
|
4
4
|
export type TableDataGridState = 'loading' | 'success' | 'error';
|
|
5
5
|
export type TableDataGridStatePayload = {
|
|
@@ -50,28 +50,12 @@ export type TableDataGridSort = {
|
|
|
50
50
|
export type TableDataGridConfig = TableDataGridSort & {
|
|
51
51
|
pageSize?: number;
|
|
52
52
|
};
|
|
53
|
-
export type TableDataGridProps<Row extends object = TableDataGridRow> = {
|
|
54
|
-
headers: Array<TableDataGridHeader<Row>>;
|
|
55
|
-
error?: boolean;
|
|
56
|
-
pageSize?: number;
|
|
57
|
-
refreshKey?: string | number | boolean;
|
|
58
|
-
tableConfig?: TableDataGridConfig;
|
|
59
|
-
} & ({
|
|
60
|
-
fetcher: TableDataGridFetcher<Row>;
|
|
61
|
-
mode?: 'infinite';
|
|
62
|
-
} | {
|
|
63
|
-
fetcher: TableDataGridUnpaginatedFetcher<Row>;
|
|
64
|
-
mode: 'unpaginated';
|
|
65
|
-
});
|
|
66
53
|
export interface TableDataGridInfiniteFetcherParams {
|
|
67
54
|
mode: 'infinite';
|
|
68
55
|
pageSize: number;
|
|
69
56
|
cursor?: unknown;
|
|
70
57
|
sort?: TableDataGridSort;
|
|
71
58
|
}
|
|
72
|
-
export interface TableDataGridUnpaginatedFetcherParams {
|
|
73
|
-
mode: 'unpaginated';
|
|
74
|
-
}
|
|
75
59
|
export type TableDataGridFetcherResult<Row extends object = TableDataGridRow> = {
|
|
76
60
|
data: Row[];
|
|
77
61
|
cursor?: unknown;
|
|
@@ -79,9 +63,5 @@ export type TableDataGridFetcherResult<Row extends object = TableDataGridRow> =
|
|
|
79
63
|
hasMore?: boolean;
|
|
80
64
|
};
|
|
81
65
|
export type TableDataGridFetcher<Row extends object = TableDataGridRow> = (params: TableDataGridInfiniteFetcherParams) => Promise<TableDataGridFetcherResult<Row>>;
|
|
82
|
-
export type TableDataGridUnpaginatedFetcherResult<Row extends object = TableDataGridRow> = {
|
|
83
|
-
data: Row[];
|
|
84
|
-
};
|
|
85
|
-
export type TableDataGridUnpaginatedFetcher<Row extends object = TableDataGridRow> = (params: TableDataGridUnpaginatedFetcherParams) => Promise<TableDataGridUnpaginatedFetcherResult<Row>>;
|
|
86
66
|
export type TableDataGridReadyPayload<Row extends object = TableDataGridRow> = GridApi<Row>;
|
|
87
67
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -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,
|
|
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,GAAG,CAAA;AAErF,MAAM,MAAM,6BAA6B,CAAC,GAAG,SAAS,MAAM,GAAG,gBAAgB,IAAI;IACjF,GAAG,EAAE,GAAG,CAAA;IACR,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,OAAO,CAAA;CACf,CAAA;AAED,MAAM,MAAM,0BAA0B,CAAC,GAAG,SAAS,MAAM,GAAG,gBAAgB,IAAI;IAC9E,GAAG,EAAE,GAAG,CAAA;IACR,QAAQ,EAAE,OAAO,CAAA;IACjB,MAAM,EAAE,mBAAmB,CAAC,GAAG,CAAC,CAAA;IAChC,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,OAAO,CAAA;IACjB,6CAA6C;IAC7C,WAAW,EAAE,MAAM,IAAI,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,mBAAmB,CAAC,GAAG,SAAS,MAAM,GAAG,gBAAgB,IAAI;IACvE,GAAG,EAAE,OAAO,CAAC,MAAM,GAAG,EAAE,MAAM,CAAC,CAAA;IAC/B,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,iFAAiF;IACjF,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG,KAAK,GAAG,MAAM,CAAA;AAEvD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,eAAe,CAAC,EAAE,0BAA0B,CAAA;CAC7C,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG,iBAAiB,GAAG;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,MAAM,WAAW,kCAAkC;IACjD,IAAI,EAAE,UAAU,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,IAAI,CAAC,EAAE,iBAAiB,CAAA;CACzB;AAED,MAAM,MAAM,0BAA0B,CAAC,GAAG,SAAS,MAAM,GAAG,gBAAgB,IAAI;IAC9E,IAAI,EAAE,GAAG,EAAE,CAAA;IACX,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,oBAAoB,CAAC,GAAG,SAAS,MAAM,GAAG,gBAAgB,IAAI,CACxE,MAAM,EAAE,kCAAkC,KACvC,OAAO,CAAC,0BAA0B,CAAC,GAAG,CAAC,CAAC,CAAA;AAE7C,MAAM,MAAM,yBAAyB,CAAC,GAAG,SAAS,MAAM,GAAG,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kong-ui-public/table-data-grid",
|
|
3
|
-
"version": "0.5.3
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/table-data-grid.umd.js",
|
|
6
6
|
"module": "./dist/table-data-grid.es.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@kong-ui-public/i18n": "^2.5.1",
|
|
25
|
-
"@kong/kongponents": "9.64.
|
|
25
|
+
"@kong/kongponents": "9.64.18",
|
|
26
26
|
"vue": "^3.5.41"
|
|
27
27
|
},
|
|
28
28
|
"repository": {
|
|
@@ -63,8 +63,7 @@
|
|
|
63
63
|
"lint:fix": "eslint --fix",
|
|
64
64
|
"stylelint": "stylelint --allow-empty-input './src/**/*.{css,scss,sass,less,styl,vue}'",
|
|
65
65
|
"stylelint:fix": "stylelint --allow-empty-input './src/**/*.{css,scss,sass,less,styl,vue}' --fix",
|
|
66
|
-
"typecheck": "vue-tsc -p './tsconfig.build.json' --noEmit
|
|
67
|
-
"typecheck:types": "vue-tsc -p './tsconfig.types.json' --noEmit",
|
|
66
|
+
"typecheck": "vue-tsc -p './tsconfig.build.json' --noEmit",
|
|
68
67
|
"test:component": "BABEL_ENV=cypress cross-env FORCE_COLOR=1 cypress run --component -b chrome --spec './src/**/*.cy.ts' --project '../../../.'",
|
|
69
68
|
"test:component:open": "BABEL_ENV=cypress cross-env FORCE_COLOR=1 cypress open --component -b chrome --project '../../../.'",
|
|
70
69
|
"test:unit": "cross-env FORCE_COLOR=1 vitest run",
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { TableDataGridRow, TableDataGridUnpaginatedFetcher } from '../types';
|
|
2
|
-
import type { Ref } from 'vue';
|
|
3
|
-
interface UseFetchUnpaginatedOptions<Row extends object = TableDataGridRow> {
|
|
4
|
-
/** Public fetcher supplied by the host. */
|
|
5
|
-
fetcher: Readonly<Ref<TableDataGridUnpaginatedFetcher<Row>>>;
|
|
6
|
-
/** Reactive invalidation input for the current query context. */
|
|
7
|
-
resetKey?: Readonly<Ref<unknown>>;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Owns the one-request lifecycle for a complete, non-paginated result.
|
|
11
|
-
*
|
|
12
|
-
* The client-side row model consumes the returned rows directly. A request
|
|
13
|
-
* generation keeps responses from an invalidated query from replacing current
|
|
14
|
-
* rows, errors, or loading state.
|
|
15
|
-
*/
|
|
16
|
-
export declare const useFetchUnpaginated: <Row extends object = TableDataGridRow>({ fetcher, resetKey, }: UseFetchUnpaginatedOptions<Row>) => {
|
|
17
|
-
data: Readonly<Ref<readonly import("vue").DeepReadonly<Row>[] | undefined, readonly import("vue").DeepReadonly<Row>[] | undefined>>;
|
|
18
|
-
datasource: undefined;
|
|
19
|
-
error: Readonly<Ref<Readonly<unknown>, Readonly<unknown>>>;
|
|
20
|
-
isFetching: Readonly<Ref<boolean, boolean>>;
|
|
21
|
-
};
|
|
22
|
-
export {};
|
|
23
|
-
//# sourceMappingURL=useFetchUnpaginated.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useFetchUnpaginated.d.ts","sourceRoot":"","sources":["../../../src/composables/useFetchUnpaginated.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,+BAA+B,EAChC,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAG9B,UAAU,0BAA0B,CAAC,GAAG,SAAS,MAAM,GAAG,gBAAgB;IACxE,2CAA2C;IAC3C,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,+BAA+B,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;IAC5D,iEAAiE;IACjE,QAAQ,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAA;CAClC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAAI,GAAG,SAAS,MAAM,GAAG,gBAAgB,EAAE,wBAGxE,0BAA0B,CAAC,GAAG,CAAC;;;;;CA0FjC,CAAA"}
|