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