@dmsi/wedgekit-react 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (263) hide show
  1. package/README.md +35 -0
  2. package/dist/chunk-27KIIUAR.js +59 -0
  3. package/dist/chunk-2G2E2JMA.js +123 -0
  4. package/dist/chunk-4C66DLIJ.js +51 -0
  5. package/dist/chunk-4RD5ZF2V.js +55 -0
  6. package/dist/chunk-4RJKB7LC.js +14 -0
  7. package/dist/chunk-4T7F5BZZ.js +26 -0
  8. package/dist/chunk-5GOBP2JS.js +53 -0
  9. package/dist/chunk-6ZY524ID.js +42 -0
  10. package/dist/chunk-AWQSSKCK.js +32 -0
  11. package/dist/chunk-BNHSAFMP.js +93 -0
  12. package/dist/chunk-BWRHL2AG.js +439 -0
  13. package/dist/chunk-DKKYR6DS.js +132 -0
  14. package/dist/chunk-E5ALT5W7.js +182 -0
  15. package/dist/chunk-FY7PTP6E.js +322 -0
  16. package/dist/chunk-GTCSRHPF.js +119 -0
  17. package/dist/chunk-I2UVVKQI.js +12 -0
  18. package/dist/chunk-IGQVA7SC.js +41 -0
  19. package/dist/chunk-K3IKUSZW.js +59 -0
  20. package/dist/chunk-KENSVWOY.js +151 -0
  21. package/dist/chunk-KX3O6GJ6.js +138 -0
  22. package/dist/chunk-L4UM372R.js +253 -0
  23. package/dist/chunk-ORMEWXMH.js +37 -0
  24. package/dist/chunk-Q3FKEKIN.js +23 -0
  25. package/dist/chunk-SEKKGFM6.js +28 -0
  26. package/dist/chunk-SY3HT54E.js +91 -0
  27. package/dist/chunk-TAW5ZZ4Z.js +346 -0
  28. package/dist/chunk-TRUPPHBQ.js +109 -0
  29. package/dist/chunk-TU55CHXU.js +30 -0
  30. package/dist/chunk-TWZZB4WO.js +114 -0
  31. package/dist/chunk-TYI74BSP.js +62 -0
  32. package/dist/chunk-U42SKNR6.js +104 -0
  33. package/dist/chunk-UU3FA6LV.js +72 -0
  34. package/dist/chunk-WVUIIBRR.js +51 -0
  35. package/dist/chunk-XUIPGYP5.js +39 -0
  36. package/dist/chunk-Z4UCFUF7.js +299 -0
  37. package/dist/components/Breadcrumbs.cjs +376 -0
  38. package/dist/components/Breadcrumbs.js +90 -0
  39. package/dist/components/Button.cjs +319 -0
  40. package/dist/components/Button.js +8 -0
  41. package/dist/components/CalendarRange.cjs +520 -0
  42. package/dist/components/CalendarRange.js +13 -0
  43. package/dist/components/Caption.cjs +283 -0
  44. package/dist/components/Caption.js +80 -0
  45. package/dist/components/Checkbox.cjs +378 -0
  46. package/dist/components/Checkbox.js +11 -0
  47. package/dist/components/ContentTab.cjs +382 -0
  48. package/dist/components/ContentTab.js +10 -0
  49. package/dist/components/ContentTabs.cjs +472 -0
  50. package/dist/components/ContentTabs.js +98 -0
  51. package/dist/components/DMSiLogo.cjs +79 -0
  52. package/dist/components/DMSiLogo.js +56 -0
  53. package/dist/components/DataGrid.cjs +3113 -0
  54. package/dist/components/DataGrid.js +758 -0
  55. package/dist/components/DataGridCell.cjs +1907 -0
  56. package/dist/components/DataGridCell.js +24 -0
  57. package/dist/components/DataTable.cjs +791 -0
  58. package/dist/components/DataTable.js +720 -0
  59. package/dist/components/DateInput.cjs +1130 -0
  60. package/dist/components/DateInput.js +170 -0
  61. package/dist/components/DateRangeInput.cjs +1131 -0
  62. package/dist/components/DateRangeInput.js +171 -0
  63. package/dist/components/DebugJson.cjs +50 -0
  64. package/dist/components/DebugJson.js +27 -0
  65. package/dist/components/Display.cjs +234 -0
  66. package/dist/components/Display.js +12 -0
  67. package/dist/components/EditingContext.cjs +73 -0
  68. package/dist/components/EditingContext.js +35 -0
  69. package/dist/components/FilterGroup.cjs +1431 -0
  70. package/dist/components/FilterGroup.js +231 -0
  71. package/dist/components/FullViewportBox.cjs +35 -0
  72. package/dist/components/FullViewportBox.js +12 -0
  73. package/dist/components/Grid.cjs +69 -0
  74. package/dist/components/Grid.js +36 -0
  75. package/dist/components/GridContainer.cjs +125 -0
  76. package/dist/components/GridContainer.js +92 -0
  77. package/dist/components/Heading.cjs +238 -0
  78. package/dist/components/Heading.js +14 -0
  79. package/dist/components/HorizontalDivider.cjs +33 -0
  80. package/dist/components/HorizontalDivider.js +10 -0
  81. package/dist/components/Icon.cjs +98 -0
  82. package/dist/components/Icon.js +7 -0
  83. package/dist/components/Input.cjs +672 -0
  84. package/dist/components/Input.js +21 -0
  85. package/dist/components/InputGroup.cjs +270 -0
  86. package/dist/components/InputGroup.js +60 -0
  87. package/dist/components/Label.cjs +223 -0
  88. package/dist/components/Label.js +8 -0
  89. package/dist/components/Link.cjs +262 -0
  90. package/dist/components/Link.js +8 -0
  91. package/dist/components/List.cjs +37 -0
  92. package/dist/components/List.js +14 -0
  93. package/dist/components/LiveChatComponent.cjs +63 -0
  94. package/dist/components/LiveChatComponent.js +40 -0
  95. package/dist/components/LogoAgilityTopBar.cjs +115 -0
  96. package/dist/components/LogoAgilityTopBar.js +92 -0
  97. package/dist/components/LogoDMSiTopBar.cjs +79 -0
  98. package/dist/components/LogoDMSiTopBar.js +7 -0
  99. package/dist/components/LogoMillworkTopBar.cjs +221 -0
  100. package/dist/components/LogoMillworkTopBar.js +198 -0
  101. package/dist/components/MainBar.cjs +211 -0
  102. package/dist/components/MainBar.js +65 -0
  103. package/dist/components/Menu.cjs +437 -0
  104. package/dist/components/Menu.js +11 -0
  105. package/dist/components/MenuOption.cjs +483 -0
  106. package/dist/components/MenuOption.js +13 -0
  107. package/dist/components/MobileDataGrid.cjs +658 -0
  108. package/dist/components/MobileDataGrid.js +125 -0
  109. package/dist/components/Modal.cjs +783 -0
  110. package/dist/components/Modal.js +245 -0
  111. package/dist/components/ModalButtons.cjs +385 -0
  112. package/dist/components/ModalButtons.js +10 -0
  113. package/dist/components/ModalContent.cjs +57 -0
  114. package/dist/components/ModalContent.js +7 -0
  115. package/dist/components/ModalHeader.cjs +426 -0
  116. package/dist/components/ModalHeader.js +11 -0
  117. package/dist/components/ModalScrim.cjs +64 -0
  118. package/dist/components/ModalScrim.js +7 -0
  119. package/dist/components/NavigationTab.cjs +431 -0
  120. package/dist/components/NavigationTab.js +10 -0
  121. package/dist/components/NavigationTabs.cjs +477 -0
  122. package/dist/components/NavigationTabs.js +56 -0
  123. package/dist/components/Notification.cjs +640 -0
  124. package/dist/components/Notification.js +117 -0
  125. package/dist/components/OptionPill.cjs +478 -0
  126. package/dist/components/OptionPill.js +11 -0
  127. package/dist/components/Paragraph.cjs +231 -0
  128. package/dist/components/Paragraph.js +8 -0
  129. package/dist/components/Password.cjs +700 -0
  130. package/dist/components/Password.js +53 -0
  131. package/dist/components/ProjectBar.cjs +242 -0
  132. package/dist/components/ProjectBar.js +63 -0
  133. package/dist/components/Radio.cjs +349 -0
  134. package/dist/components/Radio.js +131 -0
  135. package/dist/components/Search.cjs +767 -0
  136. package/dist/components/Search.js +12 -0
  137. package/dist/components/Select.cjs +758 -0
  138. package/dist/components/Select.js +12 -0
  139. package/dist/components/SideMenu.cjs +54 -0
  140. package/dist/components/SideMenu.js +21 -0
  141. package/dist/components/SideMenuGroup.cjs +422 -0
  142. package/dist/components/SideMenuGroup.js +83 -0
  143. package/dist/components/SideMenuItem.cjs +388 -0
  144. package/dist/components/SideMenuItem.js +70 -0
  145. package/dist/components/Stack.cjs +138 -0
  146. package/dist/components/Stack.js +7 -0
  147. package/dist/components/StatusPill.cjs +265 -0
  148. package/dist/components/StatusPill.js +52 -0
  149. package/dist/components/Stepper.cjs +885 -0
  150. package/dist/components/Stepper.js +105 -0
  151. package/dist/components/Subheader.cjs +226 -0
  152. package/dist/components/Subheader.js +8 -0
  153. package/dist/components/Surface.cjs +98 -0
  154. package/dist/components/Surface.js +40 -0
  155. package/dist/components/Swatch.cjs +1728 -0
  156. package/dist/components/Swatch.js +1319 -0
  157. package/dist/components/Textarea.cjs +269 -0
  158. package/dist/components/Textarea.js +96 -0
  159. package/dist/components/Theme.cjs +36 -0
  160. package/dist/components/Theme.js +7 -0
  161. package/dist/components/Time.cjs +1118 -0
  162. package/dist/components/Time.js +353 -0
  163. package/dist/components/Toast.cjs +644 -0
  164. package/dist/components/Toast.js +218 -0
  165. package/dist/components/Tooltip.cjs +273 -0
  166. package/dist/components/Tooltip.js +9 -0
  167. package/dist/components/TopBar.cjs +352 -0
  168. package/dist/components/TopBar.js +132 -0
  169. package/dist/components/useInfiniteScroll.cjs +57 -0
  170. package/dist/components/useInfiniteScroll.js +8 -0
  171. package/dist/components/useMatchesMedia.cjs +53 -0
  172. package/dist/components/useMatchesMedia.js +9 -0
  173. package/dist/components/useMenuSystem.cjs +358 -0
  174. package/dist/components/useMenuSystem.js +11 -0
  175. package/dist/components/useMounted.cjs +39 -0
  176. package/dist/components/useMounted.js +8 -0
  177. package/dist/fonts.css +21 -0
  178. package/dist/icons-light[FILL]-PPZXOLWS.woff2 +0 -0
  179. package/dist/icons-normal[FILL]-PPZXOLWS.woff2 +0 -0
  180. package/dist/index.css +4401 -0
  181. package/dist/open-sans-55T6A4JE.woff2 +0 -0
  182. package/dist/types.cjs +18 -0
  183. package/dist/types.js +0 -0
  184. package/package.json +66 -0
  185. package/src/brand.css +125 -0
  186. package/src/classNames.ts +144 -0
  187. package/src/components/Breadcrumbs.tsx +116 -0
  188. package/src/components/Button.tsx +210 -0
  189. package/src/components/CalendarRange.tsx +429 -0
  190. package/src/components/Caption.tsx +101 -0
  191. package/src/components/Checkbox.tsx +196 -0
  192. package/src/components/ContentTab.tsx +66 -0
  193. package/src/components/ContentTabs.tsx +103 -0
  194. package/src/components/DMSiLogo.tsx +32 -0
  195. package/src/components/DataGrid.tsx +948 -0
  196. package/src/components/DataGridCell.tsx +384 -0
  197. package/src/components/DataTable.tsx +835 -0
  198. package/src/components/DateInput.tsx +188 -0
  199. package/src/components/DateRangeInput.tsx +179 -0
  200. package/src/components/DebugJson.tsx +24 -0
  201. package/src/components/Display.tsx +60 -0
  202. package/src/components/EditingContext.tsx +40 -0
  203. package/src/components/FilterGroup.tsx +234 -0
  204. package/src/components/FullViewportBox.tsx +11 -0
  205. package/src/components/Grid.tsx +75 -0
  206. package/src/components/GridContainer.tsx +124 -0
  207. package/src/components/Heading.tsx +66 -0
  208. package/src/components/HorizontalDivider.tsx +3 -0
  209. package/src/components/Icon.tsx +36 -0
  210. package/src/components/Input.tsx +511 -0
  211. package/src/components/InputGroup.tsx +51 -0
  212. package/src/components/Label.tsx +40 -0
  213. package/src/components/Link.tsx +106 -0
  214. package/src/components/List.tsx +10 -0
  215. package/src/components/LiveChatComponent.tsx +56 -0
  216. package/src/components/LogoAgilityTopBar.tsx +53 -0
  217. package/src/components/LogoDMSiTopBar.tsx +32 -0
  218. package/src/components/LogoMillworkTopBar.tsx +118 -0
  219. package/src/components/MainBar.tsx +83 -0
  220. package/src/components/Menu.tsx +286 -0
  221. package/src/components/MenuOption.tsx +275 -0
  222. package/src/components/MobileDataGrid.tsx +135 -0
  223. package/src/components/Modal.tsx +271 -0
  224. package/src/components/ModalButtons.tsx +44 -0
  225. package/src/components/ModalContent.tsx +23 -0
  226. package/src/components/ModalHeader.tsx +41 -0
  227. package/src/components/ModalScrim.tsx +35 -0
  228. package/src/components/NavigationTab.tsx +89 -0
  229. package/src/components/NavigationTabs.tsx +63 -0
  230. package/src/components/Notification.tsx +120 -0
  231. package/src/components/OptionPill.tsx +114 -0
  232. package/src/components/Paragraph.tsx +49 -0
  233. package/src/components/Password.tsx +46 -0
  234. package/src/components/ProjectBar.tsx +76 -0
  235. package/src/components/Radio.tsx +140 -0
  236. package/src/components/Search.tsx +129 -0
  237. package/src/components/Select.tsx +104 -0
  238. package/src/components/SideMenu.tsx +21 -0
  239. package/src/components/SideMenuGroup.tsx +81 -0
  240. package/src/components/SideMenuItem.tsx +90 -0
  241. package/src/components/Stack.tsx +179 -0
  242. package/src/components/StatusPill.tsx +51 -0
  243. package/src/components/Stepper.tsx +91 -0
  244. package/src/components/Subheader.tsx +44 -0
  245. package/src/components/Surface.tsx +34 -0
  246. package/src/components/Swatch.tsx +1066 -0
  247. package/src/components/Textarea.tsx +101 -0
  248. package/src/components/Theme.tsx +13 -0
  249. package/src/components/Time.tsx +438 -0
  250. package/src/components/Toast.tsx +244 -0
  251. package/src/components/Tooltip.tsx +137 -0
  252. package/src/components/TopBar.tsx +124 -0
  253. package/src/components/useInfiniteScroll.tsx +40 -0
  254. package/src/components/useMatchesMedia.tsx +28 -0
  255. package/src/components/useMenuSystem.tsx +367 -0
  256. package/src/components/useMounted.tsx +14 -0
  257. package/src/darkmode.css +140 -0
  258. package/src/fonts.css +23 -0
  259. package/src/index.css +509 -0
  260. package/src/index.tsx +2 -0
  261. package/src/types.ts +149 -0
  262. package/src/utils/formatting.tsx +81 -0
  263. package/src/utils.ts +23 -0
