@brightlocal/ui-components 2.22.0 → 2.24.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/AI_USAGE.md +1 -1
- package/README.md +4 -2
- package/component-meta.json +134 -25
- package/deprecations.json +22 -0
- package/dist/alert.cjs +1 -1
- package/dist/alert.d.ts.map +1 -1
- package/dist/alert.js +32 -35
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +151 -156
- package/dist/brand-illustration-motif.cjs +1 -0
- package/dist/brand-illustration-motif.d.ts +55 -0
- package/dist/brand-illustration-motif.d.ts.map +1 -0
- package/dist/brand-illustration-motif.js +67 -0
- package/dist/chart.cjs +7 -7
- package/dist/chart.d.ts +287 -2
- package/dist/chart.d.ts.map +1 -1
- package/dist/chart.js +408 -152
- package/dist/combobox.cjs +3 -3
- package/dist/combobox.d.ts +14 -1
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +387 -376
- package/dist/context-menu.cjs +1 -1
- package/dist/context-menu.d.ts.map +1 -1
- package/dist/context-menu.js +111 -109
- package/dist/data-table.cjs +1 -0
- package/dist/{blocks/data-table.d.ts → data-table.d.ts} +159 -4
- package/dist/data-table.d.ts.map +1 -0
- package/dist/data-table.js +721 -0
- package/dist/dropdown-menu.cjs +1 -1
- package/dist/dropdown-menu.d.ts.map +1 -1
- package/dist/dropdown-menu.js +109 -121
- package/dist/field.cjs +1 -1
- package/dist/field.d.ts +16 -1
- package/dist/field.d.ts.map +1 -1
- package/dist/field.js +23 -7
- package/dist/global-layout.cjs +1 -1
- package/dist/global-layout.d.ts +32 -2
- package/dist/global-layout.d.ts.map +1 -1
- package/dist/global-layout.js +179 -109
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +526 -509
- package/dist/label.cjs +1 -1
- package/dist/label.d.ts +9 -0
- package/dist/label.d.ts.map +1 -1
- package/dist/label.js +26 -22
- package/dist/lib/spring-settle.cjs +1 -0
- package/dist/lib/spring-settle.d.ts +20 -0
- package/dist/lib/spring-settle.d.ts.map +1 -0
- package/dist/lib/spring-settle.js +4 -0
- package/dist/link.cjs +1 -1
- package/dist/link.d.ts +3 -2
- package/dist/link.d.ts.map +1 -1
- package/dist/link.js +22 -11
- package/dist/loading.cjs +1 -0
- package/dist/loading.d.ts +47 -0
- package/dist/loading.d.ts.map +1 -0
- package/dist/loading.js +163 -0
- package/dist/map.cjs +1 -1
- package/dist/map.d.ts.map +1 -1
- package/dist/map.js +1 -1
- package/dist/menubar.cjs +1 -1
- package/dist/menubar.d.ts.map +1 -1
- package/dist/menubar.js +97 -99
- package/dist/popover.cjs +1 -1
- package/dist/popover.d.ts.map +1 -1
- package/dist/popover.js +27 -26
- package/dist/select.cjs +2 -2
- package/dist/select.d.ts +16 -1
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +112 -85
- package/dist/table.cjs +1 -1
- package/dist/table.d.ts +29 -0
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +2 -2
- package/dist/text-reveal-motion.cjs +1 -1
- package/dist/text-reveal-motion.d.ts.map +1 -1
- package/dist/text-reveal-motion.js +236 -219
- package/dist/tooltip.cjs +1 -1
- package/dist/tooltip.d.ts +21 -2
- package/dist/tooltip.d.ts.map +1 -1
- package/dist/tooltip.js +35 -32
- package/dist/typography.cjs +1 -1
- package/dist/typography.d.ts +20 -4
- package/dist/typography.d.ts.map +1 -1
- package/dist/typography.js +263 -228
- package/package.json +7 -7
- package/src/blocks/sidebar.tsx +11 -23
- package/src/components/alert.tsx +10 -17
- package/src/components/brand-illustration-motif.tsx +143 -0
- package/src/components/chart.tsx +632 -1
- package/src/components/combobox.tsx +47 -0
- package/src/components/context-menu.tsx +8 -3
- package/src/{blocks → components}/data-table.tsx +272 -18
- package/src/components/dropdown-menu.tsx +6 -15
- package/src/components/field.tsx +31 -0
- package/src/components/global-layout.tsx +144 -5
- package/src/components/label.tsx +13 -1
- package/src/components/link.tsx +13 -1
- package/src/components/loading.tsx +355 -0
- package/src/components/map.tsx +3 -1
- package/src/components/menubar.tsx +6 -5
- package/src/components/popover.tsx +6 -2
- package/src/components/select.tsx +87 -10
- package/src/components/table.tsx +31 -2
- package/src/components/text-reveal-motion.tsx +90 -64
- package/src/components/tooltip.tsx +28 -3
- package/src/components/typography.tsx +74 -18
- package/src/index.ts +3 -1
- package/src/lib/spring-settle.ts +19 -0
- package/dist/blocks/data-table.cjs +0 -1
- package/dist/blocks/data-table.d.ts.map +0 -1
- package/dist/blocks/data-table.js +0 -654
|
@@ -0,0 +1,721 @@
|
|
|
1
|
+
import { jsx as t, jsxs as S, Fragment as R } from "react/jsx-runtime";
|
|
2
|
+
import * as g from "react";
|
|
3
|
+
import { useReactTable as oe, getExpandedRowModel as le, getFilteredRowModel as ie, getSortedRowModel as re, getPaginationRowModel as se, getCoreRowModel as ce, flexRender as V } from "@tanstack/react-table";
|
|
4
|
+
import { useVirtualizer as de } from "@tanstack/react-virtual";
|
|
5
|
+
import { ArrowDown as ue, ArrowUp as ge, ArrowUpDown as me, Search as pe, X as he } from "@brightlocal/icons";
|
|
6
|
+
import { cn as m } from "@brightlocal/ui-components/lib/utils";
|
|
7
|
+
import { Button as E } from "./button.js";
|
|
8
|
+
import { Checkbox as j } from "./checkbox.js";
|
|
9
|
+
import { InputGroup as fe, InputGroupAddon as H, InputGroupInput as be } from "./input-group.js";
|
|
10
|
+
import { usePagination as we, Pagination as Se, PaginationContent as Ce, PaginationItem as I, PaginationPrevious as xe, PaginationNext as ke, PaginationEllipsis as Pe, PaginationLink as Te } from "./pagination.js";
|
|
11
|
+
import { Skeleton as ve } from "./skeleton.js";
|
|
12
|
+
import { Table as G, TableBody as L, TableRow as k, TableCell as P, TableHeader as Re, TableHead as De } from "./table.js";
|
|
13
|
+
import { TypographyMuted as ye } from "./typography.js";
|
|
14
|
+
function v(e, n, l) {
|
|
15
|
+
const [a, i] = g.useState(n), o = e !== void 0 ? e : a, r = g.useRef(o);
|
|
16
|
+
g.useEffect(() => {
|
|
17
|
+
r.current = o;
|
|
18
|
+
});
|
|
19
|
+
const c = e !== void 0, d = g.useCallback(
|
|
20
|
+
(s) => {
|
|
21
|
+
const u = typeof s == "function" ? s(r.current) : s;
|
|
22
|
+
c || i(u), l?.(u);
|
|
23
|
+
},
|
|
24
|
+
[c, l]
|
|
25
|
+
);
|
|
26
|
+
return [o, d];
|
|
27
|
+
}
|
|
28
|
+
function nt(e) {
|
|
29
|
+
const {
|
|
30
|
+
columns: n,
|
|
31
|
+
data: l,
|
|
32
|
+
enableSorting: a = !0,
|
|
33
|
+
enableGlobalFiltering: i = !1,
|
|
34
|
+
enableRowSelection: o = !1,
|
|
35
|
+
enablePagination: r = !1,
|
|
36
|
+
pageSize: c = 10,
|
|
37
|
+
manualSorting: d = !1,
|
|
38
|
+
manualFiltering: s = !1,
|
|
39
|
+
manualPagination: u = !1,
|
|
40
|
+
rowCount: h,
|
|
41
|
+
pageCount: p,
|
|
42
|
+
enableExpanding: f = !1,
|
|
43
|
+
getSubRows: b,
|
|
44
|
+
getRowId: C,
|
|
45
|
+
pagination: x,
|
|
46
|
+
onPaginationChange: $,
|
|
47
|
+
sorting: D,
|
|
48
|
+
onSortingChange: T,
|
|
49
|
+
globalFilter: y,
|
|
50
|
+
onGlobalFilterChange: w,
|
|
51
|
+
rowSelection: F,
|
|
52
|
+
onRowSelectionChange: N,
|
|
53
|
+
expanded: z,
|
|
54
|
+
onExpandedChange: M
|
|
55
|
+
} = e, [A, K] = v(
|
|
56
|
+
x,
|
|
57
|
+
{ pageIndex: 0, pageSize: c },
|
|
58
|
+
$
|
|
59
|
+
), [O, Q] = v(
|
|
60
|
+
D,
|
|
61
|
+
[],
|
|
62
|
+
T
|
|
63
|
+
), [Y, Z] = v(
|
|
64
|
+
y,
|
|
65
|
+
"",
|
|
66
|
+
w
|
|
67
|
+
), [ee, te] = v(F, {}, N), [ae, ne] = v(
|
|
68
|
+
z,
|
|
69
|
+
{},
|
|
70
|
+
M
|
|
71
|
+
);
|
|
72
|
+
return oe({
|
|
73
|
+
data: l,
|
|
74
|
+
columns: n,
|
|
75
|
+
getCoreRowModel: ce(),
|
|
76
|
+
...C && { getRowId: C },
|
|
77
|
+
...(r || u) && {
|
|
78
|
+
onPaginationChange: K
|
|
79
|
+
},
|
|
80
|
+
...r && {
|
|
81
|
+
...!u && {
|
|
82
|
+
getPaginationRowModel: se()
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
...u && {
|
|
86
|
+
manualPagination: !0,
|
|
87
|
+
...h != null && { rowCount: h },
|
|
88
|
+
...p != null && { pageCount: p }
|
|
89
|
+
},
|
|
90
|
+
...a && {
|
|
91
|
+
...!d && {
|
|
92
|
+
getSortedRowModel: re()
|
|
93
|
+
},
|
|
94
|
+
onSortingChange: Q,
|
|
95
|
+
...d && { manualSorting: !0 }
|
|
96
|
+
},
|
|
97
|
+
...i && {
|
|
98
|
+
...!s && {
|
|
99
|
+
getFilteredRowModel: ie()
|
|
100
|
+
},
|
|
101
|
+
...s && { manualFiltering: !0 },
|
|
102
|
+
onGlobalFilterChange: Z,
|
|
103
|
+
globalFilterFn: "includesString"
|
|
104
|
+
},
|
|
105
|
+
...o && {
|
|
106
|
+
enableRowSelection: !0,
|
|
107
|
+
onRowSelectionChange: te
|
|
108
|
+
},
|
|
109
|
+
...f && {
|
|
110
|
+
getExpandedRowModel: le(),
|
|
111
|
+
onExpandedChange: ne,
|
|
112
|
+
getSubRows: b
|
|
113
|
+
},
|
|
114
|
+
state: {
|
|
115
|
+
pagination: A,
|
|
116
|
+
sorting: O,
|
|
117
|
+
globalFilter: Y,
|
|
118
|
+
rowSelection: ee,
|
|
119
|
+
expanded: ae
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
function Ne({
|
|
124
|
+
table: e,
|
|
125
|
+
dataHook: n,
|
|
126
|
+
trackingEl: l,
|
|
127
|
+
trackingLabel: a,
|
|
128
|
+
isLoading: i = !1,
|
|
129
|
+
skeletonRowCount: o,
|
|
130
|
+
noResultsMessage: r = "No results.",
|
|
131
|
+
stickyHeader: c = !1,
|
|
132
|
+
className: d,
|
|
133
|
+
layout: s,
|
|
134
|
+
minWidth: u,
|
|
135
|
+
scrollRegionLabel: h,
|
|
136
|
+
footer: p
|
|
137
|
+
}) {
|
|
138
|
+
const f = e.getVisibleLeafColumns().length, b = o ?? e.getState().pagination.pageSize ?? 10;
|
|
139
|
+
return /* @__PURE__ */ t(
|
|
140
|
+
"div",
|
|
141
|
+
{
|
|
142
|
+
"aria-busy": i || void 0,
|
|
143
|
+
className: m("border-border overflow-auto rounded-md border", d),
|
|
144
|
+
"data-hook": n,
|
|
145
|
+
"data-slot": "data-table-view",
|
|
146
|
+
"data-tracking-el": l,
|
|
147
|
+
"data-tracking-label": a,
|
|
148
|
+
children: /* @__PURE__ */ S(
|
|
149
|
+
G,
|
|
150
|
+
{
|
|
151
|
+
dataHook: `${n}-table`,
|
|
152
|
+
layout: s,
|
|
153
|
+
minWidth: u,
|
|
154
|
+
scrollRegionLabel: h,
|
|
155
|
+
children: [
|
|
156
|
+
/* @__PURE__ */ t(U, { stickyHeader: c, table: e }),
|
|
157
|
+
/* @__PURE__ */ t(L, { children: i ? /* @__PURE__ */ S(R, { children: [
|
|
158
|
+
/* @__PURE__ */ t(
|
|
159
|
+
_,
|
|
160
|
+
{
|
|
161
|
+
colCount: f,
|
|
162
|
+
rowCount: b
|
|
163
|
+
}
|
|
164
|
+
),
|
|
165
|
+
/* @__PURE__ */ t(k, { className: "sr-only", children: /* @__PURE__ */ t(P, { colSpan: f, children: /* @__PURE__ */ t("div", { "aria-live": "polite", role: "status", children: "Loading data…" }) }) })
|
|
166
|
+
] }) : /* @__PURE__ */ t(R, { children: e.getRowModel().rows.length > 0 ? e.getRowModel().rows.map((C) => /* @__PURE__ */ t(W, { row: C }, C.id)) : /* @__PURE__ */ t(k, { children: /* @__PURE__ */ t(P, { align: "center", colSpan: f, size: "lg", children: /* @__PURE__ */ t("div", { "aria-live": "polite", role: "status", children: r }) }) }) }) }),
|
|
167
|
+
p
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
)
|
|
171
|
+
}
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
Ne.displayName = "DataTable";
|
|
175
|
+
function U({
|
|
176
|
+
table: e,
|
|
177
|
+
stickyHeader: n
|
|
178
|
+
}) {
|
|
179
|
+
return /* @__PURE__ */ t(Re, { className: m(n && "sticky top-0 z-10"), children: e.getHeaderGroups().map((l) => /* @__PURE__ */ t(k, { children: l.headers.map((a) => {
|
|
180
|
+
const i = a.column.getCanSort() ? a.column.getIsSorted() : !1, o = i === "asc" ? "ascending" : i === "desc" ? "descending" : a.column.getCanSort() ? "none" : void 0, r = a.column.columnDef.meta;
|
|
181
|
+
return /* @__PURE__ */ t(
|
|
182
|
+
De,
|
|
183
|
+
{
|
|
184
|
+
"aria-sort": o,
|
|
185
|
+
colSpan: a.colSpan,
|
|
186
|
+
minWidth: r?.minWidth,
|
|
187
|
+
width: r?.width,
|
|
188
|
+
children: a.isPlaceholder ? null : V(
|
|
189
|
+
a.column.columnDef.header,
|
|
190
|
+
a.getContext()
|
|
191
|
+
)
|
|
192
|
+
},
|
|
193
|
+
a.id
|
|
194
|
+
);
|
|
195
|
+
}) }, l.id)) });
|
|
196
|
+
}
|
|
197
|
+
function W({ row: e }) {
|
|
198
|
+
return /* @__PURE__ */ t(k, { "data-state": e.getIsSelected() ? "selected" : void 0, children: e.getVisibleCells().map((n) => /* @__PURE__ */ t(P, { children: V(n.column.columnDef.cell, n.getContext()) }, n.id)) });
|
|
199
|
+
}
|
|
200
|
+
function _({
|
|
201
|
+
rowCount: e,
|
|
202
|
+
colCount: n
|
|
203
|
+
}) {
|
|
204
|
+
return /* @__PURE__ */ t(R, { children: Array.from({ length: e }).map((l, a) => /* @__PURE__ */ t(k, { children: Array.from({ length: n }).map((i, o) => /* @__PURE__ */ t(P, { children: /* @__PURE__ */ t(ve, { className: "h-4 w-full" }) }, `skeleton-${a}-${o}`)) }, `skeleton-${a}`)) });
|
|
205
|
+
}
|
|
206
|
+
function ze({
|
|
207
|
+
table: e,
|
|
208
|
+
dataHook: n,
|
|
209
|
+
trackingEl: l,
|
|
210
|
+
trackingLabel: a,
|
|
211
|
+
isLoading: i = !1,
|
|
212
|
+
skeletonRowCount: o,
|
|
213
|
+
noResultsMessage: r = "No results.",
|
|
214
|
+
stickyHeader: c = !1,
|
|
215
|
+
className: d,
|
|
216
|
+
layout: s,
|
|
217
|
+
minWidth: u,
|
|
218
|
+
scrollRegionLabel: h,
|
|
219
|
+
footer: p,
|
|
220
|
+
height: f,
|
|
221
|
+
estimateSize: b = 48,
|
|
222
|
+
overscan: C = 5
|
|
223
|
+
}) {
|
|
224
|
+
const x = e.getVisibleLeafColumns().length, $ = o ?? e.getState().pagination.pageSize ?? 10, D = g.useRef(null), T = e.getRowModel().rows, y = de({
|
|
225
|
+
count: T.length,
|
|
226
|
+
getScrollElement: () => D.current,
|
|
227
|
+
estimateSize: () => b,
|
|
228
|
+
overscan: C
|
|
229
|
+
}), w = y.getVirtualItems(), F = y.getTotalSize(), N = w.length > 0 ? w[0].start : 0, z = w.length > 0 ? F - w[w.length - 1].end : 0;
|
|
230
|
+
return /* @__PURE__ */ t(
|
|
231
|
+
"div",
|
|
232
|
+
{
|
|
233
|
+
ref: D,
|
|
234
|
+
"aria-busy": i || void 0,
|
|
235
|
+
className: m("border-border overflow-auto rounded-md border", d),
|
|
236
|
+
"data-hook": n,
|
|
237
|
+
"data-slot": "data-table-view",
|
|
238
|
+
"data-tracking-el": l,
|
|
239
|
+
"data-tracking-label": a,
|
|
240
|
+
style: f != null ? { height: f } : void 0,
|
|
241
|
+
children: /* @__PURE__ */ S(
|
|
242
|
+
G,
|
|
243
|
+
{
|
|
244
|
+
dataHook: `${n}-table`,
|
|
245
|
+
layout: s,
|
|
246
|
+
minWidth: u,
|
|
247
|
+
scrollRegionLabel: h,
|
|
248
|
+
children: [
|
|
249
|
+
/* @__PURE__ */ t(U, { stickyHeader: c, table: e }),
|
|
250
|
+
/* @__PURE__ */ t(L, { children: i ? /* @__PURE__ */ S(R, { children: [
|
|
251
|
+
/* @__PURE__ */ t(
|
|
252
|
+
_,
|
|
253
|
+
{
|
|
254
|
+
colCount: x,
|
|
255
|
+
rowCount: $
|
|
256
|
+
}
|
|
257
|
+
),
|
|
258
|
+
/* @__PURE__ */ t(k, { className: "sr-only", children: /* @__PURE__ */ t(P, { colSpan: x, children: /* @__PURE__ */ t("div", { "aria-live": "polite", role: "status", children: "Loading data…" }) }) })
|
|
259
|
+
] }) : T.length > 0 ? /* @__PURE__ */ S(R, { children: [
|
|
260
|
+
N > 0 && /* @__PURE__ */ t("tr", { "aria-hidden": "true", children: /* @__PURE__ */ t("td", { colSpan: x, style: { height: N } }) }),
|
|
261
|
+
w.map((M) => {
|
|
262
|
+
const A = T[M.index];
|
|
263
|
+
return /* @__PURE__ */ t(W, { row: A }, A.id);
|
|
264
|
+
}),
|
|
265
|
+
z > 0 && /* @__PURE__ */ t("tr", { "aria-hidden": "true", children: /* @__PURE__ */ t("td", { colSpan: x, style: { height: z } }) })
|
|
266
|
+
] }) : /* @__PURE__ */ t(k, { children: /* @__PURE__ */ t(P, { align: "center", colSpan: x, size: "lg", children: /* @__PURE__ */ t("div", { "aria-live": "polite", role: "status", children: r }) }) }) }),
|
|
267
|
+
p
|
|
268
|
+
]
|
|
269
|
+
}
|
|
270
|
+
)
|
|
271
|
+
}
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
ze.displayName = "VirtualizedDataTable";
|
|
275
|
+
function Ae({
|
|
276
|
+
column: e,
|
|
277
|
+
title: n,
|
|
278
|
+
className: l,
|
|
279
|
+
dataHook: a,
|
|
280
|
+
trackingEl: i,
|
|
281
|
+
trackingLabel: o,
|
|
282
|
+
align: r = "left",
|
|
283
|
+
getSortLabel: c
|
|
284
|
+
}) {
|
|
285
|
+
if (!e.getCanSort())
|
|
286
|
+
return /* @__PURE__ */ t(
|
|
287
|
+
"div",
|
|
288
|
+
{
|
|
289
|
+
className: m(
|
|
290
|
+
"text-muted-foreground text-left text-sm leading-normal font-medium",
|
|
291
|
+
r === "right" && "text-right",
|
|
292
|
+
r === "center" && "text-center",
|
|
293
|
+
l
|
|
294
|
+
),
|
|
295
|
+
"data-hook": a,
|
|
296
|
+
"data-slot": "data-table-column-header",
|
|
297
|
+
"data-tracking-el": i,
|
|
298
|
+
"data-tracking-label": o,
|
|
299
|
+
children: n
|
|
300
|
+
}
|
|
301
|
+
);
|
|
302
|
+
const d = e.getIsSorted(), s = c ? c(n, d) : d === "desc" ? `Sort by ${n}, currently descending` : d === "asc" ? `Sort by ${n}, currently ascending` : `Sort by ${n}`;
|
|
303
|
+
return /* @__PURE__ */ t(
|
|
304
|
+
"div",
|
|
305
|
+
{
|
|
306
|
+
className: m(
|
|
307
|
+
"flex items-center",
|
|
308
|
+
r === "right" && "justify-end",
|
|
309
|
+
r === "center" && "justify-center",
|
|
310
|
+
l
|
|
311
|
+
),
|
|
312
|
+
"data-slot": "data-table-column-header",
|
|
313
|
+
"data-tracking-el": i,
|
|
314
|
+
"data-tracking-label": o,
|
|
315
|
+
children: /* @__PURE__ */ S(
|
|
316
|
+
E,
|
|
317
|
+
{
|
|
318
|
+
"aria-label": s,
|
|
319
|
+
className: "text-muted-foreground h-auto p-0 text-sm font-medium",
|
|
320
|
+
dataHook: a || `column-header-${e.id}`,
|
|
321
|
+
size: "sm",
|
|
322
|
+
variant: "ghost",
|
|
323
|
+
onClick: () => e.toggleSorting(d === "asc"),
|
|
324
|
+
children: [
|
|
325
|
+
/* @__PURE__ */ t("span", { "aria-hidden": "true", children: n }),
|
|
326
|
+
/* @__PURE__ */ t(
|
|
327
|
+
"span",
|
|
328
|
+
{
|
|
329
|
+
"aria-hidden": "true",
|
|
330
|
+
className: "flex size-3 items-center justify-center",
|
|
331
|
+
children: d === "desc" ? /* @__PURE__ */ t(ue, { size: 12 }) : d === "asc" ? /* @__PURE__ */ t(ge, { size: 12 }) : /* @__PURE__ */ t(me, { size: 12 })
|
|
332
|
+
}
|
|
333
|
+
)
|
|
334
|
+
]
|
|
335
|
+
}
|
|
336
|
+
)
|
|
337
|
+
}
|
|
338
|
+
);
|
|
339
|
+
}
|
|
340
|
+
Ae.displayName = "DataTableColumnHeader";
|
|
341
|
+
function Ie({
|
|
342
|
+
table: e,
|
|
343
|
+
ariaLabel: n,
|
|
344
|
+
placeholder: l,
|
|
345
|
+
clearSearchAriaLabel: a,
|
|
346
|
+
...i
|
|
347
|
+
}) {
|
|
348
|
+
const o = e.getState().globalFilter ?? "", r = (c) => {
|
|
349
|
+
e.setGlobalFilter(c);
|
|
350
|
+
};
|
|
351
|
+
return /* @__PURE__ */ S(fe, { "data-slot": "data-table-search", ...i, children: [
|
|
352
|
+
/* @__PURE__ */ t(H, { className: "pl-3", children: /* @__PURE__ */ t(pe, {}) }),
|
|
353
|
+
/* @__PURE__ */ t(
|
|
354
|
+
be,
|
|
355
|
+
{
|
|
356
|
+
"aria-label": n ?? "Search table",
|
|
357
|
+
placeholder: l ?? "Search...",
|
|
358
|
+
type: "text",
|
|
359
|
+
value: o,
|
|
360
|
+
onChange: (c) => r(c.target.value)
|
|
361
|
+
}
|
|
362
|
+
),
|
|
363
|
+
o && /* @__PURE__ */ t(H, { className: "pr-1", children: /* @__PURE__ */ t(
|
|
364
|
+
E,
|
|
365
|
+
{
|
|
366
|
+
"aria-label": a ?? "Clear search",
|
|
367
|
+
className: "h-auto p-1",
|
|
368
|
+
"data-slot": "data-table-search-clear",
|
|
369
|
+
dataHook: `${i.dataHook}-clear`,
|
|
370
|
+
variant: "ghost",
|
|
371
|
+
onClick: () => r(""),
|
|
372
|
+
children: /* @__PURE__ */ t(he, { size: 14 })
|
|
373
|
+
}
|
|
374
|
+
) })
|
|
375
|
+
] });
|
|
376
|
+
}
|
|
377
|
+
Ie.displayName = "DataTableSearch";
|
|
378
|
+
function $e(e) {
|
|
379
|
+
const { pageIndex: n, pageSize: l } = e.getState().pagination, a = e.getRowCount(), i = e.getPageCount(), o = e.getCanPreviousPage(), r = e.getCanNextPage(), c = n + 1, d = a === 0 ? 0 : n * l + 1, s = Math.min(c * l, a), u = g.useCallback(
|
|
380
|
+
(b) => e.setPageIndex(b - 1),
|
|
381
|
+
[e]
|
|
382
|
+
), h = g.useCallback(() => e.nextPage(), [e]), p = g.useCallback(() => e.previousPage(), [e]), f = g.useCallback(
|
|
383
|
+
(b) => e.setPageSize(b),
|
|
384
|
+
[e]
|
|
385
|
+
);
|
|
386
|
+
return g.useMemo(
|
|
387
|
+
() => ({
|
|
388
|
+
pageIndex: n,
|
|
389
|
+
pageSize: l,
|
|
390
|
+
totalRows: a,
|
|
391
|
+
totalPages: i,
|
|
392
|
+
startRow: d,
|
|
393
|
+
endRow: s,
|
|
394
|
+
currentPage: c,
|
|
395
|
+
canPrev: o,
|
|
396
|
+
canNext: r,
|
|
397
|
+
goToPage: u,
|
|
398
|
+
nextPage: h,
|
|
399
|
+
previousPage: p,
|
|
400
|
+
setPageSize: f
|
|
401
|
+
}),
|
|
402
|
+
[
|
|
403
|
+
n,
|
|
404
|
+
l,
|
|
405
|
+
a,
|
|
406
|
+
i,
|
|
407
|
+
d,
|
|
408
|
+
s,
|
|
409
|
+
c,
|
|
410
|
+
o,
|
|
411
|
+
r,
|
|
412
|
+
u,
|
|
413
|
+
h,
|
|
414
|
+
p,
|
|
415
|
+
f
|
|
416
|
+
]
|
|
417
|
+
);
|
|
418
|
+
}
|
|
419
|
+
const B = g.createContext(null);
|
|
420
|
+
function X() {
|
|
421
|
+
const e = g.useContext(B);
|
|
422
|
+
if (!e)
|
|
423
|
+
throw new Error(
|
|
424
|
+
"DataTablePagination sub-components must be used within <DataTablePagination>"
|
|
425
|
+
);
|
|
426
|
+
return e;
|
|
427
|
+
}
|
|
428
|
+
function Fe({
|
|
429
|
+
renderText: e,
|
|
430
|
+
className: n
|
|
431
|
+
}) {
|
|
432
|
+
const { info: l } = X(), { startRow: a, endRow: i, totalRows: o, pageIndex: r, pageSize: c } = l, d = e ? e({ startRow: a, endRow: i, totalRows: o, pageIndex: r, pageSize: c }) : o === 0 ? null : `${a}-${i} of ${o}`;
|
|
433
|
+
return d == null ? null : /* @__PURE__ */ t(
|
|
434
|
+
"span",
|
|
435
|
+
{
|
|
436
|
+
className: m("text-muted-foreground text-sm", n),
|
|
437
|
+
"data-slot": "data-table-pagination-row-count",
|
|
438
|
+
children: d
|
|
439
|
+
}
|
|
440
|
+
);
|
|
441
|
+
}
|
|
442
|
+
Fe.displayName = "DataTablePaginationRowCount";
|
|
443
|
+
function q({
|
|
444
|
+
ariaLabel: e = "Table pagination",
|
|
445
|
+
dataHook: n,
|
|
446
|
+
className: l
|
|
447
|
+
}) {
|
|
448
|
+
const { info: a } = X(), i = we({
|
|
449
|
+
page: a.currentPage,
|
|
450
|
+
totalPages: a.totalPages
|
|
451
|
+
});
|
|
452
|
+
return /* @__PURE__ */ t(
|
|
453
|
+
Se,
|
|
454
|
+
{
|
|
455
|
+
ariaLabel: e,
|
|
456
|
+
className: m("mx-0 w-auto justify-end", l),
|
|
457
|
+
dataHook: n ?? "pagination-nav",
|
|
458
|
+
children: /* @__PURE__ */ t(Ce, { children: i.map((o, r) => o === "previous" ? /* @__PURE__ */ t(I, { children: /* @__PURE__ */ t(
|
|
459
|
+
xe,
|
|
460
|
+
{
|
|
461
|
+
disabled: !a.canPrev,
|
|
462
|
+
onClick: () => a.previousPage()
|
|
463
|
+
}
|
|
464
|
+
) }, "previous") : o === "next" ? /* @__PURE__ */ t(I, { children: /* @__PURE__ */ t(
|
|
465
|
+
ke,
|
|
466
|
+
{
|
|
467
|
+
disabled: !a.canNext,
|
|
468
|
+
onClick: () => a.nextPage()
|
|
469
|
+
}
|
|
470
|
+
) }, "next") : o === "ellipsis" ? /* @__PURE__ */ t(I, { children: /* @__PURE__ */ t(Pe, {}) }, `ellipsis-${r}`) : /* @__PURE__ */ t(I, { children: /* @__PURE__ */ t(
|
|
471
|
+
Te,
|
|
472
|
+
{
|
|
473
|
+
isActive: o === a.currentPage,
|
|
474
|
+
page: o,
|
|
475
|
+
onClick: () => a.goToPage(o)
|
|
476
|
+
}
|
|
477
|
+
) }, o)) })
|
|
478
|
+
}
|
|
479
|
+
);
|
|
480
|
+
}
|
|
481
|
+
q.displayName = "DataTablePaginationNav";
|
|
482
|
+
function Me({
|
|
483
|
+
table: e,
|
|
484
|
+
dataHook: n,
|
|
485
|
+
showRowCount: l = !0,
|
|
486
|
+
renderRowCount: a,
|
|
487
|
+
trackingEl: i,
|
|
488
|
+
trackingLabel: o,
|
|
489
|
+
className: r,
|
|
490
|
+
ariaLabel: c = "Table pagination",
|
|
491
|
+
children: d
|
|
492
|
+
}) {
|
|
493
|
+
const s = $e(e), u = g.useMemo(
|
|
494
|
+
() => ({ info: s }),
|
|
495
|
+
[s]
|
|
496
|
+
), h = {
|
|
497
|
+
"data-hook": n,
|
|
498
|
+
"data-slot": "data-table-pagination",
|
|
499
|
+
"data-tracking-el": i,
|
|
500
|
+
"data-tracking-label": o
|
|
501
|
+
};
|
|
502
|
+
if (d)
|
|
503
|
+
return /* @__PURE__ */ t(B.Provider, { value: u, children: /* @__PURE__ */ t(
|
|
504
|
+
"div",
|
|
505
|
+
{
|
|
506
|
+
className: m("flex w-full items-center gap-4", r),
|
|
507
|
+
...h,
|
|
508
|
+
children: d
|
|
509
|
+
}
|
|
510
|
+
) });
|
|
511
|
+
const p = !l || a === null ? null : a ? a({
|
|
512
|
+
startRow: s.startRow,
|
|
513
|
+
endRow: s.endRow,
|
|
514
|
+
totalRows: s.totalRows,
|
|
515
|
+
pageIndex: s.pageIndex,
|
|
516
|
+
pageSize: s.pageSize
|
|
517
|
+
}) : s.totalRows === 0 ? null : `${s.startRow}-${s.endRow} of ${s.totalRows}`;
|
|
518
|
+
return /* @__PURE__ */ t(B.Provider, { value: u, children: /* @__PURE__ */ S(
|
|
519
|
+
"div",
|
|
520
|
+
{
|
|
521
|
+
className: m(
|
|
522
|
+
"flex w-full items-center gap-4",
|
|
523
|
+
p != null ? "justify-between" : "justify-end",
|
|
524
|
+
r
|
|
525
|
+
),
|
|
526
|
+
...h,
|
|
527
|
+
children: [
|
|
528
|
+
p != null && /* @__PURE__ */ t("span", { className: "text-muted-foreground text-sm", children: p }),
|
|
529
|
+
/* @__PURE__ */ t(
|
|
530
|
+
q,
|
|
531
|
+
{
|
|
532
|
+
ariaLabel: c,
|
|
533
|
+
dataHook: `${n}-nav`
|
|
534
|
+
}
|
|
535
|
+
)
|
|
536
|
+
]
|
|
537
|
+
}
|
|
538
|
+
) });
|
|
539
|
+
}
|
|
540
|
+
Me.displayName = "DataTablePagination";
|
|
541
|
+
function Be({
|
|
542
|
+
table: e,
|
|
543
|
+
dataHook: n,
|
|
544
|
+
trackingEl: l,
|
|
545
|
+
trackingLabel: a,
|
|
546
|
+
selectAllAriaLabel: i
|
|
547
|
+
}) {
|
|
548
|
+
return /* @__PURE__ */ t(
|
|
549
|
+
j,
|
|
550
|
+
{
|
|
551
|
+
"aria-label": i ?? "Select all",
|
|
552
|
+
checked: e.getIsAllPageRowsSelected() || e.getIsSomePageRowsSelected() && "indeterminate",
|
|
553
|
+
dataHook: n || "select-all-checkbox",
|
|
554
|
+
trackingEl: l,
|
|
555
|
+
trackingLabel: a,
|
|
556
|
+
onCheckedChange: (o) => e.toggleAllPageRowsSelected(!!o)
|
|
557
|
+
}
|
|
558
|
+
);
|
|
559
|
+
}
|
|
560
|
+
Be.displayName = "DataTableSelectAllCheckbox";
|
|
561
|
+
function He({
|
|
562
|
+
row: e,
|
|
563
|
+
dataHook: n,
|
|
564
|
+
trackingEl: l,
|
|
565
|
+
trackingLabel: a,
|
|
566
|
+
selectRowAriaLabel: i
|
|
567
|
+
}) {
|
|
568
|
+
return /* @__PURE__ */ t(
|
|
569
|
+
j,
|
|
570
|
+
{
|
|
571
|
+
"aria-label": i ?? "Select row",
|
|
572
|
+
checked: e.getIsSelected(),
|
|
573
|
+
dataHook: n || `select-row-${e.id}`,
|
|
574
|
+
disabled: !e.getCanSelect(),
|
|
575
|
+
trackingEl: l,
|
|
576
|
+
trackingLabel: a,
|
|
577
|
+
onCheckedChange: (o) => e.toggleSelected(!!o)
|
|
578
|
+
}
|
|
579
|
+
);
|
|
580
|
+
}
|
|
581
|
+
He.displayName = "DataTableSelectRowCheckbox";
|
|
582
|
+
const J = g.createContext(null);
|
|
583
|
+
function Ve() {
|
|
584
|
+
const e = g.useContext(J);
|
|
585
|
+
if (!e)
|
|
586
|
+
throw new Error(
|
|
587
|
+
"DataTableBulkActions components must be used within <DataTableBulkActions>"
|
|
588
|
+
);
|
|
589
|
+
return e;
|
|
590
|
+
}
|
|
591
|
+
function Ee({
|
|
592
|
+
table: e,
|
|
593
|
+
dataHook: n,
|
|
594
|
+
trackingEl: l,
|
|
595
|
+
trackingLabel: a,
|
|
596
|
+
className: i,
|
|
597
|
+
children: o
|
|
598
|
+
}) {
|
|
599
|
+
const r = e.getFilteredSelectedRowModel().rows.length, c = e.getRowCount(), d = g.useMemo(
|
|
600
|
+
() => ({ selectedCount: r, totalCount: c }),
|
|
601
|
+
[r, c]
|
|
602
|
+
);
|
|
603
|
+
return r === 0 ? null : /* @__PURE__ */ t(J.Provider, { value: d, children: /* @__PURE__ */ t(
|
|
604
|
+
"div",
|
|
605
|
+
{
|
|
606
|
+
className: m("flex items-center gap-2.5", i),
|
|
607
|
+
"data-hook": n,
|
|
608
|
+
"data-slot": "data-table-bulk-actions",
|
|
609
|
+
"data-tracking-el": l ?? "data-table-bulk-actions",
|
|
610
|
+
"data-tracking-label": a,
|
|
611
|
+
children: o
|
|
612
|
+
}
|
|
613
|
+
) });
|
|
614
|
+
}
|
|
615
|
+
Ee.displayName = "DataTableBulkActions";
|
|
616
|
+
function je({
|
|
617
|
+
dataHook: e = "data-table-bulk-actions-summary",
|
|
618
|
+
className: n,
|
|
619
|
+
children: l
|
|
620
|
+
}) {
|
|
621
|
+
const { selectedCount: a, totalCount: i } = Ve();
|
|
622
|
+
let o;
|
|
623
|
+
return typeof l == "function" ? o = l({ selectedCount: a, totalCount: i }) : l != null ? o = l : o = `${a} of ${i} row(s) selected.`, /* @__PURE__ */ t(
|
|
624
|
+
ye,
|
|
625
|
+
{
|
|
626
|
+
asChild: !0,
|
|
627
|
+
className: m("min-w-0", n),
|
|
628
|
+
dataHook: e,
|
|
629
|
+
children: /* @__PURE__ */ t("span", { "data-slot": "data-table-bulk-actions-summary", role: "status", children: o })
|
|
630
|
+
}
|
|
631
|
+
);
|
|
632
|
+
}
|
|
633
|
+
je.displayName = "DataTableBulkActionsSummary";
|
|
634
|
+
function Ge({
|
|
635
|
+
dataHook: e = "data-table-bulk-actions-actions",
|
|
636
|
+
className: n,
|
|
637
|
+
children: l
|
|
638
|
+
}) {
|
|
639
|
+
return /* @__PURE__ */ t(
|
|
640
|
+
"div",
|
|
641
|
+
{
|
|
642
|
+
className: m("flex shrink-0 items-center gap-2", n),
|
|
643
|
+
"data-hook": e,
|
|
644
|
+
"data-slot": "data-table-bulk-actions-actions",
|
|
645
|
+
children: l
|
|
646
|
+
}
|
|
647
|
+
);
|
|
648
|
+
}
|
|
649
|
+
Ge.displayName = "DataTableBulkActionsActions";
|
|
650
|
+
function Le({
|
|
651
|
+
dataHook: e,
|
|
652
|
+
className: n,
|
|
653
|
+
children: l
|
|
654
|
+
}) {
|
|
655
|
+
return /* @__PURE__ */ t(
|
|
656
|
+
"div",
|
|
657
|
+
{
|
|
658
|
+
className: m(
|
|
659
|
+
"flex flex-col gap-3 py-4 sm:flex-row sm:items-center",
|
|
660
|
+
n
|
|
661
|
+
),
|
|
662
|
+
"data-hook": e,
|
|
663
|
+
"data-slot": "data-table-toolbar",
|
|
664
|
+
children: l
|
|
665
|
+
}
|
|
666
|
+
);
|
|
667
|
+
}
|
|
668
|
+
Le.displayName = "DataTableToolbar";
|
|
669
|
+
function Ue({
|
|
670
|
+
className: e,
|
|
671
|
+
children: n
|
|
672
|
+
}) {
|
|
673
|
+
return /* @__PURE__ */ t(
|
|
674
|
+
"div",
|
|
675
|
+
{
|
|
676
|
+
className: m(
|
|
677
|
+
"flex w-full min-w-0 items-center gap-2 sm:w-auto sm:flex-1",
|
|
678
|
+
e
|
|
679
|
+
),
|
|
680
|
+
"data-slot": "data-table-toolbar-left",
|
|
681
|
+
children: n
|
|
682
|
+
}
|
|
683
|
+
);
|
|
684
|
+
}
|
|
685
|
+
Ue.displayName = "DataTableToolbarLeft";
|
|
686
|
+
function We({
|
|
687
|
+
className: e,
|
|
688
|
+
children: n
|
|
689
|
+
}) {
|
|
690
|
+
return /* @__PURE__ */ t(
|
|
691
|
+
"div",
|
|
692
|
+
{
|
|
693
|
+
className: m(
|
|
694
|
+
"flex w-full items-center justify-end gap-2 sm:w-auto",
|
|
695
|
+
e
|
|
696
|
+
),
|
|
697
|
+
"data-slot": "data-table-toolbar-right",
|
|
698
|
+
children: n
|
|
699
|
+
}
|
|
700
|
+
);
|
|
701
|
+
}
|
|
702
|
+
We.displayName = "DataTableToolbarRight";
|
|
703
|
+
export {
|
|
704
|
+
Ne as DataTable,
|
|
705
|
+
Ee as DataTableBulkActions,
|
|
706
|
+
Ge as DataTableBulkActionsActions,
|
|
707
|
+
je as DataTableBulkActionsSummary,
|
|
708
|
+
Ae as DataTableColumnHeader,
|
|
709
|
+
Me as DataTablePagination,
|
|
710
|
+
q as DataTablePaginationNav,
|
|
711
|
+
Fe as DataTablePaginationRowCount,
|
|
712
|
+
Ie as DataTableSearch,
|
|
713
|
+
Be as DataTableSelectAllCheckbox,
|
|
714
|
+
He as DataTableSelectRowCheckbox,
|
|
715
|
+
Le as DataTableToolbar,
|
|
716
|
+
Ue as DataTableToolbarLeft,
|
|
717
|
+
We as DataTableToolbarRight,
|
|
718
|
+
ze as VirtualizedDataTable,
|
|
719
|
+
nt as useDataTable,
|
|
720
|
+
Ve as useDataTableBulkActionsContext
|
|
721
|
+
};
|