@fuf-stack/megapixels 0.17.0 → 1.0.0-next.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 (32) hide show
  1. package/README.md +3 -1
  2. package/dist/DataTable/index.d.mts +1 -1
  3. package/dist/DataTable/index.mjs +1 -2
  4. package/dist/{DataTable-Dw8152NO.mjs → DataTable-Ml6QySfA.mjs} +588 -444
  5. package/dist/DataTable-Ml6QySfA.mjs.map +1 -0
  6. package/dist/Filter/index.d.mts +1 -1
  7. package/dist/Filter/index.mjs +1 -2
  8. package/dist/{Filter-DcWQ5wx8.mjs → Filter-DXRC8M5M.mjs} +138 -83
  9. package/dist/Filter-DXRC8M5M.mjs.map +1 -0
  10. package/dist/Notification/index.d.mts +1 -1
  11. package/dist/Notification/index.mjs +1 -2
  12. package/dist/{Notification-kqOpVaUX.mjs → Notification-Dei4OOE6.mjs} +4 -4
  13. package/dist/{Notification-kqOpVaUX.mjs.map → Notification-Dei4OOE6.mjs.map} +1 -1
  14. package/dist/VirtualList/index.d.mts +1 -1
  15. package/dist/VirtualList/index.mjs +1 -2
  16. package/dist/VirtualList-sPPTnS7m.mjs +193 -0
  17. package/dist/VirtualList-sPPTnS7m.mjs.map +1 -0
  18. package/dist/{index-Qx3v5aZj.d.mts → index-B_ebAhwH.d.mts} +86 -67
  19. package/dist/{index-Qx3v5aZj.d.mts.map → index-B_ebAhwH.d.mts.map} +1 -1
  20. package/dist/{index-CeBjB8ML.d.mts → index-Bs5iWkFO.d.mts} +247 -166
  21. package/dist/{index-CeBjB8ML.d.mts.map → index-Bs5iWkFO.d.mts.map} +1 -1
  22. package/dist/{index-C8qpzima.d.mts → index-ClWVkO3I.d.mts} +2 -2
  23. package/dist/{index-C8qpzima.d.mts.map → index-ClWVkO3I.d.mts.map} +1 -1
  24. package/dist/{index-DsTgtkjk.d.mts → index-Dv6cWC7j.d.mts} +56 -37
  25. package/dist/{index-DsTgtkjk.d.mts.map → index-Dv6cWC7j.d.mts.map} +1 -1
  26. package/dist/index.d.mts +4 -4
  27. package/dist/index.mjs +4 -4
  28. package/package.json +13 -13
  29. package/dist/DataTable-Dw8152NO.mjs.map +0 -1
  30. package/dist/Filter-DcWQ5wx8.mjs.map +0 -1
  31. package/dist/VirtualList-GX38PUeR.mjs +0 -154
  32. package/dist/VirtualList-GX38PUeR.mjs.map +0 -1
@@ -1,32 +1,133 @@
1
1
  import { t as useInfiniteVirtualizer } from "./useInfiniteVirtualizer-BBgVBqJa.mjs";
2
+ import { useStyling } from "@fuf-stack/pixels/StylingProvider";
3
+ import { cn, tv } from "@fuf-stack/pixel-utils";
2
4
  import { Fragment, useCallback, useMemo, useRef, useState } from "react";
3
- import { cn, tv, variantsToClassNames } from "@fuf-stack/pixel-utils";
4
- import { ScrollShadow } from "@fuf-stack/pixels/ScrollShadow";
5
5
  import { flexRender, getCoreRowModel, getExpandedRowModel, getFilteredRowModel, getPaginationRowModel, getSortedRowModel, useReactTable } from "@tanstack/react-table";
6
6
  import { Button } from "@fuf-stack/pixels/Button";
7
- import { Checkbox } from "@base-ui/react/checkbox";
7
+ import { CheckboxButton, CheckboxField } from "react-aria-components";
8
8
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
9
9
  import { Menu } from "@fuf-stack/pixels/Menu";
10
+ import { ScrollShadow } from "@fuf-stack/pixels/ScrollShadow";
10
11
  import { LuColumns3 } from "react-icons/lu";
