@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,3113 @@
1
+ "use strict";
2
+ "use client";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __defProps = Object.defineProperties;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
8
+ var __getOwnPropNames = Object.getOwnPropertyNames;
9
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
10
+ var __getProtoOf = Object.getPrototypeOf;
11
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
12
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
13
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
14
+ var __spreadValues = (a, b) => {
15
+ for (var prop in b || (b = {}))
16
+ if (__hasOwnProp.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ if (__getOwnPropSymbols)
19
+ for (var prop of __getOwnPropSymbols(b)) {
20
+ if (__propIsEnum.call(b, prop))
21
+ __defNormalProp(a, prop, b[prop]);
22
+ }
23
+ return a;
24
+ };
25
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
26
+ var __objRest = (source, exclude) => {
27
+ var target = {};
28
+ for (var prop in source)
29
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
30
+ target[prop] = source[prop];
31
+ if (source != null && __getOwnPropSymbols)
32
+ for (var prop of __getOwnPropSymbols(source)) {
33
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
34
+ target[prop] = source[prop];
35
+ }
36
+ return target;
37
+ };
38
+ var __export = (target, all) => {
39
+ for (var name in all)
40
+ __defProp(target, name, { get: all[name], enumerable: true });
41
+ };
42
+ var __copyProps = (to, from, except, desc) => {
43
+ if (from && typeof from === "object" || typeof from === "function") {
44
+ for (let key of __getOwnPropNames(from))
45
+ if (!__hasOwnProp.call(to, key) && key !== except)
46
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
47
+ }
48
+ return to;
49
+ };
50
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
51
+ // If the importer is in node compatibility mode or this is not an ESM
52
+ // file that has been converted to a CommonJS file using a Babel-
53
+ // compatible transform (i.e. "__esModule" has not been set), then set
54
+ // "default" to the CommonJS "module.exports" for node compatibility.
55
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
56
+ mod
57
+ ));
58
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
59
+
60
+ // src/components/DataGrid.tsx
61
+ var DataGrid_exports = {};
62
+ __export(DataGrid_exports, {
63
+ DataGrid: () => DataGrid
64
+ });
65
+ module.exports = __toCommonJS(DataGrid_exports);
66
+ var import_react12 = __toESM(require("react"), 1);
67
+ var import_react_table = require("@tanstack/react-table");
68
+ var import_react_virtual = require("@tanstack/react-virtual");
69
+ var import_core = require("@dnd-kit/core");
70
+ var import_sortable2 = require("@dnd-kit/sortable");
71
+ var import_modifiers = require("@dnd-kit/modifiers");
72
+
73
+ // src/components/Button.tsx
74
+ var import_clsx2 = __toESM(require("clsx"), 1);
75
+
76
+ // src/classNames.ts
77
+ var import_clsx = __toESM(require("clsx"), 1);
78
+ var typography = {
79
+ display1: (0, import_clsx.default)(
80
+ "font-sans font-semibold",
81
+ "text-display-1-mobile desktop:text-display-1-desktop compact:text-display-1-desktop-compact",
82
+ "leading-display-1-mobile desktop:leading-display-1-desktop"
83
+ ),
84
+ display2: (0, import_clsx.default)(
85
+ "font-sans font-bold",
86
+ "text-display-2-mobile desktop:text-display-2-desktop compact:text-display-2-desktop-compact",
87
+ "leading-display-2-mobile desktop:leading-display-2-desktop"
88
+ ),
89
+ heading1: (0, import_clsx.default)(
90
+ "font-sans font-semibold",
91
+ "text-heading-1-mobile desktop:text-heading-1-desktop compact:text-heading-1-desktop-compact",
92
+ "leading-heading-1-mobile desktop:leading-heading-1-desktop"
93
+ ),
94
+ heading2: (0, import_clsx.default)(
95
+ "font-sans font-normal",
96
+ "text-heading-2-mobile desktop:text-heading-2-desktop compact:text-heading-2-desktop-compact",
97
+ "leading-heading-2-mobile desktop:leading-heading-2-desktop"
98
+ ),
99
+ heading3: (0, import_clsx.default)(
100
+ "font-sans font-semibold",
101
+ "text-heading-3-mobile desktop:text-heading-3-desktop compact:text-heading-3-desktop-compact",
102
+ "leading-heading-3-mobile desktop:leading-heading-3-desktop"
103
+ ),
104
+ subheader: (0, import_clsx.default)(
105
+ "font-sans font-semibold",
106
+ "text-subheader-mobile desktop:text-subheader-desktop compact:text-subheader-desktop-compact",
107
+ "leading-subheader-mobile desktop:leading-subheader-desktop"
108
+ ),
109
+ link: (0, import_clsx.default)(
110
+ "font-sans font-normal",
111
+ "text-link-mobile desktop:text-link-desktop compact:text-link-desktop-compact",
112
+ "leading-link-mobile desktop:leading-link-desktop"
113
+ ),
114
+ buttonLabel: (0, import_clsx.default)(
115
+ "font-sans font-semibold",
116
+ "text-label-mobile desktop:text-label-desktop compact:text-label-desktop-compact",
117
+ "leading-label-mobile desktop:leading-label-desktop"
118
+ ),
119
+ label: (0, import_clsx.default)(
120
+ "font-sans font-semibold",
121
+ "text-label-mobile desktop:text-label-desktop compact:text-label-desktop-compact",
122
+ "leading-label-mobile desktop:leading-label-desktop"
123
+ ),
124
+ paragraph: (0, import_clsx.default)(
125
+ "font-sans font-normal",
126
+ "text-paragraph-mobile desktop:text-paragraph-desktop compact:text-paragraph-desktop-compact",
127
+ "leading-paragraph-mobile desktop:leading-paragraph-desktop"
128
+ ),
129
+ caption: (0, import_clsx.default)(
130
+ "font-sans font-normal",
131
+ "text-caption-mobile desktop:text-caption-desktop compact:text-caption-desktop-compact",
132
+ "leading-caption-mobile desktop:leading-caption-desktop"
133
+ )
134
+ };
135
+ var baseTransition = (0, import_clsx.default)(
136
+ "transition-colors duration-100 ease-in-out"
137
+ );
138
+ var componentGap = (0, import_clsx.default)(
139
+ "gap-mobile-component-gap desktop:gap-desktop-component-gap compact:gap-desktop-compact-component-gap"
140
+ );
141
+ var paddingUsingComponentGap = (0, import_clsx.default)(
142
+ "p-mobile-component-gap desktop:p-desktop-component-gap compact:p-desktop-compact-component-gap"
143
+ );
144
+ var paddingYUsingLayoutGroupGap = (0, import_clsx.default)(
145
+ "py-mobile-layout-group-gap desktop:py-desktop-layout-group-gap compact:py-desktop-compact-layout-group-gap"
146
+ );
147
+ var componentPadding = (0, import_clsx.default)(
148
+ "p-mobile-component-padding desktop:p-desktop-component-padding compact:p-desktop-compact-component-padding"
149
+ );
150
+ var componentPaddingBottom = (0, import_clsx.default)(
151
+ "pb-mobile-component-padding desktop:pb-desktop-component-padding compact:pb-desktop-compact-component-padding"
152
+ );
153
+ var componentPaddingY = (0, import_clsx.default)(
154
+ "py-mobile-component-padding desktop:py-desktop-component-padding compact:py-desktop-compact-component-padding"
155
+ );
156
+ var componentPaddingXUsingComponentGap = (0, import_clsx.default)(
157
+ "px-mobile-component-gap desktop:px-desktop-component-gap compact:px-desktop-compact-component-gap"
158
+ );
159
+ var componentPaddingYUsingComponentGap = (0, import_clsx.default)(
160
+ "py-mobile-component-gap desktop:py-desktop-component-gap compact:py-desktop-compact-component-gap"
161
+ );
162
+ var componentPaddingMinusBorder = (0, import_clsx.default)(
163
+ "p-[calc(var(--spacing-mobile-component-padding)_-_1px)] desktop:p-[calc(var(--spacing-desktop-component-padding)_-_1px)] compact:p-[calc(var(--spacing-desktop-compact-component-padding)_-_1px)]"
164
+ );
165
+ var componentPaddingMinus2pxBorder = (0, import_clsx.default)(
166
+ "p-[calc(var(--spacing-mobile-component-padding)_-_2px)] desktop:p-[calc(var(--spacing-desktop-component-padding)_-_2px)] compact:p-[calc(var(--spacing-desktop-compact-component-padding)_-_2px)]"
167
+ );
168
+ var layoutPaddingBottom = (0, import_clsx.default)(
169
+ "pb-mobile-layout-padding desktop:pb-desktop-layout-padding compact:pb-desktop-compact-layout-padding"
170
+ );
171
+ var layoutPaddingY = (0, import_clsx.default)(
172
+ "py-mobile-layout-padding desktop:py-desktop-layout-padding compact:py-desktop-compact-layout-padding"
173
+ );
174
+ var containerPaddingX = (0, import_clsx.default)(
175
+ "px-mobile-container-padding desktop:px-desktop-container-padding compact:px-desktop-compact-container-padding"
176
+ );
177
+ var containerPaddingY = (0, import_clsx.default)(
178
+ "py-mobile-container-padding desktop:py-desktop-container-padding compact:py-desktop-compact-container-padding"
179
+ );
180
+ var layoutGroupGapPaddingY = (0, import_clsx.default)(
181
+ "py-mobile-layout-group-gap desktop:py-desktop-layout-group-gap compact:py-desktop-compact-layout-group-gap"
182
+ );
183
+ var layoutGroupGap = (0, import_clsx.default)(
184
+ "gap-mobile-layout-group-gap desktop:gap-desktop-layout-group-gap compact:gap-desktop-compact-layout-group-gap"
185
+ );
186
+ var layoutGap = (0, import_clsx.default)(
187
+ "gap-mobile-layout-gap desktop:gap-desktop-layout-gap compact:gap-desktop-compact-layout-gap"
188
+ );
189
+ var gapUsingContainerPadding = (0, import_clsx.default)(
190
+ "gap-mobile-container-padding desktop:gap-desktop-container-padding compact:gap-desktop-compact-container-padding"
191
+ );
192
+
193
+ // src/components/Button.tsx
194
+ var import_jsx_runtime = require("react/jsx-runtime");
195
+ var Button = (_a) => {
196
+ var _b = _a, {
197
+ variant = "primary",
198
+ as = "button",
199
+ block,
200
+ leftIcon,
201
+ rightIcon,
202
+ className,
203
+ classNameLabel,
204
+ disabled = false,
205
+ children,
206
+ iconOnly = false,
207
+ colorClassName,
208
+ href
209
+ } = _b, props = __objRest(_b, [
210
+ "variant",
211
+ "as",
212
+ "block",
213
+ "leftIcon",
214
+ "rightIcon",
215
+ "className",
216
+ "classNameLabel",
217
+ "disabled",
218
+ "children",
219
+ "iconOnly",
220
+ "colorClassName",
221
+ "href"
222
+ ]);
223
+ const primaryVariantStyles = variant === "primary" && (0, import_clsx2.default)(
224
+ (colorClassName == null ? void 0 : colorClassName.trim()) ? colorClassName : "text-text-on-action-primary-normal",
225
+ "bg-background-action-primary-normal border-background-action-primary-normal",
226
+ "hover:bg-background-action-primary-hover hover:border-background-action-primary-hover",
227
+ "focus:bg-background-action-primary-hover focus:border-background-action-primary-hover focus:outline-0",
228
+ "active:bg-background-action-primary-active active:border-background-action-primary-active",
229
+ "disabled:bg-background-action-primary-disabled disabled:border-background-action-primary-disabled disabled:text-text-on-action-primary-disabled"
230
+ );
231
+ const secondaryVariantStyles = variant === "secondary" && (0, import_clsx2.default)(
232
+ (colorClassName == null ? void 0 : colorClassName.trim()) ? colorClassName : "text-text-action-primary-normal",
233
+ "bg-background-action-secondary-normal border-border-action-normal",
234
+ "hover:bg-background-action-secondary-hover hover:border-border-action-hover hover:text-text-action-primary-hover",
235
+ "focus:bg-background-action-secondary-hover focus:border-border-action-hover focus:text-text-action-primary-hover focus:outline-0",
236
+ "active:bg-background-action-secondary-active active:border-border-action-active active:text-text-action-primary-active",
237
+ "disabled:bg-background-action-primary-disabled disabled:border-border-action-disabled disabled:text-text-action-primary-disabled"
238
+ );
239
+ const tertiaryVariantStyles = variant === "tertiary" && (0, import_clsx2.default)(
240
+ "bg-transparent border-transparent",
241
+ iconOnly ? (colorClassName == null ? void 0 : colorClassName.trim()) ? colorClassName : "text-icon-action-primary-normal" : (colorClassName == null ? void 0 : colorClassName.trim()) ? colorClassName : "text-text-action-primary-normal",
242
+ "bg-transparent border-transparent",
243
+ "hover:bg-background-action-secondary-hover hover:border-background-action-secondary-hover hover:text-text-action-primary-hover",
244
+ "focus:bg-background-action-secondary-hover focus:border-background-action-secondary-hover focus:text-text-action-primary-hover focus:outline-0",
245
+ "active:bg-background-action-secondary-active active:border-transparent active:text-text-action-primary-active",
246
+ "disabled:bg-transparent disabled:border-transparent disabled:text-text-action-primary-disabled"
247
+ );
248
+ const primaryCriticalVariantStyles = variant === "primary-critical" && (0, import_clsx2.default)(
249
+ (colorClassName == null ? void 0 : colorClassName.trim()) ? colorClassName : "text-text-on-action-primary-normal",
250
+ "bg-background-action-critical-primary-normal border-background-action-critical-primary-normal",
251
+ "hover:bg-background-action-critical-primary-hover hover:border-background-action-critical-primary-hover",
252
+ "focus:bg-background-action-critical-primary-hover focus:border-background-action-critical-primary-hover focus:outline-0",
253
+ "active:bg-background-action-critical-primary-active active:border-background-action-critical-primary-active",
254
+ "disabled:bg-background-action-critical-primary-disabled disabled:border-background-action-critical-primary-disabled disabled:text-text-on-action-primary-disabled"
255
+ );
256
+ const secondaryCriticalVariantStyles = variant === "secondary-critical" && (0, import_clsx2.default)(
257
+ (colorClassName == null ? void 0 : colorClassName.trim()) ? colorClassName : "text-text-action-critical-normal",
258
+ "bg-background-action-critical-secondary-normal border-border-action-critical-normal",
259
+ "hover:bg-background-action-critical-secondary-hover hover:border-border-action-critical-hover hover:text-text-action-critical-hover",
260
+ "focus:bg-background-action-critical-secondary-hover focus:border-border-action-critical-hover focus:text-text-action-critical-hover focus:outline-0",
261
+ "active:bg-background-action-critical-secondary-active active:border-border-action-critical-active active:text-text-action-critical-active",
262
+ "disabled:bg-background-action-critical-disabled disabled:border-border-action-critical-disabled disabled:text-text-action-critical-disabled"
263
+ );
264
+ const tertiaryCriticalVariantStyles = variant === "tertiary-critical" && (0, import_clsx2.default)(
265
+ (colorClassName == null ? void 0 : colorClassName.trim()) ? colorClassName : "text-text-action-critical-normal",
266
+ "bg-transparent border-transparent text-text-action-critical-normal",
267
+ "hover:bg-background-action-critical-secondary-hover hover:border-background-action-critical-secondary-hover hover:text-text-action-critical-hover",
268
+ "focus:bg-background-action-critical-secondary-hover focus:border-background-action-critical-secondary-hover focus:text-text-action-critical-hover focus:outline-0",
269
+ "active:bg-background-action-critical-secondary-active active:border-background-action-critical-secondary-active active:text-text-action-critical-active",
270
+ "disabled:bg-transparent disabled:border-transparent disabled:text-text-action-critical-disabled"
271
+ );
272
+ const navigationVarianStyles = variant === "navigation" && (0, import_clsx2.default)(
273
+ (colorClassName == null ? void 0 : colorClassName.trim()) ? colorClassName : "text-text-on-action-primary-normal",
274
+ "bg-transparent",
275
+ "hover:bg-background-on-action-secondary-hover hover:text-brand-text-action-primary-hover",
276
+ // "hover:bg-background-action-secondary-hover hover:text-text-action-primary-hover", // Will use this once colors are finalized
277
+ "focus:bg-background-on-action-secondary-hover focus:text-brand-text-action-primary-hover focus:outline-0",
278
+ // "focus:bg-background-action-secondary-hover focus:text-text-action-primary-hover", // Will use this once colors are finalized
279
+ "active:bg-background-on-action-secondary-active active:text-brand-text-action-primary-active",
280
+ // "active:bg-background-action-secondary-active active:text-text-action-primary-active", // Will use this once colors are finalized
281
+ "disabled:bg-transparent disabled:text-text-on-action-primary-disabled",
282
+ "flex-col",
283
+ paddingUsingComponentGap
284
+ );
285
+ const notNavigationVariantStyles = variant !== "navigation" && (0, import_clsx2.default)("border-2 flex-row", componentPaddingMinus2pxBorder, componentGap);
286
+ const buttonClasses = (0, import_clsx2.default)(
287
+ disabled ? "cursor-default" : "cursor-pointer",
288
+ block ? "w-full" : "w-fit",
289
+ baseTransition,
290
+ "rounded-sm whitespace-nowrap inline-flex items-center justify-center group/btn",
291
+ primaryVariantStyles,
292
+ secondaryVariantStyles,
293
+ tertiaryVariantStyles,
294
+ primaryCriticalVariantStyles,
295
+ secondaryCriticalVariantStyles,
296
+ tertiaryCriticalVariantStyles,
297
+ navigationVarianStyles,
298
+ notNavigationVariantStyles,
299
+ className
300
+ );
301
+ const labelClasses = (0, import_clsx2.default)(
302
+ "min-h-6 flex items-center justify-center",
303
+ classNameLabel,
304
+ componentPaddingXUsingComponentGap,
305
+ typography.buttonLabel
306
+ );
307
+ const Element = href ? "a" : as;
308
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
309
+ Element,
310
+ __spreadProps(__spreadValues({
311
+ type: Element === "button" ? "button" : void 0,
312
+ className: buttonClasses
313
+ }, props), {
314
+ disabled,
315
+ href,
316
+ children: [
317
+ leftIcon && leftIcon,
318
+ !iconOnly && children && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: labelClasses, children }),
319
+ rightIcon && rightIcon
320
+ ]
321
+ })
322
+ );
323
+ };
324
+ Button.displayName = "Button";
325
+
326
+ // src/components/Checkbox.tsx
327
+ var import_clsx5 = __toESM(require("clsx"), 1);
328
+
329
+ // src/components/Icon.tsx
330
+ var import_clsx3 = __toESM(require("clsx"), 1);
331
+ var import_jsx_runtime2 = require("react/jsx-runtime");
332
+ function Icon(_a) {
333
+ var _b = _a, {
334
+ name,
335
+ size = 24,
336
+ variant = "outline"
337
+ } = _b, props = __objRest(_b, [
338
+ "name",
339
+ "size",
340
+ "variant"
341
+ ]);
342
+ const variantStyle = variant === "filled" ? '"FILL" 1' : '"FILL" 0';
343
+ const weightStyle = size === 16 ? '"wght" 400' : '"wght" 300';
344
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
345
+ "span",
346
+ __spreadProps(__spreadValues({}, props), {
347
+ className: (0, import_clsx3.default)(
348
+ "icon",
349
+ `icon-${size}`,
350
+ // size === 16 ? "font-normal" : "font-light", // size 16 font weight is not working as normal from before
351
+ props.className
352
+ ),
353
+ style: __spreadValues({
354
+ fontVariationSettings: variantStyle + `, ${weightStyle}`
355
+ }, props.style),
356
+ children: name
357
+ })
358
+ );
359
+ }
360
+
361
+ // src/components/Paragraph.tsx
362
+ var import_clsx4 = __toESM(require("clsx"), 1);
363
+ var import_jsx_runtime3 = require("react/jsx-runtime");
364
+ var Paragraph = (_a) => {
365
+ var _b = _a, {
366
+ className,
367
+ color,
368
+ padded,
369
+ align = "left",
370
+ tall,
371
+ addOverflow,
372
+ children,
373
+ as = "p"
374
+ } = _b, props = __objRest(_b, [
375
+ "className",
376
+ "color",
377
+ "padded",
378
+ "align",
379
+ "tall",
380
+ "addOverflow",
381
+ "children",
382
+ "as"
383
+ ]);
384
+ const Element = as;
385
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
386
+ Element,
387
+ __spreadProps(__spreadValues({}, props), {
388
+ className: (0, import_clsx4.default)(
389
+ typography.paragraph,
390
+ className,
391
+ padded && componentPaddingXUsingComponentGap,
392
+ align === "left" && "text-left",
393
+ align === "center" && "text-center",
394
+ align === "right" && "text-right",
395
+ tall && "!leading-6",
396
+ addOverflow && "whitespace-nowrap text-ellipsis overflow-hidden"
397
+ ),
398
+ style: __spreadProps(__spreadValues({}, props.style), {
399
+ color: color ? `var(--color-${color})` : void 0
400
+ }),
401
+ children
402
+ })
403
+ );
404
+ };
405
+ Paragraph.displayName = "Paragraph";
406
+
407
+ // src/components/Checkbox.tsx
408
+ var import_jsx_runtime4 = require("react/jsx-runtime");
409
+ var Checkbox = (_a) => {
410
+ var _b = _a, {
411
+ label,
412
+ error,
413
+ disabled,
414
+ readOnly,
415
+ checked,
416
+ onChange,
417
+ indeterminate,
418
+ paragraphClassName
419
+ } = _b, props = __objRest(_b, [
420
+ "label",
421
+ "error",
422
+ "disabled",
423
+ "readOnly",
424
+ "checked",
425
+ "onChange",
426
+ "indeterminate",
427
+ "paragraphClassName"
428
+ ]);
429
+ const selected = indeterminate || checked;
430
+ const normalClassName = (0, import_clsx5.default)(
431
+ !selected && !error && !disabled && !readOnly && "border-border-primary-normal bg-background-action-secondary-normal peer-hover:border-border-action-hover peer-hover:bg-background-action-secondary-hover peer-active:border-border-action-active peer-active:bg-background-action-secondary-active"
432
+ );
433
+ const normalSelectedClassName = (0, import_clsx5.default)(
434
+ selected && !error && !disabled && !readOnly && "bg-background-action-primary-normal border-background-action-primary-normal peer-hover:bg-background-action-primary-hover peer-hover:border-background-action-primary-hover peer-active:bg-background-action-primary-active peer-active:border-background-action-primary-active"
435
+ );
436
+ const errorClassName = (0, import_clsx5.default)(
437
+ error && !selected && "bg-background-action-critical-secondary-normal border-border-action-critical-normal peer-hover:border-border-action-critical-hover peer-hover:bg-background-action-critical-secondary-hover peer-active:border-border-action-critical-active peer-active:bg-background-action-secondary-active"
438
+ );
439
+ const errorSelectedClassName = (0, import_clsx5.default)(
440
+ error && selected && "bg-background-action-critical-primary-normal border-background-action-critical-primary-normal peer-hover:bg-background-action-critical-primary-hover peer-hover:border-background-action-critical-primary-hover peer-active:bg-background-action-critical-primary-active peer-active:border-background-action-critical-primary-active"
441
+ );
442
+ const disabledClassName = (0, import_clsx5.default)(
443
+ disabled && !readOnly && "border-border-primary-normal bg-background-action-secondary-disabled peer-checked:bg-icon-on-action-primary-disabled peer-checked:border-icon-on-action-primary-disabled"
444
+ );
445
+ const readOnlyClassName = (0, import_clsx5.default)(
446
+ readOnly && "border-transparent bg-transparent peer-checked:bg-transparent peer-checked:border-transparent"
447
+ );
448
+ const checkColor = (0, import_clsx5.default)(
449
+ selected && !disabled && !readOnly && "color-icon-on-action-primary-normal peer-hover:color-icon-on-action-primary-hover peer-active:color-icon-on-action-primary-active",
450
+ selected && disabled && "color-background-action-primary-disabled"
451
+ );
452
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
453
+ "label",
454
+ {
455
+ className: (0, import_clsx5.default)(
456
+ "flex items-center",
457
+ componentGap,
458
+ (disabled || readOnly && error || readOnly) && "cursor-default",
459
+ !(readOnly && error) && !disabled && !readOnly && "cursor-pointer"
460
+ ),
461
+ children: [
462
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "relative", children: [
463
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
464
+ "input",
465
+ __spreadValues({
466
+ type: "checkbox",
467
+ className: "sr-only peer",
468
+ disabled,
469
+ checked: selected,
470
+ onChange: handleOnChange,
471
+ id: props.id,
472
+ "data-indeterminate": indeterminate
473
+ }, props)
474
+ ),
475
+ error && (readOnly || disabled) ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: (0, import_clsx5.default)("size-6", "flex items-center justify-center"), children: selected ? indeterminate ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "question_mark" }) }) : readOnly ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-success-400 contents", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "check" }) }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-icon-on-action-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "check", className: "pointer-events-none" }) }) : readOnly && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "close" }) }) }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
476
+ "div",
477
+ {
478
+ className: (0, import_clsx5.default)(
479
+ "size-6 border rounded-base",
480
+ "flex items-center justify-center",
481
+ baseTransition,
482
+ normalClassName,
483
+ normalSelectedClassName,
484
+ errorClassName,
485
+ errorSelectedClassName,
486
+ disabledClassName,
487
+ readOnlyClassName,
488
+ checkColor
489
+ ),
490
+ children: selected ? indeterminate ? readOnly ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "question_mark" }) }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-icon-on-action-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "remove", className: "pointer-events-none" }) }) : readOnly ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-success-400 contents", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "check" }) }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-icon-on-action-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "check", className: "pointer-events-none" }) }) : readOnly && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "close" }) })
491
+ }
492
+ )
493
+ ] }),
494
+ label && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
495
+ Paragraph,
496
+ {
497
+ as: "span",
498
+ padded: true,
499
+ className: (0, import_clsx5.default)(
500
+ "text-nowrap",
501
+ disabled && !error && "!text-text-primary-disabled",
502
+ error && !disabled && !readOnly && "!text-text-primary-error",
503
+ paragraphClassName
504
+ ),
505
+ children: label
506
+ }
507
+ )
508
+ ]
509
+ }
510
+ );
511
+ function handleOnChange(e) {
512
+ if (disabled || readOnly || readOnly && error || !onChange) {
513
+ return;
514
+ }
515
+ onChange(e);
516
+ }
517
+ };
518
+ Checkbox.displayName = "Checkbox";
519
+
520
+ // src/components/DataGridCell.tsx
521
+ var import_sortable = require("@dnd-kit/sortable");
522
+
523
+ // ../../node_modules/@dnd-kit/utilities/dist/utilities.esm.js
524
+ var import_react = require("react");
525
+ var canUseDOM = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
526
+ var CSS = /* @__PURE__ */ Object.freeze({
527
+ Translate: {
528
+ toString(transform) {
529
+ if (!transform) {
530
+ return;
531
+ }
532
+ const {
533
+ x,
534
+ y
535
+ } = transform;
536
+ return "translate3d(" + (x ? Math.round(x) : 0) + "px, " + (y ? Math.round(y) : 0) + "px, 0)";
537
+ }
538
+ },
539
+ Scale: {
540
+ toString(transform) {
541
+ if (!transform) {
542
+ return;
543
+ }
544
+ const {
545
+ scaleX,
546
+ scaleY
547
+ } = transform;
548
+ return "scaleX(" + scaleX + ") scaleY(" + scaleY + ")";
549
+ }
550
+ },
551
+ Transform: {
552
+ toString(transform) {
553
+ if (!transform) {
554
+ return;
555
+ }
556
+ return [CSS.Translate.toString(transform), CSS.Scale.toString(transform)].join(" ");
557
+ }
558
+ },
559
+ Transition: {
560
+ toString(_ref) {
561
+ let {
562
+ property,
563
+ duration,
564
+ easing
565
+ } = _ref;
566
+ return property + " " + duration + "ms " + easing;
567
+ }
568
+ }
569
+ });
570
+
571
+ // src/components/DataGridCell.tsx
572
+ var import_clsx10 = __toESM(require("clsx"), 1);
573
+ var import_react8 = require("react");
574
+
575
+ // src/components/Search.tsx
576
+ var import_react3 = require("react");
577
+
578
+ // src/components/Input.tsx
579
+ var import_react2 = require("react");
580
+ var import_clsx7 = __toESM(require("clsx"), 1);
581
+
582
+ // src/components/Label.tsx
583
+ var import_clsx6 = __toESM(require("clsx"), 1);
584
+ var import_jsx_runtime5 = require("react/jsx-runtime");
585
+ var Label = (_a) => {
586
+ var _b = _a, {
587
+ as = "span",
588
+ padded,
589
+ className,
590
+ color,
591
+ align
592
+ } = _b, props = __objRest(_b, [
593
+ "as",
594
+ "padded",
595
+ "className",
596
+ "color",
597
+ "align"
598
+ ]);
599
+ const Element = as;
600
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
601
+ Element,
602
+ __spreadProps(__spreadValues({
603
+ className: (0, import_clsx6.default)(
604
+ typography.label,
605
+ align === "left" && "text-left",
606
+ align === "center" && "text-center",
607
+ align === "right" && "text-right",
608
+ className,
609
+ padded && componentPaddingXUsingComponentGap
610
+ )
611
+ }, props), {
612
+ style: __spreadProps(__spreadValues({}, props.style), {
613
+ color: color ? `var(--color-${color})` : void 0
614
+ })
615
+ })
616
+ );
617
+ };
618
+ Label.displayName = "Label";
619
+
620
+ // src/utils/formatting.tsx
621
+ function getDecimalPlaceholder(decimals) {
622
+ if (!decimals || decimals <= 0) {
623
+ return {};
624
+ }
625
+ return {
626
+ placeholder: `0.${"0".repeat(decimals)}`
627
+ };
628
+ }
629
+ function formatDecimalValue(value, decimals) {
630
+ if (!value || value === "") {
631
+ return "";
632
+ }
633
+ const numValue = typeof value === "string" ? parseFloat(value) : value;
634
+ if (isNaN(numValue)) {
635
+ return "";
636
+ }
637
+ if (!decimals || decimals <= 0) {
638
+ return String(Math.round(numValue));
639
+ }
640
+ return numValue.toFixed(decimals);
641
+ }
642
+ function formatCurrencyDisplay(value) {
643
+ if (!value || value === "") {
644
+ return "";
645
+ }
646
+ const parts = value.split(".");
647
+ const integerPart = parts[0];
648
+ const decimalPart = parts[1];
649
+ const formattedInteger = integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
650
+ return decimalPart !== void 0 ? `${formattedInteger}.${decimalPart}` : formattedInteger;
651
+ }
652
+
653
+ // src/components/Input.tsx
654
+ var import_jsx_runtime6 = require("react/jsx-runtime");
655
+ var InputBase = (_a) => {
656
+ var _b = _a, {
657
+ before,
658
+ after,
659
+ type,
660
+ label,
661
+ error,
662
+ className,
663
+ align = "left",
664
+ caption,
665
+ required,
666
+ selectOnFocus,
667
+ removeRoundness,
668
+ inputContainerRef,
669
+ removeBorder,
670
+ wrapperClassName,
671
+ focus
672
+ } = _b, props = __objRest(_b, [
673
+ "before",
674
+ "after",
675
+ "type",
676
+ "label",
677
+ "error",
678
+ "className",
679
+ "align",
680
+ "caption",
681
+ "required",
682
+ "selectOnFocus",
683
+ "removeRoundness",
684
+ "inputContainerRef",
685
+ "removeBorder",
686
+ "wrapperClassName",
687
+ "focus"
688
+ ]);
689
+ const attributes = {
690
+ "data-error": error && !focus || null,
691
+ "data-focus": focus || null
692
+ };
693
+ const inputRef = (0, import_react2.useRef)(null);
694
+ (0, import_react2.useEffect)(() => {
695
+ var _a2;
696
+ const input = inputRef.current;
697
+ const focusHandler = () => {
698
+ input == null ? void 0 : input.select();
699
+ };
700
+ if (selectOnFocus) {
701
+ (_a2 = inputRef.current) == null ? void 0 : _a2.addEventListener("focus", focusHandler);
702
+ return () => {
703
+ input == null ? void 0 : input.removeEventListener("focus", focusHandler);
704
+ };
705
+ }
706
+ }, [selectOnFocus]);
707
+ const inputBaseClass = (0, import_clsx7.default)(
708
+ "w-full",
709
+ "flex flex-row items-center",
710
+ "bg-background-action-secondary-normal caret-icon-on-action-secondary-normal",
711
+ componentGap,
712
+ baseTransition,
713
+ "outline-transparent outline-2 -outline-offset-2",
714
+ componentPaddingMinusBorder,
715
+ !removeRoundness && "rounded-base",
716
+ !removeBorder && "border border-border-primary-normal",
717
+ "relative"
718
+ );
719
+ const inputFocusClass = (0, import_clsx7.default)(
720
+ "has-[[data-focus]]:border-transparent has-[[data-focus]]:outline-border-primary-focus focus-within:border-transparent focus-within:outline-border-primary-focus"
721
+ );
722
+ const inputDisabledClass = (0, import_clsx7.default)(
723
+ "has-disabled:bg-background-action-secondary-disabled"
724
+ );
725
+ const inputReadOnlyClass = (0, import_clsx7.default)(
726
+ "has-[input:not(:disabled):read-only]:outline-none has-[input:not(:disabled):read-only]:bg-transparent has-[input:not(:disabled):read-only]:border-transparent has-[input:not(:disabled):read-only]:pl-0"
727
+ );
728
+ const inputInvalidClass = (0, import_clsx7.default)(
729
+ "has-[[data-error]]:border-transparent has-[[data-error]]:not-focus-within:outline-border-primary-error has-[[data-error]]:not-focus-within:outline-1"
730
+ );
731
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
732
+ "label",
733
+ {
734
+ ref: inputContainerRef,
735
+ className: (0, import_clsx7.default)(
736
+ "w-full flex flex-col",
737
+ "block",
738
+ "text-text-primary-normal has-disabled:text-text-primary-disabled",
739
+ componentGap
740
+ ),
741
+ style: __spreadValues({}, props.style),
742
+ children: [
743
+ label && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: (0, import_clsx7.default)("flex items-center", componentGap), children: [
744
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
745
+ Label,
746
+ {
747
+ className: (0, import_clsx7.default)(
748
+ props.disabled || props.readOnly ? "cursor-default" : "cursor-pointer"
749
+ ),
750
+ children: label
751
+ }
752
+ ),
753
+ required && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
754
+ "span",
755
+ {
756
+ className: (0, import_clsx7.default)(typography.label, "text-text-critical-normal"),
757
+ children: "*"
758
+ }
759
+ )
760
+ ] }),
761
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
762
+ "div",
763
+ {
764
+ className: (0, import_clsx7.default)(
765
+ inputBaseClass,
766
+ !props.disabled && inputInvalidClass,
767
+ inputFocusClass,
768
+ inputDisabledClass,
769
+ inputReadOnlyClass,
770
+ wrapperClassName
771
+ ),
772
+ children: [
773
+ before,
774
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
775
+ "input",
776
+ __spreadProps(__spreadValues(__spreadValues({
777
+ ref: (el) => {
778
+ inputRef.current = el;
779
+ },
780
+ type,
781
+ required
782
+ }, props), attributes), {
783
+ id: props.id,
784
+ className: (0, import_clsx7.default)(
785
+ "flex-1 outline-none w-full max-w-full min-h-6 min-w-0",
786
+ "[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none",
787
+ "placeholder:text-text-secondary-normal disabled:text-text-secondary-disabled",
788
+ align === "right" && "text-right",
789
+ align === "center" && "text-center",
790
+ componentPaddingXUsingComponentGap,
791
+ typography.paragraph,
792
+ className,
793
+ props.readOnly && !props.disabled && "!px-0"
794
+ )
795
+ })
796
+ ),
797
+ after
798
+ ]
799
+ }
800
+ ),
801
+ caption
802
+ ]
803
+ }
804
+ );
805
+ };
806
+ var Input = (_a) => {
807
+ var _b = _a, {
808
+ variant = "default",
809
+ decimals,
810
+ uom,
811
+ removeSearchIcon,
812
+ value: propValue,
813
+ onChange,
814
+ onBlur,
815
+ onClear
816
+ } = _b, props = __objRest(_b, [
817
+ "variant",
818
+ "decimals",
819
+ "uom",
820
+ "removeSearchIcon",
821
+ "value",
822
+ "onChange",
823
+ "onBlur",
824
+ "onClear"
825
+ ]);
826
+ const [internalValue, setInternalValue] = (0, import_react2.useState)("");
827
+ const [displayValue, setDisplayValue] = (0, import_react2.useState)("");
828
+ (0, import_react2.useEffect)(() => {
829
+ var _a2;
830
+ const stringValue = (_a2 = propValue == null ? void 0 : propValue.toString()) != null ? _a2 : "";
831
+ if (variant === "currency") {
832
+ if (propValue === void 0 || propValue === "" || typeof propValue === "number" && isNaN(propValue)) {
833
+ setInternalValue("");
834
+ setDisplayValue("");
835
+ } else {
836
+ const numValue = typeof propValue === "string" ? parseFloat(propValue) : propValue;
837
+ if (!isNaN(numValue)) {
838
+ const formatted = numValue.toFixed(decimals != null ? decimals : 2);
839
+ setInternalValue(formatted);
840
+ setDisplayValue(formatCurrencyDisplay(formatted));
841
+ }
842
+ }
843
+ } else {
844
+ setInternalValue(stringValue);
845
+ setDisplayValue(stringValue);
846
+ }
847
+ }, [propValue, decimals, variant]);
848
+ const getInputProps = () => {
849
+ var _a2;
850
+ const baseProps = __spreadProps(__spreadValues(__spreadValues({}, props), getDecimalPlaceholder(decimals)), {
851
+ value: propValue
852
+ });
853
+ switch (variant) {
854
+ case "search":
855
+ return __spreadProps(__spreadValues({}, baseProps), {
856
+ placeholder: (_a2 = props.placeholder) != null ? _a2 : "Search",
857
+ className: "!mr-6",
858
+ value: displayValue
859
+ });
860
+ case "finder":
861
+ return baseProps;
862
+ case "currency":
863
+ return __spreadProps(__spreadValues({}, baseProps), {
864
+ align: "right",
865
+ type: "text",
866
+ value: displayValue
867
+ });
868
+ case "percentage":
869
+ case "uom":
870
+ return __spreadProps(__spreadValues({}, baseProps), {
871
+ type: "number",
872
+ align: "right"
873
+ });
874
+ default:
875
+ return baseProps;
876
+ }
877
+ };
878
+ const getBeforeElement = () => {
879
+ if (props.before) return props.before;
880
+ switch (variant) {
881
+ case "search":
882
+ return !removeSearchIcon ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "search" }) }) : null;
883
+ case "currency":
884
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "attach_money" }) });
885
+ default:
886
+ return null;
887
+ }
888
+ };
889
+ const getAfterElement = () => {
890
+ if (props.after) return props.after;
891
+ switch (variant) {
892
+ case "search": {
893
+ const hasValue = displayValue.length > 0;
894
+ return hasValue && !props.readOnly ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
895
+ Icon,
896
+ {
897
+ name: "close",
898
+ onClick: handleSearchReset,
899
+ className: "cursor-pointer absolute right-2 bottom-2/4 translate-y-2/4"
900
+ }
901
+ ) : null;
902
+ }
903
+ case "finder":
904
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "search" });
905
+ case "uom":
906
+ return uom ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-text-secondary-normal uppercase", children: uom.slice(0, 4) }) : null;
907
+ case "percentage":
908
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "percent" }) });
909
+ default:
910
+ return null;
911
+ }
912
+ };
913
+ const handleSearchReset = () => {
914
+ setInternalValue("");
915
+ setDisplayValue("");
916
+ if (onChange) {
917
+ const syntheticEvent = {
918
+ target: { value: "" }
919
+ };
920
+ if (typeof onChange === "function") {
921
+ onChange(syntheticEvent);
922
+ }
923
+ }
924
+ onClear == null ? void 0 : onClear();
925
+ };
926
+ const handleChange = (e) => {
927
+ const rawValue = e.target.value;
928
+ if (variant === "search") {
929
+ setInternalValue(rawValue);
930
+ setDisplayValue(rawValue);
931
+ if (typeof onChange === "function") {
932
+ onChange(e);
933
+ }
934
+ return;
935
+ }
936
+ if (variant === "currency") {
937
+ const raw = rawValue.replace(/,/g, "");
938
+ if (raw === "") {
939
+ setInternalValue("");
940
+ setDisplayValue("");
941
+ if (onChange) {
942
+ const syntheticEvent = __spreadProps(__spreadValues({}, e), {
943
+ target: __spreadProps(__spreadValues({}, e.target), { value: "" })
944
+ });
945
+ onChange(syntheticEvent);
946
+ }
947
+ return;
948
+ }
949
+ const regex = /^\d*\.?\d*$/;
950
+ if (!regex.test(raw)) return;
951
+ const parts = raw.split(".");
952
+ const currentDecimals = decimals != null ? decimals : 2;
953
+ if (parts.length === 2 && parts[1].length > currentDecimals) return;
954
+ setInternalValue(raw);
955
+ setDisplayValue(formatCurrencyDisplay(raw));
956
+ const asNumber = Number(raw);
957
+ if (!isNaN(asNumber) && onChange) {
958
+ const syntheticEvent = __spreadProps(__spreadValues({}, e), {
959
+ target: __spreadProps(__spreadValues({}, e.target), { value: asNumber.toString() })
960
+ });
961
+ onChange(syntheticEvent);
962
+ }
963
+ return;
964
+ }
965
+ setInternalValue(rawValue);
966
+ setDisplayValue(rawValue);
967
+ if (typeof onChange === "function") {
968
+ onChange(e);
969
+ }
970
+ };
971
+ const handleBlur = (e) => {
972
+ if (variant === "currency") {
973
+ const formatted = formatDecimalValue(internalValue, decimals != null ? decimals : 2);
974
+ setInternalValue(formatted);
975
+ setDisplayValue(formatCurrencyDisplay(formatted));
976
+ const asNumber = Number(formatted);
977
+ if (!isNaN(asNumber) && onChange) {
978
+ const syntheticEvent = __spreadProps(__spreadValues({}, e), {
979
+ target: __spreadProps(__spreadValues({}, e.target), { value: asNumber.toString() })
980
+ });
981
+ onChange(syntheticEvent);
982
+ }
983
+ } else if (variant === "uom" || variant === "percentage") {
984
+ const formattedValue = formatDecimalValue(e.target.value, decimals);
985
+ e.target.value = formattedValue;
986
+ }
987
+ onBlur == null ? void 0 : onBlur(e);
988
+ };
989
+ const inputProps = getInputProps();
990
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
991
+ InputBase,
992
+ __spreadProps(__spreadValues({}, inputProps), {
993
+ before: getBeforeElement(),
994
+ after: getAfterElement(),
995
+ onChange: handleChange,
996
+ onBlur: handleBlur
997
+ })
998
+ );
999
+ };
1000
+ Input.displayName = "Input";
1001
+ var Finder = (props) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Input, __spreadProps(__spreadValues({}, props), { variant: "finder" }));
1002
+ var UOM = (props) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Input, __spreadProps(__spreadValues({}, props), { variant: "uom" }));
1003
+ var Currency = (props) => {
1004
+ var _a;
1005
+ const handleCurrencyChange = (e) => {
1006
+ var _a2;
1007
+ (_a2 = props.onChange) == null ? void 0 : _a2.call(props, e);
1008
+ };
1009
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1010
+ Input,
1011
+ __spreadProps(__spreadValues({}, props), {
1012
+ variant: "currency",
1013
+ decimals: (_a = props.decimals) != null ? _a : 2,
1014
+ onChange: handleCurrencyChange
1015
+ })
1016
+ );
1017
+ };
1018
+ var Percentage = (props) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Input, __spreadProps(__spreadValues({}, props), { variant: "percentage" }));
1019
+ Finder.displayName = "Finder";
1020
+ UOM.displayName = "UOM";
1021
+ Currency.displayName = "Currency";
1022
+ Percentage.displayName = "Percentage";
1023
+
1024
+ // src/components/Search.tsx
1025
+ var import_jsx_runtime7 = require("react/jsx-runtime");
1026
+ var Search = (_a) => {
1027
+ var _b = _a, {
1028
+ label,
1029
+ error,
1030
+ children,
1031
+ readOnly,
1032
+ renderMenu,
1033
+ onClick,
1034
+ className,
1035
+ wrapperClassName,
1036
+ removeRoundness
1037
+ } = _b, props = __objRest(_b, [
1038
+ "label",
1039
+ "error",
1040
+ "children",
1041
+ "readOnly",
1042
+ "renderMenu",
1043
+ "onClick",
1044
+ "className",
1045
+ "wrapperClassName",
1046
+ "removeRoundness"
1047
+ ]);
1048
+ const inputRef = (0, import_react3.useRef)(null);
1049
+ const inputContainerRef = (0, import_react3.useRef)(null);
1050
+ const preventFocusOnInitialRender = (0, import_react3.useRef)(true);
1051
+ const [show, setShow] = (0, import_react3.useState)(false);
1052
+ const [clearing, setClearing] = (0, import_react3.useState)(false);
1053
+ const uniqueId = (0, import_react3.useId)();
1054
+ const searchMenuName = `search-menu-${uniqueId}`;
1055
+ (0, import_react3.useEffect)(() => {
1056
+ var _a2;
1057
+ if (preventFocusOnInitialRender.current) {
1058
+ preventFocusOnInitialRender.current = false;
1059
+ return;
1060
+ }
1061
+ (_a2 = inputRef.current) == null ? void 0 : _a2.focus();
1062
+ }, [props.value]);
1063
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
1064
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1065
+ Input,
1066
+ __spreadValues({
1067
+ variant: "search",
1068
+ inputContainerRef,
1069
+ ref: inputRef,
1070
+ label,
1071
+ wrapperClassName,
1072
+ onClick: (e) => {
1073
+ if (props.disabled || readOnly) {
1074
+ return;
1075
+ }
1076
+ if (clearing) {
1077
+ setClearing(false);
1078
+ return;
1079
+ }
1080
+ onClick == null ? void 0 : onClick(e);
1081
+ setShow(!show);
1082
+ },
1083
+ onClear: () => {
1084
+ setClearing(true);
1085
+ },
1086
+ onKeyDown: (e) => {
1087
+ setShow(true);
1088
+ if (["ArrowUp", "ArrowDown"].includes(e.key)) {
1089
+ e.preventDefault();
1090
+ const menu = document.querySelector(`[data-menu="${searchMenuName}"]`);
1091
+ const selectedMenuOption = menu == null ? void 0 : menu.querySelector("[data-selected]");
1092
+ if (selectedMenuOption) {
1093
+ const allMenuOptions = Array.from((menu == null ? void 0 : menu.querySelectorAll('[role="menuitem"]')) || []);
1094
+ const currentIndex = allMenuOptions.indexOf(selectedMenuOption);
1095
+ let targetOption;
1096
+ if (e.key === "ArrowDown") {
1097
+ targetOption = allMenuOptions[currentIndex + 1] || allMenuOptions[0];
1098
+ } else {
1099
+ targetOption = allMenuOptions[currentIndex - 1] || allMenuOptions[allMenuOptions.length - 1];
1100
+ }
1101
+ targetOption == null ? void 0 : targetOption.focus();
1102
+ } else {
1103
+ const toFocusMenuOption = e.key === "ArrowDown" ? menu == null ? void 0 : menu.querySelector('[role="menuitem"]') : menu == null ? void 0 : menu.querySelector('[role="menuitem"]:last-child');
1104
+ toFocusMenuOption == null ? void 0 : toFocusMenuOption.focus();
1105
+ }
1106
+ }
1107
+ },
1108
+ error,
1109
+ readOnly,
1110
+ removeRoundness,
1111
+ focus: show
1112
+ }, props)
1113
+ ),
1114
+ renderMenu ? renderMenu({
1115
+ positionTo: inputContainerRef,
1116
+ show,
1117
+ setShow,
1118
+ topOffset: props.caption ? -16 : null,
1119
+ autoFocusOff: true,
1120
+ menuName: searchMenuName
1121
+ }) : children
1122
+ ] });
1123
+ };
1124
+ Search.displayName = "Search";
1125
+
1126
+ // src/components/Menu.tsx
1127
+ var import_clsx8 = __toESM(require("clsx"), 1);
1128
+ var import_react6 = require("react");
1129
+ var import_react_dom = require("react-dom");
1130
+
1131
+ // src/components/useMenuSystem.tsx
1132
+ var import_react5 = require("react");
1133
+
1134
+ // src/components/useMatchesMedia.tsx
1135
+ var import_react4 = require("react");
1136
+ var useMatchesMedia = (query) => {
1137
+ const [matches, setMatches] = (0, import_react4.useState)(
1138
+ () => typeof window !== "undefined" ? window.matchMedia(query).matches : false
1139
+ );
1140
+ (0, import_react4.useLayoutEffect)(() => {
1141
+ const mediaQueryList = window.matchMedia(query);
1142
+ const listener = (event) => {
1143
+ setMatches(event.matches);
1144
+ };
1145
+ mediaQueryList.addEventListener("change", listener);
1146
+ setMatches(mediaQueryList.matches);
1147
+ return () => {
1148
+ mediaQueryList.removeEventListener("change", listener);
1149
+ };
1150
+ }, [query]);
1151
+ return matches;
1152
+ };
1153
+ var useMatchesMobile = () => {
1154
+ const isMobile = useMatchesMedia("(width < 48rem)");
1155
+ return isMobile;
1156
+ };
1157
+
1158
+ // src/components/useMenuSystem.tsx
1159
+ function useSubMenuSystem(mobilePositionTo) {
1160
+ const [activeMenus, setActiveMenus] = (0, import_react5.useState)(
1161
+ {}
1162
+ );
1163
+ const [activeMenu, setActiveMenu] = (0, import_react5.useState)("");
1164
+ const [currentSubMenuLevel, setCurrentSubMenuLevel] = (0, import_react5.useState)(null);
1165
+ const menuRootRef = (0, import_react5.useRef)(null);
1166
+ const subMenuRefs = (0, import_react5.useRef)({});
1167
+ const hoverTimeoutRef = (0, import_react5.useRef)(null);
1168
+ const closeTimeoutRef = (0, import_react5.useRef)(null);
1169
+ const isMobile = useMatchesMobile();
1170
+ const toggleMenu = (menuId, level) => {
1171
+ if (closeTimeoutRef.current) {
1172
+ clearTimeout(closeTimeoutRef.current);
1173
+ closeTimeoutRef.current = null;
1174
+ }
1175
+ setActiveMenu(menuId);
1176
+ setCurrentSubMenuLevel(level);
1177
+ setActiveMenus((prev) => {
1178
+ const newActiveMenus = __spreadValues({}, prev);
1179
+ if (newActiveMenus[level] === menuId) {
1180
+ delete newActiveMenus[level];
1181
+ } else {
1182
+ newActiveMenus[level] = menuId;
1183
+ }
1184
+ Object.keys(newActiveMenus).forEach((key) => {
1185
+ if (Number(key) > level) {
1186
+ delete newActiveMenus[Number(key)];
1187
+ }
1188
+ });
1189
+ return newActiveMenus;
1190
+ });
1191
+ };
1192
+ const openMenu = (menuId, level) => {
1193
+ if (closeTimeoutRef.current) {
1194
+ clearTimeout(closeTimeoutRef.current);
1195
+ closeTimeoutRef.current = null;
1196
+ }
1197
+ setActiveMenus((prev) => {
1198
+ const newActiveMenus = __spreadValues({}, prev);
1199
+ newActiveMenus[level] = menuId;
1200
+ Object.keys(newActiveMenus).forEach((key) => {
1201
+ if (Number(key) > level) {
1202
+ delete newActiveMenus[Number(key)];
1203
+ }
1204
+ });
1205
+ return newActiveMenus;
1206
+ });
1207
+ };
1208
+ const openMenuWithDelay = (menuId, level, delay = 150) => {
1209
+ if (isMobile) {
1210
+ return;
1211
+ }
1212
+ if (hoverTimeoutRef.current) {
1213
+ clearTimeout(hoverTimeoutRef.current);
1214
+ }
1215
+ hoverTimeoutRef.current = setTimeout(() => {
1216
+ openMenu(menuId, level);
1217
+ }, delay);
1218
+ };
1219
+ const closeMenuWithDelay = (level, delay = 500) => {
1220
+ if (isMobile) {
1221
+ return;
1222
+ }
1223
+ if (hoverTimeoutRef.current) {
1224
+ clearTimeout(hoverTimeoutRef.current);
1225
+ hoverTimeoutRef.current = null;
1226
+ }
1227
+ closeTimeoutRef.current = setTimeout(() => {
1228
+ closeSubMenuLevel(level);
1229
+ }, delay);
1230
+ };
1231
+ const cancelCloseTimeout = () => {
1232
+ if (isMobile) {
1233
+ return;
1234
+ }
1235
+ if (closeTimeoutRef.current) {
1236
+ clearTimeout(closeTimeoutRef.current);
1237
+ closeTimeoutRef.current = null;
1238
+ }
1239
+ };
1240
+ const closeSubMenuLevel = (level) => {
1241
+ setActiveMenus((prev) => {
1242
+ const newActiveMenus = __spreadValues({}, prev);
1243
+ delete newActiveMenus[level];
1244
+ Object.keys(newActiveMenus).forEach((key) => {
1245
+ if (Number(key) >= level) {
1246
+ delete newActiveMenus[Number(key)];
1247
+ }
1248
+ });
1249
+ if (isMobile) {
1250
+ const newSubMenuLevel = level - 1;
1251
+ setCurrentSubMenuLevel(newSubMenuLevel);
1252
+ const newActiveMenu = newActiveMenus[newSubMenuLevel];
1253
+ if (Object.keys(newActiveMenus).length > 0 && newActiveMenu) {
1254
+ setActiveMenu(newActiveMenu);
1255
+ }
1256
+ }
1257
+ return newActiveMenus;
1258
+ });
1259
+ };
1260
+ const registerSubMenu = (id, element) => {
1261
+ subMenuRefs.current[id] = element;
1262
+ };
1263
+ const isMenuActive = (menuId, level) => {
1264
+ return activeMenus[level] === menuId;
1265
+ };
1266
+ (0, import_react5.useEffect)(() => {
1267
+ const handleClickOutside = (event) => {
1268
+ var _a;
1269
+ if (Object.keys(activeMenus).length === 0) return;
1270
+ const target = event.target;
1271
+ if ((_a = menuRootRef.current) == null ? void 0 : _a.contains(target)) return;
1272
+ const isInsideActiveSubmenu = Object.values(activeMenus).some((id) => {
1273
+ const submenuEl = subMenuRefs.current[id];
1274
+ return submenuEl == null ? void 0 : submenuEl.contains(target);
1275
+ });
1276
+ if (!isInsideActiveSubmenu) {
1277
+ setActiveMenus({});
1278
+ }
1279
+ };
1280
+ document.addEventListener("mousedown", handleClickOutside);
1281
+ return () => {
1282
+ document.removeEventListener("mousedown", handleClickOutside);
1283
+ };
1284
+ }, [activeMenus]);
1285
+ (0, import_react5.useEffect)(() => {
1286
+ return () => {
1287
+ if (hoverTimeoutRef.current) {
1288
+ clearTimeout(hoverTimeoutRef.current);
1289
+ }
1290
+ if (closeTimeoutRef.current) {
1291
+ clearTimeout(closeTimeoutRef.current);
1292
+ }
1293
+ };
1294
+ }, []);
1295
+ const getAllFocusableMenuElements = () => {
1296
+ const elements = [];
1297
+ if (menuRootRef.current) {
1298
+ elements.push(...Array.from(menuRootRef.current.children));
1299
+ }
1300
+ Object.values(activeMenus).forEach((menuId) => {
1301
+ const submenuEl = subMenuRefs.current[menuId];
1302
+ if (submenuEl) {
1303
+ elements.push(...Array.from(submenuEl.children));
1304
+ }
1305
+ });
1306
+ return elements;
1307
+ };
1308
+ const findCurrentMenuLevel = (element) => {
1309
+ let current = element.parentElement;
1310
+ while (current) {
1311
+ const level = current.getAttribute("data-menu-level");
1312
+ if (level !== null) {
1313
+ return parseInt(level, 10);
1314
+ }
1315
+ current = current.parentElement;
1316
+ }
1317
+ return 0;
1318
+ };
1319
+ const getMenuElementsAtLevel = (level) => {
1320
+ var _a;
1321
+ if (level === 0 && menuRootRef.current) {
1322
+ return Array.from(menuRootRef.current.children);
1323
+ }
1324
+ const menuId = (_a = Object.entries(activeMenus).find(([, id]) => {
1325
+ const submenuEl = subMenuRefs.current[id];
1326
+ return submenuEl && submenuEl.getAttribute("data-menu-level") === level.toString();
1327
+ })) == null ? void 0 : _a[1];
1328
+ if (menuId) {
1329
+ const submenuEl = subMenuRefs.current[menuId];
1330
+ if (submenuEl) {
1331
+ return Array.from(submenuEl.children);
1332
+ }
1333
+ }
1334
+ return [];
1335
+ };
1336
+ return {
1337
+ menuRootRef,
1338
+ activeMenus,
1339
+ openMenu,
1340
+ isMenuActive,
1341
+ registerSubMenu,
1342
+ closeSubMenuLevel,
1343
+ getAllFocusableMenuElements,
1344
+ findCurrentMenuLevel,
1345
+ getMenuElementsAtLevel,
1346
+ mobileHide: isMobile && Object.keys(activeMenus).length > 0,
1347
+ listeners: {
1348
+ onSubMenuHover: openMenuWithDelay,
1349
+ onSubMenuLeave: closeMenuWithDelay,
1350
+ onSubMenuEnter: cancelCloseTimeout,
1351
+ toggleMenu,
1352
+ mobilePositionTo,
1353
+ activeMenu,
1354
+ currentSubMenuLevel,
1355
+ closeSubMenuLevel
1356
+ }
1357
+ };
1358
+ }
1359
+ function useMenuPosition(elementRef, position = "bottom", options) {
1360
+ const [menuPosition, setMenuPosition] = (0, import_react5.useState)({
1361
+ top: 0,
1362
+ left: 0,
1363
+ minWidth: 0
1364
+ });
1365
+ const isMobile = useMatchesMobile();
1366
+ const updatePosition = (0, import_react5.useCallback)(() => {
1367
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
1368
+ if (!(elementRef == null ? void 0 : elementRef.current)) return;
1369
+ const triggerRect = elementRef.current.getBoundingClientRect();
1370
+ const menuRect = (_b = (_a = options == null ? void 0 : options.menuRef) == null ? void 0 : _a.current) == null ? void 0 : _b.getBoundingClientRect();
1371
+ const viewportWidth = window.innerWidth;
1372
+ const menuWidth = (menuRect == null ? void 0 : menuRect.width) || triggerRect.width;
1373
+ const topOffset = (_c = options == null ? void 0 : options.topOffset) != null ? _c : 4;
1374
+ let top = 0;
1375
+ let left = 0;
1376
+ if (position === "bottom" || position === "bottom-right") {
1377
+ top = triggerRect.top + triggerRect.height + topOffset;
1378
+ } else {
1379
+ top = triggerRect.top;
1380
+ }
1381
+ if (position === "bottom") {
1382
+ left = triggerRect.left + window.scrollX;
1383
+ } else if (position === "bottom-right") {
1384
+ left = triggerRect.right + window.scrollX - menuWidth;
1385
+ } else if (position === "right") {
1386
+ left = triggerRect.right + window.scrollX;
1387
+ }
1388
+ const overflowsLeftViewport = left + menuWidth > viewportWidth;
1389
+ if (overflowsLeftViewport) {
1390
+ left = triggerRect.left - menuWidth;
1391
+ }
1392
+ if (isMobile) {
1393
+ left = triggerRect.left + menuWidth > viewportWidth ? Math.max(viewportWidth - menuWidth, 0) - 8 : triggerRect.left;
1394
+ top = ((_f = (_e = (_d = elementRef.current.parentElement) == null ? void 0 : _d.getBoundingClientRect()) == null ? void 0 : _e.top) != null ? _f : 0) + ((_i = (_h = (_g = elementRef.current.parentElement) == null ? void 0 : _g.getBoundingClientRect()) == null ? void 0 : _h.height) != null ? _i : 0) + topOffset;
1395
+ }
1396
+ setMenuPosition({
1397
+ top,
1398
+ left,
1399
+ minWidth: triggerRect.width
1400
+ });
1401
+ }, [elementRef, position, options == null ? void 0 : options.menuRef, options == null ? void 0 : options.topOffset, isMobile]);
1402
+ (0, import_react5.useEffect)(() => {
1403
+ if (!(options == null ? void 0 : options.isOpen) || !(options == null ? void 0 : options.setIsOpen)) return;
1404
+ const handleClickOutside = (event) => {
1405
+ var _a, _b, _c, _d, _e;
1406
+ const target = event.target;
1407
+ if ((_a = elementRef.current) == null ? void 0 : _a.contains(target)) return;
1408
+ if ((_c = (_b = options.menuRef) == null ? void 0 : _b.current) == null ? void 0 : _c.contains(target)) return;
1409
+ if ((_d = options.additionalRefs) == null ? void 0 : _d.some((ref) => {
1410
+ var _a2;
1411
+ return (_a2 = ref.current) == null ? void 0 : _a2.contains(target);
1412
+ }))
1413
+ return;
1414
+ (_e = options.setIsOpen) == null ? void 0 : _e.call(options, false);
1415
+ };
1416
+ document.addEventListener("mousedown", handleClickOutside);
1417
+ return () => {
1418
+ document.removeEventListener("mousedown", handleClickOutside);
1419
+ };
1420
+ }, [
1421
+ options,
1422
+ elementRef,
1423
+ options == null ? void 0 : options.isOpen,
1424
+ options == null ? void 0 : options.setIsOpen,
1425
+ options == null ? void 0 : options.menuRef,
1426
+ options == null ? void 0 : options.additionalRefs
1427
+ ]);
1428
+ (0, import_react5.useEffect)(() => {
1429
+ updatePosition();
1430
+ const resizeObserver = new ResizeObserver(updatePosition);
1431
+ if (elementRef == null ? void 0 : elementRef.current) {
1432
+ resizeObserver.observe(elementRef.current);
1433
+ }
1434
+ window.addEventListener("scroll", updatePosition);
1435
+ window.addEventListener("resize", updatePosition);
1436
+ return () => {
1437
+ resizeObserver.disconnect();
1438
+ window.removeEventListener("scroll", updatePosition);
1439
+ window.removeEventListener("resize", updatePosition);
1440
+ };
1441
+ }, [elementRef, updatePosition]);
1442
+ return { menuPosition, updatePosition };
1443
+ }
1444
+
1445
+ // src/utils.ts
1446
+ function findDocumentRoot(element) {
1447
+ if (typeof window === "undefined" || typeof document === "undefined") {
1448
+ throw new Error(
1449
+ "findDocumentRoot can only be used in a browser environment."
1450
+ );
1451
+ }
1452
+ if (!element || !(element instanceof Node)) {
1453
+ return window.document.body;
1454
+ }
1455
+ var currentElement = element;
1456
+ while (currentElement && currentElement.parentNode) {
1457
+ if (currentElement.parentNode === document) {
1458
+ return document.body;
1459
+ } else if (currentElement.parentNode instanceof DocumentFragment) {
1460
+ return currentElement.parentNode;
1461
+ } else {
1462
+ currentElement = currentElement.parentNode;
1463
+ }
1464
+ }
1465
+ return window.document.body;
1466
+ }
1467
+
1468
+ // src/components/Menu.tsx
1469
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1470
+ var Menu = (_a) => {
1471
+ var _b = _a, {
1472
+ children,
1473
+ className,
1474
+ ref,
1475
+ positionTo,
1476
+ mobilePositionTo,
1477
+ show,
1478
+ setShow,
1479
+ position = "bottom",
1480
+ maxHeight: customMaxHeight,
1481
+ topOffset,
1482
+ mobileBackMenuOption,
1483
+ mobileHide,
1484
+ useDefaultMinWidth,
1485
+ autoFocusOff,
1486
+ menuName
1487
+ } = _b, props = __objRest(_b, [
1488
+ "children",
1489
+ "className",
1490
+ "ref",
1491
+ "positionTo",
1492
+ "mobilePositionTo",
1493
+ "show",
1494
+ "setShow",
1495
+ "position",
1496
+ "maxHeight",
1497
+ "topOffset",
1498
+ "mobileBackMenuOption",
1499
+ "mobileHide",
1500
+ "useDefaultMinWidth",
1501
+ "autoFocusOff",
1502
+ "menuName"
1503
+ ]);
1504
+ const internalRef = (0, import_react6.useRef)(null);
1505
+ const actualRef = ref || internalRef;
1506
+ const [maxHeight, setMaxHeight] = (0, import_react6.useState)("180px");
1507
+ const isMobile = useMatchesMobile();
1508
+ const { menuPosition, updatePosition } = useMenuPosition(
1509
+ isMobile && mobilePositionTo ? mobilePositionTo : positionTo,
1510
+ position,
1511
+ {
1512
+ isOpen: show,
1513
+ setIsOpen: setShow,
1514
+ menuRef: internalRef,
1515
+ topOffset
1516
+ }
1517
+ );
1518
+ (0, import_react6.useEffect)(() => {
1519
+ const raf = requestAnimationFrame(() => {
1520
+ if (!actualRef || !actualRef.current || customMaxHeight) {
1521
+ return;
1522
+ }
1523
+ if (actualRef.current.childElementCount > 4) {
1524
+ let accumulatedHeight = 0;
1525
+ Array.from(actualRef.current.children).forEach((child, index) => {
1526
+ if (index >= 5) {
1527
+ return;
1528
+ }
1529
+ accumulatedHeight += child.clientHeight;
1530
+ });
1531
+ accumulatedHeight = accumulatedHeight / 5 * 4.5;
1532
+ setMaxHeight(`${accumulatedHeight}px`);
1533
+ }
1534
+ });
1535
+ return () => {
1536
+ cancelAnimationFrame(raf);
1537
+ };
1538
+ }, [actualRef, customMaxHeight]);
1539
+ (0, import_react6.useEffect)(() => {
1540
+ if (!show) {
1541
+ return;
1542
+ }
1543
+ initializeMenuFocus();
1544
+ updatePosition();
1545
+ }, [show, updatePosition]);
1546
+ (0, import_react6.useEffect)(() => {
1547
+ if (!show || !setShow) {
1548
+ return;
1549
+ }
1550
+ const handleEscapeKey = (event) => {
1551
+ var _a2;
1552
+ if (event.key !== "Escape") {
1553
+ return;
1554
+ }
1555
+ setShow(false);
1556
+ (_a2 = positionTo == null ? void 0 : positionTo.current) == null ? void 0 : _a2.focus();
1557
+ };
1558
+ document.addEventListener("keydown", handleEscapeKey);
1559
+ return () => {
1560
+ document.removeEventListener("keydown", handleEscapeKey);
1561
+ };
1562
+ }, [show, setShow, positionTo]);
1563
+ return show && (0, import_react_dom.createPortal)(
1564
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1565
+ "div",
1566
+ __spreadProps(__spreadValues({
1567
+ ref: setRefs,
1568
+ className: (0, import_clsx8.default)(
1569
+ "shadow-4 rounded-base bg-background-grouped-primary-normal overflow-x-hidden overflow-y-auto flex flex-col outline-0",
1570
+ "fixed",
1571
+ "z-50",
1572
+ mobileHide && "opacity-0 pointer-events-none",
1573
+ className
1574
+ )
1575
+ }, props), {
1576
+ style: __spreadProps(__spreadValues(__spreadProps(__spreadValues({}, props.style), {
1577
+ maxHeight: customMaxHeight || maxHeight
1578
+ }), menuPosition), {
1579
+ minWidth: useDefaultMinWidth ? "212px" : menuPosition.minWidth
1580
+ }),
1581
+ onKeyDown: handleKeydown,
1582
+ onMouseDown: stopPropagation,
1583
+ onMouseUp: stopPropagation,
1584
+ onTouchStart: stopPropagation,
1585
+ onTouchEnd: stopPropagation,
1586
+ tabIndex: -1,
1587
+ "data-menu": menuName != null ? menuName : "",
1588
+ children: [
1589
+ mobileBackMenuOption == null ? void 0 : mobileBackMenuOption(),
1590
+ children
1591
+ ]
1592
+ })
1593
+ ),
1594
+ findDocumentRoot(internalRef.current)
1595
+ );
1596
+ function handleKeydown(e) {
1597
+ var _a2, _b2;
1598
+ if (!internalRef.current) {
1599
+ return;
1600
+ }
1601
+ if (e.key !== "Escape") {
1602
+ e.stopPropagation();
1603
+ }
1604
+ const menuOptions = Array.from(
1605
+ internalRef.current.querySelectorAll('[role="menuitem"]')
1606
+ );
1607
+ if (menuOptions.length === 0) {
1608
+ return;
1609
+ }
1610
+ let currentIndex = -1;
1611
+ const focusedElement = document.activeElement;
1612
+ for (let i = 0; i < menuOptions.length; i++) {
1613
+ if (menuOptions[i] === focusedElement) {
1614
+ currentIndex = i;
1615
+ break;
1616
+ }
1617
+ }
1618
+ switch (e.key) {
1619
+ case "ArrowDown": {
1620
+ e.preventDefault();
1621
+ const nextIndex = currentIndex < menuOptions.length - 1 ? currentIndex + 1 : 0;
1622
+ menuOptions[nextIndex].focus();
1623
+ break;
1624
+ }
1625
+ case "ArrowUp": {
1626
+ e.preventDefault();
1627
+ const prevIndex = currentIndex > 0 ? currentIndex - 1 : menuOptions.length - 1;
1628
+ menuOptions[prevIndex].focus();
1629
+ break;
1630
+ }
1631
+ case "Home":
1632
+ e.preventDefault();
1633
+ menuOptions[0].focus();
1634
+ break;
1635
+ case "End":
1636
+ e.preventDefault();
1637
+ menuOptions[menuOptions.length - 1].focus();
1638
+ break;
1639
+ case "Enter":
1640
+ case " ":
1641
+ case "ArrowRight":
1642
+ e.preventDefault();
1643
+ if (currentIndex >= 0) {
1644
+ menuOptions[currentIndex].click();
1645
+ }
1646
+ break;
1647
+ case "ArrowLeft":
1648
+ e.preventDefault();
1649
+ (_a2 = positionTo == null ? void 0 : positionTo.current) == null ? void 0 : _a2.click();
1650
+ (_b2 = positionTo == null ? void 0 : positionTo.current) == null ? void 0 : _b2.focus();
1651
+ break;
1652
+ }
1653
+ }
1654
+ function initializeMenuFocus() {
1655
+ var _a2, _b2, _c;
1656
+ if (!autoFocusOff) {
1657
+ (_a2 = internalRef.current) == null ? void 0 : _a2.focus();
1658
+ }
1659
+ const selectedOption = (_b2 = internalRef.current) == null ? void 0 : _b2.querySelector(
1660
+ "[data-selected]"
1661
+ );
1662
+ const firstMenuItem = (_c = internalRef.current) == null ? void 0 : _c.querySelector(
1663
+ '[role="menuitem"]'
1664
+ );
1665
+ const targetElement = selectedOption || firstMenuItem;
1666
+ if (!targetElement) {
1667
+ return;
1668
+ }
1669
+ targetElement.scrollIntoView({
1670
+ block: "nearest",
1671
+ behavior: "instant"
1672
+ });
1673
+ if (autoFocusOff) {
1674
+ return;
1675
+ }
1676
+ requestAnimationFrame(() => {
1677
+ targetElement.focus();
1678
+ });
1679
+ }
1680
+ function setRefs(node) {
1681
+ internalRef.current = node;
1682
+ if (ref) {
1683
+ if (typeof ref === "function") {
1684
+ ref(node);
1685
+ } else {
1686
+ ref.current = node;
1687
+ }
1688
+ }
1689
+ }
1690
+ function stopPropagation(e) {
1691
+ e.stopPropagation();
1692
+ }
1693
+ };
1694
+ Menu.displayName = "Menu";
1695
+
1696
+ // src/components/MenuOption.tsx
1697
+ var import_clsx9 = __toESM(require("clsx"), 1);
1698
+ var import_react7 = require("react");
1699
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1700
+ var MenuOption = ({
1701
+ children,
1702
+ disabled = false,
1703
+ variant = "normal",
1704
+ value,
1705
+ before,
1706
+ after,
1707
+ subMenu,
1708
+ onClick,
1709
+ selected,
1710
+ ref,
1711
+ onSubMenuHover,
1712
+ onSubMenuLeave,
1713
+ onSubMenuEnter,
1714
+ toggleMenu,
1715
+ subMenuLevel = 1,
1716
+ currentSubMenuLevel,
1717
+ closeSubMenuLevel,
1718
+ activeMenu,
1719
+ mobilePositionTo,
1720
+ highlightMatchingText = false,
1721
+ menuValue
1722
+ }) => {
1723
+ const uniqueId = (0, import_react7.useId)();
1724
+ const internalRef = (0, import_react7.useRef)(null);
1725
+ const actualRef = ref || internalRef;
1726
+ const menuId = (0, import_react7.useRef)(`menu-${uniqueId}`);
1727
+ const isMobile = useMatchesMobile();
1728
+ const handleMouseEnter = () => {
1729
+ if (subMenu && onSubMenuHover && !disabled) {
1730
+ onSubMenuHover(menuId.current, subMenuLevel);
1731
+ }
1732
+ };
1733
+ const handleMouseLeave = () => {
1734
+ if (subMenu && onSubMenuLeave && !disabled) {
1735
+ onSubMenuLeave(subMenuLevel);
1736
+ }
1737
+ };
1738
+ const handleSubMenuEnter = () => {
1739
+ if (onSubMenuEnter) {
1740
+ onSubMenuEnter();
1741
+ }
1742
+ };
1743
+ const additionalAttributes = {
1744
+ "data-selected": selected || null
1745
+ };
1746
+ const svgStyles = (0, import_clsx9.default)(
1747
+ "[&>svg]:shrink-0 [&>svg]:fill-icon-action-primary-normal"
1748
+ );
1749
+ const textLabelStyles = (0, import_clsx9.default)("w-full whitespace-nowrap !leading-6");
1750
+ const normalStyles = variant === "normal" && !disabled && (0, import_clsx9.default)(
1751
+ "bg-transparent text-text-primary-normal",
1752
+ "hover:bg-background-action-secondary-hover",
1753
+ "focus:bg-background-action-secondary-hover",
1754
+ "data-selected:bg-background-action-secondary-hover",
1755
+ "active:bg-background-action-secondary-active"
1756
+ );
1757
+ const normalDisabledStyles = variant === "normal" && disabled && (0, import_clsx9.default)("text-text-primary-disabled");
1758
+ const actionStyles = variant === "action" && !disabled && (0, import_clsx9.default)(
1759
+ "text-action-400 bg-transparent",
1760
+ "hover:bg-background-action-secondary-hover hover:text-text-action-hover",
1761
+ "focus:bg-background-action-secondary-hover focus:text-text-action-hover",
1762
+ "data-selected:bg-background-action-secondary-active data-selected:text-text-action-active",
1763
+ "active:bg-background-action-secondary-active active:text-text-action-active"
1764
+ );
1765
+ const actionDisabledStyles = variant === "action" && disabled && (0, import_clsx9.default)("text-text-action-disabled");
1766
+ const disabledStyles = disabled && (0, import_clsx9.default)("bg-transparent cursor-default pointer-events-none");
1767
+ const renderChildren = typeof children === "string" && highlightMatchingText ? highlightMatch(children, menuValue) : children;
1768
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
1769
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1770
+ "div",
1771
+ __spreadProps(__spreadValues({
1772
+ ref: actualRef,
1773
+ className: (0, import_clsx9.default)(
1774
+ "flex items-center cursor-pointer w-full text-left relative outline-none",
1775
+ svgStyles,
1776
+ componentGap,
1777
+ componentPadding,
1778
+ baseTransition,
1779
+ normalStyles,
1780
+ normalDisabledStyles,
1781
+ actionStyles,
1782
+ actionDisabledStyles,
1783
+ disabledStyles
1784
+ ),
1785
+ "data-value": value || children,
1786
+ onClick: () => {
1787
+ onClick == null ? void 0 : onClick(menuId.current, value || children);
1788
+ if (subMenu) {
1789
+ toggleMenu(menuId.current, subMenuLevel);
1790
+ }
1791
+ },
1792
+ onMouseEnter: handleMouseEnter,
1793
+ onMouseLeave: handleMouseLeave
1794
+ }, additionalAttributes), {
1795
+ tabIndex: -1,
1796
+ role: "menuitem",
1797
+ "aria-haspopup": subMenu ? "menu" : void 0,
1798
+ children: [
1799
+ before && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "shrink-0 flex items-center", children: before }),
1800
+ variant === "action" ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Label, { padded: true, className: textLabelStyles, children: renderChildren }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Paragraph, { padded: true, className: textLabelStyles, children: renderChildren }),
1801
+ renderAfterProp()
1802
+ ]
1803
+ })
1804
+ ),
1805
+ subMenu && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1806
+ "div",
1807
+ {
1808
+ onMouseEnter: handleSubMenuEnter,
1809
+ onMouseLeave: handleMouseLeave,
1810
+ "data-submenu-parent": menuId.current,
1811
+ "data-menu-level": subMenuLevel + 1,
1812
+ children: subMenu({ menuId: menuId.current, positionTo: actualRef, mobilePositionTo, position: "right", subMenuLevel, mobileBackMenuOption, mobileHide: isMobile && activeMenu !== menuId.current })
1813
+ }
1814
+ )
1815
+ ] });
1816
+ function renderAfterProp() {
1817
+ if (after) {
1818
+ return after;
1819
+ }
1820
+ if (subMenu && after !== null) {
1821
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "chevron_right" });
1822
+ }
1823
+ }
1824
+ function mobileBackMenuOption() {
1825
+ if (!isMobile) {
1826
+ return;
1827
+ }
1828
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1829
+ MenuOption,
1830
+ {
1831
+ onClick: () => {
1832
+ closeSubMenuLevel == null ? void 0 : closeSubMenuLevel(currentSubMenuLevel != null ? currentSubMenuLevel : 0);
1833
+ },
1834
+ variant: "action",
1835
+ before: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "chevron_left" }),
1836
+ children: "Back"
1837
+ }
1838
+ );
1839
+ }
1840
+ };
1841
+ MenuOption.displayName = "MenuOption";
1842
+ function highlightMatch(text, searchValue) {
1843
+ if (!searchValue || !searchValue.trim()) {
1844
+ return text;
1845
+ }
1846
+ const regex = new RegExp(`(${searchValue.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})`, "gi");
1847
+ const parts = text.split(regex);
1848
+ return parts.map(
1849
+ (part, index) => regex.test(part) ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "font-bold", children: part }, index) : part
1850
+ );
1851
+ }
1852
+
1853
+ // src/components/DataGridCell.tsx
1854
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1855
+ var DataGridCell = (0, import_react8.memo)(
1856
+ (_a) => {
1857
+ var _b = _a, {
1858
+ type = "default",
1859
+ component = "static",
1860
+ children,
1861
+ className,
1862
+ locked = false,
1863
+ noPadding = false,
1864
+ paddedLeft = false,
1865
+ style,
1866
+ onClick,
1867
+ onRightClick,
1868
+ error,
1869
+ warning,
1870
+ center,
1871
+ width
1872
+ } = _b, props = __objRest(_b, [
1873
+ "type",
1874
+ "component",
1875
+ "children",
1876
+ "className",
1877
+ "locked",
1878
+ "noPadding",
1879
+ "paddedLeft",
1880
+ "style",
1881
+ "onClick",
1882
+ "onRightClick",
1883
+ "error",
1884
+ "warning",
1885
+ "center",
1886
+ "width"
1887
+ ]);
1888
+ const Element = type === "header" ? "th" : "td";
1889
+ const timerRef = (0, import_react8.useRef)(null);
1890
+ const [isGrabbing, setIsGrabbing] = (0, import_react8.useState)(false);
1891
+ const [isPointerPressed, setIsPointerPressed] = (0, import_react8.useState)(false);
1892
+ (0, import_react8.useEffect)(() => {
1893
+ return () => {
1894
+ if (timerRef.current) {
1895
+ clearTimeout(timerRef.current);
1896
+ timerRef.current = null;
1897
+ }
1898
+ };
1899
+ }, []);
1900
+ const handlePointerDown = (_event) => {
1901
+ setIsPointerPressed(true);
1902
+ timerRef.current = window.setTimeout(() => {
1903
+ setIsGrabbing(true);
1904
+ }, 500);
1905
+ };
1906
+ const handlePointerUp = (event) => {
1907
+ if (timerRef.current) {
1908
+ clearTimeout(timerRef.current);
1909
+ timerRef.current = null;
1910
+ }
1911
+ const rightClick = event.nativeEvent instanceof MouseEvent && event.nativeEvent.button === 2;
1912
+ if (!isGrabbing && onClick && !rightClick && isPointerPressed) {
1913
+ onClick(event);
1914
+ }
1915
+ if (rightClick && onRightClick) {
1916
+ onRightClick();
1917
+ }
1918
+ setIsGrabbing(false);
1919
+ setIsPointerPressed(false);
1920
+ };
1921
+ const handlePointerLeave = () => {
1922
+ if (timerRef.current) {
1923
+ clearTimeout(timerRef.current);
1924
+ timerRef.current = null;
1925
+ }
1926
+ };
1927
+ const headerBgStyles = type === "header" && !locked && !["button"].includes(component) && "bg-brand-400 border-brand-200";
1928
+ const lockedHeaderBgStyles = locked && !["button"].includes(component) && "bg-neutral-400 border-neutral-300";
1929
+ const headerTypeStyles = type === "header" && component !== "button" && component !== "icon" && (0, import_clsx10.default)("border-r");
1930
+ const buttonComponentStyles = component === "button" && (0, import_clsx10.default)("border-r border-b border-border-primary-normal");
1931
+ const iconComponentStyles = component === "icon" && (0, import_clsx10.default)("border-l");
1932
+ const cellClasses = (0, import_clsx10.default)(
1933
+ headerTypeStyles,
1934
+ buttonComponentStyles,
1935
+ headerBgStyles,
1936
+ lockedHeaderBgStyles,
1937
+ iconComponentStyles,
1938
+ className,
1939
+ "flex flex-1 items-center gap-1 whitespace-nowrap min-w-full max-h-10 relative text-text-primary-normal",
1940
+ "focus-within:!z-10",
1941
+ component === "input" && "border",
1942
+ component === "input" && !error && !warning && "border-border-primary-normal",
1943
+ component === "input" && error && "border-border-primary-error",
1944
+ component === "input" && warning && "border-background-warning-normal",
1945
+ !["button", "icon"].includes(component) && !noPadding && "p-2",
1946
+ paddedLeft && "pl-2",
1947
+ component === "icon" && "border-l",
1948
+ isGrabbing && "!cursor-grabbing",
1949
+ component === "checkbox" || center && "justify-center"
1950
+ );
1951
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1952
+ Element,
1953
+ __spreadProps(__spreadValues({
1954
+ className: (0, import_clsx10.default)("flex", !width && "flex-1"),
1955
+ style: { width }
1956
+ }, props), {
1957
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1958
+ "div",
1959
+ {
1960
+ className: cellClasses,
1961
+ style: __spreadValues({}, style),
1962
+ onMouseDown: handlePointerDown,
1963
+ onMouseUp: handlePointerUp,
1964
+ onMouseLeave: handlePointerLeave,
1965
+ onTouchStart: handlePointerDown,
1966
+ onTouchEnd: handlePointerUp,
1967
+ onTouchCancel: handlePointerLeave,
1968
+ onContextMenu: (e) => e.preventDefault(),
1969
+ children
1970
+ }
1971
+ )
1972
+ })
1973
+ );
1974
+ }
1975
+ );
1976
+ DataGridCell.displayName = "DataGridCell";
1977
+ function DraggableCellHeader(_a) {
1978
+ var _b = _a, {
1979
+ header,
1980
+ children,
1981
+ locked = false
1982
+ } = _b, props = __objRest(_b, [
1983
+ "header",
1984
+ "children",
1985
+ "locked"
1986
+ ]);
1987
+ var _a2;
1988
+ const { attributes, isDragging, listeners, setNodeRef, transform, node } = (0, import_sortable.useSortable)({
1989
+ id: header.column.id
1990
+ });
1991
+ const [showMenu, setShowMenu] = (0, import_react8.useState)(false);
1992
+ const [filter, setFilter] = (0, import_react8.useState)(
1993
+ (_a2 = header.column.getFilterValue()) != null ? _a2 : ""
1994
+ );
1995
+ const {
1996
+ menuRootRef,
1997
+ isMenuActive,
1998
+ registerSubMenu,
1999
+ listeners: subMenuListeners,
2000
+ mobileHide
2001
+ } = useSubMenuSystem(node);
2002
+ (0, import_react8.useEffect)(() => {
2003
+ const handler = setTimeout(() => {
2004
+ header.column.setFilterValue(filter);
2005
+ }, 500);
2006
+ return () => {
2007
+ clearTimeout(handler);
2008
+ };
2009
+ }, [filter]);
2010
+ const style = {
2011
+ opacity: isDragging ? 0.8 : 1,
2012
+ position: "relative",
2013
+ transform: CSS.Translate.toString(transform),
2014
+ transition: "width transform 0.2s ease-in-out",
2015
+ whiteSpace: "nowrap",
2016
+ width: header.column.getSize(),
2017
+ zIndex: isDragging ? 1 : 0,
2018
+ "--color-text-primary-normal": "var(--color-neutral-000)"
2019
+ };
2020
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
2021
+ DataGridCell,
2022
+ __spreadProps(__spreadValues(__spreadValues(__spreadProps(__spreadValues({
2023
+ locked,
2024
+ type: "header",
2025
+ component: "header",
2026
+ ref: setNodeRef,
2027
+ colSpan: header.colSpan,
2028
+ style
2029
+ }, props), {
2030
+ onClick: header.column.getToggleSortingHandler(),
2031
+ onRightClick: () => setShowMenu(!showMenu)
2032
+ }), locked ? {} : attributes), locked ? {} : listeners), {
2033
+ children: [
2034
+ children,
2035
+ header.column.getCanFilter() && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2036
+ Menu,
2037
+ {
2038
+ ref: menuRootRef,
2039
+ positionTo: node,
2040
+ show: showMenu,
2041
+ setShow: setShowMenu,
2042
+ mobileHide,
2043
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2044
+ MenuOption,
2045
+ __spreadProps(__spreadValues({}, subMenuListeners), {
2046
+ subMenu: (_b2) => {
2047
+ var _c = _b2, { menuId, subMenuLevel } = _c, props2 = __objRest(_c, ["menuId", "subMenuLevel"]);
2048
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
2049
+ Menu,
2050
+ __spreadProps(__spreadValues({}, props2), {
2051
+ show: isMenuActive(menuId, subMenuLevel),
2052
+ ref: (el) => {
2053
+ registerSubMenu(menuId, el);
2054
+ },
2055
+ children: [
2056
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: (0, import_clsx10.default)(paddingUsingComponentGap), children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2057
+ Search,
2058
+ {
2059
+ onChange: (event) => {
2060
+ setFilter(event.target.value);
2061
+ },
2062
+ onKeyDown: (event) => {
2063
+ if ([" ", "Space"].includes(event.key)) {
2064
+ event.stopPropagation();
2065
+ }
2066
+ },
2067
+ value: filter != null ? filter : ""
2068
+ }
2069
+ ) }),
2070
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2071
+ MenuOption,
2072
+ {
2073
+ onClick: handleFilterFnChange,
2074
+ before: menuOptionIcon("includesString"),
2075
+ children: "Contains"
2076
+ }
2077
+ ),
2078
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2079
+ MenuOption,
2080
+ {
2081
+ onClick: handleFilterFnChange,
2082
+ before: menuOptionIcon("startsWith"),
2083
+ children: "Starts with"
2084
+ }
2085
+ ),
2086
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2087
+ MenuOption,
2088
+ {
2089
+ onClick: handleFilterFnChange,
2090
+ before: menuOptionIcon("endsWith"),
2091
+ children: "Ends with"
2092
+ }
2093
+ )
2094
+ ]
2095
+ })
2096
+ );
2097
+ },
2098
+ children: "Filter"
2099
+ })
2100
+ )
2101
+ }
2102
+ )
2103
+ ]
2104
+ })
2105
+ );
2106
+ function menuOptionIcon(value) {
2107
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2108
+ Icon,
2109
+ {
2110
+ name: "check",
2111
+ className: (0, import_clsx10.default)(
2112
+ header.column.columnDef.filterFn !== value && "text-transparent"
2113
+ )
2114
+ }
2115
+ );
2116
+ }
2117
+ function handleFilterFnChange(_id, value) {
2118
+ var _a3;
2119
+ let filterFn = "includesString";
2120
+ const currentFilterFn = header.column.columnDef.filterFn;
2121
+ if ((value == null ? void 0 : value.toLowerCase()) === "starts with") {
2122
+ filterFn = currentFilterFn === "startsWith" ? "auto" : "startsWith";
2123
+ }
2124
+ if ((value == null ? void 0 : value.toLowerCase()) === "ends with") {
2125
+ filterFn = currentFilterFn === "endsWith" ? "auto" : "endsWith";
2126
+ }
2127
+ if ((value == null ? void 0 : value.toLowerCase()) === "contains") {
2128
+ filterFn = currentFilterFn === "includesString" ? "auto" : "includesString";
2129
+ }
2130
+ header.column.columnDef.filterFn = filterFn;
2131
+ header.column.setFilterValue((_a3 = header.column.getFilterValue()) != null ? _a3 : "");
2132
+ }
2133
+ }
2134
+ DraggableCellHeader.displayName = "DraggableCellHeader";
2135
+ function DragAlongCell(_a) {
2136
+ var _b = _a, {
2137
+ cell,
2138
+ children
2139
+ } = _b, props = __objRest(_b, [
2140
+ "cell",
2141
+ "children"
2142
+ ]);
2143
+ const { isDragging, setNodeRef, transform } = (0, import_sortable.useSortable)({
2144
+ id: cell.column.id
2145
+ });
2146
+ const style = {
2147
+ opacity: isDragging ? 0.8 : 1,
2148
+ position: "relative",
2149
+ transform: CSS.Translate.toString(transform),
2150
+ transition: "width transform 0.2s ease-in-out",
2151
+ zIndex: isDragging ? 1 : 0,
2152
+ width: cell.column.getSize(),
2153
+ minWidth: "min-content"
2154
+ };
2155
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(DataGridCell, __spreadProps(__spreadValues({ style, ref: setNodeRef }, props), { children }));
2156
+ }
2157
+ DragAlongCell.displayName = "DragAlongCell";
2158
+
2159
+ // src/components/Select.tsx
2160
+ var import_react9 = require("react");
2161
+ var import_clsx11 = __toESM(require("clsx"), 1);
2162
+ var import_jsx_runtime11 = require("react/jsx-runtime");
2163
+ var Select = (_a) => {
2164
+ var _b = _a, {
2165
+ label,
2166
+ error,
2167
+ children,
2168
+ readOnly,
2169
+ renderMenu,
2170
+ onClick,
2171
+ className,
2172
+ wrapperClassName,
2173
+ removeRoundness,
2174
+ displayValue,
2175
+ value
2176
+ } = _b, props = __objRest(_b, [
2177
+ "label",
2178
+ "error",
2179
+ "children",
2180
+ "readOnly",
2181
+ "renderMenu",
2182
+ "onClick",
2183
+ "className",
2184
+ "wrapperClassName",
2185
+ "removeRoundness",
2186
+ "displayValue",
2187
+ "value"
2188
+ ]);
2189
+ const inputRef = (0, import_react9.useRef)(null);
2190
+ const inputContainerRef = (0, import_react9.useRef)(null);
2191
+ const preventFocusOnInitialRender = (0, import_react9.useRef)(true);
2192
+ const [show, setShow] = (0, import_react9.useState)(false);
2193
+ (0, import_react9.useEffect)(() => {
2194
+ var _a2;
2195
+ if (preventFocusOnInitialRender.current) {
2196
+ preventFocusOnInitialRender.current = false;
2197
+ return;
2198
+ }
2199
+ (_a2 = inputRef.current) == null ? void 0 : _a2.focus();
2200
+ }, [value]);
2201
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
2202
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2203
+ InputBase,
2204
+ __spreadProps(__spreadValues({
2205
+ inputContainerRef,
2206
+ ref: inputRef,
2207
+ label,
2208
+ after: !readOnly && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2209
+ "span",
2210
+ {
2211
+ className: (0, import_clsx11.default)(
2212
+ props.disabled ? "text-icon-action-primary-disabled" : "text-icon-action-primary-normal",
2213
+ "contents"
2214
+ ),
2215
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Icon, { name: "keyboard_arrow_down" })
2216
+ }
2217
+ ),
2218
+ maxLength: 0,
2219
+ className: (0, import_clsx11.default)("!caret-transparent !cursor-default", className),
2220
+ wrapperClassName,
2221
+ onKeyDown: (e) => {
2222
+ const openKeys = ["Enter", "Space", " "];
2223
+ if (openKeys.includes(e.key)) {
2224
+ e.preventDefault();
2225
+ e.target.click();
2226
+ }
2227
+ },
2228
+ onClick: (e) => {
2229
+ if (props.disabled || readOnly) {
2230
+ return;
2231
+ }
2232
+ setShow(!show);
2233
+ onClick == null ? void 0 : onClick(e);
2234
+ },
2235
+ error,
2236
+ readOnly,
2237
+ removeRoundness,
2238
+ focus: show
2239
+ }, props), {
2240
+ value: displayValue != null ? displayValue : value
2241
+ })
2242
+ ),
2243
+ renderMenu ? renderMenu({
2244
+ positionTo: inputContainerRef,
2245
+ show,
2246
+ setShow,
2247
+ topOffset: props.caption ? -16 : null
2248
+ }) : children
2249
+ ] });
2250
+ };
2251
+ Select.displayName = "Select";
2252
+
2253
+ // src/components/Subheader.tsx
2254
+ var import_clsx12 = __toESM(require("clsx"), 1);
2255
+ var import_jsx_runtime12 = require("react/jsx-runtime");
2256
+ var Subheader = (_a) => {
2257
+ var _b = _a, {
2258
+ className,
2259
+ children,
2260
+ as = "span",
2261
+ align,
2262
+ color,
2263
+ tall
2264
+ } = _b, props = __objRest(_b, [
2265
+ "className",
2266
+ "children",
2267
+ "as",
2268
+ "align",
2269
+ "color",
2270
+ "tall"
2271
+ ]);
2272
+ const Element = as;
2273
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2274
+ Element,
2275
+ __spreadProps(__spreadValues({
2276
+ className: (0, import_clsx12.default)(
2277
+ typography.subheader,
2278
+ className,
2279
+ align === "left" && "text-left",
2280
+ align === "center" && "text-center",
2281
+ align === "right" && "text-right",
2282
+ tall && "!leading-6"
2283
+ ),
2284
+ style: __spreadProps(__spreadValues({}, props.style), {
2285
+ color: color ? `var(--color-${color})` : void 0
2286
+ })
2287
+ }, props), {
2288
+ children
2289
+ })
2290
+ );
2291
+ };
2292
+ Subheader.displayName = "Subheader";
2293
+
2294
+ // src/components/Tooltip.tsx
2295
+ var import_clsx13 = __toESM(require("clsx"), 1);
2296
+ var import_react10 = require("react");
2297
+ var import_react_dom2 = require("react-dom");
2298
+ var import_jsx_runtime13 = require("react/jsx-runtime");
2299
+ var Tooltip = ({
2300
+ message,
2301
+ position = "top",
2302
+ children,
2303
+ showOnTruncation = false,
2304
+ offset = 8
2305
+ }) => {
2306
+ const ref = (0, import_react10.useRef)(null);
2307
+ const tooltipRef = (0, import_react10.useRef)(null);
2308
+ const [isTruncated, setIsTruncated] = (0, import_react10.useState)(false);
2309
+ const [tooltipPosition, setTooltipPosition] = (0, import_react10.useState)({ top: 0, left: 0 });
2310
+ const [isVisible, setIsVisible] = (0, import_react10.useState)(false);
2311
+ const [removeOpacity, setRemoveOpacity] = (0, import_react10.useState)(false);
2312
+ const updatePosition = () => {
2313
+ if (!ref.current || !tooltipRef.current) return;
2314
+ const rect = ref.current.getBoundingClientRect();
2315
+ const tooltipRect = tooltipRef.current.getBoundingClientRect();
2316
+ let top = 0;
2317
+ let left = 0;
2318
+ switch (position) {
2319
+ case "top":
2320
+ top = rect.top - tooltipRect.height - offset;
2321
+ left = rect.left + rect.width / 2 - tooltipRect.width / 2;
2322
+ break;
2323
+ case "bottom":
2324
+ top = rect.bottom + offset;
2325
+ left = rect.left + rect.width / 2 - tooltipRect.width / 2;
2326
+ break;
2327
+ case "left":
2328
+ top = rect.top + rect.height / 2 - tooltipRect.height / 2;
2329
+ left = rect.left - tooltipRect.width - offset;
2330
+ break;
2331
+ case "right":
2332
+ top = rect.top + rect.height / 2 - tooltipRect.height / 2;
2333
+ left = rect.right + offset;
2334
+ break;
2335
+ }
2336
+ setTooltipPosition({ top, left });
2337
+ requestAnimationFrame(() => {
2338
+ setRemoveOpacity(true);
2339
+ });
2340
+ };
2341
+ const handleMouseEnter = () => {
2342
+ if (!showOnTruncation || checkForTextTruncation()) {
2343
+ setIsVisible(true);
2344
+ }
2345
+ };
2346
+ const handleMouseLeave = () => {
2347
+ setIsVisible(false);
2348
+ setRemoveOpacity(false);
2349
+ };
2350
+ (0, import_react10.useEffect)(() => {
2351
+ if (isVisible && tooltipRef.current) {
2352
+ requestAnimationFrame(() => {
2353
+ updatePosition();
2354
+ });
2355
+ }
2356
+ }, [isVisible]);
2357
+ (0, import_react10.useEffect)(() => {
2358
+ if (isVisible) {
2359
+ window.addEventListener("resize", updatePosition);
2360
+ return () => window.removeEventListener("resize", updatePosition);
2361
+ }
2362
+ }, [isVisible]);
2363
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
2364
+ "div",
2365
+ {
2366
+ ref,
2367
+ className: "relative inline-grid grid-cols-[auto_1fr] items-center",
2368
+ onMouseEnter: handleMouseEnter,
2369
+ onMouseLeave: handleMouseLeave,
2370
+ children: [
2371
+ children,
2372
+ isVisible && typeof document !== "undefined" && (0, import_react_dom2.createPortal)(
2373
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2374
+ "div",
2375
+ {
2376
+ ref: tooltipRef,
2377
+ style: {
2378
+ position: "fixed",
2379
+ top: `${tooltipPosition.top}px`,
2380
+ left: `${tooltipPosition.left}px`,
2381
+ zIndex: 9999
2382
+ },
2383
+ className: (0, import_clsx13.default)(
2384
+ typography.caption,
2385
+ "p-2 bg-neutral-500 text-neutral-100 rounded whitespace-nowrap shadow-2 pointer-events-none transition-opacity duration-100 ease-in-out",
2386
+ !removeOpacity && "opacity-0"
2387
+ ),
2388
+ children: message
2389
+ }
2390
+ ),
2391
+ document.body
2392
+ )
2393
+ ]
2394
+ }
2395
+ );
2396
+ function checkForTextTruncation() {
2397
+ if (showOnTruncation && ref.current) {
2398
+ const paragraph = ref.current.querySelector("p");
2399
+ if (paragraph) {
2400
+ const isTruncated2 = paragraph.scrollWidth > paragraph.clientWidth;
2401
+ setIsTruncated(isTruncated2);
2402
+ return isTruncated2;
2403
+ }
2404
+ }
2405
+ return false;
2406
+ }
2407
+ };
2408
+ Tooltip.displayName = "Tooltip";
2409
+
2410
+ // src/components/useInfiniteScroll.tsx
2411
+ var import_react11 = require("react");
2412
+ function useInfiniteScroll({
2413
+ containerRef,
2414
+ onLoadMore,
2415
+ isLoading,
2416
+ offset = 50,
2417
+ enabled = true
2418
+ // ✅ Add this
2419
+ }) {
2420
+ (0, import_react11.useEffect)(() => {
2421
+ if (!enabled) return;
2422
+ const handleScroll = () => {
2423
+ const el2 = containerRef.current;
2424
+ if (!el2 || isLoading) return;
2425
+ const { scrollTop, scrollHeight, clientHeight } = el2;
2426
+ const isNearBottom = scrollTop + clientHeight >= scrollHeight - offset;
2427
+ if (isNearBottom) {
2428
+ onLoadMore();
2429
+ }
2430
+ };
2431
+ const el = containerRef.current;
2432
+ if (el) el.addEventListener("scroll", handleScroll);
2433
+ return () => {
2434
+ if (el) el.removeEventListener("scroll", handleScroll);
2435
+ };
2436
+ }, [containerRef, onLoadMore, isLoading, offset, enabled]);
2437
+ }
2438
+
2439
+ // src/components/DataGrid.tsx
2440
+ var import_clsx14 = __toESM(require("clsx"), 1);
2441
+ var import_jsx_runtime14 = (
2442
+ // fake empty column to the left for virtualization scroll padding
2443
+ require("react/jsx-runtime")
2444
+ );
2445
+ var PAGE_SIZE_OPTIONS = [5, 10, 15, 20, 25, 30, 35];
2446
+ var NO_RESULTS_HEIGHT = "h-[120px]";
2447
+ function adaptTableStateSetter(setter) {
2448
+ return (valueOrFn) => {
2449
+ setter(
2450
+ (prev) => typeof valueOrFn === "function" ? valueOrFn(prev) : valueOrFn
2451
+ );
2452
+ };
2453
+ }
2454
+ function DataGrid({
2455
+ data,
2456
+ columns,
2457
+ status,
2458
+ isLoadingMore = false,
2459
+ onLoadMore,
2460
+ pagination,
2461
+ showFilterRow = false,
2462
+ hasMore = false,
2463
+ sorting: externalSorting,
2464
+ onSortingChange,
2465
+ columnFilters: externalColumnFilters,
2466
+ onColumnFiltersChange,
2467
+ rowSelection: externalRowSelection,
2468
+ onRowSelectionChange,
2469
+ filteredSortedData,
2470
+ totalRowCount,
2471
+ hideStatusBar,
2472
+ centerHeader,
2473
+ enableColumnSelector
2474
+ }) {
2475
+ var _a, _b, _c, _d, _e;
2476
+ const [columnOrder, setColumnOrder] = (0, import_react12.useState)(
2477
+ () => columns.map((c) => c.id)
2478
+ );
2479
+ const [localSorting, setLocalSorting] = (0, import_react12.useState)([]);
2480
+ const [localColumnFilters, setLocalColumnFilters] = (0, import_react12.useState)([]);
2481
+ const [localRowSelection, setLocalRowSelection] = (0, import_react12.useState)({});
2482
+ const sortingState = pagination ? externalSorting != null ? externalSorting : localSorting : localSorting;
2483
+ const setSortingState = pagination ? (updaterOrValue) => {
2484
+ const value = typeof updaterOrValue === "function" ? updaterOrValue(
2485
+ externalSorting != null ? externalSorting : []
2486
+ ) : updaterOrValue;
2487
+ (onSortingChange != null ? onSortingChange : setLocalSorting)(value);
2488
+ } : setLocalSorting;
2489
+ const columnFilterState = pagination ? externalColumnFilters != null ? externalColumnFilters : localColumnFilters : localColumnFilters;
2490
+ const setColumnFilterState = pagination ? (updaterOrValue) => {
2491
+ const value = typeof updaterOrValue === "function" ? updaterOrValue(externalColumnFilters != null ? externalColumnFilters : []) : updaterOrValue;
2492
+ (onColumnFiltersChange != null ? onColumnFiltersChange : setLocalColumnFilters)(value);
2493
+ } : setLocalColumnFilters;
2494
+ const rowSelection = pagination ? externalRowSelection != null ? externalRowSelection : localRowSelection : localRowSelection;
2495
+ const setRowSelection = pagination ? (updaterOrValue) => {
2496
+ const value = typeof updaterOrValue === "function" ? updaterOrValue(externalRowSelection != null ? externalRowSelection : {}) : updaterOrValue;
2497
+ (onRowSelectionChange != null ? onRowSelectionChange : setLocalRowSelection)(value);
2498
+ } : setLocalRowSelection;
2499
+ const id = (0, import_react12.useId)();
2500
+ const containerRef = import_react12.default.useRef(null);
2501
+ const [columnVisibility, setColumnVisibility] = (0, import_react12.useState)(() => {
2502
+ const initialVisibility = {};
2503
+ columns.forEach((column) => {
2504
+ var _a2, _b2;
2505
+ if (column.id) {
2506
+ initialVisibility[column.id] = (_b2 = (_a2 = column.meta) == null ? void 0 : _a2.visible) != null ? _b2 : true;
2507
+ }
2508
+ });
2509
+ return initialVisibility;
2510
+ });
2511
+ const toggleColumnVisibility = (0, import_react12.useCallback)(
2512
+ (id2, isVisible) => {
2513
+ setColumnVisibility((prev) => __spreadProps(__spreadValues({}, prev), { [id2]: isVisible }));
2514
+ },
2515
+ [setColumnVisibility]
2516
+ );
2517
+ const resetColumnVisibility = (0, import_react12.useCallback)(() => {
2518
+ setColumnVisibility(() => {
2519
+ const initialVisibility = {};
2520
+ columns.forEach((column) => {
2521
+ var _a2, _b2;
2522
+ if (column.id) {
2523
+ initialVisibility[column.id] = (_b2 = (_a2 = column.meta) == null ? void 0 : _a2.visible) != null ? _b2 : true;
2524
+ }
2525
+ });
2526
+ return initialVisibility;
2527
+ });
2528
+ }, [columns]);
2529
+ const table = (0, import_react_table.useReactTable)({
2530
+ columns,
2531
+ data,
2532
+ getCoreRowModel: (0, import_react_table.getCoreRowModel)(),
2533
+ getSortedRowModel: (0, import_react_table.getSortedRowModel)(),
2534
+ getFilteredRowModel: (0, import_react_table.getFilteredRowModel)(),
2535
+ columnResizeMode: "onChange",
2536
+ getRowId: (row, index) => {
2537
+ var _a2;
2538
+ return String((_a2 = row.id) != null ? _a2 : index + 1);
2539
+ },
2540
+ state: {
2541
+ columnOrder,
2542
+ sorting: sortingState,
2543
+ columnFilters: columnFilterState,
2544
+ rowSelection,
2545
+ columnVisibility
2546
+ },
2547
+ onColumnOrderChange: setColumnOrder,
2548
+ onSortingChange: adaptTableStateSetter(setSortingState),
2549
+ onColumnFiltersChange: adaptTableStateSetter(setColumnFilterState),
2550
+ onRowSelectionChange: adaptTableStateSetter(setRowSelection),
2551
+ filterFns: {
2552
+ startsWith: (row, columnId, filterValue) => {
2553
+ var _a2;
2554
+ return (_a2 = row.getValue(columnId)) == null ? void 0 : _a2.toLowerCase().startsWith(filterValue.toLowerCase());
2555
+ },
2556
+ endsWith: (row, columnId, filterValue) => {
2557
+ var _a2;
2558
+ return (_a2 = row.getValue(columnId)) == null ? void 0 : _a2.toLowerCase().endsWith(filterValue.toLowerCase());
2559
+ }
2560
+ }
2561
+ });
2562
+ const allRowIds = pagination ? (_a = filteredSortedData == null ? void 0 : filteredSortedData.map((row) => String(row.id))) != null ? _a : [] : Array.from(
2563
+ { length: totalRowCount != null ? totalRowCount : data.length },
2564
+ (_, i) => String(i + 1)
2565
+ );
2566
+ const allSelectedAcrossPages = allRowIds.every((id2) => rowSelection[id2]);
2567
+ const someSelectedAcrossPages = !allSelectedAcrossPages && allRowIds.some((id2) => rowSelection[id2]);
2568
+ const toggleSelectAllAcrossPages = () => {
2569
+ setRowSelection((prev) => {
2570
+ const isSelecting = !allSelectedAcrossPages;
2571
+ if (isSelecting) {
2572
+ const newSelection = {};
2573
+ for (const id2 of allRowIds) {
2574
+ newSelection[id2] = true;
2575
+ }
2576
+ return __spreadValues(__spreadValues({}, prev), newSelection);
2577
+ } else {
2578
+ const updatedSelection = __spreadValues({}, prev);
2579
+ for (const id2 of allRowIds) {
2580
+ delete updatedSelection[id2];
2581
+ }
2582
+ return updatedSelection;
2583
+ }
2584
+ });
2585
+ };
2586
+ useInfiniteScroll({
2587
+ containerRef,
2588
+ onLoadMore: onLoadMore != null ? onLoadMore : () => {
2589
+ },
2590
+ isLoading: isLoadingMore,
2591
+ enabled: !pagination
2592
+ });
2593
+ const handleDragEnd = (event) => {
2594
+ const { active, over } = event;
2595
+ if (active && over && active.id !== over.id) {
2596
+ setColumnOrder((prev) => {
2597
+ const oldIndex = prev.indexOf(active.id);
2598
+ const newIndex = prev.indexOf(over.id);
2599
+ return (0, import_sortable2.arrayMove)(prev, oldIndex, newIndex);
2600
+ });
2601
+ }
2602
+ };
2603
+ const sensors = (0, import_core.useSensors)(
2604
+ (0, import_core.useSensor)(import_core.MouseSensor),
2605
+ (0, import_core.useSensor)(import_core.TouchSensor),
2606
+ (0, import_core.useSensor)(import_core.KeyboardSensor)
2607
+ );
2608
+ const visibleColumns = table.getVisibleLeafColumns();
2609
+ const columnVirtualizer = (0, import_react_virtual.useVirtualizer)({
2610
+ count: visibleColumns.length,
2611
+ estimateSize: (index) => visibleColumns[index].getSize(),
2612
+ //estimate width of each column for accurate scrollbar dragging
2613
+ getScrollElement: () => containerRef.current,
2614
+ horizontal: true,
2615
+ overscan: 3
2616
+ //how many columns to render on each side off screen each way
2617
+ });
2618
+ const virtualColumns = columnVirtualizer.getVirtualItems();
2619
+ let virtualPaddingLeft;
2620
+ let virtualPaddingRight;
2621
+ if (columnVirtualizer && (virtualColumns == null ? void 0 : virtualColumns.length)) {
2622
+ virtualPaddingLeft = (_c = (_b = virtualColumns[0]) == null ? void 0 : _b.start) != null ? _c : 0;
2623
+ virtualPaddingRight = columnVirtualizer.getTotalSize() - ((_e = (_d = virtualColumns[virtualColumns.length - 1]) == null ? void 0 : _d.end) != null ? _e : 0);
2624
+ }
2625
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2626
+ import_core.DndContext,
2627
+ {
2628
+ id,
2629
+ collisionDetection: import_core.closestCenter,
2630
+ modifiers: [import_modifiers.restrictToHorizontalAxis],
2631
+ onDragEnd: handleDragEnd,
2632
+ sensors,
2633
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2634
+ import_sortable2.SortableContext,
2635
+ {
2636
+ items: columnOrder,
2637
+ strategy: import_sortable2.horizontalListSortingStrategy,
2638
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.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: [
2639
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2640
+ "div",
2641
+ {
2642
+ className: "overflow-auto scrollbar-thin h-full relative contain-paint will-change-transform",
2643
+ ref: containerRef,
2644
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("table", { className: "min-w-full grid", children: [
2645
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("thead", { className: "sticky top-0 z-10 grid", children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("tr", { className: "flex w-full", children: [
2646
+ virtualPaddingLeft ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2647
+ "th",
2648
+ {
2649
+ style: { display: "flex", width: virtualPaddingLeft }
2650
+ }
2651
+ ) : null,
2652
+ virtualColumns.map((virtualColumn) => {
2653
+ var _a2, _b2, _c2, _d2, _e2;
2654
+ const header = headerGroup.headers[virtualColumn.index];
2655
+ if (typeof header.column.columnDef.header === "string") {
2656
+ const customHeaderWidth = (_a2 = header.column.columnDef.meta) == null ? void 0 : _a2.headerWidth;
2657
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
2658
+ DraggableCellHeader,
2659
+ {
2660
+ header,
2661
+ locked: (_b2 = header.column.columnDef.meta) == null ? void 0 : _b2.locked,
2662
+ center: centerHeader,
2663
+ width: customHeaderWidth,
2664
+ className: (0, import_clsx14.default)(
2665
+ header.column.getCanSort() ? "cursor-pointer" : "cursor-grab",
2666
+ "group"
2667
+ ),
2668
+ children: [
2669
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Subheader, { tall: true, children: header.column.columnDef.header }),
2670
+ getSortIcon(header.column.getIsSorted()),
2671
+ !header.column.getIsSorted() && header.column.getCanSort() && getSortIcon(
2672
+ header.column.getNextSortingOrder(),
2673
+ true
2674
+ ),
2675
+ header.column.getSortIndex() !== -1 && table.getState().sorting.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Subheader, { tall: true, children: header.column.getSortIndex() + 1 }),
2676
+ !((_c2 = header.column.columnDef.meta) == null ? void 0 : _c2.locked) && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2677
+ "div",
2678
+ {
2679
+ onDoubleClick: (e) => {
2680
+ e.stopPropagation();
2681
+ header.column.resetSize();
2682
+ },
2683
+ onMouseDown: (e) => {
2684
+ e.stopPropagation();
2685
+ header.getResizeHandler()(e);
2686
+ },
2687
+ onTouchStart: (e) => {
2688
+ e.stopPropagation();
2689
+ header.getResizeHandler()(e);
2690
+ },
2691
+ className: "absolute right-0 inset-y-0 w-px bg-black cursor-col-resize"
2692
+ }
2693
+ )
2694
+ ]
2695
+ },
2696
+ header.id
2697
+ );
2698
+ }
2699
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react12.default.Fragment, { children: ((_d2 = header.column.columnDef.meta) == null ? void 0 : _d2.checkbox) ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2700
+ DataGridCell,
2701
+ {
2702
+ type: "header",
2703
+ component: "checkbox",
2704
+ locked: (_e2 = header.column.columnDef.meta) == null ? void 0 : _e2.locked,
2705
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2706
+ Checkbox,
2707
+ {
2708
+ checked: allSelectedAcrossPages,
2709
+ indeterminate: someSelectedAcrossPages,
2710
+ onChange: toggleSelectAllAcrossPages
2711
+ }
2712
+ )
2713
+ }
2714
+ ) : (0, import_react_table.flexRender)(
2715
+ header.column.columnDef.header,
2716
+ header.getContext()
2717
+ ) }, header.id);
2718
+ }),
2719
+ virtualPaddingRight ? (
2720
+ //fake empty column to the right for virtualization scroll padding
2721
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2722
+ "th",
2723
+ {
2724
+ style: { display: "flex", width: virtualPaddingRight }
2725
+ }
2726
+ )
2727
+ ) : null,
2728
+ enableColumnSelector && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2729
+ ColumnSelectorHeaderCell,
2730
+ {
2731
+ table,
2732
+ toggleColumnVisibility,
2733
+ resetColumnVisibility
2734
+ }
2735
+ )
2736
+ ] }, headerGroup.id)) }),
2737
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2738
+ TableBody,
2739
+ {
2740
+ columnVirtualizer,
2741
+ table,
2742
+ tableContainerRef: containerRef,
2743
+ virtualPaddingLeft,
2744
+ virtualPaddingRight,
2745
+ pagination,
2746
+ isLoadingMore,
2747
+ hasMore,
2748
+ showFilterRow,
2749
+ enableColumnSelector
2750
+ }
2751
+ )
2752
+ ] })
2753
+ }
2754
+ ),
2755
+ table.getRowModel().rows.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
2756
+ "div",
2757
+ {
2758
+ className: (0, import_clsx14.default)(
2759
+ NO_RESULTS_HEIGHT,
2760
+ "flex flex-col items-center justify-center",
2761
+ componentGap,
2762
+ componentPadding
2763
+ ),
2764
+ children: [
2765
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Subheader, { color: "text-secondary-normal", children: "No Results" }),
2766
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Paragraph, { color: "text-secondary-normal", children: "To view results, enter or update your search criteria." })
2767
+ ]
2768
+ }
2769
+ ),
2770
+ !hideStatusBar && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "p-2 pt-[7px] border-t border-border-primary-normal h-full min-h-[34px]", children: [
2771
+ pagination && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex justify-between items-center", children: [
2772
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center gap-1 w-min", children: [
2773
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2774
+ Select,
2775
+ {
2776
+ wrapperClassName: "!w-20",
2777
+ value: pagination.pageSize.toString(),
2778
+ onChange: (e) => {
2779
+ var _a2;
2780
+ return (_a2 = pagination.onPageSizeChange) == null ? void 0 : _a2.call(pagination, Number(e.target.value));
2781
+ },
2782
+ renderMenu: (props) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Menu, __spreadProps(__spreadValues({}, props), { onClick: () => props.setShow(false), children: PAGE_SIZE_OPTIONS.map((option) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2783
+ MenuOption,
2784
+ {
2785
+ selected: pagination.pageSize === option,
2786
+ onClick: () => {
2787
+ var _a2;
2788
+ return (_a2 = pagination.onPageSizeChange) == null ? void 0 : _a2.call(pagination, option);
2789
+ },
2790
+ children: option
2791
+ },
2792
+ option
2793
+ )) }))
2794
+ }
2795
+ ),
2796
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Label, { className: "whitespace-nowrap", children: "Per Page" })
2797
+ ] }),
2798
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center gap-2", children: [
2799
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2800
+ Button,
2801
+ {
2802
+ iconOnly: true,
2803
+ leftIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Icon, { name: "chevron_left" }),
2804
+ onClick: () => pagination.onPageChange(pagination.pageIndex - 1),
2805
+ variant: "tertiary",
2806
+ disabled: pagination.pageIndex === 0
2807
+ }
2808
+ ),
2809
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Paragraph, { children: [
2810
+ pagination.pageIndex * pagination.pageSize + 1,
2811
+ " -",
2812
+ " ",
2813
+ Math.min(
2814
+ (pagination.pageIndex + 1) * pagination.pageSize,
2815
+ pagination.total
2816
+ ),
2817
+ " ",
2818
+ "of ",
2819
+ pagination.total
2820
+ ] }),
2821
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2822
+ Button,
2823
+ {
2824
+ iconOnly: true,
2825
+ leftIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Icon, { name: "chevron_right" }),
2826
+ onClick: () => pagination.onPageChange(pagination.pageIndex + 1),
2827
+ variant: "tertiary",
2828
+ disabled: (pagination.pageIndex + 1) * pagination.pageSize >= pagination.total
2829
+ }
2830
+ )
2831
+ ] })
2832
+ ] }),
2833
+ status && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Paragraph, { children: status })
2834
+ ] })
2835
+ ] })
2836
+ }
2837
+ )
2838
+ }
2839
+ );
2840
+ }
2841
+ DataGrid.displayName = "DataGrid";
2842
+ function TableBody({
2843
+ columnVirtualizer,
2844
+ table,
2845
+ tableContainerRef,
2846
+ virtualPaddingLeft,
2847
+ virtualPaddingRight,
2848
+ pagination,
2849
+ isLoadingMore,
2850
+ hasMore,
2851
+ showFilterRow,
2852
+ enableColumnSelector = false
2853
+ }) {
2854
+ const { rows } = table.getRowModel();
2855
+ const rowVirtualizer = (0, import_react_virtual.useVirtualizer)({
2856
+ count: rows.length,
2857
+ estimateSize: () => 40,
2858
+ getScrollElement: () => tableContainerRef.current,
2859
+ overscan: 8
2860
+ });
2861
+ const virtualRows = rowVirtualizer.getVirtualItems();
2862
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
2863
+ "tbody",
2864
+ {
2865
+ style: {
2866
+ display: "grid",
2867
+ height: `${showFilterRow ? rowVirtualizer.getTotalSize() + 40 : rowVirtualizer.getTotalSize()}px`,
2868
+ // tells scrollbar how big the table is
2869
+ position: "relative"
2870
+ // needed for absolute positioning of rows
2871
+ },
2872
+ children: [
2873
+ showFilterRow && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2874
+ "tr",
2875
+ {
2876
+ style: {
2877
+ display: "flex",
2878
+ position: "sticky",
2879
+ top: "40px",
2880
+ width: "100%",
2881
+ height: "40px",
2882
+ zIndex: 10
2883
+ },
2884
+ className: "even:bg-background-grouped-primary-normal odd:bg-background-grouped-secondary-normal",
2885
+ children: table.getHeaderGroups().flatMap(
2886
+ (x) => x.headers.map((header) => {
2887
+ var _a, _b, _c, _d, _e;
2888
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2889
+ DragAlongCell,
2890
+ {
2891
+ noPadding: true,
2892
+ cell: header,
2893
+ width: (_a = header.column.columnDef.meta) == null ? void 0 : _a.headerWidth,
2894
+ children: header.column.getCanFilter() && ((_e = (_c = (_b = header.column.columnDef.meta) == null ? void 0 : _b.filterRowCell) == null ? void 0 : _c.call(_b, {
2895
+ header,
2896
+ table
2897
+ })) != null ? _e : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2898
+ Search,
2899
+ {
2900
+ removeRoundness: true,
2901
+ onChange: (e) => header.column.setFilterValue(e.target.value),
2902
+ value: (_d = header.column.getFilterValue()) != null ? _d : "",
2903
+ placeholder: "",
2904
+ removeSearchIcon: true
2905
+ }
2906
+ ))
2907
+ },
2908
+ header.id
2909
+ );
2910
+ })
2911
+ )
2912
+ }
2913
+ ),
2914
+ virtualRows.map((virtualRow) => {
2915
+ const row = rows[virtualRow.index];
2916
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2917
+ TableBodyRow,
2918
+ {
2919
+ columnVirtualizer,
2920
+ row,
2921
+ rowVirtualizer,
2922
+ virtualPaddingLeft,
2923
+ virtualPaddingRight,
2924
+ virtualRow,
2925
+ showFilterRow,
2926
+ enableColumnSelector
2927
+ },
2928
+ row.id
2929
+ );
2930
+ }),
2931
+ !pagination && isLoadingMore && hasMore && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2932
+ "tr",
2933
+ {
2934
+ style: {
2935
+ display: "flex",
2936
+ position: "absolute",
2937
+ width: "100%",
2938
+ transform: `translateY(${virtualRows[virtualRows.length - 1].start + 40}px)`
2939
+ },
2940
+ className: "odd:bg-background-grouped-primary-normal even:bg-background-grouped-secondary-normal",
2941
+ children: table.getAllLeafColumns().map((column) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(LoadingCell, { column: column.columnDef }, column.id))
2942
+ }
2943
+ )
2944
+ ]
2945
+ }
2946
+ );
2947
+ }
2948
+ function TableBodyRow({
2949
+ columnVirtualizer,
2950
+ row,
2951
+ // rowVirtualizer,
2952
+ virtualPaddingLeft,
2953
+ virtualPaddingRight,
2954
+ virtualRow,
2955
+ showFilterRow,
2956
+ enableColumnSelector = false
2957
+ }) {
2958
+ const visibleCells = row.getVisibleCells();
2959
+ const virtualColumns = columnVirtualizer.getVirtualItems();
2960
+ const isError = typeof row.original === "object" && row.original !== null && "rowState" in row.original && row.original.rowState === "error";
2961
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
2962
+ "tr",
2963
+ {
2964
+ className: (0, import_clsx14.default)(
2965
+ "transition-colors hover:bg-background-action-secondary-hover",
2966
+ row.getIsSelected() && "!bg-background-action-secondary-hover",
2967
+ isError && "!bg-background-action-critical-secondary-hover",
2968
+ 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"
2969
+ ),
2970
+ style: {
2971
+ display: "flex",
2972
+ position: "absolute",
2973
+ transform: `translateY(${showFilterRow ? virtualRow.start + 40 : virtualRow.start}px)`,
2974
+ width: "100%"
2975
+ },
2976
+ children: [
2977
+ virtualPaddingLeft ? (
2978
+ // fake empty column to the left for virtualization scroll padding
2979
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("td", { style: { display: "flex", width: virtualPaddingLeft } })
2980
+ ) : null,
2981
+ virtualColumns.map((virtualColumn) => {
2982
+ var _a;
2983
+ const cell = visibleCells[virtualColumn.index];
2984
+ return ((_a = cell.column.columnDef.meta) == null ? void 0 : _a.useCustomRenderer) ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react12.default.Fragment, { children: (0, import_react_table.flexRender)(cell.column.columnDef.cell, cell.getContext()) }, cell.id) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DragAlongCell, { cell, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2985
+ Tooltip,
2986
+ {
2987
+ showOnTruncation: true,
2988
+ message: cell.getValue(),
2989
+ position: "bottom",
2990
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Paragraph, { addOverflow: true, tall: true, children: cell.getValue() })
2991
+ }
2992
+ ) }, cell.id);
2993
+ }),
2994
+ virtualPaddingRight ? (
2995
+ // fake empty column to the right for virtualization scroll padding
2996
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("td", { style: { display: "flex", width: virtualPaddingRight } })
2997
+ ) : null,
2998
+ enableColumnSelector && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("td", {})
2999
+ ]
3000
+ },
3001
+ row.id
3002
+ );
3003
+ }
3004
+ var LoadingCell = ({
3005
+ column
3006
+ }) => {
3007
+ const key = `loading-${column.id}`;
3008
+ if (column.cell === "checkbox") {
3009
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DataGridCell, { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Checkbox, { disabled: true }) }, key);
3010
+ }
3011
+ if (column.cell === "input") {
3012
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DataGridCell, { component: "input", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3013
+ Input,
3014
+ {
3015
+ align: "left",
3016
+ disabled: true,
3017
+ wrapperClassName: "!rounded-none !border-0"
3018
+ }
3019
+ ) }, key);
3020
+ }
3021
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DataGridCell, { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "bg-linear-270 to-neutral-300/[24%] from-neutral-300/[12%] rounded-xs w-full max-w-25 h-6" }) }, key);
3022
+ };
3023
+ function ColumnSelectorHeaderCell({
3024
+ table,
3025
+ toggleColumnVisibility,
3026
+ resetColumnVisibility
3027
+ }) {
3028
+ const ref = (0, import_react12.useRef)(null);
3029
+ const [show, setShow] = (0, import_react12.useState)(false);
3030
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
3031
+ DataGridCell,
3032
+ {
3033
+ width: "48",
3034
+ type: "header",
3035
+ color: "text-secondary-normal",
3036
+ ref,
3037
+ children: [
3038
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3039
+ Button,
3040
+ {
3041
+ onClick: () => setShow((prev) => !prev),
3042
+ variant: "navigation",
3043
+ iconOnly: true,
3044
+ leftIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Icon, { name: "tune" })
3045
+ }
3046
+ ),
3047
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
3048
+ Menu,
3049
+ {
3050
+ positionTo: ref,
3051
+ position: "bottom-right",
3052
+ show,
3053
+ setShow,
3054
+ children: [
3055
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3056
+ Button,
3057
+ {
3058
+ variant: "tertiary",
3059
+ onClick: () => {
3060
+ resetColumnVisibility();
3061
+ setShow(false);
3062
+ },
3063
+ children: "Reset to default"
3064
+ }
3065
+ ),
3066
+ table.getAllColumns().map((column) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3067
+ ColumnSelectorMenuOption,
3068
+ {
3069
+ column,
3070
+ toggleColumnVisibility
3071
+ },
3072
+ column.id
3073
+ ))
3074
+ ]
3075
+ }
3076
+ )
3077
+ ]
3078
+ }
3079
+ );
3080
+ }
3081
+ function ColumnSelectorMenuOption({
3082
+ column,
3083
+ toggleColumnVisibility
3084
+ }) {
3085
+ const [isVisible, setIsVisible] = (0, import_react12.useState)(column.getIsVisible());
3086
+ const label = typeof column.columnDef.header === "string" ? column.columnDef.header : null;
3087
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(MenuOption, { selected: isVisible, defaultChecked: isVisible, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3088
+ Checkbox,
3089
+ {
3090
+ label: label != null ? label : "Unknown",
3091
+ checked: isVisible,
3092
+ onChange: (e) => {
3093
+ setIsVisible(e.target.checked);
3094
+ toggleColumnVisibility(column.id, e.target.checked);
3095
+ }
3096
+ }
3097
+ ) });
3098
+ }
3099
+ function getSortIcon(sort, nextSort = false) {
3100
+ const iconClassName = (0, import_clsx14.default)(
3101
+ "text-icon-on-action-primary-normal",
3102
+ nextSort && "hidden group-hover:block"
3103
+ );
3104
+ if (sort === "asc")
3105
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Icon, { size: 16, className: iconClassName, name: "arrow_upward" });
3106
+ if (sort === "desc")
3107
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Icon, { size: 16, className: iconClassName, name: "arrow_downward" });
3108
+ return null;
3109
+ }
3110
+ // Annotate the CommonJS export names for ESM import in node:
3111
+ 0 && (module.exports = {
3112
+ DataGrid
3113
+ });