@scalio-cloud/ui 0.110.0 → 0.111.1

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.
Files changed (62) hide show
  1. package/auth.css +8 -6
  2. package/dist/app-kit/ScalioAppProviders.d.ts +20 -0
  3. package/dist/app-kit/ScalioAppProviders.d.ts.map +1 -0
  4. package/dist/app-kit/ScalioDrawer.d.ts +28 -0
  5. package/dist/app-kit/ScalioDrawer.d.ts.map +1 -0
  6. package/dist/app-kit/ScalioEmptyState.d.ts +14 -0
  7. package/dist/app-kit/ScalioEmptyState.d.ts.map +1 -0
  8. package/dist/app-kit/ScalioErrorBoundary.d.ts +27 -0
  9. package/dist/app-kit/ScalioErrorBoundary.d.ts.map +1 -0
  10. package/dist/app-kit/ScalioFormDialog.d.ts +33 -0
  11. package/dist/app-kit/ScalioFormDialog.d.ts.map +1 -0
  12. package/dist/app-kit/ScalioFormField.d.ts +36 -0
  13. package/dist/app-kit/ScalioFormField.d.ts.map +1 -0
  14. package/dist/app-kit/ScalioInputs.d.ts +80 -0
  15. package/dist/app-kit/ScalioInputs.d.ts.map +1 -0
  16. package/dist/app-kit/ScalioLayout.d.ts +27 -0
  17. package/dist/app-kit/ScalioLayout.d.ts.map +1 -0
  18. package/dist/app-kit/ScalioResultBadge.d.ts +19 -0
  19. package/dist/app-kit/ScalioResultBadge.d.ts.map +1 -0
  20. package/dist/app-kit/ScalioTenantSettings.d.ts +24 -0
  21. package/dist/app-kit/ScalioTenantSettings.d.ts.map +1 -0
  22. package/dist/app-kit/ScalioUtilities.d.ts +33 -0
  23. package/dist/app-kit/ScalioUtilities.d.ts.map +1 -0
  24. package/dist/app-kit/_uiReact.d.ts +64 -3
  25. package/dist/app-kit/_uiReact.d.ts.map +1 -1
  26. package/dist/app-kit/index.d.ts +11 -0
  27. package/dist/app-kit/index.d.ts.map +1 -1
  28. package/dist/app-kit/index.js +1164 -2
  29. package/dist/app-kit/index.js.map +1 -1
  30. package/dist/app-kit/index.mjs +1144 -2
  31. package/dist/app-kit/index.mjs.map +1 -1
  32. package/dist/{chunk-A7O3P4YV.mjs → chunk-WBI44QWN.mjs} +92 -1
  33. package/dist/chunk-WBI44QWN.mjs.map +1 -0
  34. package/dist/config/index.d.ts +14 -0
  35. package/dist/config/index.d.ts.map +1 -1
  36. package/dist/config/index.js +17 -0
  37. package/dist/config/index.js.map +1 -1
  38. package/dist/config/index.mjs +15 -0
  39. package/dist/config/index.mjs.map +1 -1
  40. package/dist/core/format.d.ts +36 -0
  41. package/dist/core/format.d.ts.map +1 -0
  42. package/dist/core/index.d.ts +1 -0
  43. package/dist/core/index.d.ts.map +1 -1
  44. package/dist/core/index.js +97 -0
  45. package/dist/core/index.js.map +1 -1
  46. package/dist/core/index.mjs +13 -1
  47. package/dist/data-table/ScalioDataTable.d.ts +12 -0
  48. package/dist/data-table/ScalioDataTable.d.ts.map +1 -0
  49. package/dist/data-table/helpers.d.ts +40 -0
  50. package/dist/data-table/helpers.d.ts.map +1 -0
  51. package/dist/data-table/index.d.ts +8 -0
  52. package/dist/data-table/index.d.ts.map +1 -0
  53. package/dist/data-table/index.js +1040 -0
  54. package/dist/data-table/index.js.map +1 -0
  55. package/dist/data-table/index.mjs +1008 -0
  56. package/dist/data-table/index.mjs.map +1 -0
  57. package/dist/data-table/labels.d.ts +5 -0
  58. package/dist/data-table/labels.d.ts.map +1 -0
  59. package/dist/data-table/types.d.ts +178 -0
  60. package/dist/data-table/types.d.ts.map +1 -0
  61. package/package.json +7 -1
  62. package/dist/chunk-A7O3P4YV.mjs.map +0 -1
