@brightlocal/ui-components 2.2.0 → 2.3.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.
@@ -1,319 +1,328 @@
1
- import { jsx as a, jsxs as w, Fragment as qe } from "react/jsx-runtime";
2
- import * as r from "react";
3
- import { useReactTable as _e, getFacetedMinMaxValues as We, getFacetedUniqueValues as Je, getFacetedRowModel as Ke, getExpandedRowModel as Q, getGroupedRowModel as Qe, getFilteredRowModel as X, getSortedRowModel as Xe, getPaginationRowModel as Ye, getCoreRowModel as Ze, flexRender as k } from "@tanstack/react-table";
4
- import { createColumnHelper as qt, flexRender as _t } from "@tanstack/react-table";
5
- import { ArrowDown as et, ArrowUp as tt, ArrowUpDown as at, Ellipsis as nt, Search as lt } from "@brightlocal/icons";
6
- import { cn as b } from "@brightlocal/ui-components/lib/utils";
7
- import { Button as Y } from "../button.js";
8
- import { Checkbox as Z } from "../checkbox.js";
9
- import { InputGroup as ot, InputGroupInput as it, InputGroupAddon as st } from "../input-group.js";
10
- import { Skeleton as rt } from "../skeleton.js";
11
- import { DropdownMenu as ct, DropdownMenuTrigger as dt, DropdownMenuContent as gt } from "../dropdown-menu.js";
12
- import { Table as ut, TableHeader as mt, TableRow as C, TableHead as ft, TableBody as ht, TableCell as x } from "../table.js";
13
- import { usePagination as pt, Pagination as bt, PaginationContent as wt, PaginationItem as R, PaginationPrevious as Ct, PaginationNext as St, PaginationEllipsis as xt, PaginationLink as kt } from "../pagination.js";
14
- function Rt({
15
- columns: n,
16
- data: l,
17
- dataHook: o,
18
- trackingEl: i,
19
- trackingLabel: s,
20
- enableRowSelection: g = !1,
21
- enableSorting: c = !0,
22
- enableFiltering: d = !1,
23
- enableGlobalFiltering: h = !1,
24
- enablePagination: p = !1,
25
- enableColumnPinning: S = !1,
26
- enableRowPinning: u = !1,
27
- enableColumnOrdering: y = !1,
28
- enableGrouping: f = !1,
29
- enableExpanding: T = !1,
30
- enableFaceting: ae = !1,
31
- pageSize: q = 10,
32
- noResultsMessage: ne = "No results.",
33
- isLoading: le = !1,
34
- skeletonRowCount: oe,
35
- getSubRows: ie,
36
- sorting: se,
37
- onSortingChange: P,
38
- columnFilters: re,
39
- onColumnFiltersChange: D,
40
- globalFilter: ce,
41
- onGlobalFilterChange: M,
42
- rowSelection: de,
43
- onRowSelectionChange: N,
44
- columnOrder: ge,
45
- onColumnOrderChange: F,
46
- columnPinning: ue,
47
- onColumnPinningChange: I,
48
- rowPinning: me,
49
- onRowPinningChange: V,
50
- grouping: fe,
51
- onGroupingChange: v,
52
- expanded: he,
53
- onExpandedChange: $,
54
- className: pe,
55
- renderToolbar: _,
56
- renderFooter: W,
57
- renderPagination: J
58
- }, be) {
59
- const [we, Ce] = r.useState(
60
- []
61
- ), [Se, xe] = r.useState([]), [ke, Re] = r.useState(""), [ye, Te] = r.useState({}), [Pe, De] = r.useState([]), [Me, Ne] = r.useState({}), [Fe, Ie] = r.useState({}), [Ve, ve] = r.useState(
62
- []
63
- ), [$e, Ae] = r.useState(
64
- {}
65
- ), A = se ?? we, G = re ?? Se, H = ce ?? ke, j = de ?? ye, z = ge ?? Pe, E = ue ?? Me, L = me ?? Fe, O = fe ?? Ve, U = he ?? $e, Ge = r.useCallback(
66
- (e) => {
67
- const t = typeof e == "function" ? e(A) : e;
68
- P ? P(t) : Ce(t);
69
- },
70
- [A, P]
71
- ), He = r.useCallback(
72
- (e) => {
73
- const t = typeof e == "function" ? e(G) : e;
74
- D ? D(t) : xe(t);
75
- },
76
- [G, D]
77
- ), je = r.useCallback(
78
- (e) => {
79
- const t = typeof e == "function" ? e(H) : e;
80
- M ? M(t) : Re(t);
81
- },
82
- [H, M]
83
- ), ze = r.useCallback(
84
- (e) => {
85
- const t = typeof e == "function" ? e(j) : e;
86
- N ? N(t) : Te(t);
87
- },
88
- [j, N]
89
- ), Ee = r.useCallback(
90
- (e) => {
91
- const t = typeof e == "function" ? e(z) : e;
92
- F ? F(t) : De(t);
93
- },
94
- [z, F]
95
- ), Le = r.useCallback(
96
- (e) => {
97
- const t = typeof e == "function" ? e(E) : e;
98
- I ? I(t) : Ne(t);
99
- },
100
- [E, I]
101
- ), Oe = r.useCallback(
102
- (e) => {
103
- const t = typeof e == "function" ? e(L) : e;
104
- V ? V(t) : Ie(t);
105
- },
106
- [L, V]
107
- ), Ue = r.useCallback(
108
- (e) => {
109
- const t = typeof e == "function" ? e(O) : e;
110
- v ? v(t) : ve(t);
111
- },
112
- [O, v]
113
- ), K = r.useCallback(
114
- (e) => {
115
- const t = typeof e == "function" ? e(U) : e;
116
- $ ? $(t) : Ae(t);
1
+ import { jsx as e, jsxs as S, Fragment as D } from "react/jsx-runtime";
2
+ import * as P from "react";
3
+ import { flexRender as A, useReactTable as ee, getExpandedRowModel as te, getFilteredRowModel as ae, getSortedRowModel as ne, getPaginationRowModel as oe, getCoreRowModel as le } from "@tanstack/react-table";
4
+ import { createColumnHelper as Ye, flexRender as Ze } from "@tanstack/react-table";
5
+ import { useVirtualizer as ie } from "@tanstack/react-virtual";
6
+ import { ArrowDown as re, ArrowUp as se, ArrowUpDown as ce, Ellipsis as de, Search as ge } from "@brightlocal/icons";
7
+ import { cn as f } from "@brightlocal/ui-components/lib/utils";
8
+ import { Button as E } from "../button.js";
9
+ import { Checkbox as H } from "../checkbox.js";
10
+ import { DropdownMenu as ue, DropdownMenuTrigger as me, DropdownMenuContent as pe } from "../dropdown-menu.js";
11
+ import { InputGroup as he, InputGroupInput as fe, InputGroupAddon as be } from "../input-group.js";
12
+ import { usePagination as Se, Pagination as Ce, PaginationContent as we, PaginationItem as $, PaginationPrevious as xe, PaginationNext as ke, PaginationEllipsis as ve, PaginationLink as Re } from "../pagination.js";
13
+ import { Skeleton as Te } from "../skeleton.js";
14
+ import { Table as V, TableHeader as j, TableRow as k, TableHead as G, TableBody as L, TableCell as T } from "../table.js";
15
+ function y(t, a, l) {
16
+ const [n, o] = P.useState(a), r = t !== void 0 ? t : n, i = P.useRef(r);
17
+ P.useEffect(() => {
18
+ i.current = r;
19
+ });
20
+ const c = t !== void 0, d = P.useCallback(
21
+ (h) => {
22
+ const g = typeof h == "function" ? h(i.current) : h;
23
+ c || o(g), l?.(g);
117
24
  },
118
- [U, $]
119
- ), m = _e({
25
+ [c, l]
26
+ );
27
+ return [r, d];
28
+ }
29
+ function Qe(t) {
30
+ const {
31
+ columns: a,
120
32
  data: l,
121
- columns: n,
122
- getCoreRowModel: Ze(),
123
- // Pagination
124
- ...p && {
125
- getPaginationRowModel: Ye(),
126
- initialState: {
127
- pagination: {
128
- pageSize: q
129
- }
33
+ enableSorting: n = !0,
34
+ enableGlobalFiltering: o = !1,
35
+ enableRowSelection: r = !1,
36
+ enablePagination: i = !1,
37
+ pageSize: c = 10,
38
+ manualSorting: d = !1,
39
+ manualFiltering: h = !1,
40
+ manualPagination: g = !1,
41
+ rowCount: C,
42
+ pageCount: u,
43
+ enableExpanding: s = !1,
44
+ getSubRows: w,
45
+ getRowId: b,
46
+ pagination: m,
47
+ onPaginationChange: v,
48
+ sorting: x,
49
+ onSortingChange: F,
50
+ globalFilter: N,
51
+ onGlobalFilterChange: z,
52
+ rowSelection: R,
53
+ onRowSelectionChange: p,
54
+ expanded: I,
55
+ onExpandedChange: M
56
+ } = t, [_, O] = y(
57
+ m,
58
+ { pageIndex: 0, pageSize: c },
59
+ v
60
+ ), [q, J] = y(
61
+ x,
62
+ [],
63
+ F
64
+ ), [K, Q] = y(
65
+ N,
66
+ "",
67
+ z
68
+ ), [W, X] = y(R, {}, p), [Y, Z] = y(
69
+ I,
70
+ {},
71
+ M
72
+ );
73
+ return ee({
74
+ data: l,
75
+ columns: a,
76
+ getCoreRowModel: le(),
77
+ ...b && { getRowId: b },
78
+ ...(i || g) && {
79
+ onPaginationChange: O
80
+ },
81
+ ...i && {
82
+ ...!g && {
83
+ getPaginationRowModel: oe()
130
84
  }
131
85
  },
132
- // Sorting
133
- ...c && {
134
- getSortedRowModel: Xe(),
135
- onSortingChange: Ge
86
+ ...g && {
87
+ manualPagination: !0,
88
+ ...C != null && { rowCount: C },
89
+ ...u != null && { pageCount: u }
136
90
  },
137
- // Column Filtering
138
- ...d && {
139
- getFilteredRowModel: X(),
140
- onColumnFiltersChange: He
91
+ ...n && {
92
+ ...!d && {
93
+ getSortedRowModel: ne()
94
+ },
95
+ onSortingChange: J,
96
+ ...d && { manualSorting: !0 }
141
97
  },
142
- // Global Filtering
143
- ...h && {
144
- getFilteredRowModel: X(),
145
- onGlobalFilterChange: je,
98
+ ...o && {
99
+ ...!h && {
100
+ getFilteredRowModel: ae()
101
+ },
102
+ ...h && { manualFiltering: !0 },
103
+ onGlobalFilterChange: Q,
146
104
  globalFilterFn: "includesString"
147
105
  },
148
- // Row Selection
149
- ...g && {
106
+ ...r && {
150
107
  enableRowSelection: !0,
151
- onRowSelectionChange: ze
152
- },
153
- // Column Ordering
154
- ...y && {
155
- onColumnOrderChange: Ee
156
- },
157
- // Column Pinning
158
- ...S && {
159
- onColumnPinningChange: Le
108
+ onRowSelectionChange: X
160
109
  },
161
- // Row Pinning
162
- ...u && {
163
- enableRowPinning: !0,
164
- onRowPinningChange: Oe,
165
- keepPinnedRows: !0
110
+ ...s && {
111
+ getExpandedRowModel: te(),
112
+ onExpandedChange: Z,
113
+ getSubRows: w
166
114
  },
167
- // Grouping
168
- ...f && {
169
- getGroupedRowModel: Qe(),
170
- getExpandedRowModel: Q(),
171
- onGroupingChange: Ue,
172
- onExpandedChange: K
173
- },
174
- // Expanding
175
- ...T && {
176
- getExpandedRowModel: Q(),
177
- onExpandedChange: K,
178
- getSubRows: ie
179
- },
180
- // Faceting (for filter dropdowns)
181
- ...ae && {
182
- getFacetedRowModel: Ke(),
183
- getFacetedUniqueValues: Je(),
184
- getFacetedMinMaxValues: We()
185
- },
186
- // State
187
115
  state: {
188
- sorting: A,
189
- columnFilters: G,
190
- globalFilter: H,
191
- rowSelection: j,
192
- columnOrder: z,
193
- columnPinning: E,
194
- rowPinning: L,
195
- grouping: O,
196
- expanded: U
116
+ pagination: _,
117
+ sorting: q,
118
+ globalFilter: K,
119
+ rowSelection: W,
120
+ expanded: Y
197
121
  }
198
122
  });
199
- return /* @__PURE__ */ w(
123
+ }
124
+ function ye({
125
+ table: t,
126
+ dataHook: a,
127
+ trackingEl: l,
128
+ trackingLabel: n,
129
+ isLoading: o = !1,
130
+ skeletonRowCount: r,
131
+ noResultsMessage: i = "No results.",
132
+ stickyHeader: c = !1,
133
+ className: d,
134
+ footer: h
135
+ }) {
136
+ const g = t.getVisibleLeafColumns().length, C = r ?? t.getState().pagination.pageSize ?? 10;
137
+ return /* @__PURE__ */ e(
200
138
  "div",
201
139
  {
202
- ref: be,
203
- className: pe,
204
- "data-hook": o,
205
- "data-slot": "data-table",
206
- "data-tracking-el": i,
207
- "data-tracking-label": s,
208
- children: [
209
- _ && _(m),
210
- /* @__PURE__ */ w(ut, { dataHook: `${o}-table`, children: [
211
- /* @__PURE__ */ a(mt, { children: m.getHeaderGroups().map((e) => /* @__PURE__ */ a(C, { children: e.headers.map((t) => /* @__PURE__ */ a(ft, { colSpan: t.colSpan, children: t.isPlaceholder ? null : k(
212
- t.column.columnDef.header,
213
- t.getContext()
214
- ) }, t.id)) }, e.id)) }),
215
- /* @__PURE__ */ a(ht, { children: le ? Array.from({ length: oe ?? q }).map(
216
- (e, t) => /* @__PURE__ */ a(C, { children: m.getVisibleLeafColumns().map((It, Be) => /* @__PURE__ */ a(x, { children: /* @__PURE__ */ a(rt, { className: "h-4 w-full" }) }, `skeleton-${t}-${Be}`)) }, `skeleton-${t}`)
217
- ) : /* @__PURE__ */ w(qe, { children: [
218
- u && m.getTopRows().map((e) => /* @__PURE__ */ a(
219
- C,
220
- {
221
- "data-state": e.getIsSelected() && "selected",
222
- children: e.getVisibleCells().map((t) => /* @__PURE__ */ a(x, { children: k(
223
- t.column.columnDef.cell,
224
- t.getContext()
225
- ) }, t.id))
226
- },
227
- e.id
228
- )),
229
- m.getRowModel().rows?.length ? m.getRowModel().rows.map((e) => /* @__PURE__ */ a(
230
- C,
231
- {
232
- "data-state": e.getIsSelected() && "selected",
233
- children: e.getVisibleCells().map((t) => /* @__PURE__ */ a(x, { children: k(
234
- t.column.columnDef.cell,
235
- t.getContext()
236
- ) }, t.id))
237
- },
238
- e.id
239
- )) : /* @__PURE__ */ a(C, { children: /* @__PURE__ */ a(x, { colSpan: m.getVisibleLeafColumns().length, children: ne }) }),
240
- u && m.getBottomRows().map((e) => /* @__PURE__ */ a(
241
- C,
242
- {
243
- "data-state": e.getIsSelected() && "selected",
244
- children: e.getVisibleCells().map((t) => /* @__PURE__ */ a(x, { children: k(
245
- t.column.columnDef.cell,
246
- t.getContext()
247
- ) }, t.id))
248
- },
249
- e.id
250
- ))
251
- ] }) }),
252
- W && W(m)
253
- ] }),
254
- J && J(m)
255
- ]
140
+ "aria-busy": o || void 0,
141
+ className: f(d),
142
+ "data-hook": a,
143
+ "data-slot": "data-table-view",
144
+ "data-tracking-el": l,
145
+ "data-tracking-label": n,
146
+ children: /* @__PURE__ */ S(V, { dataHook: `${a}-table`, children: [
147
+ /* @__PURE__ */ e(
148
+ j,
149
+ {
150
+ className: f(c && "bg-background sticky top-0 z-10"),
151
+ children: t.getHeaderGroups().map((u) => /* @__PURE__ */ e(k, { children: u.headers.map((s) => {
152
+ const w = s.column.getCanSort() ? s.column.getIsSorted() : !1, b = w === "asc" ? "ascending" : w === "desc" ? "descending" : s.column.getCanSort() ? "none" : void 0;
153
+ return /* @__PURE__ */ e(
154
+ G,
155
+ {
156
+ "aria-sort": b,
157
+ colSpan: s.colSpan,
158
+ children: s.isPlaceholder ? null : A(
159
+ s.column.columnDef.header,
160
+ s.getContext()
161
+ )
162
+ },
163
+ s.id
164
+ );
165
+ }) }, u.id))
166
+ }
167
+ ),
168
+ /* @__PURE__ */ e(L, { children: o ? /* @__PURE__ */ S(D, { children: [
169
+ /* @__PURE__ */ e(
170
+ U,
171
+ {
172
+ colCount: g,
173
+ rowCount: C
174
+ }
175
+ ),
176
+ /* @__PURE__ */ e(k, { className: "sr-only", children: /* @__PURE__ */ e(T, { colSpan: g, children: /* @__PURE__ */ e("div", { "aria-live": "polite", role: "status", children: "Loading data…" }) }) })
177
+ ] }) : /* @__PURE__ */ e(D, { children: t.getRowModel().rows.length > 0 ? t.getRowModel().rows.map((u) => /* @__PURE__ */ e(B, { row: u }, u.id)) : /* @__PURE__ */ e(k, { children: /* @__PURE__ */ e(T, { colSpan: g, children: /* @__PURE__ */ e("div", { "aria-live": "polite", role: "status", children: i }) }) }) }) }),
178
+ h
179
+ ] })
256
180
  }
257
181
  );
258
182
  }
259
- const yt = r.forwardRef(Rt);
260
- yt.displayName = "DataTable";
261
- function Tt({
262
- column: n,
263
- title: l,
264
- className: o,
265
- dataHook: i,
266
- trackingEl: s,
267
- trackingLabel: g,
268
- align: c = "left"
183
+ ye.displayName = "DataTable";
184
+ function B({ row: t }) {
185
+ return /* @__PURE__ */ e(k, { "data-state": t.getIsSelected() ? "selected" : void 0, children: t.getVisibleCells().map((a) => /* @__PURE__ */ e(T, { children: A(a.column.columnDef.cell, a.getContext()) }, a.id)) });
186
+ }
187
+ function U({
188
+ rowCount: t,
189
+ colCount: a
190
+ }) {
191
+ return /* @__PURE__ */ e(D, { children: Array.from({ length: t }).map((l, n) => /* @__PURE__ */ e(k, { children: Array.from({ length: a }).map((o, r) => /* @__PURE__ */ e(T, { children: /* @__PURE__ */ e(Te, { className: "h-4 w-full" }) }, `skeleton-${n}-${r}`)) }, `skeleton-${n}`)) });
192
+ }
193
+ function Pe({
194
+ table: t,
195
+ dataHook: a,
196
+ trackingEl: l,
197
+ trackingLabel: n,
198
+ isLoading: o = !1,
199
+ skeletonRowCount: r,
200
+ noResultsMessage: i = "No results.",
201
+ stickyHeader: c = !1,
202
+ className: d,
203
+ footer: h,
204
+ height: g,
205
+ estimateSize: C = 48,
206
+ overscan: u = 5
207
+ }) {
208
+ const s = t.getVisibleLeafColumns().length, w = r ?? t.getState().pagination.pageSize ?? 10, b = P.useRef(null), m = t.getRowModel().rows, v = ie({
209
+ count: m.length,
210
+ getScrollElement: () => b.current,
211
+ estimateSize: () => C,
212
+ overscan: u
213
+ }), x = v.getVirtualItems(), F = v.getTotalSize(), N = x.length > 0 ? x[0].start : 0, z = x.length > 0 ? F - x[x.length - 1].end : 0;
214
+ return /* @__PURE__ */ e(
215
+ "div",
216
+ {
217
+ ref: b,
218
+ "aria-busy": o || void 0,
219
+ className: f("overflow-auto", d),
220
+ "data-hook": a,
221
+ "data-slot": "data-table-view",
222
+ "data-tracking-el": l,
223
+ "data-tracking-label": n,
224
+ style: g != null ? { height: g } : void 0,
225
+ children: /* @__PURE__ */ S(V, { dataHook: `${a}-table`, children: [
226
+ /* @__PURE__ */ e(
227
+ j,
228
+ {
229
+ className: f(c && "bg-background sticky top-0 z-10"),
230
+ children: t.getHeaderGroups().map((R) => /* @__PURE__ */ e(k, { children: R.headers.map((p) => {
231
+ const I = p.column.getCanSort() ? p.column.getIsSorted() : !1, M = I === "asc" ? "ascending" : I === "desc" ? "descending" : p.column.getCanSort() ? "none" : void 0;
232
+ return /* @__PURE__ */ e(
233
+ G,
234
+ {
235
+ "aria-sort": M,
236
+ colSpan: p.colSpan,
237
+ children: p.isPlaceholder ? null : A(
238
+ p.column.columnDef.header,
239
+ p.getContext()
240
+ )
241
+ },
242
+ p.id
243
+ );
244
+ }) }, R.id))
245
+ }
246
+ ),
247
+ /* @__PURE__ */ e(L, { children: o ? /* @__PURE__ */ S(D, { children: [
248
+ /* @__PURE__ */ e(
249
+ U,
250
+ {
251
+ colCount: s,
252
+ rowCount: w
253
+ }
254
+ ),
255
+ /* @__PURE__ */ e(k, { className: "sr-only", children: /* @__PURE__ */ e(T, { colSpan: s, children: /* @__PURE__ */ e("div", { "aria-live": "polite", role: "status", children: "Loading data…" }) }) })
256
+ ] }) : m.length > 0 ? /* @__PURE__ */ S(D, { children: [
257
+ N > 0 && /* @__PURE__ */ e("tr", { "aria-hidden": "true", children: /* @__PURE__ */ e("td", { colSpan: s, style: { height: N } }) }),
258
+ x.map((R) => {
259
+ const p = m[R.index];
260
+ return /* @__PURE__ */ e(B, { row: p }, p.id);
261
+ }),
262
+ z > 0 && /* @__PURE__ */ e("tr", { "aria-hidden": "true", children: /* @__PURE__ */ e("td", { colSpan: s, style: { height: z } }) })
263
+ ] }) : /* @__PURE__ */ e(k, { children: /* @__PURE__ */ e(T, { colSpan: s, children: /* @__PURE__ */ e("div", { "aria-live": "polite", role: "status", children: i }) }) }) }),
264
+ h
265
+ ] })
266
+ }
267
+ );
268
+ }
269
+ Pe.displayName = "VirtualizedDataTable";
270
+ function De({
271
+ column: t,
272
+ title: a,
273
+ className: l,
274
+ dataHook: n,
275
+ trackingEl: o,
276
+ trackingLabel: r,
277
+ align: i = "left"
269
278
  }) {
270
- if (!n.getCanSort())
271
- return /* @__PURE__ */ a(
279
+ if (!t.getCanSort())
280
+ return /* @__PURE__ */ e(
272
281
  "div",
273
282
  {
274
- className: b(
283
+ className: f(
275
284
  "text-muted-foreground text-left text-sm leading-normal font-medium",
276
- c === "right" && "text-right",
277
- c === "center" && "text-center",
278
- o
285
+ i === "right" && "text-right",
286
+ i === "center" && "text-center",
287
+ l
279
288
  ),
280
- "data-hook": i,
289
+ "data-hook": n,
281
290
  "data-slot": "data-table-column-header",
282
- "data-tracking-el": s,
283
- "data-tracking-label": g,
284
- children: l
291
+ "data-tracking-el": o,
292
+ "data-tracking-label": r,
293
+ children: a
285
294
  }
286
295
  );
287
- const d = n.getIsSorted(), h = d === "desc" ? `Sort by ${l}, currently descending` : d === "asc" ? `Sort by ${l}, currently ascending` : `Sort by ${l}`;
288
- return /* @__PURE__ */ a(
296
+ const c = t.getIsSorted(), d = c === "desc" ? `Sort by ${a}, currently descending` : c === "asc" ? `Sort by ${a}, currently ascending` : `Sort by ${a}`;
297
+ return /* @__PURE__ */ e(
289
298
  "div",
290
299
  {
291
- className: b(
300
+ className: f(
292
301
  "flex items-center",
293
- c === "right" && "justify-end",
294
- c === "center" && "justify-center",
295
- o
302
+ i === "right" && "justify-end",
303
+ i === "center" && "justify-center",
304
+ l
296
305
  ),
297
306
  "data-slot": "data-table-column-header",
298
- "data-tracking-el": s,
299
- "data-tracking-label": g,
300
- children: /* @__PURE__ */ w(
301
- Y,
307
+ "data-tracking-el": o,
308
+ "data-tracking-label": r,
309
+ children: /* @__PURE__ */ S(
310
+ E,
302
311
  {
303
- "aria-label": h,
304
- className: b("text-muted-foreground h-auto p-0 text-sm font-medium"),
305
- dataHook: i || `column-header-${n.id}`,
312
+ "aria-label": d,
313
+ className: "text-muted-foreground h-auto p-0 text-sm font-medium",
314
+ dataHook: n || `column-header-${t.id}`,
306
315
  size: "sm",
307
316
  variant: "ghost",
308
- onClick: () => n.toggleSorting(d === "asc"),
317
+ onClick: () => t.toggleSorting(c === "asc"),
309
318
  children: [
310
- /* @__PURE__ */ a("span", { "aria-hidden": "true", children: l }),
311
- /* @__PURE__ */ a(
319
+ /* @__PURE__ */ e("span", { "aria-hidden": "true", children: a }),
320
+ /* @__PURE__ */ e(
312
321
  "span",
313
322
  {
314
323
  "aria-hidden": "true",
315
324
  className: "flex size-3 items-center justify-center",
316
- children: d === "desc" ? /* @__PURE__ */ a(et, { size: 12 }) : d === "asc" ? /* @__PURE__ */ a(tt, { size: 12 }) : /* @__PURE__ */ a(at, { size: 12 })
325
+ children: c === "desc" ? /* @__PURE__ */ e(re, { size: 12 }) : c === "asc" ? /* @__PURE__ */ e(se, { size: 12 }) : /* @__PURE__ */ e(ce, { size: 12 })
317
326
  }
318
327
  )
319
328
  ]
@@ -322,241 +331,235 @@ function Tt({
322
331
  }
323
332
  );
324
333
  }
325
- Tt.displayName = "DataTableColumnHeader";
326
- function Pt({
327
- row: n,
328
- dataHook: l,
329
- trackingEl: o,
330
- trackingLabel: i,
331
- ariaLabel: s = "Open row actions menu",
332
- children: g
334
+ De.displayName = "DataTableColumnHeader";
335
+ function Ne({
336
+ row: t,
337
+ dataHook: a,
338
+ trackingEl: l,
339
+ trackingLabel: n,
340
+ ariaLabel: o = "Open row actions menu",
341
+ children: r
333
342
  }) {
334
- return /* @__PURE__ */ w(ct, { children: [
335
- /* @__PURE__ */ a(dt, { asChild: !0, "data-slot": "data-table-row-actions", children: /* @__PURE__ */ a(
336
- Y,
343
+ return /* @__PURE__ */ S(ue, { children: [
344
+ /* @__PURE__ */ e(me, { asChild: !0, "data-slot": "data-table-row-actions", children: /* @__PURE__ */ e(
345
+ E,
337
346
  {
338
- "aria-label": s,
339
- dataHook: l || `row-actions-${n.id}`,
347
+ "aria-label": o,
348
+ dataHook: a || `row-actions-${t.id}`,
340
349
  size: "sm",
341
- trackingEl: o,
342
- trackingLabel: i,
350
+ trackingEl: l,
351
+ trackingLabel: n,
343
352
  variant: "ghost",
344
- children: /* @__PURE__ */ a(nt, {})
353
+ children: /* @__PURE__ */ e(de, {})
345
354
  }
346
355
  ) }),
347
- /* @__PURE__ */ a(gt, { align: "end", dataHook: `${l}-menu`, children: g })
356
+ /* @__PURE__ */ e(
357
+ pe,
358
+ {
359
+ align: "end",
360
+ dataHook: a ? `${a}-menu` : `row-actions-${t.id}-menu`,
361
+ children: r
362
+ }
363
+ )
348
364
  ] });
349
365
  }
350
- Pt.displayName = "DataTableRowActions";
351
- function B({
352
- dataHook: n,
353
- trackingEl: l,
354
- trackingLabel: o,
355
- className: i,
356
- children: s
366
+ Ne.displayName = "DataTableRowActions";
367
+ function ze({
368
+ dataHook: t,
369
+ trackingEl: a,
370
+ trackingLabel: l,
371
+ className: n,
372
+ children: o
357
373
  }) {
358
- return /* @__PURE__ */ a(
374
+ return /* @__PURE__ */ e(
359
375
  "div",
360
376
  {
361
- className: b(
362
- "flex flex-wrap items-center justify-between gap-2 py-4",
363
- i
364
- ),
365
- "data-hook": n,
366
- "data-slot": "data-table-toolbar",
367
- "data-tracking-el": l,
368
- "data-tracking-label": o,
369
- children: s
377
+ className: f("flex items-center gap-2", n),
378
+ "data-hook": t,
379
+ "data-slot": "data-table-toolbar-left",
380
+ "data-tracking-el": a,
381
+ "data-tracking-label": l,
382
+ children: o
370
383
  }
371
384
  );
372
385
  }
373
- function ee({
374
- dataHook: n,
375
- trackingEl: l,
376
- trackingLabel: o,
377
- className: i,
378
- children: s
386
+ ze.displayName = "DataTableToolbarLeft";
387
+ function Ie({
388
+ dataHook: t,
389
+ trackingEl: a,
390
+ trackingLabel: l,
391
+ className: n,
392
+ children: o
379
393
  }) {
380
- return /* @__PURE__ */ a(
394
+ return /* @__PURE__ */ e(
381
395
  "div",
382
396
  {
383
- className: b("flex items-center gap-2", i),
384
- "data-hook": n,
385
- "data-slot": "data-table-toolbar-left",
386
- "data-tracking-el": l,
387
- "data-tracking-label": o,
388
- children: s
397
+ className: f("flex items-center gap-2", n),
398
+ "data-hook": t,
399
+ "data-slot": "data-table-toolbar-right",
400
+ "data-tracking-el": a,
401
+ "data-tracking-label": l,
402
+ children: o
389
403
  }
390
404
  );
391
405
  }
392
- ee.displayName = "DataTableToolbar.Left";
393
- function te({
394
- dataHook: n,
395
- trackingEl: l,
396
- trackingLabel: o,
397
- className: i,
398
- children: s
406
+ Ie.displayName = "DataTableToolbarRight";
407
+ function $e({
408
+ dataHook: t,
409
+ trackingEl: a,
410
+ trackingLabel: l,
411
+ className: n,
412
+ children: o
399
413
  }) {
400
- return /* @__PURE__ */ a(
414
+ return /* @__PURE__ */ e(
401
415
  "div",
402
416
  {
403
- className: b("flex items-center gap-2", i),
404
- "data-hook": n,
405
- "data-slot": "data-table-toolbar-right",
406
- "data-tracking-el": l,
407
- "data-tracking-label": o,
408
- children: s
417
+ className: f(
418
+ "flex flex-wrap items-center justify-between gap-2 py-4",
419
+ n
420
+ ),
421
+ "data-hook": t,
422
+ "data-slot": "data-table-toolbar",
423
+ "data-tracking-el": a,
424
+ "data-tracking-label": l,
425
+ children: o
409
426
  }
410
427
  );
411
428
  }
412
- te.displayName = "DataTableToolbar.Right";
413
- B.Left = ee;
414
- B.Right = te;
415
- B.displayName = "DataTableToolbar";
416
- function Dt({
417
- table: n,
418
- dataHook: l,
419
- trackingEl: o,
420
- trackingLabel: i,
421
- ariaLabel: s = "Search table",
422
- placeholder: g = "Search...",
423
- column: c,
424
- width: d,
425
- className: h
429
+ $e.displayName = "DataTableToolbar";
430
+ function Fe({
431
+ table: t,
432
+ ariaLabel: a = "Search table",
433
+ placeholder: l = "Search...",
434
+ ...n
426
435
  }) {
427
- const p = c ? n.getColumn(c)?.getFilterValue() ?? "" : n.getState().globalFilter ?? "", S = (u) => {
428
- c ? n.getColumn(c)?.setFilterValue(u) : n.setGlobalFilter(u);
436
+ const o = t.getState().globalFilter ?? "", r = (i) => {
437
+ t.setGlobalFilter(i);
429
438
  };
430
- return /* @__PURE__ */ a(
431
- "div",
432
- {
433
- className: b(!d && "w-full max-w-sm", h),
434
- "data-slot": "data-table-search",
435
- style: d ? { width: d, minWidth: d } : void 0,
436
- children: /* @__PURE__ */ w(ot, { className: "rounded-full", dataHook: l, children: [
437
- /* @__PURE__ */ a(
438
- it,
439
- {
440
- "aria-label": s,
441
- placeholder: g,
442
- trackingEl: o,
443
- trackingLabel: i,
444
- type: "text",
445
- value: p,
446
- onChange: (u) => S(u.target.value)
447
- }
448
- ),
449
- /* @__PURE__ */ a(st, { className: "pr-3", children: /* @__PURE__ */ a(lt, {}) })
450
- ] })
451
- }
452
- );
439
+ return /* @__PURE__ */ S(he, { ...n, children: [
440
+ /* @__PURE__ */ e(
441
+ fe,
442
+ {
443
+ "aria-label": a,
444
+ placeholder: l,
445
+ type: "text",
446
+ value: o,
447
+ onChange: (i) => r(i.target.value)
448
+ }
449
+ ),
450
+ /* @__PURE__ */ e(be, { className: "pr-3", children: /* @__PURE__ */ e(ge, {}) })
451
+ ] });
453
452
  }
454
- Dt.displayName = "DataTableSearch";
455
- function Mt({
456
- table: n,
457
- dataHook: l,
458
- trackingEl: o,
459
- trackingLabel: i,
460
- className: s,
461
- ariaLabel: g = "Table pagination"
453
+ Fe.displayName = "DataTableSearch";
454
+ function Me({
455
+ table: t,
456
+ dataHook: a,
457
+ trackingEl: l,
458
+ trackingLabel: n,
459
+ className: o,
460
+ ariaLabel: r = "Table pagination"
462
461
  }) {
463
- const c = n.getState().pagination.pageIndex + 1, d = n.getPageCount(), h = n.getState().pagination.pageSize, p = n.getFilteredRowModel().rows.length, S = p === 0 ? 0 : (c - 1) * h + 1, u = Math.min(c * h, p), y = pt({
464
- page: c,
465
- totalPages: d,
462
+ const { pageIndex: i, pageSize: c } = t.getState().pagination, d = t.getRowCount(), h = t.getPageCount(), g = t.getCanPreviousPage(), C = t.getCanNextPage(), u = i + 1, s = d === 0 ? 0 : i * c + 1, w = Math.min(u * c, d), b = Se({
463
+ page: u,
464
+ totalPages: h,
466
465
  siblingCount: 1,
467
466
  boundaryCount: 1
468
467
  });
469
- return /* @__PURE__ */ w(
468
+ return /* @__PURE__ */ S(
470
469
  "div",
471
470
  {
472
- className: b("flex items-center justify-end gap-4", s),
473
- "data-hook": l,
471
+ className: f("flex items-center justify-end gap-4", o),
472
+ "data-hook": a,
474
473
  "data-slot": "data-table-pagination",
475
- "data-tracking-el": o,
476
- "data-tracking-label": i,
474
+ "data-tracking-el": l,
475
+ "data-tracking-label": n,
477
476
  children: [
478
- /* @__PURE__ */ a("span", { className: "text-muted-foreground text-sm", children: p === 0 ? "0 of 0" : `${S}-${u} of ${p}` }),
479
- /* @__PURE__ */ a(
480
- bt,
477
+ /* @__PURE__ */ e("span", { className: "text-muted-foreground text-sm", children: d === 0 ? "0 of 0" : `${s}-${w} of ${d}` }),
478
+ /* @__PURE__ */ e(
479
+ Ce,
481
480
  {
482
- ariaLabel: g,
481
+ ariaLabel: r,
483
482
  className: "mx-0 w-auto justify-end",
484
- dataHook: `${l}-nav`,
485
- children: /* @__PURE__ */ a(wt, { children: y.map((f, T) => f === "previous" ? /* @__PURE__ */ a(R, { children: /* @__PURE__ */ a(
486
- Ct,
483
+ dataHook: `${a}-nav`,
484
+ children: /* @__PURE__ */ e(we, { children: b.map((m, v) => m === "previous" ? /* @__PURE__ */ e($, { children: /* @__PURE__ */ e(
485
+ xe,
487
486
  {
488
- disabled: !n.getCanPreviousPage(),
489
- onClick: () => n.previousPage()
487
+ disabled: !g,
488
+ onClick: () => t.previousPage()
490
489
  }
491
- ) }, "previous") : f === "next" ? /* @__PURE__ */ a(R, { children: /* @__PURE__ */ a(
492
- St,
490
+ ) }, "previous") : m === "next" ? /* @__PURE__ */ e($, { children: /* @__PURE__ */ e(
491
+ ke,
493
492
  {
494
- disabled: !n.getCanNextPage(),
495
- onClick: () => n.nextPage()
493
+ disabled: !C,
494
+ onClick: () => t.nextPage()
496
495
  }
497
- ) }, "next") : f === "ellipsis" ? /* @__PURE__ */ a(R, { children: /* @__PURE__ */ a(xt, {}) }, `ellipsis-${T}`) : /* @__PURE__ */ a(R, { children: /* @__PURE__ */ a(
498
- kt,
496
+ ) }, "next") : m === "ellipsis" ? /* @__PURE__ */ e($, { children: /* @__PURE__ */ e(ve, {}) }, `ellipsis-${v}`) : /* @__PURE__ */ e($, { children: /* @__PURE__ */ e(
497
+ Re,
499
498
  {
500
- isActive: f === c,
501
- page: f,
502
- onClick: () => n.setPageIndex(f - 1)
499
+ isActive: m === u,
500
+ page: m,
501
+ onClick: () => t.setPageIndex(m - 1)
503
502
  }
504
- ) }, f)) })
503
+ ) }, m)) })
505
504
  }
506
505
  )
507
506
  ]
508
507
  }
509
508
  );
510
509
  }
511
- Mt.displayName = "DataTablePagination";
512
- function Nt({
513
- table: n,
514
- dataHook: l,
515
- trackingEl: o,
516
- trackingLabel: i
510
+ Me.displayName = "DataTablePagination";
511
+ function Ae({
512
+ table: t,
513
+ dataHook: a,
514
+ trackingEl: l,
515
+ trackingLabel: n
517
516
  }) {
518
- return /* @__PURE__ */ a(
519
- Z,
517
+ return /* @__PURE__ */ e(
518
+ H,
520
519
  {
521
520
  "aria-label": "Select all",
522
- checked: n.getIsAllPageRowsSelected() || n.getIsSomePageRowsSelected() && "indeterminate",
523
- dataHook: l || "select-all-checkbox",
524
- trackingEl: o,
525
- trackingLabel: i,
526
- onCheckedChange: (s) => n.toggleAllPageRowsSelected(!!s)
521
+ checked: t.getIsAllPageRowsSelected() || t.getIsSomePageRowsSelected() && "indeterminate",
522
+ dataHook: a || "select-all-checkbox",
523
+ trackingEl: l,
524
+ trackingLabel: n,
525
+ onCheckedChange: (o) => t.toggleAllPageRowsSelected(!!o)
527
526
  }
528
527
  );
529
528
  }
530
- Nt.displayName = "DataTableSelectAllCheckbox";
531
- function Ft({
532
- row: n,
533
- dataHook: l,
534
- trackingEl: o,
535
- trackingLabel: i
529
+ Ae.displayName = "DataTableSelectAllCheckbox";
530
+ function Ee({
531
+ row: t,
532
+ dataHook: a,
533
+ trackingEl: l,
534
+ trackingLabel: n
536
535
  }) {
537
- return /* @__PURE__ */ a(
538
- Z,
536
+ return /* @__PURE__ */ e(
537
+ H,
539
538
  {
540
539
  "aria-label": "Select row",
541
- checked: n.getIsSelected(),
542
- dataHook: l || `select-row-${n.id}`,
543
- disabled: !n.getCanSelect(),
544
- trackingEl: o,
545
- trackingLabel: i,
546
- onCheckedChange: (s) => n.toggleSelected(!!s)
540
+ checked: t.getIsSelected(),
541
+ dataHook: a || `select-row-${t.id}`,
542
+ disabled: !t.getCanSelect(),
543
+ trackingEl: l,
544
+ trackingLabel: n,
545
+ onCheckedChange: (o) => t.toggleSelected(!!o)
547
546
  }
548
547
  );
549
548
  }
550
- Ft.displayName = "DataTableSelectRowCheckbox";
549
+ Ee.displayName = "DataTableSelectRowCheckbox";
551
550
  export {
552
- yt as DataTable,
553
- Tt as DataTableColumnHeader,
554
- Mt as DataTablePagination,
555
- Pt as DataTableRowActions,
556
- Dt as DataTableSearch,
557
- Nt as DataTableSelectAllCheckbox,
558
- Ft as DataTableSelectRowCheckbox,
559
- B as DataTableToolbar,
560
- qt as createColumnHelper,
561
- _t as flexRender
551
+ ye as DataTable,
552
+ De as DataTableColumnHeader,
553
+ Me as DataTablePagination,
554
+ Ne as DataTableRowActions,
555
+ Fe as DataTableSearch,
556
+ Ae as DataTableSelectAllCheckbox,
557
+ Ee as DataTableSelectRowCheckbox,
558
+ $e as DataTableToolbar,
559
+ ze as DataTableToolbarLeft,
560
+ Ie as DataTableToolbarRight,
561
+ Pe as VirtualizedDataTable,
562
+ Ye as createColumnHelper,
563
+ Ze as flexRender,
564
+ Qe as useDataTable
562
565
  };