@bmsuisse/datagrid 0.32.0 → 0.32.2
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/index.d.ts +22 -1
- package/dist/index.js +25 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1744,6 +1744,17 @@ interface TreeDataGridProps<TRow> extends TreeAccessors<TRow> {
|
|
|
1744
1744
|
columns: ColumnDef<TRow>[];
|
|
1745
1745
|
/** Root-level rows. */
|
|
1746
1746
|
data: TRow[];
|
|
1747
|
+
/**
|
|
1748
|
+
* Whether the root `data` set is still being fetched. Purely cosmetic —
|
|
1749
|
+
* unlike `<DataGrid>`'s `loading` (a full-overlay spinner over the whole
|
|
1750
|
+
* body), `<TreeDataGrid>` has no existing rows to obscure while `data` is
|
|
1751
|
+
* empty, so this only swaps the empty-state row from "No results." to a
|
|
1752
|
+
* spinner + "Loading..." for as long as `data.length === 0`. Once real
|
|
1753
|
+
* rows arrive, this stops mattering — a background refetch never re-shows
|
|
1754
|
+
* the empty state, so there's nothing for a full overlay to add here.
|
|
1755
|
+
* Defaults to `false`.
|
|
1756
|
+
*/
|
|
1757
|
+
loading?: boolean;
|
|
1747
1758
|
/**
|
|
1748
1759
|
* The column whose cell gets the depth indentation + expand/collapse
|
|
1749
1760
|
* chevron prepended. Defaults to the first column in `columns`.
|
|
@@ -1848,6 +1859,16 @@ interface TreeDataGridProps<TRow> extends TreeAccessors<TRow> {
|
|
|
1848
1859
|
estimatedRowHeight?: number;
|
|
1849
1860
|
/** Max height of the scrollable table body in pixels. Required for virtualization to have a viewport to scroll within. Defaults to 480. */
|
|
1850
1861
|
maxBodyHeight?: number;
|
|
1862
|
+
/**
|
|
1863
|
+
* `data-testid` for the tree's own scrollable container — the element
|
|
1864
|
+
* `maxBodyHeight` actually applies to once virtualized. Omit for no
|
|
1865
|
+
* attribute at all. Useful for an e2e test that needs to scroll this
|
|
1866
|
+
* specific tree or assert on its scroll position; the outer
|
|
1867
|
+
* `data-testid="tree-datagrid"` wrapper isn't it, and isn't unique per
|
|
1868
|
+
* tree on a page with more than one — same convention as `<DataGrid>`'s
|
|
1869
|
+
* own `testId`.
|
|
1870
|
+
*/
|
|
1871
|
+
testId?: string;
|
|
1851
1872
|
/**
|
|
1852
1873
|
* Controlled row selection — same convention as `<DataGrid>`'s own
|
|
1853
1874
|
* `selectedIds`/`onSelectedIdsChange`. Both must be supplied together to
|
|
@@ -1949,7 +1970,7 @@ interface TreeDataGridProps<TRow> extends TreeAccessors<TRow> {
|
|
|
1949
1970
|
* column's cell matches `treeColumnId` (defaults to `columns[0]`); every
|
|
1950
1971
|
* other column renders exactly like it would in `<DataGrid>`.
|
|
1951
1972
|
*/
|
|
1952
|
-
declare function TreeDataGrid<TRow>({ columns, data, treeColumnId, columnVisibility, getRowId, getChildren, hasChildren, onLoadChildren, initialExpandedLevel, expanded: controlledExpanded, onExpandedChange, childrenMap: controlledChildrenMap, onChildrenMapChange, indentSize, getRowProps, getRowTestId, rowActions, virtualizeThreshold, estimatedRowHeight, maxBodyHeight, selectedIds: controlledSelectedIds, onSelectedIdsChange, getRowSelectionState, isRowSelectionDisabled, groupBy, renderGroupHeader, defaultGroupsExpanded, expandedGroups: controlledExpandedGroups, onExpandedGroupsChange, zebra, editing, }: TreeDataGridProps<TRow>): ReactElement;
|
|
1973
|
+
declare function TreeDataGrid<TRow>({ columns, data, loading, treeColumnId, columnVisibility, getRowId, getChildren, hasChildren, onLoadChildren, initialExpandedLevel, expanded: controlledExpanded, onExpandedChange, childrenMap: controlledChildrenMap, onChildrenMapChange, indentSize, getRowProps, getRowTestId, rowActions, virtualizeThreshold, estimatedRowHeight, maxBodyHeight, testId, selectedIds: controlledSelectedIds, onSelectedIdsChange, getRowSelectionState, isRowSelectionDisabled, groupBy, renderGroupHeader, defaultGroupsExpanded, expandedGroups: controlledExpandedGroups, onExpandedGroupsChange, zebra, editing, }: TreeDataGridProps<TRow>): ReactElement;
|
|
1953
1974
|
|
|
1954
1975
|
interface FlatTreeRow<TRow> {
|
|
1955
1976
|
row: TRow;
|
package/dist/index.js
CHANGED
|
@@ -4397,6 +4397,7 @@ function TreeCell({
|
|
|
4397
4397
|
function TreeDataGrid({
|
|
4398
4398
|
columns,
|
|
4399
4399
|
data,
|
|
4400
|
+
loading = false,
|
|
4400
4401
|
treeColumnId,
|
|
4401
4402
|
columnVisibility,
|
|
4402
4403
|
getRowId,
|
|
@@ -4415,6 +4416,7 @@ function TreeDataGrid({
|
|
|
4415
4416
|
virtualizeThreshold = 100,
|
|
4416
4417
|
estimatedRowHeight = 40,
|
|
4417
4418
|
maxBodyHeight = 480,
|
|
4419
|
+
testId,
|
|
4418
4420
|
selectedIds: controlledSelectedIds,
|
|
4419
4421
|
onSelectedIdsChange,
|
|
4420
4422
|
getRowSelectionState,
|
|
@@ -4603,30 +4605,44 @@ function TreeDataGrid({
|
|
|
4603
4605
|
"div",
|
|
4604
4606
|
{
|
|
4605
4607
|
ref: scrollRef,
|
|
4608
|
+
"data-testid": testId,
|
|
4606
4609
|
className: shouldVirtualize ? "overflow-y-auto" : void 0,
|
|
4607
4610
|
style: shouldVirtualize ? { maxHeight: maxBodyHeight } : void 0,
|
|
4608
4611
|
children: /* @__PURE__ */ jsxs21("table", { className: "w-full border-collapse text-sm", children: [
|
|
4609
4612
|
/* @__PURE__ */ jsx34("thead", { ref: theadRef, children: /* @__PURE__ */ jsxs21("tr", { className: "divide-x divide-border", children: [
|
|
4610
|
-
showSelectionColumn && /* @__PURE__ */ jsx34(
|
|
4611
|
-
|
|
4613
|
+
showSelectionColumn && /* @__PURE__ */ jsx34(
|
|
4614
|
+
"th",
|
|
4612
4615
|
{
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
+
className: "sticky top-0 z-20 border-b border-border bg-muted p-1",
|
|
4617
|
+
style: { width: SELECTION_COLUMN_WIDTH },
|
|
4618
|
+
children: /* @__PURE__ */ jsx34(
|
|
4619
|
+
Checkbox,
|
|
4620
|
+
{
|
|
4621
|
+
"aria-label": "Select all visible rows",
|
|
4622
|
+
checked: allVisibleSelected,
|
|
4623
|
+
onCheckedChange: toggleAllVisibleSelected
|
|
4624
|
+
}
|
|
4625
|
+
)
|
|
4616
4626
|
}
|
|
4617
|
-
)
|
|
4627
|
+
),
|
|
4618
4628
|
visibleColumns.map((column) => /* @__PURE__ */ jsx34(
|
|
4619
4629
|
"th",
|
|
4620
4630
|
{
|
|
4621
4631
|
style: column.width ? { width: column.width } : void 0,
|
|
4622
|
-
className:
|
|
4632
|
+
className: cn(
|
|
4633
|
+
"sticky top-0 z-20 border-b border-border bg-muted p-2 font-medium",
|
|
4634
|
+
alignClassName(column)
|
|
4635
|
+
),
|
|
4623
4636
|
children: column.header
|
|
4624
4637
|
},
|
|
4625
4638
|
column.id
|
|
4626
4639
|
)),
|
|
4627
|
-
showRowActionsColumn && /* @__PURE__ */ jsx34("th", { className: "border-b border-border p-2", "aria-label": "Row actions" })
|
|
4640
|
+
showRowActionsColumn && /* @__PURE__ */ jsx34("th", { className: "sticky top-0 z-20 border-b border-border bg-muted p-2", "aria-label": "Row actions" })
|
|
4628
4641
|
] }) }),
|
|
4629
|
-
/* @__PURE__ */ jsx34("tbody", { children: data.length === 0 ? /* @__PURE__ */ jsx34("tr", { children: /* @__PURE__ */ jsx34("td", { colSpan: totalColumnCount, className: "p-4 text-center text-muted-foreground", children:
|
|
4642
|
+
/* @__PURE__ */ jsx34("tbody", { children: data.length === 0 ? /* @__PURE__ */ jsx34("tr", { children: /* @__PURE__ */ jsx34("td", { colSpan: totalColumnCount, className: "p-4 text-center text-muted-foreground", children: loading ? /* @__PURE__ */ jsxs21("span", { className: "inline-flex items-center gap-2", children: [
|
|
4643
|
+
/* @__PURE__ */ jsx34(Loader22, { className: "h-4 w-4 animate-spin", "aria-hidden": "true" }),
|
|
4644
|
+
"Loading..."
|
|
4645
|
+
] }) : "No results." }) }) : groupedBuckets ? groupedBuckets.map((bucket) => {
|
|
4630
4646
|
const groupExpanded = isGroupExpanded(bucket.key);
|
|
4631
4647
|
return /* @__PURE__ */ jsxs21(Fragment5, { children: [
|
|
4632
4648
|
/* @__PURE__ */ jsx34("tr", { "data-testid": `group-header-${bucket.key}`, children: /* @__PURE__ */ jsx34(
|