@dmsi/wedgekit-react 0.0.185 → 0.0.186

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 (39) hide show
  1. package/dist/{chunk-FFU6FB3K.js → chunk-4BGVBVKV.js} +12 -5
  2. package/dist/{chunk-5GUW4DUY.js → chunk-AEDQLVKH.js} +71 -23
  3. package/dist/{chunk-Z2KZO4J3.js → chunk-GKYKZGS7.js} +6 -6
  4. package/dist/{chunk-PMBEIP24.js → chunk-IDSFWKOR.js} +1 -1
  5. package/dist/{chunk-XH65MD2C.js → chunk-KADNOKNW.js} +1 -1
  6. package/dist/{chunk-UBU6IJML.js → chunk-M4LOHASV.js} +7 -5
  7. package/dist/components/DataGridCell.cjs +83 -26
  8. package/dist/components/DataGridCell.js +9 -9
  9. package/dist/components/DateInput.js +9 -9
  10. package/dist/components/DateRangeInput.js +10 -10
  11. package/dist/components/FilterGroup.js +7 -7
  12. package/dist/components/Input.js +2 -2
  13. package/dist/components/Menu.cjs +24 -10
  14. package/dist/components/Menu.js +3 -3
  15. package/dist/components/MenuOption.cjs +9 -2
  16. package/dist/components/MenuOption.js +2 -2
  17. package/dist/components/MobileDataGrid.js +3 -3
  18. package/dist/components/Modal.js +2 -2
  19. package/dist/components/NestedMenu.cjs +9 -2
  20. package/dist/components/NestedMenu.js +2 -2
  21. package/dist/components/Notification.js +3 -3
  22. package/dist/components/PDFViewer.js +5 -5
  23. package/dist/components/Password.js +2 -2
  24. package/dist/components/Search.js +3 -3
  25. package/dist/components/Select.js +3 -3
  26. package/dist/components/Stepper.js +2 -2
  27. package/dist/components/Time.js +2 -2
  28. package/dist/components/Toast.js +3 -3
  29. package/dist/components/Upload.js +3 -3
  30. package/dist/components/index.cjs +83 -26
  31. package/dist/components/index.js +18 -18
  32. package/dist/components/useMenuSystem.cjs +71 -23
  33. package/dist/components/useMenuSystem.js +1 -1
  34. package/package.json +1 -1
  35. package/src/components/Menu.tsx +2 -0
  36. package/src/components/MenuOption.tsx +10 -0
  37. package/src/components/useMenuSystem.tsx +80 -29
  38. package/dist/{chunk-4T3DRGLF.js → chunk-MVGOAMTP.js} +3 -3
  39. package/dist/{chunk-F6YFWBVV.js → chunk-RYBHJC4G.js} +3 -3
@@ -1,9 +1,9 @@
1
- import {
2
- useMatchesMobile
3
- } from "./chunk-WNQ53SVY.js";
4
1
  import {
5
2
  Label
6
3
  } from "./chunk-JWCT72WR.js";
4
+ import {
5
+ useMatchesMobile
6
+ } from "./chunk-WNQ53SVY.js";
7
7
  import {
8
8
  Paragraph
9
9
  } from "./chunk-HVI3CL7Y.js";
