@brotskyllc/react-data-table 0.0.0-stage → 0.1.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 (94) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +68 -2
  3. package/THIRD_PARTY_NOTICES.md +27 -0
  4. package/dist/ColumnResizeHandle.d.ts +9 -0
  5. package/dist/ColumnResizeHandle.js +49 -0
  6. package/dist/DataTableDraggableRows.d.ts +21 -0
  7. package/dist/DataTableDraggableRows.js +29 -0
  8. package/dist/DataTableRows.d.ts +22 -0
  9. package/dist/DataTableRows.js +62 -0
  10. package/dist/DataTableSkeletonRows.d.ts +8 -0
  11. package/dist/DataTableSkeletonRows.js +9 -0
  12. package/dist/DataTableTableContent.d.ts +28 -0
  13. package/dist/DataTableTableContent.js +46 -0
  14. package/dist/TableCell.d.ts +7 -0
  15. package/dist/TableCell.js +20 -0
  16. package/dist/TableHeader.d.ts +16 -0
  17. package/dist/TableHeader.js +42 -0
  18. package/dist/TableRow.d.ts +26 -0
  19. package/dist/TableRow.js +31 -0
  20. package/dist/cn.d.ts +2 -0
  21. package/dist/cn.js +3 -0
  22. package/dist/columnResizeTypes.d.ts +18 -0
  23. package/dist/columnResizeTypes.js +1 -0
  24. package/dist/columnTypes.d.ts +25 -0
  25. package/dist/columnTypes.js +1 -0
  26. package/dist/columnWidthStorage.d.ts +13 -0
  27. package/dist/columnWidthStorage.js +53 -0
  28. package/dist/compat.d.ts +17 -0
  29. package/dist/compat.js +19 -0
  30. package/dist/getColumnWidthStyle.d.ts +1 -0
  31. package/dist/getColumnWidthStyle.js +7 -0
  32. package/dist/getTableHeaderFlexClassName.d.ts +2 -0
  33. package/dist/getTableHeaderFlexClassName.js +6 -0
  34. package/dist/index.d.ts +6 -0
  35. package/dist/index.js +4 -0
  36. package/dist/isRowClickSelectTarget.d.ts +1 -0
  37. package/dist/isRowClickSelectTarget.js +34 -0
  38. package/dist/rowIds.d.ts +2 -0
  39. package/dist/rowIds.js +2 -0
  40. package/dist/rowPickerOpenState.d.ts +11 -0
  41. package/dist/rowPickerOpenState.js +41 -0
  42. package/dist/selectionTypes.d.ts +10 -0
  43. package/dist/selectionTypes.js +1 -0
  44. package/dist/sortOrder.d.ts +5 -0
  45. package/dist/sortOrder.js +1 -0
  46. package/dist/sortRowsByColumn.d.ts +9 -0
  47. package/dist/sortRowsByColumn.js +40 -0
  48. package/dist/stripImportantWidthClasses.d.ts +1 -0
  49. package/dist/stripImportantWidthClasses.js +9 -0
  50. package/dist/types.d.ts +47 -0
  51. package/dist/types.js +1 -0
  52. package/dist/ui/skeleton.d.ts +2 -0
  53. package/dist/ui/skeleton.js +6 -0
  54. package/dist/ui/table-scroll-region.d.ts +11 -0
  55. package/dist/ui/table-scroll-region.js +30 -0
  56. package/dist/ui/table.d.ts +51 -0
  57. package/dist/ui/table.js +20 -0
  58. package/dist/ui/tableScrollRegion.d.ts +15 -0
  59. package/dist/ui/tableScrollRegion.js +10 -0
  60. package/dist/ui/tooltip.d.ts +12 -0
  61. package/dist/ui/tooltip.js +10 -0
  62. package/dist/utils.d.ts +1 -0
  63. package/dist/utils.js +5 -0
  64. package/package.json +65 -4
  65. package/src/ColumnResizeHandle.tsx +102 -0
  66. package/src/DataTableDraggableRows.tsx +132 -0
  67. package/src/DataTableRows.tsx +239 -0
  68. package/src/DataTableSkeletonRows.tsx +46 -0
  69. package/src/DataTableTableContent.tsx +160 -0
  70. package/src/TableCell.tsx +39 -0
  71. package/src/TableHeader.tsx +205 -0
  72. package/src/TableRow.tsx +151 -0
  73. package/src/cn.ts +3 -0
  74. package/src/columnResizeTypes.ts +26 -0
  75. package/src/columnTypes.ts +39 -0
  76. package/src/columnWidthStorage.ts +94 -0
  77. package/src/compat.ts +19 -0
  78. package/src/getColumnWidthStyle.ts +11 -0
  79. package/src/getTableHeaderFlexClassName.ts +14 -0
  80. package/src/index.ts +13 -0
  81. package/src/isRowClickSelectTarget.ts +39 -0
  82. package/src/rowIds.ts +11 -0
  83. package/src/rowPickerOpenState.tsx +98 -0
  84. package/src/selectionTypes.ts +16 -0
  85. package/src/sortOrder.ts +2 -0
  86. package/src/sortRowsByColumn.ts +72 -0
  87. package/src/stripImportantWidthClasses.ts +16 -0
  88. package/src/types.ts +51 -0
  89. package/src/ui/skeleton.tsx +15 -0
  90. package/src/ui/table-scroll-region.tsx +68 -0
  91. package/src/ui/table.tsx +147 -0
  92. package/src/ui/tableScrollRegion.ts +33 -0
  93. package/src/ui/tooltip.tsx +36 -0
  94. package/src/utils.ts +5 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AEGIS Security & Investigations
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,69 @@
1
- # Temporary Holding Version
1
+ # React Data Table
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ <p>
4
+ <a href="https://www.prlane.com/"><img src="https://www.prlane.com/brand/prlane/prlane-symbol-dark.png" width="24" alt=""> Proudly uses PRLane</a>
5
+ ·
6
+ <a href="https://www.brotskydesigns.com/"><img src="https://www.brotskydesigns.com/apple-touch-icon.png" width="24" height="24" alt=""> By Brotsky Designs</a>
7
+ </p>
8
+
9
+ A controlled React 19 table renderer extracted from AEGIS's shared table. The host owns data fetching, search, filtering, pagination, selection state, preferences, business actions, and exports. No network or storage access is performed by this package.
10
+
11
+ **MIT licensed.** Source is public. The public npm package name is `@brotskyllc/react-data-table`; after its first release, install with `npm install --save-exact @brotskyllc/react-data-table@0.1.0`. Use `npm view @brotskyllc/react-data-table version` to check registry availability. A checksum-verified `npm pack` artifact is also supported. Preserve LICENSE and THIRD_PARTY_NOTICES.md when redistributing.
12
+
13
+ ## Usage
14
+
15
+ ```tsx
16
+ 'use client';
17
+ import { DataTableCore, type TableColumn } from '@brotskyllc/react-data-table';
18
+
19
+ type Item = { id: string; name: string; count: number };
20
+ const columns: TableColumn<Item>[] = [
21
+ { key: 'name', header: 'Name' },
22
+ { key: 'count', header: 'Count', className: 'text-right' },
23
+ { key: 'actions', header: 'Actions', render: (_value, row) => <button onClick={() => console.log(row.id)}>Open</button> },
24
+ ];
25
+ export function Example({ rows }: { rows: Item[] }) {
26
+ return <DataTableCore data={rows} columns={columns} scrollAreaLabel="Items"
27
+ onSort={() => {}} onSelectAll={() => {}} onRowSelect={() => {}} />;
28
+ }
29
+ ```
30
+
31
+ Use stable unique string `id` values for selection, expansion, dragging, and inline pickers. The index fallback is only suitable for static, non-interactive rows.
32
+
33
+ ## Styling and customization
34
+
35
+ The package uses Tailwind utilities and semantic tokens (`background`, `foreground`, `muted`, `border`, `ring`, `primary`, `popover`). Include its published source in the host's Tailwind scan. For Tailwind 4, add a path relative to the stylesheet:
36
+
37
+ ```css
38
+ @source "../../../node_modules/@brotskyllc/react-data-table/src";
39
+ ```
40
+
41
+ For Tailwind 3 include `./node_modules/@brotskyllc/react-data-table/src/**/*.{ts,tsx}` in `content`. Supply your existing light/dark theme and animation utilities.
42
+
43
+ - `columns`: nested keys, custom cell rendering, widths, alignment, header tooltips, `headerClassName` and cell classes.
44
+ - `sort` + `onSort`: controlled indicator and callback. The renderer never rearranges rows. `sortRowsByColumn` is an optional immutable client-sort helper.
45
+ - `selection`, `allSelected`, `hasSelectableRows`, `onSelectAll`, `onRowSelect`: host-controlled state and eligibility. The host defines selection scope and keeps off-page selections.
46
+ - `expandableRows`: controlled or local expansion with accessible toggle labels and panel IDs.
47
+ - `columnResize`: a structural `ColumnResizeApi` adapter. The host owns measurement, bounds, storage and persistence. Controls support pointer dragging, arrows (Shift for larger steps), Home and double-click reset.
48
+ - `draggable`: opt-in lazy drag-and-drop body and host `onDragEnd`; requires stable IDs. React Suspense replaces the original Next-specific loader.
49
+ - `rowClassName`, row hover/click callbacks, test IDs, `footer`, `emptyState`, `isTableLoading`, and `loadingRowCount` cover presentation customization.
50
+ - `useDataTableRowPickerOpen`: preserves inline picker state through row refreshes. Import this hook from the same package as the renderer so context identity stays shared.
51
+
52
+ Keep authentication, GraphQL types, application IDs, export auditing, saved views, responsive facet chrome, pagination and retry UI in the host. Business actions remain cell render functions supplied by the app.
53
+
54
+ ## Development and distribution
55
+
56
+ ```sh
57
+ npm ci
58
+ npm run build
59
+ bun test
60
+ npm pack --dry-run
61
+ npm run check:package
62
+ npm run test:consumer
63
+ ```
64
+
65
+ TypeScript emits ESM and declarations. React remains a peer dependency; third-party code is installed as dependencies rather than bundled. The client entry preserves `use client`; relative imports use `.js` for native ESM compatibility.
66
+
67
+ The build clears old output before compiling. The package audit inspects the real tarball, checks its allowlist, export targets, client boundaries and React peers, and scans for credential patterns, private imports and workstation paths. The consumer check installs that tarball into a temporary application, resolves both entries in native ESM, checks declarations with strict TypeScript settings, server-renders synthetic rows, and generates Tailwind 3 styles from the published source. It uses network access to install public dependencies and removes its temporary files on completion. Neither check publishes anything.
68
+
69
+ The initial adapters should be reviewed before expanding migration to other tables. No registry publish automation is configured. Registry publication requires owner approval, verified npm organization access and a final pack audit. Publish an approved tarball with `npm publish <tarball> --access public --registry=https://registry.npmjs.org/`. Never commit registry credentials.
@@ -0,0 +1,27 @@
1
+ # Third-party notices
2
+
3
+ The table, tooltip and skeleton primitives are derived from shadcn/ui.
4
+
5
+ MIT License
6
+
7
+ Copyright (c) 2023 shadcn
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in all
17
+ copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE.
26
+
27
+ Runtime packages are installed as dependencies, not bundled: React (MIT), Radix (MIT), clsx (MIT), tailwind-merge (MIT), lucide-react (ISC), @hello-pangea/dnd (Apache-2.0). Their package notices remain distributed by their respective packages.
@@ -0,0 +1,9 @@
1
+ import type { ColumnResizeApi } from "./columnResizeTypes.js";
2
+ interface ColumnResizeHandleProps {
3
+ columnKey: string;
4
+ columnHeader: string;
5
+ width: number | undefined;
6
+ columnResize: ColumnResizeApi;
7
+ }
8
+ export declare const ColumnResizeHandle: ({ columnKey, columnHeader, width, columnResize, }: ColumnResizeHandleProps) => import("react").JSX.Element;
9
+ export {};
@@ -0,0 +1,49 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { cn } from "./cn.js";
3
+ import { MAX_COLUMN_WIDTH_PX, MIN_COLUMN_WIDTH_PX, } from "./columnWidthStorage.js";
4
+ const KEYBOARD_STEP_PX = 16;
5
+ const KEYBOARD_LARGE_STEP_PX = 48;
6
+ export const ColumnResizeHandle = ({ columnKey, columnHeader, width, columnResize, }) => {
7
+ const bounds = columnResize.getColumnBounds?.(columnKey);
8
+ const isResizing = columnResize.resizingColumnKey === columnKey;
9
+ const handleKeyDown = (event) => {
10
+ const step = event.shiftKey ? KEYBOARD_LARGE_STEP_PX : KEYBOARD_STEP_PX;
11
+ if (event.key === "ArrowLeft") {
12
+ event.preventDefault();
13
+ columnResize.nudgeWidth(columnKey, -step);
14
+ return;
15
+ }
16
+ if (event.key === "ArrowRight") {
17
+ event.preventDefault();
18
+ columnResize.nudgeWidth(columnKey, step);
19
+ return;
20
+ }
21
+ if (event.key === "Home") {
22
+ event.preventDefault();
23
+ columnResize.resetWidth(columnKey);
24
+ }
25
+ };
26
+ return (_jsx("div", { role: "separator", "aria-orientation": "vertical", "aria-label": `Resize ${columnHeader} column`, "aria-valuenow": width, "aria-valuemin": bounds?.min ?? MIN_COLUMN_WIDTH_PX, "aria-valuemax": bounds?.max ?? MAX_COLUMN_WIDTH_PX, tabIndex: 0, "data-testid": `datatable-column-resize-${columnKey}`, "data-resizing": isResizing ? "true" : undefined, className: "group/resize absolute inset-y-0 right-0 z-10 flex w-3 cursor-col-resize touch-none select-none items-center justify-center focus:outline-none", onPointerDown: (event) => {
27
+ event.preventDefault();
28
+ event.stopPropagation();
29
+ columnResize.startResize(columnKey, event.clientX);
30
+ try {
31
+ event.currentTarget.setPointerCapture?.(event.pointerId);
32
+ }
33
+ catch { }
34
+ }, onPointerMove: (event) => {
35
+ event.stopPropagation();
36
+ columnResize.updateResize(event.clientX);
37
+ }, onPointerUp: (event) => {
38
+ event.stopPropagation();
39
+ event.currentTarget.releasePointerCapture?.(event.pointerId);
40
+ columnResize.endResize();
41
+ }, onPointerCancel: () => {
42
+ columnResize.endResize();
43
+ }, onClick: (event) => {
44
+ event.stopPropagation();
45
+ }, onDoubleClick: (event) => {
46
+ event.stopPropagation();
47
+ columnResize.resetWidth(columnKey);
48
+ }, onKeyDown: handleKeyDown, children: _jsx("span", { "aria-hidden": "true", className: cn("h-1/2 w-px rounded-full bg-border transition-colors", "group-hover/resize:w-0.5 group-hover/resize:bg-primary", "group-focus/resize:w-0.5 group-focus/resize:bg-primary", isResizing && "w-0.5 bg-primary") }) }));
49
+ };
@@ -0,0 +1,21 @@
1
+ import { type ReactNode } from "react";
2
+ import type { DataTableProps, TableColumn } from "./types.js";
3
+ export type DataTableDraggableRowsProps<T> = {
4
+ data: T[];
5
+ columns: TableColumn<T>[];
6
+ draggable: NonNullable<DataTableProps<T>["draggable"]>;
7
+ selection?: DataTableProps<T>["selection"];
8
+ expandableRows?: DataTableProps<T>["expandableRows"];
9
+ expandedRowIds: Set<string>;
10
+ onToggleRowExpansion: (rowId: string) => void;
11
+ onRowSelect: (rowId: string) => void;
12
+ tableInstanceId: string;
13
+ isTableLoading: boolean;
14
+ rowClassName?: (row: T) => string;
15
+ getRowDataTestId?: (row: T) => string | undefined;
16
+ onRowClick?: DataTableProps<T>["onRowClick"];
17
+ onRowMouseEnter?: (row: T) => void;
18
+ onRowMouseLeave?: () => void;
19
+ renderExpandedContentRow: (row: T, expandedContentRowId: string, isExpanded: boolean, rowCanExpand: boolean) => ReactNode;
20
+ };
21
+ export declare const DataTableDraggableRows: <T>({ data, columns, draggable, selection, expandableRows, expandedRowIds, onToggleRowExpansion, onRowSelect, tableInstanceId, isTableLoading, rowClassName, getRowDataTestId, onRowClick, onRowMouseEnter, onRowMouseLeave, renderExpandedContentRow, }: DataTableDraggableRowsProps<T>) => import("react").JSX.Element;
@@ -0,0 +1,29 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { DragDropContext, Draggable, Droppable } from "@hello-pangea/dnd";
4
+ import { Fragment } from "react";
5
+ import { TableBody } from "./ui/table.js";
6
+ import { cn } from "./cn.js";
7
+ import { getExpandedContentRowId, getRowId } from "./rowIds.js";
8
+ import { DataTableRowIdProvider } from "./rowPickerOpenState.js";
9
+ import { DataTableRow } from "./TableRow.js";
10
+ export const DataTableDraggableRows = ({ data, columns, draggable, selection, expandableRows, expandedRowIds, onToggleRowExpansion, onRowSelect, tableInstanceId, isTableLoading, rowClassName, getRowDataTestId, onRowClick, onRowMouseEnter, onRowMouseLeave, renderExpandedContentRow, }) => {
11
+ return (_jsx(DragDropContext, { onDragEnd: draggable.onDragEnd, children: _jsx(Droppable, { droppableId: "table-body", type: "table-row", children: (provided) => (_jsxs(TableBody, { ...provided.droppableProps, ref: provided.innerRef, className: cn("transition-opacity duration-200", isTableLoading && "opacity-50"), children: [data.map((row, index) => {
12
+ const rowId = getRowId(row, index);
13
+ const rowCanExpand = expandableRows
14
+ ? (expandableRows.isRowExpandable?.(row) ?? true)
15
+ : false;
16
+ const isRowExpanded = rowCanExpand && expandedRowIds.has(rowId);
17
+ const expandedContentRowId = getExpandedContentRowId(tableInstanceId, rowId);
18
+ return (_jsx(Fragment, { children: _jsxs(DataTableRowIdProvider, { rowId: rowId, children: [_jsx(Draggable, { draggableId: rowId, index: index, children: (draggableProvided) => (_jsx(DataTableRow, { row: row, rowId: rowId, columns: columns, selection: selection, draggable: draggable, expandableRows: expandableRows
19
+ ? {
20
+ isRowExpandable: rowCanExpand,
21
+ isExpanded: isRowExpanded,
22
+ expandedContentId: expandedContentRowId,
23
+ onToggleExpand: () => onToggleRowExpansion(rowId),
24
+ toggleAriaLabel: expandableRows.getToggleAriaLabel?.(row, isRowExpanded),
25
+ toggleDataTestId: expandableRows.getToggleDataTestId?.(row),
26
+ }
27
+ : undefined, provided: draggableProvided, rowClassName: rowClassName, getRowDataTestId: getRowDataTestId, onRowClick: onRowClick, onRowMouseEnter: onRowMouseEnter, onRowMouseLeave: onRowMouseLeave, onRowSelect: onRowSelect })) }), renderExpandedContentRow(row, expandedContentRowId, isRowExpanded, rowCanExpand)] }) }, rowId));
28
+ }), provided.placeholder] })) }) }));
29
+ };
@@ -0,0 +1,22 @@
1
+ import type { DataTableProps, TableColumn } from "./types.js";
2
+ type DataTableRowsProps<T> = {
3
+ data: T[];
4
+ columns: TableColumn<T>[];
5
+ draggable?: DataTableProps<T>["draggable"];
6
+ selection?: DataTableProps<T>["selection"];
7
+ expandableRows?: DataTableProps<T>["expandableRows"];
8
+ expandedRowIds: Set<string>;
9
+ onToggleRowExpansion: (rowId: string) => void;
10
+ onRowSelect: (rowId: string) => void;
11
+ tableInstanceId: string;
12
+ isTableLoading: boolean;
13
+ loadingRowCount: number;
14
+ emptyState?: DataTableProps<T>["emptyState"];
15
+ rowClassName?: (row: T) => string;
16
+ getRowDataTestId?: (row: T) => string | undefined;
17
+ onRowClick?: DataTableProps<T>["onRowClick"];
18
+ onRowMouseEnter?: (row: T) => void;
19
+ onRowMouseLeave?: () => void;
20
+ };
21
+ export declare const DataTableRows: <T>({ data, columns, draggable, selection, expandableRows, expandedRowIds, onToggleRowExpansion, onRowSelect, tableInstanceId, isTableLoading, loadingRowCount, emptyState, rowClassName, getRowDataTestId, onRowClick, onRowMouseEnter, onRowMouseLeave, }: DataTableRowsProps<T>) => import("react").JSX.Element;
22
+ export {};
@@ -0,0 +1,62 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Fragment, lazy, Suspense, useEffect, useState } from "react";
3
+ import { TableBody, TableCell, TableRow } from "./ui/table.js";
4
+ import { cn } from "./cn.js";
5
+ import { DataTableSkeletonRows } from "./DataTableSkeletonRows.js";
6
+ import { getExpandedContentRowId, getRowId } from "./rowIds.js";
7
+ import { DataTableRowIdProvider } from "./rowPickerOpenState.js";
8
+ import { DataTableRow } from "./TableRow.js";
9
+ const DRAGGABLE_LOADING_COLUMNS = [
10
+ { key: "primary", header: "" },
11
+ { key: "secondary", header: "" },
12
+ { key: "tertiary", header: "" },
13
+ ];
14
+ const LazyDraggableRows = lazy(() => import("./DataTableDraggableRows.js").then((m) => ({
15
+ default: m.DataTableDraggableRows,
16
+ })));
17
+ // Match the original client-only drag body without depending on a framework.
18
+ const DataTableDraggableRows = (props) => {
19
+ const [mounted, setMounted] = useState(false);
20
+ useEffect(() => setMounted(true), []);
21
+ const fallback = (_jsx(TableBody, { "aria-busy": "true", "data-testid": "data-table-draggable-loading", children: _jsx(DataTableSkeletonRows, { columns: DRAGGABLE_LOADING_COLUMNS, rowCount: 3, utilityColumnsCount: 1 }) }));
22
+ return mounted ? (_jsx(Suspense, { fallback: fallback, children: _jsx(LazyDraggableRows, { ...props }) })) : (fallback);
23
+ };
24
+ export const DataTableRows = ({ data, columns, draggable, selection, expandableRows, expandedRowIds, onToggleRowExpansion, onRowSelect, tableInstanceId, isTableLoading, loadingRowCount, emptyState, rowClassName, getRowDataTestId, onRowClick, onRowMouseEnter, onRowMouseLeave, }) => {
25
+ const utilityColumnsCount = (selection ? 1 : 0) +
26
+ (draggable?.enabled ? 1 : 0) +
27
+ (expandableRows ? 1 : 0);
28
+ const expandedContentColSpan = columns.length + utilityColumnsCount;
29
+ if (isTableLoading && data.length === 0) {
30
+ return (_jsx(TableBody, { "aria-busy": "true", "data-testid": "data-table-loading", children: _jsx(DataTableSkeletonRows, { columns: columns, rowCount: loadingRowCount, utilityColumnsCount: utilityColumnsCount }) }));
31
+ }
32
+ if (data.length === 0) {
33
+ return (_jsx(TableBody, { children: _jsx(TableRow, { "data-testid": "data-table-empty", className: "hover:bg-transparent", children: _jsx(TableCell, { colSpan: expandedContentColSpan, className: "h-24 text-center text-muted-foreground", children: emptyState ?? "No results found." }) }) }));
34
+ }
35
+ const renderExpandedContentRow = (row, expandedContentRowId, isExpanded, rowCanExpand) => {
36
+ if (!expandableRows || !rowCanExpand || !isExpanded) {
37
+ return null;
38
+ }
39
+ return (_jsx(TableRow, { id: expandedContentRowId, className: "hover:bg-transparent", children: _jsx(TableCell, { colSpan: expandedContentColSpan, className: cn("p-0", expandableRows.expandedRowClassName), children: expandableRows.renderExpandedContent(row) }) }));
40
+ };
41
+ if (draggable?.enabled) {
42
+ return (_jsx(Suspense, { fallback: _jsx(TableBody, { "aria-busy": "true", "data-testid": "data-table-draggable-loading", children: _jsx(DataTableSkeletonRows, { columns: DRAGGABLE_LOADING_COLUMNS, rowCount: 3, utilityColumnsCount: 1 }) }), children: _jsx(DataTableDraggableRows, { data: data, columns: columns, draggable: draggable, selection: selection, expandableRows: expandableRows, expandedRowIds: expandedRowIds, onToggleRowExpansion: onToggleRowExpansion, onRowSelect: onRowSelect, tableInstanceId: tableInstanceId, isTableLoading: isTableLoading, rowClassName: rowClassName, getRowDataTestId: getRowDataTestId, onRowClick: onRowClick, onRowMouseEnter: onRowMouseEnter, onRowMouseLeave: onRowMouseLeave, renderExpandedContentRow: renderExpandedContentRow }) }));
43
+ }
44
+ return (_jsx(TableBody, { className: cn("transition-opacity duration-200", isTableLoading && "opacity-50"), children: data.map((row, index) => {
45
+ const rowId = getRowId(row, index);
46
+ const rowCanExpand = expandableRows
47
+ ? (expandableRows.isRowExpandable?.(row) ?? true)
48
+ : false;
49
+ const isRowExpanded = rowCanExpand && expandedRowIds.has(rowId);
50
+ const expandedContentRowId = getExpandedContentRowId(tableInstanceId, rowId);
51
+ return (_jsx(Fragment, { children: _jsxs(DataTableRowIdProvider, { rowId: rowId, children: [_jsx(DataTableRow, { row: row, rowId: rowId, columns: columns, selection: selection, draggable: draggable, expandableRows: expandableRows
52
+ ? {
53
+ isRowExpandable: rowCanExpand,
54
+ isExpanded: isRowExpanded,
55
+ expandedContentId: expandedContentRowId,
56
+ onToggleExpand: () => onToggleRowExpansion(rowId),
57
+ toggleAriaLabel: expandableRows.getToggleAriaLabel?.(row, isRowExpanded),
58
+ toggleDataTestId: expandableRows.getToggleDataTestId?.(row),
59
+ }
60
+ : undefined, rowClassName: rowClassName, getRowDataTestId: getRowDataTestId, onRowClick: onRowClick, onRowMouseEnter: onRowMouseEnter, onRowMouseLeave: onRowMouseLeave, onRowSelect: onRowSelect }), renderExpandedContentRow(row, expandedContentRowId, isRowExpanded, rowCanExpand)] }) }, rowId));
61
+ }) }));
62
+ };
@@ -0,0 +1,8 @@
1
+ import type { TableColumn } from "./types.js";
2
+ type DataTableSkeletonRowsProps<T> = {
3
+ columns: TableColumn<T>[];
4
+ rowCount: number;
5
+ utilityColumnsCount: number;
6
+ };
7
+ export declare const DataTableSkeletonRows: <T>({ columns, rowCount, utilityColumnsCount, }: DataTableSkeletonRowsProps<T>) => import("react").JSX.Element;
8
+ export {};
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { Skeleton } from "./ui/skeleton.js";
3
+ import { TableCell, TableRow } from "./ui/table.js";
4
+ import { cn } from "./cn.js";
5
+ const DEFAULT_SKELETON_WIDTHS = ["w-24", "w-32", "w-20", "w-28", "w-16"];
6
+ export const DataTableSkeletonRows = ({ columns, rowCount, utilityColumnsCount, }) => {
7
+ return (_jsx(_Fragment, { children: Array.from({ length: rowCount }, (_, rowIndex) => (_jsxs(TableRow, { "aria-hidden": "true", children: [Array.from({ length: utilityColumnsCount }, (_, cellIndex) => (_jsx(TableCell, { className: "w-10", children: _jsx(Skeleton, { className: "h-4 w-4" }) }, `skeleton-util-${cellIndex}`))), columns.map((column, columnIndex) => (_jsx(TableCell, { className: column.className, children: _jsx(Skeleton, { className: cn("h-4", column.skeletonClassName ??
8
+ DEFAULT_SKELETON_WIDTHS[columnIndex % DEFAULT_SKELETON_WIDTHS.length]) }) }, String(column.key))))] }, `skeleton-row-${rowIndex}`))) }));
9
+ };
@@ -0,0 +1,28 @@
1
+ import type { ColumnResizeApi } from "./columnResizeTypes.js";
2
+ import type { DataTableProps, TableColumn } from "./types.js";
3
+ export type DataTableTableContentProps<T> = {
4
+ columns: TableColumn<T>[];
5
+ data: DataTableProps<T>["data"];
6
+ sort?: DataTableProps<T>["sort"];
7
+ selection?: DataTableProps<T>["selection"];
8
+ draggable?: DataTableProps<T>["draggable"];
9
+ expandableRows?: DataTableProps<T>["expandableRows"];
10
+ tableClassName?: DataTableProps<T>["tableClassName"];
11
+ scrollAreaLabel?: DataTableProps<T>["scrollAreaLabel"];
12
+ rowClassName?: DataTableProps<T>["rowClassName"];
13
+ getRowDataTestId?: DataTableProps<T>["getRowDataTestId"];
14
+ onRowClick?: DataTableProps<T>["onRowClick"];
15
+ onRowMouseEnter?: DataTableProps<T>["onRowMouseEnter"];
16
+ onRowMouseLeave?: DataTableProps<T>["onRowMouseLeave"];
17
+ footer?: DataTableProps<T>["footer"];
18
+ columnResize?: ColumnResizeApi | null;
19
+ isTableLoading?: boolean;
20
+ loadingRowCount?: number;
21
+ emptyState?: DataTableProps<T>["emptyState"];
22
+ allSelected?: boolean;
23
+ hasSelectableRows?: boolean;
24
+ onSort: (column: TableColumn<T>) => void;
25
+ onSelectAll: () => void;
26
+ onRowSelect: (rowId: string) => void;
27
+ };
28
+ export declare const DataTableTableContent: <T>({ columns, data, sort, selection, draggable, expandableRows, tableClassName, scrollAreaLabel, rowClassName, getRowDataTestId, onRowClick, onRowMouseEnter, onRowMouseLeave, footer, columnResize, isTableLoading, loadingRowCount, emptyState, allSelected, hasSelectableRows, onSort, onSelectAll, onRowSelect, }: DataTableTableContentProps<T>) => import("react").JSX.Element;
@@ -0,0 +1,46 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useId, useState } from "react";
4
+ import { Table, TableCell, TableFooter, TableRow } from "./ui/table.js";
5
+ import { cn } from "./cn.js";
6
+ import { DataTableRows } from "./DataTableRows.js";
7
+ import { RowPickerOpenStateProvider } from "./rowPickerOpenState.js";
8
+ import { stripImportantWidthClasses } from "./stripImportantWidthClasses.js";
9
+ import { DataTableHeader } from "./TableHeader.js";
10
+ export const DataTableTableContent = ({ columns, data, sort, selection, draggable, expandableRows, tableClassName, scrollAreaLabel, rowClassName, getRowDataTestId, onRowClick, onRowMouseEnter, onRowMouseLeave, footer, columnResize, isTableLoading = false, loadingRowCount = 8, emptyState, allSelected = false, hasSelectableRows = false, onSort, onSelectAll, onRowSelect, }) => {
11
+ const [uncontrolledExpandedRowIds, setUncontrolledExpandedRowIds] = useState(() => new Set());
12
+ const tableInstanceId = useId();
13
+ const controlledExpandedRowIds = expandableRows?.onToggleExpandedRowId &&
14
+ expandableRows.expandedRowIds !== undefined
15
+ ? expandableRows.expandedRowIds
16
+ : undefined;
17
+ const isExpandControlled = controlledExpandedRowIds !== undefined;
18
+ const expandedRowIds = controlledExpandedRowIds ?? uncontrolledExpandedRowIds;
19
+ const toggleRowExpansion = (rowId) => {
20
+ if (expandableRows?.onToggleExpandedRowId && isExpandControlled) {
21
+ expandableRows.onToggleExpandedRowId(rowId);
22
+ return;
23
+ }
24
+ setUncontrolledExpandedRowIds((prev) => {
25
+ const next = new Set(prev);
26
+ if (next.has(rowId)) {
27
+ next.delete(rowId);
28
+ }
29
+ else {
30
+ next.add(rowId);
31
+ }
32
+ return next;
33
+ });
34
+ };
35
+ const resizeTableStyle = columnResize?.isFixedLayout && columnResize.totalWidth !== null
36
+ ? {
37
+ tableLayout: "fixed",
38
+ width: `${columnResize.totalWidth}px`,
39
+ minWidth: `${columnResize.totalWidth}px`,
40
+ }
41
+ : undefined;
42
+ const resolvedTableClassName = resizeTableStyle
43
+ ? stripImportantWidthClasses(tableClassName)
44
+ : tableClassName;
45
+ return (_jsx(RowPickerOpenStateProvider, { children: _jsxs(Table, { className: cn(resolvedTableClassName, columnResize && "[&_td]:overflow-hidden [&_th]:overflow-hidden", columnResize?.resizingColumnKey && "select-none"), style: resizeTableStyle, scrollAreaLabel: scrollAreaLabel, children: [_jsx(DataTableHeader, { columns: columns, sort: sort, selection: selection, draggable: draggable, expandableRows: expandableRows, allSelected: allSelected, headerCheckboxDisabled: selection ? !hasSelectableRows : false, columnResize: columnResize, onSort: onSort, onSelectAll: onSelectAll }), _jsx(DataTableRows, { data: data, columns: columns, draggable: draggable, selection: selection, expandableRows: expandableRows, expandedRowIds: expandedRowIds, onToggleRowExpansion: toggleRowExpansion, onRowSelect: onRowSelect, tableInstanceId: tableInstanceId, isTableLoading: isTableLoading, loadingRowCount: loadingRowCount, emptyState: emptyState, rowClassName: rowClassName, getRowDataTestId: getRowDataTestId, onRowClick: onRowClick, onRowMouseEnter: onRowMouseEnter, onRowMouseLeave: onRowMouseLeave }), footer && footer.cells.length > 0 && (_jsx(TableFooter, { className: footer.className, children: _jsx(TableRow, { children: footer.cells.map((cell) => (_jsx(TableCell, { className: cell.className, children: cell.content }, cell.key))) }) }))] }) }));
46
+ };
@@ -0,0 +1,7 @@
1
+ import type { TableColumn } from "./types.js";
2
+ interface TableCellProps<T> {
3
+ column: TableColumn<T>;
4
+ row: T;
5
+ }
6
+ export declare const DataTableCell: <T>({ column, row }: TableCellProps<T>) => import("react").JSX.Element;
7
+ export {};
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { TableCell } from "./ui/table.js";
3
+ import { cn } from "./cn.js";
4
+ import { getNestedValue } from "./utils.js";
5
+ export const DataTableCell = ({ column, row }) => {
6
+ const value = getNestedValue(row, column.key);
7
+ return (_jsx(TableCell, { className: cn("text-gray-600 dark:text-gray-300", column.className), style: column.width
8
+ ? {
9
+ width: typeof column.width === "number"
10
+ ? `${column.width}px`
11
+ : column.width,
12
+ minWidth: typeof column.width === "number"
13
+ ? `${column.width}px`
14
+ : column.width,
15
+ maxWidth: typeof column.width === "number"
16
+ ? `${column.width}px`
17
+ : column.width,
18
+ }
19
+ : undefined, children: column.render ? column.render(value, row) : String(value ?? "") }));
20
+ };
@@ -0,0 +1,16 @@
1
+ import type { ColumnResizeApi } from "./columnResizeTypes.js";
2
+ import type { DataTableProps, TableColumn } from "./types.js";
3
+ interface TableHeaderProps<T> {
4
+ columns: TableColumn<T>[];
5
+ sort?: DataTableProps<T>["sort"];
6
+ selection?: DataTableProps<T>["selection"];
7
+ draggable?: DataTableProps<T>["draggable"];
8
+ expandableRows?: DataTableProps<T>["expandableRows"];
9
+ allSelected: boolean;
10
+ headerCheckboxDisabled?: boolean;
11
+ columnResize?: ColumnResizeApi | null;
12
+ onSort: (column: TableColumn<T>) => void;
13
+ onSelectAll: () => void;
14
+ }
15
+ export declare const DataTableHeader: <T>({ columns, sort, selection, draggable, expandableRows, allSelected, headerCheckboxDisabled, columnResize, onSort, onSelectAll, }: TableHeaderProps<T>) => import("react").JSX.Element;
16
+ export {};
@@ -0,0 +1,42 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { ChevronDown, ChevronUp, HelpCircle } from "lucide-react";
3
+ import { TableHead, TableRow, TableHeader as UITableHeader, } from "./ui/table.js";
4
+ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "./ui/tooltip.js";
5
+ import { SortOrder } from "./sortOrder.js";
6
+ import { cn } from "./cn.js";
7
+ import { ColumnResizeHandle } from "./ColumnResizeHandle.js";
8
+ import { readColumnWidth, UTILITY_COLUMN_WIDTH_PX, } from "./columnWidthStorage.js";
9
+ import { getColumnWidthStyle } from "./getColumnWidthStyle.js";
10
+ import { getTableHeaderFlexClassName, isTableColumnRightAligned, } from "./getTableHeaderFlexClassName.js";
11
+ const headerAriaSort = (column, sort) => {
12
+ if (!column.sortable)
13
+ return undefined;
14
+ if (sort?.field !== column.key)
15
+ return "none";
16
+ return sort.order === SortOrder.Desc ? "descending" : "ascending";
17
+ };
18
+ export const DataTableHeader = ({ columns, sort, selection, draggable, expandableRows, allSelected, headerCheckboxDisabled = false, columnResize, onSort, onSelectAll, }) => {
19
+ const hasAnyTooltip = columns.some((c) => c.headerTooltip);
20
+ const utilityColumnStyle = columnResize
21
+ ? getColumnWidthStyle(UTILITY_COLUMN_WIDTH_PX)
22
+ : undefined;
23
+ const headerCells = (_jsxs(_Fragment, { children: [selection && (_jsx(TableHead, { className: "w-10", style: utilityColumnStyle, children: _jsx("input", { type: "checkbox", "aria-label": selection.selectAllAriaLabel, "data-testid": selection.selectAllTestId, checked: allSelected, disabled: headerCheckboxDisabled, onChange: onSelectAll, className: headerCheckboxDisabled
24
+ ? "cursor-not-allowed opacity-50"
25
+ : "cursor-pointer" }) })), draggable?.enabled && (_jsx(TableHead, { className: "w-10", style: utilityColumnStyle, children: _jsx("span", { className: "sr-only", children: "Reorder rows" }) })), expandableRows && (_jsx(TableHead, { className: "w-10", style: utilityColumnStyle })), columns.map((column) => {
26
+ const columnKey = String(column.key);
27
+ const isRightAligned = isTableColumnRightAligned(column.className);
28
+ const isResizable = Boolean(columnResize?.isFixedLayout) && column.resizable !== false;
29
+ const currentWidth = columnResize
30
+ ? readColumnWidth(columnResize.widths, columnKey)
31
+ : undefined;
32
+ const pinnedWidth = columnResize?.isFixedLayout
33
+ ? currentWidth
34
+ : undefined;
35
+ const styleWidth = pinnedWidth ?? column.width;
36
+ const sortIcon = column.sortable ? (_jsx("span", { className: "inline-block h-4 w-4 flex-shrink-0", children: sort?.field === column.key ? (sort.order === SortOrder.Asc ? (_jsx(ChevronUp, { className: "h-4 w-4" })) : (_jsx(ChevronDown, { className: "h-4 w-4" }))) : (_jsx("span", { className: "h-4 w-4" })) })) : null;
37
+ const headerLabel = columnResize ? (_jsx("span", { className: "truncate", children: column.header })) : (column.header);
38
+ const headerContent = column.sortable ? (_jsxs("button", { type: "button", "aria-label": column.sortAriaLabel, className: "inline-flex min-w-0 items-center gap-1 rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background", children: [isRightAligned ? sortIcon : null, headerLabel, isRightAligned ? null : sortIcon] })) : (headerLabel);
39
+ return (_jsxs(TableHead, { ref: columnResize?.registerHeaderRef(columnKey), "aria-label": columnResize ? column.header : undefined, "aria-sort": headerAriaSort(column, sort), className: cn("text-gray-900 dark:text-white", column.sortable && "cursor-pointer", columnResize && "relative", column.className, column.headerClassName), style: getColumnWidthStyle(styleWidth), onClick: column.sortable ? () => onSort(column) : undefined, children: [_jsxs("div", { className: cn(getTableHeaderFlexClassName(column.className), columnResize && "min-w-0"), children: [headerContent, column.headerTooltip && (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx("button", { type: "button", onClick: (e) => e.stopPropagation(), className: "inline-flex shrink-0 rounded p-0.5 text-muted-foreground hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-1", "aria-label": "More information", children: _jsx(HelpCircle, { className: "h-3.5 w-3.5" }) }) }), _jsx(TooltipContent, { side: "top", children: column.headerTooltip })] }))] }), isResizable && columnResize && (_jsx(ColumnResizeHandle, { columnKey: columnKey, columnHeader: column.header, width: currentWidth, columnResize: columnResize }))] }, columnKey));
40
+ })] }));
41
+ return (_jsx(UITableHeader, { children: _jsx(TableRow, { className: "hover:bg-zinc-50 dark:hover:bg-zinc-800", children: hasAnyTooltip ? (_jsx(TooltipProvider, { children: headerCells })) : (headerCells) }) }));
42
+ };
@@ -0,0 +1,26 @@
1
+ import type { DraggableProvided } from "@hello-pangea/dnd";
2
+ import type { DataTableProps, TableColumn } from "./types.js";
3
+ interface TableRowProps<T> {
4
+ row: T;
5
+ rowId: string;
6
+ columns: TableColumn<T>[];
7
+ selection?: DataTableProps<T>["selection"];
8
+ draggable?: DataTableProps<T>["draggable"];
9
+ expandableRows?: {
10
+ isRowExpandable: boolean;
11
+ isExpanded: boolean;
12
+ expandedContentId: string;
13
+ onToggleExpand: () => void;
14
+ toggleAriaLabel?: string;
15
+ toggleDataTestId?: string;
16
+ };
17
+ provided?: DraggableProvided;
18
+ rowClassName?: (row: T) => string;
19
+ getRowDataTestId?: (row: T) => string | undefined;
20
+ onRowClick?: DataTableProps<T>["onRowClick"];
21
+ onRowMouseEnter?: (row: T) => void;
22
+ onRowMouseLeave?: () => void;
23
+ onRowSelect: (rowId: string) => void;
24
+ }
25
+ export declare const DataTableRow: <T>({ row, rowId, columns, selection, draggable, expandableRows, provided, rowClassName, getRowDataTestId, onRowClick, onRowMouseEnter, onRowMouseLeave, onRowSelect, }: TableRowProps<T>) => import("react").JSX.Element;
26
+ export {};
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { DragHandleDots2Icon } from "@radix-ui/react-icons";
3
+ import { ChevronDown, ChevronRight } from "lucide-react";
4
+ import { TableCell, TableRow as UITableRow } from "./ui/table.js";
5
+ import { cn } from "./cn.js";
6
+ import { isRowClickSelectTarget } from "./isRowClickSelectTarget.js";
7
+ import { DataTableCell } from "./TableCell.js";
8
+ export const DataTableRow = ({ row, rowId, columns, selection, draggable, expandableRows, provided, rowClassName, getRowDataTestId, onRowClick, onRowMouseEnter, onRowMouseLeave, onRowSelect, }) => {
9
+ const rowSelectable = !selection?.isRowSelectable || selection.isRowSelectable(row);
10
+ const clickTogglesSelection = Boolean(selection?.selectOnRowClick && rowSelectable);
11
+ const clickOpensRow = Boolean(onRowClick) && !clickTogglesSelection;
12
+ const handleRowClick = (event) => {
13
+ if (!isRowClickSelectTarget(event.target)) {
14
+ return;
15
+ }
16
+ if (clickTogglesSelection) {
17
+ onRowSelect(row.id);
18
+ return;
19
+ }
20
+ onRowClick?.(row);
21
+ };
22
+ return (_jsxs(UITableRow, { ref: provided?.innerRef, ...provided?.draggableProps, "data-testid": getRowDataTestId?.(row), className: cn((clickTogglesSelection || clickOpensRow) && "cursor-pointer", rowClassName?.(row)), onClick: clickTogglesSelection || clickOpensRow ? handleRowClick : undefined, onMouseEnter: () => {
23
+ onRowMouseEnter?.(row);
24
+ }, onMouseLeave: () => {
25
+ onRowMouseLeave?.();
26
+ }, children: [selection && (_jsx(TableCell, { className: "w-10", children: _jsx("input", { type: "checkbox", "aria-label": selection.getRowCheckboxAriaLabel?.(row), "data-testid": selection.getRowCheckboxTestId?.(row), checked: rowSelectable &&
27
+ selection.selectedIds.includes(row.id), disabled: !rowSelectable, onChange: () => onRowSelect(row.id), className: rowSelectable ? "cursor-pointer" : "cursor-not-allowed opacity-50" }) })), draggable?.enabled && (_jsx(TableCell, { className: "w-11", children: _jsx("div", { ...(draggable?.enabled ? provided?.dragHandleProps : {}), "aria-label": draggable.getRowDragHandleLabel?.(row) ?? "Reorder row", className: cn("flex min-h-11 min-w-11 items-center justify-center text-muted-foreground hover:text-foreground", draggable?.dragHandleClassName), children: _jsx(DragHandleDots2Icon, { className: "h-4 w-4", "aria-hidden": true }) }) })), expandableRows && (_jsx(TableCell, { className: "w-10", children: expandableRows.isRowExpandable && (_jsxs("button", { type: "button", "data-testid": expandableRows.toggleDataTestId, "aria-expanded": expandableRows.isExpanded, "aria-controls": expandableRows.expandedContentId, onClick: expandableRows.onToggleExpand, className: "inline-flex h-8 w-8 items-center justify-center rounded-sm text-muted-foreground hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-1", children: [_jsx("span", { className: "sr-only", children: expandableRows.toggleAriaLabel ??
28
+ (expandableRows.isExpanded
29
+ ? `Collapse row ${rowId}`
30
+ : `Expand row ${rowId}`) }), expandableRows.isExpanded ? (_jsx(ChevronDown, { className: "h-4 w-4", "aria-hidden": "true" })) : (_jsx(ChevronRight, { className: "h-4 w-4", "aria-hidden": "true" }))] })) })), columns.map((column) => (_jsx(DataTableCell, { column: column, row: row }, String(column.key))))] }));
31
+ };
package/dist/cn.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import { type ClassValue } from "clsx";
2
+ export declare const cn: (...inputs: ClassValue[]) => string;
package/dist/cn.js ADDED
@@ -0,0 +1,3 @@
1
+ import { clsx } from "clsx";
2
+ import { twMerge } from "tailwind-merge";
3
+ export const cn = (...inputs) => twMerge(clsx(inputs));
@@ -0,0 +1,18 @@
1
+ import type { PersistedColumnWidths } from "./columnWidthStorage.js";
2
+ export type ColumnResizeApi = {
3
+ /** Host-defined bounds announced by resize controls. */
4
+ getColumnBounds?: (columnKey: string) => {
5
+ min: number;
6
+ max: number;
7
+ };
8
+ widths: PersistedColumnWidths;
9
+ totalWidth: number | null;
10
+ isFixedLayout: boolean;
11
+ resizingColumnKey: string | null;
12
+ registerHeaderRef: (columnKey: string) => (element: HTMLTableCellElement | null) => void;
13
+ startResize: (columnKey: string, clientX: number) => void;
14
+ updateResize: (clientX: number) => void;
15
+ endResize: () => void;
16
+ nudgeWidth: (columnKey: string, deltaX: number) => void;
17
+ resetWidth: (columnKey: string) => void;
18
+ };
@@ -0,0 +1 @@
1
+ export {};