@acronis-platform/ui-react 5.3.0 → 5.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ui/data-table/data-table-bulk-actions-bar.js +1 -1
- package/dist/components/ui/data-table/data-table-bulk-actions-bar.js.map +1 -1
- package/dist/components/ui/data-table/data-table-view-options.js +3 -2
- package/dist/components/ui/data-table/data-table-view-options.js.map +1 -1
- package/dist/components/ui/data-table/data-table.js +149 -144
- package/dist/components/ui/data-table/data-table.js.map +1 -1
- package/dist/components/ui/segment-control/segment-control.js +99 -0
- package/dist/components/ui/segment-control/segment-control.js.map +1 -0
- package/dist/components/ui/table/table-view-options.js +88 -33
- package/dist/components/ui/table/table-view-options.js.map +1 -1
- package/dist/components/ui/table/table.js.map +1 -1
- package/dist/index.js +33 -32
- package/dist/llms/data-table.md +33 -7
- package/dist/llms/segment-control.md +161 -0
- package/dist/llms/table.md +56 -23
- package/dist/llms.txt +5 -1
- package/dist/react.js +33 -32
- package/dist/src/components/ui/data-table/data-table-view-options.d.ts +1 -1
- package/dist/src/components/ui/data-table/data-table.d.ts +19 -3
- package/dist/src/components/ui/data-table/data-table.docs.d.ts +19 -6
- package/dist/src/components/ui/segment-control/index.d.ts +1 -0
- package/dist/src/components/ui/segment-control/segment-control.d.ts +32 -0
- package/dist/src/components/ui/table/table-view-options.d.ts +9 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/ui-react.css +1 -1
- package/package.json +3 -3
|
@@ -5,7 +5,7 @@ import { Fragment as n, jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
|
5
5
|
function a({ table: a, children: o, selectedLabel: s = (e) => `${e} item${e === 1 ? "" : "s"} selected:`, clearLabel: c = "Deselect", loadedLabel: l }) {
|
|
6
6
|
let u = a.getSelectedRowModel().rows.length, d = t(a);
|
|
7
7
|
return /* @__PURE__ */ i("div", {
|
|
8
|
-
className: "flex items-center gap-4",
|
|
8
|
+
className: "flex items-center gap-4 px-[var(--ui-table-global-cell-padding-x)]",
|
|
9
9
|
children: [/* @__PURE__ */ r("fieldset", {
|
|
10
10
|
disabled: !d,
|
|
11
11
|
className: "m-0 flex min-w-0 items-center gap-4 border-0 p-0",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table-bulk-actions-bar.js","names":[],"sources":["../../../../src/components/ui/data-table/data-table-bulk-actions-bar.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { Table } from '@tanstack/react-table';\n\nimport { Button } from '../button';\nimport { isBulkSelectionActive } from './data-table-selection';\n\ninterface DataTableBulkActionsBarProps<TData> {\n table: Table<TData>;\n /**\n * Bulk actions offered for the current selection — rendered leading, ahead\n * of the trailing summary/Deselect control. Wrapped in a native `<fieldset\n * disabled>` while nothing is selected, so every nested control (a `Button`\n * renders a plain `<button>`) picks up the disabled state and styling for\n * free — no per-action wiring needed. Each action reads the selection off\n * the same `table` instance (`table.getSelectedRowModel().rows`).\n */\n children?: ReactNode;\n /** Builds the trailing selection summary from the selected-row count. */\n selectedLabel?: (count: number) => string;\n /** Label of the trailing control that clears the selection. */\n clearLabel?: string;\n /**\n * Trailing summary shown in place of the selection summary while nothing is\n * selected — e.g. `\"25 of 1250 items loaded\"`. Omit to render nothing in\n * that state.\n */\n loadedLabel?: ReactNode;\n}\n\n// Thin TanStack adapter: reads the selected-row count off\n// `table.getSelectedRowModel()` and routes Deselect back through\n// `table.resetRowSelection()`. It owns no state of its own.\n//\n// Always mounted (unlike a bar that appears/disappears with selection) — it\n// just toggles between two states (Figma 5916-11286 disabled / 5916-11991\n// enabled), on the same `isBulkSelectionActive` threshold that hides the\n// per-row actions column: with nothing selected, the leading actions are\n// disabled and the trailing side shows `loadedLabel`; once at least one row\n// is selected — including exactly one — the actions enable and the trailing\n// side switches to the selection summary + Deselect.\nexport function DataTableBulkActionsBar<TData>({\n table,\n children,\n selectedLabel = (count) => `${count} item${count === 1 ? '' : 's'} selected:`,\n clearLabel = 'Deselect',\n loadedLabel,\n}: DataTableBulkActionsBarProps<TData>) {\n const selectedCount = table.getSelectedRowModel().rows.length;\n const hasSelection = isBulkSelectionActive(table);\n\n return (\n <div className=\"flex items-center gap-4\">\n <fieldset\n disabled={!hasSelection}\n className=\"m-0 flex min-w-0 items-center gap-4 border-0 p-0\"\n >\n {children}\n </fieldset>\n <div className=\"ms-auto flex items-center gap-2\">\n {hasSelection ? (\n <>\n <span className=\"text-sm\">{selectedLabel(selectedCount)}</span>\n <Button\n variant=\"ghost\"\n className=\"h-8\"\n onClick={() => table.resetRowSelection()}\n >\n {clearLabel}\n </Button>\n </>\n ) : (\n loadedLabel !== undefined && (\n <span className=\"text-sm text-muted-foreground\">{loadedLabel}</span>\n )\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;AAwCA,SAAgB,EAA+B,EAC7C,UACA,aACA,oBAAiB,MAAU,GAAG,EAAM,OAAO,MAAU,IAAI,KAAK,IAAI,aAClE,gBAAa,YACb,kBACsC;CACtC,IAAM,IAAgB,EAAM,oBAAoB,CAAC,CAAC,KAAK,QACjD,IAAe,EAAsB,CAAK;CAEhD,OACE,kBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACE,kBAAC,YAAD;GACE,UAAU,CAAC;GACX,WAAU;GAET;EACO,CAAA,GACV,kBAAC,OAAD;GAAK,WAAU;GACZ,UAAA,IACC,kBAAA,GAAA,EAAA,UAAA,CACE,kBAAC,QAAD;IAAM,WAAU;IAAW,UAAA,EAAc,CAAa;GAAQ,CAAA,GAC9D,kBAAC,GAAD;IACE,SAAQ;IACR,WAAU;IACV,eAAe,EAAM,kBAAkB;IAEtC,UAAA;GACK,CAAA,CACR,EAAA,CAAA,IAEF,MAAgB,KAAA,KACd,kBAAC,QAAD;IAAM,WAAU;IAAiC,UAAA;GAAkB,CAAA;EAGpE,CAAA,CACF;;AAET"}
|
|
1
|
+
{"version":3,"file":"data-table-bulk-actions-bar.js","names":[],"sources":["../../../../src/components/ui/data-table/data-table-bulk-actions-bar.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { Table } from '@tanstack/react-table';\n\nimport { Button } from '../button';\nimport { isBulkSelectionActive } from './data-table-selection';\n\ninterface DataTableBulkActionsBarProps<TData> {\n table: Table<TData>;\n /**\n * Bulk actions offered for the current selection — rendered leading, ahead\n * of the trailing summary/Deselect control. Wrapped in a native `<fieldset\n * disabled>` while nothing is selected, so every nested control (a `Button`\n * renders a plain `<button>`) picks up the disabled state and styling for\n * free — no per-action wiring needed. Each action reads the selection off\n * the same `table` instance (`table.getSelectedRowModel().rows`).\n */\n children?: ReactNode;\n /** Builds the trailing selection summary from the selected-row count. */\n selectedLabel?: (count: number) => string;\n /** Label of the trailing control that clears the selection. */\n clearLabel?: string;\n /**\n * Trailing summary shown in place of the selection summary while nothing is\n * selected — e.g. `\"25 of 1250 items loaded\"`. Omit to render nothing in\n * that state.\n */\n loadedLabel?: ReactNode;\n}\n\n// Thin TanStack adapter: reads the selected-row count off\n// `table.getSelectedRowModel()` and routes Deselect back through\n// `table.resetRowSelection()`. It owns no state of its own.\n//\n// Always mounted (unlike a bar that appears/disappears with selection) — it\n// just toggles between two states (Figma 5916-11286 disabled / 5916-11991\n// enabled), on the same `isBulkSelectionActive` threshold that hides the\n// per-row actions column: with nothing selected, the leading actions are\n// disabled and the trailing side shows `loadedLabel`; once at least one row\n// is selected — including exactly one — the actions enable and the trailing\n// side switches to the selection summary + Deselect.\nexport function DataTableBulkActionsBar<TData>({\n table,\n children,\n selectedLabel = (count) => `${count} item${count === 1 ? '' : 's'} selected:`,\n clearLabel = 'Deselect',\n loadedLabel,\n}: DataTableBulkActionsBarProps<TData>) {\n const selectedCount = table.getSelectedRowModel().rows.length;\n const hasSelection = isBulkSelectionActive(table);\n\n return (\n <div className=\"flex items-center gap-4 px-[var(--ui-table-global-cell-padding-x)]\">\n <fieldset\n disabled={!hasSelection}\n className=\"m-0 flex min-w-0 items-center gap-4 border-0 p-0\"\n >\n {children}\n </fieldset>\n <div className=\"ms-auto flex items-center gap-2\">\n {hasSelection ? (\n <>\n <span className=\"text-sm\">{selectedLabel(selectedCount)}</span>\n <Button\n variant=\"ghost\"\n className=\"h-8\"\n onClick={() => table.resetRowSelection()}\n >\n {clearLabel}\n </Button>\n </>\n ) : (\n loadedLabel !== undefined && (\n <span className=\"text-sm text-muted-foreground\">{loadedLabel}</span>\n )\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;AAwCA,SAAgB,EAA+B,EAC7C,UACA,aACA,oBAAiB,MAAU,GAAG,EAAM,OAAO,MAAU,IAAI,KAAK,IAAI,aAClE,gBAAa,YACb,kBACsC;CACtC,IAAM,IAAgB,EAAM,oBAAoB,CAAC,CAAC,KAAK,QACjD,IAAe,EAAsB,CAAK;CAEhD,OACE,kBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACE,kBAAC,YAAD;GACE,UAAU,CAAC;GACX,WAAU;GAET;EACO,CAAA,GACV,kBAAC,OAAD;GAAK,WAAU;GACZ,UAAA,IACC,kBAAA,GAAA,EAAA,UAAA,CACE,kBAAC,QAAD;IAAM,WAAU;IAAW,UAAA,EAAc,CAAa;GAAQ,CAAA,GAC9D,kBAAC,GAAD;IACE,SAAQ;IACR,WAAU;IACV,eAAe,EAAM,kBAAkB;IAEtC,UAAA;GACK,CAAA,CACR,EAAA,CAAA,IAEF,MAAgB,KAAA,KACd,kBAAC,QAAD;IAAM,WAAU;IAAiC,UAAA;GAAkB,CAAA;EAGpE,CAAA,CACF;;AAET"}
|
|
@@ -4,8 +4,9 @@ import { jsx as t } from "react/jsx-runtime";
|
|
|
4
4
|
function n({ table: n, ...r }) {
|
|
5
5
|
let i = n.getAllColumns().filter((e) => e.accessorFn !== void 0 && e.getCanHide()).map((e) => ({
|
|
6
6
|
id: e.id,
|
|
7
|
-
label: e.id,
|
|
8
|
-
hidden: !e.getIsVisible()
|
|
7
|
+
label: e.columnDef.meta?.label ?? (typeof e.columnDef.header == "string" ? e.columnDef.header : e.id),
|
|
8
|
+
hidden: !e.getIsVisible(),
|
|
9
|
+
category: e.columnDef.meta?.category
|
|
9
10
|
}));
|
|
10
11
|
return /* @__PURE__ */ t(e, {
|
|
11
12
|
columns: i,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table-view-options.js","names":[],"sources":["../../../../src/components/ui/data-table/data-table-view-options.tsx"],"sourcesContent":["import type { Table } from '@tanstack/react-table';\n\nimport { TableViewOptions, type TableViewOptionsProps } from '../table';\n\ninterface DataTableViewOptionsProps<TData
|
|
1
|
+
{"version":3,"file":"data-table-view-options.js","names":[],"sources":["../../../../src/components/ui/data-table/data-table-view-options.tsx"],"sourcesContent":["import type { Table } from '@tanstack/react-table';\n\nimport { TableViewOptions, type TableViewOptionsProps } from '../table';\n\ninterface DataTableViewOptionsProps<TData> extends Pick<\n TableViewOptionsProps,\n | 'triggerLabel'\n | 'iconOnly'\n | 'triggerAriaLabel'\n | 'searchPlaceholder'\n | 'showAllLabel'\n | 'noResultsLabel'\n> {\n table: Table<TData>;\n}\n\n// Thin TanStack adapter over the primitive-only `TableViewOptions`: maps\n// `table.getAllColumns()` onto the plain `{ id, label, hidden }[]` shape and\n// routes `onToggle` back through `column.toggleVisibility()`.\nexport function DataTableViewOptions<TData>({\n table,\n ...triggerProps\n}: DataTableViewOptionsProps<TData>) {\n const columns = table\n .getAllColumns()\n .filter(\n (column) =>\n typeof column.accessorFn !== 'undefined' && column.getCanHide()\n )\n .map((column) => ({\n id: column.id,\n label:\n column.columnDef.meta?.label ??\n (typeof column.columnDef.header === 'string'\n ? column.columnDef.header\n : column.id),\n hidden: !column.getIsVisible(),\n category: column.columnDef.meta?.category,\n }));\n\n return (\n <TableViewOptions\n columns={columns}\n onToggle={(id) => {\n const column = table.getColumn(id);\n column?.toggleVisibility(!column.getIsVisible());\n }}\n {...triggerProps}\n />\n );\n}\n"],"mappings":";;;AAmBA,SAAgB,EAA4B,EAC1C,UACA,GAAG,KACgC;CACnC,IAAM,IAAU,EACb,cAAc,CAAC,CACf,QACE,MACQ,EAAO,eAAe,UAAe,EAAO,WAAW,CAClE,CAAC,CACA,KAAK,OAAY;EAChB,IAAI,EAAO;EACX,OACE,EAAO,UAAU,MAAM,UACtB,OAAO,EAAO,UAAU,UAAW,WAChC,EAAO,UAAU,SACjB,EAAO;EACb,QAAQ,CAAC,EAAO,aAAa;EAC7B,UAAU,EAAO,UAAU,MAAM;CACnC,EAAE;CAEJ,OACE,kBAAC,GAAD;EACW;EACT,WAAW,MAAO;GAChB,IAAM,IAAS,EAAM,UAAU,CAAE;GACjC,GAAQ,iBAAiB,CAAC,EAAO,aAAa,CAAC;EACjD;EACA,GAAI;CACL,CAAA;AAEL"}
|
|
@@ -8,11 +8,11 @@ import { DropdownMenu as ne, DropdownMenuContent as re, DropdownMenuTrigger as i
|
|
|
8
8
|
import { Table as ae, TableActionsCell as oe, TableBody as se, TableCell as f, TableHead as ce, TableHeader as le, TableRow as p, TableSettingsCell as ue } from "../table/table.js";
|
|
9
9
|
import { isBulkSelectionActive as de } from "./data-table-selection.js";
|
|
10
10
|
import { DataTableViewOptions as fe } from "./data-table-view-options.js";
|
|
11
|
-
import { Fragment as m, useEffect as pe, useMemo as
|
|
12
|
-
import { jsx as
|
|
13
|
-
import { EllipsisIcon as
|
|
11
|
+
import { Fragment as m, useEffect as pe, useMemo as h, useRef as me, useState as g } from "react";
|
|
12
|
+
import { jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
13
|
+
import { EllipsisIcon as he } from "@acronis-platform/icons-react/stroke-mono";
|
|
14
14
|
//#region src/components/ui/data-table/data-table.tsx
|
|
15
|
-
function
|
|
15
|
+
function y(e) {
|
|
16
16
|
let t = e.getIsPinned();
|
|
17
17
|
if (t) return {
|
|
18
18
|
position: "sticky",
|
|
@@ -22,19 +22,19 @@ function v(e) {
|
|
|
22
22
|
boxShadow: t === "left" ? "4px 0 4px -4px var(--ui-table-global-row-border-color)" : "-4px 0 4px -4px var(--ui-table-global-row-border-color)"
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function b(e, t) {
|
|
26
26
|
if (e.id === "select") return 48;
|
|
27
27
|
if (t || e.columnDef.size !== void 0) return e.getSize();
|
|
28
28
|
}
|
|
29
|
-
function
|
|
30
|
-
let n =
|
|
29
|
+
function ge(e, t) {
|
|
30
|
+
let n = y(e.column), r = b(e.column, t);
|
|
31
31
|
if (!(!n && r === void 0)) return {
|
|
32
32
|
...n,
|
|
33
33
|
width: r
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
function x(e, t) {
|
|
37
|
-
let n =
|
|
37
|
+
let n = y(e.column), r = b(e.column, t);
|
|
38
38
|
if (!(!n && r === void 0)) return {
|
|
39
39
|
...n,
|
|
40
40
|
width: r
|
|
@@ -66,21 +66,21 @@ var _e = {
|
|
|
66
66
|
action: "Drag border"
|
|
67
67
|
}
|
|
68
68
|
};
|
|
69
|
-
function E({ columns:
|
|
70
|
-
let
|
|
69
|
+
function E({ columns: y = [], data: b = [], table: E, getRowId: ve, getRowCanExpand: ye, renderExpandedRow: D, striped: be = !1, bordered: xe = !1, highlightCurrentRow: O = !1, skeleton: k = !1, skeletonRows: Se = 5, enableColumnResizing: Ce = !1, onColumnSizingChange: we, enableColumnReordering: Te = !1, columnOrder: Ee, onColumnOrderChange: De, columnVisibility: Oe, onColumnVisibilityChange: ke, rowSelection: A, onRowSelectionChange: Ae, manualSorting: j = !1, sorting: M, onSortingChange: je, renderRow: N, renderEmptyState: P, paginationMode: F = "page", onLoadMore: Me, loadMoreRootMargin: Ne, hasNextPage: I = !1, resizeColumnLabel: Pe = "Resize column", emptyLabel: Fe = "No results.", isLoadingMore: L = !1, hideActionColumn: Ie = !1, renderRowActions: R, rowActionsLabel: Le = "Row actions", columnSettingsLabel: Re, columnSearchPlaceholder: ze, showAllColumnsLabel: Be, noColumnsFoundLabel: Ve, headerHints: He }) {
|
|
70
|
+
let z = {
|
|
71
71
|
..._e,
|
|
72
|
-
...
|
|
73
|
-
}, [
|
|
74
|
-
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
},
|
|
78
|
-
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
},
|
|
72
|
+
...He
|
|
73
|
+
}, [Ue, We] = g([]), Ge = M ?? Ue, [Ke, qe] = g([]), [Je, Ye] = g({}), Xe = Oe ?? Je, [Ze, Qe] = g({}), $e = A ?? Ze, [et, tt] = g({}), [nt, rt] = g({}), [it, at] = g([]), ot = Ee ?? it, [B, V] = g(), [st, ct] = g(), [lt, H] = g(0), U = me([]), ut = (e) => {
|
|
74
|
+
rt(e), we?.(e);
|
|
75
|
+
}, dt = (e) => {
|
|
76
|
+
Ee === void 0 && at(e), De?.(e);
|
|
77
|
+
}, ft = (e) => {
|
|
78
|
+
Ye(e), ke?.(e);
|
|
79
|
+
}, pt = (e) => {
|
|
80
|
+
M === void 0 && We(e), je?.(e);
|
|
81
|
+
}, mt = (e) => {
|
|
82
|
+
A === void 0 && Qe(e), Ae?.(e);
|
|
83
|
+
}, W = !Ie && !E, G = h(() => W ? [{
|
|
84
84
|
id: "__actions",
|
|
85
85
|
size: 48,
|
|
86
86
|
enableSorting: !1,
|
|
@@ -88,114 +88,119 @@ function E({ columns: v = [], data: y = [], table: E, getRowCanExpand: ve, rende
|
|
|
88
88
|
meta: { pin: "right" },
|
|
89
89
|
header: () => null,
|
|
90
90
|
cell: () => null
|
|
91
|
-
}] : [], [
|
|
92
|
-
data:
|
|
93
|
-
columns:
|
|
94
|
-
|
|
91
|
+
}] : [], [W]), K = h(() => [...y, ...G], [y, G]), [ht, q] = g(), gt = te({
|
|
92
|
+
data: b,
|
|
93
|
+
columns: K,
|
|
94
|
+
getRowId: ve,
|
|
95
|
+
enableColumnResizing: Ce,
|
|
95
96
|
columnResizeMode: "onChange",
|
|
96
97
|
getCoreRowModel: s(),
|
|
97
98
|
getExpandedRowModel: c(),
|
|
98
|
-
...
|
|
99
|
-
getRowCanExpand:
|
|
100
|
-
onExpandedChange:
|
|
101
|
-
manualSorting:
|
|
102
|
-
onSortingChange:
|
|
103
|
-
...
|
|
104
|
-
onColumnFiltersChange:
|
|
99
|
+
...F === "page" ? { getPaginationRowModel: u() } : {},
|
|
100
|
+
getRowCanExpand: ye,
|
|
101
|
+
onExpandedChange: tt,
|
|
102
|
+
manualSorting: j,
|
|
103
|
+
onSortingChange: pt,
|
|
104
|
+
...j ? {} : { getSortedRowModel: ee() },
|
|
105
|
+
onColumnFiltersChange: qe,
|
|
105
106
|
getFilteredRowModel: l(),
|
|
106
|
-
onColumnVisibilityChange:
|
|
107
|
-
onRowSelectionChange:
|
|
108
|
-
onColumnSizingChange:
|
|
109
|
-
onColumnOrderChange:
|
|
107
|
+
onColumnVisibilityChange: ft,
|
|
108
|
+
onRowSelectionChange: mt,
|
|
109
|
+
onColumnSizingChange: ut,
|
|
110
|
+
onColumnOrderChange: dt,
|
|
111
|
+
initialState: W ? { columnPinning: { right: ["__actions"] } } : void 0,
|
|
110
112
|
state: {
|
|
111
|
-
sorting:
|
|
112
|
-
columnFilters:
|
|
113
|
-
columnVisibility:
|
|
114
|
-
rowSelection:
|
|
115
|
-
expanded:
|
|
116
|
-
columnSizing:
|
|
117
|
-
columnOrder:
|
|
113
|
+
sorting: Ge,
|
|
114
|
+
columnFilters: Ke,
|
|
115
|
+
columnVisibility: Xe,
|
|
116
|
+
rowSelection: $e,
|
|
117
|
+
expanded: et,
|
|
118
|
+
columnSizing: nt,
|
|
119
|
+
columnOrder: ot
|
|
118
120
|
}
|
|
119
|
-
}),
|
|
121
|
+
}), J = E ?? gt, Y = !E && F === "infinite", X = Ce && !E, _t = Te && !E, Z = !!J.getState().columnSizingInfo.isResizingColumn;
|
|
120
122
|
pe(() => {
|
|
121
|
-
if (
|
|
123
|
+
if (Z) return document.documentElement.setAttribute("data-ui-column-resizing", ""), () => {
|
|
122
124
|
document.documentElement.removeAttribute("data-ui-column-resizing");
|
|
123
125
|
};
|
|
124
|
-
}, [
|
|
125
|
-
let
|
|
126
|
-
onIntersect: () =>
|
|
127
|
-
disabled: !
|
|
128
|
-
rootMargin:
|
|
129
|
-
}),
|
|
126
|
+
}, [Z]);
|
|
127
|
+
let vt = t({
|
|
128
|
+
onIntersect: () => Me?.(),
|
|
129
|
+
disabled: !Y || !I || L,
|
|
130
|
+
rootMargin: Ne
|
|
131
|
+
}), yt = (e, t) => {
|
|
130
132
|
if (e.ctrlKey || e.altKey || e.metaKey) return;
|
|
131
133
|
let n = w(e.key, t.column.getSize(), {
|
|
132
134
|
shiftKey: e.shiftKey,
|
|
133
135
|
min: t.column.columnDef.minSize ?? S,
|
|
134
136
|
max: t.column.columnDef.maxSize ?? C
|
|
135
137
|
});
|
|
136
|
-
n !== void 0 && (e.preventDefault(),
|
|
138
|
+
n !== void 0 && (e.preventDefault(), J.setColumnSizing((e) => ({
|
|
137
139
|
...e,
|
|
138
140
|
[t.column.id]: n
|
|
139
141
|
})));
|
|
140
|
-
},
|
|
141
|
-
e.dataTransfer && (e.dataTransfer.effectAllowed = "move", e.dataTransfer.setData("text/plain", t)),
|
|
142
|
-
},
|
|
142
|
+
}, bt = (e, t) => {
|
|
143
|
+
e.dataTransfer && (e.dataTransfer.effectAllowed = "move", e.dataTransfer.setData("text/plain", t)), V(t);
|
|
144
|
+
}, xt = (e) => {
|
|
143
145
|
e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "move");
|
|
144
|
-
},
|
|
145
|
-
if (e.preventDefault(), !
|
|
146
|
-
let n =
|
|
147
|
-
|
|
146
|
+
}, St = (e, t) => {
|
|
147
|
+
if (e.preventDefault(), !B) return;
|
|
148
|
+
let n = J.getState().columnOrder, r = n.length ? n : J.getAllLeafColumns().map((e) => e.id);
|
|
149
|
+
J.setColumnOrder(T(r, B, t)), V(void 0);
|
|
148
150
|
};
|
|
149
151
|
pe(() => {
|
|
150
|
-
E ||
|
|
152
|
+
E || J.getAllLeafColumns().forEach((e) => {
|
|
151
153
|
e.pin(e.columnDef.meta?.pin ?? !1);
|
|
152
154
|
});
|
|
153
155
|
}, [
|
|
154
|
-
|
|
155
|
-
|
|
156
|
+
J,
|
|
157
|
+
K,
|
|
156
158
|
E
|
|
157
159
|
]);
|
|
158
|
-
let
|
|
159
|
-
|
|
160
|
-
},
|
|
160
|
+
let Q = J.getRowModel().rows, $ = de(J), Ct = Q.length ? Math.min(lt, Q.length - 1) : 0, wt = (e) => {
|
|
161
|
+
H(e);
|
|
162
|
+
}, Tt = (e, t) => {
|
|
161
163
|
if (e.target !== e.currentTarget || e.key !== "ArrowDown" && e.key !== "ArrowUp") return;
|
|
162
|
-
let n = e.key === "ArrowDown" ? Math.min(t + 1,
|
|
163
|
-
n !== t && (e.preventDefault(),
|
|
164
|
-
},
|
|
165
|
-
return /* @__PURE__ */
|
|
166
|
-
className: e("rounded-md border border-[var(--ui-table-global-row-border-color)]",
|
|
167
|
-
children: /* @__PURE__ */
|
|
168
|
-
style:
|
|
169
|
-
children: [/* @__PURE__ */
|
|
164
|
+
let n = e.key === "ArrowDown" ? Math.min(t + 1, Q.length - 1) : Math.max(t - 1, 0);
|
|
165
|
+
n !== t && (e.preventDefault(), H(n), U.current[n]?.focus());
|
|
166
|
+
}, Et = xe ? "[&_th:not(:last-child)]:border-e [&_td:not(:last-child)]:border-e [&_th]:border-[var(--ui-table-global-row-border-color)] [&_td]:border-[var(--ui-table-global-row-border-color)]" : void 0, Dt = "bg-background";
|
|
167
|
+
return /* @__PURE__ */ _("div", {
|
|
168
|
+
className: e("rounded-md border border-[var(--ui-table-global-row-border-color)]", Et),
|
|
169
|
+
children: /* @__PURE__ */ v(ae, {
|
|
170
|
+
style: X ? { width: J.getCenterTotalSize() } : void 0,
|
|
171
|
+
children: [/* @__PURE__ */ _(a, { children: /* @__PURE__ */ _(le, { children: J.getHeaderGroups().map((t) => /* @__PURE__ */ _(p, {
|
|
170
172
|
className: "hover:bg-transparent",
|
|
171
173
|
children: t.headers.map((t) => {
|
|
172
|
-
let n = t.column.getIsPinned(), a =
|
|
173
|
-
c &&
|
|
174
|
-
s &&
|
|
175
|
-
a &&
|
|
174
|
+
let n = t.column.getIsPinned(), a = X && t.column.getCanResize() && t.column.id !== "select", s = _t && !t.isPlaceholder && !n, c = !t.isPlaceholder && t.column.getCanSort(), l = [
|
|
175
|
+
c && z.sort,
|
|
176
|
+
s && z.reorder,
|
|
177
|
+
a && z.resize
|
|
176
178
|
].filter((e) => !!e);
|
|
177
|
-
if (t.column.id === "__actions") return /* @__PURE__ */
|
|
178
|
-
style:
|
|
179
|
-
className:
|
|
180
|
-
children: /* @__PURE__ */
|
|
181
|
-
table:
|
|
179
|
+
if (t.column.id === "__actions") return /* @__PURE__ */ _(ue, {
|
|
180
|
+
style: ge(t, X),
|
|
181
|
+
className: Dt,
|
|
182
|
+
children: /* @__PURE__ */ _(fe, {
|
|
183
|
+
table: J,
|
|
182
184
|
iconOnly: !0,
|
|
183
|
-
triggerAriaLabel:
|
|
185
|
+
triggerAriaLabel: Re,
|
|
186
|
+
searchPlaceholder: ze,
|
|
187
|
+
showAllLabel: Be,
|
|
188
|
+
noResultsLabel: Ve
|
|
184
189
|
})
|
|
185
190
|
}, t.id);
|
|
186
|
-
let u = /* @__PURE__ */
|
|
191
|
+
let u = /* @__PURE__ */ v(ce, {
|
|
187
192
|
wrap: t.column.columnDef.meta?.wrap,
|
|
188
|
-
style:
|
|
189
|
-
draggable: s && !
|
|
190
|
-
onDragStart: s ? (e) =>
|
|
191
|
-
onDragOver: s ?
|
|
192
|
-
onDrop: s ? (e) =>
|
|
193
|
-
onDragEnd: s ? () =>
|
|
194
|
-
className: e(a && "relative", c && !
|
|
195
|
-
children: [t.isPlaceholder ? null : d(t.column.columnDef.header, t.getContext()), a && /* @__PURE__ */
|
|
193
|
+
style: ge(t, X),
|
|
194
|
+
draggable: s && !Z || void 0,
|
|
195
|
+
onDragStart: s ? (e) => bt(e, t.column.id) : void 0,
|
|
196
|
+
onDragOver: s ? xt : void 0,
|
|
197
|
+
onDrop: s ? (e) => St(e, t.column.id) : void 0,
|
|
198
|
+
onDragEnd: s ? () => V(void 0) : void 0,
|
|
199
|
+
className: e(a && "relative", c && !Z && "transition-colors hover:bg-[var(--ui-table-header-cell-color-hover)] active:bg-[var(--ui-table-header-cell-color-active)]", s && !Z && "cursor-grab select-none active:cursor-grabbing", s && B === t.column.id && "opacity-50", n && Dt),
|
|
200
|
+
children: [t.isPlaceholder ? null : d(t.column.columnDef.header, t.getContext()), a && /* @__PURE__ */ _("div", {
|
|
196
201
|
role: "separator",
|
|
197
202
|
"aria-orientation": "vertical",
|
|
198
|
-
"aria-label":
|
|
203
|
+
"aria-label": Pe,
|
|
199
204
|
"aria-valuenow": t.column.getSize(),
|
|
200
205
|
"aria-valuemin": t.column.columnDef.minSize ?? S,
|
|
201
206
|
"aria-valuemax": t.column.columnDef.maxSize ?? C,
|
|
@@ -203,16 +208,16 @@ function E({ columns: v = [], data: y = [], table: E, getRowCanExpand: ve, rende
|
|
|
203
208
|
draggable: !1,
|
|
204
209
|
onMouseDown: t.getResizeHandler(),
|
|
205
210
|
onTouchStart: t.getResizeHandler(),
|
|
206
|
-
onKeyDown: (e) =>
|
|
207
|
-
className: e("absolute end-0 top-0 h-full w-1 cursor-(--ui-resizable-cursor) touch-none select-none bg-[var(--ui-table-global-row-border-color)] opacity-0 transition-[opacity,background-color] hover:bg-[var(--ui-resizable-border-color-hover)] hover:opacity-100 focus-visible:bg-[var(--ui-resizable-border-color-hover)] focus-visible:opacity-100 focus-visible:outline-[3px] focus-visible:
|
|
211
|
+
onKeyDown: (e) => yt(e, t),
|
|
212
|
+
className: e("absolute end-0 top-0 h-full w-1 cursor-(--ui-resizable-cursor) touch-none select-none bg-[var(--ui-table-global-row-border-color)] opacity-0 transition-[opacity,background-color] hover:bg-[var(--ui-resizable-border-color-hover)] hover:opacity-100 focus-visible:bg-[var(--ui-resizable-border-color-hover)] focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-inset focus-visible:ring-[var(--ui-focus-primary)]", t.column.getIsResizing() && "bg-[var(--ui-resizable-border-color-active)] opacity-100")
|
|
208
213
|
})]
|
|
209
214
|
});
|
|
210
|
-
return l.length === 0 ? /* @__PURE__ */
|
|
211
|
-
disabled:
|
|
212
|
-
children: [/* @__PURE__ */
|
|
215
|
+
return l.length === 0 ? /* @__PURE__ */ _(m, { children: u }, t.id) : /* @__PURE__ */ v(r, {
|
|
216
|
+
disabled: Z || B !== void 0,
|
|
217
|
+
children: [/* @__PURE__ */ _(o, { render: u }), /* @__PURE__ */ _(i, {
|
|
213
218
|
className: "flex flex-col gap-1",
|
|
214
|
-
children: l.map((e) => /* @__PURE__ */
|
|
215
|
-
/* @__PURE__ */
|
|
219
|
+
children: l.map((e) => /* @__PURE__ */ v("span", { children: [
|
|
220
|
+
/* @__PURE__ */ v("span", {
|
|
216
221
|
className: "font-semibold",
|
|
217
222
|
children: [e.label, ":"]
|
|
218
223
|
}),
|
|
@@ -222,80 +227,80 @@ function E({ columns: v = [], data: y = [], table: E, getRowCanExpand: ve, rende
|
|
|
222
227
|
})]
|
|
223
228
|
}, t.id);
|
|
224
229
|
})
|
|
225
|
-
}, t.id)) }) }), /* @__PURE__ */
|
|
226
|
-
|
|
230
|
+
}, t.id)) }) }), /* @__PURE__ */ v(se, { children: [
|
|
231
|
+
k ? Array.from({ length: Se }).map((e, t) => /* @__PURE__ */ _(p, {
|
|
227
232
|
className: "hover:bg-transparent",
|
|
228
|
-
children:
|
|
229
|
-
}, `skeleton-${t}`)) :
|
|
230
|
-
if (
|
|
231
|
-
let i = t.getIsSelected(), a =
|
|
232
|
-
return /* @__PURE__ */
|
|
233
|
+
children: J.getVisibleLeafColumns().map((e) => /* @__PURE__ */ _(f, { children: /* @__PURE__ */ _("div", { className: "h-4 w-full animate-pulse rounded bg-[var(--ui-background-surface-secondary)]" }) }, e.id))
|
|
234
|
+
}, `skeleton-${t}`)) : Q?.length ? Q.map((t, r) => {
|
|
235
|
+
if (N) return /* @__PURE__ */ _(m, { children: N(t, r) }, t.id);
|
|
236
|
+
let i = t.getIsSelected(), a = O && st === t.id, o = i || a ? "bg-[var(--ui-table-data-row-color-active)]" : be && r % 2 == 1 ? "bg-[var(--ui-background-surface-secondary)]" : "bg-background group-hover:bg-[var(--ui-table-data-row-color-hover)]", s = !$ && ht === t.id;
|
|
237
|
+
return /* @__PURE__ */ v(m, { children: [/* @__PURE__ */ _(p, {
|
|
233
238
|
ref: (e) => {
|
|
234
|
-
|
|
239
|
+
U.current[r] = e;
|
|
235
240
|
},
|
|
236
|
-
tabIndex: r ===
|
|
237
|
-
onFocus: () =>
|
|
238
|
-
onKeyDown: (e) =>
|
|
241
|
+
tabIndex: r === Ct ? 0 : -1,
|
|
242
|
+
onFocus: () => wt(r),
|
|
243
|
+
onKeyDown: (e) => Tt(e, r),
|
|
239
244
|
selected: i,
|
|
240
|
-
onClick:
|
|
241
|
-
className: e("group",
|
|
245
|
+
onClick: O ? () => ct(t.id) : void 0,
|
|
246
|
+
className: e("group", O && "cursor-pointer", be && r % 2 == 1 && !i && !a && "bg-[var(--ui-background-surface-secondary)]", a && !i && "bg-[var(--ui-table-data-row-color-active)]", s && "hover:bg-transparent"),
|
|
242
247
|
children: t.getVisibleCells().map((r) => {
|
|
243
248
|
let i = r.column.getIsPinned();
|
|
244
|
-
return r.column.id === "__actions" ? /* @__PURE__ */
|
|
245
|
-
style: x(r,
|
|
249
|
+
return r.column.id === "__actions" ? /* @__PURE__ */ _(oe, {
|
|
250
|
+
style: x(r, X),
|
|
246
251
|
className: o,
|
|
247
|
-
bulkSelectionActive:
|
|
248
|
-
onMouseEnter:
|
|
249
|
-
onMouseLeave:
|
|
250
|
-
children:
|
|
251
|
-
render: /* @__PURE__ */
|
|
252
|
-
children: /* @__PURE__ */
|
|
253
|
-
}), /* @__PURE__ */
|
|
252
|
+
bulkSelectionActive: $,
|
|
253
|
+
onMouseEnter: $ ? void 0 : () => q(t.id),
|
|
254
|
+
onMouseLeave: $ ? void 0 : () => q((e) => e === t.id ? void 0 : e),
|
|
255
|
+
children: R && /* @__PURE__ */ v(ne, { children: [/* @__PURE__ */ _(ie, {
|
|
256
|
+
render: /* @__PURE__ */ _(n, { "aria-label": Le }),
|
|
257
|
+
children: /* @__PURE__ */ _(he, {})
|
|
258
|
+
}), /* @__PURE__ */ _(re, {
|
|
254
259
|
align: "end",
|
|
255
|
-
children:
|
|
260
|
+
children: R(t)
|
|
256
261
|
})] })
|
|
257
|
-
}, r.id) : /* @__PURE__ */
|
|
262
|
+
}, r.id) : /* @__PURE__ */ _(f, {
|
|
258
263
|
wrap: r.column.columnDef.meta?.wrap,
|
|
259
|
-
style: x(r,
|
|
264
|
+
style: x(r, X),
|
|
260
265
|
className: e(i && o),
|
|
261
266
|
children: d(r.column.columnDef.cell, r.getContext())
|
|
262
267
|
}, r.id);
|
|
263
268
|
})
|
|
264
|
-
}), D && t.getIsExpanded() && /* @__PURE__ */
|
|
269
|
+
}), D && t.getIsExpanded() && /* @__PURE__ */ _(p, {
|
|
265
270
|
className: "hover:bg-transparent",
|
|
266
|
-
children: /* @__PURE__ */
|
|
271
|
+
children: /* @__PURE__ */ _(f, {
|
|
267
272
|
className: "h-auto py-3",
|
|
268
273
|
colSpan: t.getVisibleCells().length,
|
|
269
274
|
children: D(t)
|
|
270
275
|
})
|
|
271
276
|
})] }, t.id);
|
|
272
|
-
}) :
|
|
273
|
-
colSpan:
|
|
277
|
+
}) : P ? /* @__PURE__ */ _(p, { children: /* @__PURE__ */ _(f, {
|
|
278
|
+
colSpan: J.getVisibleLeafColumns().length,
|
|
274
279
|
className: "h-24 text-center",
|
|
275
|
-
children:
|
|
276
|
-
}) }) : /* @__PURE__ */
|
|
277
|
-
colSpan:
|
|
280
|
+
children: P({ hasFilters: J.getState().columnFilters.length > 0 })
|
|
281
|
+
}) }) : /* @__PURE__ */ _(p, { children: /* @__PURE__ */ _(f, {
|
|
282
|
+
colSpan: J.getVisibleLeafColumns().length,
|
|
278
283
|
className: "h-24 text-center text-[var(--ui-table-data-value-color-disabled)]",
|
|
279
|
-
children:
|
|
284
|
+
children: Fe
|
|
280
285
|
}) }),
|
|
281
|
-
|
|
282
|
-
ref:
|
|
286
|
+
Y && !k && Q.length > 0 && I && /* @__PURE__ */ _(p, {
|
|
287
|
+
ref: vt,
|
|
283
288
|
"aria-hidden": !0,
|
|
284
289
|
className: "hover:bg-transparent",
|
|
285
|
-
children: /* @__PURE__ */
|
|
286
|
-
colSpan:
|
|
290
|
+
children: /* @__PURE__ */ _(f, {
|
|
291
|
+
colSpan: J.getVisibleLeafColumns().length,
|
|
287
292
|
className: "h-1 p-0"
|
|
288
293
|
})
|
|
289
294
|
}),
|
|
290
|
-
|
|
295
|
+
Y && !k && Q.length > 0 && L && /* @__PURE__ */ _(p, {
|
|
291
296
|
className: "hover:bg-transparent",
|
|
292
|
-
children: /* @__PURE__ */
|
|
293
|
-
colSpan:
|
|
294
|
-
children: /* @__PURE__ */
|
|
297
|
+
children: /* @__PURE__ */ _(f, {
|
|
298
|
+
colSpan: J.getVisibleLeafColumns().length,
|
|
299
|
+
children: /* @__PURE__ */ _("div", {
|
|
295
300
|
role: "status",
|
|
296
301
|
"aria-live": "polite",
|
|
297
302
|
className: "h-4 w-full animate-pulse rounded bg-[var(--ui-background-surface-secondary)]",
|
|
298
|
-
children: /* @__PURE__ */
|
|
303
|
+
children: /* @__PURE__ */ _("span", {
|
|
299
304
|
className: "sr-only",
|
|
300
305
|
children: "Loading more rows…"
|
|
301
306
|
})
|
|
@@ -307,6 +312,6 @@ function E({ columns: v = [], data: y = [], table: E, getRowCanExpand: ve, rende
|
|
|
307
312
|
});
|
|
308
313
|
}
|
|
309
314
|
//#endregion
|
|
310
|
-
export { E as DataTable, x as getCellStyle,
|
|
315
|
+
export { E as DataTable, x as getCellStyle, b as getColumnWidth, y as getPinnedStyle, w as getResizeKeyboardStep, T as reorderColumn };
|
|
311
316
|
|
|
312
317
|
//# sourceMappingURL=data-table.js.map
|