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