@kong-ui-public/table-data-grid 0.4.1 → 0.4.2-pr.3761.bed46084d.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 +44 -1
- package/dist/style.css +1 -1
- package/dist/table-data-grid.es.js +352 -268
- 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 +17 -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,36 @@ should opt out of the default flexible fill behavior.
|
|
|
213
221
|
| `minWidth` | `number` | No | Minimum AG Grid column width in pixels. Columns with only `minWidth` still fill available width by default. |
|
|
214
222
|
| `maxWidth` | `number` | No | Maximum AG Grid column width in pixels. Columns with `maxWidth` do not receive default flex sizing. |
|
|
215
223
|
| `disableRowClick` | `boolean` | No | Suppresses `row:click` for clicks landing in this column's cells, e.g. an actions column. `cell:click` still fires. |
|
|
224
|
+
| `sortable` | `boolean` | No | Enables sorting on this column via AG Grid's built-in header sort control. Only one column can be sorted at a time. |
|
|
225
|
+
| `showSortIcon` | `boolean` | No | Shows the unsorted sort icon on this column even when it isn't the active sort, instead of only on hover or once sorted. Only relevant when `sortable` is true. |
|
|
226
|
+
|
|
227
|
+
## Sorting
|
|
228
|
+
|
|
229
|
+
`TableDataGrid` supports sorting by a single column at a time. Mark a column
|
|
230
|
+
sortable with `header.sortable`, and AG Grid renders its built-in sort icon
|
|
231
|
+
and handles the click. Sorting a second column replaces the first; AG Grid's
|
|
232
|
+
shift-click multi-sort gesture is disabled.
|
|
233
|
+
|
|
234
|
+
```vue
|
|
235
|
+
<TableDataGrid
|
|
236
|
+
:fetcher="fetchRows"
|
|
237
|
+
:headers="[
|
|
238
|
+
{ key: 'name', label: 'Name', sortable: true },
|
|
239
|
+
{ key: 'status', label: 'Status', sortable: true },
|
|
240
|
+
]"
|
|
241
|
+
:table-config="tableConfig"
|
|
242
|
+
@sort="handleSort"
|
|
243
|
+
@update:table-config="tableConfig = $event"
|
|
244
|
+
/>
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
The current sort lives in `tableConfig` (`sortColumnKey`, `sortColumnOrder`),
|
|
248
|
+
alongside `pageSize`. Pass `tableConfig` to restore a previously-chosen sort
|
|
249
|
+
on mount, or to move the sort after mount without a click; omit it to let the
|
|
250
|
+
component own the sort internally. A sort change emits `sort` (the narrower,
|
|
251
|
+
sort-only payload) and then `update:tableConfig` (the full current config),
|
|
252
|
+
and rebuilds the infinite datasource from the beginning — a cursor produced
|
|
253
|
+
under one sort order is not valid under another.
|
|
216
254
|
|
|
217
255
|
## Custom Cell Content
|
|
218
256
|
|
|
@@ -249,6 +287,8 @@ Columns without a matching slot render their raw `rowValue`.
|
|
|
249
287
|
| `state` | `{ state: 'loading' \| 'success' \| 'error', hasData: boolean }` | Internal fetch lifecycle changes after the datasource starts requesting rows. |
|
|
250
288
|
| `row:click` | `(row: TableDataGridRowClickPayload<Row>, event: RowClickedEvent<Row>)` | A row is clicked, unless the click landed in a `disableRowClick` column. |
|
|
251
289
|
| `cell:click` | `TableDataGridCellClickPayload<Row>` | Any cell is clicked, including cells in `disableRowClick` columns. |
|
|
290
|
+
| `sort` | `TableDataGridSort` | The current single-column sort changes. Fires before `update:tableConfig`. |
|
|
291
|
+
| `update:tableConfig` | `TableDataGridConfig` | A meaningful change to the current table configuration (sort or page size). |
|
|
252
292
|
|
|
253
293
|
## Slots
|
|
254
294
|
|
|
@@ -272,3 +312,6 @@ Columns without a matching slot render their raw `rowValue`.
|
|
|
272
312
|
- `TableDataGridFetcherResult`
|
|
273
313
|
- `TableDataGridFetcher`
|
|
274
314
|
- `TableDataGridReadyPayload`
|
|
315
|
+
- `TableDataGridSortDirection`
|
|
316
|
+
- `TableDataGridSort`
|
|
317
|
+
- `TableDataGridConfig`
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.table-data-grid-cell-renderer,.table-data-grid-cell-tooltip,.table-data-grid-cell-content{display:block;min-width:0;width:100%}.table-data-grid-cell-content{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.kong-ui-public-table-data-grid[data-v-
|
|
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 h, watch as M, ref as N, shallowRef as G, readonly as T, defineComponent as $, onMounted as j, onUnmounted as H, nextTick as Q, resolveComponent as q, openBlock as I, createBlock as P, resolveDynamicComponent as J, createElementBlock as B, createVNode as A, withCtx as X, createElementVNode as Y, toDisplayString as Z, useSlots as ee, toRef as x, renderSlot as V, unref as g } from "vue";
|
|
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 z = /* @__PURE__ */ ((e) => (e.PENDING = "PENDING", e.LOADING = "LOADING", e.SUCCESS = "SUCCESS", e.ERROR = "ERROR", e))(z || {});
|
|
6
|
+
const ie = (e) => !!e?.length;
|
|
7
|
+
function ce(e, n, t, l = ie) {
|
|
8
|
+
const r = h(() => l(e.value)), s = h(() => {
|
|
9
|
+
const m = e.value !== void 0, a = n.value !== void 0 && n.value !== null;
|
|
10
|
+
return t.value ? "LOADING" : r.value ? "SUCCESS" : a ? "ERROR" : m ? "SUCCESS" : "PENDING";
|
|
11
11
|
});
|
|
12
12
|
return {
|
|
13
|
-
fetchState:
|
|
13
|
+
fetchState: z,
|
|
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
|
+
M(
|
|
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 !== z.PENDING) {
|
|
30
|
+
if (r === z.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 === z.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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (s)
|
|
81
|
-
return s;
|
|
82
|
-
let d;
|
|
83
|
-
const h = {
|
|
84
|
-
promise: new Promise((f) => {
|
|
85
|
-
d = f;
|
|
73
|
+
const l = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), s = N(0), o = G(), m = G(), a = G(), c = N(!1), d = (i) => i === s.value, S = (i) => {
|
|
74
|
+
const v = r.get(i);
|
|
75
|
+
if (v)
|
|
76
|
+
return v;
|
|
77
|
+
let y;
|
|
78
|
+
const C = {
|
|
79
|
+
promise: new Promise((u) => {
|
|
80
|
+
y = u;
|
|
86
81
|
}),
|
|
87
|
-
resolve: (
|
|
82
|
+
resolve: (u) => y(u)
|
|
88
83
|
};
|
|
89
|
-
return
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
},
|
|
93
|
-
blockIndex:
|
|
94
|
-
currentBlockCompletion:
|
|
95
|
-
datasourceId:
|
|
84
|
+
return r.set(i, C), C;
|
|
85
|
+
}, b = (i, v) => {
|
|
86
|
+
v.resolve(!1), r.get(i) === v && r.delete(i);
|
|
87
|
+
}, D = async ({
|
|
88
|
+
blockIndex: i,
|
|
89
|
+
currentBlockCompletion: v,
|
|
90
|
+
datasourceId: y
|
|
96
91
|
}) => {
|
|
97
|
-
if (
|
|
92
|
+
if (i === 0)
|
|
98
93
|
return "ready";
|
|
99
|
-
const
|
|
100
|
-
if (!
|
|
101
|
-
return
|
|
102
|
-
const
|
|
103
|
-
return
|
|
104
|
-
},
|
|
105
|
-
blockIndex:
|
|
106
|
-
currentBlockCompletion:
|
|
107
|
-
getRowsParams:
|
|
108
|
-
pageSize:
|
|
109
|
-
result:
|
|
94
|
+
const C = r.get(i - 1);
|
|
95
|
+
if (!C)
|
|
96
|
+
return b(i, v), "failed";
|
|
97
|
+
const u = await C.promise;
|
|
98
|
+
return d(y) ? u ? "ready" : (b(i, v), "failed") : (b(i, v), "stale");
|
|
99
|
+
}, R = ({
|
|
100
|
+
blockIndex: i,
|
|
101
|
+
currentBlockCompletion: v,
|
|
102
|
+
getRowsParams: y,
|
|
103
|
+
pageSize: C,
|
|
104
|
+
result: u
|
|
110
105
|
}) => {
|
|
111
|
-
|
|
112
|
-
startRow:
|
|
113
|
-
rowsLength:
|
|
114
|
-
pageSize:
|
|
115
|
-
total:
|
|
116
|
-
hasMore:
|
|
117
|
-
})),
|
|
118
|
-
},
|
|
119
|
-
blockIndex:
|
|
120
|
-
currentBlockCompletion:
|
|
121
|
-
fetchError:
|
|
122
|
-
getRowsParams:
|
|
106
|
+
u.cursor !== void 0 && l.set(i, u.cursor), y.successCallback(u.data, me({
|
|
107
|
+
startRow: y.startRow,
|
|
108
|
+
rowsLength: u.data.length,
|
|
109
|
+
pageSize: C,
|
|
110
|
+
total: u.total,
|
|
111
|
+
hasMore: u.hasMore
|
|
112
|
+
})), y.startRow === 0 && (m.value = u.data), v.resolve(!0);
|
|
113
|
+
}, f = ({
|
|
114
|
+
blockIndex: i,
|
|
115
|
+
currentBlockCompletion: v,
|
|
116
|
+
fetchError: y,
|
|
117
|
+
getRowsParams: C
|
|
123
118
|
}) => {
|
|
124
|
-
|
|
125
|
-
},
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
119
|
+
a.value = y, C.failCallback(), b(i, v);
|
|
120
|
+
}, w = () => {
|
|
121
|
+
const i = s.value + 1;
|
|
122
|
+
s.value = i, l.clear(), r.clear(), m.value = void 0, a.value = void 0;
|
|
123
|
+
let v = 0;
|
|
124
|
+
const y = () => {
|
|
125
|
+
d(i) && (c.value = v > 0);
|
|
126
|
+
};
|
|
127
|
+
return y(), {
|
|
128
|
+
async getRows(C) {
|
|
129
129
|
const {
|
|
130
|
-
blockIndex:
|
|
131
|
-
pageSize:
|
|
132
|
-
} =
|
|
133
|
-
startRow:
|
|
134
|
-
endRow:
|
|
135
|
-
}),
|
|
136
|
-
blockIndex:
|
|
137
|
-
currentBlockCompletion:
|
|
138
|
-
datasourceId:
|
|
130
|
+
blockIndex: u,
|
|
131
|
+
pageSize: F
|
|
132
|
+
} = de({
|
|
133
|
+
startRow: C.startRow,
|
|
134
|
+
endRow: C.endRow
|
|
135
|
+
}), k = S(u), E = await D({
|
|
136
|
+
blockIndex: u,
|
|
137
|
+
currentBlockCompletion: k,
|
|
138
|
+
datasourceId: i
|
|
139
139
|
});
|
|
140
|
-
if (
|
|
141
|
-
|
|
140
|
+
if (E !== "ready") {
|
|
141
|
+
E === "failed" && C.failCallback();
|
|
142
142
|
return;
|
|
143
143
|
}
|
|
144
|
-
|
|
144
|
+
d(i) && (a.value = void 0), v += 1, y();
|
|
145
145
|
try {
|
|
146
|
-
const
|
|
146
|
+
const O = u > 0 ? l.get(u - 1) : void 0, _ = await e({
|
|
147
147
|
mode: "infinite",
|
|
148
|
-
pageSize:
|
|
149
|
-
cursor:
|
|
148
|
+
pageSize: F,
|
|
149
|
+
cursor: O,
|
|
150
|
+
sort: t?.value
|
|
150
151
|
});
|
|
151
|
-
if (!
|
|
152
|
-
|
|
152
|
+
if (!d(i)) {
|
|
153
|
+
C.failCallback(), b(u, k);
|
|
153
154
|
return;
|
|
154
155
|
}
|
|
155
|
-
|
|
156
|
-
blockIndex:
|
|
157
|
-
currentBlockCompletion:
|
|
158
|
-
getRowsParams:
|
|
159
|
-
pageSize:
|
|
160
|
-
result:
|
|
156
|
+
R({
|
|
157
|
+
blockIndex: u,
|
|
158
|
+
currentBlockCompletion: k,
|
|
159
|
+
getRowsParams: C,
|
|
160
|
+
pageSize: F,
|
|
161
|
+
result: _
|
|
161
162
|
});
|
|
162
|
-
} catch (
|
|
163
|
-
if (!
|
|
164
|
-
|
|
163
|
+
} catch (O) {
|
|
164
|
+
if (!d(i)) {
|
|
165
|
+
C.failCallback(), b(u, k);
|
|
165
166
|
return;
|
|
166
167
|
}
|
|
167
|
-
|
|
168
|
-
blockIndex:
|
|
169
|
-
currentBlockCompletion:
|
|
170
|
-
fetchError:
|
|
171
|
-
getRowsParams:
|
|
168
|
+
f({
|
|
169
|
+
blockIndex: u,
|
|
170
|
+
currentBlockCompletion: k,
|
|
171
|
+
fetchError: O,
|
|
172
|
+
getRowsParams: C
|
|
172
173
|
});
|
|
173
174
|
} finally {
|
|
174
|
-
|
|
175
|
+
v = Math.max(0, v - 1), y();
|
|
175
176
|
}
|
|
176
177
|
}
|
|
177
178
|
};
|
|
178
|
-
},
|
|
179
|
-
|
|
179
|
+
}, K = () => {
|
|
180
|
+
o.value = w();
|
|
180
181
|
};
|
|
181
|
-
return
|
|
182
|
-
() =>
|
|
182
|
+
return M(
|
|
183
|
+
() => n?.value,
|
|
183
184
|
() => {
|
|
184
|
-
|
|
185
|
+
K();
|
|
185
186
|
},
|
|
186
187
|
{ immediate: !0 }
|
|
187
188
|
), {
|
|
188
|
-
datasource:
|
|
189
|
-
data:
|
|
190
|
-
error:
|
|
191
|
-
isFetching:
|
|
189
|
+
datasource: T(o),
|
|
190
|
+
data: T(m),
|
|
191
|
+
error: T(a),
|
|
192
|
+
isFetching: T(c)
|
|
192
193
|
};
|
|
193
|
-
},
|
|
194
|
+
}, ve = {
|
|
194
195
|
key: 1,
|
|
195
196
|
class: "table-data-grid-cell-renderer"
|
|
196
|
-
},
|
|
197
|
+
}, Ce = /* @__PURE__ */ $({
|
|
197
198
|
name: "TableDataGridCellRenderer",
|
|
198
199
|
__name: "TableDataGridCellRenderer",
|
|
199
200
|
props: {
|
|
200
201
|
params: {}
|
|
201
202
|
},
|
|
202
|
-
setup(e, { expose:
|
|
203
|
-
const t =
|
|
204
|
-
const
|
|
205
|
-
return
|
|
206
|
-
}),
|
|
203
|
+
setup(e, { expose: n }) {
|
|
204
|
+
const t = G(e.params), l = N(null), r = N(!1), s = h(() => t.value.valueFormatted ?? String(t.value.value ?? "")), o = h(() => {
|
|
205
|
+
const f = t.value.colDef?.colId;
|
|
206
|
+
return f ? t.value.context?.cells?.slots?.[f] : void 0;
|
|
207
|
+
}), m = h(() => ({
|
|
207
208
|
column: t.value.headerDef,
|
|
208
209
|
refreshCell: () => {
|
|
209
|
-
const
|
|
210
|
-
|
|
210
|
+
const f = t.value.node;
|
|
211
|
+
f && t.value.api.refreshCells({ force: !0, rowNodes: [f] });
|
|
211
212
|
},
|
|
212
213
|
row: t.value.data ?? {},
|
|
213
214
|
rowIndex: t.value.node?.rowIndex ?? 0,
|
|
214
215
|
rowValue: t.value.value,
|
|
215
216
|
selected: t.value.node?.isSelected() ?? !1
|
|
216
|
-
})),
|
|
217
|
-
let
|
|
218
|
-
const
|
|
219
|
-
const
|
|
220
|
-
r.value = !!
|
|
221
|
-
},
|
|
222
|
-
|
|
223
|
-
|
|
217
|
+
})), a = () => o.value?.(m.value);
|
|
218
|
+
let c, d, S = !1;
|
|
219
|
+
const b = () => {
|
|
220
|
+
const f = l.value;
|
|
221
|
+
r.value = !!f && f.scrollWidth > f.clientWidth;
|
|
222
|
+
}, D = () => {
|
|
223
|
+
S || (d !== void 0 && cancelAnimationFrame(d), d = requestAnimationFrame(() => {
|
|
224
|
+
d = void 0, b();
|
|
224
225
|
}));
|
|
225
|
-
},
|
|
226
|
-
if (
|
|
227
|
-
|
|
228
|
-
const
|
|
229
|
-
|
|
226
|
+
}, R = (f) => {
|
|
227
|
+
if (c?.disconnect(), f) {
|
|
228
|
+
c?.observe(f);
|
|
229
|
+
const w = f.closest(".ag-cell");
|
|
230
|
+
w && c?.observe(w);
|
|
230
231
|
}
|
|
231
|
-
|
|
232
|
+
D();
|
|
232
233
|
};
|
|
233
|
-
return
|
|
234
|
-
|
|
235
|
-
}),
|
|
236
|
-
|
|
237
|
-
}),
|
|
238
|
-
refresh(
|
|
239
|
-
return t.value =
|
|
234
|
+
return j(() => {
|
|
235
|
+
c = new ResizeObserver(D), R(l.value);
|
|
236
|
+
}), M(l, R, { flush: "post" }), H(() => {
|
|
237
|
+
S = !0, c?.disconnect(), d !== void 0 && cancelAnimationFrame(d);
|
|
238
|
+
}), n({
|
|
239
|
+
refresh(f) {
|
|
240
|
+
return t.value = f, Q(D), !0;
|
|
240
241
|
}
|
|
241
|
-
}), (
|
|
242
|
-
const
|
|
243
|
-
return
|
|
244
|
-
|
|
242
|
+
}), (f, w) => {
|
|
243
|
+
const K = q("KTooltip");
|
|
244
|
+
return o.value ? (I(), P(J(a), { key: 0 })) : (I(), B("span", ve, [
|
|
245
|
+
A(K, {
|
|
245
246
|
class: "table-data-grid-cell-tooltip",
|
|
246
247
|
disabled: !r.value,
|
|
247
248
|
"kpop-attributes": { popoverDelay: 400 },
|
|
248
249
|
"max-width": "300",
|
|
249
250
|
placement: "bottom-start",
|
|
250
251
|
target: "body",
|
|
251
|
-
text:
|
|
252
|
+
text: s.value
|
|
252
253
|
}, {
|
|
253
|
-
default:
|
|
254
|
-
|
|
254
|
+
default: X(() => [
|
|
255
|
+
Y("span", {
|
|
255
256
|
ref_key: "contentElement",
|
|
256
|
-
ref:
|
|
257
|
+
ref: l,
|
|
257
258
|
class: "table-data-grid-cell-content"
|
|
258
|
-
},
|
|
259
|
+
}, Z(s.value), 513)
|
|
259
260
|
]),
|
|
260
261
|
_: 1
|
|
261
262
|
}, 8, ["disabled", "text"])
|
|
262
263
|
]));
|
|
263
264
|
};
|
|
264
265
|
}
|
|
265
|
-
}),
|
|
266
|
+
}), pe = ({
|
|
267
|
+
headers: e,
|
|
268
|
+
slots: n,
|
|
269
|
+
initialSort: t
|
|
270
|
+
}) => {
|
|
271
|
+
const l = h(() => ({
|
|
272
|
+
cells: { slots: n }
|
|
273
|
+
})), r = (o) => {
|
|
274
|
+
const m = t?.sortColumnKey === o.key;
|
|
275
|
+
return {
|
|
276
|
+
colId: o.key,
|
|
277
|
+
// Columns with no explicit width constraint share remaining space equally.
|
|
278
|
+
flex: !o.width && !o.maxWidth ? 1 : void 0,
|
|
279
|
+
headerName: o.label,
|
|
280
|
+
maxWidth: o.maxWidth,
|
|
281
|
+
minWidth: o.minWidth,
|
|
282
|
+
sortable: o.sortable,
|
|
283
|
+
unSortIcon: o.showSortIcon,
|
|
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: h(() => e.value.map(r)),
|
|
294
|
+
gridContext: l
|
|
295
|
+
};
|
|
296
|
+
}, ye = ({
|
|
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 = ({
|
|
266
308
|
headers: e,
|
|
267
|
-
|
|
309
|
+
pageSize: n,
|
|
310
|
+
tableConfig: t,
|
|
311
|
+
emitTableConfigUpdate: l,
|
|
312
|
+
onExternalConfigChange: r
|
|
268
313
|
}) => {
|
|
269
|
-
const
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
colId: i.key,
|
|
273
|
-
// Columns with no explicit width constraint share remaining space equally.
|
|
274
|
-
flex: !i.width && !i.maxWidth ? 1 : void 0,
|
|
275
|
-
headerName: i.label,
|
|
276
|
-
maxWidth: i.maxWidth,
|
|
277
|
-
minWidth: i.minWidth,
|
|
278
|
-
valueGetter: (v) => v.data?.[i.key],
|
|
279
|
-
width: i.width,
|
|
280
|
-
cellRenderer: fe,
|
|
281
|
-
// custom params passed to the cell renderer.
|
|
282
|
-
cellRendererParams: { headerDef: i }
|
|
314
|
+
const s = (d) => ye({ config: d, headers: e.value, pageSize: n.value }), o = N(s(t.value));
|
|
315
|
+
M(() => s(t.value), (d) => {
|
|
316
|
+
W(d, o.value) || (o.value = d, r?.(d));
|
|
283
317
|
});
|
|
318
|
+
const m = (d) => {
|
|
319
|
+
const S = s({ ...o.value, ...d });
|
|
320
|
+
W(S, o.value) || (o.value = S, l(S));
|
|
321
|
+
}, a = h(() => ({
|
|
322
|
+
sortColumnKey: o.value.sortColumnKey,
|
|
323
|
+
sortColumnOrder: o.value.sortColumnOrder
|
|
324
|
+
})), c = h(() => o.value.pageSize ?? n.value);
|
|
284
325
|
return {
|
|
285
|
-
|
|
286
|
-
|
|
326
|
+
activeTableConfig: T(o),
|
|
327
|
+
activeSort: a,
|
|
328
|
+
activePageSize: c,
|
|
329
|
+
patchTableConfig: m
|
|
287
330
|
};
|
|
288
|
-
},
|
|
331
|
+
}, he = ({
|
|
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 = h(() => new Set(
|
|
337
|
+
n.value.filter((a) => a.disableRowClick).map((a) => a.key)
|
|
338
|
+
)), r = (a) => {
|
|
339
|
+
const c = a.event?.target;
|
|
340
|
+
return c instanceof Element ? c.closest(".ag-cell")?.getAttribute("col-id") ?? void 0 : void 0;
|
|
341
|
+
}, s = (a) => {
|
|
342
|
+
const c = r(a);
|
|
343
|
+
return !!(c && l.value.has(c));
|
|
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, d) => (c.sortIndex ?? 0) - (d.sortIndex ?? 0)), m = o[o.length - 1], a = m ? { sortColumnKey: m.colId, sortColumnOrder: m.sort } : {};
|
|
371
|
+
a.sortColumnKey === e.value.sortColumnKey && a.sortColumnOrder === e.value.sortColumnOrder || (n(a), t(a), o.length > 1 && l(s.api, a));
|
|
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
|
+
}, Ie = {
|
|
331
389
|
key: 0,
|
|
332
390
|
class: "table-error-state",
|
|
333
391
|
"data-testid": "table-error-state"
|
|
334
|
-
},
|
|
392
|
+
}, Ke = {
|
|
335
393
|
key: 1,
|
|
336
394
|
class: "table-empty-state",
|
|
337
395
|
"data-testid": "table-empty-state"
|
|
338
|
-
},
|
|
396
|
+
}, Ee = /* @__PURE__ */ $({
|
|
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
|
-
|
|
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 = G(), { activeTableConfig: o, activeSort: m, activePageSize: a, patchTableConfig: c } = ge({
|
|
410
|
+
headers: x(() => e.headers),
|
|
411
|
+
pageSize: x(() => e.pageSize),
|
|
412
|
+
tableConfig: x(() => e.tableConfig),
|
|
413
|
+
emitTableConfigUpdate: (p) => t("update:tableConfig", p),
|
|
414
|
+
onExternalConfigChange: (p) => {
|
|
415
|
+
s.value && S(s.value, { sortColumnKey: p.sortColumnKey, sortColumnOrder: p.sortColumnOrder });
|
|
416
|
+
}
|
|
417
|
+
}), { onSortChanged: d, applySortToGrid: S } = Se({
|
|
418
|
+
activeSort: m,
|
|
419
|
+
emitSort: (p) => t("sort", p),
|
|
420
|
+
patchTableConfig: c
|
|
421
|
+
}), { columnDefs: b, gridContext: D } = pe({
|
|
422
|
+
headers: x(() => e.headers),
|
|
423
|
+
slots: r,
|
|
424
|
+
// A snapshot, not the reactive activeSort: only the initial resolved sort
|
|
425
|
+
// (e.g. from a host-controlled tableConfig prop at mount) needs seeding
|
|
426
|
+
// into column defs. See useTableDataGridColumnDefs for why.
|
|
427
|
+
initialSort: m.value
|
|
428
|
+
}), { onCellClick: R, onRowClick: f } = he({
|
|
354
429
|
cellClick: (p) => t("cell:click", p),
|
|
355
|
-
headers:
|
|
356
|
-
rowClick: (p,
|
|
357
|
-
}),
|
|
430
|
+
headers: x(() => e.headers),
|
|
431
|
+
rowClick: (p, U) => t("row:click", p, U)
|
|
432
|
+
}), w = {
|
|
358
433
|
resizable: !1,
|
|
359
434
|
sortable: !1,
|
|
360
435
|
suppressMovable: !0
|
|
361
|
-
},
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
436
|
+
}, K = h(() => [
|
|
437
|
+
e.fetcher,
|
|
438
|
+
a.value,
|
|
439
|
+
e.refreshKey,
|
|
440
|
+
o.value.sortColumnKey,
|
|
441
|
+
o.value.sortColumnOrder
|
|
442
|
+
]), i = h(() => m.value.sortColumnKey ? m.value : void 0), {
|
|
443
|
+
data: v,
|
|
444
|
+
datasource: y,
|
|
445
|
+
error: C,
|
|
446
|
+
isFetching: u
|
|
447
|
+
} = fe({
|
|
367
448
|
fetcher: e.fetcher,
|
|
368
|
-
resetKey:
|
|
449
|
+
resetKey: K,
|
|
450
|
+
sort: i
|
|
369
451
|
}), {
|
|
370
|
-
fetchState:
|
|
371
|
-
hasData:
|
|
372
|
-
state:
|
|
373
|
-
} =
|
|
374
|
-
|
|
452
|
+
fetchState: F,
|
|
453
|
+
hasData: k,
|
|
454
|
+
state: E
|
|
455
|
+
} = ce(v, C, u), O = h(() => E.value === F.SUCCESS && !k.value);
|
|
456
|
+
ue({
|
|
375
457
|
emitState: (p) => t("state", p),
|
|
376
|
-
fetchLifecycleState:
|
|
377
|
-
hasData:
|
|
458
|
+
fetchLifecycleState: E,
|
|
459
|
+
hasData: k
|
|
378
460
|
});
|
|
379
|
-
const
|
|
380
|
-
t("grid:ready", p.api);
|
|
461
|
+
const _ = (p) => {
|
|
462
|
+
s.value = p.api, t("grid:ready", p.api);
|
|
381
463
|
};
|
|
382
|
-
return (p,
|
|
383
|
-
const
|
|
384
|
-
return
|
|
385
|
-
e.error ? (
|
|
386
|
-
|
|
387
|
-
|
|
464
|
+
return (p, U) => {
|
|
465
|
+
const L = q("KEmptyState");
|
|
466
|
+
return I(), B("div", Re, [
|
|
467
|
+
e.error ? (I(), B("div", Ie, [
|
|
468
|
+
V(p.$slots, "error-state", {}, () => [
|
|
469
|
+
A(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
|
+
])) : O.value ? (I(), B("div", Ke, [
|
|
476
|
+
V(p.$slots, "empty-state", {}, () => [
|
|
477
|
+
A(L, {
|
|
478
|
+
message: g(l)("emptyState.message"),
|
|
479
|
+
title: g(l)("emptyState.title")
|
|
398
480
|
}, null, 8, ["message", "title"])
|
|
399
481
|
], !0)
|
|
400
|
-
])) : (
|
|
482
|
+
])) : (I(), P(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(b),
|
|
487
|
+
context: g(D),
|
|
488
|
+
datasource: g(y),
|
|
489
|
+
"default-col-def": w,
|
|
408
490
|
"infinite-initial-row-count": 1,
|
|
409
|
-
loading:
|
|
491
|
+
loading: g(u),
|
|
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(R),
|
|
497
|
+
onGridReady: _,
|
|
498
|
+
onRowClicked: g(f),
|
|
499
|
+
onSortChanged: g(d)
|
|
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
|
+
}, Ne = /* @__PURE__ */ Oe(Ee, [["__scopeId", "data-v-2bcd2d90"]]);
|
|
426
510
|
export {
|
|
427
|
-
|
|
511
|
+
Ne 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(S,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("ag-grid-vue3"),require("ag-grid-community"),require("@kong-ui-public/i18n")):typeof define=="function"&&define.amd?define(["exports","vue","ag-grid-vue3","ag-grid-community","@kong-ui-public/i18n"],e):(S=typeof globalThis<"u"?globalThis:S||self,e(S["kong-ui-public-table-data-grid"]={},S.Vue,S.AgGridVue,S.agGridCommunity,S["kong-ui-public-i18n"]))})(this,(function(S,e,F,x,G){"use strict";var E=(t=>(t.PENDING="PENDING",t.LOADING="LOADING",t.SUCCESS="SUCCESS",t.ERROR="ERROR",t))(E||{});const M=t=>!!t?.length;function A(t,s,o,r=M){const l=e.computed(()=>r(t.value)),c=e.computed(()=>{const m=t.value!==void 0,n=s.value!==void 0&&s.value!==null;return o.value?"LOADING":l.value?"SUCCESS":n?"ERROR":m?"SUCCESS":"PENDING"});return{fetchState:E,hasData:l,state:c}}const V=({emitState:t,fetchLifecycleState:s,hasData:o})=>{e.watch(()=>({hasData:o.value,state:s.value}),({hasData:r,state:l})=>{if(l!==E.PENDING){if(l===E.LOADING){t({hasData:r,state:"loading"});return}if(l===E.ERROR){t({hasData:r,state:"error"});return}t({hasData:r,state:"success"})}})},U=({startRow:t,endRow:s})=>{const o=s-t;return{blockIndex:o>0?Math.floor(t/o):0,pageSize:o}},L=({startRow:t,rowsLength:s,pageSize:o,total:r,hasMore:l})=>{if(typeof r=="number")return r;if(l!==!0&&(l===!1||s<o))return t+s},W=({fetcher:t,resetKey:s,sort:o})=>{const r=new Map,l=new Map,c=e.ref(0),a=e.shallowRef(),m=e.shallowRef(),n=e.shallowRef(),d=e.ref(!1),f=i=>i===c.value,b=i=>{const p=l.get(i);if(p)return p;let y;const g={promise:new Promise(u=>{y=u}),resolve:u=>y(u)};return l.set(i,g),g},k=(i,p)=>{p.resolve(!1),l.get(i)===p&&l.delete(i)},w=async({blockIndex:i,currentBlockCompletion:p,datasourceId:y})=>{if(i===0)return"ready";const g=l.get(i-1);if(!g)return k(i,p),"failed";const u=await g.promise;return f(y)?u?"ready":(k(i,p),"failed"):(k(i,p),"stale")},R=({blockIndex:i,currentBlockCompletion:p,getRowsParams:y,pageSize:g,result:u})=>{u.cursor!==void 0&&r.set(i,u.cursor),y.successCallback(u.data,L({startRow:y.startRow,rowsLength:u.data.length,pageSize:g,total:u.total,hasMore:u.hasMore})),y.startRow===0&&(m.value=u.data),p.resolve(!0)},C=({blockIndex:i,currentBlockCompletion:p,fetchError:y,getRowsParams:g})=>{n.value=y,g.failCallback(),k(i,p)},D=()=>{const i=c.value+1;c.value=i,r.clear(),l.clear(),m.value=void 0,n.value=void 0;let p=0;const y=()=>{f(i)&&(d.value=p>0)};return y(),{async getRows(g){const{blockIndex:u,pageSize:T}=U({startRow:g.startRow,endRow:g.endRow}),v=b(u),K=await w({blockIndex:u,currentBlockCompletion:v,datasourceId:i});if(K!=="ready"){K==="failed"&&g.failCallback();return}f(i)&&(n.value=void 0),p+=1,y();try{const O=u>0?r.get(u-1):void 0,B=await t({mode:"infinite",pageSize:T,cursor:O,sort:o?.value});if(!f(i)){g.failCallback(),k(u,v);return}R({blockIndex:u,currentBlockCompletion:v,getRowsParams:g,pageSize:T,result:B})}catch(O){if(!f(i)){g.failCallback(),k(u,v);return}C({blockIndex:u,currentBlockCompletion:v,fetchError:O,getRowsParams:g})}finally{p=Math.max(0,p-1),y()}}}},I=()=>{a.value=D()};return e.watch(()=>s?.value,()=>{I()},{immediate:!0}),{datasource:e.readonly(a),data:e.readonly(m),error:e.readonly(n),isFetching:e.readonly(d)}},q={key:1,class:"table-data-grid-cell-renderer"},$=e.defineComponent({name:"TableDataGridCellRenderer",__name:"TableDataGridCellRenderer",props:{params:{}},setup(t,{expose:s}){const o=e.shallowRef(t.params),r=e.ref(null),l=e.ref(!1),c=e.computed(()=>o.value.valueFormatted??String(o.value.value??"")),a=e.computed(()=>{const C=o.value.colDef?.colId;return C?o.value.context?.cells?.slots?.[C]:void 0}),m=e.computed(()=>({column:o.value.headerDef,refreshCell:()=>{const C=o.value.node;C&&o.value.api.refreshCells({force:!0,rowNodes:[C]})},row:o.value.data??{},rowIndex:o.value.node?.rowIndex??0,rowValue:o.value.value,selected:o.value.node?.isSelected()??!1})),n=()=>a.value?.(m.value);let d,f,b=!1;const k=()=>{const C=r.value;l.value=!!C&&C.scrollWidth>C.clientWidth},w=()=>{b||(f!==void 0&&cancelAnimationFrame(f),f=requestAnimationFrame(()=>{f=void 0,k()}))},R=C=>{if(d?.disconnect(),C){d?.observe(C);const D=C.closest(".ag-cell");D&&d?.observe(D)}w()};return e.onMounted(()=>{d=new ResizeObserver(w),R(r.value)}),e.watch(r,R,{flush:"post"}),e.onUnmounted(()=>{b=!0,d?.disconnect(),f!==void 0&&cancelAnimationFrame(f)}),s({refresh(C){return o.value=C,e.nextTick(w),!0}}),(C,D)=>{const I=e.resolveComponent("KTooltip");return a.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n),{key:0})):(e.openBlock(),e.createElementBlock("span",q,[e.createVNode(I,{class:"table-data-grid-cell-tooltip",disabled:!l.value,"kpop-attributes":{popoverDelay:400},"max-width":"300",placement:"bottom-start",target:"body",text:c.value},{default:e.withCtx(()=>[e.createElementVNode("span",{ref_key:"contentElement",ref:r,class:"table-data-grid-cell-content"},e.toDisplayString(c.value),513)]),_:1},8,["disabled","text"])]))}}}),j=({headers:t,slots:s,initialSort:o})=>{const r=e.computed(()=>({cells:{slots:s}})),l=a=>{const m=o?.sortColumnKey===a.key;return{colId:a.key,flex:!a.width&&!a.maxWidth?1:void 0,headerName:a.label,maxWidth:a.maxWidth,minWidth:a.minWidth,sortable:a.sortable,unSortIcon:a.showSortIcon,...m?{sort:o?.sortColumnOrder,sortIndex:0}:{},valueGetter:n=>n.data?.[a.key],width:a.width,cellRenderer:$,cellRendererParams:{headerDef:a}}};return{columnDefs:e.computed(()=>t.value.map(l)),gridContext:r}},P=({config:t,headers:s,pageSize:o})=>{const r=new Set(s.filter(c=>c.sortable).map(c=>c.key)),l=t?.sortColumnKey&&r.has(t.sortColumnKey)?t.sortColumnKey:void 0;return{sortColumnKey:l,sortColumnOrder:l?t?.sortColumnOrder:void 0,pageSize:t?.pageSize??o}},N=(t,s)=>t.sortColumnKey===s.sortColumnKey&&t.sortColumnOrder===s.sortColumnOrder&&t.pageSize===s.pageSize,H=({headers:t,pageSize:s,tableConfig:o,emitTableConfigUpdate:r,onExternalConfigChange:l})=>{const c=f=>P({config:f,headers:t.value,pageSize:s.value}),a=e.ref(c(o.value));e.watch(()=>c(o.value),f=>{N(f,a.value)||(a.value=f,l?.(f))});const m=f=>{const b=c({...a.value,...f});N(b,a.value)||(a.value=b,r(b))},n=e.computed(()=>({sortColumnKey:a.value.sortColumnKey,sortColumnOrder:a.value.sortColumnOrder})),d=e.computed(()=>a.value.pageSize??s.value);return{activeTableConfig:e.readonly(a),activeSort:n,activePageSize:d,patchTableConfig:m}},Q=({cellClick:t,headers:s,rowClick:o})=>{const r=e.computed(()=>new Set(s.value.filter(n=>n.disableRowClick).map(n=>n.key))),l=n=>{const d=n.event?.target;return d instanceof Element?d.closest(".ag-cell")?.getAttribute("col-id")??void 0:void 0},c=n=>{const d=l(n);return!!(d&&r.value.has(d))};return{onCellClick:n=>{const d=n.colDef.colId;!n.data||!d||t({columnKey:d,row:n.data,value:n.value})},onRowClick:n=>{n.data&&!c(n)&&o(n.data,n)}}},J=({activeSort:t,emitSort:s,patchTableConfig:o})=>{const r=(c,a)=>{c.applyColumnState({state:a.sortColumnKey?[{colId:a.sortColumnKey,sort:a.sortColumnOrder??null,sortIndex:0}]:[],defaultState:{sort:null,sortIndex:null}})};return{onSortChanged:c=>{const a=c.api.getColumnState().filter(d=>d.sort).sort((d,f)=>(d.sortIndex??0)-(f.sortIndex??0)),m=a[a.length-1],n=m?{sortColumnKey:m.colId,sortColumnOrder:m.sort}:{};n.sortColumnKey===t.value.sortColumnKey&&n.sortColumnOrder===t.value.sortColumnOrder||(s(n),o(n),a.length>1&&r(c.api,n))},applySortToGrid:r}},X={emptyState:{title:"No Data",message:"There is no data to display."},errorState:{title:"An error occurred",message:"Data cannot be displayed due to an error."}};function Y(){const t=G.createI18n("en-us",X);return{i18n:t,i18nT:G.i18nTComponent(t)}}const Z={class:"kong-ui-public-table-data-grid","data-testid":"table-data-grid"},ee={key:0,class:"table-error-state","data-testid":"table-error-state"},te={key:1,class:"table-empty-state","data-testid":"table-empty-state"},oe=((t,s)=>{const o=t.__vccOpts||t;for(const[r,l]of s)o[r]=l;return o})(e.defineComponent({__name:"TableDataGrid",props:{headers:{},fetcher:{type:Function},error:{type:Boolean,default:!1},pageSize:{default:25},refreshKey:{type:[String,Number,Boolean]},tableConfig:{}},emits:["grid:ready","state","row:click","cell:click","sort","update:tableConfig"],setup(t,{emit:s}){x.ModuleRegistry.registerModules([x.AllCommunityModule,x.InfiniteRowModelModule]);const o=s,{i18n:{t:r}}=Y(),l=e.useSlots(),c=e.shallowRef(),{activeTableConfig:a,activeSort:m,activePageSize:n,patchTableConfig:d}=H({headers:e.toRef(()=>t.headers),pageSize:e.toRef(()=>t.pageSize),tableConfig:e.toRef(()=>t.tableConfig),emitTableConfigUpdate:h=>o("update:tableConfig",h),onExternalConfigChange:h=>{c.value&&b(c.value,{sortColumnKey:h.sortColumnKey,sortColumnOrder:h.sortColumnOrder})}}),{onSortChanged:f,applySortToGrid:b}=J({activeSort:m,emitSort:h=>o("sort",h),patchTableConfig:d}),{columnDefs:k,gridContext:w}=j({headers:e.toRef(()=>t.headers),slots:l,initialSort:m.value}),{onCellClick:R,onRowClick:C}=Q({cellClick:h=>o("cell:click",h),headers:e.toRef(()=>t.headers),rowClick:(h,z)=>o("row:click",h,z)}),D={resizable:!1,sortable:!1,suppressMovable:!0},I=e.computed(()=>[t.fetcher,n.value,t.refreshKey,a.value.sortColumnKey,a.value.sortColumnOrder]),i=e.computed(()=>m.value.sortColumnKey?m.value:void 0),{data:p,datasource:y,error:g,isFetching:u}=W({fetcher:t.fetcher,resetKey:I,sort:i}),{fetchState:T,hasData:v,state:K}=A(p,g,u),O=e.computed(()=>K.value===T.SUCCESS&&!v.value);V({emitState:h=>o("state",h),fetchLifecycleState:K,hasData:v});const B=h=>{c.value=h.api,o("grid:ready",h.api)};return(h,z)=>{const _=e.resolveComponent("KEmptyState");return e.openBlock(),e.createElementBlock("div",Z,[t.error?(e.openBlock(),e.createElementBlock("div",ee,[e.renderSlot(h.$slots,"error-state",{},()=>[e.createVNode(_,{"icon-variant":"error",message:e.unref(r)("errorState.message"),title:e.unref(r)("errorState.title")},null,8,["message","title"])],!0)])):O.value?(e.openBlock(),e.createElementBlock("div",te,[e.renderSlot(h.$slots,"empty-state",{},()=>[e.createVNode(_,{message:e.unref(r)("emptyState.message"),title:e.unref(r)("emptyState.title")},null,8,["message","title"])],!0)])):(e.openBlock(),e.createBlock(e.unref(F.AgGridVue),{key:2,"cache-block-size":e.unref(n),class:"table-data-grid-grid","column-defs":e.unref(k),context:e.unref(w),datasource:e.unref(y),"default-col-def":D,"infinite-initial-row-count":1,loading:e.unref(u),"row-model-type":"infinite","suppress-cell-focus":!0,"suppress-multi-sort":!0,theme:e.unref(x.themeQuartz),onCellClicked:e.unref(R),onGridReady:B,onRowClicked:e.unref(C),onSortChanged:e.unref(f)},null,8,["cache-block-size","column-defs","context","datasource","loading","theme","onCellClicked","onRowClicked","onSortChanged"]))])}}}),[["__scopeId","data-v-2bcd2d90"]]);S.TableDataGrid=oe,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -1,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;;;;;;;;;;;;;CAmV9B,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;;;;;;;;;CAiCA,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,28 @@ export type TableDataGridHeader<Row extends object = TableDataGridRow> = {
|
|
|
33
33
|
* selection/click mechanics are unaffected.
|
|
34
34
|
*/
|
|
35
35
|
disableRowClick?: boolean;
|
|
36
|
+
/** Enables sorting on this column via AG Grid's built-in header sort control. */
|
|
37
|
+
sortable?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Shows the unsorted sort icon on this column's header even when it isn't
|
|
40
|
+
* the active sort, instead of only on hover or once sorted. Only relevant
|
|
41
|
+
* when `sortable` is true.
|
|
42
|
+
*/
|
|
43
|
+
showSortIcon?: boolean;
|
|
44
|
+
};
|
|
45
|
+
export type TableDataGridSortDirection = 'asc' | 'desc';
|
|
46
|
+
export type TableDataGridSort = {
|
|
47
|
+
sortColumnKey?: string;
|
|
48
|
+
sortColumnOrder?: TableDataGridSortDirection;
|
|
49
|
+
};
|
|
50
|
+
export type TableDataGridConfig = TableDataGridSort & {
|
|
51
|
+
pageSize?: number;
|
|
36
52
|
};
|
|
37
53
|
export interface TableDataGridInfiniteFetcherParams {
|
|
38
54
|
mode: 'infinite';
|
|
39
55
|
pageSize: number;
|
|
40
56
|
cursor?: unknown;
|
|
57
|
+
sort?: TableDataGridSort;
|
|
41
58
|
}
|
|
42
59
|
export type TableDataGridFetcherResult<Row extends object = TableDataGridRow> = {
|
|
43
60
|
data: Row[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAEhD,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAA;AAC1C,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AACtD,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAA;AAEhE,MAAM,MAAM,yBAAyB,GAAG;IACtC,KAAK,EAAE,kBAAkB,CAAA;IACzB,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,4BAA4B,CAAC,GAAG,SAAS,MAAM,GAAG,gBAAgB,IAAI,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;IAClB;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG,KAAK,GAAG,MAAM,CAAA;AAEvD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,eAAe,CAAC,EAAE,0BAA0B,CAAA;CAC7C,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG,iBAAiB,GAAG;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,MAAM,WAAW,kCAAkC;IACjD,IAAI,EAAE,UAAU,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,IAAI,CAAC,EAAE,iBAAiB,CAAA;CACzB;AAED,MAAM,MAAM,0BAA0B,CAAC,GAAG,SAAS,MAAM,GAAG,gBAAgB,IAAI;IAC9E,IAAI,EAAE,GAAG,EAAE,CAAA;IACX,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,oBAAoB,CAAC,GAAG,SAAS,MAAM,GAAG,gBAAgB,IAAI,CACxE,MAAM,EAAE,kCAAkC,KACvC,OAAO,CAAC,0BAA0B,CAAC,GAAG,CAAC,CAAC,CAAA;AAE7C,MAAM,MAAM,yBAAyB,CAAC,GAAG,SAAS,MAAM,GAAG,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC,CAAA"}
|
|
@@ -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"}
|