@databiosphere/findable-ui 20.0.0 → 21.0.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/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +11 -0
- package/lib/components/Table/common/columnDef.js +18 -2
- package/lib/components/Table/common/columnIdentifier.d.ts +4 -0
- package/lib/components/Table/common/columnIdentifier.js +4 -0
- package/lib/components/Table/common/typeGuards.d.ts +11 -0
- package/lib/components/Table/common/typeGuards.js +8 -0
- package/lib/components/Table/common/utils.d.ts +1 -28
- package/lib/components/Table/common/utils.js +5 -88
- package/lib/components/Table/components/TableCell/common/utils.js +3 -3
- package/lib/components/Table/components/TableCell/components/RowSelectionCell/rowSelectionCell.d.ts +2 -5
- package/lib/components/Table/components/TableFeatures/ColumnVisibility/utils.d.ts +7 -18
- package/lib/components/Table/components/TableFeatures/ColumnVisibility/utils.js +20 -31
- package/lib/components/Table/components/TableHead/components/HeadSelectionCell/headSelectionCell.d.ts +2 -5
- package/lib/components/Table/components/TableHead/components/HeadSelectionCell/headSelectionCell.js +2 -2
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/columnGrouping.js +5 -17
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/components/MenuItems/constants.d.ts +3 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/components/MenuItems/constants.js +10 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/components/MenuItems/menuItems.d.ts +1 -1
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/components/MenuItems/menuItems.js +22 -10
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/components/MenuItems/types.d.ts +1 -2
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/components/MenuItems/utils.d.ts +27 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/components/MenuItems/utils.js +45 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/constants.d.ts +1 -3
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/constants.js +0 -10
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/utils.d.ts +3 -13
- package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/utils.js +22 -27
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/columnVisibility.d.ts +3 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/columnVisibility.js +13 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/columnVisibility.styles.d.ts +3 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/columnVisibility.styles.js +11 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/components/MenuItems/constants.d.ts +2 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/components/MenuItems/constants.js +7 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/components/MenuItems/menuItems.d.ts +3 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/components/MenuItems/menuItems.js +22 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/components/MenuItems/menuItems.styles.d.ts +2 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/components/MenuItems/menuItems.styles.js +16 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/components/MenuItems/types.d.ts +4 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/components/MenuItems/types.js +1 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/components/MenuItems/utils.d.ts +26 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/components/MenuItems/utils.js +32 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/constants.d.ts +2 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/constants.js +3 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/types.d.ts +4 -0
- package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/types.js +1 -0
- package/lib/components/Table/components/TableToolbar/tableToolbar.js +5 -12
- package/lib/components/Table/features/RowPosition/constants.js +5 -3
- package/lib/components/Table/features/RowPosition/types.d.ts +3 -0
- package/lib/components/Table/features/RowPosition/utils.d.ts +1 -7
- package/lib/components/Table/features/RowPosition/utils.js +0 -20
- package/lib/components/Table/features/RowPreview/constants.js +1 -1
- package/lib/components/Table/features/entities.d.ts +2 -2
- package/lib/components/Table/table.d.ts +2 -4
- package/lib/components/Table/table.js +9 -31
- package/lib/components/TableCreator/common/utils.js +1 -4
- package/lib/components/TableCreator/options/columnTrackSizing/typeGuards.d.ts +7 -0
- package/lib/components/TableCreator/options/columnTrackSizing/typeGuards.js +8 -0
- package/lib/components/TableCreator/options/columnTrackSizing/utils.d.ts +30 -0
- package/lib/components/TableCreator/options/columnTrackSizing/utils.js +83 -0
- package/lib/components/TableCreator/options/hook.js +8 -7
- package/lib/components/TableCreator/options/initialState/columnVisibility.d.ts +7 -0
- package/lib/components/TableCreator/options/initialState/columnVisibility.js +16 -0
- package/lib/components/TableCreator/options/initialState/hook.d.ts +2 -0
- package/lib/components/TableCreator/options/initialState/hook.js +10 -0
- package/lib/components/TableCreator/options/visibility/constants.d.ts +2 -0
- package/lib/components/TableCreator/options/visibility/constants.js +3 -0
- package/lib/components/TableCreator/options/visibility/hook.d.ts +2 -0
- package/lib/components/TableCreator/options/visibility/hook.js +11 -0
- package/lib/components/TableCreator/tableCreator.js +4 -18
- package/lib/config/entities.d.ts +0 -4
- package/lib/providers/exploreState/actions/updateVisibility/action.d.ts +10 -0
- package/lib/providers/exploreState/actions/updateVisibility/action.js +16 -0
- package/lib/providers/exploreState/actions/updateVisibility/dispatch.d.ts +7 -0
- package/lib/providers/exploreState/actions/updateVisibility/dispatch.js +12 -0
- package/lib/providers/exploreState/actions/updateVisibility/types.d.ts +9 -0
- package/lib/providers/exploreState/actions/updateVisibility/types.js +1 -0
- package/lib/providers/exploreState/actions/updateVisibility/utils.d.ts +10 -0
- package/lib/providers/exploreState/actions/updateVisibility/utils.js +21 -0
- package/lib/providers/exploreState/entities.d.ts +1 -1
- package/lib/providers/exploreState/initializer/utils.js +5 -13
- package/lib/providers/exploreState/payloads/entities.d.ts +1 -5
- package/lib/providers/exploreState/utils.d.ts +1 -1
- package/lib/providers/exploreState/utils.js +5 -5
- package/lib/providers/exploreState.d.ts +2 -8
- package/lib/providers/exploreState.js +2 -5
- package/package.json +1 -1
- package/src/components/Table/common/columnDef.ts +18 -2
- package/src/components/Table/common/columnIdentifier.ts +4 -0
- package/src/components/Table/common/typeGuards.ts +12 -0
- package/src/components/Table/common/utils.ts +5 -115
- package/src/components/Table/components/TableCell/common/utils.ts +3 -3
- package/src/components/Table/components/TableCell/components/RowSelectionCell/rowSelectionCell.tsx +3 -7
- package/src/components/Table/components/TableFeatures/ColumnVisibility/utils.ts +25 -44
- package/src/components/Table/components/TableHead/components/HeadSelectionCell/headSelectionCell.tsx +5 -9
- package/src/components/Table/components/TableToolbar/components/ColumnGrouping/columnGrouping.tsx +4 -22
- package/src/components/Table/components/TableToolbar/components/ColumnGrouping/components/MenuItems/constants.ts +13 -0
- package/src/components/Table/components/TableToolbar/components/ColumnGrouping/components/MenuItems/menuItems.tsx +47 -20
- package/src/components/Table/components/TableToolbar/components/ColumnGrouping/components/MenuItems/types.ts +1 -2
- package/src/components/Table/components/TableToolbar/components/ColumnGrouping/components/MenuItems/utils.ts +58 -0
- package/src/components/Table/components/TableToolbar/components/ColumnGrouping/constants.ts +1 -13
- package/src/components/Table/components/TableToolbar/components/ColumnGrouping/utils.ts +26 -33
- package/src/components/Table/components/TableToolbar/components/ColumnVisibility/columnVisibility.styles.ts +12 -0
- package/src/components/Table/components/TableToolbar/components/ColumnVisibility/columnVisibility.tsx +28 -0
- package/src/components/Table/components/TableToolbar/components/ColumnVisibility/components/MenuItems/constants.ts +9 -0
- package/src/components/Table/components/TableToolbar/components/ColumnVisibility/components/MenuItems/menuItems.styles.ts +17 -0
- package/src/components/Table/components/TableToolbar/components/ColumnVisibility/components/MenuItems/menuItems.tsx +53 -0
- package/src/components/Table/components/TableToolbar/components/ColumnVisibility/components/MenuItems/types.ts +5 -0
- package/src/components/Table/components/TableToolbar/components/ColumnVisibility/components/MenuItems/utils.ts +44 -0
- package/src/components/Table/components/TableToolbar/components/ColumnVisibility/constants.ts +5 -0
- package/src/components/Table/components/TableToolbar/components/ColumnVisibility/types.ts +5 -0
- package/src/components/Table/components/TableToolbar/tableToolbar.tsx +5 -19
- package/src/components/Table/features/RowPosition/constants.ts +8 -5
- package/src/components/Table/features/RowPosition/types.ts +4 -0
- package/src/components/Table/features/RowPosition/utils.ts +1 -30
- package/src/components/Table/features/RowPreview/constants.ts +1 -1
- package/src/components/Table/features/entities.ts +2 -2
- package/src/components/Table/table.tsx +8 -46
- package/src/components/TableCreator/common/utils.ts +0 -4
- package/src/components/TableCreator/options/columnTrackSizing/typeGuards.ts +12 -0
- package/src/components/TableCreator/options/columnTrackSizing/utils.ts +99 -0
- package/src/components/TableCreator/options/hook.ts +8 -11
- package/src/components/TableCreator/options/initialState/columnVisibility.ts +22 -0
- package/src/components/TableCreator/options/initialState/hook.ts +24 -0
- package/src/components/TableCreator/options/visibility/constants.ts +5 -0
- package/src/components/TableCreator/options/visibility/hook.ts +22 -0
- package/src/components/TableCreator/tableCreator.tsx +3 -27
- package/src/config/entities.ts +2 -4
- package/src/providers/exploreState/actions/updateVisibility/action.ts +29 -0
- package/src/providers/exploreState/actions/updateVisibility/dispatch.ts +19 -0
- package/src/providers/exploreState/actions/updateVisibility/types.ts +11 -0
- package/src/providers/exploreState/actions/updateVisibility/utils.ts +28 -0
- package/src/providers/exploreState/entities.ts +1 -1
- package/src/providers/exploreState/initializer/utils.ts +5 -21
- package/src/providers/exploreState/payloads/entities.ts +0 -6
- package/src/providers/exploreState/utils.ts +5 -5
- package/src/providers/exploreState.tsx +3 -18
- package/lib/components/Table/components/CheckboxMenu/checkboxMenu.d.ts +0 -16
- package/lib/components/Table/components/CheckboxMenu/checkboxMenu.js +0 -28
- package/lib/components/Table/components/CheckboxMenu/checkboxMenu.stories.d.ts +0 -5
- package/lib/components/Table/components/CheckboxMenu/checkboxMenu.stories.js +0 -46
- package/lib/components/Table/components/CheckboxMenu/checkboxMenu.styles.d.ts +0 -3
- package/lib/components/Table/components/CheckboxMenu/checkboxMenu.styles.js +0 -21
- package/lib/components/Table/features/constants.d.ts +0 -6
- package/lib/components/Table/features/constants.js +0 -8
- package/lib/components/TableCreator/common/constants.d.ts +0 -7
- package/lib/components/TableCreator/common/constants.js +0 -21
- package/src/components/Table/components/CheckboxMenu/checkboxMenu.stories.tsx +0 -54
- package/src/components/Table/components/CheckboxMenu/checkboxMenu.styles.ts +0 -22
- package/src/components/Table/components/CheckboxMenu/checkboxMenu.tsx +0 -87
- package/src/components/Table/features/constants.ts +0 -10
- package/src/components/TableCreator/common/constants.ts +0 -25
- /package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/{columnGrouping.styles.d.ts → components/MenuItems/menuItems.styles.d.ts} +0 -0
- /package/lib/components/Table/components/TableToolbar/components/ColumnGrouping/{columnGrouping.styles.js → components/MenuItems/menuItems.styles.js} +0 -0
- /package/src/components/Table/components/TableToolbar/components/ColumnGrouping/{columnGrouping.styles.ts → components/MenuItems/menuItems.styles.ts} +0 -0
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
import { Column,
|
|
1
|
+
import { Column, RowData } from "@tanstack/react-table";
|
|
2
2
|
/**
|
|
3
3
|
* Retrieves the button label for the column grouping dropdown.
|
|
4
|
-
*
|
|
5
|
-
* @param groupingByColumnId - Map of column groupings by column ID.
|
|
6
|
-
* @param groupingState - Grouping state.
|
|
4
|
+
* @param columns - Columns.
|
|
7
5
|
* @returns button label.
|
|
8
6
|
*/
|
|
9
|
-
export declare function getButtonLabel<T extends RowData>(
|
|
10
|
-
/**
|
|
11
|
-
* Retrieves a map of column groupings by column ID from the given table instance.
|
|
12
|
-
* Columns that are visible, group-able with a `string` header are included and are keyed by
|
|
13
|
-
* their column ID. The value is a tuple containing the column header and the column instance.
|
|
14
|
-
* @param table - Table.
|
|
15
|
-
* @returns map of column grouping by column id.
|
|
16
|
-
*/
|
|
17
|
-
export declare function getColumnGrouping<T extends RowData>(table: Table<T>): Map<string, [string, Column<T>]>;
|
|
7
|
+
export declare function getButtonLabel<T extends RowData>(columns: Column<T>[]): string;
|
|
@@ -1,36 +1,31 @@
|
|
|
1
|
+
import { isStringHeaderColumn } from "../../../../common/typeGuards";
|
|
1
2
|
/**
|
|
2
3
|
* Retrieves the button label for the column grouping dropdown.
|
|
3
|
-
*
|
|
4
|
-
* @param groupingByColumnId - Map of column groupings by column ID.
|
|
5
|
-
* @param groupingState - Grouping state.
|
|
4
|
+
* @param columns - Columns.
|
|
6
5
|
* @returns button label.
|
|
7
6
|
*/
|
|
8
|
-
export function getButtonLabel(
|
|
9
|
-
const
|
|
10
|
-
|
|
7
|
+
export function getButtonLabel(columns) {
|
|
8
|
+
const headers = columns
|
|
9
|
+
.filter(isColumnGrouped)
|
|
10
|
+
.filter(isStringHeaderColumn)
|
|
11
|
+
.map(mapGroupedHeader);
|
|
12
|
+
if (headers.length === 0)
|
|
11
13
|
return "Group by";
|
|
12
|
-
return `Group by: ${
|
|
14
|
+
return `Group by: ${headers.join(", ")}`;
|
|
13
15
|
}
|
|
14
16
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* @param table - Table.
|
|
19
|
-
* @returns map of column grouping by column id.
|
|
17
|
+
* Returns true if the column is grouped.
|
|
18
|
+
* @param column - Column.
|
|
19
|
+
* @returns true if the column is grouped.
|
|
20
20
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (typeof header !== "string")
|
|
32
|
-
continue;
|
|
33
|
-
groupingByColumnId.set(id, [header, column]);
|
|
34
|
-
}
|
|
35
|
-
return groupingByColumnId;
|
|
21
|
+
function isColumnGrouped(column) {
|
|
22
|
+
return column.getIsGrouped();
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Maps a column to its header.
|
|
26
|
+
* @param column - Column.
|
|
27
|
+
* @returns header.
|
|
28
|
+
*/
|
|
29
|
+
function mapGroupedHeader(column) {
|
|
30
|
+
return column.columnDef.header;
|
|
36
31
|
}
|
package/lib/components/Table/components/TableToolbar/components/ColumnVisibility/columnVisibility.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DropdownButton } from "../../../../../common/Button/components/DropdownButton/dropdownButton";
|
|
3
|
+
import { StyledDropdownMenu } from "./columnVisibility.styles";
|
|
4
|
+
import { MenuItems } from "./components/MenuItems/menuItems";
|
|
5
|
+
import { MENU_PROPS } from "./constants";
|
|
6
|
+
export const ColumnVisibility = ({ tableInstance, }) => {
|
|
7
|
+
const { options: { enableHiding }, } = tableInstance;
|
|
8
|
+
if (!enableHiding)
|
|
9
|
+
return null;
|
|
10
|
+
return (React.createElement(StyledDropdownMenu, { ...MENU_PROPS, button: (props) => (React.createElement(DropdownButton, { ...props }, "Edit Columns")) }, () => [
|
|
11
|
+
React.createElement(MenuItems, { key: "column-visibility", tableInstance: tableInstance }),
|
|
12
|
+
]));
|
|
13
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import styled from "@emotion/styled";
|
|
2
|
+
import { DropdownMenu } from "../../../../../common/DropdownMenu/dropdownMenu";
|
|
3
|
+
export const StyledDropdownMenu = styled(DropdownMenu) `
|
|
4
|
+
.MuiListItemButton-root {
|
|
5
|
+
gap: 8px;
|
|
6
|
+
|
|
7
|
+
&.Mui-disabled {
|
|
8
|
+
opacity: 1;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
`;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Checkbox, ListItemButton, ListItemText } from "@mui/material";
|
|
2
|
+
import React, { Fragment } from "react";
|
|
3
|
+
import { CheckedIcon } from "../../../../../../../common/CustomIcon/components/CheckedIcon/checkedIcon";
|
|
4
|
+
import { UncheckedIcon } from "../../../../../../../common/CustomIcon/components/UncheckedIcon/uncheckedIcon";
|
|
5
|
+
import { handleResetVisibilityState } from "../../../../../TableFeatures/ColumnVisibility/utils";
|
|
6
|
+
import { LIST_ITEM_TEXT_PROPS } from "./constants";
|
|
7
|
+
import { StyledMenuItem } from "./menuItems.styles";
|
|
8
|
+
import { getCanHideColumns, getVisibleColumnCount, isToggleVisibilityDisabled, } from "./utils";
|
|
9
|
+
export const MenuItems = ({ tableInstance, }) => {
|
|
10
|
+
const { getAllColumns } = tableInstance;
|
|
11
|
+
const columns = getCanHideColumns(getAllColumns());
|
|
12
|
+
const visibleCount = getVisibleColumnCount(columns);
|
|
13
|
+
return (React.createElement(Fragment, null,
|
|
14
|
+
columns.map((column) => {
|
|
15
|
+
const isDisabled = isToggleVisibilityDisabled(column, visibleCount);
|
|
16
|
+
return (React.createElement(ListItemButton, { key: column.id, component: "li", disabled: isDisabled, onClick: () => column.toggleVisibility() },
|
|
17
|
+
React.createElement(Checkbox, { checked: column.getIsVisible(), checkedIcon: React.createElement(CheckedIcon, null), disabled: isDisabled, icon: React.createElement(UncheckedIcon, null) }),
|
|
18
|
+
React.createElement(ListItemText, { disableTypography: true }, column.columnDef.header)));
|
|
19
|
+
}),
|
|
20
|
+
React.createElement(StyledMenuItem, { component: "li", onClick: () => handleResetVisibilityState(tableInstance) },
|
|
21
|
+
React.createElement(ListItemText, { ...LIST_ITEM_TEXT_PROPS }, "Reset"))));
|
|
22
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import styled from "@emotion/styled";
|
|
2
|
+
import { MenuItem } from "@mui/material";
|
|
3
|
+
export const StyledMenuItem = styled(MenuItem) `
|
|
4
|
+
&:hover {
|
|
5
|
+
background-color: transparent;
|
|
6
|
+
|
|
7
|
+
.MuiListItemText-root {
|
|
8
|
+
.MuiListItemText-primary {
|
|
9
|
+
text-decoration: underline;
|
|
10
|
+
text-decoration-skip-ink: none;
|
|
11
|
+
text-underline-color: currentColor;
|
|
12
|
+
text-underline-position: from-font;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Column, RowData } from "@tanstack/react-table";
|
|
2
|
+
/**
|
|
3
|
+
* Returns columns that are enabled to be hidden.
|
|
4
|
+
* @param columns - Columns.
|
|
5
|
+
* @returns columns that are enabled to be hidden.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getCanHideColumns<T extends RowData>(columns: Column<T>[]): (Column<T> & {
|
|
8
|
+
columnDef: {
|
|
9
|
+
header: string;
|
|
10
|
+
};
|
|
11
|
+
})[];
|
|
12
|
+
/**
|
|
13
|
+
* Returns the number of visible columns, excluding grouped columns.
|
|
14
|
+
* @param columns - Columns.
|
|
15
|
+
* @returns number of visible, un-grouped columns.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getVisibleColumnCount<T extends RowData>(columns: Column<T>[]): number;
|
|
18
|
+
/**
|
|
19
|
+
* Returns whether the column visibility toggle is disabled.
|
|
20
|
+
* - If the column is grouped, the toggle is disabled.
|
|
21
|
+
* - If the column is visible and the count of visible, un-grouped columns is 1, the toggle is disabled.
|
|
22
|
+
* @param column - Column.
|
|
23
|
+
* @param visibleCount - Count of visible, un-grouped columns.
|
|
24
|
+
* @returns true if the column visibility toggle is disabled.
|
|
25
|
+
*/
|
|
26
|
+
export declare function isToggleVisibilityDisabled<T extends RowData>(column: Column<T>, visibleCount: number): boolean;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { isStringHeaderColumn } from "../../../../../../common/typeGuards";
|
|
2
|
+
/**
|
|
3
|
+
* Returns columns that are enabled to be hidden.
|
|
4
|
+
* @param columns - Columns.
|
|
5
|
+
* @returns columns that are enabled to be hidden.
|
|
6
|
+
*/
|
|
7
|
+
export function getCanHideColumns(columns) {
|
|
8
|
+
return columns
|
|
9
|
+
.filter(isStringHeaderColumn) // Currently, headers are configured as strings. Only include columns that have a string header (for now).
|
|
10
|
+
.filter(({ getCanHide }) => getCanHide());
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Returns the number of visible columns, excluding grouped columns.
|
|
14
|
+
* @param columns - Columns.
|
|
15
|
+
* @returns number of visible, un-grouped columns.
|
|
16
|
+
*/
|
|
17
|
+
export function getVisibleColumnCount(columns) {
|
|
18
|
+
return columns.filter(({ getIsGrouped, getIsVisible }) => getIsVisible() && !getIsGrouped()).length;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Returns whether the column visibility toggle is disabled.
|
|
22
|
+
* - If the column is grouped, the toggle is disabled.
|
|
23
|
+
* - If the column is visible and the count of visible, un-grouped columns is 1, the toggle is disabled.
|
|
24
|
+
* @param column - Column.
|
|
25
|
+
* @param visibleCount - Count of visible, un-grouped columns.
|
|
26
|
+
* @returns true if the column visibility toggle is disabled.
|
|
27
|
+
*/
|
|
28
|
+
export function isToggleVisibilityDisabled(column, visibleCount) {
|
|
29
|
+
if (column.getIsGrouped())
|
|
30
|
+
return true;
|
|
31
|
+
return column.getIsVisible() && visibleCount === 1;
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React, { Fragment } from "react";
|
|
2
2
|
import { useExploreState } from "../../../../hooks/useExploreState";
|
|
3
3
|
import { ROW_DIRECTION } from "../../common/entities";
|
|
4
|
-
import {
|
|
5
|
-
import { CheckboxMenu } from "../CheckboxMenu/checkboxMenu";
|
|
4
|
+
import { isAnyRowSelected } from "../../common/utils";
|
|
6
5
|
import { DownloadEntityResults } from "../DownloadEntityResults/downloadEntityResults";
|
|
7
6
|
import { PaginationSummary } from "../PaginationSummary/paginationSummary";
|
|
8
7
|
import { ColumnGrouping } from "./components/ColumnGrouping/columnGrouping";
|
|
8
|
+
import { ColumnVisibility } from "./components/ColumnVisibility/columnVisibility";
|
|
9
9
|
import { RowPreview } from "./components/RowPreview/rowPreview";
|
|
10
10
|
import { RowSelection } from "./components/RowSelection/rowSelection";
|
|
11
11
|
import { Toolbar, ToolbarActions } from "./tableToolbar.styles";
|
|
@@ -13,24 +13,17 @@ export const TableToolbar = ({ listView, rowDirection, tableInstance, }) => {
|
|
|
13
13
|
const { exploreState } = useExploreState();
|
|
14
14
|
const { paginationState } = exploreState;
|
|
15
15
|
const { currentPage, pages, pageSize, rows } = paginationState;
|
|
16
|
-
const { getSelectedRowModel, options: { enableGrouping },
|
|
16
|
+
const { getSelectedRowModel, options: { enableGrouping, enableHiding }, } = tableInstance;
|
|
17
17
|
const { enableDownload, rowPreviewView } = listView || {};
|
|
18
18
|
const isLastPage = currentPage === pages;
|
|
19
|
-
const editColumnOptions = getEditColumnOptions(tableInstance);
|
|
20
19
|
const showToolbar = rowDirection === ROW_DIRECTION.DEFAULT &&
|
|
21
|
-
(
|
|
22
|
-
/**
|
|
23
|
-
* Resets column visibility to default state.
|
|
24
|
-
*/
|
|
25
|
-
const onResetColumnVisibility = () => {
|
|
26
|
-
resetColumnVisibility(false);
|
|
27
|
-
};
|
|
20
|
+
(enableHiding || enableDownload || enableGrouping);
|
|
28
21
|
return (React.createElement(Fragment, null,
|
|
29
22
|
showToolbar && (React.createElement(Toolbar, { variant: "table" },
|
|
30
23
|
isAnyRowSelected(tableInstance) ? (React.createElement(RowSelection, { rows: getSelectedRowModel().rows, rowSelectionView: listView?.rowSelectionView })) : (React.createElement(PaginationSummary, { firstResult: (currentPage - 1) * pageSize + 1, lastResult: isLastPage ? rows : pageSize * currentPage, totalResult: rows })),
|
|
31
24
|
React.createElement(ToolbarActions, null,
|
|
32
25
|
enableDownload && (React.createElement(DownloadEntityResults, { entityName: exploreState.tabValue, rows: tableInstance.getFilteredRowModel().rows })),
|
|
33
26
|
React.createElement(ColumnGrouping, { tableInstance: tableInstance }),
|
|
34
|
-
React.createElement(
|
|
27
|
+
React.createElement(ColumnVisibility, { tableInstance: tableInstance })))),
|
|
35
28
|
React.createElement(RowPreview, { rowPreviewView: rowPreviewView, tableInstance: tableInstance })));
|
|
36
29
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getRowModel, getRowPosition
|
|
1
|
+
import { getRowModel, getRowPosition } from "./utils";
|
|
2
2
|
export const ROW_POSITION = {
|
|
3
3
|
createCell: (cell, column, row, table) => {
|
|
4
4
|
row.getRowPosition = () => {
|
|
@@ -11,7 +11,9 @@ export const ROW_POSITION = {
|
|
|
11
11
|
return getRowModel(table, rowModel);
|
|
12
12
|
};
|
|
13
13
|
},
|
|
14
|
-
|
|
15
|
-
return
|
|
14
|
+
getDefaultOptions: () => {
|
|
15
|
+
return {
|
|
16
|
+
enableRowPosition: false,
|
|
17
|
+
};
|
|
16
18
|
},
|
|
17
19
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RowData, RowModel, Table } from "@tanstack/react-table";
|
|
2
2
|
/**
|
|
3
3
|
* Returns row model, with getter for row position.
|
|
4
4
|
* @param table - Table.
|
|
@@ -13,9 +13,3 @@ export declare function getRowModel<T extends RowData>(table: Table<T>, rowModel
|
|
|
13
13
|
* @returns row position.
|
|
14
14
|
*/
|
|
15
15
|
export declare function getRowPosition<T extends RowData>(rowId: string, table: Table<T>): number;
|
|
16
|
-
/**
|
|
17
|
-
* Returns the initial table state.
|
|
18
|
-
* @param initialState - Initial state.
|
|
19
|
-
* @returns initial state.
|
|
20
|
-
*/
|
|
21
|
-
export declare function initInitialState(initialState?: InitialTableState): Partial<TableState>;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { ACCESSOR_KEYS } from "../../../TableCreator/common/constants";
|
|
2
|
-
import { DEFAULT_PAGINATION } from "../constants";
|
|
3
1
|
/**
|
|
4
2
|
* Returns row model, with getter for row position.
|
|
5
3
|
* @param table - Table.
|
|
@@ -42,21 +40,3 @@ function calculateRowPosition(table, index) {
|
|
|
42
40
|
const { pagination: { pageIndex, pageSize }, } = getState();
|
|
43
41
|
return pageIndex * pageSize + (index + 1);
|
|
44
42
|
}
|
|
45
|
-
/**
|
|
46
|
-
* Returns the initial table state.
|
|
47
|
-
* @param initialState - Initial state.
|
|
48
|
-
* @returns initial state.
|
|
49
|
-
*/
|
|
50
|
-
export function initInitialState(initialState) {
|
|
51
|
-
return {
|
|
52
|
-
...initialState,
|
|
53
|
-
columnVisibility: {
|
|
54
|
-
[ACCESSOR_KEYS.ROW_POSITION]: false,
|
|
55
|
-
...initialState?.columnVisibility,
|
|
56
|
-
},
|
|
57
|
-
pagination: {
|
|
58
|
-
...DEFAULT_PAGINATION,
|
|
59
|
-
...initialState?.pagination,
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { RowData } from "@tanstack/react-table";
|
|
2
|
-
import { RowPositionRow } from "./RowPosition/types";
|
|
2
|
+
import { RowPositionOptions, RowPositionRow } from "./RowPosition/types";
|
|
3
3
|
import { RowPreviewInstance, RowPreviewOptions, RowPreviewRow, RowPreviewTableState } from "./RowPreview/entities";
|
|
4
4
|
export type CustomFeatureInitialTableState = Partial<RowPreviewTableState>;
|
|
5
5
|
export type CustomFeatureInstance<T extends RowData> = RowPreviewInstance<T>;
|
|
6
|
-
export type CustomFeatureOptions = RowPreviewOptions;
|
|
6
|
+
export type CustomFeatureOptions = RowPreviewOptions & RowPositionOptions;
|
|
7
7
|
export type CustomFeatureRow = RowPositionRow & RowPreviewRow;
|
|
8
8
|
export type CustomFeatureTableState = RowPreviewTableState;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { ColumnDef, CoreOptions,
|
|
1
|
+
import { ColumnDef, CoreOptions, RowData } from "@tanstack/react-table";
|
|
2
2
|
import { ListConfig, ListViewConfig } from "../../config/entities";
|
|
3
3
|
export interface TableProps<T extends RowData> {
|
|
4
4
|
columns: ColumnDef<T>[];
|
|
5
5
|
getRowId?: CoreOptions<T>["getRowId"];
|
|
6
|
-
initialState: InitialTableState;
|
|
7
6
|
items: T[];
|
|
8
7
|
listView?: ListViewConfig;
|
|
9
8
|
loading?: boolean;
|
|
@@ -16,11 +15,10 @@ export interface TableProps<T extends RowData> {
|
|
|
16
15
|
* @param tableProps - Set of props required for displaying the table.
|
|
17
16
|
* @param tableProps.columns - Set of columns to display.
|
|
18
17
|
* @param tableProps.getRowId - Function to customize the row ID.
|
|
19
|
-
* @param tableProps.initialState - Initial table state.
|
|
20
18
|
* @param tableProps.items - Row data to display.
|
|
21
19
|
* @param tableProps.listView - List view configuration.
|
|
22
20
|
* @param tableProps.tableOptions - TanStack table options.
|
|
23
21
|
* @returns Configured table element for display.
|
|
24
22
|
*/
|
|
25
|
-
export declare const TableComponent: <T extends RowData>({ columns, getRowId,
|
|
23
|
+
export declare const TableComponent: <T extends RowData>({ columns, getRowId, items, listView, tableOptions, }: TableProps<T>) => JSX.Element;
|
|
26
24
|
export declare const Table: typeof TableComponent;
|
|
@@ -12,8 +12,9 @@ import { DEFAULT_PAGINATION_STATE } from "../../providers/exploreState/initializ
|
|
|
12
12
|
import { TABLET } from "../../theme/common/breakpoints";
|
|
13
13
|
import { FluidPaper, GridPaper } from "../common/Paper/paper.styles";
|
|
14
14
|
import { NoResults } from "../NoResults/noResults";
|
|
15
|
+
import { getColumnTrackSizing } from "../TableCreator/options/columnTrackSizing/utils";
|
|
15
16
|
import { ROW_DIRECTION } from "./common/entities";
|
|
16
|
-
import { buildCategoryViews, getFacetedUniqueValuesWithArrayValues,
|
|
17
|
+
import { buildCategoryViews, getFacetedUniqueValuesWithArrayValues, getTableStatePagination, isClientFilteringEnabled, } from "./common/utils";
|
|
17
18
|
import { Pagination as DXPagination } from "./components/Pagination/pagination";
|
|
18
19
|
import { TableBody } from "./components/TableBody/tableBody";
|
|
19
20
|
import { TableHead } from "./components/TableHead/tableHead";
|
|
@@ -28,20 +29,19 @@ import { GridTable } from "./table.styles";
|
|
|
28
29
|
* @param tableProps - Set of props required for displaying the table.
|
|
29
30
|
* @param tableProps.columns - Set of columns to display.
|
|
30
31
|
* @param tableProps.getRowId - Function to customize the row ID.
|
|
31
|
-
* @param tableProps.initialState - Initial table state.
|
|
32
32
|
* @param tableProps.items - Row data to display.
|
|
33
33
|
* @param tableProps.listView - List view configuration.
|
|
34
34
|
* @param tableProps.tableOptions - TanStack table options.
|
|
35
35
|
* @returns Configured table element for display.
|
|
36
36
|
*/
|
|
37
|
-
export const TableComponent = ({ columns, getRowId,
|
|
37
|
+
export const TableComponent = ({ columns, getRowId, items, listView, tableOptions, }) => {
|
|
38
38
|
const tabletDown = useBreakpointHelper(BREAKPOINT_FN_NAME.DOWN, TABLET);
|
|
39
39
|
const exploreMode = useExploreMode();
|
|
40
40
|
const { exploreDispatch, exploreState } = useExploreState();
|
|
41
41
|
const { entityPageState, filterState, listItems, loading, paginationState, rowPreview, tabValue, } = exploreState;
|
|
42
|
-
const {
|
|
42
|
+
const { columnVisibility, grouping, rowSelection, sorting } = entityPageState[tabValue];
|
|
43
43
|
const { currentPage, pages, pageSize, rows: pageCount } = paginationState;
|
|
44
|
-
const { disablePagination = false
|
|
44
|
+
const { disablePagination = false } = listView || {};
|
|
45
45
|
const clientFiltering = isClientFilteringEnabled(exploreMode);
|
|
46
46
|
const rowDirection = tabletDown
|
|
47
47
|
? ROW_DIRECTION.VERTICAL
|
|
@@ -65,13 +65,6 @@ export const TableComponent = ({ columns, getRowId, initialState, items, listVie
|
|
|
65
65
|
: SORT_DIRECTION.ASC,
|
|
66
66
|
});
|
|
67
67
|
};
|
|
68
|
-
const onColumnVisibilityChange = (updater) => {
|
|
69
|
-
// TODO(cc) memoize `onColumnVisibilityChange` with `useCallback`.
|
|
70
|
-
exploreDispatch({
|
|
71
|
-
payload: typeof updater === "function" ? updater(columnsVisibility) : updater,
|
|
72
|
-
type: ExploreActionKind.UpdateColumnVisibility,
|
|
73
|
-
});
|
|
74
|
-
};
|
|
75
68
|
const onRowPreviewChange = useCallback((updater) => {
|
|
76
69
|
exploreDispatch({
|
|
77
70
|
payload: typeof updater === "function" ? updater(rowPreview) : updater,
|
|
@@ -86,7 +79,7 @@ export const TableComponent = ({ columns, getRowId, initialState, items, listVie
|
|
|
86
79
|
});
|
|
87
80
|
}, [exploreDispatch, rowSelection]);
|
|
88
81
|
const state = {
|
|
89
|
-
columnVisibility
|
|
82
|
+
columnVisibility,
|
|
90
83
|
grouping,
|
|
91
84
|
pagination,
|
|
92
85
|
rowPreview,
|
|
@@ -94,20 +87,11 @@ export const TableComponent = ({ columns, getRowId, initialState, items, listVie
|
|
|
94
87
|
sorting,
|
|
95
88
|
};
|
|
96
89
|
/**
|
|
97
|
-
* TODO: Refactor `ListConfig` to follow the API patterns of the TanStack Table library.
|
|
98
90
|
* TODO: Update `ColumnConfig` to follow the `ColumnDef` API of TanStack Table.
|
|
99
91
|
* - Standardize column definitions to leverage the full power of TanStack Table's feature set and improve compatibility.
|
|
100
|
-
* TODO:
|
|
101
|
-
* - `defaultSort` in `ListConfig`: Replace this with TanStack Table's `tableOptions.initialState.sorting` feature.
|
|
102
|
-
* - `columnVisible` in `ColumnConfig`: Replace this with TanStack Table's `tableOptions.initialState.columnVisibility` feature.
|
|
103
|
-
* TODO: Define `columnVisibility` and `sorting` directly within `ListConfig` via the `tableOptions.initialState` property.
|
|
92
|
+
* TODO: Define `sorting` directly within `ListConfig` via the `tableOptions.initialState` property.
|
|
104
93
|
* - This will simplify the configuration structure and centralize table state definitions, reducing redundancy and improving clarity.
|
|
105
|
-
* - It will also allow for direct configuration of other TanStack Table options such as `columnOrder` via `tableOptions.initialState.columnOrder`.
|
|
106
|
-
*
|
|
107
|
-
* Current Workaround:
|
|
108
|
-
* - The `initialState` property from `tableOptions` is destructured to separate it from other options. This allows the remaining properties in `tableOptions` to be passed directly to the TanStack Table configuration without breaking the current ListConfig `defaultSort` and `columnVisible` properties.
|
|
109
94
|
*/
|
|
110
|
-
const { initialState: _initialState, ...restTableOptions } = tableOptions ?? {};
|
|
111
95
|
const tableInstance = useReactTable({
|
|
112
96
|
_features: [ROW_POSITION, ROW_PREVIEW],
|
|
113
97
|
columns,
|
|
@@ -115,8 +99,6 @@ export const TableComponent = ({ columns, getRowId, initialState, items, listVie
|
|
|
115
99
|
enableColumnFilters: true, // client-side filtering.
|
|
116
100
|
enableFilters: true, // client-side filtering.
|
|
117
101
|
enableMultiSort: clientFiltering, // TODO(cc) move to sorting options; default to false and let the table options in config flag this value.
|
|
118
|
-
enableRowPreview,
|
|
119
|
-
enableRowSelection,
|
|
120
102
|
getCoreRowModel: getCoreRowModel(),
|
|
121
103
|
getFacetedRowModel: clientFiltering ? getFacetedRowModel() : undefined,
|
|
122
104
|
getFacetedUniqueValues: clientFiltering
|
|
@@ -126,16 +108,14 @@ export const TableComponent = ({ columns, getRowId, initialState, items, listVie
|
|
|
126
108
|
getPaginationRowModel: getPaginationRowModel(),
|
|
127
109
|
getRowId,
|
|
128
110
|
getSortedRowModel: clientFiltering ? getSortedRowModel() : undefined,
|
|
129
|
-
initialState: { ...initialState, ..._initialState }, // `sorting` and `columnVisibility` are managed by the ExploreState.
|
|
130
111
|
manualPagination: true,
|
|
131
112
|
manualSorting: !clientFiltering,
|
|
132
|
-
onColumnVisibilityChange,
|
|
133
113
|
onRowPreviewChange,
|
|
134
114
|
onRowSelectionChange,
|
|
135
115
|
onSortingChange,
|
|
136
116
|
pageCount,
|
|
137
117
|
state,
|
|
138
|
-
...
|
|
118
|
+
...tableOptions,
|
|
139
119
|
});
|
|
140
120
|
const { getAllColumns, getRowModel, getState, getVisibleFlatColumns, nextPage: tableNextPage, previousPage: tablePreviousPage, } = tableInstance;
|
|
141
121
|
const allColumns = getAllColumns();
|
|
@@ -143,8 +123,6 @@ export const TableComponent = ({ columns, getRowId, initialState, items, listVie
|
|
|
143
123
|
const { rows } = getRowModel();
|
|
144
124
|
const noResults = !loading && (!rows || rows.length === 0);
|
|
145
125
|
const scrollTop = useScroll();
|
|
146
|
-
const visibleColumns = getVisibleFlatColumns();
|
|
147
|
-
const gridTemplateColumns = getGridTemplateColumns(visibleColumns);
|
|
148
126
|
const handleTableNextPage = () => {
|
|
149
127
|
let nextPage = tableNextPage;
|
|
150
128
|
if (!clientFiltering) {
|
|
@@ -226,7 +204,7 @@ export const TableComponent = ({ columns, getRowId, initialState, items, listVie
|
|
|
226
204
|
React.createElement(GridPaper, null,
|
|
227
205
|
React.createElement(TableToolbar, { listView: listView, rowDirection: rowDirection, tableInstance: tableInstance }),
|
|
228
206
|
React.createElement(TableContainer, null,
|
|
229
|
-
React.createElement(GridTable, { collapsable: true, gridTemplateColumns:
|
|
207
|
+
React.createElement(GridTable, { collapsable: true, gridTemplateColumns: getColumnTrackSizing(getVisibleFlatColumns()) },
|
|
230
208
|
React.createElement(TableHead, { rowDirection: rowDirection, tableInstance: tableInstance }),
|
|
231
209
|
React.createElement(TableBody, { rows: rows, rowDirection: rowDirection, tableInstance: tableInstance }))),
|
|
232
210
|
!disablePagination && (React.createElement(DXPagination, { canNextPage: canNextPage(), canPreviousPage: canPreviousPage(), currentPage: currentPage, onNextPage: handleTableNextPage, onPreviousPage: handleTablePreviousPage, totalPage: pages ?? 0 })))));
|
|
@@ -9,13 +9,10 @@
|
|
|
9
9
|
export function buildBaseColumnDef(baseColumnConfig) {
|
|
10
10
|
const { columnPinned,
|
|
11
11
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- Destructure to avoid passing it to the columnDef.
|
|
12
|
-
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- Destructure to avoid passing it to the columnDef.
|
|
14
|
-
componentConfig, disableHiding, header, id, meta, width, ...columnDef } = baseColumnConfig;
|
|
12
|
+
componentConfig, header, id, meta, width, ...columnDef } = baseColumnConfig;
|
|
15
13
|
return {
|
|
16
14
|
...columnDef,
|
|
17
15
|
accessorKey: id,
|
|
18
|
-
enableHiding: !disableHiding,
|
|
19
16
|
header,
|
|
20
17
|
id,
|
|
21
18
|
meta: {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { GridTrackMinMax, GridTrackSize } from "../../../../config/entities";
|
|
2
|
+
/**
|
|
3
|
+
* Type guard to determine if the given track size represents a size range (min-max).
|
|
4
|
+
* @param width - Grid table track size.
|
|
5
|
+
* @returns `true` if the given grid track size is a `GridTrackMinMax`, otherwise `false`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isGridTrackMinMax(width?: GridTrackSize): width is GridTrackMinMax;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type guard to determine if the given track size represents a size range (min-max).
|
|
3
|
+
* @param width - Grid table track size.
|
|
4
|
+
* @returns `true` if the given grid track size is a `GridTrackMinMax`, otherwise `false`.
|
|
5
|
+
*/
|
|
6
|
+
export function isGridTrackMinMax(width) {
|
|
7
|
+
return width?.min !== undefined;
|
|
8
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Column, RowData } from "@tanstack/react-table";
|
|
2
|
+
/**
|
|
3
|
+
* Generates the grid track sizing for a table using a grid layout.
|
|
4
|
+
* Creates a string value for the `grid-template-columns` CSS property based on the visible columns.
|
|
5
|
+
* It ensures proper sizing for grouped, system, and non-system columns.
|
|
6
|
+
* - Grouped columns are excluded from grid sizing as they flex across the table.
|
|
7
|
+
* - System columns (e.g., "rowPosition" and "rowSelection") have pre-defined sizing.
|
|
8
|
+
* - Non-system columns collectively fill the table's width. If their total fractional sizing is less than `1fr`, the first non-system column is assigned `1fr` to ensure the table is filled.
|
|
9
|
+
* @param visibleColumns - Visible columns.
|
|
10
|
+
* @returns string defining the CSS `grid-template-columns` value for the table.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getColumnTrackSizing<T extends RowData>(visibleColumns: Column<T>[]): string;
|
|
13
|
+
/**
|
|
14
|
+
* Determines the CSS grid track size for a given column.
|
|
15
|
+
* Calculates the track size for a column based on its width configuration.
|
|
16
|
+
* If the column's width is defined as a min-max range, it returns a `minmax()` CSS function.
|
|
17
|
+
* Otherwise, it defaults to the column's width or `1fr` if no width is specified.
|
|
18
|
+
* @param column - Column.
|
|
19
|
+
* @returns A string representing the CSS track size for the column. This can be a `minmax()` function or a fixed/flexible value (e.g., `auto`, `1fr`, `200px`).
|
|
20
|
+
*/
|
|
21
|
+
export declare function getColumnTrackSize<T extends RowData>(column: Column<T>): string;
|
|
22
|
+
/**
|
|
23
|
+
* Extracts the fractional value (`fr`) from a CSS track size string.
|
|
24
|
+
* This function parses a CSS track size (e.g., `1fr`, `minmax(168px, 0.5fr)`)
|
|
25
|
+
* and extracts the numeric fractional value that appears before `fr`.
|
|
26
|
+
* If the input does not contain a valid fractional value, the function returns `0`.
|
|
27
|
+
* @param columnTrackSize - The CSS track size string e.g. `1fr`, `minmax(100px, 0.5fr)`, `200px`, or `auto`.
|
|
28
|
+
* @returns The fractional value as a number, or `0` if no fractional value is found.
|
|
29
|
+
*/
|
|
30
|
+
export declare function extractFractionalValue(columnTrackSize: string): number;
|