@@ -0,0 +1,758 @@
1
+ "use client";
2
+ import {
3
+ Tooltip
4
+ } from "../chunk-2G2E2JMA.js";
5
+ import {
6
+ useInfiniteScroll
7
+ } from "../chunk-AWQSSKCK.js";
8
+ import {
9
+ Subheader
10
+ } from "../chunk-5GOBP2JS.js";
11
+ import {
12
+ Select
13
+ } from "../chunk-TRUPPHBQ.js";
14
+ import {
15
+ DataGridCell,
16
+ DragAlongCell,
17
+ DraggableCellHeader
18
+ } from "../chunk-TAW5ZZ4Z.js";
19
+ import {
20
+ Menu
21
+ } from "../chunk-L4UM372R.js";
22
+ import "../chunk-Z4UCFUF7.js";
23
+ import {
24
+ MenuOption
25
+ } from "../chunk-E5ALT5W7.js";
26
+ import "../chunk-SEKKGFM6.js";
27
+ import {
28
+ Search
29
+ } from "../chunk-GTCSRHPF.js";
30
+ import "../chunk-WVUIIBRR.js";
31
+ import "../chunk-4T7F5BZZ.js";
32
+ import {
33
+ Input
34
+ } from "../chunk-BWRHL2AG.js";
35
+ import {
36
+ Label
37
+ } from "../chunk-4C66DLIJ.js";
38
+ import {
39
+ Button
40
+ } from "../chunk-KENSVWOY.js";
41
+ import {
42
+ Checkbox
43
+ } from "../chunk-DKKYR6DS.js";
44
+ import {
45
+ Paragraph
46
+ } from "../chunk-K3IKUSZW.js";
47
+ import {
48
+ Icon
49
+ } from "../chunk-IGQVA7SC.js";
50
+ import {
51
+ componentGap,
52
+ componentPadding
53
+ } from "../chunk-KX3O6GJ6.js";
54
+ import {
55
+ __spreadProps,
56
+ __spreadValues
57
+ } from "../chunk-ORMEWXMH.js";
58
+
59
+ // src/components/DataGrid.tsx
60
+ import React, { useCallback, useId, useRef, useState } from "react";
61
+ import {
62
+ flexRender,
63
+ getCoreRowModel,
64
+ getFilteredRowModel,
65
+ getSortedRowModel,
66
+ useReactTable
67
+ } from "@tanstack/react-table";
68
+ import {
69
+ useVirtualizer
70
+ } from "@tanstack/react-virtual";
71
+ import {
72
+ closestCenter,
73
+ DndContext,
74
+ KeyboardSensor,
75
+ MouseSensor,
76
+ TouchSensor,
77
+ useSensor,
78
+ useSensors
79
+ } from "@dnd-kit/core";
80
+ import {
81
+ arrayMove,
82
+ horizontalListSortingStrategy,
83
+ SortableContext
84
+ } from "@dnd-kit/sortable";
85
+ import { restrictToHorizontalAxis } from "@dnd-kit/modifiers";
86
+ import clsx from "clsx";
87
+ import { jsx, jsxs } from "react/jsx-runtime";
88
+ var PAGE_SIZE_OPTIONS = [5, 10, 15, 20, 25, 30, 35];
89
+ var NO_RESULTS_HEIGHT = "h-[120px]";
90
+ function adaptTableStateSetter(setter) {
91
+ return (valueOrFn) => {
92
+ setter(
93
+ (prev) => typeof valueOrFn === "function" ? valueOrFn(prev) : valueOrFn
94
+ );
95
+ };
96
+ }
97
+ function DataGrid({
98
+ data,
99
+ columns,
100
+ status,
101
+ isLoadingMore = false,
102
+ onLoadMore,
103
+ pagination,
104
+ showFilterRow = false,
105
+ hasMore = false,
106
+ sorting: externalSorting,
107
+ onSortingChange,
108
+ columnFilters: externalColumnFilters,
109
+ onColumnFiltersChange,
110
+ rowSelection: externalRowSelection,
111
+ onRowSelectionChange,
112
+ filteredSortedData,
113
+ totalRowCount,
114
+ hideStatusBar,
115
+ centerHeader,
116
+ enableColumnSelector
117
+ }) {
118
+ var _a, _b, _c, _d, _e;
119
+ const [columnOrder, setColumnOrder] = useState(
120
+ () => columns.map((c) => c.id)
121
+ );
122
+ const [localSorting, setLocalSorting] = useState([]);
123
+ const [localColumnFilters, setLocalColumnFilters] = useState([]);
124
+ const [localRowSelection, setLocalRowSelection] = useState({});
125
+ const sortingState = pagination ? externalSorting != null ? externalSorting : localSorting : localSorting;
126
+ const setSortingState = pagination ? (updaterOrValue) => {
127
+ const value = typeof updaterOrValue === "function" ? updaterOrValue(
128
+ externalSorting != null ? externalSorting : []
129
+ ) : updaterOrValue;
130
+ (onSortingChange != null ? onSortingChange : setLocalSorting)(value);
131
+ } : setLocalSorting;
132
+ const columnFilterState = pagination ? externalColumnFilters != null ? externalColumnFilters : localColumnFilters : localColumnFilters;
133
+ const setColumnFilterState = pagination ? (updaterOrValue) => {
134
+ const value = typeof updaterOrValue === "function" ? updaterOrValue(externalColumnFilters != null ? externalColumnFilters : []) : updaterOrValue;
135
+ (onColumnFiltersChange != null ? onColumnFiltersChange : setLocalColumnFilters)(value);
136
+ } : setLocalColumnFilters;
137
+ const rowSelection = pagination ? externalRowSelection != null ? externalRowSelection : localRowSelection : localRowSelection;
138
+ const setRowSelection = pagination ? (updaterOrValue) => {
139
+ const value = typeof updaterOrValue === "function" ? updaterOrValue(externalRowSelection != null ? externalRowSelection : {}) : updaterOrValue;
140
+ (onRowSelectionChange != null ? onRowSelectionChange : setLocalRowSelection)(value);
141
+ } : setLocalRowSelection;
142
+ const id = useId();
143
+ const containerRef = React.useRef(null);
144
+ const [columnVisibility, setColumnVisibility] = useState(() => {
145
+ const initialVisibility = {};
146
+ columns.forEach((column) => {
147
+ var _a2, _b2;
148
+ if (column.id) {
149
+ initialVisibility[column.id] = (_b2 = (_a2 = column.meta) == null ? void 0 : _a2.visible) != null ? _b2 : true;
150
+ }
151
+ });
152
+ return initialVisibility;
153
+ });
154
+ const toggleColumnVisibility = useCallback(
155
+ (id2, isVisible) => {
156
+ setColumnVisibility((prev) => __spreadProps(__spreadValues({}, prev), { [id2]: isVisible }));
157
+ },
158
+ [setColumnVisibility]
159
+ );
160
+ const resetColumnVisibility = useCallback(() => {
161
+ setColumnVisibility(() => {
162
+ const initialVisibility = {};
163
+ columns.forEach((column) => {
164
+ var _a2, _b2;
165
+ if (column.id) {
166
+ initialVisibility[column.id] = (_b2 = (_a2 = column.meta) == null ? void 0 : _a2.visible) != null ? _b2 : true;
167
+ }
168
+ });
169
+ return initialVisibility;
170
+ });
171
+ }, [columns]);
172
+ const table = useReactTable({
173
+ columns,
174
+ data,
175
+ getCoreRowModel: getCoreRowModel(),
176
+ getSortedRowModel: getSortedRowModel(),
177
+ getFilteredRowModel: getFilteredRowModel(),
178
+ columnResizeMode: "onChange",
179
+ getRowId: (row, index) => {
180
+ var _a2;
181
+ return String((_a2 = row.id) != null ? _a2 : index + 1);
182
+ },
183
+ state: {
184
+ columnOrder,
185
+ sorting: sortingState,
186
+ columnFilters: columnFilterState,
187
+ rowSelection,
188
+ columnVisibility
189
+ },
190
+ onColumnOrderChange: setColumnOrder,
191
+ onSortingChange: adaptTableStateSetter(setSortingState),
192
+ onColumnFiltersChange: adaptTableStateSetter(setColumnFilterState),
193
+ onRowSelectionChange: adaptTableStateSetter(setRowSelection),
194
+ filterFns: {
195
+ startsWith: (row, columnId, filterValue) => {
196
+ var _a2;
197
+ return (_a2 = row.getValue(columnId)) == null ? void 0 : _a2.toLowerCase().startsWith(filterValue.toLowerCase());
198
+ },
199
+ endsWith: (row, columnId, filterValue) => {
200
+ var _a2;
201
+ return (_a2 = row.getValue(columnId)) == null ? void 0 : _a2.toLowerCase().endsWith(filterValue.toLowerCase());
202
+ }
203
+ }
204
+ });
205
+ const allRowIds = pagination ? (_a = filteredSortedData == null ? void 0 : filteredSortedData.map((row) => String(row.id))) != null ? _a : [] : Array.from(
206
+ { length: totalRowCount != null ? totalRowCount : data.length },
207
+ (_, i) => String(i + 1)
208
+ );
209
+ const allSelectedAcrossPages = allRowIds.every((id2) => rowSelection[id2]);
210
+ const someSelectedAcrossPages = !allSelectedAcrossPages && allRowIds.some((id2) => rowSelection[id2]);
211
+ const toggleSelectAllAcrossPages = () => {
212
+ setRowSelection((prev) => {
213
+ const isSelecting = !allSelectedAcrossPages;
214
+ if (isSelecting) {
215
+ const newSelection = {};
216
+ for (const id2 of allRowIds) {
217
+ newSelection[id2] = true;
218
+ }
219
+ return __spreadValues(__spreadValues({}, prev), newSelection);
220
+ } else {
221
+ const updatedSelection = __spreadValues({}, prev);
222
+ for (const id2 of allRowIds) {
223
+ delete updatedSelection[id2];
224
+ }
225
+ return updatedSelection;
226
+ }
227
+ });
228
+ };
229
+ useInfiniteScroll({
230
+ containerRef,
231
+ onLoadMore: onLoadMore != null ? onLoadMore : () => {
232
+ },
233
+ isLoading: isLoadingMore,
234
+ enabled: !pagination
235
+ });
236
+ const handleDragEnd = (event) => {
237
+ const { active, over } = event;
238
+ if (active && over && active.id !== over.id) {
239
+ setColumnOrder((prev) => {
240
+ const oldIndex = prev.indexOf(active.id);
241
+ const newIndex = prev.indexOf(over.id);
242
+ return arrayMove(prev, oldIndex, newIndex);
243
+ });
244
+ }
245
+ };
246
+ const sensors = useSensors(
247
+ useSensor(MouseSensor),
248
+ useSensor(TouchSensor),
249
+ useSensor(KeyboardSensor)
250
+ );
251
+ const visibleColumns = table.getVisibleLeafColumns();
252
+ const columnVirtualizer = useVirtualizer({
253
+ count: visibleColumns.length,
254
+ estimateSize: (index) => visibleColumns[index].getSize(),
255
+ //estimate width of each column for accurate scrollbar dragging
256
+ getScrollElement: () => containerRef.current,
257
+ horizontal: true,
258
+ overscan: 3
259
+ //how many columns to render on each side off screen each way
260
+ });
261
+ const virtualColumns = columnVirtualizer.getVirtualItems();
262
+ let virtualPaddingLeft;
263
+ let virtualPaddingRight;
264
+ if (columnVirtualizer && (virtualColumns == null ? void 0 : virtualColumns.length)) {
265
+ virtualPaddingLeft = (_c = (_b = virtualColumns[0]) == null ? void 0 : _b.start) != null ? _c : 0;
266
+ virtualPaddingRight = columnVirtualizer.getTotalSize() - ((_e = (_d = virtualColumns[virtualColumns.length - 1]) == null ? void 0 : _d.end) != null ? _e : 0);
267
+ }
268
+ return /* @__PURE__ */ jsx(
269
+ DndContext,
270
+ {
271
+ id,
272
+ collisionDetection: closestCenter,
273
+ modifiers: [restrictToHorizontalAxis],
274
+ onDragEnd: handleDragEnd,
275
+ sensors,
276
+ children: /* @__PURE__ */ jsx(
277
+ SortableContext,
278
+ {
279
+ items: columnOrder,
280
+ strategy: horizontalListSortingStrategy,
281
+ children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col flex-1 h-full w-full rounded border border-border-primary-normal overflow-hidden text-text-primary-normal", children: [
282
+ /* @__PURE__ */ jsx(
283
+ "div",
284
+ {
285
+ className: "overflow-auto scrollbar-thin h-full relative contain-paint will-change-transform",
286
+ ref: containerRef,
287
+ children: /* @__PURE__ */ jsxs("table", { className: "min-w-full grid", children: [
288
+ /* @__PURE__ */ jsx("thead", { className: "sticky top-0 z-10 grid", children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsxs("tr", { className: "flex w-full", children: [
289
+ virtualPaddingLeft ? (
290
+ // fake empty column to the left for virtualization scroll padding
291
+ /* @__PURE__ */ jsx(
292
+ "th",
293
+ {
294
+ style: { display: "flex", width: virtualPaddingLeft }
295
+ }
296
+ )
297
+ ) : null,
298
+ virtualColumns.map((virtualColumn) => {
299
+ var _a2, _b2, _c2, _d2, _e2;
300
+ const header = headerGroup.headers[virtualColumn.index];
301
+ if (typeof header.column.columnDef.header === "string") {
302
+ const customHeaderWidth = (_a2 = header.column.columnDef.meta) == null ? void 0 : _a2.headerWidth;
303
+ return /* @__PURE__ */ jsxs(
304
+ DraggableCellHeader,
305
+ {
306
+ header,
307
+ locked: (_b2 = header.column.columnDef.meta) == null ? void 0 : _b2.locked,
308
+ center: centerHeader,
309
+ width: customHeaderWidth,
310
+ className: clsx(
311
+ header.column.getCanSort() ? "cursor-pointer" : "cursor-grab",
312
+ "group"
313
+ ),
314
+ children: [
315
+ /* @__PURE__ */ jsx(Subheader, { tall: true, children: header.column.columnDef.header }),
316
+ getSortIcon(header.column.getIsSorted()),
317
+ !header.column.getIsSorted() && header.column.getCanSort() && getSortIcon(
318
+ header.column.getNextSortingOrder(),
319
+ true
320
+ ),
321
+ header.column.getSortIndex() !== -1 && table.getState().sorting.length > 1 && /* @__PURE__ */ jsx(Subheader, { tall: true, children: header.column.getSortIndex() + 1 }),
322
+ !((_c2 = header.column.columnDef.meta) == null ? void 0 : _c2.locked) && /* @__PURE__ */ jsx(
323
+ "div",
324
+ {
325
+ onDoubleClick: (e) => {
326
+ e.stopPropagation();
327
+ header.column.resetSize();
328
+ },
329
+ onMouseDown: (e) => {
330
+ e.stopPropagation();
331
+ header.getResizeHandler()(e);
332
+ },
333
+ onTouchStart: (e) => {
334
+ e.stopPropagation();
335
+ header.getResizeHandler()(e);
336
+ },
337
+ className: "absolute right-0 inset-y-0 w-px bg-black cursor-col-resize"
338
+ }
339
+ )
340
+ ]
341
+ },
342
+ header.id
343
+ );
344
+ }
345
+ return /* @__PURE__ */ jsx(React.Fragment, { children: ((_d2 = header.column.columnDef.meta) == null ? void 0 : _d2.checkbox) ? /* @__PURE__ */ jsx(
346
+ DataGridCell,
347
+ {
348
+ type: "header",
349
+ component: "checkbox",
350
+ locked: (_e2 = header.column.columnDef.meta) == null ? void 0 : _e2.locked,
351
+ children: /* @__PURE__ */ jsx(
352
+ Checkbox,
353
+ {
354
+ checked: allSelectedAcrossPages,
355
+ indeterminate: someSelectedAcrossPages,
356
+ onChange: toggleSelectAllAcrossPages
357
+ }
358
+ )
359
+ }
360
+ ) : flexRender(
361
+ header.column.columnDef.header,
362
+ header.getContext()
363
+ ) }, header.id);
364
+ }),
365
+ virtualPaddingRight ? (
366
+ //fake empty column to the right for virtualization scroll padding
367
+ /* @__PURE__ */ jsx(
368
+ "th",
369
+ {
370
+ style: { display: "flex", width: virtualPaddingRight }
371
+ }
372
+ )
373
+ ) : null,
374
+ enableColumnSelector && /* @__PURE__ */ jsx(
375
+ ColumnSelectorHeaderCell,
376
+ {
377
+ table,
378
+ toggleColumnVisibility,
379
+ resetColumnVisibility
380
+ }
381
+ )
382
+ ] }, headerGroup.id)) }),
383
+ /* @__PURE__ */ jsx(
384
+ TableBody,
385
+ {
386
+ columnVirtualizer,
387
+ table,
388
+ tableContainerRef: containerRef,
389
+ virtualPaddingLeft,
390
+ virtualPaddingRight,
391
+ pagination,
392
+ isLoadingMore,
393
+ hasMore,
394
+ showFilterRow,
395
+ enableColumnSelector
396
+ }
397
+ )
398
+ ] })
399
+ }
400
+ ),
401
+ table.getRowModel().rows.length === 0 && /* @__PURE__ */ jsxs(
402
+ "div",
403
+ {
404
+ className: clsx(
405
+ NO_RESULTS_HEIGHT,
406
+ "flex flex-col items-center justify-center",
407
+ componentGap,
408
+ componentPadding
409
+ ),
410
+ children: [
411
+ /* @__PURE__ */ jsx(Subheader, { color: "text-secondary-normal", children: "No Results" }),
412
+ /* @__PURE__ */ jsx(Paragraph, { color: "text-secondary-normal", children: "To view results, enter or update your search criteria." })
413
+ ]
414
+ }
415
+ ),
416
+ !hideStatusBar && /* @__PURE__ */ jsxs("div", { className: "p-2 pt-[7px] border-t border-border-primary-normal h-full min-h-[34px]", children: [
417
+ pagination && /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center", children: [
418
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 w-min", children: [
419
+ /* @__PURE__ */ jsx(
420
+ Select,
421
+ {
422
+ wrapperClassName: "!w-20",
423
+ value: pagination.pageSize.toString(),
424
+ onChange: (e) => {
425
+ var _a2;
426
+ return (_a2 = pagination.onPageSizeChange) == null ? void 0 : _a2.call(pagination, Number(e.target.value));
427
+ },
428
+ renderMenu: (props) => /* @__PURE__ */ jsx(Menu, __spreadProps(__spreadValues({}, props), { onClick: () => props.setShow(false), children: PAGE_SIZE_OPTIONS.map((option) => /* @__PURE__ */ jsx(
429
+ MenuOption,
430
+ {
431
+ selected: pagination.pageSize === option,
432
+ onClick: () => {
433
+ var _a2;
434
+ return (_a2 = pagination.onPageSizeChange) == null ? void 0 : _a2.call(pagination, option);
435
+ },
436
+ children: option
437
+ },
438
+ option
439
+ )) }))
440
+ }
441
+ ),
442
+ /* @__PURE__ */ jsx(Label, { className: "whitespace-nowrap", children: "Per Page" })
443
+ ] }),
444
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
445
+ /* @__PURE__ */ jsx(
446
+ Button,
447
+ {
448
+ iconOnly: true,
449
+ leftIcon: /* @__PURE__ */ jsx(Icon, { name: "chevron_left" }),
450
+ onClick: () => pagination.onPageChange(pagination.pageIndex - 1),
451
+ variant: "tertiary",
452
+ disabled: pagination.pageIndex === 0
453
+ }
454
+ ),
455
+ /* @__PURE__ */ jsxs(Paragraph, { children: [
456
+ pagination.pageIndex * pagination.pageSize + 1,
457
+ " -",
458
+ " ",
459
+ Math.min(
460
+ (pagination.pageIndex + 1) * pagination.pageSize,
461
+ pagination.total
462
+ ),
463
+ " ",
464
+ "of ",
465
+ pagination.total
466
+ ] }),
467
+ /* @__PURE__ */ jsx(
468
+ Button,
469
+ {
470
+ iconOnly: true,
471
+ leftIcon: /* @__PURE__ */ jsx(Icon, { name: "chevron_right" }),
472
+ onClick: () => pagination.onPageChange(pagination.pageIndex + 1),
473
+ variant: "tertiary",
474
+ disabled: (pagination.pageIndex + 1) * pagination.pageSize >= pagination.total
475
+ }
476
+ )
477
+ ] })
478
+ ] }),
479
+ status && /* @__PURE__ */ jsx(Paragraph, { children: status })
480
+ ] })
481
+ ] })
482
+ }
483
+ )
484
+ }
485
+ );
486
+ }
487
+ DataGrid.displayName = "DataGrid";
488
+ function TableBody({
489
+ columnVirtualizer,
490
+ table,
491
+ tableContainerRef,
492
+ virtualPaddingLeft,
493
+ virtualPaddingRight,
494
+ pagination,
495
+ isLoadingMore,
496
+ hasMore,
497
+ showFilterRow,
498
+ enableColumnSelector = false
499
+ }) {
500
+ const { rows } = table.getRowModel();
501
+ const rowVirtualizer = useVirtualizer({
502
+ count: rows.length,
503
+ estimateSize: () => 40,
504
+ getScrollElement: () => tableContainerRef.current,
505
+ overscan: 8
506
+ });
507
+ const virtualRows = rowVirtualizer.getVirtualItems();
508
+ return /* @__PURE__ */ jsxs(
509
+ "tbody",
510
+ {
511
+ style: {
512
+ display: "grid",
513
+ height: `${showFilterRow ? rowVirtualizer.getTotalSize() + 40 : rowVirtualizer.getTotalSize()}px`,
514
+ // tells scrollbar how big the table is
515
+ position: "relative"
516
+ // needed for absolute positioning of rows
517
+ },
518
+ children: [
519
+ showFilterRow && /* @__PURE__ */ jsx(
520
+ "tr",
521
+ {
522
+ style: {
523
+ display: "flex",
524
+ position: "sticky",
525
+ top: "40px",
526
+ width: "100%",
527
+ height: "40px",
528
+ zIndex: 10
529
+ },
530
+ className: "even:bg-background-grouped-primary-normal odd:bg-background-grouped-secondary-normal",
531
+ children: table.getHeaderGroups().flatMap(
532
+ (x) => x.headers.map((header) => {
533
+ var _a, _b, _c, _d, _e;
534
+ return /* @__PURE__ */ jsx(
535
+ DragAlongCell,
536
+ {
537
+ noPadding: true,
538
+ cell: header,
539
+ width: (_a = header.column.columnDef.meta) == null ? void 0 : _a.headerWidth,
540
+ children: header.column.getCanFilter() && ((_e = (_c = (_b = header.column.columnDef.meta) == null ? void 0 : _b.filterRowCell) == null ? void 0 : _c.call(_b, {
541
+ header,
542
+ table
543
+ })) != null ? _e : /* @__PURE__ */ jsx(
544
+ Search,
545
+ {
546
+ removeRoundness: true,
547
+ onChange: (e) => header.column.setFilterValue(e.target.value),
548
+ value: (_d = header.column.getFilterValue()) != null ? _d : "",
549
+ placeholder: "",
550
+ removeSearchIcon: true
551
+ }
552
+ ))
553
+ },
554
+ header.id
555
+ );
556
+ })
557
+ )
558
+ }
559
+ ),
560
+ virtualRows.map((virtualRow) => {
561
+ const row = rows[virtualRow.index];
562
+ return /* @__PURE__ */ jsx(
563
+ TableBodyRow,
564
+ {
565
+ columnVirtualizer,
566
+ row,
567
+ rowVirtualizer,
568
+ virtualPaddingLeft,
569
+ virtualPaddingRight,
570
+ virtualRow,
571
+ showFilterRow,
572
+ enableColumnSelector
573
+ },
574
+ row.id
575
+ );
576
+ }),
577
+ !pagination && isLoadingMore && hasMore && /* @__PURE__ */ jsx(
578
+ "tr",
579
+ {
580
+ style: {
581
+ display: "flex",
582
+ position: "absolute",
583
+ width: "100%",
584
+ transform: `translateY(${virtualRows[virtualRows.length - 1].start + 40}px)`
585
+ },
586
+ className: "odd:bg-background-grouped-primary-normal even:bg-background-grouped-secondary-normal",
587
+ children: table.getAllLeafColumns().map((column) => /* @__PURE__ */ jsx(LoadingCell, { column: column.columnDef }, column.id))
588
+ }
589
+ )
590
+ ]
591
+ }
592
+ );
593
+ }
594
+ function TableBodyRow({
595
+ columnVirtualizer,
596
+ row,
597
+ // rowVirtualizer,
598
+ virtualPaddingLeft,
599
+ virtualPaddingRight,
600
+ virtualRow,
601
+ showFilterRow,
602
+ enableColumnSelector = false
603
+ }) {
604
+ const visibleCells = row.getVisibleCells();
605
+ const virtualColumns = columnVirtualizer.getVirtualItems();
606
+ const isError = typeof row.original === "object" && row.original !== null && "rowState" in row.original && row.original.rowState === "error";
607
+ return /* @__PURE__ */ jsxs(
608
+ "tr",
609
+ {
610
+ className: clsx(
611
+ "transition-colors hover:bg-background-action-secondary-hover",
612
+ row.getIsSelected() && "!bg-background-action-secondary-hover",
613
+ isError && "!bg-background-action-critical-secondary-hover",
614
+ showFilterRow ? "even:bg-background-grouped-primary-normal odd:bg-background-grouped-secondary-normal" : "odd:bg-background-grouped-primary-normal even:bg-background-grouped-secondary-normal"
615
+ ),
616
+ style: {
617
+ display: "flex",
618
+ position: "absolute",
619
+ transform: `translateY(${showFilterRow ? virtualRow.start + 40 : virtualRow.start}px)`,
620
+ width: "100%"
621
+ },
622
+ children: [
623
+ virtualPaddingLeft ? (
624
+ // fake empty column to the left for virtualization scroll padding
625
+ /* @__PURE__ */ jsx("td", { style: { display: "flex", width: virtualPaddingLeft } })
626
+ ) : null,
627
+ virtualColumns.map((virtualColumn) => {
628
+ var _a;
629
+ const cell = visibleCells[virtualColumn.index];
630
+ return ((_a = cell.column.columnDef.meta) == null ? void 0 : _a.useCustomRenderer) ? /* @__PURE__ */ jsx(React.Fragment, { children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id) : /* @__PURE__ */ jsx(DragAlongCell, { cell, children: /* @__PURE__ */ jsx(
631
+ Tooltip,
632
+ {
633
+ showOnTruncation: true,
634
+ message: cell.getValue(),
635
+ position: "bottom",
636
+ children: /* @__PURE__ */ jsx(Paragraph, { addOverflow: true, tall: true, children: cell.getValue() })
637
+ }
638
+ ) }, cell.id);
639
+ }),
640
+ virtualPaddingRight ? (
641
+ // fake empty column to the right for virtualization scroll padding
642
+ /* @__PURE__ */ jsx("td", { style: { display: "flex", width: virtualPaddingRight } })
643
+ ) : null,
644
+ enableColumnSelector && /* @__PURE__ */ jsx("td", {})
645
+ ]
646
+ },
647
+ row.id
648
+ );
649
+ }
650
+ var LoadingCell = ({
651
+ column
652
+ }) => {
653
+ const key = `loading-${column.id}`;
654
+ if (column.cell === "checkbox") {
655
+ return /* @__PURE__ */ jsx(DataGridCell, { children: /* @__PURE__ */ jsx(Checkbox, { disabled: true }) }, key);
656
+ }
657
+ if (column.cell === "input") {
658
+ return /* @__PURE__ */ jsx(DataGridCell, { component: "input", children: /* @__PURE__ */ jsx(
659
+ Input,
660
+ {
661
+ align: "left",
662
+ disabled: true,
663
+ wrapperClassName: "!rounded-none !border-0"
664
+ }
665
+ ) }, key);
666
+ }
667
+ return /* @__PURE__ */ jsx(DataGridCell, { children: /* @__PURE__ */ jsx("div", { className: "bg-linear-270 to-neutral-300/[24%] from-neutral-300/[12%] rounded-xs w-full max-w-25 h-6" }) }, key);
668
+ };
669
+ function ColumnSelectorHeaderCell({
670
+ table,
671
+ toggleColumnVisibility,
672
+ resetColumnVisibility
673
+ }) {
674
+ const ref = useRef(null);
675
+ const [show, setShow] = useState(false);
676
+ return /* @__PURE__ */ jsxs(
677
+ DataGridCell,
678
+ {
679
+ width: "48",
680
+ type: "header",
681
+ color: "text-secondary-normal",
682
+ ref,
683
+ children: [
684
+ /* @__PURE__ */ jsx(
685
+ Button,
686
+ {
687
+ onClick: () => setShow((prev) => !prev),
688
+ variant: "navigation",
689
+ iconOnly: true,
690
+ leftIcon: /* @__PURE__ */ jsx(Icon, { name: "tune" })
691
+ }
692
+ ),
693
+ /* @__PURE__ */ jsxs(
694
+ Menu,
695
+ {
696
+ positionTo: ref,
697
+ position: "bottom-right",
698
+ show,
699
+ setShow,
700
+ children: [
701
+ /* @__PURE__ */ jsx(
702
+ Button,
703
+ {
704
+ variant: "tertiary",
705
+ onClick: () => {
706
+ resetColumnVisibility();
707
+ setShow(false);
708
+ },
709
+ children: "Reset to default"
710
+ }
711
+ ),
712
+ table.getAllColumns().map((column) => /* @__PURE__ */ jsx(
713
+ ColumnSelectorMenuOption,
714
+ {
715
+ column,
716
+ toggleColumnVisibility
717
+ },
718
+ column.id
719
+ ))
720
+ ]
721
+ }
722
+ )
723
+ ]
724
+ }
725
+ );
726
+ }
727
+ function ColumnSelectorMenuOption({
728
+ column,
729
+ toggleColumnVisibility
730
+ }) {
731
+ const [isVisible, setIsVisible] = useState(column.getIsVisible());
732
+ const label = typeof column.columnDef.header === "string" ? column.columnDef.header : null;
733
+ return /* @__PURE__ */ jsx(MenuOption, { selected: isVisible, defaultChecked: isVisible, children: /* @__PURE__ */ jsx(
734
+ Checkbox,
735
+ {
736
+ label: label != null ? label : "Unknown",
737
+ checked: isVisible,
738
+ onChange: (e) => {
739
+ setIsVisible(e.target.checked);
740
+ toggleColumnVisibility(column.id, e.target.checked);
741
+ }
742
+ }
743
+ ) });
744
+ }
745
+ function getSortIcon(sort, nextSort = false) {
746
+ const iconClassName = clsx(
747
+ "text-icon-on-action-primary-normal",
748
+ nextSort && "hidden group-hover:block"
749
+ );
750
+ if (sort === "asc")
751
+ return /* @__PURE__ */ jsx(Icon, { size: 16, className: iconClassName, name: "arrow_upward" });
752
+ if (sort === "desc")
753
+ return /* @__PURE__ */ jsx(Icon, { size: 16, className: iconClassName, name: "arrow_downward" });
754
+ return null;
755
+ }
756
+ export {
757
+ DataGrid
758
+ };