11
- //#region src/DataTable/Subcomponents/DataTableCheckbox.tsx
12
- /** Small checkbox wrapper used by DataTable selection UI. */
12
+ //#region src/DataTable/dataTableVariants.ts
13
+ /** Styling slots for DataTable */
14
+ const dataTableVariants = tv({ slots: {
15
+ /** Root wrapper around toolbar, table, and pagination */
16
+ base: "w-full",
17
+ /** Selection checkbox control in header/rows */
18
+ checkbox: [
19
+ "relative inline-flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center",
20
+ "rounded border border-divider bg-background align-middle text-foreground",
21
+ "data-[focus-visible]:outline-2 data-[focus-visible]:outline-offset-2 data-[focus-visible]:outline-focus"
22
+ ],
23
+ /** Checkmark/minus glyph inside the selection checkbox */
24
+ checkboxIndicator: "pointer-events-none absolute inset-0 flex items-center justify-center text-[10px] leading-none",
25
+ /** Empty-state cell shown when no rows match */
26
+ emptyCell: "h-24 text-center text-default-500",
27
+ /** Button used by the injected expandable-row toggle column */
28
+ expandButton: "h-8 min-w-8 px-0 disabled:cursor-not-allowed data-[disabled=true]:pointer-events-auto data-[disabled=true]:cursor-not-allowed",
29
+ /** Table cell that spans all visible columns for expanded content */
30
+ expandedCell: "p-4 text-sm text-default-600",
31
+ /** Table row rendered directly below an expanded data row */
32
+ expandedRow: "bg-content1",
33
+ /** Icon wrapper inside the expandable-row toggle button */
34
+ expandIcon: "inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center text-default-500",
35
+ /** Header/body cell reserved for the expandable-row toggle column */
36
+ expansionCell: "w-10 px-0 text-center",
37
+ /** Inner wrapper that visually centers expandable-row toggle buttons */
38
+ expansionCellContent: "flex justify-center",
39
+ /** Loading-state cell shown while data is being fetched */
40
+ loadingCell: "h-24 text-center text-default-500",
41
+ /** Loading/retry cell shown when fetching next page in infinite mode */
42
+ loadingMoreCell: "flex h-14 items-center justify-center text-default-500",
43
+ /** Plain header content used for non-sortable columns */
44
+ nonSortableHeaderContent: "inline-flex items-center",
45
+ /** Label wrapping the "Rows per page" selector */
46
+ pageSizeLabel: "flex items-center gap-2 text-sm text-default-500",
47
+ /** Menu trigger used to choose page size */
48
+ pageSizeSelect: "min-w-16 justify-between gap-2",
49
+ /** "Page X of Y" summary text */
50
+ pageSummary: "text-sm text-default-500",
51
+ /** Pagination footer container */
52
+ pagination: "flex items-center gap-2 py-4",
53
+ /** Shared class applied to pagination action buttons */
54
+ paginationButton: "",
55
+ /** Placeholder rows for unknown-yet data in total-count mode */
56
+ placeholderCell: "h-10 animate-pulse bg-default-100/60 p-3 dark:bg-default-100/10",
57
+ /** Scroll container in virtualized/infinite mode */
58
+ scrollContainer: "overflow-y-auto overflow-x-hidden",
59
+ /** Optional styling slot for ScrollShadow wrapper behavior */
60
+ scrollShadow: "",
61
+ /** Built-in text search input(s) rendered in the toolbar */
62
+ searchInput: [
63
+ "h-10 w-full max-w-sm rounded-small border-2 border-default-200 bg-transparent px-3 text-sm text-foreground",
64
+ "outline-none transition-colors",
65
+ "placeholder:text-default-500 hover:border-default-400 data-[focused=true]:border-focus dark:border-default-100"
66
+ ],
67
+ /** Header/body cell reserved for the selection checkbox column */
68
+ selectionCell: "w-10 px-0 text-center",
69
+ /** Inner wrapper that visually centers selection checkboxes in their cells */
70
+ selectionCellContent: "flex justify-center",
71
+ /** Selected rows summary text in pagination footer */
72
+ selectionSummary: "mr-auto text-sm text-default-500",
73
+ /** Header button used for sortable columns */
74
+ sortButton: "-ml-2 min-w-0 justify-start gap-1.5 px-2 text-left font-medium text-foreground data-[sortable=true]:cursor-pointer",
75
+ /** Icon wrapper for sort direction indicators */
76
+ sortIcon: "inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center text-default-400",
77
+ /** Semantic table element */
78
+ table: "w-full caption-bottom text-sm",
79
+ /** Border/overflow container around the table */
80
+ tableWrapper: "overflow-hidden rounded-md border border-divider",
81
+ /** Semantic table body wrapper */
82
+ tbody: "",
83
+ /** Standard table data cell */
84
+ td: "p-3 align-middle text-foreground",
85
+ /** Standard table header cell */
86
+ th: "h-10 px-3 text-left align-middle font-medium text-foreground",
87
+ /** Table header row group background */
88
+ thead: "bg-content2",
89
+ /** Toolbar container for filters/actions */
90
+ toolbar: "flex items-center gap-3 py-4",
91
+ /** Optional custom toolbar content area */
92
+ toolbarContent: "flex flex-1 items-center",
93
+ /** Table row styling including selected-row state */
94
+ tr: "border-b border-divider last:border-b-0 data-[state=selected]:bg-content2/60",
95
+ /** Checkmark indicator area inside view options menu items */
96
+ viewOptionsIndicator: "mr-2 inline-flex w-3 justify-center",
97
+ /** Individual view-options menu item */
98
+ viewOptionsItem: ["data-highlighted:bg-default-100 dark:data-highlighted:bg-default-100/20", "flex cursor-pointer items-center rounded px-2 py-1 text-sm text-foreground outline-none"],
99
+ /** Dropdown menu panel for view options */
100
+ viewOptionsMenu: "z-50 min-w-40 rounded-md border border-divider bg-background p-1 shadow-md",
101
+ /** Positioner wrapper used by menu popover */
102
+ viewOptionsPositioner: "outline-none",
103
+ /** Trigger button for the "Columns" menu */
104
+ viewOptionsTrigger: "ml-auto gap-2"
105
+ } });
106
+ //#endregion
107
+ //#region src/DataTable/subcomponents/DataTableCheckbox.tsx
108
+ /**
109
+ * Row selection checkbox with a mixed state for partially selected pages
110
+ *
111
+ * @see https://react-aria.adobe.com/Checkbox
112
+ */
13
113
  const DataTableCheckbox = ({ ariaLabel, checked, className = void 0, checkedIcon = "✓", indeterminate = false, indeterminateIcon = "−", onCheckedChange, testId = void 0 }) => {
14
114
  const indicatorIcon = indeterminate ? indeterminateIcon : checkedIcon;
15
115
  const resolvedIndicatorIcon = indicatorIcon === false ? null : indicatorIcon;
16
- return /* @__PURE__ */ jsx(Checkbox.Root, {
116
+ return /* @__PURE__ */ jsx(CheckboxField, {
17
117
  "aria-label": ariaLabel,
18
- checked,
19
- className: className?.checkbox,
20
- "data-slot": "checkbox",
21
- "data-testid": testId,
22
- indeterminate,
23
- onCheckedChange: (nextChecked) => {
24
- onCheckedChange(Boolean(nextChecked));
25
- },
26
- children: /* @__PURE__ */ jsx(Checkbox.Indicator, {
27
- className: className?.checkboxIndicator,
28
- "data-slot": "checkbox-indicator",
29
- children: resolvedIndicatorIcon
118
+ isIndeterminate: indeterminate,
119
+ isSelected: checked,
120
+ onChange: onCheckedChange,
121
+ children: /* @__PURE__ */ jsx(CheckboxButton, {
122
+ className: className?.checkbox,
123
+ "data-slot": "checkbox",
124
+ "data-testid": testId,
125
+ children: checked || indeterminate ? /* @__PURE__ */ jsx("span", {
126
+ "aria-hidden": "true",
127
+ className: className?.checkboxIndicator,
128
+ "data-slot": "checkbox-indicator",
129
+ children: resolvedIndicatorIcon
130
+ }) : null
30
131
  })
31
132
  });
32
133
  };
@@ -271,8 +372,8 @@ const useDataTableController = ({ checkboxClassNames, columns, data, enableExpan
271
372
  getRowCanExpand: (row) => {
272
373
  return hasExpandableRowContent || row.subRows.length > 0;
273
374
  },
274
- getSubRows,
275
375
  getSortedRowModel: enableServerMode ? void 0 : getSortedRowModel(),
376
+ getSubRows,
276
377
  manualFiltering: enableServerMode,
277
378
  manualSorting: enableServerMode,
278
379
  onColumnFiltersChange: setColumnFilters,
@@ -294,164 +395,7 @@ const useDataTableController = ({ checkboxClassNames, columns, data, enableExpan
294
395
  };
295
396
  };
296
397
  //#endregion
297
- //#region src/DataTable/Subcomponents/DataTableCells.tsx
298
- const getColumnKind = (columnId) => {
299
- if (columnId === "__expand") return "expansion";
300
- if (columnId === "__select") return "selection";
301
- return "data";
302
- };
303
- const getCellDataSlot = (columnKind) => {
304
- if (columnKind === "expansion") return "expansion-cell";
305
- if (columnKind === "selection") return "selection-cell";
306
- return "td";
307
- };
308
- const getHeaderDataSlot = (columnKind) => {
309
- if (columnKind === "data") return "th";
310
- return getCellDataSlot(columnKind);
311
- };
312
- const getControlCellContentDataSlot = (columnKind) => {
313
- if (columnKind === "expansion") return "expansion-cell-content";
314
- return "selection-cell-content";
315
- };
316
- /**
317
- * Flex sizing for cells in virtualized mode.
318
- *
319
- * Because virtual rows are absolutely positioned, we cannot rely on native
320
- * table layout for column width sync; header/body cells must apply matching
321
- * explicit sizing rules.
322
- */
323
- const getVirtualCellStyle = (columnKind, size) => {
324
- if (columnKind === "data") return {
325
- flex: `1 1 ${size}px`,
326
- minWidth: 0,
327
- width: size
328
- };
329
- return {
330
- flex: `0 0 ${size}px`,
331
- width: size
332
- };
333
- };
334
- /** Shared row positioning style for full-width virtual rows. */
335
- const virtualFullWidthRowStyle = (start) => {
336
- return {
337
- display: "flex",
338
- position: "absolute",
339
- transform: `translateY(${start}px)`,
340
- width: "100%"
341
- };
342
- };
343
- /** Shared single-cell style for full-width virtual rows. */
344
- const virtualFullWidthCellStyle = {
345
- flex: "1 1 auto",
346
- width: "100%"
347
- };
348
- /**
349
- * Renders one header cell and encapsulates sortable/non-sortable behavior.
350
- */
351
- const DataTableHeaderCell = ({ classNames, header, sortIcons = void 0, virtualized = false }) => {
352
- const canSort = header.column.getCanSort();
353
- const columnKind = getColumnKind(header.column.id);
354
- const isExpansionColumn = columnKind === "expansion";
355
- const isSelectionColumn = columnKind === "selection";
356
- const sortState = header.column.getIsSorted();
357
- const sortIndicator = getSortIndicator(canSort, sortState, sortIcons);
358
- if (header.isPlaceholder) return /* @__PURE__ */ jsx("th", {
359
- "aria-label": "Empty column header",
360
- className: classNames.th,
361
- "data-slot": getHeaderDataSlot(columnKind)
362
- }, header.id);
363
- return /* @__PURE__ */ jsx("th", {
364
- className: cn(classNames.th, isExpansionColumn && classNames.expansionCell, isSelectionColumn && classNames.selectionCell),
365
- "data-slot": getHeaderDataSlot(columnKind),
366
- style: virtualized ? {
367
- alignItems: "center",
368
- display: "flex",
369
- ...getVirtualCellStyle(columnKind, header.getSize())
370
- } : void 0,
371
- children: canSort ? /* @__PURE__ */ jsxs(Button, {
372
- className: classNames.sortButton,
373
- "data-sortable": canSort,
374
- dataSlot: "sort-button",
375
- onClick: () => {
376
- header.column.toggleSorting(sortState === "asc");
377
- },
378
- size: "sm",
379
- variant: "light",
380
- children: [flexRender(header.column.columnDef.header, header.getContext()), sortIndicator ? /* @__PURE__ */ jsx("span", {
381
- "aria-hidden": "true",
382
- className: classNames.sortIcon,
383
- "data-slot": "sort-icon",
384
- children: sortIndicator
385
- }) : null]
386
- }) : /* @__PURE__ */ jsx("div", {
387
- className: cn(classNames.nonSortableHeaderContent, isExpansionColumn && classNames.expansionCellContent, isSelectionColumn && classNames.selectionCellContent),
388
- "data-slot": columnKind === "data" ? "non-sortable-header-content" : getControlCellContentDataSlot(columnKind),
389
- children: flexRender(header.column.columnDef.header, header.getContext())
390
- })
391
- }, header.id);
392
- };
393
- /**
394
- * Renders one body cell and hides control-column wrapper details from row loops.
395
- */
396
- const DataTableBodyCell = ({ cell, classNames, virtualized = false }) => {
397
- const columnKind = getColumnKind(cell.column.id);
398
- const isExpansionColumn = columnKind === "expansion";
399
- const isSelectionColumn = columnKind === "selection";
400
- const isControlColumn = columnKind !== "data";
401
- const cellContent = flexRender(cell.column.columnDef.cell, cell.getContext());
402
- const expansionIndent = isExpansionColumn && cell.row.depth > 0 ? { paddingLeft: `${cell.row.depth * 1.25}rem` } : void 0;
403
- return /* @__PURE__ */ jsx("td", {
404
- className: cn(classNames.td, isExpansionColumn && classNames.expansionCell, isSelectionColumn && classNames.selectionCell),
405
- "data-slot": getCellDataSlot(columnKind),
406
- style: virtualized ? getVirtualCellStyle(columnKind, cell.column.getSize()) : void 0,
407
- children: isControlColumn ? /* @__PURE__ */ jsx("div", {
408
- className: cn(isExpansionColumn && classNames.expansionCellContent, isSelectionColumn && classNames.selectionCellContent),
409
- "data-slot": getControlCellContentDataSlot(columnKind),
410
- style: expansionIndent,
411
- children: cellContent
412
- }) : cellContent
413
- }, cell.id);
414
- };
415
- //#endregion
416
- //#region src/DataTable/Subcomponents/DataTableBodyRows.tsx
417
- /**
418
- * Standard row renderer used in non-virtualized table mode.
419
- *
420
- * It renders:
421
- * - each data row
422
- * - an optional sibling expanded-content row that spans all visible columns
423
- */
424
- const DataTableBodyRows = ({ classNames, expandableRows = void 0, rows, visibleColumnCount, virtualized = false }) => {
425
- return rows.map((row) => {
426
- return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("tr", {
427
- className: classNames.tr,
428
- "data-slot": "tr",
429
- "data-state": row.getIsSelected() ? "selected" : void 0,
430
- style: virtualized ? {
431
- display: "flex",
432
- width: "100%"
433
- } : void 0,
434
- children: row.getVisibleCells().map((cell) => {
435
- return /* @__PURE__ */ jsx(DataTableBodyCell, {
436
- cell,
437
- classNames,
438
- virtualized
439
- }, cell.id);
440
- })
441
- }), expandableRows?.renderContent && row.getIsExpanded() ? /* @__PURE__ */ jsx("tr", {
442
- className: cn(classNames.tr, classNames.expandedRow),
443
- "data-slot": "expanded-row",
444
- children: /* @__PURE__ */ jsx("td", {
445
- className: classNames.expandedCell,
446
- colSpan: visibleColumnCount,
447
- "data-slot": "expanded-cell",
448
- children: expandableRows.renderContent(row)
449
- })
450
- }) : null] }, row.id);
451
- });
452
- };
453
- //#endregion
454
- //#region src/DataTable/Subcomponents/DataTablePagination.tsx
398
+ //#region src/DataTable/subcomponents/DataTablePagination.tsx
455
399
  const ChevronDownIcon = () => {
456
400
  return /* @__PURE__ */ jsx("svg", {
457
401
  "aria-hidden": "true",
@@ -469,8 +413,8 @@ const ChevronDownIcon = () => {
469
413
  })
470
414
  });
471
415
  };
472
- /** Footer controls for paging, page size, and selected-row summary. */
473
- const DataTablePagination = ({ classNames, pageSizeOptions, showRowsPerPage, showSelectionSummary, table, testId = void 0 }) => {
416
+ /** Footer controls for paging, page size, and selected-row summary */
417
+ const DataTablePagination = ({ className: classNames, pageSizeOptions, showRowsPerPage, showSelectionSummary, table, testId = void 0 }) => {
474
418
  const { pageSize } = table.getState().pagination;
475
419
  const selectedRowCount = table.getFilteredSelectedRowModel().rows.length;
476
420
  const pageSizeItems = pageSizeOptions.map((size) => {
@@ -565,60 +509,215 @@ const DataTablePagination = ({ classNames, pageSizeOptions, showRowsPerPage, sho
565
509
  });
566
510
  };
567
511
  //#endregion
568
- //#region src/DataTable/Subcomponents/DataTableViewOptions.tsx
512
+ //#region src/DataTable/subcomponents/dataTableCellHelpers.ts
513
+ const getColumnKind = (columnId) => {
514
+ if (columnId === "__expand") return "expansion";
515
+ if (columnId === "__select") return "selection";
516
+ return "data";
517
+ };
518
+ const getCellDataSlot = (columnKind) => {
519
+ if (columnKind === "expansion") return "expansion-cell";
520
+ if (columnKind === "selection") return "selection-cell";
521
+ return "td";
522
+ };
523
+ const getHeaderDataSlot = (columnKind) => {
524
+ if (columnKind === "data") return "th";
525
+ return getCellDataSlot(columnKind);
526
+ };
527
+ const getControlCellContentDataSlot = (columnKind) => {
528
+ if (columnKind === "expansion") return "expansion-cell-content";
529
+ return "selection-cell-content";
530
+ };
569
531
  /**
570
- * Resolves a human-readable label for a column, preferring its string header
571
- * over the raw TanStack column id (e.g. "Status" instead of "status").
532
+ * Flex sizing for cells in virtualized mode.
533
+ *
534
+ * Because virtual rows are absolutely positioned, we cannot rely on native
535
+ * table layout for column width sync; header/body cells must apply matching
536
+ * explicit sizing rules.
572
537
  */
573
- const getColumnLabel = (column) => {
574
- const { header } = column.columnDef;
575
- return typeof header === "string" ? header : column.id;
538
+ const getVirtualCellStyle = (columnKind, size) => {
539
+ if (columnKind === "data") return {
540
+ flex: `1 1 ${size}px`,
541
+ minWidth: 0,
542
+ width: size
543
+ };
544
+ return {
545
+ flex: `0 0 ${size}px`,
546
+ width: size
547
+ };
576
548
  };
577
- /** Dropdown for toggling table column visibility. */
578
- const DataTableViewOptions = ({ classNames, table, triggerIcon = /* @__PURE__ */ jsx(LuColumns3, {}), visibleIcon = "✓", testId = void 0 }) => {
579
- const hideableColumns = table.getAllColumns().filter((column) => {
580
- return column.getCanHide();
581
- });
582
- const columnsById = new Map(hideableColumns.map((column) => {
583
- return [column.id, column];
584
- }));
585
- const items = hideableColumns.map((column) => {
586
- const columnLabel = getColumnLabel(column);
587
- return {
588
- key: column.id,
589
- className: classNames.viewOptionsItem,
590
- dataSlot: "view-options-item",
591
- textValue: columnLabel,
592
- label: /* @__PURE__ */ jsxs("span", {
593
- className: "flex items-center gap-2",
594
- children: [/* @__PURE__ */ jsx("span", {
595
- className: classNames.viewOptionsIndicator,
596
- "data-slot": "view-options-indicator",
597
- children: column.getIsVisible() && visibleIcon !== false ? visibleIcon : ""
598
- }), columnLabel]
549
+ /** Shared row positioning style for full-width virtual rows. */
550
+ const virtualFullWidthRowStyle = (start) => {
551
+ return {
552
+ display: "flex",
553
+ position: "absolute",
554
+ transform: `translateY(${start}px)`,
555
+ width: "100%"
556
+ };
557
+ };
558
+ /** Shared single-cell style for full-width virtual rows. */
559
+ const virtualFullWidthCellStyle = {
560
+ flex: "1 1 auto",
561
+ width: "100%"
562
+ };
563
+ //#endregion
564
+ //#region src/DataTable/subcomponents/DataTableBodyCell.tsx
565
+ /**
566
+ * Renders one body cell and hides control-column wrapper details from row loops.
567
+ */
568
+ const DataTableBodyCell = ({ cell, className: classNames, virtualized = false }) => {
569
+ const columnKind = getColumnKind(cell.column.id);
570
+ const isExpansionColumn = columnKind === "expansion";
571
+ const isSelectionColumn = columnKind === "selection";
572
+ const isControlColumn = columnKind !== "data";
573
+ const cellContent = flexRender(cell.column.columnDef.cell, cell.getContext());
574
+ const expansionIndent = isExpansionColumn && cell.row.depth > 0 ? { paddingLeft: `${cell.row.depth * 1.25}rem` } : void 0;
575
+ return /* @__PURE__ */ jsx("td", {
576
+ className: cn(classNames.td, isExpansionColumn && classNames.expansionCell, isSelectionColumn && classNames.selectionCell),
577
+ "data-slot": getCellDataSlot(columnKind),
578
+ style: virtualized ? getVirtualCellStyle(columnKind, cell.column.getSize()) : void 0,
579
+ children: isControlColumn ? /* @__PURE__ */ jsx("div", {
580
+ className: cn(isExpansionColumn && classNames.expansionCellContent, isSelectionColumn && classNames.selectionCellContent),
581
+ "data-slot": getControlCellContentDataSlot(columnKind),
582
+ style: expansionIndent,
583
+ children: cellContent
584
+ }) : cellContent
585
+ }, cell.id);
586
+ };
587
+ //#endregion
588
+ //#region src/DataTable/subcomponents/DataTableBodyRows.tsx
589
+ /**
590
+ * Standard row renderer used in non-virtualized table mode.
591
+ *
592
+ * It renders:
593
+ * - each data row
594
+ * - an optional sibling expanded-content row that spans all visible columns
595
+ */
596
+ const DataTableBodyRows = ({ className: classNames, expandableRows = void 0, rows, visibleColumnCount, virtualized = false }) => {
597
+ return rows.map((row) => {
598
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("tr", {
599
+ className: classNames.tr,
600
+ "data-slot": "tr",
601
+ "data-state": row.getIsSelected() ? "selected" : void 0,
602
+ style: virtualized ? {
603
+ display: "flex",
604
+ width: "100%"
605
+ } : void 0,
606
+ children: row.getVisibleCells().map((cell) => {
607
+ return /* @__PURE__ */ jsx(DataTableBodyCell, {
608
+ cell,
609
+ className: classNames,
610
+ virtualized
611
+ }, cell.id);
599
612
  })
600
- };
613
+ }), expandableRows?.renderContent && row.getIsExpanded() ? /* @__PURE__ */ jsx("tr", {
614
+ className: cn(classNames.tr, classNames.expandedRow),
615
+ "data-slot": "expanded-row",
616
+ children: /* @__PURE__ */ jsx("td", {
617
+ className: classNames.expandedCell,
618
+ colSpan: visibleColumnCount,
619
+ "data-slot": "expanded-cell",
620
+ children: expandableRows.renderContent(row)
621
+ })
622
+ }) : null] }, row.id);
601
623
  });
602
- return /* @__PURE__ */ jsxs(Menu, {
603
- items,
604
- onAction: (key) => {
605
- const column = columnsById.get(String(key));
606
- if (!column) return;
607
- column.toggleVisibility(!column.getIsVisible());
608
- },
609
- testId: testId ? `${testId}-column-visibility-trigger` : void 0,
610
- triggerButtonProps: {
611
- "aria-label": "Toggle column visibility",
612
- className: classNames.viewOptionsTrigger,
613
- dataSlot: "view-options-trigger",
614
- disableRipple: true,
624
+ };
625
+ //#endregion
626
+ //#region src/DataTable/subcomponents/DataTableHeaderCell.tsx
627
+ /**
628
+ * Renders one header cell and encapsulates sortable/non-sortable behavior.
629
+ */
630
+ const DataTableHeaderCell = ({ className: classNames, header, sortIcons = void 0, virtualized = false }) => {
631
+ const canSort = header.column.getCanSort();
632
+ const columnKind = getColumnKind(header.column.id);
633
+ const isExpansionColumn = columnKind === "expansion";
634
+ const isSelectionColumn = columnKind === "selection";
635
+ const sortState = header.column.getIsSorted();
636
+ const sortIndicator = getSortIndicator(canSort, sortState, sortIcons);
637
+ if (header.isPlaceholder) return /* @__PURE__ */ jsx("th", {
638
+ "aria-label": "Empty column header",
639
+ className: classNames.th,
640
+ "data-slot": getHeaderDataSlot(columnKind)
641
+ }, header.id);
642
+ const handleSort = () => {
643
+ header.column.toggleSorting(sortState === "asc");
644
+ };
645
+ return /* @__PURE__ */ jsx("th", {
646
+ className: cn(classNames.th, isExpansionColumn && classNames.expansionCell, isSelectionColumn && classNames.selectionCell),
647
+ "data-slot": getHeaderDataSlot(columnKind),
648
+ style: virtualized ? {
649
+ alignItems: "center",
650
+ display: "flex",
651
+ ...getVirtualCellStyle(columnKind, header.getSize())
652
+ } : void 0,
653
+ children: canSort ? /* @__PURE__ */ jsxs(Button, {
654
+ className: classNames.sortButton,
655
+ "data-sortable": canSort,
656
+ dataSlot: "sort-button",
657
+ onClick: handleSort,
615
658
  size: "sm",
616
- variant: "bordered"
617
- },
618
- children: [triggerIcon === false ? null : triggerIcon, "Columns"]
659
+ variant: "light",
660
+ children: [flexRender(header.column.columnDef.header, header.getContext()), sortIndicator ? /* @__PURE__ */ jsx("span", {
661
+ "aria-hidden": "true",
662
+ className: classNames.sortIcon,
663
+ "data-slot": "sort-icon",
664
+ children: sortIndicator
665
+ }) : null]
666
+ }) : /* @__PURE__ */ jsx("div", {
667
+ className: cn(classNames.nonSortableHeaderContent, isExpansionColumn && classNames.expansionCellContent, isSelectionColumn && classNames.selectionCellContent),
668
+ "data-slot": columnKind === "data" ? "non-sortable-header-content" : getControlCellContentDataSlot(columnKind),
669
+ children: flexRender(header.column.columnDef.header, header.getContext())
670
+ })
671
+ }, header.id);
672
+ };
673
+ //#endregion
674
+ //#region src/DataTable/subcomponents/DataTableHeaderRows.tsx
675
+ /** Column header groups and sorting controls for either table layout */
676
+ const DataTableHeaderRows = ({ className: classNames, sortIcons = void 0, table, virtualized = false }) => {
677
+ return table.getHeaderGroups().map((headerGroup) => {
678
+ return /* @__PURE__ */ jsx("tr", {
679
+ className: classNames.tr,
680
+ "data-slot": "tr",
681
+ style: virtualized ? {
682
+ display: "flex",
683
+ width: "100%"
684
+ } : void 0,
685
+ children: headerGroup.headers.map((header) => {
686
+ return /* @__PURE__ */ jsx(DataTableHeaderCell, {
687
+ className: classNames,
688
+ header,
689
+ sortIcons,
690
+ virtualized
691
+ }, header.id);
692
+ })
693
+ }, headerGroup.id);
619
694
  });
620
695
  };
621
696
  //#endregion
697
+ //#region src/DataTable/subcomponents/DataTableStateRows.tsx
698
+ /** Full-width loading and empty rows without replacing the table structure */
699
+ const DataTableStateRows = ({ className: classNames, emptyContent, loading, loadingContent, rowCount, visibleColumnCount }) => {
700
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [loading ? /* @__PURE__ */ jsx("tr", {
701
+ className: classNames.tr,
702
+ "data-slot": "tr",
703
+ children: /* @__PURE__ */ jsx("td", {
704
+ className: classNames.loadingCell,
705
+ colSpan: visibleColumnCount,
706
+ "data-slot": "loading-cell",
707
+ children: loadingContent
708
+ })
709
+ }) : null, !loading && rowCount === 0 ? /* @__PURE__ */ jsx("tr", {
710
+ className: classNames.tr,
711
+ "data-slot": "tr",
712
+ children: /* @__PURE__ */ jsx("td", {
713
+ className: classNames.emptyCell,
714
+ colSpan: visibleColumnCount,
715
+ "data-slot": "empty-cell",
716
+ children: emptyContent
717
+ })
718
+ }) : null] });
719
+ };
720
+ //#endregion
622
721
  //#region src/DataTable/hooks/useDataTableVirtualizer.ts
623
722
  /**
624
723
  * Flattens current table state into virtual render items.
@@ -740,14 +839,14 @@ const useDataTableVirtualizer = ({ expandableRows, infiniteScroll, rows, scrollE
740
839
  };
741
840
  };
742
841
  //#endregion
743
- //#region src/DataTable/Subcomponents/DataTableVirtualBodyRows.tsx
842
+ //#region src/DataTable/subcomponents/DataTableVirtualBodyRows.tsx
744
843
  /**
745
844
  * Virtualized row renderer for DataTable body.
746
845
  *
747
846
  * It maps virtual items (row/expanded/placeholder/load-more) to absolute
748
847
  * positioned `<tr>` elements and delegates load-more retry handling.
749
848
  */
750
- const DataTableVirtualBodyRows = ({ classNames, expandableRows = void 0, infiniteScroll = void 0, loadingMoreContent = "Loading more...", retryContent = "Load next page", rows, scrollElementRef = void 0, virtualized, virtualization = void 0, visibleColumnCount }) => {
849
+ const DataTableVirtualBodyRows = ({ className: classNames, expandableRows = void 0, infiniteScroll = void 0, loadingMoreContent = "Loading more...", retryContent = "Load next page", rows, scrollElementRef = void 0, virtualized, virtualization = void 0, visibleColumnCount }) => {
751
850
  const { getItem, measureElement, retry, totalSize, virtualItems } = useDataTableVirtualizer({
752
851
  expandableRows,
753
852
  infiniteScroll,
@@ -780,7 +879,7 @@ const DataTableVirtualBodyRows = ({ classNames, expandableRows = void 0, infinit
780
879
  children: item.row.getVisibleCells().map((cell) => {
781
880
  return /* @__PURE__ */ jsx(DataTableBodyCell, {
782
881
  cell,
783
- classNames,
882
+ className: classNames,
784
883
  virtualized
785
884
  }, cell.id);
786
885
  })
@@ -842,64 +941,221 @@ const DataTableVirtualBodyRows = ({ classNames, expandableRows = void 0, infinit
842
941
  })] });
843
942
  };
844
943
  //#endregion
845
- //#region src/DataTable/DataTable.tsx
846
- const dataTableVariants = tv({ slots: {
847
- base: "w-full",
848
- checkbox: "relative inline-flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center rounded border border-divider bg-background align-middle text-foreground",
849
- checkboxIndicator: "pointer-events-none absolute inset-0 flex items-center justify-center text-[10px] leading-none",
850
- emptyCell: "h-24 text-center text-default-500",
851
- expandButton: "h-8 min-w-8 px-0 disabled:cursor-not-allowed data-[disabled=true]:pointer-events-auto data-[disabled=true]:cursor-not-allowed",
852
- expandIcon: "inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center text-default-500",
853
- expansionCell: "w-10 px-0 text-center",
854
- expansionCellContent: "flex justify-center",
855
- expandedRow: "bg-content1",
856
- expandedCell: "p-4 text-sm text-default-600",
857
- searchInput: "h-10 w-full max-w-sm rounded-small border-2 border-default-200 bg-transparent px-3 text-sm text-foreground outline-none transition-colors placeholder:text-default-500 hover:border-default-400 data-[focused=true]:border-focus dark:border-default-100",
858
- loadingCell: "h-24 text-center text-default-500",
859
- loadingMoreCell: "flex h-14 items-center justify-center text-default-500",
860
- nonSortableHeaderContent: "inline-flex items-center",
861
- pageSizeLabel: "flex items-center gap-2 text-sm text-default-500",
862
- pageSizeSelect: "min-w-16 justify-between gap-2",
863
- pageSummary: "text-sm text-default-500",
864
- pagination: "flex items-center gap-2 py-4",
865
- paginationButton: "",
866
- placeholderCell: "h-10 animate-pulse bg-default-100/60 p-3 dark:bg-default-100/10",
867
- selectionSummary: "mr-auto text-sm text-default-500",
868
- selectionCell: "w-10 px-0 text-center",
869
- selectionCellContent: "flex justify-center",
870
- sortButton: "-ml-2 min-w-0 justify-start gap-1.5 px-2 text-left font-medium text-foreground data-[sortable=true]:cursor-pointer",
871
- sortIcon: "inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center text-default-400",
872
- scrollContainer: "overflow-y-auto overflow-x-hidden",
873
- scrollShadow: "",
874
- table: "w-full caption-bottom text-sm",
875
- tableWrapper: "overflow-hidden rounded-md border border-divider",
876
- tbody: "",
877
- td: "p-3 align-middle text-foreground",
878
- th: "h-10 px-3 text-left align-middle font-medium text-foreground",
879
- thead: "bg-content2",
880
- toolbar: "flex items-center gap-3 py-4",
881
- toolbarContent: "flex flex-1 items-center",
882
- tr: "border-b border-divider last:border-b-0 data-[state=selected]:bg-content2/60",
883
- viewOptionsIndicator: "mr-2 inline-flex w-3 justify-center",
884
- viewOptionsItem: "data-highlighted:bg-default-100 dark:data-highlighted:bg-default-100/20 flex cursor-pointer items-center rounded px-2 py-1 text-sm text-foreground outline-none",
885
- viewOptionsMenu: "z-50 min-w-40 rounded-md border border-divider bg-background p-1 shadow-md",
886
- viewOptionsPositioner: "outline-none",
887
- viewOptionsTrigger: "ml-auto gap-2"
888
- } });
944
+ //#region src/DataTable/subcomponents/DataTableSurface.tsx
945
+ /** Semantic table surface with standard or virtualized row composition */
946
+ const DataTableSurface = ({ ariaLabel = void 0, className: classNames, emptyContent = void 0, expandableRows: resolvedExpandableRows = void 0, icons = void 0, infiniteScroll: resolvedInfiniteScroll = void 0, loading = false, loadingContent = void 0, scrollContainerRef, table, virtualization: virtualConfig = void 0, virtualized }) => {
947
+ const tableRows = table.getRowModel().rows;
948
+ const visibleColumnCount = table.getVisibleLeafColumns().length;
949
+ if (virtualized) return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("table", {
950
+ "aria-hidden": loading && tableRows.length === 0 ? "true" : void 0,
951
+ className: classNames.table,
952
+ "data-slot": "table",
953
+ style: { display: "grid" },
954
+ children: /* @__PURE__ */ jsx("thead", {
955
+ className: classNames.thead,
956
+ "data-slot": "thead",
957
+ children: /* @__PURE__ */ jsx(DataTableHeaderRows, {
958
+ className: classNames,
959
+ sortIcons: icons?.sort,
960
+ table,
961
+ virtualized: true
962
+ })
963
+ })
964
+ }), /* @__PURE__ */ jsx(ScrollShadow, {
965
+ ref: scrollContainerRef,
966
+ className: classNames.scrollShadow ? `${classNames.scrollContainer} ${classNames.scrollShadow}` : classNames.scrollContainer,
967
+ dataSlot: "scroll-container",
968
+ size: virtualConfig?.scrollShadowSize ?? 40,
969
+ style: { maxHeight: virtualConfig?.maxHeight },
970
+ visibility: resolvedInfiniteScroll?.loadMoreError ? "none" : "auto",
971
+ children: /* @__PURE__ */ jsx("table", {
972
+ "aria-label": ariaLabel,
973
+ className: classNames.table,
974
+ "data-slot": "table",
975
+ style: { display: "grid" },
976
+ children: /* @__PURE__ */ jsxs("tbody", {
977
+ className: classNames.tbody,
978
+ "data-slot": "tbody",
979
+ style: {
980
+ display: "grid",
981
+ position: "relative"
982
+ },
983
+ children: [loading ? null : /* @__PURE__ */ jsx(DataTableVirtualBodyRows, {
984
+ className: classNames,
985
+ expandableRows: resolvedExpandableRows,
986
+ infiniteScroll: resolvedInfiniteScroll,
987
+ loadingMoreContent: resolvedInfiniteScroll?.loadingMoreContent,
988
+ retryContent: resolvedInfiniteScroll?.retryContent,
989
+ rows: tableRows,
990
+ scrollElementRef: scrollContainerRef,
991
+ virtualization: virtualConfig,
992
+ virtualized: true,
993
+ visibleColumnCount
994
+ }), /* @__PURE__ */ jsx(DataTableStateRows, {
995
+ className: classNames,
996
+ emptyContent,
997
+ loading,
998
+ loadingContent,
999
+ rowCount: tableRows.length,
1000
+ visibleColumnCount
1001
+ })]
1002
+ })
1003
+ })
1004
+ })] });
1005
+ return /* @__PURE__ */ jsxs("table", {
1006
+ "aria-label": ariaLabel,
1007
+ className: classNames.table,
1008
+ "data-slot": "table",
1009
+ children: [/* @__PURE__ */ jsx("thead", {
1010
+ className: classNames.thead,
1011
+ "data-slot": "thead",
1012
+ children: /* @__PURE__ */ jsx(DataTableHeaderRows, {
1013
+ className: classNames,
1014
+ sortIcons: icons?.sort,
1015
+ table
1016
+ })
1017
+ }), /* @__PURE__ */ jsxs("tbody", {
1018
+ className: classNames.tbody,
1019
+ "data-slot": "tbody",
1020
+ children: [loading ? null : /* @__PURE__ */ jsx(DataTableBodyRows, {
1021
+ className: classNames,
1022
+ expandableRows: resolvedExpandableRows,
1023
+ rows: tableRows,
1024
+ visibleColumnCount
1025
+ }), /* @__PURE__ */ jsx(DataTableStateRows, {
1026
+ className: classNames,
1027
+ emptyContent,
1028
+ loading,
1029
+ loadingContent,
1030
+ rowCount: tableRows.length,
1031
+ visibleColumnCount
1032
+ })]
1033
+ })]
1034
+ });
1035
+ };
1036
+ //#endregion
1037
+ //#region src/DataTable/subcomponents/DataTableSearchInput.tsx
1038
+ /** Column search input that commits filters and resets server-side scrolling */
1039
+ const DataTableSearchInput = ({ className, infiniteScroll: resolvedInfiniteScroll = void 0, scrollContainerRef, searchFieldCount, searchField, table, testId = void 0 }) => {
1040
+ const searchValue = table.getColumn(searchField.column)?.getFilterValue() ?? "";
1041
+ let searchTestId;
1042
+ if (testId) searchTestId = searchFieldCount === 1 ? `${testId}-search` : `${testId}-search-${searchField.column}`;
1043
+ const handleChange = (event) => {
1044
+ const { value } = event.target;
1045
+ table.getColumn(searchField.column)?.setFilterValue(value);
1046
+ if (resolvedInfiniteScroll) {
1047
+ resolvedInfiniteScroll.onSearchChange?.(searchField.column, value);
1048
+ scrollContainerRef.current?.scrollTo({ top: 0 });
1049
+ }
1050
+ };
1051
+ return /* @__PURE__ */ jsx("input", {
1052
+ className,
1053
+ "data-focused": Boolean(searchValue),
1054
+ "data-slot": "search-input",
1055
+ "data-testid": searchTestId,
1056
+ onChange: handleChange,
1057
+ placeholder: searchField.placeholder ?? "Search...",
1058
+ value: searchValue
1059
+ });
1060
+ };
1061
+ //#endregion
1062
+ //#region src/DataTable/subcomponents/DataTableViewOptions.tsx
889
1063
  /**
890
- * Generic, feature-composable data table built on TanStack Table.
891
- *
892
- * Responsibilities:
893
- * - Renders semantic table markup (`table`, `thead`, `tbody`, `tr`, `th`, `td`).
894
- * - Wires sorting/search/visibility/selection/pagination state via
895
- * `useDataTableController`.
896
- * - Exposes slot-based styling through `dataTableVariants` + `className`.
897
- * - Supports optional custom toolbar content (e.g. megapixels `Filter`).
898
- *
899
- * Feature configuration:
900
- * - Configure search/visibility/selection/pagination through `features`.
1064
+ * Resolves a human-readable label for a column, preferring its string header
1065
+ * over the raw TanStack column id (e.g. "Status" instead of "status").
901
1066
  */
902
- const DataTable = ({ ariaLabel = "Data table", className = void 0, columns, data, emptyContent = "No results.", features = void 0, icons = void 0, loading = false, loadingContent = "Loading...", testId = void 0, toolbarContent = void 0 }) => {
1067
+ const getColumnLabel = (column) => {
1068
+ const { header } = column.columnDef;
1069
+ return typeof header === "string" ? header : column.id;
1070
+ };
1071
+ /** Dropdown for toggling table column visibility */
1072
+ const DataTableViewOptions = ({ className: classNames, table, triggerIcon = /* @__PURE__ */ jsx(LuColumns3, {}), visibleIcon = "✓", testId = void 0 }) => {
1073
+ const hideableColumns = table.getAllColumns().filter((column) => {
1074
+ return column.getCanHide();
1075
+ });
1076
+ const columnsById = new Map(hideableColumns.map((column) => {
1077
+ return [column.id, column];
1078
+ }));
1079
+ const items = hideableColumns.map((column) => {
1080
+ const columnLabel = getColumnLabel(column);
1081
+ return {
1082
+ key: column.id,
1083
+ className: classNames.viewOptionsItem,
1084
+ dataSlot: "view-options-item",
1085
+ textValue: columnLabel,
1086
+ label: /* @__PURE__ */ jsxs("span", {
1087
+ className: "flex items-center gap-2",
1088
+ children: [/* @__PURE__ */ jsx("span", {
1089
+ className: classNames.viewOptionsIndicator,
1090
+ "data-slot": "view-options-indicator",
1091
+ children: column.getIsVisible() && visibleIcon !== false ? visibleIcon : ""
1092
+ }), columnLabel]
1093
+ })
1094
+ };
1095
+ });
1096
+ return /* @__PURE__ */ jsxs(Menu, {
1097
+ items,
1098
+ onAction: (key) => {
1099
+ const column = columnsById.get(String(key));
1100
+ if (!column) return;
1101
+ column.toggleVisibility(!column.getIsVisible());
1102
+ },
1103
+ testId: testId ? `${testId}-column-visibility-trigger` : void 0,
1104
+ triggerButtonProps: {
1105
+ "aria-label": "Toggle column visibility",
1106
+ className: classNames.viewOptionsTrigger,
1107
+ dataSlot: "view-options-trigger",
1108
+ disableRipple: true,
1109
+ size: "sm",
1110
+ variant: "bordered"
1111
+ },
1112
+ children: [triggerIcon === false ? null : triggerIcon, "Columns"]
1113
+ });
1114
+ };
1115
+ //#endregion
1116
+ //#region src/DataTable/subcomponents/DataTableToolbar.tsx
1117
+ /** Search, custom actions and column visibility controls above the table */
1118
+ const DataTableToolbar = ({ className: classNames, columnVisibility: resolvedEnableColumnVisibility, icons = void 0, infiniteScroll: resolvedInfiniteScroll = void 0, scrollContainerRef, searchFields: resolvedSearchFields, table, testId = void 0, toolbarContent = void 0 }) => {
1119
+ const showToolbar = resolvedSearchFields.length > 0 || resolvedEnableColumnVisibility || Boolean(toolbarContent);
1120
+ return /* @__PURE__ */ jsx(Fragment$1, { children: showToolbar ? /* @__PURE__ */ jsxs("div", {
1121
+ className: classNames.toolbar,
1122
+ "data-slot": "toolbar",
1123
+ children: [
1124
+ toolbarContent ? /* @__PURE__ */ jsx("div", {
1125
+ className: classNames.toolbarContent,
1126
+ "data-slot": "toolbar-content",
1127
+ children: toolbarContent
1128
+ }) : null,
1129
+ resolvedSearchFields.map((searchField) => {
1130
+ return /* @__PURE__ */ jsx(DataTableSearchInput, {
1131
+ className: classNames.searchInput,
1132
+ infiniteScroll: resolvedInfiniteScroll,
1133
+ scrollContainerRef,
1134
+ searchField,
1135
+ searchFieldCount: resolvedSearchFields.length,
1136
+ table,
1137
+ testId
1138
+ }, searchField.column);
1139
+ }),
1140
+ resolvedEnableColumnVisibility ? /* @__PURE__ */ jsx(DataTableViewOptions, {
1141
+ className: {
1142
+ viewOptionsIndicator: classNames.viewOptionsIndicator,
1143
+ viewOptionsItem: classNames.viewOptionsItem,
1144
+ viewOptionsTrigger: classNames.viewOptionsTrigger
1145
+ },
1146
+ table,
1147
+ testId,
1148
+ triggerIcon: icons?.columnVisibility?.trigger,
1149
+ visibleIcon: icons?.columnVisibility?.visible
1150
+ }) : null
1151
+ ]
1152
+ }) : null });
1153
+ };
1154
+ //#endregion
1155
+ //#region src/DataTable/subcomponents/DataTableControl.tsx
1156
+ /** Table feature state and composition of toolbar, rows and pagination */
1157
+ const DataTableControl = ({ ariaLabel = "Data table", className: classNames, columns, data, emptyContent = "No results.", features = void 0, icons = void 0, loading = false, loadingContent = "Loading...", testId = void 0, toolbarContent = void 0 }) => {
1158
+ const scrollContainerRef = useRef(null);
903
1159
  const resolvedEnableColumnVisibility = features?.columnVisibility ?? false;
904
1160
  const resolvedExpandableRows = features?.expandableRows;
905
1161
  const resolvedEnableExpandableRows = Boolean(resolvedExpandableRows);
@@ -920,13 +1176,10 @@ const DataTable = ({ ariaLabel = "Data table", className = void 0, columns, data
920
1176
  dynamicRowHeight: true,
921
1177
  maxHeight: 600
922
1178
  } : void 0);
923
- const variants = dataTableVariants();
924
- const scrollContainerRef = useRef(null);
925
1179
  const handleSortingChange = useCallback((sorting) => {
926
1180
  if (resolvedInfiniteScroll) scrollContainerRef.current?.scrollTo({ top: 0 });
927
1181
  resolvedInfiniteScroll?.onSortingChange?.(sorting);
928
1182
  }, [resolvedInfiniteScroll]);
929
- const classNames = variantsToClassNames(variants, className, "base");
930
1183
  const checkboxClassNames = useMemo(() => {
931
1184
  return {
932
1185
  checkbox: classNames.checkbox,
@@ -945,8 +1198,8 @@ const DataTable = ({ ariaLabel = "Data table", className = void 0, columns, data
945
1198
  data,
946
1199
  enableExpandableRows: resolvedEnableExpandableRows,
947
1200
  enablePagination: resolvedEnablePagination,
948
- enableServerMode: Boolean(resolvedInfiniteScroll),
949
1201
  enableRowSelection: resolvedEnableRowSelection,
1202
+ enableServerMode: Boolean(resolvedInfiniteScroll),
950
1203
  expansionClassNames,
951
1204
  expansionIcons: icons?.expandableRows,
952
1205
  getSubRows: resolvedExpandableRows?.getSubRows,
@@ -955,172 +1208,43 @@ const DataTable = ({ ariaLabel = "Data table", className = void 0, columns, data
955
1208
  pageSizeOptions: resolvedPageSizeOptions,
956
1209
  selectionIcons: icons?.selection
957
1210
  });
958
- const visibleColumnCount = table.getVisibleLeafColumns().length;
959
- const tableRows = table.getRowModel().rows;
960
- const showToolbar = resolvedSearchFields.length > 0 || resolvedEnableColumnVisibility || Boolean(toolbarContent);
961
- const renderHeaderRows = (virtualized) => {
962
- return table.getHeaderGroups().map((headerGroup) => {
963
- return /* @__PURE__ */ jsx("tr", {
964
- className: classNames.tr,
965
- "data-slot": "tr",
966
- style: virtualized ? {
967
- display: "flex",
968
- width: "100%"
969
- } : void 0,
970
- children: headerGroup.headers.map((header) => {
971
- return /* @__PURE__ */ jsx(DataTableHeaderCell, {
972
- classNames,
973
- header,
974
- sortIcons: icons?.sort,
975
- virtualized
976
- }, header.id);
977
- })
978
- }, headerGroup.id);
979
- });
980
- };
981
- const renderBodyStateRows = () => {
982
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [loading ? /* @__PURE__ */ jsx("tr", {
983
- className: classNames.tr,
984
- "data-slot": "tr",
985
- children: /* @__PURE__ */ jsx("td", {
986
- className: classNames.loadingCell,
987
- colSpan: visibleColumnCount,
988
- "data-slot": "loading-cell",
989
- children: loadingContent
990
- })
991
- }) : null, !loading && tableRows.length === 0 ? /* @__PURE__ */ jsx("tr", {
992
- className: classNames.tr,
993
- "data-slot": "tr",
994
- children: /* @__PURE__ */ jsx("td", {
995
- className: classNames.emptyCell,
996
- colSpan: visibleColumnCount,
997
- "data-slot": "empty-cell",
998
- children: emptyContent
999
- })
1000
- }) : null] });
1001
- };
1002
- const renderVirtualizedTable = () => {
1003
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("table", {
1004
- "aria-hidden": loading && tableRows.length === 0 ? "true" : void 0,
1005
- className: classNames.table,
1006
- "data-slot": "table",
1007
- style: { display: "grid" },
1008
- children: /* @__PURE__ */ jsx("thead", {
1009
- className: classNames.thead,
1010
- "data-slot": "thead",
1011
- children: renderHeaderRows(true)
1012
- })
1013
- }), /* @__PURE__ */ jsx(ScrollShadow, {
1014
- ref: scrollContainerRef,
1015
- className: classNames.scrollShadow ? `${classNames.scrollContainer} ${classNames.scrollShadow}` : classNames.scrollContainer,
1016
- dataSlot: "scroll-container",
1017
- size: virtualConfig?.scrollShadowSize ?? 40,
1018
- style: { maxHeight: virtualConfig?.maxHeight },
1019
- visibility: resolvedInfiniteScroll?.loadMoreError ? "none" : "auto",
1020
- children: /* @__PURE__ */ jsx("table", {
1021
- "aria-label": ariaLabel,
1022
- className: classNames.table,
1023
- "data-slot": "table",
1024
- style: { display: "grid" },
1025
- children: /* @__PURE__ */ jsxs("tbody", {
1026
- className: classNames.tbody,
1027
- "data-slot": "tbody",
1028
- style: {
1029
- display: "grid",
1030
- position: "relative"
1031
- },
1032
- children: [loading ? null : /* @__PURE__ */ jsx(DataTableVirtualBodyRows, {
1033
- classNames,
1034
- expandableRows: resolvedExpandableRows,
1035
- infiniteScroll: resolvedInfiniteScroll,
1036
- loadingMoreContent: resolvedInfiniteScroll?.loadingMoreContent,
1037
- retryContent: resolvedInfiniteScroll?.retryContent,
1038
- rows: tableRows,
1039
- scrollElementRef: scrollContainerRef,
1040
- virtualization: virtualConfig,
1041
- virtualized: true,
1042
- visibleColumnCount
1043
- }), renderBodyStateRows()]
1044
- })
1045
- })
1046
- })] });
1047
- };
1048
- const renderStandardTable = () => {
1049
- return /* @__PURE__ */ jsxs("table", {
1050
- "aria-label": ariaLabel,
1051
- className: classNames.table,
1052
- "data-slot": "table",
1053
- children: [/* @__PURE__ */ jsx("thead", {
1054
- className: classNames.thead,
1055
- "data-slot": "thead",
1056
- children: renderHeaderRows(false)
1057
- }), /* @__PURE__ */ jsxs("tbody", {
1058
- className: classNames.tbody,
1059
- "data-slot": "tbody",
1060
- children: [loading ? null : /* @__PURE__ */ jsx(DataTableBodyRows, {
1061
- classNames,
1062
- expandableRows: resolvedExpandableRows,
1063
- rows: tableRows,
1064
- visibleColumnCount
1065
- }), renderBodyStateRows()]
1066
- })]
1067
- });
1068
- };
1069
1211
  return /* @__PURE__ */ jsxs("div", {
1070
1212
  className: classNames.base,
1213
+ "data-component": "data-table",
1071
1214
  "data-slot": "base",
1072
1215
  "data-testid": testId,
1073
1216
  children: [
1074
- showToolbar ? /* @__PURE__ */ jsxs("div", {
1075
- className: classNames.toolbar,
1076
- "data-slot": "toolbar",
1077
- children: [
1078
- toolbarContent ? /* @__PURE__ */ jsx("div", {
1079
- className: classNames.toolbarContent,
1080
- "data-slot": "toolbar-content",
1081
- children: toolbarContent
1082
- }) : null,
1083
- resolvedSearchFields.map((searchField) => {
1084
- const searchValue = table.getColumn(searchField.column)?.getFilterValue() ?? "";
1085
- let searchTestId;
1086
- if (testId) searchTestId = resolvedSearchFields.length === 1 ? `${testId}-search` : `${testId}-search-${searchField.column}`;
1087
- return /* @__PURE__ */ jsx("input", {
1088
- className: classNames.searchInput,
1089
- "data-focused": Boolean(searchValue),
1090
- "data-slot": "search-input",
1091
- "data-testid": searchTestId,
1092
- onChange: (event) => {
1093
- const { value } = event.target;
1094
- table.getColumn(searchField.column)?.setFilterValue(value);
1095
- if (resolvedInfiniteScroll) {
1096
- resolvedInfiniteScroll.onSearchChange?.(searchField.column, value);
1097
- scrollContainerRef.current?.scrollTo({ top: 0 });
1098
- }
1099
- },
1100
- placeholder: searchField.placeholder ?? "Search...",
1101
- value: searchValue
1102
- }, searchField.column);
1103
- }),
1104
- resolvedEnableColumnVisibility ? /* @__PURE__ */ jsx(DataTableViewOptions, {
1105
- classNames: {
1106
- viewOptionsIndicator: classNames.viewOptionsIndicator,
1107
- viewOptionsItem: classNames.viewOptionsItem,
1108
- viewOptionsTrigger: classNames.viewOptionsTrigger
1109
- },
1110
- table,
1111
- testId,
1112
- triggerIcon: icons?.columnVisibility?.trigger,
1113
- visibleIcon: icons?.columnVisibility?.visible
1114
- }) : null
1115
- ]
1116
- }) : null,
1217
+ /* @__PURE__ */ jsx(DataTableToolbar, {
1218
+ className: classNames,
1219
+ columnVisibility: resolvedEnableColumnVisibility,
1220
+ icons,
1221
+ infiniteScroll: resolvedInfiniteScroll,
1222
+ scrollContainerRef,
1223
+ searchFields: resolvedSearchFields,
1224
+ table,
1225
+ testId,
1226
+ toolbarContent
1227
+ }),
1117
1228
  /* @__PURE__ */ jsx("div", {
1118
1229
  className: classNames.tableWrapper,
1119
1230
  "data-slot": "table-wrapper",
1120
- children: resolvedEnableVirtualization ? renderVirtualizedTable() : renderStandardTable()
1231
+ children: /* @__PURE__ */ jsx(DataTableSurface, {
1232
+ ariaLabel,
1233
+ className: classNames,
1234
+ emptyContent,
1235
+ expandableRows: resolvedExpandableRows,
1236
+ icons,
1237
+ infiniteScroll: resolvedInfiniteScroll,
1238
+ loading,
1239
+ loadingContent,
1240
+ scrollContainerRef,
1241
+ table,
1242
+ virtualization: virtualConfig,
1243
+ virtualized: resolvedEnableVirtualization
1244
+ })
1121
1245
  }),
1122
1246
  resolvedEnablePagination ? /* @__PURE__ */ jsx(DataTablePagination, {
1123
- classNames: {
1247
+ className: {
1124
1248
  pageSizeLabel: classNames.pageSizeLabel,
1125
1249
  pageSizeSelect: classNames.pageSizeSelect,
1126
1250
  pageSummary: classNames.pageSummary,
@@ -1138,9 +1262,29 @@ const DataTable = ({ ariaLabel = "Data table", className = void 0, columns, data
1138
1262
  });
1139
1263
  };
1140
1264
  //#endregion
1265
+ //#region src/DataTable/DataTable.tsx
1266
+ /**
1267
+ * Configurable data table built on TanStack Table with semantic table markup
1268
+ *
1269
+ * Configure search, sorting, column visibility, row selection and pagination
1270
+ * through column definitions and `features`, with optional custom toolbar content
1271
+ *
1272
+ * Supports virtual scrolling and cursor-based loading for larger datasets
1273
+ * Customize individual slots through `className`
1274
+ */
1275
+ const DataTable = ({ className = void 0, ...props }) => {
1276
+ const styling = useStyling();
1277
+ const variants = styling.resolve(dataTableVariants);
1278
+ const classNames = styling.variantsToClassNames(variants, className, "base");
1279
+ return /* @__PURE__ */ jsx(DataTableControl, {
1280
+ ...props,
1281
+ className: classNames
1282
+ });
1283
+ };
1284
+ //#endregion
1141
1285
  //#region src/DataTable/index.ts
1142
1286
  var DataTable_default = DataTable;
1143
1287
  //#endregion
1144
1288
  export { DataTable as n, dataTableVariants as r, DataTable_default as t };
1145
1289
 
1146
- //# sourceMappingURL=DataTable-Dw8152NO.mjs.map
1290
+ //# sourceMappingURL=DataTable-Ml6QySfA.mjs.map