@duro-app/ui 0.49.0 → 0.51.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.
@@ -0,0 +1,25 @@
1
+ import { Pagination } from './components/Table/Pagination';
2
+ import { SortIndicator } from './components/Table/SortIndicator';
3
+ import { ColumnFilter } from './components/Table/ColumnFilter';
4
+ import { SortChip } from './components/Table/SortChip';
5
+ import { FromTanstack } from './components/Table/FromTanstack';
6
+ /** The full table: the presentational parts plus the TanStack integration. */
7
+ export declare const Table: {
8
+ Pagination: typeof Pagination;
9
+ SortIndicator: typeof SortIndicator;
10
+ ColumnFilter: typeof ColumnFilter;
11
+ SortChip: typeof SortChip;
12
+ /** Renders a styled Table directly from a TanStack table instance. */
13
+ FromTanstack: typeof FromTanstack;
14
+ Container: typeof import('./components/Table/Table').Container;
15
+ Root: typeof import('./components/Table/Table').Root;
16
+ Header: typeof import('./components/Table/Table').Header;
17
+ Body: typeof import('./components/Table/Table').Body;
18
+ Row: typeof import('./components/Table/Table').Row;
19
+ HeaderCell: typeof import('./components/Table/Table').HeaderCell;
20
+ Cell: typeof import('./components/Table/Table').Cell;
21
+ };
22
+ export { useDataTable } from './components/Table/useDataTable';
23
+ export { VirtualTable, type VirtualTableRange } from './components/VirtualTable/VirtualTable';
24
+ export type { TableVariant, TableSize } from './components/Table/Table';
25
+ //# sourceMappingURL=table.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../src/table.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAMH,OAAO,0CAA0C,CAAA;AAGjD,OAAO,EAAC,UAAU,EAAC,MAAM,+BAA+B,CAAA;AACxD,OAAO,EAAC,aAAa,EAAC,MAAM,kCAAkC,CAAA;AAC9D,OAAO,EAAC,YAAY,EAAC,MAAM,iCAAiC,CAAA;AAC5D,OAAO,EAAC,QAAQ,EAAC,MAAM,6BAA6B,CAAA;AACpD,OAAO,EAAC,YAAY,EAAC,MAAM,iCAAiC,CAAA;AAE5D,8EAA8E;AAC9E,eAAO,MAAM,KAAK;;;;;IAMhB,sEAAsE;;;;;;;;;CAEvE,CAAA;AAED,OAAO,EAAC,YAAY,EAAC,MAAM,iCAAiC,CAAA;AAI5D,OAAO,EAAC,YAAY,EAAE,KAAK,iBAAiB,EAAC,MAAM,wCAAwC,CAAA;AAE3F,YAAY,EAAC,YAAY,EAAE,SAAS,EAAC,MAAM,0BAA0B,CAAA"}
package/dist/table.js ADDED
@@ -0,0 +1,647 @@
1
+ import { c as H, m as p, d as b, M as F, s as gt, R as nt, H as xt, a as kt, B as pt, b as bt, C as mt, e as ft } from "./Table-xlMa_Kqe.js";
2
+ import { jsx as u, jsxs as D } from "react/jsx-runtime";
3
+ import { flexRender as E, useReactTable as rt, getPaginationRowModel as ht, getFilteredRowModel as yt, getSortedRowModel as it, getCoreRowModel as at } from "@tanstack/react-table";
4
+ import { useState as G, useCallback as St, useRef as X, useEffect as _, useLayoutEffect as Tt } from "react";
5
+ import { useVirtualizer as Ct } from "@tanstack/react-virtual";
6
+ const wt = {
7
+ sm: 640
8
+ }, q = {
9
+ root: {
10
+ "display-k1xSpc": "display-x78zum5",
11
+ "alignItems-kGNEyG": "alignItems-x6s0dn4",
12
+ "justifyContent-kjj79g": "justifyContent-xl56j7k",
13
+ "gap-kOIVth": "gap-x175yhtj",
14
+ "paddingTop-kLKAdn": "paddingTop-x5882n6",
15
+ "paddingBottom-kGO01o": "paddingBottom-x1dr83cj",
16
+ $$css: "Table/Pagination.tsx:9"
17
+ },
18
+ button: {
19
+ "display-k1xSpc": "display-x3nfvp2",
20
+ "alignItems-kGNEyG": "alignItems-x6s0dn4",
21
+ "justifyContent-kjj79g": "justifyContent-xl56j7k",
22
+ "paddingTop-kLKAdn": "paddingTop-x1i738hq",
23
+ "paddingBottom-kGO01o": "paddingBottom-x6sojwk",
24
+ "paddingLeft-kE3dHu": "paddingLeft-x6xq64o",
25
+ "paddingRight-kpe85a": "paddingRight-xpkaq21",
26
+ "borderWidth-kMzoRj": "borderWidth-xmkeg23",
27
+ "borderStyle-ksu8eU": "borderStyle-x1y0btm7",
28
+ "borderColor-kVAM5u": "borderColor-x15ykms2",
29
+ "borderRadius-kaIpWk": "borderRadius-x1kogg8i",
30
+ "backgroundColor-kWkggS": "backgroundColor-xjbqb8w backgroundColor-x14zl4n5",
31
+ "color-kMwMTN": "color-x95150z",
32
+ "fontSize-kGuDYH": "fontSize-x1tzajr0",
33
+ "cursor-kkrTdU": "cursor-x1ypdohk",
34
+ "transitionProperty-k1ekBW": "transitionProperty-x15406qy",
35
+ "transitionDuration-kIyJzY": "transitionDuration-xx6bhzk",
36
+ $$css: "Table/Pagination.tsx:17"
37
+ },
38
+ buttonDisabled: {
39
+ "opacity-kSiTet": "opacity-xti2d7y",
40
+ "cursor-kkrTdU": "cursor-x1h6gzvc",
41
+ "backgroundColor-kWkggS": "backgroundColor-xjbqb8w",
42
+ $$css: "Table/Pagination.tsx:39"
43
+ },
44
+ pageInfo: {
45
+ "fontSize-kGuDYH": "fontSize-x1tzajr0",
46
+ "color-kMwMTN": "color-x4opovt",
47
+ $$css: "Table/Pagination.tsx:44"
48
+ }
49
+ };
50
+ function st(o) {
51
+ const t = H.c(33), {
52
+ table: e
53
+ } = o;
54
+ let n;
55
+ t[0] !== e ? (n = e.getState(), t[0] = e, t[1] = n) : n = t[1];
56
+ const {
57
+ pageIndex: l,
58
+ pageSize: r
59
+ } = n.pagination;
60
+ let i;
61
+ t[2] !== e ? (i = e.getPageCount(), t[2] = e, t[3] = i) : i = t[3];
62
+ const s = i;
63
+ if (e.getFilteredRowModel().rows.length <= r)
64
+ return null;
65
+ let k;
66
+ t[4] !== e ? (k = !e.getCanPreviousPage() && q.buttonDisabled, t[4] = e, t[5] = k) : k = t[5];
67
+ let c;
68
+ t[6] !== k ? (c = [q.button, k], t[6] = k, t[7] = c) : c = t[7];
69
+ let x, y;
70
+ t[8] !== e ? (x = () => e.previousPage(), y = e.getCanPreviousPage(), t[8] = e, t[9] = x, t[10] = y) : (x = t[9], y = t[10]);
71
+ const T = !y;
72
+ let m;
73
+ t[11] !== c || t[12] !== x || t[13] !== T ? (m = /* @__PURE__ */ u("button", { "data-element-src": "Table/Pagination.tsx:63", ...p(b.button, c), onClick: x, disabled: T, type: "button", children: "Previous" }), t[11] = c, t[12] = x, t[13] = T, t[14] = m) : m = t[14];
74
+ const f = l + 1;
75
+ let S;
76
+ t[15] !== s || t[16] !== f ? (S = /* @__PURE__ */ D("span", { "data-element-src": "Table/Pagination.tsx:70", ...p(b.span, q.pageInfo), children: [
77
+ f,
78
+ " / ",
79
+ s
80
+ ] }), t[15] = s, t[16] = f, t[17] = S) : S = t[17];
81
+ let h;
82
+ t[18] !== e ? (h = !e.getCanNextPage() && q.buttonDisabled, t[18] = e, t[19] = h) : h = t[19];
83
+ let V;
84
+ t[20] !== h ? (V = [q.button, h], t[20] = h, t[21] = V) : V = t[21];
85
+ let w, M;
86
+ t[22] !== e ? (w = () => e.nextPage(), M = e.getCanNextPage(), t[22] = e, t[23] = w, t[24] = M) : (w = t[23], M = t[24]);
87
+ const $ = !M;
88
+ let a;
89
+ t[25] !== V || t[26] !== w || t[27] !== $ ? (a = /* @__PURE__ */ u("button", { "data-element-src": "Table/Pagination.tsx:73", ...p(b.button, V), onClick: w, disabled: $, type: "button", children: "Next" }), t[25] = V, t[26] = w, t[27] = $, t[28] = a) : a = t[28];
90
+ let R;
91
+ return t[29] !== S || t[30] !== a || t[31] !== m ? (R = /* @__PURE__ */ D("div", { "data-element-src": "Table/Pagination.tsx:62", ...p(b.div, q.root), children: [
92
+ m,
93
+ S,
94
+ a
95
+ ] }), t[29] = S, t[30] = a, t[31] = m, t[32] = R) : R = t[32], R;
96
+ }
97
+ const J = {
98
+ root: {
99
+ "display-k1xSpc": "display-x3nfvp2",
100
+ "alignItems-kGNEyG": "alignItems-x6s0dn4",
101
+ "marginLeft-koQZXg": "marginLeft-x1iog12x",
102
+ "fontSize-kGuDYH": "fontSize-x1k6wstc",
103
+ "userSelect-kfSwDN": "userSelect-x87ps6o",
104
+ "opacity-kSiTet": "opacity-xg01cxk",
105
+ "transitionProperty-k1ekBW": "transitionProperty-x19991ni",
106
+ "transitionDuration-kIyJzY": "transitionDuration-xgdialr",
107
+ $$css: "Table/SortIndicator.tsx:7"
108
+ },
109
+ active: {
110
+ "opacity-kSiTet": "opacity-x1hc1fzr",
111
+ "color-kMwMTN": "color-xf715ks",
112
+ $$css: "Table/SortIndicator.tsx:18"
113
+ },
114
+ inactive: {
115
+ "color-kMwMTN": "color-x4opovt",
116
+ $$css: "Table/SortIndicator.tsx:22"
117
+ }
118
+ };
119
+ function vt(o) {
120
+ const t = H.c(5), {
121
+ column: e
122
+ } = o;
123
+ if (!e.getCanSort())
124
+ return null;
125
+ const n = e.getIsSorted(), l = n ? J.active : J.inactive;
126
+ let r;
127
+ t[0] !== l ? (r = [J.root, l], t[0] = l, t[1] = r) : r = t[1];
128
+ const i = n === "asc" ? "▲" : n === "desc" ? "▼" : "⇅";
129
+ let s;
130
+ return t[2] !== r || t[3] !== i ? (s = /* @__PURE__ */ u("span", { "data-element-src": "Table/SortIndicator.tsx:46", ...p(b.span, r), "data-sort-indicator": "", children: i }), t[2] = r, t[3] = i, t[4] = s) : s = t[4], s;
131
+ }
132
+ const Vt = {
133
+ input: {
134
+ "width-kzqmXN": "width-xh8yej3",
135
+ "paddingTop-kLKAdn": "paddingTop-x1nn3v0j",
136
+ "paddingBottom-kGO01o": "paddingBottom-x1120s5i",
137
+ "paddingLeft-kE3dHu": "paddingLeft-xzmizx3",
138
+ "paddingRight-kpe85a": "paddingRight-x7ulw7g",
139
+ "marginTop-keoZOQ": "marginTop-xuerg7n",
140
+ "borderWidth-kMzoRj": "borderWidth-xmkeg23",
141
+ "borderStyle-ksu8eU": "borderStyle-x1y0btm7",
142
+ "borderColor-kVAM5u": "borderColor-x15ykms2",
143
+ "borderRadius-kaIpWk": "borderRadius-xwi0hqr",
144
+ "backgroundColor-kWkggS": "backgroundColor-xr5vhjl",
145
+ "color-kMwMTN": "color-x95150z",
146
+ "fontSize-kGuDYH": "fontSize-x1f81oxx",
147
+ "outline-kI3sdo": "outline-x1a2a7pz",
148
+ $$css: "Table/ColumnFilter.tsx:9"
149
+ }
150
+ };
151
+ function $t(o) {
152
+ const t = H.c(8), {
153
+ column: e,
154
+ placeholder: n
155
+ } = o;
156
+ if (!e.getCanFilter())
157
+ return null;
158
+ let l;
159
+ t[0] !== e ? (l = e.getFilterValue() ?? "", t[0] = e, t[1] = l) : l = t[1];
160
+ const r = l;
161
+ let i;
162
+ t[2] !== e ? (i = (k) => e.setFilterValue(k.target.value || void 0), t[2] = e, t[3] = i) : i = t[3];
163
+ const s = n ?? "Filter...";
164
+ let C;
165
+ return t[4] !== r || t[5] !== i || t[6] !== s ? (C = /* @__PURE__ */ u("input", { "data-element-src": "Table/ColumnFilter.tsx:38", ...p(b.input, Vt.input), type: "text", value: r, onChange: i, placeholder: s, dir: "auto" }), t[4] = r, t[5] = i, t[6] = s, t[7] = C) : C = t[7], C;
166
+ }
167
+ function Z(o) {
168
+ const t = H.c(21), {
169
+ options: e,
170
+ value: n,
171
+ onChange: l,
172
+ label: r
173
+ } = o, i = r === void 0 ? "Sort by" : r;
174
+ let s;
175
+ t[0] !== e || t[1] !== n ? (s = n ? e.find((f) => f.id === n.id) : null, t[0] = e, t[1] = n, t[2] = s) : s = t[2];
176
+ const C = s, k = C ? `${i}: ${C.label} ${n.desc ? "↓" : "↑"}` : i;
177
+ let c;
178
+ t[3] !== k ? (c = /* @__PURE__ */ u(F.Trigger, { children: k }), t[3] = k, t[4] = c) : c = t[4];
179
+ let x;
180
+ if (t[5] !== l || t[6] !== e || t[7] !== n) {
181
+ let f;
182
+ t[9] !== l || t[10] !== n ? (f = (S) => {
183
+ const h = n?.id === S.id, V = h ? !n.desc : !1;
184
+ return /* @__PURE__ */ D(F.Item, { onClick: () => l({
185
+ id: S.id,
186
+ desc: V
187
+ }), children: [
188
+ S.label,
189
+ h ? ` ${n.desc ? "↓" : "↑"}` : ""
190
+ ] }, S.id);
191
+ }, t[9] = l, t[10] = n, t[11] = f) : f = t[11], x = e.map(f), t[5] = l, t[6] = e, t[7] = n, t[8] = x;
192
+ } else
193
+ x = t[8];
194
+ let y;
195
+ t[12] !== l || t[13] !== n ? (y = n !== null && /* @__PURE__ */ u(F.Item, { onClick: () => l(null), children: "Clear sort" }), t[12] = l, t[13] = n, t[14] = y) : y = t[14];
196
+ let T;
197
+ t[15] !== x || t[16] !== y ? (T = /* @__PURE__ */ D(F.Popup, { children: [
198
+ x,
199
+ y
200
+ ] }), t[15] = x, t[16] = y, t[17] = T) : T = t[17];
201
+ let m;
202
+ return t[18] !== c || t[19] !== T ? (m = /* @__PURE__ */ u("div", { "data-element-src": "Table/SortChip.tsx:32", ...p(b.div, gt.sortChip), children: /* @__PURE__ */ D(F.Root, { children: [
203
+ c,
204
+ T
205
+ ] }) }), t[18] = c, t[19] = T, t[20] = m) : m = t[20], m;
206
+ }
207
+ Z.displayName = "SortChip";
208
+ function dt(o) {
209
+ const t = H.c(30), {
210
+ table: e,
211
+ variant: n,
212
+ size: l,
213
+ responsive: r,
214
+ minColumnWidth: i,
215
+ sortChip: s,
216
+ pagination: C,
217
+ rowKey: k,
218
+ onRowClick: c,
219
+ rowAriaLabel: x
220
+ } = o, y = n === void 0 ? "default" : n, T = l === void 0 ? "md" : l, m = r === void 0 ? !0 : r;
221
+ let f;
222
+ t[0] !== s || t[1] !== e ? (f = s ? It(e) : void 0, t[0] = s, t[1] = e, t[2] = f) : f = t[2];
223
+ const S = f;
224
+ let h;
225
+ t[3] !== C || t[4] !== e ? (h = C ? /* @__PURE__ */ u(st, { table: e }) : void 0, t[3] = C, t[4] = e, t[5] = h) : h = t[5];
226
+ const V = h;
227
+ let w;
228
+ t[6] !== e ? (w = e.getHeaderGroups().map(Mt), t[6] = e, t[7] = w) : w = t[7];
229
+ let M;
230
+ t[8] !== w ? (M = /* @__PURE__ */ u(kt, { children: w }), t[8] = w, t[9] = M) : M = t[9];
231
+ let $;
232
+ if (t[10] !== c || t[11] !== x || t[12] !== k || t[13] !== e) {
233
+ let j;
234
+ t[15] !== c || t[16] !== x || t[17] !== k ? (j = (P) => {
235
+ const W = k?.(P) ?? P.id;
236
+ return /* @__PURE__ */ u(nt, { onClick: c ? () => c(P) : void 0, "aria-label": x?.(P), children: P.getVisibleCells().map(zt) }, W);
237
+ }, t[15] = c, t[16] = x, t[17] = k, t[18] = j) : j = t[18], $ = e.getRowModel().rows.map(j), t[10] = c, t[11] = x, t[12] = k, t[13] = e, t[14] = $;
238
+ } else
239
+ $ = t[14];
240
+ let a;
241
+ t[19] !== $ ? (a = /* @__PURE__ */ u(pt, { children: $ }), t[19] = $, t[20] = a) : a = t[20];
242
+ let R;
243
+ return t[21] !== i || t[22] !== V || t[23] !== m || t[24] !== T || t[25] !== S || t[26] !== M || t[27] !== a || t[28] !== y ? (R = /* @__PURE__ */ D(bt, { variant: y, size: T, responsive: m, minColumnWidth: i, sortChip: S, pagination: V, children: [
244
+ M,
245
+ a
246
+ ] }), t[21] = i, t[22] = V, t[23] = m, t[24] = T, t[25] = S, t[26] = M, t[27] = a, t[28] = y, t[29] = R) : R = t[29], R;
247
+ }
248
+ function zt(o) {
249
+ return /* @__PURE__ */ u(mt, { isActions: o.column.columnDef.meta?.isActions === !0, children: E(o.column.columnDef.cell, o.getContext()) }, o.id);
250
+ }
251
+ function Mt(o) {
252
+ return /* @__PURE__ */ u(nt, { children: o.headers.map(Rt) }, o.id);
253
+ }
254
+ function Rt(o) {
255
+ const t = o.column.columnDef, e = t.meta, n = typeof t.header == "string" ? t.header : void 0, l = e?.stackLabel ?? n ?? "";
256
+ return /* @__PURE__ */ u(xt, { label: l, "aria-label": e?.isActions ? l || "Actions" : void 0, children: o.isPlaceholder ? null : E(t.header, o.getContext()) }, o.id);
257
+ }
258
+ dt.displayName = "FromTanstack";
259
+ function It(o) {
260
+ const t = o.getAllColumns().filter((l) => l.getCanSort()).map((l) => {
261
+ const r = typeof l.columnDef.header == "string" ? l.columnDef.header : l.id;
262
+ return {
263
+ id: l.id,
264
+ label: l.columnDef.meta?.stackLabel ?? r
265
+ };
266
+ });
267
+ if (t.length === 0) return null;
268
+ const e = o.getState().sorting[0], n = e ? {
269
+ id: e.id,
270
+ desc: e.desc
271
+ } : null;
272
+ return /* @__PURE__ */ u(Z, { options: t, value: n, onChange: (l) => o.setSorting(l ? [{
273
+ id: l.id,
274
+ desc: l.desc
275
+ }] : []) });
276
+ }
277
+ function Ft(o, t, e = {}) {
278
+ const {
279
+ enableSorting: n = !1,
280
+ enableFiltering: l = !1,
281
+ enableRowSelection: r = !1,
282
+ onRowSelectionChange: i
283
+ } = e, s = e.pagination != null, [C, k] = G([]), [c, x] = G([]), [y, T] = G({
284
+ pageIndex: e.pagination?.pageIndex ?? 0,
285
+ pageSize: e.pagination?.pageSize ?? 10
286
+ }), [m, f] = G({}), S = St((h) => {
287
+ f((V) => {
288
+ const w = typeof h == "function" ? h(V) : h;
289
+ return i?.(w), w;
290
+ });
291
+ }, [i]);
292
+ return rt({
293
+ data: o,
294
+ columns: t,
295
+ state: {
296
+ sorting: C,
297
+ columnFilters: c,
298
+ pagination: y,
299
+ rowSelection: m
300
+ },
301
+ getCoreRowModel: at(),
302
+ getSortedRowModel: it(),
303
+ getFilteredRowModel: yt(),
304
+ getPaginationRowModel: ht(),
305
+ onSortingChange: k,
306
+ onColumnFiltersChange: x,
307
+ onPaginationChange: T,
308
+ enableSorting: n,
309
+ enableRowSelection: typeof r == "function" ? r : !!r,
310
+ onRowSelectionChange: S,
311
+ // When pagination is disabled, set a very large page size to show all rows
312
+ ...!s && {
313
+ autoResetPageIndex: !1
314
+ }
315
+ });
316
+ }
317
+ const jt = {
318
+ "overflowY-kORKVm": "overflowY-x1odjw0f",
319
+ "overscrollBehavior-kZeWKH": "overscrollBehavior-xish69e",
320
+ $$css: "VirtualTable/styles.css.ts:21"
321
+ }, Wt = {
322
+ "position-kVAEAm": "position-x1n2onr6",
323
+ "width-kzqmXN": "width-xh8yej3",
324
+ $$css: "VirtualTable/styles.css.ts:64"
325
+ }, Bt = {
326
+ "position-kVAEAm": "position-x10l6tqk",
327
+ "top-k87sOh": "top-x13vifvy",
328
+ "left-kbCHJM": "left-xu96u03",
329
+ "transform-k3aq6I": "transform-xsqj5wx",
330
+ $$css: "VirtualTable/styles.css.ts:83"
331
+ }, Dt = {
332
+ "flexShrink-kmuXW": "flexShrink-xs83m0k",
333
+ "flexBasis-kCS8Yb": "flexBasis-x1r8uery",
334
+ "minWidth-k7Eaqz": "minWidth-xeuugli",
335
+ $$css: "VirtualTable/styles.css.ts:102"
336
+ }, g = {
337
+ wrap: {
338
+ "position-kVAEAm": "position-x1n2onr6",
339
+ "width-kzqmXN": "width-xh8yej3",
340
+ $$css: "VirtualTable/styles.css.ts:7"
341
+ },
342
+ scroll: {
343
+ "position-kVAEAm": "position-x1n2onr6",
344
+ "width-kzqmXN": "width-xh8yej3",
345
+ "borderWidth-kMzoRj": "borderWidth-xmkeg23",
346
+ "borderStyle-ksu8eU": "borderStyle-x1y0btm7",
347
+ "borderColor-kVAM5u": "borderColor-x15ykms2",
348
+ "borderRadius-kaIpWk": "borderRadius-xwbokb3",
349
+ "backgroundColor-kWkggS": "backgroundColor-xuw63hu",
350
+ $$css: "VirtualTable/styles.css.ts:11"
351
+ },
352
+ scrollMax: (o) => [jt, {
353
+ "maxHeight-kskxy": o != null ? "maxHeight-x1jols5v" : o,
354
+ $$css: "VirtualTable/styles.css.ts:21"
355
+ }, {
356
+ "--x-maxHeight": ((t) => typeof t == "number" ? t + "px" : t ?? void 0)(o)
357
+ }],
358
+ head: {
359
+ "position-kVAEAm": "position-x7wzq59",
360
+ "top-k87sOh": "top-x13vifvy",
361
+ "zIndex-kY2c9j": "zIndex-x1vjfegm",
362
+ "backgroundColor-kWkggS": "backgroundColor-xuw63hu",
363
+ $$css: "VirtualTable/styles.css.ts:26"
364
+ },
365
+ headRow: {
366
+ "display-k1xSpc": "display-x78zum5",
367
+ "flexDirection-kXwgrk": "flexDirection-x1q0g3np",
368
+ "borderBottomWidth-kt9PQ7": "borderBottomWidth-xso031l",
369
+ "borderBottomStyle-kfdmCh": "borderBottomStyle-x1q0q8m5",
370
+ "borderBottomColor-kL6WhQ": "borderBottomColor-x19cyuh1",
371
+ $$css: "VirtualTable/styles.css.ts:32"
372
+ },
373
+ headCell: {
374
+ "display-k1xSpc": "display-x78zum5",
375
+ "flexDirection-kXwgrk": "flexDirection-x1q0g3np",
376
+ "alignItems-kGNEyG": "alignItems-x6s0dn4",
377
+ "gap-kOIVth": "gap-xl5ne8a",
378
+ "paddingTop-kLKAdn": "paddingTop-xc2wovk",
379
+ "paddingBottom-kGO01o": "paddingBottom-x1dr83cj",
380
+ "paddingLeft-kE3dHu": "paddingLeft-x2rk66v",
381
+ "paddingRight-kpe85a": "paddingRight-x7huf2v",
382
+ "fontFamily-kMv6JI": "fontFamily-xce2pww",
383
+ "fontSize-kGuDYH": "fontSize-x1f81oxx",
384
+ "fontWeight-k63SB2": "fontWeight-x1x12jc5",
385
+ "textTransform-kP9fke": "textTransform-xtvhhri",
386
+ "letterSpacing-kb6lSQ": "letterSpacing-x3gc2hl",
387
+ "color-kMwMTN": "color-x4opovt",
388
+ $$css: "VirtualTable/styles.css.ts:39"
389
+ },
390
+ headCellSortable: {
391
+ "cursor-kkrTdU": "cursor-x1ypdohk",
392
+ "userSelect-kfSwDN": "userSelect-x87ps6o",
393
+ "color-kMwMTN": "color-x4opovt color-xtolcfe",
394
+ $$css: "VirtualTable/styles.css.ts:55"
395
+ },
396
+ sortMark: {
397
+ "fontSize-kGuDYH": "fontSize-x1f81oxx",
398
+ "color-kMwMTN": "color-xf715ks",
399
+ $$css: "VirtualTable/styles.css.ts:60"
400
+ },
401
+ bodyTotal: (o) => [Wt, {
402
+ "height-kZKoxP": o != null ? "height-x16ye13r" : o,
403
+ $$css: "VirtualTable/styles.css.ts:64"
404
+ }, {
405
+ "--x-height": ((t) => typeof t == "number" ? t + "px" : t ?? void 0)(o)
406
+ }],
407
+ row: {
408
+ "display-k1xSpc": "display-x78zum5",
409
+ "flexDirection-kXwgrk": "flexDirection-x1q0g3np",
410
+ "alignItems-kGNEyG": "alignItems-x6s0dn4",
411
+ "width-kzqmXN": "width-xh8yej3",
412
+ "borderBottomWidth-kt9PQ7": "borderBottomWidth-xso031l",
413
+ "borderBottomStyle-kfdmCh": "borderBottomStyle-x1q0q8m5",
414
+ "borderBottomColor-kL6WhQ": "borderBottomColor-x19cyuh1",
415
+ $$css: "VirtualTable/styles.css.ts:69"
416
+ },
417
+ rowClickable: {
418
+ "cursor-kkrTdU": "cursor-x1ypdohk",
419
+ "backgroundColor-kWkggS": "backgroundColor-xjbqb8w backgroundColor-x14zl4n5",
420
+ $$css: "VirtualTable/styles.css.ts:78"
421
+ },
422
+ rowAbsolute: (o) => [Bt, {
423
+ "--x-transform": `translateY(${o}px)` != null ? `translateY(${o}px)` : void 0
424
+ }],
425
+ cell: {
426
+ "paddingTop-kLKAdn": "paddingTop-xc2wovk",
427
+ "paddingBottom-kGO01o": "paddingBottom-x1dr83cj",
428
+ "paddingLeft-kE3dHu": "paddingLeft-x2rk66v",
429
+ "paddingRight-kpe85a": "paddingRight-x7huf2v",
430
+ "fontFamily-kMv6JI": "fontFamily-xce2pww",
431
+ "fontSize-kGuDYH": "fontSize-x1tzajr0",
432
+ "color-kMwMTN": "color-x95150z",
433
+ "overflow-kVQacm": "overflow-xb3r6kr",
434
+ "textOverflow-kg5iWk": "textOverflow-xlyipyv",
435
+ "whiteSpace-khDVqt": "whiteSpace-xuxw1ft",
436
+ $$css: "VirtualTable/styles.css.ts:89"
437
+ },
438
+ cellFlex: (o) => [Dt, {
439
+ "flexGrow-kzQI83": o != null ? "flexGrow-xw36f2b" : o,
440
+ $$css: "VirtualTable/styles.css.ts:102"
441
+ }, {
442
+ "--x-flexGrow": o ?? void 0
443
+ }],
444
+ stackScroll: {
445
+ "position-kVAEAm": "position-x1n2onr6",
446
+ "width-kzqmXN": "width-xh8yej3",
447
+ "backgroundColor-kWkggS": "backgroundColor-xjbqb8w",
448
+ $$css: "VirtualTable/styles.css.ts:111"
449
+ },
450
+ stackBody: {
451
+ "display-k1xSpc": "display-x78zum5",
452
+ "flexDirection-kXwgrk": "flexDirection-xdt5ytf",
453
+ "gap-kOIVth": "gap-x175yhtj",
454
+ $$css: "VirtualTable/styles.css.ts:116"
455
+ },
456
+ stackRow: {
457
+ "display-k1xSpc": "display-x78zum5",
458
+ "flexDirection-kXwgrk": "flexDirection-xdt5ytf",
459
+ "gap-kOIVth": "gap-xl5ne8a",
460
+ "width-kzqmXN": "width-xh8yej3",
461
+ "padding-kmVPX3": "padding-xlm5w08",
462
+ "borderWidth-kMzoRj": "borderWidth-xmkeg23",
463
+ "borderStyle-ksu8eU": "borderStyle-x1y0btm7",
464
+ "borderColor-kVAM5u": "borderColor-x15ykms2",
465
+ "borderRadius-kaIpWk": "borderRadius-x17rit4p",
466
+ "backgroundColor-kWkggS": "backgroundColor-xuw63hu",
467
+ $$css: "VirtualTable/styles.css.ts:121"
468
+ },
469
+ stackCell: {
470
+ "display-k1xSpc": "display-xrvj5dj",
471
+ "gridTemplateColumns-kumcoG": "gridTemplateColumns-xl463y0",
472
+ "gap-kOIVth": "gap-x175yhtj",
473
+ "alignItems-kGNEyG": "alignItems-x6s0dn4",
474
+ "fontFamily-kMv6JI": "fontFamily-xce2pww",
475
+ "fontSize-kGuDYH": "fontSize-x1tzajr0",
476
+ "color-kMwMTN": "color-x95150z",
477
+ $$css: "VirtualTable/styles.css.ts:133"
478
+ },
479
+ stackCellLabel: {
480
+ "color-kMwMTN": "color-x4opovt",
481
+ "fontWeight-k63SB2": "fontWeight-x120ksxs",
482
+ "fontSize-kGuDYH": "fontSize-x1f81oxx",
483
+ $$css: "VirtualTable/styles.css.ts:142"
484
+ },
485
+ stackCellValue: {
486
+ "minWidth-k7Eaqz": "minWidth-xeuugli",
487
+ "overflowWrap-kHjlTd": "overflowWrap-x1mzt3pk",
488
+ $$css: "VirtualTable/styles.css.ts:147"
489
+ },
490
+ empty: {
491
+ "paddingTop-kLKAdn": "paddingTop-x1v4wg84",
492
+ "paddingBottom-kGO01o": "paddingBottom-x8ouyoa",
493
+ "textAlign-k9WMMc": "textAlign-x2b8uid",
494
+ "color-kMwMTN": "color-x4opovt",
495
+ "fontFamily-kMv6JI": "fontFamily-xce2pww",
496
+ "fontSize-kGuDYH": "fontSize-x1tzajr0",
497
+ $$css: "VirtualTable/styles.css.ts:151"
498
+ },
499
+ pos: {
500
+ "position-kVAEAm": "position-x10l6tqk",
501
+ "right-kCIrl2": "right-x192tdk8",
502
+ "bottom-krVfgx": "bottom-x85g1lr",
503
+ "paddingTop-kLKAdn": "paddingTop-xyqdw3p",
504
+ "paddingBottom-kGO01o": "paddingBottom-xg8j3zb",
505
+ "paddingLeft-kE3dHu": "paddingLeft-x6xq64o",
506
+ "paddingRight-kpe85a": "paddingRight-xpkaq21",
507
+ "borderRadius-kaIpWk": "borderRadius-x1k4pcc6",
508
+ "backgroundColor-kWkggS": "backgroundColor-xlyqa1p",
509
+ "borderWidth-kMzoRj": "borderWidth-xmkeg23",
510
+ "borderStyle-ksu8eU": "borderStyle-x1y0btm7",
511
+ "borderColor-kVAM5u": "borderColor-x15ykms2",
512
+ "color-kMwMTN": "color-x4opovt",
513
+ "fontFamily-kMv6JI": "fontFamily-xce2pww",
514
+ "fontSize-kGuDYH": "fontSize-x1f81oxx",
515
+ "pointerEvents-kfzvcC": "pointerEvents-x47corl",
516
+ $$css: "VirtualTable/styles.css.ts:160"
517
+ }
518
+ }, Pt = typeof window < "u" ? Tt : _;
519
+ function Et({
520
+ data: o,
521
+ columns: t,
522
+ sorting: e,
523
+ onSortingChange: n,
524
+ getRowId: l,
525
+ onRowClick: r,
526
+ rowLabel: i,
527
+ initialPage: s,
528
+ onVisiblePageChange: C,
529
+ rangeLabel: k,
530
+ pageSize: c = 50,
531
+ estimateRowHeight: x = 44,
532
+ maxHeight: y = "70vh",
533
+ virtualizeThreshold: T = 150,
534
+ stackBelow: m = wt.sm,
535
+ responsive: f = !0,
536
+ emptyLabel: S
537
+ }) {
538
+ const [h, V] = G([]), $ = rt({
539
+ data: o,
540
+ columns: t,
541
+ state: {
542
+ sorting: e ?? h
543
+ },
544
+ onSortingChange: n ?? V,
545
+ getRowId: l,
546
+ getCoreRowModel: at(),
547
+ getSortedRowModel: it()
548
+ }), a = $.getRowModel().rows, R = X(null), [j, P] = G(!1);
549
+ Pt(() => {
550
+ if (!f) {
551
+ P(!1);
552
+ return;
553
+ }
554
+ const d = R.current;
555
+ if (!d || typeof ResizeObserver > "u") return;
556
+ const v = (I) => {
557
+ I > 0 && P(I < m);
558
+ };
559
+ v(d.getBoundingClientRect().width);
560
+ const B = new ResizeObserver((I) => {
561
+ const z = I[0];
562
+ if (!z) return;
563
+ const L = z.contentBoxSize?.[0];
564
+ v(L ? L.inlineSize : z.contentRect.width);
565
+ });
566
+ return B.observe(d), () => B.disconnect();
567
+ }, [f, m]);
568
+ const W = a.length > T && !j, tt = X(null), O = Ct({
569
+ count: a.length,
570
+ getScrollElement: () => tt.current,
571
+ estimateSize: () => x,
572
+ overscan: 12
573
+ }), K = X(!0);
574
+ _(() => {
575
+ if (!W) {
576
+ K.current = !1;
577
+ return;
578
+ }
579
+ s && s > 1 && O.scrollToIndex((s - 1) * c, {
580
+ align: "start"
581
+ });
582
+ const d = setTimeout(() => {
583
+ K.current = !1;
584
+ }, 300);
585
+ return () => clearTimeout(d);
586
+ }, [W]);
587
+ const N = O.getVirtualItems(), Q = N[0]?.index ?? 0, et = N.length ? N[N.length - 1].index : 0, ot = Math.max(1, Math.ceil(a.length / c)), A = Math.floor(Math.max(0, Q) / c) + 1, Y = {
588
+ from: a.length ? Q + 1 : 0,
589
+ to: a.length ? et + 1 : 0,
590
+ total: a.length,
591
+ page: A,
592
+ pages: ot
593
+ }, U = X(null);
594
+ _(() => {
595
+ if (!(!W || !C)) {
596
+ if (K.current) {
597
+ U.current = A;
598
+ return;
599
+ }
600
+ U.current !== A && (U.current = A, C({
601
+ from: a.length ? Q + 1 : 0,
602
+ to: a.length ? et + 1 : 0,
603
+ total: a.length,
604
+ page: A,
605
+ pages: ot
606
+ }));
607
+ }
608
+ }, [A, W]);
609
+ const ct = (d) => {
610
+ const v = d.meta;
611
+ return typeof v?.stackLabel == "string" ? v.stackLabel : typeof v?.label == "string" ? v.label : typeof d.header == "string" ? d.header : "";
612
+ }, lt = (d, v, B, I) => j ? /* @__PURE__ */ u("div", { "data-element-src": "VirtualTable/VirtualTable.tsx:240", role: "row", "aria-label": i?.(d.original), onClick: r ? () => r(d.original) : void 0, ...p(b.div, g.stackRow, !!r && g.rowClickable), children: d.getVisibleCells().map((z) => {
613
+ const L = ct(z.column.columnDef);
614
+ return /* @__PURE__ */ D("div", { "data-element-src": "VirtualTable/VirtualTable.tsx:250", role: "cell", ...p(b.div, g.stackCell), children: [
615
+ L ? /* @__PURE__ */ u("span", { "data-element-src": "VirtualTable/VirtualTable.tsx:251", ...p(b.span, g.stackCellLabel), children: L }) : null,
616
+ /* @__PURE__ */ u("div", { "data-element-src": "VirtualTable/VirtualTable.tsx:252", ...p(b.div, g.stackCellValue), children: E(z.column.columnDef.cell, z.getContext()) })
617
+ ] }, z.id);
618
+ }) }, d.id) : /* @__PURE__ */ u("div", { "data-element-src": "VirtualTable/VirtualTable.tsx:260", ref: I, "data-index": v, role: "row", "aria-label": i?.(d.original), onClick: r ? () => r(d.original) : void 0, ...p(b.div, g.row, !!r && g.rowClickable, B), children: d.getVisibleCells().map((z) => /* @__PURE__ */ u("div", { "data-element-src": "VirtualTable/VirtualTable.tsx:270", role: "cell", ...p(b.div, g.cell, g.cellFlex(z.column.getSize())), children: E(z.column.columnDef.cell, z.getContext()) }, z.id)) }, d.id), ut = k?.(Y) ?? (a.length ? `${Y.from}–${Y.to} / ${Y.total}` : "");
619
+ return /* @__PURE__ */ D("div", { "data-element-src": "VirtualTable/VirtualTable.tsx:285", ref: R, ...p(b.div, g.wrap), children: [
620
+ /* @__PURE__ */ D("div", { "data-element-src": "VirtualTable/VirtualTable.tsx:286", ref: tt, role: "table", ...p(b.div, j ? g.stackScroll : g.scroll, W && g.scrollMax(y)), children: [
621
+ j ? null : /* @__PURE__ */ u("div", { "data-element-src": "VirtualTable/VirtualTable.tsx:295", role: "rowgroup", ...p(b.div, g.head), children: $.getHeaderGroups().map((d) => /* @__PURE__ */ u("div", { "data-element-src": "VirtualTable/VirtualTable.tsx:297", role: "row", ...p(b.div, g.headRow), children: d.headers.map((v) => {
622
+ const B = v.column, I = B.getIsSorted();
623
+ return /* @__PURE__ */ D("div", { "data-element-src": "VirtualTable/VirtualTable.tsx:302", role: "columnheader", "aria-sort": I === "asc" ? "ascending" : I === "desc" ? "descending" : void 0, onClick: B.getCanSort() ? B.getToggleSortingHandler() : void 0, ...p(b.div, g.headCell, B.getCanSort() && g.headCellSortable, g.cellFlex(v.getSize())), children: [
624
+ v.isPlaceholder ? null : E(B.columnDef.header, v.getContext()),
625
+ I ? /* @__PURE__ */ u("span", { "data-element-src": "VirtualTable/VirtualTable.tsx:323", ...p(b.span, g.sortMark), children: I === "asc" ? "↑" : "↓" }) : null
626
+ ] }, v.id);
627
+ }) }, d.id)) }),
628
+ a.length === 0 ? /* @__PURE__ */ u("div", { "data-element-src": "VirtualTable/VirtualTable.tsx:336", ...p(b.div, g.empty), children: S }) : /* @__PURE__ */ u("div", { "data-element-src": "VirtualTable/VirtualTable.tsx:338", role: "rowgroup", ...p(b.div, j ? g.stackBody : W ? g.bodyTotal(O.getTotalSize()) : void 0), children: W ? N.map((d) => lt(a[d.index], d.index, g.rowAbsolute(d.start), O.measureElement)) : a.map((d, v) => lt(d, v)) })
629
+ ] }),
630
+ W && a.length > 0 ? /* @__PURE__ */ u("div", { "data-element-src": "VirtualTable/VirtualTable.tsx:363", "aria-live": "polite", ...p(b.div, g.pos), children: ut }) : null
631
+ ] });
632
+ }
633
+ const Ht = {
634
+ ...ft,
635
+ Pagination: st,
636
+ SortIndicator: vt,
637
+ ColumnFilter: $t,
638
+ SortChip: Z,
639
+ /** Renders a styled Table directly from a TanStack table instance. */
640
+ FromTanstack: dt
641
+ };
642
+ export {
643
+ Ht as Table,
644
+ Et as VirtualTable,
645
+ Ft as useDataTable
646
+ };
647
+ //# sourceMappingURL=table.js.map