@dmsi/wedgekit-react 0.0.550 → 0.0.552
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/{chunk-U3QGZAVS.js → chunk-JADOJNBI.js} +4 -4
- package/dist/{chunk-N2KPADIL.js → chunk-WNGFRQ4Y.js} +7 -7
- package/dist/{chunk-ZVY3TLXL.js → chunk-ZIPJMN2E.js} +4 -4
- package/dist/components/Alert.js +2 -2
- package/dist/components/CalendarRange.js +10 -10
- package/dist/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.js +10 -10
- package/dist/components/DataGrid/ColumnSelectorHeaderCell/index.js +10 -10
- package/dist/components/DataGrid/PinnedColumns.js +10 -10
- package/dist/components/DataGrid/TableBody/LoadingCell.js +10 -10
- package/dist/components/DataGrid/TableBody/TableBodyRow.js +10 -10
- package/dist/components/DataGrid/TableBody/index.js +10 -10
- package/dist/components/DataGrid/index.js +10 -10
- package/dist/components/DataGrid/utils.js +10 -10
- package/dist/components/DateInput.js +10 -10
- package/dist/components/DateRangeInput.js +10 -10
- package/dist/components/FilterGroup.js +5 -5
- package/dist/components/MobileDataGrid/ColumnSelector/index.js +10 -10
- package/dist/components/MobileDataGrid/MobileDataGridHeader.js +10 -10
- package/dist/components/MobileDataGrid/RowDetailModalProvider/index.js +5 -5
- package/dist/components/MobileDataGrid/index.js +10 -10
- package/dist/components/Modal.js +4 -4
- package/dist/components/ModalButtons.js +2 -2
- package/dist/components/ModalHeader.js +2 -2
- package/dist/components/NavigationTab.js +2 -2
- package/dist/components/NavigationTabs.js +2 -2
- package/dist/components/NestedMenu.js +3 -3
- package/dist/components/Notification.js +3 -3
- package/dist/components/OptionPill.js +2 -2
- package/dist/components/PDFViewer/DownloadIcon.js +2 -2
- package/dist/components/PDFViewer/PDFNavigation.js +2 -2
- package/dist/components/PDFViewer/index.js +6 -6
- package/dist/components/ProductImagePreview/index.js +1 -1
- package/dist/components/Stepper.js +3 -3
- package/dist/components/Toast.js +3 -3
- package/dist/components/Upload.js +3 -3
- package/dist/components/index.js +16 -16
- package/package.json +8 -9
- package/src/brand.css +0 -125
- package/src/classNames.ts +0 -174
- package/src/components/AccessChangerTabItem.tsx +0 -71
- package/src/components/Accordion.tsx +0 -108
- package/src/components/Alert.tsx +0 -81
- package/src/components/Breadcrumbs.tsx +0 -142
- package/src/components/Button.tsx +0 -216
- package/src/components/CalendarRange.tsx +0 -628
- package/src/components/Caption.tsx +0 -144
- package/src/components/Card.tsx +0 -88
- package/src/components/Checkbox.tsx +0 -206
- package/src/components/CompactImagesPreview.tsx +0 -135
- package/src/components/ContentTab.tsx +0 -84
- package/src/components/ContentTabs.tsx +0 -136
- package/src/components/DMSiLogo.tsx +0 -33
- package/src/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.tsx +0 -35
- package/src/components/DataGrid/ColumnSelectorHeaderCell/index.tsx +0 -74
- package/src/components/DataGrid/PinnedColumns.tsx +0 -183
- package/src/components/DataGrid/TableBody/LoadingCell.tsx +0 -44
- package/src/components/DataGrid/TableBody/TableBodyRow.tsx +0 -157
- package/src/components/DataGrid/TableBody/index.tsx +0 -185
- package/src/components/DataGrid/index.tsx +0 -756
- package/src/components/DataGrid/types.ts +0 -98
- package/src/components/DataGrid/utils.tsx +0 -15
- package/src/components/DataGridCell.tsx +0 -526
- package/src/components/DataTable.tsx +0 -881
- package/src/components/DateInput.tsx +0 -306
- package/src/components/DateRangeInput.tsx +0 -758
- package/src/components/DebugJson.tsx +0 -28
- package/src/components/Display.tsx +0 -66
- package/src/components/EditingContext.tsx +0 -43
- package/src/components/EmptyCartIcon.tsx +0 -18
- package/src/components/FilterGroup.tsx +0 -264
- package/src/components/FullViewportBox.tsx +0 -19
- package/src/components/Grid.tsx +0 -97
- package/src/components/Heading.tsx +0 -72
- package/src/components/HorizontalDivider.tsx +0 -22
- package/src/components/Icon.tsx +0 -39
- package/src/components/ImagePlaceholder.tsx +0 -22
- package/src/components/Input.tsx +0 -609
- package/src/components/InputGroup.tsx +0 -59
- package/src/components/Label.tsx +0 -46
- package/src/components/Link.tsx +0 -117
- package/src/components/List.tsx +0 -18
- package/src/components/ListGroup.tsx +0 -82
- package/src/components/LiveChatComponent.tsx +0 -56
- package/src/components/LoadingScrim.tsx +0 -33
- package/src/components/LogoAgilityTopBar.tsx +0 -54
- package/src/components/LogoDMSiTopBar.tsx +0 -33
- package/src/components/LogoMillworkTopBar.tsx +0 -119
- package/src/components/MainBar.tsx +0 -91
- package/src/components/MaxViewportBox.tsx +0 -19
- package/src/components/Menu.tsx +0 -316
- package/src/components/MenuOption.tsx +0 -330
- package/src/components/MobileDataGrid/ColumnList.tsx +0 -66
- package/src/components/MobileDataGrid/ColumnSelector/index.tsx +0 -97
- package/src/components/MobileDataGrid/GridContextProvider/GridContext.tsx +0 -25
- package/src/components/MobileDataGrid/GridContextProvider/index.tsx +0 -132
- package/src/components/MobileDataGrid/GridContextProvider/useGridContext.ts +0 -10
- package/src/components/MobileDataGrid/MobileDataGridCard/MobileDataGridColumn.tsx +0 -27
- package/src/components/MobileDataGrid/MobileDataGridCard/index.tsx +0 -138
- package/src/components/MobileDataGrid/MobileDataGridHeader.tsx +0 -81
- package/src/components/MobileDataGrid/RowDetailModalProvider/ModalContent.tsx +0 -42
- package/src/components/MobileDataGrid/RowDetailModalProvider/index.tsx +0 -68
- package/src/components/MobileDataGrid/dataGridReducer.ts +0 -55
- package/src/components/MobileDataGrid/index.tsx +0 -92
- package/src/components/MobileDataGrid/types.ts +0 -4
- package/src/components/Modal.tsx +0 -312
- package/src/components/ModalButtons.tsx +0 -62
- package/src/components/ModalContent.tsx +0 -31
- package/src/components/ModalHeader.tsx +0 -78
- package/src/components/ModalScrim.tsx +0 -42
- package/src/components/NavigationTab.tsx +0 -95
- package/src/components/NavigationTabs.tsx +0 -70
- package/src/components/NestedMenu.tsx +0 -131
- package/src/components/Notification.tsx +0 -128
- package/src/components/OptionPill.tsx +0 -139
- package/src/components/OrderCheckIcon.tsx +0 -19
- package/src/components/PDFViewer/DownloadIcon.tsx +0 -25
- package/src/components/PDFViewer/PDFElement.tsx +0 -90
- package/src/components/PDFViewer/PDFNavigation.tsx +0 -68
- package/src/components/PDFViewer/PDFPage.tsx +0 -34
- package/src/components/PDFViewer/index.tsx +0 -128
- package/src/components/Pagination.tsx +0 -182
- package/src/components/Paragraph.tsx +0 -55
- package/src/components/Password.tsx +0 -62
- package/src/components/ProductImagePreview/CarouselPagination.tsx +0 -54
- package/src/components/ProductImagePreview/MobileImageCarousel.tsx +0 -226
- package/src/components/ProductImagePreview/ProductPrimaryImage.tsx +0 -219
- package/src/components/ProductImagePreview/Thumbnail.tsx +0 -55
- package/src/components/ProductImagePreview/ZoomWindow.tsx +0 -136
- package/src/components/ProductImagePreview/index.tsx +0 -182
- package/src/components/ProductImagePreview/useProductImagePreview.ts +0 -211
- package/src/components/ProjectBar.tsx +0 -82
- package/src/components/Radio.tsx +0 -146
- package/src/components/Search.tsx +0 -152
- package/src/components/SearchResultImage/index.tsx +0 -39
- package/src/components/Select.tsx +0 -114
- package/src/components/SideMenu.tsx +0 -30
- package/src/components/SideMenuGroup.tsx +0 -95
- package/src/components/SideMenuItem.tsx +0 -109
- package/src/components/SimpleTable.tsx +0 -77
- package/src/components/SkeletonParagraph.tsx +0 -31
- package/src/components/Spinner.tsx +0 -32
- package/src/components/Stack.tsx +0 -347
- package/src/components/StatusPill.tsx +0 -59
- package/src/components/Stepper.tsx +0 -128
- package/src/components/Subheader.tsx +0 -50
- package/src/components/Surface.tsx +0 -37
- package/src/components/Swatch.tsx +0 -1341
- package/src/components/Textarea.tsx +0 -102
- package/src/components/Theme.tsx +0 -27
- package/src/components/Time.tsx +0 -460
- package/src/components/Toast.tsx +0 -268
- package/src/components/Tooltip.tsx +0 -159
- package/src/components/TopBar.tsx +0 -139
- package/src/components/Upload.tsx +0 -107
- package/src/components/WorldpayIframe.tsx +0 -7
- package/src/components/index.ts +0 -34
- package/src/components/useMenuSystem.tsx +0 -456
- package/src/components/useMounted.tsx +0 -14
- package/src/darkmode.css +0 -278
- package/src/fonts.css +0 -23
- package/src/hooks/index.ts +0 -4
- package/src/hooks/useInfiniteScroll.tsx +0 -40
- package/src/hooks/useKeydown.ts +0 -42
- package/src/hooks/useMatchesMedia.ts +0 -18
- package/src/hooks/useTableLayout.ts +0 -106
- package/src/index.css +0 -800
- package/src/index.tsx +0 -5
- package/src/types.ts +0 -150
- package/src/utils/date.ts +0 -236
- package/src/utils/formatting.tsx +0 -81
- package/src/utils/index.ts +0 -4
- package/src/utils/mergeObjectArrays.ts +0 -18
- package/src/utils.ts +0 -24
- package/dist/{chunk-7FQ7PGUF.js → chunk-7COWXCPA.js} +3 -3
- package/dist/{chunk-NKCFYM7A.js → chunk-7SFFUICM.js} +3 -3
- package/dist/{chunk-25RZP3VR.js → chunk-AKJUBFJK.js} +3 -3
- package/dist/{chunk-TAPYQBQU.js → chunk-CMMQTIVM.js} +3 -3
- package/dist/{chunk-GYEXSNFP.js → chunk-FWCVZWE6.js} +3 -3
- package/dist/{chunk-MV6W7OMC.js → chunk-QMMPHXVE.js} +3 -3
- package/dist/{chunk-GG5OZTI5.js → chunk-XRE52QTN.js} +3 -3
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ColumnDef,
|
|
3
|
-
ColumnFiltersState,
|
|
4
|
-
SortingState,
|
|
5
|
-
} from "@tanstack/react-table";
|
|
6
|
-
|
|
7
|
-
import { ReactNode } from "react";
|
|
8
|
-
|
|
9
|
-
// TanStack Table
|
|
10
|
-
import {
|
|
11
|
-
FilterFn,
|
|
12
|
-
Header,
|
|
13
|
-
PartialKeys,
|
|
14
|
-
RowData,
|
|
15
|
-
Table,
|
|
16
|
-
TableOptionsResolved,
|
|
17
|
-
} from "@tanstack/react-table";
|
|
18
|
-
|
|
19
|
-
// Types
|
|
20
|
-
export interface DataGridPagination {
|
|
21
|
-
pageIndex: number;
|
|
22
|
-
pageSize: number;
|
|
23
|
-
total: number;
|
|
24
|
-
onPageChange: (pageIndex: number) => void;
|
|
25
|
-
onPageSizeChange?: (pageSize: number) => void;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface DataGridProps<T extends Record<string, unknown>> {
|
|
29
|
-
id?: string;
|
|
30
|
-
rowIdAccessor?: keyof T;
|
|
31
|
-
testid?: string;
|
|
32
|
-
data: T[];
|
|
33
|
-
columns: ColumnDef<T>[];
|
|
34
|
-
status?: string;
|
|
35
|
-
locked?: boolean;
|
|
36
|
-
isLoadingMore?: boolean;
|
|
37
|
-
onLoadMore?: () => void;
|
|
38
|
-
hasMore?: boolean;
|
|
39
|
-
pagination?: DataGridPagination;
|
|
40
|
-
showFilterRow?: boolean;
|
|
41
|
-
sorting?: SortingState;
|
|
42
|
-
onSortingChange?: (state: SortingState) => void;
|
|
43
|
-
columnFilters?: ColumnFiltersState;
|
|
44
|
-
onColumnFiltersChange?: (filters: ColumnFiltersState) => void;
|
|
45
|
-
rowSelection?: Record<string, boolean>;
|
|
46
|
-
onRowSelectionChange?: (selection: Record<string, boolean>) => void;
|
|
47
|
-
filteredSortedData?: T[];
|
|
48
|
-
totalRowCount: number;
|
|
49
|
-
hideStatusBar?: boolean;
|
|
50
|
-
centerHeader?: boolean;
|
|
51
|
-
enableColumnSelector?: boolean;
|
|
52
|
-
predeterminedLeftPins?: string[];
|
|
53
|
-
predeterminedRightPins?: string[];
|
|
54
|
-
useMenuDefaultMinWidth?: boolean;
|
|
55
|
-
rowDisabled?: boolean;
|
|
56
|
-
rowDisabledAccessor?: (row: T) => boolean;
|
|
57
|
-
ref?: React.Ref<{ getSavedLayout: () => ColumnDef<T>[] | undefined }>;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
declare module "@tanstack/react-table" {
|
|
61
|
-
interface TableOptions<TData extends RowData>
|
|
62
|
-
extends PartialKeys<
|
|
63
|
-
TableOptionsResolved<TData>,
|
|
64
|
-
"state" | "onStateChange" | "renderFallbackValue"
|
|
65
|
-
> {
|
|
66
|
-
filterFns?: FilterFns;
|
|
67
|
-
}
|
|
68
|
-
interface FilterFns {
|
|
69
|
-
endsWith?: FilterFn<RowData>;
|
|
70
|
-
startsWith?: FilterFn<RowData>;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
interface ColumnMeta<TData extends RowData, TValue> {
|
|
74
|
-
filterVariant?: "text" | "select" | "range";
|
|
75
|
-
className?: string;
|
|
76
|
-
sticky?: boolean;
|
|
77
|
-
useCustomRenderer?: boolean;
|
|
78
|
-
locked?: boolean;
|
|
79
|
-
checkbox?: boolean;
|
|
80
|
-
headerWidth?: string;
|
|
81
|
-
visible?: boolean;
|
|
82
|
-
inVisibilityMenu?: boolean;
|
|
83
|
-
filterRowCell?: ({
|
|
84
|
-
header,
|
|
85
|
-
table,
|
|
86
|
-
}: {
|
|
87
|
-
header: Header<TData, TValue>;
|
|
88
|
-
table: Table<TData>;
|
|
89
|
-
}) => ReactNode;
|
|
90
|
-
align?: "left" | "right" | string;
|
|
91
|
-
format?: string;
|
|
92
|
-
mobileCell?: (props: {
|
|
93
|
-
column: ColumnDef<TData>;
|
|
94
|
-
cellValue: unknown;
|
|
95
|
-
row: RowData;
|
|
96
|
-
}) => React.ReactNode;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import clsx from "clsx";
|
|
2
|
-
import { Icon } from "..";
|
|
3
|
-
import { SortDirection } from "@tanstack/react-table";
|
|
4
|
-
|
|
5
|
-
export function getSortIcon(sort: SortDirection | false, nextSort = false) {
|
|
6
|
-
const iconClassName = clsx(
|
|
7
|
-
"text-icon-on-action-primary-normal",
|
|
8
|
-
nextSort && "hidden group-hover:block",
|
|
9
|
-
);
|
|
10
|
-
if (sort === "asc")
|
|
11
|
-
return <Icon size={16} className={iconClassName} name="arrow_upward" />;
|
|
12
|
-
if (sort === "desc")
|
|
13
|
-
return <Icon size={16} className={iconClassName} name="arrow_downward" />;
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
@@ -1,526 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { useSortable } from "@dnd-kit/sortable";
|
|
4
|
-
import { CSS } from "@dnd-kit/utilities";
|
|
5
|
-
import {
|
|
6
|
-
// BuiltInFilterFn,
|
|
7
|
-
Cell,
|
|
8
|
-
// FilterFn,
|
|
9
|
-
FilterFnOption,
|
|
10
|
-
Header,
|
|
11
|
-
RowData,
|
|
12
|
-
} from "@tanstack/react-table";
|
|
13
|
-
import clsx from "clsx";
|
|
14
|
-
import {
|
|
15
|
-
ComponentProps,
|
|
16
|
-
CSSProperties,
|
|
17
|
-
PropsWithChildren,
|
|
18
|
-
RefObject,
|
|
19
|
-
useEffect,
|
|
20
|
-
useRef,
|
|
21
|
-
useState,
|
|
22
|
-
memo,
|
|
23
|
-
} from "react";
|
|
24
|
-
import { componentPadding, paddingUsingComponentGap } from "../classNames";
|
|
25
|
-
import { MenuOption } from "./MenuOption";
|
|
26
|
-
import { Menu } from "./Menu";
|
|
27
|
-
import { Icon } from "./Icon";
|
|
28
|
-
import { Search } from "./Search";
|
|
29
|
-
import { useSubMenuSystem } from "./useMenuSystem";
|
|
30
|
-
import type { AsProps } from "../types";
|
|
31
|
-
|
|
32
|
-
type Tags = "td" | "th";
|
|
33
|
-
|
|
34
|
-
type DataGridCellProps = PropsWithChildren<{
|
|
35
|
-
id?: string;
|
|
36
|
-
testid?: string;
|
|
37
|
-
type?: "default" | "header" | "summary";
|
|
38
|
-
component?: "header" | "checkbox" | "icon" | "button" | "static" | "input";
|
|
39
|
-
locked?: boolean;
|
|
40
|
-
noPadding?: boolean;
|
|
41
|
-
paddedLeft?: boolean;
|
|
42
|
-
onRightClick?: () => void;
|
|
43
|
-
error?: boolean;
|
|
44
|
-
warning?: boolean;
|
|
45
|
-
center?: boolean;
|
|
46
|
-
width?: string;
|
|
47
|
-
minWidth?: string;
|
|
48
|
-
disabled?: boolean;
|
|
49
|
-
}>;
|
|
50
|
-
|
|
51
|
-
export const DataGridCell = memo(
|
|
52
|
-
({
|
|
53
|
-
id,
|
|
54
|
-
type = "default",
|
|
55
|
-
component = "static",
|
|
56
|
-
children,
|
|
57
|
-
className,
|
|
58
|
-
locked = false,
|
|
59
|
-
noPadding = false,
|
|
60
|
-
paddedLeft = false,
|
|
61
|
-
style,
|
|
62
|
-
onClick,
|
|
63
|
-
onRightClick,
|
|
64
|
-
error,
|
|
65
|
-
warning,
|
|
66
|
-
center,
|
|
67
|
-
width,
|
|
68
|
-
minWidth,
|
|
69
|
-
disabled,
|
|
70
|
-
testid,
|
|
71
|
-
...props
|
|
72
|
-
}: AsProps<Tags> & DataGridCellProps) => {
|
|
73
|
-
const Element = type === "header" ? "th" : "td";
|
|
74
|
-
const timerRef = useRef<number | null>(null);
|
|
75
|
-
const [isGrabbing, setIsGrabbing] = useState(false);
|
|
76
|
-
const [isPointerPressed, setIsPointerPressed] = useState(false);
|
|
77
|
-
|
|
78
|
-
useEffect(() => {
|
|
79
|
-
return () => {
|
|
80
|
-
if (timerRef.current) {
|
|
81
|
-
clearTimeout(timerRef.current);
|
|
82
|
-
timerRef.current = null;
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
}, []);
|
|
86
|
-
|
|
87
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
88
|
-
const handlePointerDown = (_event: React.MouseEvent | React.TouchEvent) => {
|
|
89
|
-
setIsPointerPressed(true);
|
|
90
|
-
|
|
91
|
-
timerRef.current = window.setTimeout(() => {
|
|
92
|
-
setIsGrabbing(true);
|
|
93
|
-
}, 500);
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const handlePointerUp = (event: React.MouseEvent | React.TouchEvent) => {
|
|
97
|
-
if (timerRef.current) {
|
|
98
|
-
clearTimeout(timerRef.current);
|
|
99
|
-
timerRef.current = null;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const rightClick =
|
|
103
|
-
event.nativeEvent instanceof MouseEvent &&
|
|
104
|
-
event.nativeEvent.button === 2;
|
|
105
|
-
|
|
106
|
-
if (!isGrabbing && onClick && !rightClick && isPointerPressed) {
|
|
107
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
108
|
-
onClick(event as any);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (rightClick && onRightClick) {
|
|
112
|
-
onRightClick();
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
setIsGrabbing(false);
|
|
116
|
-
setIsPointerPressed(false);
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
const handlePointerLeave = () => {
|
|
120
|
-
if (timerRef.current) {
|
|
121
|
-
clearTimeout(timerRef.current);
|
|
122
|
-
timerRef.current = null;
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
const headerBgStyles =
|
|
127
|
-
type === "header" &&
|
|
128
|
-
!locked &&
|
|
129
|
-
!["button"].includes(component) &&
|
|
130
|
-
"bg-brand-400 border-brand-200";
|
|
131
|
-
const lockedHeaderBgStyles =
|
|
132
|
-
locked &&
|
|
133
|
-
!["button"].includes(component) &&
|
|
134
|
-
"bg-neutral-400 border-neutral-300";
|
|
135
|
-
|
|
136
|
-
const headerTypeStyles =
|
|
137
|
-
type === "header" &&
|
|
138
|
-
component !== "button" &&
|
|
139
|
-
component !== "icon" &&
|
|
140
|
-
clsx("border-r");
|
|
141
|
-
|
|
142
|
-
const buttonComponentStyles =
|
|
143
|
-
component === "button" &&
|
|
144
|
-
clsx("border-r border-b border-border-primary-normal");
|
|
145
|
-
|
|
146
|
-
const iconComponentStyles = component === "icon" && clsx("border-l");
|
|
147
|
-
|
|
148
|
-
const cellClasses = clsx(
|
|
149
|
-
headerTypeStyles,
|
|
150
|
-
buttonComponentStyles,
|
|
151
|
-
headerBgStyles,
|
|
152
|
-
lockedHeaderBgStyles,
|
|
153
|
-
iconComponentStyles,
|
|
154
|
-
className,
|
|
155
|
-
"flex flex-1 items-center gap-1 whitespace-nowrap h-10 relative text-text-primary-normal",
|
|
156
|
-
"focus-within:!z-10",
|
|
157
|
-
"overflow-x-hidden",
|
|
158
|
-
"overflow-y-hidden",
|
|
159
|
-
component === "input" && "border",
|
|
160
|
-
component === "input" &&
|
|
161
|
-
!error &&
|
|
162
|
-
!warning &&
|
|
163
|
-
"border-border-primary-normal",
|
|
164
|
-
component === "input" && error && "border-border-primary-error",
|
|
165
|
-
component === "input" && warning && "border-background-warning-normal",
|
|
166
|
-
!["button", "icon"].includes(component) && !noPadding && componentPadding,
|
|
167
|
-
paddedLeft && "pl-2",
|
|
168
|
-
component === "icon" && "border-l",
|
|
169
|
-
isGrabbing && "!cursor-grabbing",
|
|
170
|
-
component === "checkbox" || (center && "justify-center"),
|
|
171
|
-
disabled && "!text-text-primary-disabled",
|
|
172
|
-
);
|
|
173
|
-
|
|
174
|
-
return (
|
|
175
|
-
<Element
|
|
176
|
-
id={id}
|
|
177
|
-
data-testid={testid}
|
|
178
|
-
className={clsx("flex h-10", !width && "flex-1")}
|
|
179
|
-
style={{ width, minWidth }}
|
|
180
|
-
{...props}
|
|
181
|
-
data-theme={type === "header" && !locked ? "brand" : undefined}
|
|
182
|
-
>
|
|
183
|
-
<div
|
|
184
|
-
className={cellClasses}
|
|
185
|
-
style={{
|
|
186
|
-
...style,
|
|
187
|
-
}}
|
|
188
|
-
onMouseDown={handlePointerDown}
|
|
189
|
-
onMouseUp={handlePointerUp}
|
|
190
|
-
onMouseLeave={handlePointerLeave}
|
|
191
|
-
onTouchStart={handlePointerDown}
|
|
192
|
-
onTouchEnd={handlePointerUp}
|
|
193
|
-
onTouchCancel={handlePointerLeave}
|
|
194
|
-
onContextMenu={(e) => e.preventDefault()}
|
|
195
|
-
>
|
|
196
|
-
{children}
|
|
197
|
-
</div>
|
|
198
|
-
</Element>
|
|
199
|
-
);
|
|
200
|
-
},
|
|
201
|
-
);
|
|
202
|
-
|
|
203
|
-
DataGridCell.displayName = "DataGridCell";
|
|
204
|
-
|
|
205
|
-
export type DataGridCellHeaderProps<T> = {
|
|
206
|
-
header: Header<T, unknown>;
|
|
207
|
-
children: React.ReactNode;
|
|
208
|
-
width?: string;
|
|
209
|
-
setNodeRef?: (node: HTMLElement | null) => void;
|
|
210
|
-
node?: RefObject<HTMLElement | null>;
|
|
211
|
-
useMenuDefaultMinWidth?: boolean;
|
|
212
|
-
} & DataGridCellProps &
|
|
213
|
-
ComponentProps<"th">;
|
|
214
|
-
|
|
215
|
-
export function DataCellHeader<T>({
|
|
216
|
-
header,
|
|
217
|
-
children,
|
|
218
|
-
setNodeRef,
|
|
219
|
-
node,
|
|
220
|
-
id,
|
|
221
|
-
testid,
|
|
222
|
-
useMenuDefaultMinWidth,
|
|
223
|
-
...props
|
|
224
|
-
}: DataGridCellHeaderProps<T>) {
|
|
225
|
-
const [showMenu, setShowMenu] = useState(false);
|
|
226
|
-
const [filter, setFilter] = useState(
|
|
227
|
-
(header.column.getFilterValue() as string) ?? "",
|
|
228
|
-
);
|
|
229
|
-
const ref = useRef<HTMLElement>(null);
|
|
230
|
-
const predeterminedPinned = useRef(false);
|
|
231
|
-
|
|
232
|
-
const { column, getContext } = header;
|
|
233
|
-
const { id: columnId, setFilterValue } = column;
|
|
234
|
-
|
|
235
|
-
const {
|
|
236
|
-
menuRootRef,
|
|
237
|
-
isMenuActive,
|
|
238
|
-
registerSubMenu,
|
|
239
|
-
listeners: subMenuListeners,
|
|
240
|
-
mobileHide,
|
|
241
|
-
} = useSubMenuSystem(node ? node : ref);
|
|
242
|
-
|
|
243
|
-
useEffect(() => {
|
|
244
|
-
const columnPinning =
|
|
245
|
-
getContext().table.options.initialState?.columnPinning;
|
|
246
|
-
const left = columnPinning?.left ?? [];
|
|
247
|
-
const right = columnPinning?.right ?? [];
|
|
248
|
-
|
|
249
|
-
predeterminedPinned.current = [...left, ...right].includes(columnId);
|
|
250
|
-
}, [columnId, getContext]);
|
|
251
|
-
|
|
252
|
-
useEffect(() => {
|
|
253
|
-
const handler = setTimeout(() => {
|
|
254
|
-
setFilterValue(filter);
|
|
255
|
-
}, 500);
|
|
256
|
-
|
|
257
|
-
return () => {
|
|
258
|
-
clearTimeout(handler);
|
|
259
|
-
};
|
|
260
|
-
}, [filter, setFilterValue]);
|
|
261
|
-
|
|
262
|
-
const style: CSSProperties = {
|
|
263
|
-
position: "relative",
|
|
264
|
-
whiteSpace: "nowrap",
|
|
265
|
-
minWidth: header.column.getSize(),
|
|
266
|
-
"--color-text-primary-normal": "var(--color-text-brand-primary-normal)",
|
|
267
|
-
"--color-icon-on-action-primary-normal":
|
|
268
|
-
"var(--color-text-brand-primary-normal)",
|
|
269
|
-
"--background-action-secondary-normal":
|
|
270
|
-
"var(--color-text-brand-primary-normal)",
|
|
271
|
-
...props.style,
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
return (
|
|
275
|
-
<DataGridCell
|
|
276
|
-
id={id}
|
|
277
|
-
testid={testid}
|
|
278
|
-
ref={setNodeRef ? setNodeRef : ref}
|
|
279
|
-
type="header"
|
|
280
|
-
component="header"
|
|
281
|
-
style={style}
|
|
282
|
-
minWidth={`${header.column.getSize()}px`}
|
|
283
|
-
onClick={header.column.getToggleSortingHandler()}
|
|
284
|
-
onRightClick={() => setShowMenu(!showMenu)}
|
|
285
|
-
{...props}
|
|
286
|
-
>
|
|
287
|
-
{children}
|
|
288
|
-
|
|
289
|
-
{header.column.getCanFilter() && (
|
|
290
|
-
<Menu
|
|
291
|
-
id={id ? `${id}-menu` : undefined}
|
|
292
|
-
testid={testid ? `${testid}-menu` : undefined}
|
|
293
|
-
ref={menuRootRef}
|
|
294
|
-
positionTo={node ? node : ref}
|
|
295
|
-
show={showMenu}
|
|
296
|
-
setShow={setShowMenu}
|
|
297
|
-
mobileHide={mobileHide}
|
|
298
|
-
useDefaultMinWidth={useMenuDefaultMinWidth}
|
|
299
|
-
>
|
|
300
|
-
<MenuOption
|
|
301
|
-
id={id ? `${id}-filter-option` : undefined}
|
|
302
|
-
testid={testid ? `${testid}-filter-option` : undefined}
|
|
303
|
-
{...subMenuListeners}
|
|
304
|
-
subMenu={({ menuId, subMenuLevel, ...props }) => (
|
|
305
|
-
<Menu
|
|
306
|
-
id={id ? `${id}-filter-submenu` : undefined}
|
|
307
|
-
testid={testid ? `${testid}-filter-submenu` : undefined}
|
|
308
|
-
{...props}
|
|
309
|
-
show={isMenuActive(menuId, subMenuLevel)}
|
|
310
|
-
ref={(el) => {
|
|
311
|
-
registerSubMenu(menuId, el);
|
|
312
|
-
}}
|
|
313
|
-
useDefaultMinWidth={useMenuDefaultMinWidth}
|
|
314
|
-
>
|
|
315
|
-
<div className={clsx(paddingUsingComponentGap)}>
|
|
316
|
-
<Search
|
|
317
|
-
id={id ? `${id}-filter-search` : undefined}
|
|
318
|
-
testid={testid ? `${testid}-filter-search` : undefined}
|
|
319
|
-
onChange={(event) => {
|
|
320
|
-
setFilter(event.target.value);
|
|
321
|
-
}}
|
|
322
|
-
onKeyDown={(event) => {
|
|
323
|
-
if ([" ", "Space"].includes(event.key)) {
|
|
324
|
-
event.stopPropagation();
|
|
325
|
-
}
|
|
326
|
-
}}
|
|
327
|
-
value={(filter ?? "") as string}
|
|
328
|
-
/>
|
|
329
|
-
</div>
|
|
330
|
-
|
|
331
|
-
<MenuOption
|
|
332
|
-
id={id ? `${id}-filter-contains` : undefined}
|
|
333
|
-
testid={testid ? `${testid}-filter-contains` : undefined}
|
|
334
|
-
onClick={handleFilterFnChange}
|
|
335
|
-
before={menuOptionIcon("includesString")}
|
|
336
|
-
>
|
|
337
|
-
Contains
|
|
338
|
-
</MenuOption>
|
|
339
|
-
|
|
340
|
-
<MenuOption
|
|
341
|
-
id={id ? `${id}-filter-startswith` : undefined}
|
|
342
|
-
testid={testid ? `${testid}-filter-startswith` : undefined}
|
|
343
|
-
onClick={handleFilterFnChange}
|
|
344
|
-
before={menuOptionIcon("startsWith")}
|
|
345
|
-
>
|
|
346
|
-
Starts with
|
|
347
|
-
</MenuOption>
|
|
348
|
-
|
|
349
|
-
<MenuOption
|
|
350
|
-
id={id ? `${id}-filter-endswith` : undefined}
|
|
351
|
-
testid={testid ? `${testid}-filter-endswith` : undefined}
|
|
352
|
-
onClick={handleFilterFnChange}
|
|
353
|
-
before={menuOptionIcon("endsWith")}
|
|
354
|
-
>
|
|
355
|
-
Ends with
|
|
356
|
-
</MenuOption>
|
|
357
|
-
</Menu>
|
|
358
|
-
)}
|
|
359
|
-
>
|
|
360
|
-
Filter
|
|
361
|
-
</MenuOption>
|
|
362
|
-
|
|
363
|
-
{!predeterminedPinned.current && header.column.getCanPin() && (
|
|
364
|
-
<MenuOption
|
|
365
|
-
onClick={() => {
|
|
366
|
-
setShowMenu(!showMenu);
|
|
367
|
-
}}
|
|
368
|
-
{...subMenuListeners}
|
|
369
|
-
subMenu={({ menuId, subMenuLevel, ...props }) => (
|
|
370
|
-
<Menu
|
|
371
|
-
{...props}
|
|
372
|
-
show={isMenuActive(menuId, subMenuLevel)}
|
|
373
|
-
ref={(el) => {
|
|
374
|
-
registerSubMenu(menuId, el);
|
|
375
|
-
}}
|
|
376
|
-
>
|
|
377
|
-
<MenuOption
|
|
378
|
-
selected={header.column.getIsPinned() === "left"}
|
|
379
|
-
onClick={() => {
|
|
380
|
-
if (header.column.getIsPinned() === "left") {
|
|
381
|
-
header.column.pin(false);
|
|
382
|
-
} else {
|
|
383
|
-
header.column.pin("left");
|
|
384
|
-
}
|
|
385
|
-
}}
|
|
386
|
-
after={
|
|
387
|
-
header.column.getIsPinned() === "left" && (
|
|
388
|
-
<Icon name="check" />
|
|
389
|
-
)
|
|
390
|
-
}
|
|
391
|
-
>
|
|
392
|
-
Left
|
|
393
|
-
</MenuOption>
|
|
394
|
-
|
|
395
|
-
<MenuOption
|
|
396
|
-
selected={header.column.getIsPinned() === "right"}
|
|
397
|
-
onClick={() => {
|
|
398
|
-
if (header.column.getIsPinned() === "right") {
|
|
399
|
-
header.column.pin(false);
|
|
400
|
-
} else {
|
|
401
|
-
header.column.pin("right");
|
|
402
|
-
}
|
|
403
|
-
}}
|
|
404
|
-
after={
|
|
405
|
-
header.column.getIsPinned() === "right" && (
|
|
406
|
-
<Icon name="check" />
|
|
407
|
-
)
|
|
408
|
-
}
|
|
409
|
-
>
|
|
410
|
-
Right
|
|
411
|
-
</MenuOption>
|
|
412
|
-
</Menu>
|
|
413
|
-
)}
|
|
414
|
-
>
|
|
415
|
-
{`Freeze [${header.column.columnDef.header as string}]`}
|
|
416
|
-
</MenuOption>
|
|
417
|
-
)}
|
|
418
|
-
</Menu>
|
|
419
|
-
)}
|
|
420
|
-
</DataGridCell>
|
|
421
|
-
);
|
|
422
|
-
|
|
423
|
-
function menuOptionIcon(value: string) {
|
|
424
|
-
return (
|
|
425
|
-
<Icon
|
|
426
|
-
name="check"
|
|
427
|
-
className={clsx(
|
|
428
|
-
header.column.columnDef.filterFn !== value && "text-transparent",
|
|
429
|
-
)}
|
|
430
|
-
/>
|
|
431
|
-
);
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
function handleFilterFnChange<TData>(_id: string, value: string | undefined) {
|
|
435
|
-
let filterFn: FilterFnOption<TData> = "includesString";
|
|
436
|
-
const currentFilterFn = header.column.columnDef.filterFn as string;
|
|
437
|
-
|
|
438
|
-
if (value?.toLowerCase() === "starts with") {
|
|
439
|
-
filterFn = currentFilterFn === "startsWith" ? "auto" : "startsWith";
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
if (value?.toLowerCase() === "ends with") {
|
|
443
|
-
filterFn = currentFilterFn === "endsWith" ? "auto" : "endsWith";
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
if (value?.toLowerCase() === "contains") {
|
|
447
|
-
filterFn =
|
|
448
|
-
currentFilterFn === "includesString" ? "auto" : "includesString";
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
header.column.columnDef.filterFn = filterFn;
|
|
452
|
-
header.column.setFilterValue(filter);
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
DataCellHeader.displayName = "DataCellHeader";
|
|
457
|
-
|
|
458
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
459
|
-
export function DraggableCellHeader<T extends Record<string, any>>({
|
|
460
|
-
header,
|
|
461
|
-
children,
|
|
462
|
-
...props
|
|
463
|
-
}: DataGridCellHeaderProps<T>) {
|
|
464
|
-
const { attributes, isDragging, listeners, setNodeRef, transform, node } =
|
|
465
|
-
useSortable({
|
|
466
|
-
id: header.column.id,
|
|
467
|
-
});
|
|
468
|
-
|
|
469
|
-
const style: CSSProperties = {
|
|
470
|
-
opacity: isDragging ? 0.8 : 1,
|
|
471
|
-
position: "relative",
|
|
472
|
-
transform: CSS.Translate.toString(transform),
|
|
473
|
-
transition: "width transform 0.2s ease-in-out",
|
|
474
|
-
whiteSpace: "nowrap",
|
|
475
|
-
zIndex: isDragging ? 1 : 0,
|
|
476
|
-
"--color-text-primary-normal": "var(--color-action-000)",
|
|
477
|
-
"--color-icon-on-action-primary-normal": "var(--color-action-000)",
|
|
478
|
-
userSelect: "none",
|
|
479
|
-
};
|
|
480
|
-
|
|
481
|
-
return (
|
|
482
|
-
<DataCellHeader
|
|
483
|
-
header={header}
|
|
484
|
-
setNodeRef={setNodeRef}
|
|
485
|
-
node={node}
|
|
486
|
-
style={style}
|
|
487
|
-
{...props}
|
|
488
|
-
{...attributes}
|
|
489
|
-
{...listeners}
|
|
490
|
-
>
|
|
491
|
-
{children}
|
|
492
|
-
</DataCellHeader>
|
|
493
|
-
);
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
DraggableCellHeader.displayName = "DraggableCellHeader";
|
|
497
|
-
|
|
498
|
-
export function DragAlongCell<T extends RowData, TValue>({
|
|
499
|
-
cell,
|
|
500
|
-
children,
|
|
501
|
-
...props
|
|
502
|
-
}: {
|
|
503
|
-
cell: Header<T, TValue> | Cell<T, TValue>;
|
|
504
|
-
children?: React.ReactNode;
|
|
505
|
-
} & DataGridCellProps) {
|
|
506
|
-
const { isDragging, setNodeRef, transform } = useSortable({
|
|
507
|
-
id: cell.column.id,
|
|
508
|
-
});
|
|
509
|
-
|
|
510
|
-
const style: CSSProperties = {
|
|
511
|
-
opacity: isDragging ? 0.8 : 1,
|
|
512
|
-
position: "relative",
|
|
513
|
-
transform: CSS.Translate.toString(transform),
|
|
514
|
-
transition: "width transform 0.2s ease-in-out",
|
|
515
|
-
minWidth: cell.column.getSize(),
|
|
516
|
-
zIndex: isDragging ? 1 : 0,
|
|
517
|
-
};
|
|
518
|
-
|
|
519
|
-
return (
|
|
520
|
-
<DataGridCell style={style} ref={setNodeRef} {...props}>
|
|
521
|
-
{children}
|
|
522
|
-
</DataGridCell>
|
|
523
|
-
);
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
DragAlongCell.displayName = "DragAlongCell";
|