@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.
Files changed (180) hide show
  1. package/dist/{chunk-U3QGZAVS.js → chunk-JADOJNBI.js} +4 -4
  2. package/dist/{chunk-N2KPADIL.js → chunk-WNGFRQ4Y.js} +7 -7
  3. package/dist/{chunk-ZVY3TLXL.js → chunk-ZIPJMN2E.js} +4 -4
  4. package/dist/components/Alert.js +2 -2
  5. package/dist/components/CalendarRange.js +10 -10
  6. package/dist/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.js +10 -10
  7. package/dist/components/DataGrid/ColumnSelectorHeaderCell/index.js +10 -10
  8. package/dist/components/DataGrid/PinnedColumns.js +10 -10
  9. package/dist/components/DataGrid/TableBody/LoadingCell.js +10 -10
  10. package/dist/components/DataGrid/TableBody/TableBodyRow.js +10 -10
  11. package/dist/components/DataGrid/TableBody/index.js +10 -10
  12. package/dist/components/DataGrid/index.js +10 -10
  13. package/dist/components/DataGrid/utils.js +10 -10
  14. package/dist/components/DateInput.js +10 -10
  15. package/dist/components/DateRangeInput.js +10 -10
  16. package/dist/components/FilterGroup.js +5 -5
  17. package/dist/components/MobileDataGrid/ColumnSelector/index.js +10 -10
  18. package/dist/components/MobileDataGrid/MobileDataGridHeader.js +10 -10
  19. package/dist/components/MobileDataGrid/RowDetailModalProvider/index.js +5 -5
  20. package/dist/components/MobileDataGrid/index.js +10 -10
  21. package/dist/components/Modal.js +4 -4
  22. package/dist/components/ModalButtons.js +2 -2
  23. package/dist/components/ModalHeader.js +2 -2
  24. package/dist/components/NavigationTab.js +2 -2
  25. package/dist/components/NavigationTabs.js +2 -2
  26. package/dist/components/NestedMenu.js +3 -3
  27. package/dist/components/Notification.js +3 -3
  28. package/dist/components/OptionPill.js +2 -2
  29. package/dist/components/PDFViewer/DownloadIcon.js +2 -2
  30. package/dist/components/PDFViewer/PDFNavigation.js +2 -2
  31. package/dist/components/PDFViewer/index.js +6 -6
  32. package/dist/components/ProductImagePreview/index.js +1 -1
  33. package/dist/components/Stepper.js +3 -3
  34. package/dist/components/Toast.js +3 -3
  35. package/dist/components/Upload.js +3 -3
  36. package/dist/components/index.js +16 -16
  37. package/package.json +8 -9
  38. package/src/brand.css +0 -125
  39. package/src/classNames.ts +0 -174
  40. package/src/components/AccessChangerTabItem.tsx +0 -71
  41. package/src/components/Accordion.tsx +0 -108
  42. package/src/components/Alert.tsx +0 -81
  43. package/src/components/Breadcrumbs.tsx +0 -142
  44. package/src/components/Button.tsx +0 -216
  45. package/src/components/CalendarRange.tsx +0 -628
  46. package/src/components/Caption.tsx +0 -144
  47. package/src/components/Card.tsx +0 -88
  48. package/src/components/Checkbox.tsx +0 -206
  49. package/src/components/CompactImagesPreview.tsx +0 -135
  50. package/src/components/ContentTab.tsx +0 -84
  51. package/src/components/ContentTabs.tsx +0 -136
  52. package/src/components/DMSiLogo.tsx +0 -33
  53. package/src/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.tsx +0 -35
  54. package/src/components/DataGrid/ColumnSelectorHeaderCell/index.tsx +0 -74
  55. package/src/components/DataGrid/PinnedColumns.tsx +0 -183
  56. package/src/components/DataGrid/TableBody/LoadingCell.tsx +0 -44
  57. package/src/components/DataGrid/TableBody/TableBodyRow.tsx +0 -157
  58. package/src/components/DataGrid/TableBody/index.tsx +0 -185
  59. package/src/components/DataGrid/index.tsx +0 -756
  60. package/src/components/DataGrid/types.ts +0 -98
  61. package/src/components/DataGrid/utils.tsx +0 -15
  62. package/src/components/DataGridCell.tsx +0 -526
  63. package/src/components/DataTable.tsx +0 -881
  64. package/src/components/DateInput.tsx +0 -306
  65. package/src/components/DateRangeInput.tsx +0 -758
  66. package/src/components/DebugJson.tsx +0 -28
  67. package/src/components/Display.tsx +0 -66
  68. package/src/components/EditingContext.tsx +0 -43
  69. package/src/components/EmptyCartIcon.tsx +0 -18
  70. package/src/components/FilterGroup.tsx +0 -264
  71. package/src/components/FullViewportBox.tsx +0 -19
  72. package/src/components/Grid.tsx +0 -97
  73. package/src/components/Heading.tsx +0 -72
  74. package/src/components/HorizontalDivider.tsx +0 -22
  75. package/src/components/Icon.tsx +0 -39
  76. package/src/components/ImagePlaceholder.tsx +0 -22
  77. package/src/components/Input.tsx +0 -609
  78. package/src/components/InputGroup.tsx +0 -59
  79. package/src/components/Label.tsx +0 -46
  80. package/src/components/Link.tsx +0 -117
  81. package/src/components/List.tsx +0 -18
  82. package/src/components/ListGroup.tsx +0 -82
  83. package/src/components/LiveChatComponent.tsx +0 -56
  84. package/src/components/LoadingScrim.tsx +0 -33
  85. package/src/components/LogoAgilityTopBar.tsx +0 -54
  86. package/src/components/LogoDMSiTopBar.tsx +0 -33
  87. package/src/components/LogoMillworkTopBar.tsx +0 -119
  88. package/src/components/MainBar.tsx +0 -91
  89. package/src/components/MaxViewportBox.tsx +0 -19
  90. package/src/components/Menu.tsx +0 -316
  91. package/src/components/MenuOption.tsx +0 -330
  92. package/src/components/MobileDataGrid/ColumnList.tsx +0 -66
  93. package/src/components/MobileDataGrid/ColumnSelector/index.tsx +0 -97
  94. package/src/components/MobileDataGrid/GridContextProvider/GridContext.tsx +0 -25
  95. package/src/components/MobileDataGrid/GridContextProvider/index.tsx +0 -132
  96. package/src/components/MobileDataGrid/GridContextProvider/useGridContext.ts +0 -10
  97. package/src/components/MobileDataGrid/MobileDataGridCard/MobileDataGridColumn.tsx +0 -27
  98. package/src/components/MobileDataGrid/MobileDataGridCard/index.tsx +0 -138
  99. package/src/components/MobileDataGrid/MobileDataGridHeader.tsx +0 -81
  100. package/src/components/MobileDataGrid/RowDetailModalProvider/ModalContent.tsx +0 -42
  101. package/src/components/MobileDataGrid/RowDetailModalProvider/index.tsx +0 -68
  102. package/src/components/MobileDataGrid/dataGridReducer.ts +0 -55
  103. package/src/components/MobileDataGrid/index.tsx +0 -92
  104. package/src/components/MobileDataGrid/types.ts +0 -4
  105. package/src/components/Modal.tsx +0 -312
  106. package/src/components/ModalButtons.tsx +0 -62
  107. package/src/components/ModalContent.tsx +0 -31
  108. package/src/components/ModalHeader.tsx +0 -78
  109. package/src/components/ModalScrim.tsx +0 -42
  110. package/src/components/NavigationTab.tsx +0 -95
  111. package/src/components/NavigationTabs.tsx +0 -70
  112. package/src/components/NestedMenu.tsx +0 -131
  113. package/src/components/Notification.tsx +0 -128
  114. package/src/components/OptionPill.tsx +0 -139
  115. package/src/components/OrderCheckIcon.tsx +0 -19
  116. package/src/components/PDFViewer/DownloadIcon.tsx +0 -25
  117. package/src/components/PDFViewer/PDFElement.tsx +0 -90
  118. package/src/components/PDFViewer/PDFNavigation.tsx +0 -68
  119. package/src/components/PDFViewer/PDFPage.tsx +0 -34
  120. package/src/components/PDFViewer/index.tsx +0 -128
  121. package/src/components/Pagination.tsx +0 -182
  122. package/src/components/Paragraph.tsx +0 -55
  123. package/src/components/Password.tsx +0 -62
  124. package/src/components/ProductImagePreview/CarouselPagination.tsx +0 -54
  125. package/src/components/ProductImagePreview/MobileImageCarousel.tsx +0 -226
  126. package/src/components/ProductImagePreview/ProductPrimaryImage.tsx +0 -219
  127. package/src/components/ProductImagePreview/Thumbnail.tsx +0 -55
  128. package/src/components/ProductImagePreview/ZoomWindow.tsx +0 -136
  129. package/src/components/ProductImagePreview/index.tsx +0 -182
  130. package/src/components/ProductImagePreview/useProductImagePreview.ts +0 -211
  131. package/src/components/ProjectBar.tsx +0 -82
  132. package/src/components/Radio.tsx +0 -146
  133. package/src/components/Search.tsx +0 -152
  134. package/src/components/SearchResultImage/index.tsx +0 -39
  135. package/src/components/Select.tsx +0 -114
  136. package/src/components/SideMenu.tsx +0 -30
  137. package/src/components/SideMenuGroup.tsx +0 -95
  138. package/src/components/SideMenuItem.tsx +0 -109
  139. package/src/components/SimpleTable.tsx +0 -77
  140. package/src/components/SkeletonParagraph.tsx +0 -31
  141. package/src/components/Spinner.tsx +0 -32
  142. package/src/components/Stack.tsx +0 -347
  143. package/src/components/StatusPill.tsx +0 -59
  144. package/src/components/Stepper.tsx +0 -128
  145. package/src/components/Subheader.tsx +0 -50
  146. package/src/components/Surface.tsx +0 -37
  147. package/src/components/Swatch.tsx +0 -1341
  148. package/src/components/Textarea.tsx +0 -102
  149. package/src/components/Theme.tsx +0 -27
  150. package/src/components/Time.tsx +0 -460
  151. package/src/components/Toast.tsx +0 -268
  152. package/src/components/Tooltip.tsx +0 -159
  153. package/src/components/TopBar.tsx +0 -139
  154. package/src/components/Upload.tsx +0 -107
  155. package/src/components/WorldpayIframe.tsx +0 -7
  156. package/src/components/index.ts +0 -34
  157. package/src/components/useMenuSystem.tsx +0 -456
  158. package/src/components/useMounted.tsx +0 -14
  159. package/src/darkmode.css +0 -278
  160. package/src/fonts.css +0 -23
  161. package/src/hooks/index.ts +0 -4
  162. package/src/hooks/useInfiniteScroll.tsx +0 -40
  163. package/src/hooks/useKeydown.ts +0 -42
  164. package/src/hooks/useMatchesMedia.ts +0 -18
  165. package/src/hooks/useTableLayout.ts +0 -106
  166. package/src/index.css +0 -800
  167. package/src/index.tsx +0 -5
  168. package/src/types.ts +0 -150
  169. package/src/utils/date.ts +0 -236
  170. package/src/utils/formatting.tsx +0 -81
  171. package/src/utils/index.ts +0 -4
  172. package/src/utils/mergeObjectArrays.ts +0 -18
  173. package/src/utils.ts +0 -24
  174. package/dist/{chunk-7FQ7PGUF.js → chunk-7COWXCPA.js} +3 -3
  175. package/dist/{chunk-NKCFYM7A.js → chunk-7SFFUICM.js} +3 -3
  176. package/dist/{chunk-25RZP3VR.js → chunk-AKJUBFJK.js} +3 -3
  177. package/dist/{chunk-TAPYQBQU.js → chunk-CMMQTIVM.js} +3 -3
  178. package/dist/{chunk-GYEXSNFP.js → chunk-FWCVZWE6.js} +3 -3
  179. package/dist/{chunk-MV6W7OMC.js → chunk-QMMPHXVE.js} +3 -3
  180. package/dist/{chunk-GG5OZTI5.js → chunk-XRE52QTN.js} +3 -3