@@ -0,0 +1,1008 @@
1
+ // src/data-table/ScalioDataTable.tsx
2
+ import React, { useEffect, useMemo, useRef, useState } from "react";
3
+ import {
4
+ AlertCircle,
5
+ ArrowDown,
6
+ ArrowUp,
7
+ ArrowUpDown,
8
+ ChevronDown,
9
+ ChevronLeft,
10
+ ChevronRight,
11
+ ChevronsLeft,
12
+ ChevronsRight,
13
+ Columns3,
14
+ Download,
15
+ RefreshCw,
16
+ Rows3,
17
+ Search,
18
+ X
19
+ } from "lucide-react";
20
+
21
+ // src/data-table/helpers.ts
22
+ function resolveCellValue(row, column) {
23
+ if (!column.accessor) return void 0;
24
+ if (typeof column.accessor === "function") return column.accessor(row);
25
+ return row[column.accessor];
26
+ }
27
+ function resolveColumnLabel(column) {
28
+ if (column.label) return column.label;
29
+ if (typeof column.header === "string") return column.header;
30
+ return column.id;
31
+ }
32
+ function filterRows(rows, columns, search, filterValues, filters = []) {
33
+ const needle = search.trim().toLowerCase();
34
+ const activeFacets = filters.filter((f) => {
35
+ const selected = filterValues[f.id];
36
+ return Array.isArray(selected) && selected.length > 0;
37
+ });
38
+ if (!needle && activeFacets.length === 0) return rows;
39
+ const searchableCols = columns.filter((col) => {
40
+ if (col.searchable === false) return false;
41
+ return Boolean(col.searchValue || col.accessor);
42
+ });
43
+ return rows.filter((row) => {
44
+ for (const facet of activeFacets) {
45
+ const selected = filterValues[facet.id] ?? [];
46
+ if (facet.match) {
47
+ if (!facet.match(row, selected)) return false;
48
+ } else {
49
+ const raw = row[facet.id];
50
+ if (!selected.includes(String(raw ?? ""))) return false;
51
+ }
52
+ }
53
+ if (!needle) return true;
54
+ for (const col of searchableCols) {
55
+ const text = col.searchValue ? col.searchValue(row) : String(resolveCellValue(row, col) ?? "");
56
+ if (text.toLowerCase().includes(needle)) return true;
57
+ }
58
+ return false;
59
+ });
60
+ }
61
+ function compareUnknown(a, b) {
62
+ const aEmpty = a === null || a === void 0 || a === "";
63
+ const bEmpty = b === null || b === void 0 || b === "";
64
+ if (aEmpty && bEmpty) return 0;
65
+ if (aEmpty) return 1;
66
+ if (bEmpty) return -1;
67
+ if (typeof a === "number" && typeof b === "number") return a - b;
68
+ if (typeof a === "boolean" && typeof b === "boolean") return Number(a) - Number(b);
69
+ if (a instanceof Date && b instanceof Date) return a.getTime() - b.getTime();
70
+ return String(a).localeCompare(String(b), void 0, { numeric: true, sensitivity: "base" });
71
+ }
72
+ function sortRows(rows, columns, sort) {
73
+ if (!sort) return rows;
74
+ const col = columns.find((c) => c.id === sort.id);
75
+ if (!col) return rows;
76
+ const dir = sort.desc ? -1 : 1;
77
+ return [...rows].sort((a, b) => {
78
+ const cmp = col.sortFn ? col.sortFn(a, b) : compareUnknown(resolveCellValue(a, col), resolveCellValue(b, col));
79
+ return cmp * dir;
80
+ });
81
+ }
82
+ function paginateRows(rows, page, pageSize) {
83
+ const safeSize = Math.max(1, pageSize);
84
+ const safePage = Math.max(1, page);
85
+ const start = (safePage - 1) * safeSize;
86
+ return rows.slice(start, start + safeSize);
87
+ }
88
+ var FORMULA_PREFIX_RE = /^[=+\-@\t\r]/;
89
+ function escapeCsvCell(value) {
90
+ const raw = value === null || value === void 0 ? "" : String(value);
91
+ const safe = FORMULA_PREFIX_RE.test(raw) ? `'${raw}` : raw;
92
+ if (/[",\r\n]/.test(safe)) {
93
+ return `"${safe.replace(/"/g, '""')}"`;
94
+ }
95
+ return safe;
96
+ }
97
+ function buildCsv(rows, columns) {
98
+ const exportCols = columns.filter((c) => c.csvValue !== false);
99
+ const headerLine = exportCols.map((c) => escapeCsvCell(resolveColumnLabel(c))).join(",");
100
+ const bodyLines = rows.map(
101
+ (row) => exportCols.map((col) => {
102
+ const val = typeof col.csvValue === "function" ? col.csvValue(row) : resolveCellValue(row, col);
103
+ return escapeCsvCell(val);
104
+ }).join(",")
105
+ );
106
+ return `\uFEFF${[headerLine, ...bodyLines].join("\r\n")}`;
107
+ }
108
+ function loadTablePrefs(storageKey) {
109
+ if (!storageKey || typeof window === "undefined") return {};
110
+ try {
111
+ const raw = window.localStorage.getItem(storageKey);
112
+ if (!raw) return {};
113
+ const parsed = JSON.parse(raw);
114
+ return parsed && typeof parsed === "object" ? parsed : {};
115
+ } catch {
116
+ return {};
117
+ }
118
+ }
119
+ function saveTablePrefs(storageKey, prefs) {
120
+ if (!storageKey || typeof window === "undefined") return;
121
+ try {
122
+ window.localStorage.setItem(storageKey, JSON.stringify(prefs));
123
+ } catch {
124
+ }
125
+ }
126
+
127
+ // src/data-table/labels.ts
128
+ var DEFAULT_DATA_TABLE_LABELS = {
129
+ en: {
130
+ searchPlaceholder: "Search...",
131
+ clearSearch: "Clear search",
132
+ columns: "Columns",
133
+ showAllColumns: "Show all",
134
+ density: "Density",
135
+ densityCompact: "Compact",
136
+ densityComfortable: "Comfortable",
137
+ densitySpacious: "Spacious",
138
+ exportCsv: "Export CSV",
139
+ refresh: "Refresh",
140
+ filtersReset: "Reset filters",
141
+ selectedCount: "{count} selected",
142
+ clearSelection: "Clear selection",
143
+ selectAllRows: "Select all rows on page",
144
+ selectRow: "Select row",
145
+ expandRow: "Expand row",
146
+ collapseRow: "Collapse row",
147
+ emptyTitle: "No entries yet",
148
+ emptyDescription: "There is nothing to display right now.",
149
+ noMatchesTitle: "No matching entries",
150
+ noMatchesDescription: "Adjust or reset your search and filters.",
151
+ errorTitle: "Could not load data",
152
+ retry: "Try again",
153
+ rowsPerPage: "Rows per page",
154
+ pageOf: "Page {page} of {pages}",
155
+ rangeOf: "{start}\u2013{end} of {total}",
156
+ previousPage: "Previous page",
157
+ nextPage: "Next page",
158
+ firstPage: "First page",
159
+ lastPage: "Last page"
160
+ },
161
+ de: {
162
+ searchPlaceholder: "Suchen...",
163
+ clearSearch: "Suche leeren",
164
+ columns: "Spalten",
165
+ showAllColumns: "Alle anzeigen",
166
+ density: "Dichte",
167
+ densityCompact: "Kompakt",
168
+ densityComfortable: "Standard",
169
+ densitySpacious: "Grossz\xFCgig",
170
+ exportCsv: "CSV exportieren",
171
+ refresh: "Aktualisieren",
172
+ filtersReset: "Filter zur\xFCcksetzen",
173
+ selectedCount: "{count} ausgew\xE4hlt",
174
+ clearSelection: "Auswahl aufheben",
175
+ selectAllRows: "Alle Zeilen auf dieser Seite ausw\xE4hlen",
176
+ selectRow: "Zeile ausw\xE4hlen",
177
+ expandRow: "Zeile aufklappen",
178
+ collapseRow: "Zeile zuklappen",
179
+ emptyTitle: "Noch keine Eintr\xE4ge",
180
+ emptyDescription: "Aktuell gibt es nichts anzuzeigen.",
181
+ noMatchesTitle: "Keine passenden Eintr\xE4ge",
182
+ noMatchesDescription: "Suche oder Filter anpassen oder zur\xFCcksetzen.",
183
+ errorTitle: "Daten konnten nicht geladen werden",
184
+ retry: "Erneut versuchen",
185
+ rowsPerPage: "Zeilen pro Seite",
186
+ pageOf: "Seite {page} von {pages}",
187
+ rangeOf: "{start}\u2013{end} von {total}",
188
+ previousPage: "Vorherige Seite",
189
+ nextPage: "N\xE4chste Seite",
190
+ firstPage: "Erste Seite",
191
+ lastPage: "Letzte Seite"
192
+ }
193
+ };
194
+ function interpolateLabel(template, vars) {
195
+ let out = template;
196
+ for (const [k, v] of Object.entries(vars)) {
197
+ out = out.split(`{${k}}`).join(String(v));
198
+ }
199
+ return out;
200
+ }
201
+
202
+ // src/data-table/ScalioDataTable.tsx
203
+ import { jsx, jsxs } from "react/jsx-runtime";
204
+ var DENSITY_CELL_CLASS = {
205
+ compact: "px-2.5 py-1.5 text-xs",
206
+ comfortable: "px-3 py-2.5 text-sm",
207
+ spacious: "px-4 py-3.5 text-sm"
208
+ };
209
+ var ALIGN_CLASS = {
210
+ left: "text-left",
211
+ center: "text-center",
212
+ right: "text-right"
213
+ };
214
+ function triggerCsvDownload(csv, filename) {
215
+ if (typeof window === "undefined" || typeof document === "undefined") return;
216
+ const blob = new Blob([csv], { type: "text/csv;charset=utf-8;" });
217
+ const url = URL.createObjectURL(blob);
218
+ const a = document.createElement("a");
219
+ a.href = url;
220
+ a.download = filename.endsWith(".csv") ? filename : `${filename}.csv`;
221
+ document.body.appendChild(a);
222
+ a.click();
223
+ document.body.removeChild(a);
224
+ URL.revokeObjectURL(url);
225
+ }
226
+ function ScalioDataTable({
227
+ data,
228
+ columns,
229
+ getRowId,
230
+ manual = false,
231
+ totalCount,
232
+ sort: controlledSort,
233
+ defaultSort = null,
234
+ onSortChange,
235
+ page: controlledPage,
236
+ defaultPage = 1,
237
+ onPageChange,
238
+ pageSize: controlledPageSize,
239
+ defaultPageSize = 25,
240
+ pageSizeOptions = [10, 25, 50, 100],
241
+ onPageSizeChange,
242
+ paginate = true,
243
+ searchable = true,
244
+ search: controlledSearch,
245
+ onSearchChange,
246
+ searchPlaceholder,
247
+ filters = [],
248
+ filterValues: controlledFilterValues,
249
+ onFilterChange,
250
+ selectable = false,
251
+ selectedIds: controlledSelectedIds,
252
+ onSelectionChange,
253
+ bulkActions = [],
254
+ renderExpandedRow,
255
+ onRowClick,
256
+ rowClassName,
257
+ exportCsv = false,
258
+ columnChooser = true,
259
+ densityToggle = true,
260
+ defaultDensity = "comfortable",
261
+ stickyHeader = true,
262
+ storageKey,
263
+ onRefresh,
264
+ refreshing = false,
265
+ toolbarActions,
266
+ loading = false,
267
+ loadingRows = 5,
268
+ error = null,
269
+ onRetry,
270
+ emptyTitle,
271
+ emptyDescription,
272
+ emptyAction,
273
+ lang = "en",
274
+ labels: labelOverrides,
275
+ testId = "scalio-data-table",
276
+ className = ""
277
+ }) {
278
+ const L = { ...DEFAULT_DATA_TABLE_LABELS[lang], ...labelOverrides };
279
+ const initialPrefs = useMemo(() => loadTablePrefs(storageKey), [storageKey]);
280
+ const [internalSort, setInternalSort] = useState(
281
+ initialPrefs.sort !== void 0 ? initialPrefs.sort : defaultSort
282
+ );
283
+ const [internalPage, setInternalPage] = useState(defaultPage);
284
+ const [internalPageSize, setInternalPageSize] = useState(
285
+ initialPrefs.pageSize ?? defaultPageSize
286
+ );
287
+ const [internalSearch, setInternalSearch] = useState("");
288
+ const [internalFilterValues, setInternalFilterValues] = useState({});
289
+ const [internalSelectedIds, setInternalSelectedIds] = useState([]);
290
+ const [expandedIds, setExpandedIds] = useState(/* @__PURE__ */ new Set());
291
+ const [density, setDensity] = useState(initialPrefs.density ?? defaultDensity);
292
+ const [hiddenCols, setHiddenCols] = useState(() => {
293
+ if (initialPrefs.hiddenColumns) return new Set(initialPrefs.hiddenColumns);
294
+ return new Set(columns.filter((c) => c.defaultHidden).map((c) => c.id));
295
+ });
296
+ const [openMenu, setOpenMenu] = useState(null);
297
+ const [bulkBusy, setBulkBusy] = useState(null);
298
+ const menuContainerRef = useRef(null);
299
+ useEffect(() => {
300
+ if (!openMenu) return;
301
+ const onDocClick = (e) => {
302
+ if (menuContainerRef.current && !menuContainerRef.current.contains(e.target)) {
303
+ setOpenMenu(null);
304
+ }
305
+ };
306
+ const onKey = (e) => {
307
+ if (e.key === "Escape") setOpenMenu(null);
308
+ };
309
+ document.addEventListener("mousedown", onDocClick);
310
+ document.addEventListener("keydown", onKey);
311
+ return () => {
312
+ document.removeEventListener("mousedown", onDocClick);
313
+ document.removeEventListener("keydown", onKey);
314
+ };
315
+ }, [openMenu]);
316
+ const sort = controlledSort !== void 0 ? controlledSort : internalSort;
317
+ const page = controlledPage !== void 0 ? controlledPage : internalPage;
318
+ const pageSize = controlledPageSize !== void 0 ? controlledPageSize : internalPageSize;
319
+ const search = controlledSearch !== void 0 ? controlledSearch : internalSearch;
320
+ const filterValues = controlledFilterValues !== void 0 ? controlledFilterValues : internalFilterValues;
321
+ const selectedIds = controlledSelectedIds !== void 0 ? controlledSelectedIds : internalSelectedIds;
322
+ useEffect(() => {
323
+ if (!storageKey) return;
324
+ saveTablePrefs(storageKey, {
325
+ hiddenColumns: Array.from(hiddenCols),
326
+ density,
327
+ pageSize,
328
+ sort
329
+ });
330
+ }, [storageKey, hiddenCols, density, pageSize, sort]);
331
+ const visibleColumns = useMemo(
332
+ () => columns.filter((col) => !hiddenCols.has(col.id)),
333
+ [columns, hiddenCols]
334
+ );
335
+ const processedRows = useMemo(() => {
336
+ if (manual) return data;
337
+ const filtered = filterRows(data, columns, search, filterValues, filters);
338
+ return sortRows(filtered, columns, sort);
339
+ }, [manual, data, columns, search, filterValues, filters, sort]);
340
+ const effectiveTotal = manual ? totalCount ?? data.length : processedRows.length;
341
+ const totalPages = paginate ? Math.max(1, Math.ceil(effectiveTotal / Math.max(1, pageSize))) : 1;
342
+ const clampedPage = Math.min(Math.max(1, page), totalPages);
343
+ const pageRows = useMemo(() => {
344
+ if (!paginate || manual) return processedRows;
345
+ return paginateRows(processedRows, clampedPage, pageSize);
346
+ }, [paginate, manual, processedRows, clampedPage, pageSize]);
347
+ const selectedSet = useMemo(() => new Set(selectedIds), [selectedIds]);
348
+ const pageRowIds = useMemo(
349
+ () => pageRows.map((row, idx) => getRowId(row, idx)),
350
+ [pageRows, getRowId]
351
+ );
352
+ const allPageSelected = pageRowIds.length > 0 && pageRowIds.every((id) => selectedSet.has(id));
353
+ const somePageSelected = pageRowIds.some((id) => selectedSet.has(id)) && !allPageSelected;
354
+ const selectedRows = useMemo(() => {
355
+ const out = [];
356
+ for (let i = 0; i < data.length; i += 1) {
357
+ const row = data[i];
358
+ if (row !== void 0 && selectedSet.has(getRowId(row, i))) {
359
+ out.push(row);
360
+ }
361
+ }
362
+ return out;
363
+ }, [data, selectedSet, getRowId]);
364
+ const setSort = (next) => {
365
+ if (controlledSort === void 0) setInternalSort(next);
366
+ onSortChange?.(next);
367
+ };
368
+ const setPage = (next) => {
369
+ const safe = Math.min(Math.max(1, next), totalPages);
370
+ if (controlledPage === void 0) setInternalPage(safe);
371
+ onPageChange?.(safe);
372
+ };
373
+ const setPageSize = (next) => {
374
+ if (controlledPageSize === void 0) setInternalPageSize(next);
375
+ onPageSizeChange?.(next);
376
+ setPage(1);
377
+ };
378
+ const setSearch = (next) => {
379
+ if (controlledSearch === void 0) setInternalSearch(next);
380
+ onSearchChange?.(next);
381
+ if (clampedPage !== 1) setPage(1);
382
+ };
383
+ const updateFilters = (next) => {
384
+ if (controlledFilterValues === void 0) setInternalFilterValues(next);
385
+ onFilterChange?.(next);
386
+ if (clampedPage !== 1) setPage(1);
387
+ };
388
+ const updateSelection = (nextIds) => {
389
+ if (controlledSelectedIds === void 0) setInternalSelectedIds(nextIds);
390
+ if (onSelectionChange) {
391
+ const idSet = new Set(nextIds);
392
+ const rows = data.filter((r, i) => idSet.has(getRowId(r, i)));
393
+ onSelectionChange(nextIds, rows);
394
+ }
395
+ };
396
+ const toggleSort = (col) => {
397
+ if (!col.sortable) return;
398
+ if (!sort || sort.id !== col.id) {
399
+ setSort({ id: col.id, desc: false });
400
+ } else if (!sort.desc) {
401
+ setSort({ id: col.id, desc: true });
402
+ } else {
403
+ setSort(null);
404
+ }
405
+ };
406
+ const toggleSelectAllPage = () => {
407
+ if (allPageSelected) {
408
+ const pageSet = new Set(pageRowIds);
409
+ updateSelection(selectedIds.filter((id) => !pageSet.has(id)));
410
+ } else {
411
+ const merged = new Set(selectedIds);
412
+ for (const id of pageRowIds) merged.add(id);
413
+ updateSelection(Array.from(merged));
414
+ }
415
+ };
416
+ const toggleSelectRow = (id) => {
417
+ if (selectedSet.has(id)) {
418
+ updateSelection(selectedIds.filter((x) => x !== id));
419
+ } else {
420
+ updateSelection([...selectedIds, id]);
421
+ }
422
+ };
423
+ const toggleExpandRow = (id) => {
424
+ setExpandedIds((prev) => {
425
+ const next = new Set(prev);
426
+ if (next.has(id)) next.delete(id);
427
+ else next.add(id);
428
+ return next;
429
+ });
430
+ };
431
+ const toggleColumn = (id) => {
432
+ setHiddenCols((prev) => {
433
+ const next = new Set(prev);
434
+ if (next.has(id)) {
435
+ next.delete(id);
436
+ } else if (visibleColumns.length > 1) {
437
+ next.add(id);
438
+ }
439
+ return next;
440
+ });
441
+ };
442
+ const toggleFacetValue = (facetId, optionValue) => {
443
+ const current = filterValues[facetId] ?? [];
444
+ const exists = current.includes(optionValue);
445
+ const nextFacet = exists ? current.filter((v) => v !== optionValue) : [...current, optionValue];
446
+ updateFilters({ ...filterValues, [facetId]: nextFacet });
447
+ };
448
+ const hasActiveFilters = search.trim().length > 0 || Object.values(filterValues).some((vals) => Array.isArray(vals) && vals.length > 0);
449
+ const resetAllFilters = () => {
450
+ setSearch("");
451
+ updateFilters({});
452
+ };
453
+ const handleExportCsv = () => {
454
+ const csv = buildCsv(processedRows, visibleColumns);
455
+ const filename = typeof exportCsv === "string" ? exportCsv : "export.csv";
456
+ triggerCsvDownload(csv, filename);
457
+ };
458
+ const cellPadding = DENSITY_CELL_CLASS[density];
459
+ const extraColCount = (selectable ? 1 : 0) + (renderExpandedRow ? 1 : 0);
460
+ const totalColSpan = visibleColumns.length + extraColCount;
461
+ const rangeStart = effectiveTotal === 0 ? 0 : (clampedPage - 1) * pageSize + 1;
462
+ const rangeEnd = paginate ? Math.min(clampedPage * pageSize, effectiveTotal) : effectiveTotal;
463
+ const pinClass = (col, isHeader) => {
464
+ if (col.pinned === "left") {
465
+ return `sticky left-0 ${isHeader ? "z-20 bg-muted" : "z-10 bg-background"} shadow-[1px_0_0_0_hsl(var(--border))]`;
466
+ }
467
+ if (col.pinned === "right") {
468
+ return `sticky right-0 ${isHeader ? "z-20 bg-muted" : "z-10 bg-background"} shadow-[-1px_0_0_0_hsl(var(--border))]`;
469
+ }
470
+ return "";
471
+ };
472
+ return /* @__PURE__ */ jsxs("div", { className: `space-y-3 ${className}`.trim(), "data-testid": testId, ref: menuContainerRef, children: [
473
+ (searchable || filters.length > 0 || columnChooser || densityToggle || exportCsv || onRefresh || toolbarActions) && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2", "data-testid": `${testId}-toolbar`, children: [
474
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2 flex-1 min-w-[200px]", children: [
475
+ searchable && /* @__PURE__ */ jsxs("div", { className: "relative flex-1 max-w-xs min-w-[180px]", children: [
476
+ /* @__PURE__ */ jsx(Search, { className: "w-3.5 h-3.5 text-muted-foreground absolute left-2.5 top-1/2 -translate-y-1/2 pointer-events-none" }),
477
+ /* @__PURE__ */ jsx(
478
+ "input",
479
+ {
480
+ type: "search",
481
+ value: search,
482
+ onChange: (e) => setSearch(e.target.value),
483
+ placeholder: searchPlaceholder ?? L.searchPlaceholder,
484
+ "aria-label": searchPlaceholder ?? L.searchPlaceholder,
485
+ "data-testid": `${testId}-search`,
486
+ className: "w-full h-9 pl-8 pr-7 text-sm bg-background text-foreground border border-input rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
487
+ }
488
+ ),
489
+ search && /* @__PURE__ */ jsx(
490
+ "button",
491
+ {
492
+ type: "button",
493
+ onClick: () => setSearch(""),
494
+ "aria-label": L.clearSearch,
495
+ "data-testid": `${testId}-search-clear`,
496
+ className: "absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",
497
+ children: /* @__PURE__ */ jsx(X, { className: "w-3.5 h-3.5" })
498
+ }
499
+ )
500
+ ] }),
501
+ filters.map((facet) => {
502
+ const active = filterValues[facet.id] ?? [];
503
+ const isOpen = openMenu === `facet:${facet.id}`;
504
+ return /* @__PURE__ */ jsxs("div", { className: "relative", children: [
505
+ /* @__PURE__ */ jsxs(
506
+ "button",
507
+ {
508
+ type: "button",
509
+ onClick: () => setOpenMenu(isOpen ? null : `facet:${facet.id}`),
510
+ "aria-expanded": isOpen,
511
+ "data-testid": `${testId}-filter-${facet.id}`,
512
+ className: `h-9 px-3 text-xs font-medium rounded-sm border inline-flex items-center gap-1.5 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ${active.length > 0 ? "bg-primary/10 border-primary text-primary" : "bg-background border-input text-foreground hover:bg-muted"}`,
513
+ children: [
514
+ /* @__PURE__ */ jsx("span", { children: facet.label }),
515
+ active.length > 0 && /* @__PURE__ */ jsx("span", { className: "px-1.5 py-0.5 text-[10px] font-bold rounded-full bg-primary text-primary-foreground", children: active.length }),
516
+ /* @__PURE__ */ jsx(ChevronDown, { className: "w-3.5 h-3.5 opacity-60" })
517
+ ]
518
+ }
519
+ ),
520
+ isOpen && /* @__PURE__ */ jsx(
521
+ "div",
522
+ {
523
+ className: "absolute left-0 mt-1 w-56 rounded-sm border border-border bg-popover text-popover-foreground shadow-md p-1.5 z-30 space-y-0.5",
524
+ "data-testid": `${testId}-filter-menu-${facet.id}`,
525
+ children: facet.options.map((opt) => {
526
+ const checked = active.includes(opt.value);
527
+ return /* @__PURE__ */ jsxs(
528
+ "label",
529
+ {
530
+ className: "flex items-center justify-between gap-2 px-2 py-1.5 text-xs rounded-sm hover:bg-muted cursor-pointer",
531
+ children: [
532
+ /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-2", children: [
533
+ /* @__PURE__ */ jsx(
534
+ "input",
535
+ {
536
+ type: "checkbox",
537
+ checked,
538
+ onChange: () => toggleFacetValue(facet.id, opt.value),
539
+ className: "rounded border-input accent-primary"
540
+ }
541
+ ),
542
+ /* @__PURE__ */ jsx("span", { children: opt.label })
543
+ ] }),
544
+ opt.count !== void 0 && /* @__PURE__ */ jsx("span", { className: "text-muted-foreground tabular-nums", children: opt.count })
545
+ ]
546
+ },
547
+ opt.value
548
+ );
549
+ })
550
+ }
551
+ )
552
+ ] }, facet.id);
553
+ }),
554
+ hasActiveFilters && /* @__PURE__ */ jsxs(
555
+ "button",
556
+ {
557
+ type: "button",
558
+ onClick: resetAllFilters,
559
+ "data-testid": `${testId}-reset-filters`,
560
+ className: "h-9 px-2.5 text-xs text-muted-foreground hover:text-foreground inline-flex items-center gap-1",
561
+ children: [
562
+ /* @__PURE__ */ jsx(X, { className: "w-3.5 h-3.5" }),
563
+ L.filtersReset
564
+ ]
565
+ }
566
+ )
567
+ ] }),
568
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
569
+ toolbarActions,
570
+ exportCsv && /* @__PURE__ */ jsxs(
571
+ "button",
572
+ {
573
+ type: "button",
574
+ onClick: handleExportCsv,
575
+ disabled: processedRows.length === 0,
576
+ "data-testid": `${testId}-export-csv`,
577
+ className: "h-9 px-2.5 text-xs font-medium rounded-sm border border-input bg-background text-foreground hover:bg-muted inline-flex items-center gap-1.5 disabled:opacity-40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
578
+ children: [
579
+ /* @__PURE__ */ jsx(Download, { className: "w-3.5 h-3.5" }),
580
+ /* @__PURE__ */ jsx("span", { className: "hidden sm:inline", children: L.exportCsv })
581
+ ]
582
+ }
583
+ ),
584
+ densityToggle && /* @__PURE__ */ jsxs("div", { className: "relative", children: [
585
+ /* @__PURE__ */ jsxs(
586
+ "button",
587
+ {
588
+ type: "button",
589
+ onClick: () => setOpenMenu(openMenu === "density" ? null : "density"),
590
+ "aria-label": L.density,
591
+ "aria-expanded": openMenu === "density",
592
+ "data-testid": `${testId}-density-btn`,
593
+ className: "h-9 px-2.5 text-xs font-medium rounded-sm border border-input bg-background text-foreground hover:bg-muted inline-flex items-center gap-1.5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
594
+ children: [
595
+ /* @__PURE__ */ jsx(Rows3, { className: "w-3.5 h-3.5" }),
596
+ /* @__PURE__ */ jsx("span", { className: "hidden sm:inline", children: L.density })
597
+ ]
598
+ }
599
+ ),
600
+ openMenu === "density" && /* @__PURE__ */ jsx(
601
+ "div",
602
+ {
603
+ className: "absolute right-0 mt-1 w-40 rounded-sm border border-border bg-popover text-popover-foreground shadow-md p-1 z-30",
604
+ "data-testid": `${testId}-density-menu`,
605
+ children: [
606
+ ["compact", L.densityCompact],
607
+ ["comfortable", L.densityComfortable],
608
+ ["spacious", L.densitySpacious]
609
+ ].map(([value, label]) => /* @__PURE__ */ jsx(
610
+ "button",
611
+ {
612
+ type: "button",
613
+ onClick: () => {
614
+ setDensity(value);
615
+ setOpenMenu(null);
616
+ },
617
+ "data-testid": `${testId}-density-${value}`,
618
+ className: `w-full text-left px-2.5 py-1.5 text-xs rounded-sm transition-colors ${density === value ? "bg-primary/10 text-primary font-semibold" : "hover:bg-muted"}`,
619
+ children: label
620
+ },
621
+ value
622
+ ))
623
+ }
624
+ )
625
+ ] }),
626
+ columnChooser && /* @__PURE__ */ jsxs("div", { className: "relative", children: [
627
+ /* @__PURE__ */ jsxs(
628
+ "button",
629
+ {
630
+ type: "button",
631
+ onClick: () => setOpenMenu(openMenu === "columns" ? null : "columns"),
632
+ "aria-label": L.columns,
633
+ "aria-expanded": openMenu === "columns",
634
+ "data-testid": `${testId}-columns-btn`,
635
+ className: "h-9 px-2.5 text-xs font-medium rounded-sm border border-input bg-background text-foreground hover:bg-muted inline-flex items-center gap-1.5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
636
+ children: [
637
+ /* @__PURE__ */ jsx(Columns3, { className: "w-3.5 h-3.5" }),
638
+ /* @__PURE__ */ jsx("span", { className: "hidden sm:inline", children: L.columns })
639
+ ]
640
+ }
641
+ ),
642
+ openMenu === "columns" && /* @__PURE__ */ jsxs(
643
+ "div",
644
+ {
645
+ className: "absolute right-0 mt-1 w-56 rounded-sm border border-border bg-popover text-popover-foreground shadow-md p-1.5 z-30 space-y-0.5",
646
+ "data-testid": `${testId}-columns-menu`,
647
+ children: [
648
+ columns.filter((c) => c.hideable !== false).map((col) => {
649
+ const visible = !hiddenCols.has(col.id);
650
+ return /* @__PURE__ */ jsxs(
651
+ "label",
652
+ {
653
+ className: "flex items-center gap-2 px-2 py-1.5 text-xs rounded-sm hover:bg-muted cursor-pointer",
654
+ children: [
655
+ /* @__PURE__ */ jsx(
656
+ "input",
657
+ {
658
+ type: "checkbox",
659
+ checked: visible,
660
+ disabled: visible && visibleColumns.length <= 1,
661
+ onChange: () => toggleColumn(col.id),
662
+ "data-testid": `${testId}-col-toggle-${col.id}`,
663
+ className: "rounded border-input accent-primary"
664
+ }
665
+ ),
666
+ /* @__PURE__ */ jsx("span", { children: resolveColumnLabel(col) })
667
+ ]
668
+ },
669
+ col.id
670
+ );
671
+ }),
672
+ hiddenCols.size > 0 && /* @__PURE__ */ jsx(
673
+ "button",
674
+ {
675
+ type: "button",
676
+ onClick: () => setHiddenCols(/* @__PURE__ */ new Set()),
677
+ className: "w-full mt-1 pt-1.5 border-t border-border text-left px-2 py-1 text-xs text-primary hover:underline",
678
+ children: L.showAllColumns
679
+ }
680
+ )
681
+ ]
682
+ }
683
+ )
684
+ ] }),
685
+ onRefresh && /* @__PURE__ */ jsx(
686
+ "button",
687
+ {
688
+ type: "button",
689
+ onClick: onRefresh,
690
+ disabled: refreshing,
691
+ "aria-label": L.refresh,
692
+ title: L.refresh,
693
+ "data-testid": `${testId}-refresh`,
694
+ className: "h-9 w-9 inline-flex items-center justify-center rounded-sm border border-input bg-background text-foreground hover:bg-muted disabled:opacity-40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
695
+ children: /* @__PURE__ */ jsx(RefreshCw, { className: `w-3.5 h-3.5 ${refreshing ? "animate-spin" : ""}` })
696
+ }
697
+ )
698
+ ] })
699
+ ] }),
700
+ selectable && selectedIds.length > 0 && /* @__PURE__ */ jsxs(
701
+ "div",
702
+ {
703
+ className: "flex flex-wrap items-center justify-between gap-2 px-3 py-2 rounded-sm border border-primary/40 bg-primary/5 text-sm",
704
+ "data-testid": `${testId}-bulk-bar`,
705
+ children: [
706
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
707
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-primary", children: interpolateLabel(L.selectedCount, { count: selectedIds.length }) }),
708
+ /* @__PURE__ */ jsx(
709
+ "button",
710
+ {
711
+ type: "button",
712
+ onClick: () => updateSelection([]),
713
+ "data-testid": `${testId}-clear-selection`,
714
+ className: "text-xs text-muted-foreground hover:text-foreground underline",
715
+ children: L.clearSelection
716
+ }
717
+ )
718
+ ] }),
719
+ bulkActions.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap items-center gap-1.5", children: bulkActions.map((action) => /* @__PURE__ */ jsxs(
720
+ "button",
721
+ {
722
+ type: "button",
723
+ disabled: action.disabled || bulkBusy !== null,
724
+ "data-testid": `${testId}-bulk-${action.id}`,
725
+ onClick: async () => {
726
+ setBulkBusy(action.id);
727
+ try {
728
+ await action.onAction(selectedRows);
729
+ } finally {
730
+ setBulkBusy(null);
731
+ }
732
+ },
733
+ className: `h-8 px-3 text-xs font-semibold rounded-sm inline-flex items-center gap-1.5 transition-colors disabled:opacity-40 ${action.tone === "danger" ? "bg-destructive text-destructive-foreground hover:bg-destructive/90" : "bg-primary text-primary-foreground hover:bg-primary/90"}`,
734
+ children: [
735
+ action.icon,
736
+ action.label
737
+ ]
738
+ },
739
+ action.id
740
+ )) })
741
+ ]
742
+ }
743
+ ),
744
+ error && /* @__PURE__ */ jsxs(
745
+ "div",
746
+ {
747
+ role: "alert",
748
+ "data-testid": `${testId}-error`,
749
+ className: "flex items-center justify-between gap-3 px-4 py-3 rounded-sm border border-destructive/40 bg-destructive/10 text-destructive text-sm",
750
+ children: [
751
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
752
+ /* @__PURE__ */ jsx(AlertCircle, { className: "w-4 h-4 shrink-0" }),
753
+ /* @__PURE__ */ jsxs("div", { children: [
754
+ /* @__PURE__ */ jsx("p", { className: "font-semibold", children: L.errorTitle }),
755
+ /* @__PURE__ */ jsx("p", { className: "text-xs opacity-90", children: error })
756
+ ] })
757
+ ] }),
758
+ onRetry && /* @__PURE__ */ jsx(
759
+ "button",
760
+ {
761
+ type: "button",
762
+ onClick: onRetry,
763
+ "data-testid": `${testId}-retry`,
764
+ className: "h-8 px-3 text-xs font-semibold rounded-sm border border-destructive/40 hover:bg-destructive/10",
765
+ children: L.retry
766
+ }
767
+ )
768
+ ]
769
+ }
770
+ ),
771
+ /* @__PURE__ */ jsx("div", { className: "border border-border rounded-sm bg-card overflow-x-auto", children: /* @__PURE__ */ jsxs("table", { className: "w-full border-collapse", children: [
772
+ /* @__PURE__ */ jsx(
773
+ "thead",
774
+ {
775
+ className: `bg-muted/60 border-b border-border ${stickyHeader ? "sticky top-0 z-10" : ""}`,
776
+ children: /* @__PURE__ */ jsxs("tr", { children: [
777
+ renderExpandedRow && /* @__PURE__ */ jsx("th", { className: "w-9 px-2 py-2", "aria-label": L.expandRow }),
778
+ selectable && /* @__PURE__ */ jsx("th", { className: "w-10 px-3 py-2 text-left", children: /* @__PURE__ */ jsx(
779
+ "input",
780
+ {
781
+ type: "checkbox",
782
+ checked: allPageSelected,
783
+ ref: (el) => {
784
+ if (el) el.indeterminate = somePageSelected;
785
+ },
786
+ onChange: toggleSelectAllPage,
787
+ "aria-label": L.selectAllRows,
788
+ "data-testid": `${testId}-select-all`,
789
+ className: "rounded border-input accent-primary"
790
+ }
791
+ ) }),
792
+ visibleColumns.map((col) => {
793
+ const isSorted = sort?.id === col.id;
794
+ const ariaSort = !col.sortable ? void 0 : isSorted ? sort.desc ? "descending" : "ascending" : "none";
795
+ const align = ALIGN_CLASS[col.align ?? "left"];
796
+ return /* @__PURE__ */ jsx(
797
+ "th",
798
+ {
799
+ scope: "col",
800
+ "aria-sort": ariaSort,
801
+ style: { width: col.width, minWidth: col.minWidth },
802
+ className: `px-3 py-2.5 text-[11px] font-bold uppercase tracking-wider text-muted-foreground select-none whitespace-nowrap ${align} ${pinClass(col, true)} ${col.headerClassName ?? ""}`,
803
+ children: col.sortable ? /* @__PURE__ */ jsxs(
804
+ "button",
805
+ {
806
+ type: "button",
807
+ onClick: () => toggleSort(col),
808
+ "data-testid": `${testId}-sort-${col.id}`,
809
+ className: "inline-flex items-center gap-1 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm",
810
+ children: [
811
+ /* @__PURE__ */ jsx("span", { children: col.header }),
812
+ isSorted ? sort.desc ? /* @__PURE__ */ jsx(ArrowDown, { className: "w-3.5 h-3.5 text-primary" }) : /* @__PURE__ */ jsx(ArrowUp, { className: "w-3.5 h-3.5 text-primary" }) : /* @__PURE__ */ jsx(ArrowUpDown, { className: "w-3 h-3 opacity-40" })
813
+ ]
814
+ }
815
+ ) : col.header
816
+ },
817
+ col.id
818
+ );
819
+ })
820
+ ] })
821
+ }
822
+ ),
823
+ /* @__PURE__ */ jsx("tbody", { className: "divide-y divide-border", children: loading ? Array.from({ length: loadingRows }).map((_, idx) => /* @__PURE__ */ jsx("tr", { "data-testid": `${testId}-skeleton-row`, children: Array.from({ length: totalColSpan }).map((__, colIdx) => /* @__PURE__ */ jsx("td", { className: cellPadding, children: /* @__PURE__ */ jsx("div", { className: "h-4 w-3/4 rounded bg-muted animate-pulse" }) }, colIdx)) }, `skeleton-${idx}`)) : pageRows.length === 0 ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsxs("td", { colSpan: totalColSpan, className: "px-6 py-12 text-center", "data-testid": `${testId}-empty`, children: [
824
+ /* @__PURE__ */ jsx("p", { className: "text-sm font-semibold text-foreground", children: hasActiveFilters ? L.noMatchesTitle : emptyTitle ?? L.emptyTitle }),
825
+ /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-muted-foreground", children: hasActiveFilters ? L.noMatchesDescription : emptyDescription ?? L.emptyDescription }),
826
+ hasActiveFilters ? /* @__PURE__ */ jsx(
827
+ "button",
828
+ {
829
+ type: "button",
830
+ onClick: resetAllFilters,
831
+ className: "mt-3 h-8 px-3 text-xs font-medium rounded-sm border border-input bg-background hover:bg-muted",
832
+ children: L.filtersReset
833
+ }
834
+ ) : emptyAction && /* @__PURE__ */ jsx("div", { className: "mt-3", children: emptyAction })
835
+ ] }) }) : pageRows.map((row, rowIndex) => {
836
+ const rowId = getRowId(row, rowIndex);
837
+ const isSelected = selectedSet.has(rowId);
838
+ const isExpanded = expandedIds.has(rowId);
839
+ const extraClass = rowClassName ? rowClassName(row, rowIndex) : "";
840
+ return /* @__PURE__ */ jsxs(React.Fragment, { children: [
841
+ /* @__PURE__ */ jsxs(
842
+ "tr",
843
+ {
844
+ "data-testid": `${testId}-row-${rowId}`,
845
+ tabIndex: onRowClick ? 0 : void 0,
846
+ onClick: onRowClick ? () => onRowClick(row) : void 0,
847
+ onKeyDown: onRowClick ? (e) => {
848
+ if (e.key === "Enter" || e.key === " ") {
849
+ e.preventDefault();
850
+ onRowClick(row);
851
+ }
852
+ } : void 0,
853
+ className: `transition-colors ${isSelected ? "bg-primary/5" : "hover:bg-muted/40"} ${onRowClick ? "cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring" : ""} ${extraClass}`,
854
+ children: [
855
+ renderExpandedRow && /* @__PURE__ */ jsx("td", { className: "w-9 px-2 py-1.5", children: /* @__PURE__ */ jsx(
856
+ "button",
857
+ {
858
+ type: "button",
859
+ onClick: (e) => {
860
+ e.stopPropagation();
861
+ toggleExpandRow(rowId);
862
+ },
863
+ "aria-expanded": isExpanded,
864
+ "aria-label": isExpanded ? L.collapseRow : L.expandRow,
865
+ "data-testid": `${testId}-expand-${rowId}`,
866
+ className: "h-7 w-7 inline-flex items-center justify-center rounded-sm text-muted-foreground hover:bg-muted hover:text-foreground",
867
+ children: /* @__PURE__ */ jsx(
868
+ ChevronRight,
869
+ {
870
+ className: `w-4 h-4 transition-transform ${isExpanded ? "rotate-90" : ""}`
871
+ }
872
+ )
873
+ }
874
+ ) }),
875
+ selectable && /* @__PURE__ */ jsx(
876
+ "td",
877
+ {
878
+ className: "w-10 px-3 py-1.5",
879
+ onClick: (e) => e.stopPropagation(),
880
+ children: /* @__PURE__ */ jsx(
881
+ "input",
882
+ {
883
+ type: "checkbox",
884
+ checked: isSelected,
885
+ onChange: () => toggleSelectRow(rowId),
886
+ "aria-label": L.selectRow,
887
+ "data-testid": `${testId}-select-${rowId}`,
888
+ className: "rounded border-input accent-primary"
889
+ }
890
+ )
891
+ }
892
+ ),
893
+ visibleColumns.map((col) => {
894
+ const align = ALIGN_CLASS[col.align ?? "left"];
895
+ const content = col.cell ? col.cell(row, rowIndex) : String(resolveCellValue(row, col) ?? "\u2013");
896
+ return /* @__PURE__ */ jsx(
897
+ "td",
898
+ {
899
+ className: `${cellPadding} text-foreground ${align} ${pinClass(col, false)} ${col.className ?? ""}`,
900
+ children: content
901
+ },
902
+ col.id
903
+ );
904
+ })
905
+ ]
906
+ }
907
+ ),
908
+ renderExpandedRow && isExpanded && /* @__PURE__ */ jsx("tr", { "data-testid": `${testId}-expanded-${rowId}`, className: "bg-muted/20", children: /* @__PURE__ */ jsx("td", { colSpan: totalColSpan, className: "px-4 py-3", children: renderExpandedRow(row) }) })
909
+ ] }, rowId);
910
+ }) })
911
+ ] }) }),
912
+ paginate && effectiveTotal > 0 && /* @__PURE__ */ jsxs(
913
+ "div",
914
+ {
915
+ className: "flex flex-wrap items-center justify-between gap-3 text-xs text-muted-foreground",
916
+ "data-testid": `${testId}-pagination`,
917
+ children: [
918
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
919
+ /* @__PURE__ */ jsx("span", { className: "tabular-nums", children: interpolateLabel(L.rangeOf, {
920
+ start: rangeStart,
921
+ end: rangeEnd,
922
+ total: effectiveTotal
923
+ }) }),
924
+ /* @__PURE__ */ jsxs("label", { className: "inline-flex items-center gap-1.5", children: [
925
+ /* @__PURE__ */ jsx("span", { children: L.rowsPerPage }),
926
+ /* @__PURE__ */ jsx(
927
+ "select",
928
+ {
929
+ value: pageSize,
930
+ onChange: (e) => setPageSize(Number(e.target.value)),
931
+ "data-testid": `${testId}-page-size`,
932
+ className: "h-8 px-2 rounded-sm border border-input bg-background text-foreground text-xs focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
933
+ children: pageSizeOptions.map((size) => /* @__PURE__ */ jsx("option", { value: size, children: size }, size))
934
+ }
935
+ )
936
+ ] })
937
+ ] }),
938
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
939
+ /* @__PURE__ */ jsx("span", { className: "mr-2 tabular-nums", children: interpolateLabel(L.pageOf, { page: clampedPage, pages: totalPages }) }),
940
+ /* @__PURE__ */ jsx(
941
+ "button",
942
+ {
943
+ type: "button",
944
+ onClick: () => setPage(1),
945
+ disabled: clampedPage <= 1,
946
+ "aria-label": L.firstPage,
947
+ "data-testid": `${testId}-page-first`,
948
+ className: "h-8 w-8 inline-flex items-center justify-center rounded-sm border border-input bg-background text-foreground hover:bg-muted disabled:opacity-40",
949
+ children: /* @__PURE__ */ jsx(ChevronsLeft, { className: "w-3.5 h-3.5" })
950
+ }
951
+ ),
952
+ /* @__PURE__ */ jsx(
953
+ "button",
954
+ {
955
+ type: "button",
956
+ onClick: () => setPage(clampedPage - 1),
957
+ disabled: clampedPage <= 1,
958
+ "aria-label": L.previousPage,
959
+ "data-testid": `${testId}-page-prev`,
960
+ className: "h-8 w-8 inline-flex items-center justify-center rounded-sm border border-input bg-background text-foreground hover:bg-muted disabled:opacity-40",
961
+ children: /* @__PURE__ */ jsx(ChevronLeft, { className: "w-3.5 h-3.5" })
962
+ }
963
+ ),
964
+ /* @__PURE__ */ jsx(
965
+ "button",
966
+ {
967
+ type: "button",
968
+ onClick: () => setPage(clampedPage + 1),
969
+ disabled: clampedPage >= totalPages,
970
+ "aria-label": L.nextPage,
971
+ "data-testid": `${testId}-page-next`,
972
+ className: "h-8 w-8 inline-flex items-center justify-center rounded-sm border border-input bg-background text-foreground hover:bg-muted disabled:opacity-40",
973
+ children: /* @__PURE__ */ jsx(ChevronRight, { className: "w-3.5 h-3.5" })
974
+ }
975
+ ),
976
+ /* @__PURE__ */ jsx(
977
+ "button",
978
+ {
979
+ type: "button",
980
+ onClick: () => setPage(totalPages),
981
+ disabled: clampedPage >= totalPages,
982
+ "aria-label": L.lastPage,
983
+ "data-testid": `${testId}-page-last`,
984
+ className: "h-8 w-8 inline-flex items-center justify-center rounded-sm border border-input bg-background text-foreground hover:bg-muted disabled:opacity-40",
985
+ children: /* @__PURE__ */ jsx(ChevronsRight, { className: "w-3.5 h-3.5" })
986
+ }
987
+ )
988
+ ] })
989
+ ]
990
+ }
991
+ )
992
+ ] });
993
+ }
994
+ export {
995
+ DEFAULT_DATA_TABLE_LABELS,
996
+ ScalioDataTable,
997
+ buildCsv,
998
+ escapeCsvCell,
999
+ filterRows,
1000
+ interpolateLabel,
1001
+ loadTablePrefs,
1002
+ paginateRows,
1003
+ resolveCellValue,
1004
+ resolveColumnLabel,
1005
+ saveTablePrefs,
1006
+ sortRows
1007
+ };
1008
+ //# sourceMappingURL=index.mjs.map