@wallarm-org/design-system 0.62.0 → 0.63.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/Breadcrumbs/BreadcrumbsItem.js +1 -0
- package/dist/components/BulkBar/BulkBarSummary.d.ts +4 -14
- package/dist/components/BulkBar/BulkBarSummary.js +15 -46
- package/dist/components/BulkBar/BulkBarSummaryClear.d.ts +7 -0
- package/dist/components/BulkBar/BulkBarSummaryClear.js +25 -0
- package/dist/components/BulkBar/BulkBarSummaryCount.d.ts +13 -0
- package/dist/components/BulkBar/BulkBarSummaryCount.js +18 -0
- package/dist/components/BulkBar/BulkBarSummarySelectAll.d.ts +7 -0
- package/dist/components/BulkBar/BulkBarSummarySelectAll.js +25 -0
- package/dist/components/BulkBar/BulkBarSummarySeparator.d.ts +8 -0
- package/dist/components/BulkBar/BulkBarSummarySeparator.js +12 -0
- package/dist/components/BulkBar/index.d.ts +5 -0
- package/dist/components/BulkBar/index.js +6 -0
- package/dist/components/Calendar/CalendarPresetItem.d.ts +9 -3
- package/dist/components/Calendar/CalendarPresetItem.js +8 -5
- package/dist/components/Calendar/CalendarTrigger.d.ts +12 -3
- package/dist/components/Calendar/CalendarTrigger.js +3 -3
- package/dist/components/Calendar/index.d.ts +1 -1
- package/dist/components/Card/Card.js +2 -0
- package/dist/components/CodeSnippet/CodeSnippetCode.js +9 -2
- package/dist/components/CodeSnippet/CodeSnippetCopyButton.js +1 -1
- package/dist/components/CodeSnippet/CodeSnippetFullscreenButton.js +0 -1
- package/dist/components/CodeSnippet/CodeSnippetRoot.d.ts +8 -1
- package/dist/components/CodeSnippet/CodeSnippetRoot.js +5 -3
- package/dist/components/CodeSnippet/CodeSnippetShowMoreButton.d.ts +12 -0
- package/dist/components/CodeSnippet/{internal/ShowMoreButton.js → CodeSnippetShowMoreButton.js} +15 -9
- package/dist/components/CodeSnippet/CodeSnippetTab.d.ts +3 -6
- package/dist/components/CodeSnippet/CodeSnippetTab.js +5 -7
- package/dist/components/CodeSnippet/CodeSnippetWrapButton.js +0 -1
- package/dist/components/CodeSnippet/InlineCodeSnippet.d.ts +4 -2
- package/dist/components/CodeSnippet/InlineCodeSnippet.js +14 -7
- package/dist/components/CodeSnippet/index.d.ts +2 -1
- package/dist/components/CodeSnippet/index.js +2 -1
- package/dist/components/CodeSnippet/internal/FoldToggle.js +9 -2
- package/dist/components/CodeSnippet/lib/foldUtils.d.ts +6 -0
- package/dist/components/DateRangeInput/DateRangeEndValue.d.ts +9 -2
- package/dist/components/DateRangeInput/DateRangeEndValue.js +3 -2
- package/dist/components/DateRangeInput/DateRangeSegmentGroup.d.ts +12 -1
- package/dist/components/DateRangeInput/DateRangeSegmentGroup.js +24 -6
- package/dist/components/DateRangeInput/DateRangeStartValue.d.ts +11 -4
- package/dist/components/DateRangeInput/DateRangeStartValue.js +3 -2
- package/dist/components/DateRangeInput/index.d.ts +2 -2
- package/dist/components/Drawer/Drawer.d.ts +5 -0
- package/dist/components/Drawer/Drawer.js +3 -1
- package/dist/components/Drawer/DrawerClose.d.ts +3 -2
- package/dist/components/Drawer/DrawerClose.js +6 -3
- package/dist/components/Drawer/DrawerHeader.d.ts +1 -1
- package/dist/components/Drawer/DrawerHeader.js +4 -1
- package/dist/components/Drawer/DrawerResizeHandle.d.ts +7 -2
- package/dist/components/Drawer/DrawerResizeHandle.js +31 -6
- package/dist/components/Drawer/DrawerRoot.d.ts +3 -0
- package/dist/components/Drawer/DrawerRoot.js +3 -1
- package/dist/components/Drawer/DrawerTrigger.d.ts +3 -2
- package/dist/components/Drawer/DrawerTrigger.js +3 -2
- package/dist/components/Drawer/index.d.ts +1 -0
- package/dist/components/DropdownMenu/DropdownMenuCheckboxItem.d.ts +2 -1
- package/dist/components/DropdownMenu/DropdownMenuCheckboxItem.js +2 -2
- package/dist/components/DropdownMenu/DropdownMenuContextTrigger.d.ts +3 -5
- package/dist/components/DropdownMenu/DropdownMenuContextTrigger.js +2 -2
- package/dist/components/DropdownMenu/DropdownMenuItem.d.ts +2 -1
- package/dist/components/DropdownMenu/DropdownMenuItem.js +2 -2
- package/dist/components/DropdownMenu/DropdownMenuRadioGroup.d.ts +2 -1
- package/dist/components/DropdownMenu/DropdownMenuRadioGroup.js +4 -4
- package/dist/components/DropdownMenu/DropdownMenuRadioItem.d.ts +2 -1
- package/dist/components/DropdownMenu/DropdownMenuRadioItem.js +2 -2
- package/dist/components/DropdownMenu/DropdownMenuTrigger.d.ts +3 -5
- package/dist/components/DropdownMenu/DropdownMenuTrigger.js +2 -2
- package/dist/components/DropdownMenu/DropdownMenuTriggerItem.d.ts +4 -4
- package/dist/components/DropdownMenu/DropdownMenuTriggerItem.js +4 -3
- package/dist/components/DropdownMenu/index.d.ts +4 -4
- package/dist/components/NavRail/NavRailItem.d.ts +2 -1
- package/dist/components/NavRail/NavRailItem.js +6 -4
- package/dist/components/Popover/PopoverContent.d.ts +3 -3
- package/dist/components/Popover/PopoverContent.js +4 -8
- package/dist/components/Popover/PopoverTrigger.d.ts +3 -5
- package/dist/components/Popover/PopoverTrigger.js +3 -7
- package/dist/components/Popover/index.d.ts +2 -2
- package/dist/components/SegmentedControl/SegmentedControlItem.d.ts +6 -4
- package/dist/components/SegmentedControl/SegmentedControlItem.js +5 -2
- package/dist/components/SegmentedTabs/SegmentedTabsTrigger.d.ts +5 -3
- package/dist/components/SegmentedTabs/SegmentedTabsTrigger.js +5 -3
- package/dist/components/SegmentedTabs/SegmentedTabsTriggerButton.js +2 -2
- package/dist/components/Select/SelectButton.js +2 -2
- package/dist/components/Select/SelectClearTrigger.d.ts +2 -1
- package/dist/components/Select/SelectClearTrigger.js +2 -2
- package/dist/components/Select/SelectInput/SelectInput.d.ts +4 -1
- package/dist/components/Select/SelectInput/SelectInput.js +3 -2
- package/dist/components/Select/SelectOption.d.ts +2 -1
- package/dist/components/Select/SelectOption.js +2 -2
- package/dist/components/Select/SelectSearchInput.d.ts +3 -2
- package/dist/components/Select/SelectSearchInput.js +3 -2
- package/dist/components/Select/index.d.ts +1 -1
- package/dist/components/Selection/SelectionBulkBar/SelectionBulkBar.d.ts +1 -1
- package/dist/components/Selection/SelectionBulkBar/SelectionBulkBar.js +44 -5
- package/dist/components/Selection/index.d.ts +2 -0
- package/dist/components/Selection/index.js +2 -1
- package/dist/components/Table/Table.js +7 -0
- package/dist/components/Table/TableActionBar/TableActionBar.d.ts +7 -1
- package/dist/components/Table/TableActionBar/TableActionBar.js +6 -2
- package/dist/components/Table/TableActionBar/TableActionBarSelection.d.ts +16 -2
- package/dist/components/Table/TableActionBar/TableActionBarSelection.js +52 -10
- package/dist/components/Table/TableActionBar/index.d.ts +1 -0
- package/dist/components/Table/TableActionBar/index.js +2 -1
- package/dist/components/Table/TableColumnMenu/TableColumnMenu.d.ts +37 -0
- package/dist/components/Table/TableColumnMenu/TableColumnMenu.js +139 -0
- package/dist/components/Table/TableColumnMenu/TableColumnMenuHideItem.d.ts +8 -0
- package/dist/components/Table/TableColumnMenu/TableColumnMenuHideItem.js +27 -0
- package/dist/components/Table/TableColumnMenu/TableColumnMenuMoveLeftItem.d.ts +8 -0
- package/dist/components/Table/TableColumnMenu/TableColumnMenuMoveLeftItem.js +38 -0
- package/dist/components/Table/TableColumnMenu/TableColumnMenuMoveRightItem.d.ts +8 -0
- package/dist/components/Table/TableColumnMenu/TableColumnMenuMoveRightItem.js +39 -0
- package/dist/components/Table/TableColumnMenu/TableColumnMenuPinItem.d.ts +10 -0
- package/dist/components/Table/TableColumnMenu/TableColumnMenuPinItem.js +31 -0
- package/dist/components/Table/TableColumnMenu/TableColumnMenuSortItem.d.ts +17 -0
- package/dist/components/Table/TableColumnMenu/TableColumnMenuSortItem.js +33 -0
- package/dist/components/Table/TableColumnMenu/index.d.ts +6 -0
- package/dist/components/Table/TableColumnMenu/index.js +7 -0
- package/dist/components/Table/TableHeadCell.js +17 -18
- package/dist/components/Table/TableInner/TableInner.d.ts +2 -0
- package/dist/components/Table/TableInner/TableInner.js +21 -12
- package/dist/components/Table/TableInner/TableInnerContainer.d.ts +1 -0
- package/dist/components/Table/TableInner/TableInnerContainer.js +5 -3
- package/dist/components/Table/TableInner/TableInnerWindow.d.ts +1 -0
- package/dist/components/Table/TableInner/TableInnerWindow.js +5 -3
- package/dist/components/Table/TableScrollHandler.d.ts +27 -4
- package/dist/components/Table/TableScrollHandler.js +99 -68
- package/dist/components/Table/TableScrollHandlerContext.d.ts +19 -0
- package/dist/components/Table/TableScrollHandlerContext.js +24 -0
- package/dist/components/Table/TableScrollHandlerSlot.d.ts +8 -0
- package/dist/components/Table/TableScrollHandlerSlot.js +18 -0
- package/dist/components/Table/TableSettingsMenu/TableSettingsMenu.d.ts +18 -2
- package/dist/components/Table/TableSettingsMenu/TableSettingsMenu.js +105 -95
- package/dist/components/Table/TableSettingsMenu/TableSettingsMenuContentContext.d.ts +7 -0
- package/dist/components/Table/TableSettingsMenu/TableSettingsMenuContentContext.js +9 -0
- package/dist/components/Table/TableSettingsMenu/TableSettingsMenuContext.d.ts +15 -0
- package/dist/components/Table/TableSettingsMenu/TableSettingsMenuContext.js +21 -0
- package/dist/components/Table/TableSettingsMenu/TableSettingsMenuItem.d.ts +8 -6
- package/dist/components/Table/TableSettingsMenu/TableSettingsMenuItem.js +17 -11
- package/dist/components/Table/TableSettingsMenu/TableSettingsMenuReset.d.ts +5 -0
- package/dist/components/Table/TableSettingsMenu/TableSettingsMenuReset.js +34 -0
- package/dist/components/Table/TableSettingsMenu/TableSettingsMenuSearch.d.ts +5 -0
- package/dist/components/Table/TableSettingsMenu/TableSettingsMenuSearch.js +17 -0
- package/dist/components/Table/TableSettingsMenu/TableSettingsMenuSlot.d.ts +11 -0
- package/dist/components/Table/TableSettingsMenu/TableSettingsMenuSlot.js +16 -0
- package/dist/components/Table/TableSettingsMenu/index.d.ts +6 -1
- package/dist/components/Table/TableSettingsMenu/index.js +6 -1
- package/dist/components/Table/TableSortTrigger.d.ts +39 -0
- package/dist/components/Table/TableSortTrigger.js +86 -0
- package/dist/components/Table/index.d.ts +6 -2
- package/dist/components/Table/index.js +7 -3
- package/dist/components/Table/lib/collectDirectChildren.d.ts +8 -0
- package/dist/components/Table/lib/collectDirectChildren.js +13 -0
- package/dist/components/Table/lib/containsDirectChild.d.ts +12 -0
- package/dist/components/Table/lib/containsDirectChild.js +12 -0
- package/dist/components/Table/lib/index.d.ts +2 -0
- package/dist/components/Table/lib/index.js +3 -1
- package/dist/components/Tabs/TabsTrigger.d.ts +5 -4
- package/dist/components/Tabs/TabsTrigger.js +3 -2
- package/dist/components/Tag/Tag.js +2 -1
- package/dist/components/Tag/TagClose.d.ts +5 -3
- package/dist/components/Tag/TagClose.js +13 -9
- package/dist/components/Tag/index.d.ts +1 -1
- package/dist/components/Tooltip/Tooltip.js +4 -2
- package/dist/components/Tooltip/TooltipContent.d.ts +4 -4
- package/dist/components/Tooltip/TooltipContent.js +3 -3
- package/dist/components/Tooltip/TooltipTrigger.d.ts +4 -4
- package/dist/components/Tooltip/TooltipTrigger.js +2 -2
- package/dist/components/Tooltip/index.d.ts +2 -2
- package/dist/components/Tour/Tour.d.ts +7 -1
- package/dist/components/Tour/Tour.js +8 -2
- package/dist/components/Tour/TourClose.d.ts +6 -2
- package/dist/components/Tour/TourClose.js +6 -6
- package/dist/components/Tour/TourFooter.js +8 -3
- package/dist/components/Tour/TourInner.d.ts +7 -1
- package/dist/components/Tour/TourInner.js +2 -2
- package/dist/components/Tour/index.d.ts +1 -0
- package/dist/components/Tour/index.js +2 -1
- package/dist/components/Tour/types.d.ts +12 -1
- package/dist/hooks/useCopyTooltip.d.ts +1 -3
- package/dist/hooks/useCopyTooltip.js +1 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/metadata/components.json +30183 -16896
- package/dist/utils/testId.d.ts +4 -1
- package/dist/utils/testId.js +2 -1
- package/package.json +1 -1
- package/dist/components/CodeSnippet/internal/ShowMoreButton.d.ts +0 -2
- package/dist/components/Selection/SelectionBulkBar/SelectionBulkBarSummary.d.ts +0 -2
- package/dist/components/Selection/SelectionBulkBar/SelectionBulkBarSummary.js +0 -18
- package/dist/components/Table/TableHeadCellMenu.d.ts +0 -9
- package/dist/components/Table/TableHeadCellMenu.js +0 -174
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { Selection, type SelectionProps } from './Selection';
|
|
2
2
|
export { SelectionAll, type SelectionAllProps } from './SelectionAll';
|
|
3
3
|
export { SelectionBulkBar, type SelectionBulkBarPlacement, type SelectionBulkBarProps, } from './SelectionBulkBar';
|
|
4
|
+
export type { SelectionContextValue } from './SelectionContext';
|
|
4
5
|
export { SelectionItem, type SelectionItemProps } from './SelectionItem';
|
|
6
|
+
export { useSelectionContext } from './useSelectionContext';
|
|
@@ -2,4 +2,5 @@ import { Selection } from "./Selection.js";
|
|
|
2
2
|
import { SelectionAll } from "./SelectionAll.js";
|
|
3
3
|
import { SelectionBulkBar } from "./SelectionBulkBar/index.js";
|
|
4
4
|
import { SelectionItem } from "./SelectionItem.js";
|
|
5
|
-
|
|
5
|
+
import { useSelectionContext } from "./useSelectionContext.js";
|
|
6
|
+
export { Selection, SelectionAll, SelectionBulkBar, SelectionItem, useSelectionContext };
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { TestIdProvider } from "../../utils/testId.js";
|
|
3
|
+
import { containsDirectChild } from "./lib/index.js";
|
|
3
4
|
import { TableProvider } from "./TableContext/index.js";
|
|
4
5
|
import { TableImperativeBridge } from "./TableImperativeBridge.js";
|
|
5
6
|
import { TableInner } from "./TableInner/index.js";
|
|
7
|
+
import { TableScrollHandler } from "./TableScrollHandler.js";
|
|
8
|
+
import { TableSettingsMenu } from "./TableSettingsMenu/index.js";
|
|
6
9
|
const Table = (props)=>{
|
|
7
10
|
const { data, isLoading = false, children, className, 'aria-label': ariaLabel, 'data-testid': testId, ref, ...providerProps } = props;
|
|
8
11
|
const isEmpty = 0 === data.length && !isLoading;
|
|
9
12
|
const showSettings = !!props.onColumnVisibilityChange || !!props.onColumnOrderChange;
|
|
13
|
+
const hasConsumerSettingsMenu = containsDirectChild(children, TableSettingsMenu);
|
|
14
|
+
const hasConsumerScrollHandler = containsDirectChild(children, TableScrollHandler);
|
|
10
15
|
return /*#__PURE__*/ jsxs(TableProvider, {
|
|
11
16
|
data: data,
|
|
12
17
|
isLoading: isLoading,
|
|
@@ -21,6 +26,8 @@ const Table = (props)=>{
|
|
|
21
26
|
isEmpty: isEmpty,
|
|
22
27
|
virtualized: props.virtualized,
|
|
23
28
|
showSettings: showSettings,
|
|
29
|
+
hasConsumerSettingsMenu: hasConsumerSettingsMenu,
|
|
30
|
+
hasConsumerScrollHandler: hasConsumerScrollHandler,
|
|
24
31
|
ariaLabel: ariaLabel,
|
|
25
32
|
className: className,
|
|
26
33
|
"data-testid": testId,
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type FC, type ReactNode } from 'react';
|
|
2
2
|
export interface TableActionBarProps {
|
|
3
|
+
/**
|
|
4
|
+
* Action controls rendered on the right (consumer-owned `<Button>`s, etc.).
|
|
5
|
+
* A single direct `<TableActionBarSelection>` child is recognized and used to
|
|
6
|
+
* override the default selection summary on the left; everything else is
|
|
7
|
+
* treated as an action control.
|
|
8
|
+
*/
|
|
3
9
|
children?: ReactNode;
|
|
4
10
|
}
|
|
5
11
|
export declare const TableActionBar: FC<TableActionBarProps>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Children, isValidElement } from "react";
|
|
2
3
|
import { Popover } from "@ark-ui/react/popover";
|
|
3
4
|
import { Portal } from "@ark-ui/react/portal";
|
|
4
5
|
import { useTestId } from "../../../utils/testId.js";
|
|
@@ -7,6 +8,9 @@ import { HStack } from "../../Stack/index.js";
|
|
|
7
8
|
import { TableActionBarSelection } from "./TableActionBarSelection.js";
|
|
8
9
|
const TableActionBar = ({ children })=>{
|
|
9
10
|
const testId = useTestId('action-bar');
|
|
11
|
+
const items = Children.toArray(children);
|
|
12
|
+
const selectionOverride = items.find((child)=>/*#__PURE__*/ isValidElement(child) && child.type === TableActionBarSelection);
|
|
13
|
+
const actions = items.filter((child)=>child !== selectionOverride);
|
|
10
14
|
return /*#__PURE__*/ jsx(Portal, {
|
|
11
15
|
children: /*#__PURE__*/ jsx(Popover.Positioner, {
|
|
12
16
|
style: {
|
|
@@ -19,11 +23,11 @@ const TableActionBar = ({ children })=>{
|
|
|
19
23
|
gap: 40,
|
|
20
24
|
align: "center",
|
|
21
25
|
children: [
|
|
22
|
-
/*#__PURE__*/ jsx(TableActionBarSelection, {}),
|
|
26
|
+
selectionOverride ?? /*#__PURE__*/ jsx(TableActionBarSelection, {}),
|
|
23
27
|
/*#__PURE__*/ jsx(HStack, {
|
|
24
28
|
gap: 8,
|
|
25
29
|
align: "center",
|
|
26
|
-
children:
|
|
30
|
+
children: actions
|
|
27
31
|
})
|
|
28
32
|
]
|
|
29
33
|
})
|
|
@@ -1,2 +1,16 @@
|
|
|
1
|
-
import type
|
|
2
|
-
export
|
|
1
|
+
import { type FC, type ReactNode } from 'react';
|
|
2
|
+
export interface TableActionBarSelectionProps {
|
|
3
|
+
/**
|
|
4
|
+
* Optional override of the selection summary. Compose it from the exported
|
|
5
|
+
* `BulkBarSummary*` primitives; the DS injects table state and actions
|
|
6
|
+
* (`onClick`, `disabled`, `count`) into the recognized parts while preserving
|
|
7
|
+
* every attribute you set (`data-analytics-id`, `data-analytics-props`,
|
|
8
|
+
* `aria-*`, `ref`, any `data-*`). Omit `children` to render the DS default
|
|
9
|
+
* block.
|
|
10
|
+
*
|
|
11
|
+
* Injection targets the **direct** `BulkBarSummary*` children (Fragments are
|
|
12
|
+
* not unwrapped); wrapping a part in your own element opts it out of wiring.
|
|
13
|
+
*/
|
|
14
|
+
children?: ReactNode;
|
|
15
|
+
}
|
|
16
|
+
export declare const TableActionBarSelection: FC<TableActionBarSelectionProps>;
|
|
@@ -1,16 +1,58 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { BulkBarSummary } from "../../BulkBar/
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Children, cloneElement, isValidElement } from "react";
|
|
3
|
+
import { BulkBarSummary, BulkBarSummaryClear, BulkBarSummaryCount, BulkBarSummarySelectAll, BulkBarSummarySeparator } from "../../BulkBar/index.js";
|
|
4
4
|
import { useTableContext } from "../TableContext/index.js";
|
|
5
|
-
const
|
|
5
|
+
const composeClick = (consumer, internal)=>(event)=>{
|
|
6
|
+
consumer?.(event);
|
|
7
|
+
if (event.defaultPrevented) return;
|
|
8
|
+
internal();
|
|
9
|
+
};
|
|
10
|
+
const TableActionBarSelection = ({ children })=>{
|
|
6
11
|
const { table } = useTableContext();
|
|
7
|
-
const
|
|
12
|
+
const count = Object.keys(table.getState().rowSelection).length;
|
|
13
|
+
const isAllSelected = table.getIsAllRowsSelected();
|
|
14
|
+
const selectAll = ()=>table.toggleAllRowsSelected(true);
|
|
15
|
+
const clear = ()=>table.resetRowSelection();
|
|
16
|
+
if (void 0 === children) return /*#__PURE__*/ jsxs(BulkBarSummary, {
|
|
17
|
+
children: [
|
|
18
|
+
/*#__PURE__*/ jsx(BulkBarSummaryCount, {
|
|
19
|
+
count: count
|
|
20
|
+
}),
|
|
21
|
+
/*#__PURE__*/ jsx(BulkBarSummarySelectAll, {
|
|
22
|
+
onClick: selectAll,
|
|
23
|
+
disabled: isAllSelected
|
|
24
|
+
}),
|
|
25
|
+
/*#__PURE__*/ jsx(BulkBarSummarySeparator, {}),
|
|
26
|
+
/*#__PURE__*/ jsx(BulkBarSummaryClear, {
|
|
27
|
+
onClick: clear
|
|
28
|
+
})
|
|
29
|
+
]
|
|
30
|
+
});
|
|
31
|
+
const wired = Children.map(children, (child)=>{
|
|
32
|
+
if (!/*#__PURE__*/ isValidElement(child)) return child;
|
|
33
|
+
if (child.type === BulkBarSummarySelectAll) {
|
|
34
|
+
const el = child;
|
|
35
|
+
return /*#__PURE__*/ cloneElement(el, {
|
|
36
|
+
disabled: el.props.disabled ?? isAllSelected,
|
|
37
|
+
onClick: composeClick(el.props.onClick, selectAll)
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
if (child.type === BulkBarSummaryClear) {
|
|
41
|
+
const el = child;
|
|
42
|
+
return /*#__PURE__*/ cloneElement(el, {
|
|
43
|
+
onClick: composeClick(el.props.onClick, clear)
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
if (child.type === BulkBarSummaryCount) {
|
|
47
|
+
const el = child;
|
|
48
|
+
return /*#__PURE__*/ cloneElement(el, {
|
|
49
|
+
count: el.props.count ?? count
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return child;
|
|
53
|
+
});
|
|
8
54
|
return /*#__PURE__*/ jsx(BulkBarSummary, {
|
|
9
|
-
|
|
10
|
-
count: Object.keys(table.getState().rowSelection).length,
|
|
11
|
-
isAllSelected: table.getIsAllRowsSelected(),
|
|
12
|
-
onSelectAll: ()=>table.toggleAllRowsSelected(true),
|
|
13
|
-
onClear: ()=>table.resetRowSelection()
|
|
55
|
+
children: wired
|
|
14
56
|
});
|
|
15
57
|
};
|
|
16
58
|
TableActionBarSelection.displayName = 'TableActionBarSelection';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { TableActionBar } from './TableActionBar';
|
|
2
2
|
export { TableActionBarAnchor } from './TableActionBarAnchor';
|
|
3
3
|
export { TableActionBarProvider } from './TableActionBarProvider';
|
|
4
|
+
export { TableActionBarSelection, type TableActionBarSelectionProps, } from './TableActionBarSelection';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TableActionBar } from "./TableActionBar.js";
|
|
2
2
|
import { TableActionBarAnchor } from "./TableActionBarAnchor.js";
|
|
3
3
|
import { TableActionBarProvider } from "./TableActionBarProvider.js";
|
|
4
|
-
|
|
4
|
+
import { TableActionBarSelection } from "./TableActionBarSelection.js";
|
|
5
|
+
export { TableActionBar, TableActionBarAnchor, TableActionBarProvider, TableActionBarSelection };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type ButtonHTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
import type { Column } from '@tanstack/react-table';
|
|
3
|
+
import { type TestableProps } from '../../../utils/testId';
|
|
4
|
+
interface TableColumnMenuContextValue {
|
|
5
|
+
column: Column<unknown>;
|
|
6
|
+
}
|
|
7
|
+
export declare const useTableColumnMenuContext: () => TableColumnMenuContextValue;
|
|
8
|
+
export interface TableColumnMenuProps<T = unknown> extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'color' | 'type' | 'children'>, TestableProps {
|
|
9
|
+
/** Column from the header render context. */
|
|
10
|
+
column: Column<T>;
|
|
11
|
+
/**
|
|
12
|
+
* When omitted, the menu renders the default set of items (Move left / Move
|
|
13
|
+
* right / Sort submenu / Pin / Hide) the same way the design system has
|
|
14
|
+
* always rendered them. When provided, the consumer takes full control of
|
|
15
|
+
* the menu's contents — typically a mix of the exported item sub-components
|
|
16
|
+
* (`TableColumnMenuSortItem`, `TableColumnMenuPinItem`, etc.) for per-item
|
|
17
|
+
* analytics, or arbitrary `DropdownMenuItem`s for custom actions.
|
|
18
|
+
*/
|
|
19
|
+
children?: ReactNode;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Per-column header menu ("…" trigger) with an optional consumer-controlled
|
|
23
|
+
* item set. The trigger `<button>` accepts the full
|
|
24
|
+
* `ButtonHTMLAttributes<HTMLButtonElement>` surface (minus `color` / `type` /
|
|
25
|
+
* `children`) plus `TestableProps`, so `data-analytics-id`,
|
|
26
|
+
* `data-analytics-props`, `aria-*`, `id`, `ref`, and any `data-*` reach the
|
|
27
|
+
* underlying DOM node directly.
|
|
28
|
+
*
|
|
29
|
+
* The menu collapses to `null` when no action is available for the column
|
|
30
|
+
* (sorting disabled, pinning disabled, hiding disabled, and DnD disabled) —
|
|
31
|
+
* matching the behavior of the legacy `TableHeadCellMenu` it replaces.
|
|
32
|
+
*/
|
|
33
|
+
export declare const TableColumnMenu: {
|
|
34
|
+
<T>({ column, children, className, "data-testid": testIdProp, ...rest }: TableColumnMenuProps<T>): import("react/jsx-runtime").JSX.Element | null;
|
|
35
|
+
displayName: string;
|
|
36
|
+
};
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useState } from "react";
|
|
3
|
+
import { Check, ChevronsDown, Ellipsis } from "../../../icons/index.js";
|
|
4
|
+
import { cn } from "../../../utils/cn.js";
|
|
5
|
+
import { useTestId } from "../../../utils/testId.js";
|
|
6
|
+
import { Button } from "../../Button/index.js";
|
|
7
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, DropdownMenuTriggerItem } from "../../DropdownMenu/index.js";
|
|
8
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "../../Tooltip/index.js";
|
|
9
|
+
import { SORT_LABELS } from "../lib/index.js";
|
|
10
|
+
import { useTableContext } from "../TableContext/index.js";
|
|
11
|
+
import { TableColumnMenuHideItem } from "./TableColumnMenuHideItem.js";
|
|
12
|
+
import { TableColumnMenuMoveLeftItem } from "./TableColumnMenuMoveLeftItem.js";
|
|
13
|
+
import { TableColumnMenuMoveRightItem } from "./TableColumnMenuMoveRightItem.js";
|
|
14
|
+
import { TableColumnMenuPinItem } from "./TableColumnMenuPinItem.js";
|
|
15
|
+
const TableColumnMenuContext = /*#__PURE__*/ createContext(null);
|
|
16
|
+
const useTableColumnMenuContext = ()=>{
|
|
17
|
+
const ctx = useContext(TableColumnMenuContext);
|
|
18
|
+
if (!ctx) throw new Error('TableColumnMenu item components must be rendered inside <TableColumnMenu>');
|
|
19
|
+
return ctx;
|
|
20
|
+
};
|
|
21
|
+
const TableColumnMenu = ({ column, children, className, 'data-testid': testIdProp, ...rest })=>{
|
|
22
|
+
const ctx = useTableContext();
|
|
23
|
+
const testId = useTestId('column-menu', testIdProp);
|
|
24
|
+
const [menuOpen, setMenuOpen] = useState(false);
|
|
25
|
+
const isAlwaysPinned = ctx.alwaysPinnedLeft.includes(column.id);
|
|
26
|
+
const canSort = ctx.sortingEnabled && column.getCanSort();
|
|
27
|
+
const canPin = ctx.pinningEnabled && column.getCanPin() && !isAlwaysPinned;
|
|
28
|
+
const canHide = ctx.visibilityEnabled && column.getCanHide();
|
|
29
|
+
const canReorder = ctx.columnDndEnabled && !isAlwaysPinned;
|
|
30
|
+
if (!canSort && !canPin && !canHide && !canReorder) return null;
|
|
31
|
+
return /*#__PURE__*/ jsx(TableColumnMenuContext.Provider, {
|
|
32
|
+
value: {
|
|
33
|
+
column: column
|
|
34
|
+
},
|
|
35
|
+
children: /*#__PURE__*/ jsx("span", {
|
|
36
|
+
className: "shrink-0 inline-flex opacity-0 group-hover:opacity-100 has-[>_[data-state=open]]:opacity-100 transition-opacity",
|
|
37
|
+
children: /*#__PURE__*/ jsxs(Tooltip, {
|
|
38
|
+
disabled: menuOpen,
|
|
39
|
+
children: [
|
|
40
|
+
/*#__PURE__*/ jsxs(DropdownMenu, {
|
|
41
|
+
onOpenChange: setMenuOpen,
|
|
42
|
+
children: [
|
|
43
|
+
/*#__PURE__*/ jsx(DropdownMenuTrigger, {
|
|
44
|
+
asChild: true,
|
|
45
|
+
children: /*#__PURE__*/ jsx(TooltipTrigger, {
|
|
46
|
+
asChild: true,
|
|
47
|
+
children: /*#__PURE__*/ jsx(Button, {
|
|
48
|
+
...rest,
|
|
49
|
+
type: "button",
|
|
50
|
+
"data-testid": testId,
|
|
51
|
+
variant: "ghost",
|
|
52
|
+
color: "neutral",
|
|
53
|
+
size: "small",
|
|
54
|
+
"aria-label": rest['aria-label'] ?? 'More',
|
|
55
|
+
className: cn(className),
|
|
56
|
+
children: /*#__PURE__*/ jsx(Ellipsis, {})
|
|
57
|
+
})
|
|
58
|
+
})
|
|
59
|
+
}),
|
|
60
|
+
/*#__PURE__*/ jsx(DropdownMenuContent, {
|
|
61
|
+
children: children ?? /*#__PURE__*/ jsx(DefaultTableColumnMenuItems, {})
|
|
62
|
+
})
|
|
63
|
+
]
|
|
64
|
+
}),
|
|
65
|
+
/*#__PURE__*/ jsx(TooltipContent, {
|
|
66
|
+
children: "More"
|
|
67
|
+
})
|
|
68
|
+
]
|
|
69
|
+
})
|
|
70
|
+
})
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
TableColumnMenu.displayName = 'TableColumnMenu';
|
|
74
|
+
const DefaultTableColumnMenuItems = ()=>{
|
|
75
|
+
const { column } = useTableColumnMenuContext();
|
|
76
|
+
const ctx = useTableContext();
|
|
77
|
+
const isPinned = column.getIsPinned();
|
|
78
|
+
const isAlwaysPinned = ctx.alwaysPinnedLeft.includes(column.id);
|
|
79
|
+
const canReorder = ctx.columnDndEnabled && !isAlwaysPinned;
|
|
80
|
+
const canSort = ctx.sortingEnabled && column.getCanSort();
|
|
81
|
+
const canPin = ctx.pinningEnabled && column.getCanPin() && !isAlwaysPinned;
|
|
82
|
+
const canHide = ctx.visibilityEnabled && column.getCanHide();
|
|
83
|
+
const visibleColumns = ctx.table.getVisibleLeafColumns();
|
|
84
|
+
const columnIdx = visibleColumns.findIndex((c)=>c.id === column.id);
|
|
85
|
+
const isFirst = 0 === columnIdx;
|
|
86
|
+
const isLast = columnIdx === visibleColumns.length - 1;
|
|
87
|
+
const canMoveLeft = canReorder && !isFirst && !isPinned;
|
|
88
|
+
const canMoveRight = canReorder && !isLast && !isPinned;
|
|
89
|
+
const hasMovement = canMoveLeft || canMoveRight;
|
|
90
|
+
const sortType = column.columnDef.meta?.sortType;
|
|
91
|
+
const [ascLabel, descLabel] = sortType && SORT_LABELS[sortType] || SORT_LABELS.text;
|
|
92
|
+
const sortDirection = column.getIsSorted();
|
|
93
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
94
|
+
children: [
|
|
95
|
+
/*#__PURE__*/ jsx(TableColumnMenuMoveLeftItem, {}),
|
|
96
|
+
/*#__PURE__*/ jsx(TableColumnMenuMoveRightItem, {}),
|
|
97
|
+
hasMovement && (canSort || canPin || canHide) && /*#__PURE__*/ jsx(DropdownMenuSeparator, {}),
|
|
98
|
+
canSort && /*#__PURE__*/ jsxs(DropdownMenu, {
|
|
99
|
+
children: [
|
|
100
|
+
/*#__PURE__*/ jsxs(DropdownMenuTriggerItem, {
|
|
101
|
+
children: [
|
|
102
|
+
/*#__PURE__*/ jsx(ChevronsDown, {
|
|
103
|
+
size: "sm"
|
|
104
|
+
}),
|
|
105
|
+
"Sort"
|
|
106
|
+
]
|
|
107
|
+
}),
|
|
108
|
+
/*#__PURE__*/ jsxs(DropdownMenuContent, {
|
|
109
|
+
children: [
|
|
110
|
+
/*#__PURE__*/ jsxs(DropdownMenuItem, {
|
|
111
|
+
onSelect: ()=>column.toggleSorting(false),
|
|
112
|
+
children: [
|
|
113
|
+
ascLabel,
|
|
114
|
+
'asc' === sortDirection && /*#__PURE__*/ jsx(Check, {
|
|
115
|
+
size: "sm",
|
|
116
|
+
className: "ml-auto text-icon-primary"
|
|
117
|
+
})
|
|
118
|
+
]
|
|
119
|
+
}),
|
|
120
|
+
/*#__PURE__*/ jsxs(DropdownMenuItem, {
|
|
121
|
+
onSelect: ()=>column.toggleSorting(true),
|
|
122
|
+
children: [
|
|
123
|
+
descLabel,
|
|
124
|
+
'desc' === sortDirection && /*#__PURE__*/ jsx(Check, {
|
|
125
|
+
size: "sm",
|
|
126
|
+
className: "ml-auto text-icon-primary"
|
|
127
|
+
})
|
|
128
|
+
]
|
|
129
|
+
})
|
|
130
|
+
]
|
|
131
|
+
})
|
|
132
|
+
]
|
|
133
|
+
}),
|
|
134
|
+
/*#__PURE__*/ jsx(TableColumnMenuPinItem, {}),
|
|
135
|
+
/*#__PURE__*/ jsx(TableColumnMenuHideItem, {})
|
|
136
|
+
]
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
export { TableColumnMenu, useTableColumnMenuContext };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import { type DropdownMenuItemProps } from '../../DropdownMenu';
|
|
3
|
+
export type TableColumnMenuHideItemProps = DropdownMenuItemProps;
|
|
4
|
+
/**
|
|
5
|
+
* "Hide" entry in the column header menu. Auto-suppresses when the column
|
|
6
|
+
* cannot be hidden.
|
|
7
|
+
*/
|
|
8
|
+
export declare const TableColumnMenuHideItem: FC<TableColumnMenuHideItemProps>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { EyeOff } from "../../../icons/index.js";
|
|
3
|
+
import { DropdownMenuItem } from "../../DropdownMenu/index.js";
|
|
4
|
+
import { useTableContext } from "../TableContext/index.js";
|
|
5
|
+
import { useTableColumnMenuContext } from "./TableColumnMenu.js";
|
|
6
|
+
const TableColumnMenuHideItem = ({ onSelect, children, ...rest })=>{
|
|
7
|
+
const { column } = useTableColumnMenuContext();
|
|
8
|
+
const ctx = useTableContext();
|
|
9
|
+
const canHide = ctx.visibilityEnabled && column.getCanHide();
|
|
10
|
+
if (!canHide) return null;
|
|
11
|
+
const handleSelect = ()=>{
|
|
12
|
+
onSelect?.();
|
|
13
|
+
column.toggleVisibility(false);
|
|
14
|
+
};
|
|
15
|
+
return /*#__PURE__*/ jsxs(DropdownMenuItem, {
|
|
16
|
+
...rest,
|
|
17
|
+
onSelect: handleSelect,
|
|
18
|
+
children: [
|
|
19
|
+
/*#__PURE__*/ jsx(EyeOff, {
|
|
20
|
+
size: "sm"
|
|
21
|
+
}),
|
|
22
|
+
children ?? 'Hide'
|
|
23
|
+
]
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
TableColumnMenuHideItem.displayName = 'TableColumnMenuHideItem';
|
|
27
|
+
export { TableColumnMenuHideItem };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import { type DropdownMenuItemProps } from '../../DropdownMenu';
|
|
3
|
+
export type TableColumnMenuMoveLeftItemProps = DropdownMenuItemProps;
|
|
4
|
+
/**
|
|
5
|
+
* "Move left" entry in the column header menu. Auto-suppresses when the
|
|
6
|
+
* column cannot be reordered, is pinned, or is already first.
|
|
7
|
+
*/
|
|
8
|
+
export declare const TableColumnMenuMoveLeftItem: FC<TableColumnMenuMoveLeftItemProps>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { arrayMove } from "@dnd-kit/sortable";
|
|
3
|
+
import { ArrowLeft } from "../../../icons/index.js";
|
|
4
|
+
import { DropdownMenuItem } from "../../DropdownMenu/index.js";
|
|
5
|
+
import { useTableContext } from "../TableContext/index.js";
|
|
6
|
+
import { useTableColumnMenuContext } from "./TableColumnMenu.js";
|
|
7
|
+
const TableColumnMenuMoveLeftItem = ({ onSelect, children, ...rest })=>{
|
|
8
|
+
const { column } = useTableColumnMenuContext();
|
|
9
|
+
const ctx = useTableContext();
|
|
10
|
+
const isPinned = column.getIsPinned();
|
|
11
|
+
const isAlwaysPinned = ctx.alwaysPinnedLeft.includes(column.id);
|
|
12
|
+
const canReorder = ctx.columnDndEnabled && !isAlwaysPinned;
|
|
13
|
+
const visibleColumns = ctx.table.getVisibleLeafColumns();
|
|
14
|
+
const columnIdx = visibleColumns.findIndex((c)=>c.id === column.id);
|
|
15
|
+
const canMoveLeft = canReorder && columnIdx > 0 && !isPinned;
|
|
16
|
+
if (!canMoveLeft) return null;
|
|
17
|
+
const handleSelect = ()=>{
|
|
18
|
+
onSelect?.();
|
|
19
|
+
const allColumns = ctx.table.getAllLeafColumns();
|
|
20
|
+
const currentOrder = ctx.table.getState().columnOrder.length ? ctx.table.getState().columnOrder : allColumns.map((c)=>c.id);
|
|
21
|
+
const fromIdx = currentOrder.indexOf(column.id);
|
|
22
|
+
const toIdx = fromIdx - 1;
|
|
23
|
+
if (toIdx < 0) return;
|
|
24
|
+
ctx.setColumnOrder(arrayMove(currentOrder, fromIdx, toIdx));
|
|
25
|
+
};
|
|
26
|
+
return /*#__PURE__*/ jsxs(DropdownMenuItem, {
|
|
27
|
+
...rest,
|
|
28
|
+
onSelect: handleSelect,
|
|
29
|
+
children: [
|
|
30
|
+
/*#__PURE__*/ jsx(ArrowLeft, {
|
|
31
|
+
size: "sm"
|
|
32
|
+
}),
|
|
33
|
+
children ?? 'Move left'
|
|
34
|
+
]
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
TableColumnMenuMoveLeftItem.displayName = 'TableColumnMenuMoveLeftItem';
|
|
38
|
+
export { TableColumnMenuMoveLeftItem };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import { type DropdownMenuItemProps } from '../../DropdownMenu';
|
|
3
|
+
export type TableColumnMenuMoveRightItemProps = DropdownMenuItemProps;
|
|
4
|
+
/**
|
|
5
|
+
* "Move right" entry in the column header menu. Auto-suppresses when the
|
|
6
|
+
* column cannot be reordered, is pinned, or is already last.
|
|
7
|
+
*/
|
|
8
|
+
export declare const TableColumnMenuMoveRightItem: FC<TableColumnMenuMoveRightItemProps>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { arrayMove } from "@dnd-kit/sortable";
|
|
3
|
+
import { ArrowRight } from "../../../icons/index.js";
|
|
4
|
+
import { DropdownMenuItem } from "../../DropdownMenu/index.js";
|
|
5
|
+
import { useTableContext } from "../TableContext/index.js";
|
|
6
|
+
import { useTableColumnMenuContext } from "./TableColumnMenu.js";
|
|
7
|
+
const TableColumnMenuMoveRightItem = ({ onSelect, children, ...rest })=>{
|
|
8
|
+
const { column } = useTableColumnMenuContext();
|
|
9
|
+
const ctx = useTableContext();
|
|
10
|
+
const isPinned = column.getIsPinned();
|
|
11
|
+
const isAlwaysPinned = ctx.alwaysPinnedLeft.includes(column.id);
|
|
12
|
+
const canReorder = ctx.columnDndEnabled && !isAlwaysPinned;
|
|
13
|
+
const visibleColumns = ctx.table.getVisibleLeafColumns();
|
|
14
|
+
const columnIdx = visibleColumns.findIndex((c)=>c.id === column.id);
|
|
15
|
+
const isLast = columnIdx === visibleColumns.length - 1;
|
|
16
|
+
const canMoveRight = canReorder && !isLast && !isPinned;
|
|
17
|
+
if (!canMoveRight) return null;
|
|
18
|
+
const handleSelect = ()=>{
|
|
19
|
+
onSelect?.();
|
|
20
|
+
const allColumns = ctx.table.getAllLeafColumns();
|
|
21
|
+
const currentOrder = ctx.table.getState().columnOrder.length ? ctx.table.getState().columnOrder : allColumns.map((c)=>c.id);
|
|
22
|
+
const fromIdx = currentOrder.indexOf(column.id);
|
|
23
|
+
const toIdx = fromIdx + 1;
|
|
24
|
+
if (toIdx >= currentOrder.length) return;
|
|
25
|
+
ctx.setColumnOrder(arrayMove(currentOrder, fromIdx, toIdx));
|
|
26
|
+
};
|
|
27
|
+
return /*#__PURE__*/ jsxs(DropdownMenuItem, {
|
|
28
|
+
...rest,
|
|
29
|
+
onSelect: handleSelect,
|
|
30
|
+
children: [
|
|
31
|
+
/*#__PURE__*/ jsx(ArrowRight, {
|
|
32
|
+
size: "sm"
|
|
33
|
+
}),
|
|
34
|
+
children ?? 'Move right'
|
|
35
|
+
]
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
TableColumnMenuMoveRightItem.displayName = 'TableColumnMenuMoveRightItem';
|
|
39
|
+
export { TableColumnMenuMoveRightItem };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import { type DropdownMenuItemProps } from '../../DropdownMenu';
|
|
3
|
+
export type TableColumnMenuPinItemProps = DropdownMenuItemProps;
|
|
4
|
+
/**
|
|
5
|
+
* Pin / unpin toggle. Renders "Pin" when the column is unpinned and "Unpin"
|
|
6
|
+
* when it is — the same DOM node receives the consumer's `data-analytics-id`
|
|
7
|
+
* in both states, so a single id captures both transitions. Auto-suppresses
|
|
8
|
+
* when the column cannot be pinned (or is always-pinned).
|
|
9
|
+
*/
|
|
10
|
+
export declare const TableColumnMenuPinItem: FC<TableColumnMenuPinItemProps>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Pin, PinOff } from "../../../icons/index.js";
|
|
3
|
+
import { DropdownMenuItem } from "../../DropdownMenu/index.js";
|
|
4
|
+
import { useTableContext } from "../TableContext/index.js";
|
|
5
|
+
import { useTableColumnMenuContext } from "./TableColumnMenu.js";
|
|
6
|
+
const TableColumnMenuPinItem = ({ onSelect, children, ...rest })=>{
|
|
7
|
+
const { column } = useTableColumnMenuContext();
|
|
8
|
+
const ctx = useTableContext();
|
|
9
|
+
const isPinned = column.getIsPinned();
|
|
10
|
+
const isAlwaysPinned = ctx.alwaysPinnedLeft.includes(column.id);
|
|
11
|
+
const canPin = ctx.pinningEnabled && column.getCanPin() && !isAlwaysPinned;
|
|
12
|
+
if (!canPin) return null;
|
|
13
|
+
const handleSelect = ()=>{
|
|
14
|
+
onSelect?.();
|
|
15
|
+
column.pin(isPinned ? false : 'left');
|
|
16
|
+
};
|
|
17
|
+
return /*#__PURE__*/ jsxs(DropdownMenuItem, {
|
|
18
|
+
...rest,
|
|
19
|
+
onSelect: handleSelect,
|
|
20
|
+
children: [
|
|
21
|
+
isPinned ? /*#__PURE__*/ jsx(PinOff, {
|
|
22
|
+
size: "sm"
|
|
23
|
+
}) : /*#__PURE__*/ jsx(Pin, {
|
|
24
|
+
size: "sm"
|
|
25
|
+
}),
|
|
26
|
+
children ?? (isPinned ? 'Unpin' : 'Pin')
|
|
27
|
+
]
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
TableColumnMenuPinItem.displayName = 'TableColumnMenuPinItem';
|
|
31
|
+
export { TableColumnMenuPinItem };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import { type DropdownMenuItemProps } from '../../DropdownMenu';
|
|
3
|
+
export interface TableColumnMenuSortItemProps extends DropdownMenuItemProps {
|
|
4
|
+
/** Direction this item commits when selected. */
|
|
5
|
+
direction: 'asc' | 'desc';
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* "Sort ascending / descending" entry. Renders the localized label that
|
|
9
|
+
* matches the column's `sortType` (e.g. "A → Z" for text, "Highest on top"
|
|
10
|
+
* for number/score/size) and shows a checkmark when the column is currently
|
|
11
|
+
* sorted in this direction. Auto-suppresses when sorting is disabled.
|
|
12
|
+
*
|
|
13
|
+
* The legacy default menu nests these items under a submenu; consumer-supplied
|
|
14
|
+
* children can place them flat or inside their own `<DropdownMenu>` submenu —
|
|
15
|
+
* the item itself doesn't care.
|
|
16
|
+
*/
|
|
17
|
+
export declare const TableColumnMenuSortItem: FC<TableColumnMenuSortItemProps>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Check } from "../../../icons/index.js";
|
|
3
|
+
import { DropdownMenuItem } from "../../DropdownMenu/index.js";
|
|
4
|
+
import { SORT_LABELS } from "../lib/index.js";
|
|
5
|
+
import { useTableContext } from "../TableContext/index.js";
|
|
6
|
+
import { useTableColumnMenuContext } from "./TableColumnMenu.js";
|
|
7
|
+
const TableColumnMenuSortItem = ({ direction, onSelect, children, ...rest })=>{
|
|
8
|
+
const { column } = useTableColumnMenuContext();
|
|
9
|
+
const ctx = useTableContext();
|
|
10
|
+
if (!ctx.sortingEnabled || !column.getCanSort()) return null;
|
|
11
|
+
const sortDirection = column.getIsSorted();
|
|
12
|
+
const sortType = column.columnDef.meta?.sortType;
|
|
13
|
+
const [ascLabel, descLabel] = sortType && SORT_LABELS[sortType] || SORT_LABELS.text;
|
|
14
|
+
const label = 'asc' === direction ? ascLabel : descLabel;
|
|
15
|
+
const isActive = sortDirection === direction;
|
|
16
|
+
const handleSelect = ()=>{
|
|
17
|
+
onSelect?.();
|
|
18
|
+
column.toggleSorting('desc' === direction);
|
|
19
|
+
};
|
|
20
|
+
return /*#__PURE__*/ jsxs(DropdownMenuItem, {
|
|
21
|
+
...rest,
|
|
22
|
+
onSelect: handleSelect,
|
|
23
|
+
children: [
|
|
24
|
+
children ?? label,
|
|
25
|
+
isActive && /*#__PURE__*/ jsx(Check, {
|
|
26
|
+
size: "sm",
|
|
27
|
+
className: "ml-auto text-icon-primary"
|
|
28
|
+
})
|
|
29
|
+
]
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
TableColumnMenuSortItem.displayName = 'TableColumnMenuSortItem';
|
|
33
|
+
export { TableColumnMenuSortItem };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { TableColumnMenu, type TableColumnMenuProps } from './TableColumnMenu';
|
|
2
|
+
export { TableColumnMenuHideItem, type TableColumnMenuHideItemProps, } from './TableColumnMenuHideItem';
|
|
3
|
+
export { TableColumnMenuMoveLeftItem, type TableColumnMenuMoveLeftItemProps, } from './TableColumnMenuMoveLeftItem';
|
|
4
|
+
export { TableColumnMenuMoveRightItem, type TableColumnMenuMoveRightItemProps, } from './TableColumnMenuMoveRightItem';
|
|
5
|
+
export { TableColumnMenuPinItem, type TableColumnMenuPinItemProps, } from './TableColumnMenuPinItem';
|
|
6
|
+
export { TableColumnMenuSortItem, type TableColumnMenuSortItemProps, } from './TableColumnMenuSortItem';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TableColumnMenu } from "./TableColumnMenu.js";
|
|
2
|
+
import { TableColumnMenuHideItem } from "./TableColumnMenuHideItem.js";
|
|
3
|
+
import { TableColumnMenuMoveLeftItem } from "./TableColumnMenuMoveLeftItem.js";
|
|
4
|
+
import { TableColumnMenuMoveRightItem } from "./TableColumnMenuMoveRightItem.js";
|
|
5
|
+
import { TableColumnMenuPinItem } from "./TableColumnMenuPinItem.js";
|
|
6
|
+
import { TableColumnMenuSortItem } from "./TableColumnMenuSortItem.js";
|
|
7
|
+
export { TableColumnMenu, TableColumnMenuHideItem, TableColumnMenuMoveLeftItem, TableColumnMenuMoveRightItem, TableColumnMenuPinItem, TableColumnMenuSortItem };
|