@@ -1,136 +0,0 @@
1
- "use client";
2
- import clsx from "clsx";
3
- import { ReactNode, useState, useRef, useCallback, useEffect } from "react";
4
- import { ContentTab } from "./ContentTab";
5
-
6
- type Tab = {
7
- id: string;
8
- label: string;
9
- content?: ReactNode;
10
- disabled?: boolean;
11
- };
12
-
13
- export type SelectedTab = Omit<Tab, "content" | "label"> & {
14
- index: number;
15
- };
16
-
17
- export type ContentTabsProps = {
18
- tabs: Tab[];
19
- onTabChange?: (tabId: string) => void;
20
- fullWidthTabs?: boolean;
21
- id?: string;
22
- testid?: string;
23
- selectedTab?: SelectedTab | null;
24
- contentPadding?: boolean;
25
- };
26
-
27
- const afterClasses =
28
- "after:absolute after:bottom-0 after:left-0 after:w-full after:h-0.5 after:bg-border-primary-normal z-0";
29
-
30
- export const ContentTabs = ({
31
- tabs,
32
- onTabChange,
33
- fullWidthTabs,
34
- id,
35
- testid,
36
- selectedTab,
37
- contentPadding = true,
38
- }: ContentTabsProps) => {
39
- const [selectedTabId, setSelectedTabId] = useState<string>(tabs[0]?.id || "");
40
- const [focusedTabIndex, setFocusedTabIndex] = useState<number>(0);
41
- const tabRefs = useRef<(HTMLButtonElement | null)[]>([]);
42
-
43
- const handleTabClick = useCallback(
44
- (id: string, index: number) => {
45
- setSelectedTabId(id);
46
- setFocusedTabIndex(index);
47
- onTabChange?.(id);
48
- },
49
- [onTabChange],
50
- );
51
-
52
- useEffect(() => {
53
- if (selectedTab) {
54
- handleTabClick(selectedTab.id, selectedTab.index);
55
- }
56
- }, [selectedTab, handleTabClick]);
57
-
58
- const handleKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {
59
- let newIndex = focusedTabIndex;
60
- if (e.key === "ArrowRight") {
61
- e.preventDefault();
62
- newIndex = (focusedTabIndex + 1) % tabs.length;
63
- } else if (e.key === "ArrowLeft") {
64
- e.preventDefault();
65
- newIndex = (focusedTabIndex - 1 + tabs.length) % tabs.length;
66
- } else {
67
- return;
68
- }
69
- const tabId = tabs[newIndex].id;
70
- setSelectedTabId(tabId);
71
- onTabChange?.(tabId);
72
- tabRefs.current[newIndex]?.focus();
73
- setFocusedTabIndex(newIndex);
74
- };
75
-
76
- const selectedContent = tabs.find((tab) => tab.id === selectedTabId)?.content;
77
-
78
- return (
79
- <div id={id} data-testid={testid}>
80
- <div className={clsx("overflow-x-auto", contentPadding && "pb-2")}>
81
- <div
82
- id={id ? `${id}-tablist` : undefined}
83
- data-testid={testid ? `${testid}-tablist` : undefined}
84
- role="tablist"
85
- aria-orientation="horizontal"
86
- className={clsx("flex relative", afterClasses)}
87
- onKeyDown={handleKeyDown}
88
- >
89
- {tabs.map((tab, index) => {
90
- const isSelected = selectedTabId === tab.id;
91
- return (
92
- <ContentTab
93
- disabled={tab.disabled}
94
- fullWidth={fullWidthTabs}
95
- key={tab.id}
96
- id={id ? `${id}-tab-${tab.id}` : undefined}
97
- testid={testid ? `${testid}-tab-${tab.id}` : undefined}
98
- label={tab.label}
99
- selected={isSelected}
100
- onClick={() => handleTabClick(tab.id, index)}
101
- onFocus={() => {
102
- setSelectedTabId(tab.id);
103
-
104
- setFocusedTabIndex(index);
105
- onTabChange?.(tab.id);
106
- }}
107
- className={clsx(!isSelected && afterClasses)}
108
- role="tab"
109
- aria-selected={isSelected}
110
- aria-controls={`${id ? `${id}-` : ""}panel-${tab.id}`}
111
- tabIndex={isSelected ? 0 : -1}
112
- ref={(el) => {
113
- tabRefs.current[index] = el;
114
- }}
115
- />
116
- );
117
- })}
118
- </div>
119
- </div>
120
- {selectedContent && (
121
- <div
122
- id={(id ? `${id}-` : "") + `panel-${selectedTabId}`}
123
- data-testid={(testid ? `${testid}-` : "") + `panel-${selectedTabId}`}
124
- className="mt-2"
125
- role="tabpanel"
126
- aria-labelledby={`tab-${selectedTabId}`}
127
- tabIndex={0}
128
- >
129
- {selectedContent}
130
- </div>
131
- )}
132
- </div>
133
- );
134
- };
135
-
136
- ContentTabs.displayName = "ContentTabs";
@@ -1,33 +0,0 @@
1
- export function DMSiLogo(props: React.SVGProps<SVGSVGElement>) {
2
- return (
3
- <svg
4
- width="107"
5
- height="24"
6
- viewBox="0 0 107 24"
7
- fill="none"
8
- xmlns="http://www.w3.org/2000/svg"
9
- {...props}
10
- >
11
- <path
12
- d="M10.1472 5.86855H22.261C24.0328 5.86855 25.2192 5.79792 26.2514 7.25517C27.1489 8.60833 27.4185 9.79792 27.2105 11.4336C27.0025 13.0693 26.5596 14.2291 25.4926 15.6529C24.9996 16.3295 24.3795 16.8648 23.6284 17.2552C22.6077 17.7533 21.9529 17.6827 20.9206 17.6827H8.69893V17.6381L8.00562 23.2589H20.7704C24.2755 23.2589 27.6496 22.5228 30.4807 19.9949C33.0999 17.6827 34.6444 14.8128 35.0489 11.612C35.4918 8.12506 34.6406 5.72357 32.2948 3.3035C29.8875 0.775615 26.8793 0.362976 23.2278 0.362976H10.8328L10.1472 5.92803V5.86855Z"
13
- fill="#1D1E1E"
14
- />
15
- <path
16
- d="M45.7143 0.960477L45.3484 3.9233L45.437 3.64077C46.9276 1.46605 49.2772 0.618469 51.8771 0.618469C54.6042 0.618469 56.3567 1.62219 57.4082 3.91958C59.2263 1.53668 61.5527 0.618469 64.4531 0.618469C66.3135 0.618469 67.9544 1.16122 69.0868 2.45862C70.485 4.04598 70.2192 6.1352 69.9342 8.3917L68.0083 23.2356H60.5705L62.3462 9.28018C62.5234 7.901 62.5041 6.35453 60.5128 6.35453C58.0862 6.35453 57.6085 8.52925 57.389 10.2393L55.7366 23.2319H48.2025L49.9782 9.27646C50.1477 7.93817 49.9897 6.22442 48.1255 6.22442C46.0918 6.22442 45.4408 7.6891 45.2367 9.27646L43.461 23.2319H35.3453L38.2072 0.960477H45.7143Z"
17
- fill="#1D1E1E"
18
- />
19
- <path
20
- d="M97.4234 0.336578L96.6954 6.39234H103.474L96.2755 9.54104L94.5076 23.2734H103.255L106.175 0.336578H97.4234Z"
21
- fill="#1D1E1E"
22
- />
23
- <path
24
- d="M91.03 10.4126C89.3545 9.34573 86.6082 9.04833 84.6092 8.79182C83.9158 8.70632 83.1339 8.49814 82.4059 8.29368C82.1286 8.23792 81.8705 8.16729 81.6317 8.07807C81.5431 8.05204 81.443 8.02231 81.3583 8C81.1618 7.95539 80.9461 7.81041 80.7535 7.61338C80.353 7.30855 80.1141 6.94424 80.1141 6.54647C80.1141 6.35688 80.1835 6.17844 80.2836 6.00372C80.2952 5.98513 80.3029 5.97026 80.3144 5.95167C80.7921 5.20446 82.1248 4.66543 83.7117 4.66543C85.626 4.66543 87.1821 5.44981 87.29 6.43866H94.7393C93.7571 2.34572 89.0772 0 84.8326 0C82.3135 0 79.1204 0.342007 76.7439 1.66171C74.4598 2.94052 72.8228 4.66914 72.5069 7.14126C71.7674 12.9405 77.1945 14.026 81.8436 14.6654C82.1017 14.6952 82.6062 14.8141 83.157 15.0037C84.5976 15.2974 85.6183 16.026 85.6183 16.8848C85.6183 17.8773 84.2509 18.6989 82.4522 18.8699C82.2442 18.9145 82.0593 18.9368 81.9168 18.9368C80.7689 18.9368 79.987 18.8625 79.4131 18.487C78.689 18.197 78.1613 17.777 77.9726 17.29H70.165C71.205 22.3234 75.8387 24 80.534 24C85.6145 24 92.6747 22.2491 93.4412 16.2342C93.6801 14.3494 93.0099 11.7286 91.0378 10.4089L91.03 10.4126Z"
25
- fill="#1D1E1E"
26
- />
27
- <path
28
- d="M1.85771 9.54941H16.9027L0.825439 16.9174L1.85771 9.54941Z"
29
- fill="#0077C8"
30
- />
31
- </svg>
32
- );
33
- }
@@ -1,35 +0,0 @@
1
- import { Column } from "@tanstack/react-table";
2
- import { useState } from "react";
3
- import { Checkbox, MenuOption } from "../..";
4
-
5
- export function ColumnSelectorMenuOption<T>({
6
- id,
7
- testid,
8
- column,
9
- toggleColumnVisibility,
10
- }: {
11
- id?: string;
12
- testid?: string;
13
- column: Column<T, unknown>;
14
- toggleColumnVisibility: (id: string, isVisible: boolean) => void;
15
- }) {
16
- const [isVisible, setIsVisible] = useState(column.getIsVisible());
17
- const label =
18
- typeof column.columnDef.header === "string"
19
- ? column.columnDef.header
20
- : null;
21
- return (
22
- <MenuOption id={id} testid={testid} defaultChecked={isVisible}>
23
- <Checkbox
24
- id={id ? `${id}-checkbox` : undefined}
25
- testid={testid ? `${testid}-checkbox` : undefined}
26
- label={label ?? "Unknown"}
27
- checked={isVisible}
28
- onChange={(e) => {
29
- setIsVisible(e.target.checked);
30
- toggleColumnVisibility(column.id, e.target.checked);
31
- }}
32
- />
33
- </MenuOption>
34
- );
35
- }
@@ -1,74 +0,0 @@
1
- import { Table } from "@tanstack/react-table";
2
- import { useRef, useState } from "react";
3
- import { Button, DataGridCell, Icon, Menu } from "../..";
4
- import { ColumnSelectorMenuOption } from "./ColumnSelectorMenuOption";
5
-
6
- export function ColumnSelectorHeaderCell<T>({
7
- id,
8
- testid,
9
- table,
10
- toggleColumnVisibility,
11
- resetColumnVisibility,
12
- }: {
13
- id?: string;
14
- testid?: string;
15
- table: Table<T>;
16
- toggleColumnVisibility: (id: string, isVisible: boolean) => void;
17
- resetColumnVisibility: () => void;
18
- }) {
19
- const ref = useRef<HTMLElement>(null);
20
- const [show, setShow] = useState(false);
21
-
22
- return (
23
- <DataGridCell
24
- id={id}
25
- testid={testid}
26
- width="48px"
27
- type="header"
28
- color="text-secondary-normal"
29
- ref={ref}
30
- >
31
- <Button
32
- id={id ? `${id}-button` : undefined}
33
- testid={testid ? `${testid}-button` : undefined}
34
- onClick={() => setShow((prev) => !prev)}
35
- variant="navigation"
36
- iconOnly
37
- leftIcon={<Icon name="tune" />}
38
- ></Button>
39
- <Menu
40
- id={id ? `${id}-menu` : undefined}
41
- testid={testid ? `${testid}-menu` : undefined}
42
- positionTo={ref}
43
- position="bottom-right"
44
- show={show}
45
- setShow={setShow}
46
- calculateMinMaxHeight
47
- >
48
- <Button
49
- id={id ? `${id}-reset-button` : undefined}
50
- testid={testid ? `${testid}-reset-button` : undefined}
51
- variant="tertiary"
52
- onClick={() => {
53
- resetColumnVisibility();
54
- setShow(false);
55
- }}
56
- >
57
- Reset to default
58
- </Button>
59
- {table
60
- .getAllColumns()
61
- .filter((x) => x.columnDef.meta?.inVisibilityMenu)
62
- .map((column) => (
63
- <ColumnSelectorMenuOption
64
- id={id ? `${id}-option-${column.id}` : undefined}
65
- testid={testid ? `${testid}-option-${column.id}` : undefined}
66
- key={column.id}
67
- column={column}
68
- toggleColumnVisibility={toggleColumnVisibility}
69
- />
70
- ))}
71
- </Menu>
72
- </DataGridCell>
73
- );
74
- }
@@ -1,183 +0,0 @@
1
- import { flexRender, RowData, Table } from "@tanstack/react-table";
2
- import { Checkbox, DataCellHeader, DataGridCell, Subheader } from "..";
3
- import { DataGridPagination } from "./types";
4
- import clsx from "clsx";
5
- import { getSortIcon } from "./utils";
6
- import React from "react";
7
- import { TableBody } from "./TableBody";
8
- import { ColumnSelectorHeaderCell } from "./ColumnSelectorHeaderCell";
9
- interface PinnedColumnsProps<TData extends RowData> {
10
- id?: string;
11
-
12
- toggleColumnVisibility?: (columnId: string, isVisible: boolean) => void;
13
- resetColumnVisibility?: () => void;
14
-
15
- pinDirection: "left" | "right";
16
- table: Table<TData>;
17
- tableContainerRef: React.RefObject<HTMLDivElement | null>;
18
- pagination: DataGridPagination | undefined;
19
- isLoadingMore: boolean;
20
- hasMore: boolean;
21
- showFilterRow: boolean;
22
- enableColumnSelector?: boolean;
23
- centerHeader?: boolean;
24
- allSelectedAcrossPages?: boolean;
25
- someSelectedAcrossPages?: boolean;
26
- toggleSelectAllAcrossPages?: () => void;
27
- testid?: string;
28
- }
29
-
30
- export function PinnedColumns<TData>({
31
- id,
32
- pinDirection = "left",
33
- table,
34
- centerHeader,
35
- allSelectedAcrossPages,
36
- someSelectedAcrossPages,
37
- toggleSelectAllAcrossPages,
38
- testid,
39
- enableColumnSelector,
40
- toggleColumnVisibility,
41
- resetColumnVisibility,
42
- ...props
43
- }: PinnedColumnsProps<TData>) {
44
- const headerGroups =
45
- pinDirection === "left"
46
- ? table.getLeftHeaderGroups()
47
- : table.getRightHeaderGroups();
48
-
49
- const pinnedTestId = testid ? `${pinDirection}-pinned-${testid}` : undefined;
50
-
51
- const hasAnyHeaders = headerGroups[0]?.headers.length > 0;
52
-
53
- if (!hasAnyHeaders && !enableColumnSelector) return;
54
-
55
- return (
56
- <table
57
- className={clsx(
58
- "flex flex-col min-h-min sticky z-20",
59
- pinDirection === "left" ? "left-0" : "right-0",
60
- )}
61
- data-testid={pinnedTestId}
62
- >
63
- <thead className="sticky top-0 z-20 grid">
64
- {headerGroups.map((headerGroup) => {
65
- return (
66
- <tr
67
- key={headerGroup.id}
68
- data-testid={
69
- pinnedTestId
70
- ? `${pinnedTestId}-header-row-${headerGroup.id}`
71
- : undefined
72
- }
73
- className="flex w-full"
74
- >
75
- {headerGroup.headers.map((header) => {
76
- if (!header) {
77
- return;
78
- }
79
-
80
- if (typeof header.column.columnDef.header === "string") {
81
- const customHeaderWidth =
82
- header.column.columnDef.meta?.headerWidth;
83
-
84
- return (
85
- <DataCellHeader
86
- locked
87
- key={header.id}
88
- testid={
89
- pinnedTestId
90
- ? `${pinnedTestId}-header-${header.id}`
91
- : undefined
92
- }
93
- header={header}
94
- center={centerHeader}
95
- width={customHeaderWidth}
96
- className={clsx(
97
- header.column.getCanSort()
98
- ? "cursor-pointer"
99
- : "cursor-grab",
100
- "group",
101
- )}
102
- >
103
- <Subheader tall>
104
- {header.column.columnDef.header}
105
- </Subheader>
106
-
107
- {getSortIcon(header.column.getIsSorted())}
108
-
109
- {!header.column.getIsSorted() &&
110
- header.column.getCanSort() &&
111
- getSortIcon(header.column.getNextSortingOrder(), true)}
112
-
113
- {header.column.getSortIndex() !== -1 &&
114
- table.getState().sorting.length > 1 && (
115
- <Subheader tall>
116
- {header.column.getSortIndex() + 1}
117
- </Subheader>
118
- )}
119
-
120
- {!header.column.columnDef.meta?.locked && (
121
- <div
122
- onDoubleClick={(e) => {
123
- e.stopPropagation();
124
- header.column.resetSize();
125
- }}
126
- onMouseDown={(e) => {
127
- e.stopPropagation();
128
- header.getResizeHandler()(e);
129
- }}
130
- onTouchStart={(e) => {
131
- e.stopPropagation();
132
- header.getResizeHandler()(e);
133
- }}
134
- className="absolute right-0 inset-y-0 w-px bg-black cursor-col-resize"
135
- />
136
- )}
137
- </DataCellHeader>
138
- );
139
- }
140
- return (
141
- <React.Fragment key={header.id}>
142
- {header.column.columnDef.meta?.checkbox ? (
143
- <DataGridCell type="header" component="checkbox" locked>
144
- <Checkbox
145
- checked={allSelectedAcrossPages}
146
- indeterminate={someSelectedAcrossPages}
147
- onChange={toggleSelectAllAcrossPages}
148
- />
149
- </DataGridCell>
150
- ) : (
151
- flexRender(
152
- header.column.columnDef.header,
153
- header.getContext(),
154
- )
155
- )}
156
- </React.Fragment>
157
- );
158
- })}
159
-
160
- {enableColumnSelector && (
161
- <ColumnSelectorHeaderCell
162
- id={id ? `${id}-column-selector` : undefined}
163
- testid={testid ? `${testid}-column-selector` : undefined}
164
- table={table}
165
- toggleColumnVisibility={toggleColumnVisibility ?? (() => {})}
166
- resetColumnVisibility={resetColumnVisibility ?? (() => {})}
167
- />
168
- )}
169
- </tr>
170
- );
171
- })}
172
- </thead>
173
-
174
- <TableBody
175
- testid={pinnedTestId}
176
- {...props}
177
- table={table}
178
- locked={!enableColumnSelector}
179
- pinDirection={pinDirection}
180
- />
181
- </table>
182
- );
183
- }
@@ -1,44 +0,0 @@
1
- import { ColumnDef, RowData } from "@tanstack/react-table";
2
- import { Checkbox, DataGridCell, Input } from "../..";
3
-
4
- export function LoadingCell<T extends RowData>({
5
- id,
6
- testid,
7
- column,
8
- }: {
9
- id?: string;
10
- testid?: string;
11
- column: ColumnDef<T>;
12
- }) {
13
- const key = `loading-${column.id}`;
14
- if (column.cell === "checkbox") {
15
- return (
16
- <DataGridCell id={id ? `${id}-${key}` : undefined} testid={testid ? `${testid}-${key}` : undefined} key={key}>
17
- <Checkbox id={id ? `${id}-${key}-checkbox` : undefined} testid={testid ? `${testid}-${key}-checkbox` : undefined} disabled />
18
- </DataGridCell>
19
- );
20
- }
21
- if (column.cell === "input") {
22
- return (
23
- <DataGridCell
24
- id={id ? `${id}-${key}` : undefined}
25
- testid={testid ? `${testid}-${key}` : undefined}
26
- key={key}
27
- component="input"
28
- >
29
- <Input
30
- id={id ? `${id}-${key}-input` : undefined}
31
- testid={testid ? `${testid}-${key}-input` : undefined}
32
- align="left"
33
- disabled
34
- wrapperClassName="!rounded-none !border-0"
35
- />
36
- </DataGridCell>
37
- );
38
- }
39
- return (
40
- <DataGridCell id={id ? `${id}-${key}` : undefined} testid={testid ? `${testid}-${key}` : undefined} key={key}>
41
- <div className="bg-linear-270 to-neutral-300/[24%] from-neutral-300/[12%] rounded-xs w-full max-w-25 h-6"></div>
42
- </DataGridCell>
43
- );
44
- }
@@ -1,157 +0,0 @@
1
- import clsx from "clsx";
2
- import { Cell, flexRender, Row } from "@tanstack/react-table";
3
- import { VirtualItem, Virtualizer } from "@tanstack/react-virtual";
4
- import React from "react";
5
- import { DataGridCell, DragAlongCell, Paragraph, Tooltip } from "../..";
6
- import { formatCurrencyDisplay, formatDate } from "../../../utils";
7
-
8
- const valueFormatters = {
9
- date: (value: unknown) =>
10
- typeof value === "string" ? formatDate(value) : "",
11
- currency: (value: unknown) => formatCurrencyDisplay(value as string),
12
- };
13
-
14
- type ValueFormatterKey = keyof typeof valueFormatters;
15
-
16
- function isValueFormatterKey(value: unknown): value is ValueFormatterKey {
17
- return typeof value === "string" && value in valueFormatters;
18
- }
19
-
20
- interface TableBodyRowProps<T> {
21
- id?: string;
22
- testid?: string;
23
- columnVirtualizer?: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
24
- row: Row<T>;
25
- rowVirtualizer: Virtualizer<HTMLDivElement, HTMLTableRowElement>;
26
- virtualPaddingLeft?: number | undefined;
27
- virtualPaddingRight?: number | undefined;
28
- virtualRow: VirtualItem;
29
- showFilterRow: boolean;
30
- enableColumnSelector?: boolean;
31
- locked?: boolean;
32
- pinDirection?: "left" | "right";
33
- disabled?: boolean;
34
- }
35
-
36
- export function TableBodyRow<T>({
37
- id,
38
- testid,
39
- columnVirtualizer,
40
- row,
41
- // rowVirtualizer,
42
- virtualPaddingLeft,
43
- virtualPaddingRight,
44
- virtualRow,
45
- showFilterRow,
46
- // enableColumnSelector = false,
47
- locked,
48
- pinDirection,
49
- disabled,
50
- }: TableBodyRowProps<T>) {
51
- let visibleCells: Cell<T, unknown>[];
52
-
53
- if (locked) {
54
- visibleCells =
55
- pinDirection === "left"
56
- ? row.getLeftVisibleCells()
57
- : row.getRightVisibleCells();
58
- } else {
59
- visibleCells = row.getCenterVisibleCells();
60
- }
61
-
62
- const virtualColumns = columnVirtualizer?.getVirtualItems() ?? [];
63
- const columns = locked ? visibleCells : virtualColumns;
64
-
65
- const isError =
66
- typeof row.original === "object" &&
67
- row.original !== null &&
68
- "rowState" in row.original &&
69
- row.original.rowState === "error";
70
-
71
- const CellElement = locked ? DataGridCell : DragAlongCell;
72
-
73
- return (
74
- <tr
75
- key={row.id}
76
- className={clsx(
77
- "min-h-10",
78
- "transition-colors",
79
- !disabled && "hover:bg-background-action-secondary-hover",
80
- row.getIsSelected() && !disabled && "!bg-background-action-secondary-hover",
81
- isError && !disabled && "!bg-background-action-critical-secondary-hover",
82
- showFilterRow && !disabled
83
- ? "even:bg-background-grouped-primary-normal odd:bg-background-grouped-secondary-normal"
84
- : "odd:bg-background-grouped-primary-normal even:bg-background-grouped-secondary-normal",
85
- )}
86
- id={id ? `${id}-row-${row.id}` : undefined}
87
- data-testid={testid ? `${testid}-row-${row.id}` : undefined}
88
- style={{
89
- display: "flex",
90
- position: "absolute",
91
- transform: `translateY(${
92
- showFilterRow ? virtualRow.start + 40 : virtualRow.start
93
- }px)`,
94
- width: "100%",
95
- }}
96
- >
97
- {!locked && virtualPaddingLeft ? (
98
- // fake empty column to the left for virtualization scroll padding
99
- <td style={{ display: "flex", width: virtualPaddingLeft }} />
100
- ) : null}
101
- {columns.map((column) => {
102
- const cell = locked
103
- ? (column as Cell<T, unknown>)
104
- : visibleCells[(column as VirtualItem).index];
105
-
106
- if (!cell) {
107
- return;
108
- }
109
- const cellFormat = cell.column.columnDef.meta?.format;
110
-
111
- const cellValue =
112
- cellFormat && isValueFormatterKey(cellFormat)
113
- ? valueFormatters[cellFormat](cell.getValue())
114
- : cell.getValue();
115
-
116
- const cellAlignment =
117
- cell.column.columnDef.meta?.align ??
118
- (typeof cellValue === "number" ? "right" : "left");
119
-
120
- return cell.column.columnDef.meta?.useCustomRenderer ? (
121
- <React.Fragment key={cell.id}>
122
- {flexRender(cell.column.columnDef.cell, cell.getContext())}
123
- </React.Fragment>
124
- ) : (
125
- <CellElement
126
- key={cell.id}
127
- id={id ? `${id}-row-${row.id}-cell-${cell.id}` : undefined}
128
- testid={
129
- testid ? `${testid}-row-${row.id}-cell-${cell.id}` : undefined
130
- }
131
- cell={cell}
132
- className={clsx({
133
- "justify-start": cellAlignment === "left",
134
- "justify-end": cellAlignment === "right",
135
- })}
136
- >
137
- <Tooltip
138
- id={id ? `${id}-tooltip-${cell.id}` : undefined}
139
- testid={testid ? `${testid}-tooltip-${cell.id}` : undefined}
140
- showOnTruncation
141
- message={cellValue as string}
142
- position="bottom"
143
- >
144
- <Paragraph addOverflow tall>
145
- {cellValue as React.ReactNode | string}
146
- </Paragraph>
147
- </Tooltip>
148
- </CellElement>
149
- );
150
- })}
151
- {!locked && virtualPaddingRight ? (
152
- // fake empty column to the right for virtualization scroll padding
153
- <td style={{ display: "flex", width: virtualPaddingRight }} />
154
- ) : null}
155
- </tr>
156
- );
157
- }