@@ -47,7 +47,8 @@ var MenuOption = ({
47
47
  activeMenu,
48
48
  mobilePositionTo,
49
49
  highlightMatchingText = false,
50
- menuValue
50
+ menuValue,
51
+ onMouseMove
51
52
  }) => {
52
53
  const uniqueId = useId();
53
54
  const internalRef = useRef(null);
@@ -64,6 +65,11 @@ var MenuOption = ({
64
65
  onSubMenuLeave(subMenuLevel);
65
66
  }
66
67
  };
68
+ const handleMouseMove = () => {
69
+ if (subMenu && onMouseMove && !disabled) {
70
+ onMouseMove();
71
+ }
72
+ };
67
73
  const handleSubMenuEnter = () => {
68
74
  if (onSubMenuEnter) {
69
75
  onSubMenuEnter();
@@ -122,7 +128,8 @@ var MenuOption = ({
122
128
  }
123
129
  },
124
130
  onMouseEnter: handleMouseEnter,
125
- onMouseLeave: handleMouseLeave
131
+ onMouseLeave: handleMouseLeave,
132
+ onMouseMove: handleMouseMove
126
133
  }, additionalAttributes), {
127
134
  tabIndex: -1,
128
135
  role: "menuitem",
@@ -19,6 +19,10 @@ function useSubMenuSystem(mobilePositionTo) {
19
19
  const subMenuRefs = useRef({});
20
20
  const hoverTimeoutRef = useRef(null);
21
21
  const closeTimeoutRef = useRef(null);
22
+ const mouseStopTimeoutRef = useRef(null);
23
+ const isMouseMovingRef = useRef(false);
24
+ const pendingOpenActionRef = useRef(null);
25
+ const pendingCloseActionRef = useRef(null);
22
26
  const isMobile = useMatchesMobile();
23
27
  const toggleMenu = (menuId, level) => {
24
28
  if (closeTimeoutRef.current) {
@@ -58,36 +62,67 @@ function useSubMenuSystem(mobilePositionTo) {
58
62
  return newActiveMenus;
59
63
  });
60
64
  };
65
+ const executePendingActions = useCallback(() => {
66
+ if (pendingCloseActionRef.current) {
67
+ pendingCloseActionRef.current();
68
+ pendingCloseActionRef.current = null;
69
+ }
70
+ if (pendingOpenActionRef.current) {
71
+ pendingOpenActionRef.current();
72
+ pendingOpenActionRef.current = null;
73
+ }
74
+ }, []);
61
75
  const openMenuWithDelay = (menuId, level, delay = 150) => {
62
76
  if (isMobile) {
63
77
  return;
64
78
  }
65
- if (hoverTimeoutRef.current) {
66
- clearTimeout(hoverTimeoutRef.current);
79
+ pendingOpenActionRef.current = () => {
80
+ if (hoverTimeoutRef.current) {
81
+ clearTimeout(hoverTimeoutRef.current);
82
+ }
83
+ hoverTimeoutRef.current = setTimeout(() => {
84
+ openMenu(menuId, level);
85
+ }, delay);
86
+ };
87
+ if (!isMouseMovingRef.current) {
88
+ executePendingActions();
67
89
  }
68
- hoverTimeoutRef.current = setTimeout(() => {
69
- openMenu(menuId, level);
70
- }, delay);
71
90
  };
72
91
  const closeMenuWithDelay = (level, delay = 500) => {
73
92
  if (isMobile) {
74
93
  return;
75
94
  }
76
- if (hoverTimeoutRef.current) {
77
- clearTimeout(hoverTimeoutRef.current);
78
- hoverTimeoutRef.current = null;
95
+ pendingCloseActionRef.current = () => {
96
+ if (hoverTimeoutRef.current) {
97
+ clearTimeout(hoverTimeoutRef.current);
98
+ hoverTimeoutRef.current = null;
99
+ }
100
+ closeTimeoutRef.current = setTimeout(() => {
101
+ closeSubMenuLevel(level);
102
+ }, delay);
103
+ };
104
+ if (!isMouseMovingRef.current) {
105
+ executePendingActions();
106
+ }
107
+ };
108
+ const handleMouseMove = () => {
109
+ isMouseMovingRef.current = true;
110
+ if (mouseStopTimeoutRef.current) {
111
+ clearTimeout(mouseStopTimeoutRef.current);
79
112
  }
80
- closeTimeoutRef.current = setTimeout(() => {
81
- closeSubMenuLevel(level);
82
- }, delay);
113
+ mouseStopTimeoutRef.current = setTimeout(() => {
114
+ isMouseMovingRef.current = false;
115
+ executePendingActions();
116
+ }, 200);
83
117
  };
84
118
  const cancelCloseTimeout = () => {
85
119
  if (isMobile) {
86
120
  return;
87
121
  }
88
- if (closeTimeoutRef.current) {
89
- clearTimeout(closeTimeoutRef.current);
90
- closeTimeoutRef.current = null;
122
+ if (mouseStopTimeoutRef.current) {
123
+ clearTimeout(mouseStopTimeoutRef.current);
124
+ mouseStopTimeoutRef.current = null;
125
+ isMouseMovingRef.current = false;
91
126
  }
92
127
  };
93
128
  const closeSubMenuLevel = (level) => {
@@ -203,6 +238,7 @@ function useSubMenuSystem(mobilePositionTo) {
203
238
  onSubMenuHover: openMenuWithDelay,
204
239
  onSubMenuLeave: closeMenuWithDelay,
205
240
  onSubMenuEnter: cancelCloseTimeout,
241
+ onMouseMove: handleMouseMove,
206
242
  toggleMenu,
207
243
  mobilePositionTo,
208
244
  activeMenu,
@@ -217,9 +253,9 @@ function useMenuPosition(elementRef, position = "bottom", options) {
217
253
  left: 0,
218
254
  minWidth: 0
219
255
  });
220
- const isMobile = useMatchesMobile();
256
+ const isMobile = options == null ? void 0 : options.isMobile;
221
257
  const updatePosition = useCallback(() => {
222
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
258
+ var _a, _b, _c;
223
259
  if (!(elementRef == null ? void 0 : elementRef.current)) return;
224
260
  const triggerRect = elementRef.current.getBoundingClientRect();
225
261
  const menuRect = (_b = (_a = options == null ? void 0 : options.menuRef) == null ? void 0 : _a.current) == null ? void 0 : _b.getBoundingClientRect();
@@ -238,15 +274,27 @@ function useMenuPosition(elementRef, position = "bottom", options) {
238
274
  } else if (position === "bottom-right") {
239
275
  left = triggerRect.right + window.scrollX - menuWidth;
240
276
  } else if (position === "right") {
241
- left = triggerRect.right + window.scrollX;
277
+ if (isMobile) {
278
+ left = triggerRect.left + window.scrollX;
279
+ } else {
280
+ left = triggerRect.right + window.scrollX;
281
+ }
282
+ }
283
+ const overflowsRightViewport = left + menuWidth > viewportWidth;
284
+ if (overflowsRightViewport) {
285
+ const newLeft = triggerRect.left - menuWidth;
286
+ const overflowsLeftViewport = newLeft < 0;
287
+ if (overflowsLeftViewport) {
288
+ left = (viewportWidth - menuWidth) / 2;
289
+ } else {
290
+ left = newLeft;
291
+ }
242
292
  }
243
- const overflowsLeftViewport = left + menuWidth > viewportWidth;
244
- if (overflowsLeftViewport) {
245
- left = triggerRect.left - menuWidth;
293
+ if (isMobile && position === "right") {
294
+ top = triggerRect.top + triggerRect.height + topOffset;
246
295
  }
247
- if (isMobile) {
248
- left = triggerRect.left + menuWidth > viewportWidth ? Math.max(viewportWidth - menuWidth, 0) - 8 : triggerRect.left;
249
- 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;
296
+ if (isMobile && menuWidth > viewportWidth) {
297
+ left = 0;
250
298
  }
251
299
  setMenuPosition({
252
300
  top,
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  Menu
3
- } from "./chunk-UBU6IJML.js";
3
+ } from "./chunk-M4LOHASV.js";
4
4
  import {
5
5
  useSubMenuSystem
6
- } from "./chunk-5GUW4DUY.js";
6
+ } from "./chunk-AEDQLVKH.js";
7
7
  import {
8
8
  MenuOption
9
- } from "./chunk-FFU6FB3K.js";
10
- import {
11
- Search
12
- } from "./chunk-PMBEIP24.js";
9
+ } from "./chunk-4BGVBVKV.js";
13
10
  import {
14
11
  CSS
15
12
  } from "./chunk-WVUIIBRR.js";
13
+ import {
14
+ Search
15
+ } from "./chunk-IDSFWKOR.js";
16
16
  import {
17
17
  Icon
18
18
  } from "./chunk-NKUETCDA.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Input
3
- } from "./chunk-4T3DRGLF.js";
3
+ } from "./chunk-MVGOAMTP.js";
4
4
  import {
5
5
  __objRest,
6
6
  __spreadValues
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  InputBase
3
- } from "./chunk-4T3DRGLF.js";
3
+ } from "./chunk-MVGOAMTP.js";
4
4
  import {
5
5
  Icon
6
6
  } from "./chunk-NKUETCDA.js";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  useMenuPosition
3
- } from "./chunk-5GUW4DUY.js";
4
- import {
5
- useMatchesMobile
6
- } from "./chunk-WNQ53SVY.js";
3
+ } from "./chunk-AEDQLVKH.js";
7
4
  import {
8
5
  findDocumentRoot
9
6
  } from "./chunk-6LN6QT6M.js";
7
+ import {
8
+ useMatchesMobile
9
+ } from "./chunk-WNQ53SVY.js";
10
10
  import {
11
11
  __objRest,
12
12
  __spreadProps,
@@ -73,7 +73,8 @@ var Menu = (_a) => {
73
73
  isOpen: show,
74
74
  setIsOpen: setShow,
75
75
  menuRef: internalRef,
76
- topOffset
76
+ topOffset,
77
+ isMobile: !!(isMobile && mobilePositionTo)
77
78
  }
78
79
  );
79
80
  useEffect(() => {
@@ -146,6 +147,7 @@ var Menu = (_a) => {
146
147
  "shadow-4 rounded-base bg-background-grouped-primary-normal overflow-x-hidden overflow-y-auto flex flex-col outline-0",
147
148
  "fixed",
148
149
  "z-50",
150
+ "max-w-screen",
149
151
  mobileHide && "opacity-0 pointer-events-none",
150
152
  className
151
153
  )
@@ -907,6 +907,10 @@ function useSubMenuSystem(mobilePositionTo) {
907
907
  const subMenuRefs = (0, import_react7.useRef)({});
908
908
  const hoverTimeoutRef = (0, import_react7.useRef)(null);
909
909
  const closeTimeoutRef = (0, import_react7.useRef)(null);
910
+ const mouseStopTimeoutRef = (0, import_react7.useRef)(null);
911
+ const isMouseMovingRef = (0, import_react7.useRef)(false);
912
+ const pendingOpenActionRef = (0, import_react7.useRef)(null);
913
+ const pendingCloseActionRef = (0, import_react7.useRef)(null);
910
914
  const isMobile = useMatchesMobile();
911
915
  const toggleMenu = (menuId, level) => {
912
916
  if (closeTimeoutRef.current) {
@@ -946,36 +950,67 @@ function useSubMenuSystem(mobilePositionTo) {
946
950
  return newActiveMenus;
947
951
  });
948
952
  };
953
+ const executePendingActions = (0, import_react7.useCallback)(() => {
954
+ if (pendingCloseActionRef.current) {
955
+ pendingCloseActionRef.current();
956
+ pendingCloseActionRef.current = null;
957
+ }
958
+ if (pendingOpenActionRef.current) {
959
+ pendingOpenActionRef.current();
960
+ pendingOpenActionRef.current = null;
961
+ }
962
+ }, []);
949
963
  const openMenuWithDelay = (menuId, level, delay = 150) => {
950
964
  if (isMobile) {
951
965
  return;
952
966
  }
953
- if (hoverTimeoutRef.current) {
954
- clearTimeout(hoverTimeoutRef.current);
967
+ pendingOpenActionRef.current = () => {
968
+ if (hoverTimeoutRef.current) {
969
+ clearTimeout(hoverTimeoutRef.current);
970
+ }
971
+ hoverTimeoutRef.current = setTimeout(() => {
972
+ openMenu(menuId, level);
973
+ }, delay);
974
+ };
975
+ if (!isMouseMovingRef.current) {
976
+ executePendingActions();
955
977
  }
956
- hoverTimeoutRef.current = setTimeout(() => {
957
- openMenu(menuId, level);
958
- }, delay);
959
978
  };
960
979
  const closeMenuWithDelay = (level, delay = 500) => {
961
980
  if (isMobile) {
962
981
  return;
963
982
  }
964
- if (hoverTimeoutRef.current) {
965
- clearTimeout(hoverTimeoutRef.current);
966
- hoverTimeoutRef.current = null;
983
+ pendingCloseActionRef.current = () => {
984
+ if (hoverTimeoutRef.current) {
985
+ clearTimeout(hoverTimeoutRef.current);
986
+ hoverTimeoutRef.current = null;
987
+ }
988
+ closeTimeoutRef.current = setTimeout(() => {
989
+ closeSubMenuLevel(level);
990
+ }, delay);
991
+ };
992
+ if (!isMouseMovingRef.current) {
993
+ executePendingActions();
967
994
  }
968
- closeTimeoutRef.current = setTimeout(() => {
969
- closeSubMenuLevel(level);
970
- }, delay);
995
+ };
996
+ const handleMouseMove = () => {
997
+ isMouseMovingRef.current = true;
998
+ if (mouseStopTimeoutRef.current) {
999
+ clearTimeout(mouseStopTimeoutRef.current);
1000
+ }
1001
+ mouseStopTimeoutRef.current = setTimeout(() => {
1002
+ isMouseMovingRef.current = false;
1003
+ executePendingActions();
1004
+ }, 200);
971
1005
  };
972
1006
  const cancelCloseTimeout = () => {
973
1007
  if (isMobile) {
974
1008
  return;
975
1009
  }
976
- if (closeTimeoutRef.current) {
977
- clearTimeout(closeTimeoutRef.current);
978
- closeTimeoutRef.current = null;
1010
+ if (mouseStopTimeoutRef.current) {
1011
+ clearTimeout(mouseStopTimeoutRef.current);
1012
+ mouseStopTimeoutRef.current = null;
1013
+ isMouseMovingRef.current = false;
979
1014
  }
980
1015
  };
981
1016
  const closeSubMenuLevel = (level) => {
@@ -1091,6 +1126,7 @@ function useSubMenuSystem(mobilePositionTo) {
1091
1126
  onSubMenuHover: openMenuWithDelay,
1092
1127
  onSubMenuLeave: closeMenuWithDelay,
1093
1128
  onSubMenuEnter: cancelCloseTimeout,
1129
+ onMouseMove: handleMouseMove,
1094
1130
  toggleMenu,
1095
1131
  mobilePositionTo,
1096
1132
  activeMenu,
@@ -1105,9 +1141,9 @@ function useMenuPosition(elementRef, position = "bottom", options) {
1105
1141
  left: 0,
1106
1142
  minWidth: 0
1107
1143
  });
1108
- const isMobile = useMatchesMobile();
1144
+ const isMobile = options == null ? void 0 : options.isMobile;
1109
1145
  const updatePosition = (0, import_react7.useCallback)(() => {
1110
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
1146
+ var _a, _b, _c;
1111
1147
  if (!(elementRef == null ? void 0 : elementRef.current)) return;
1112
1148
  const triggerRect = elementRef.current.getBoundingClientRect();
1113
1149
  const menuRect = (_b = (_a = options == null ? void 0 : options.menuRef) == null ? void 0 : _a.current) == null ? void 0 : _b.getBoundingClientRect();
@@ -1126,15 +1162,27 @@ function useMenuPosition(elementRef, position = "bottom", options) {
1126
1162
  } else if (position === "bottom-right") {
1127
1163
  left = triggerRect.right + window.scrollX - menuWidth;
1128
1164
  } else if (position === "right") {
1129
- left = triggerRect.right + window.scrollX;
1165
+ if (isMobile) {
1166
+ left = triggerRect.left + window.scrollX;
1167
+ } else {
1168
+ left = triggerRect.right + window.scrollX;
1169
+ }
1170
+ }
1171
+ const overflowsRightViewport = left + menuWidth > viewportWidth;
1172
+ if (overflowsRightViewport) {
1173
+ const newLeft = triggerRect.left - menuWidth;
1174
+ const overflowsLeftViewport = newLeft < 0;
1175
+ if (overflowsLeftViewport) {
1176
+ left = (viewportWidth - menuWidth) / 2;
1177
+ } else {
1178
+ left = newLeft;
1179
+ }
1130
1180
  }
1131
- const overflowsLeftViewport = left + menuWidth > viewportWidth;
1132
- if (overflowsLeftViewport) {
1133
- left = triggerRect.left - menuWidth;
1181
+ if (isMobile && position === "right") {
1182
+ top = triggerRect.top + triggerRect.height + topOffset;
1134
1183
  }
1135
- if (isMobile) {
1136
- left = triggerRect.left + menuWidth > viewportWidth ? Math.max(viewportWidth - menuWidth, 0) - 8 : triggerRect.left;
1137
- 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;
1184
+ if (isMobile && menuWidth > viewportWidth) {
1185
+ left = 0;
1138
1186
  }
1139
1187
  setMenuPosition({
1140
1188
  top,
@@ -1261,7 +1309,8 @@ var Menu = (_a) => {
1261
1309
  isOpen: show,
1262
1310
  setIsOpen: setShow,
1263
1311
  menuRef: internalRef,
1264
- topOffset
1312
+ topOffset,
1313
+ isMobile: !!(isMobile && mobilePositionTo)
1265
1314
  }
1266
1315
  );
1267
1316
  (0, import_react8.useEffect)(() => {
@@ -1334,6 +1383,7 @@ var Menu = (_a) => {
1334
1383
  "shadow-4 rounded-base bg-background-grouped-primary-normal overflow-x-hidden overflow-y-auto flex flex-col outline-0",
1335
1384
  "fixed",
1336
1385
  "z-50",
1386
+ "max-w-screen",
1337
1387
  mobileHide && "opacity-0 pointer-events-none",
1338
1388
  className
1339
1389
  )
@@ -1540,7 +1590,8 @@ var MenuOption = ({
1540
1590
  activeMenu,
1541
1591
  mobilePositionTo,
1542
1592
  highlightMatchingText = false,
1543
- menuValue
1593
+ menuValue,
1594
+ onMouseMove
1544
1595
  }) => {
1545
1596
  const uniqueId = (0, import_react9.useId)();
1546
1597
  const internalRef = (0, import_react9.useRef)(null);
@@ -1557,6 +1608,11 @@ var MenuOption = ({
1557
1608
  onSubMenuLeave(subMenuLevel);
1558
1609
  }
1559
1610
  };
1611
+ const handleMouseMove = () => {
1612
+ if (subMenu && onMouseMove && !disabled) {
1613
+ onMouseMove();
1614
+ }
1615
+ };
1560
1616
  const handleSubMenuEnter = () => {
1561
1617
  if (onSubMenuEnter) {
1562
1618
  onSubMenuEnter();
@@ -1615,7 +1671,8 @@ var MenuOption = ({
1615
1671
  }
1616
1672
  },
1617
1673
  onMouseEnter: handleMouseEnter,
1618
- onMouseLeave: handleMouseLeave
1674
+ onMouseLeave: handleMouseLeave,
1675
+ onMouseMove: handleMouseMove
1619
1676
  }, additionalAttributes), {
1620
1677
  tabIndex: -1,
1621
1678
  role: "menuitem",
@@ -4,17 +4,17 @@ import {
4
4
  DataGridCell,
5
5
  DragAlongCell,
6
6
  DraggableCellHeader
7
- } from "../chunk-Z2KZO4J3.js";
8
- import "../chunk-UBU6IJML.js";
9
- import "../chunk-5GUW4DUY.js";
10
- import "../chunk-FFU6FB3K.js";
11
- import "../chunk-WNQ53SVY.js";
7
+ } from "../chunk-GKYKZGS7.js";
8
+ import "../chunk-M4LOHASV.js";
9
+ import "../chunk-AEDQLVKH.js";
10
+ import "../chunk-4BGVBVKV.js";
11
+ import "../chunk-WVUIIBRR.js";
12
12
  import "../chunk-6LN6QT6M.js";
13
- import "../chunk-PMBEIP24.js";
14
- import "../chunk-4T3DRGLF.js";
15
- import "../chunk-5UH6QUFB.js";
13
+ import "../chunk-IDSFWKOR.js";
14
+ import "../chunk-MVGOAMTP.js";
16
15
  import "../chunk-JWCT72WR.js";
17
- import "../chunk-WVUIIBRR.js";
16
+ import "../chunk-WNQ53SVY.js";
17
+ import "../chunk-5UH6QUFB.js";
18
18
  import "../chunk-HVI3CL7Y.js";
19
19
  import "../chunk-NKUETCDA.js";
20
20
  import "../chunk-RDLEIAQU.js";
@@ -1,21 +1,21 @@
1
- import {
2
- calculateCursorPosition,
3
- formatDate,
4
- formatInputValue,
5
- isValidDate,
6
- parseInputDate
7
- } from "../chunk-M3433XEJ.js";
8
1
  import {
9
2
  findDocumentRoot
10
3
  } from "../chunk-6LN6QT6M.js";
11
4
  import {
12
5
  InputBase
13
- } from "../chunk-4T3DRGLF.js";
14
- import "../chunk-5UH6QUFB.js";
6
+ } from "../chunk-MVGOAMTP.js";
15
7
  import "../chunk-JWCT72WR.js";
16
8
  import {
17
9
  CalendarRange
18
10
  } from "../chunk-4XA32LKR.js";
11
+ import {
12
+ calculateCursorPosition,
13
+ formatDate,
14
+ formatInputValue,
15
+ isValidDate,
16
+ parseInputDate
17
+ } from "../chunk-M3433XEJ.js";
18
+ import "../chunk-5UH6QUFB.js";
19
19
  import {
20
20
  Icon
21
21
  } from "../chunk-NKUETCDA.js";
@@ -1,22 +1,22 @@
1
- import {
2
- calculateCursorPosition,
3
- formatDate,
4
- formatInputValue,
5
- isValidDate,
6
- isValidDateRangeOrder,
7
- parseInputDate
8
- } from "../chunk-M3433XEJ.js";
9
1
  import {
10
2
  findDocumentRoot
11
3
  } from "../chunk-6LN6QT6M.js";
12
4
  import {
13
5
  InputBase
14
- } from "../chunk-4T3DRGLF.js";
15
- import "../chunk-5UH6QUFB.js";
6
+ } from "../chunk-MVGOAMTP.js";
16
7
  import "../chunk-JWCT72WR.js";
17
8
  import {
18
9
  CalendarRange
19
10
  } from "../chunk-4XA32LKR.js";
11
+ import {
12
+ calculateCursorPosition,
13
+ formatDate,
14
+ formatInputValue,
15
+ isValidDate,
16
+ isValidDateRangeOrder,
17
+ parseInputDate
18
+ } from "../chunk-M3433XEJ.js";
19
+ import "../chunk-5UH6QUFB.js";
20
20
  import {
21
21
  Icon
22
22
  } from "../chunk-NKUETCDA.js";
@@ -2,22 +2,22 @@
2
2
  import {
3
3
  OptionPill
4
4
  } from "../chunk-LM5MKBPM.js";
5
- import {
6
- Checkbox
7
- } from "../chunk-WFQEE2OO.js";
8
5
  import {
9
6
  Search
10
- } from "../chunk-PMBEIP24.js";
11
- import "../chunk-4T3DRGLF.js";
12
- import "../chunk-5UH6QUFB.js";
7
+ } from "../chunk-IDSFWKOR.js";
8
+ import "../chunk-MVGOAMTP.js";
13
9
  import {
14
10
  Label
15
11
  } from "../chunk-JWCT72WR.js";
12
+ import {
13
+ Checkbox
14
+ } from "../chunk-WFQEE2OO.js";
15
+ import "../chunk-FKMKHLQH.js";
16
+ import "../chunk-5UH6QUFB.js";
16
17
  import "../chunk-HVI3CL7Y.js";
17
18
  import {
18
19
  Link
19
20
  } from "../chunk-I6GEUF6Y.js";
20
- import "../chunk-FKMKHLQH.js";
21
21
  import {
22
22
  Icon
23
23
  } from "../chunk-NKUETCDA.js";
@@ -6,9 +6,9 @@ import {
6
6
  InputBase,
7
7
  Percentage,
8
8
  UOM
9
- } from "../chunk-4T3DRGLF.js";
10
- import "../chunk-5UH6QUFB.js";
9
+ } from "../chunk-MVGOAMTP.js";
11
10
  import "../chunk-JWCT72WR.js";
11
+ import "../chunk-5UH6QUFB.js";
12
12
  import "../chunk-NKUETCDA.js";
13
13
  import "../chunk-RDLEIAQU.js";
14
14
  import "../chunk-ORMEWXMH.js";
@@ -98,9 +98,9 @@ function useMenuPosition(elementRef, position = "bottom", options) {
98
98
  left: 0,
99
99
  minWidth: 0
100
100
  });
101
- const isMobile = useMatchesMobile();
101
+ const isMobile = options == null ? void 0 : options.isMobile;
102
102
  const updatePosition = (0, import_react4.useCallback)(() => {
103
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
103
+ var _a, _b, _c;
104
104
  if (!(elementRef == null ? void 0 : elementRef.current)) return;
105
105
  const triggerRect = elementRef.current.getBoundingClientRect();
106
106
  const menuRect = (_b = (_a = options == null ? void 0 : options.menuRef) == null ? void 0 : _a.current) == null ? void 0 : _b.getBoundingClientRect();
@@ -119,15 +119,27 @@ function useMenuPosition(elementRef, position = "bottom", options) {
119
119
  } else if (position === "bottom-right") {
120
120
  left = triggerRect.right + window.scrollX - menuWidth;
121
121
  } else if (position === "right") {
122
- left = triggerRect.right + window.scrollX;
122
+ if (isMobile) {
123
+ left = triggerRect.left + window.scrollX;
124
+ } else {
125
+ left = triggerRect.right + window.scrollX;
126
+ }
123
127
  }
124
- const overflowsLeftViewport = left + menuWidth > viewportWidth;
125
- if (overflowsLeftViewport) {
126
- left = triggerRect.left - menuWidth;
128
+ const overflowsRightViewport = left + menuWidth > viewportWidth;
129
+ if (overflowsRightViewport) {
130
+ const newLeft = triggerRect.left - menuWidth;
131
+ const overflowsLeftViewport = newLeft < 0;
132
+ if (overflowsLeftViewport) {
133
+ left = (viewportWidth - menuWidth) / 2;
134
+ } else {
135
+ left = newLeft;
136
+ }
137
+ }
138
+ if (isMobile && position === "right") {
139
+ top = triggerRect.top + triggerRect.height + topOffset;
127
140
  }
128
- if (isMobile) {
129
- left = triggerRect.left + menuWidth > viewportWidth ? Math.max(viewportWidth - menuWidth, 0) - 8 : triggerRect.left;
130
- 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;
141
+ if (isMobile && menuWidth > viewportWidth) {
142
+ left = 0;
131
143
  }
132
144
  setMenuPosition({
133
145
  top,
@@ -254,7 +266,8 @@ var Menu = (_a) => {
254
266
  isOpen: show,
255
267
  setIsOpen: setShow,
256
268
  menuRef: internalRef,
257
- topOffset
269
+ topOffset,
270
+ isMobile: !!(isMobile && mobilePositionTo)
258
271
  }
259
272
  );
260
273
  (0, import_react5.useEffect)(() => {
@@ -327,6 +340,7 @@ var Menu = (_a) => {
327
340
  "shadow-4 rounded-base bg-background-grouped-primary-normal overflow-x-hidden overflow-y-auto flex flex-col outline-0",
328
341
  "fixed",
329
342
  "z-50",
343
+ "max-w-screen",
330
344
  mobileHide && "opacity-0 pointer-events-none",
331
345
  className
332
346
  )
@@ -1,10 +1,10 @@
1
1
  "use client";
2
2
  import {
3
3
  Menu
4
- } from "../chunk-UBU6IJML.js";
5
- import "../chunk-5GUW4DUY.js";
6
- import "../chunk-WNQ53SVY.js";
4
+ } from "../chunk-M4LOHASV.js";
5
+ import "../chunk-AEDQLVKH.js";
7
6
  import "../chunk-6LN6QT6M.js";
7
+ import "../chunk-WNQ53SVY.js";
8
8
  import "../chunk-ORMEWXMH.js";
9
9
  export {
10
10
  Menu