@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
@@ -75,6 +75,10 @@ function useSubMenuSystem(mobilePositionTo) {
75
75
  const subMenuRefs = (0, import_react4.useRef)({});
76
76
  const hoverTimeoutRef = (0, import_react4.useRef)(null);
77
77
  const closeTimeoutRef = (0, import_react4.useRef)(null);
78
+ const mouseStopTimeoutRef = (0, import_react4.useRef)(null);
79
+ const isMouseMovingRef = (0, import_react4.useRef)(false);
80
+ const pendingOpenActionRef = (0, import_react4.useRef)(null);
81
+ const pendingCloseActionRef = (0, import_react4.useRef)(null);
78
82
  const isMobile = useMatchesMobile();
79
83
  const toggleMenu = (menuId, level) => {
80
84
  if (closeTimeoutRef.current) {
@@ -114,36 +118,67 @@ function useSubMenuSystem(mobilePositionTo) {
114
118
  return newActiveMenus;
115
119
  });
116
120
  };
121
+ const executePendingActions = (0, import_react4.useCallback)(() => {
122
+ if (pendingCloseActionRef.current) {
123
+ pendingCloseActionRef.current();
124
+ pendingCloseActionRef.current = null;
125
+ }
126
+ if (pendingOpenActionRef.current) {
127
+ pendingOpenActionRef.current();
128
+ pendingOpenActionRef.current = null;
129
+ }
130
+ }, []);
117
131
  const openMenuWithDelay = (menuId, level, delay = 150) => {
118
132
  if (isMobile) {
119
133
  return;
120
134
  }
121
- if (hoverTimeoutRef.current) {
122
- clearTimeout(hoverTimeoutRef.current);
135
+ pendingOpenActionRef.current = () => {
136
+ if (hoverTimeoutRef.current) {
137
+ clearTimeout(hoverTimeoutRef.current);
138
+ }
139
+ hoverTimeoutRef.current = setTimeout(() => {
140
+ openMenu(menuId, level);
141
+ }, delay);
142
+ };
143
+ if (!isMouseMovingRef.current) {
144
+ executePendingActions();
123
145
  }
124
- hoverTimeoutRef.current = setTimeout(() => {
125
- openMenu(menuId, level);
126
- }, delay);
127
146
  };
128
147
  const closeMenuWithDelay = (level, delay = 500) => {
129
148
  if (isMobile) {
130
149
  return;
131
150
  }
132
- if (hoverTimeoutRef.current) {
133
- clearTimeout(hoverTimeoutRef.current);
134
- hoverTimeoutRef.current = null;
151
+ pendingCloseActionRef.current = () => {
152
+ if (hoverTimeoutRef.current) {
153
+ clearTimeout(hoverTimeoutRef.current);
154
+ hoverTimeoutRef.current = null;
155
+ }
156
+ closeTimeoutRef.current = setTimeout(() => {
157
+ closeSubMenuLevel(level);
158
+ }, delay);
159
+ };
160
+ if (!isMouseMovingRef.current) {
161
+ executePendingActions();
162
+ }
163
+ };
164
+ const handleMouseMove = () => {
165
+ isMouseMovingRef.current = true;
166
+ if (mouseStopTimeoutRef.current) {
167
+ clearTimeout(mouseStopTimeoutRef.current);
135
168
  }
136
- closeTimeoutRef.current = setTimeout(() => {
137
- closeSubMenuLevel(level);
138
- }, delay);
169
+ mouseStopTimeoutRef.current = setTimeout(() => {
170
+ isMouseMovingRef.current = false;
171
+ executePendingActions();
172
+ }, 200);
139
173
  };
140
174
  const cancelCloseTimeout = () => {
141
175
  if (isMobile) {
142
176
  return;
143
177
  }
144
- if (closeTimeoutRef.current) {
145
- clearTimeout(closeTimeoutRef.current);
146
- closeTimeoutRef.current = null;
178
+ if (mouseStopTimeoutRef.current) {
179
+ clearTimeout(mouseStopTimeoutRef.current);
180
+ mouseStopTimeoutRef.current = null;
181
+ isMouseMovingRef.current = false;
147
182
  }
148
183
  };
149
184
  const closeSubMenuLevel = (level) => {
@@ -259,6 +294,7 @@ function useSubMenuSystem(mobilePositionTo) {
259
294
  onSubMenuHover: openMenuWithDelay,
260
295
  onSubMenuLeave: closeMenuWithDelay,
261
296
  onSubMenuEnter: cancelCloseTimeout,
297
+ onMouseMove: handleMouseMove,
262
298
  toggleMenu,
263
299
  mobilePositionTo,
264
300
  activeMenu,
@@ -273,9 +309,9 @@ function useMenuPosition(elementRef, position = "bottom", options) {
273
309
  left: 0,
274
310
  minWidth: 0
275
311
  });
276
- const isMobile = useMatchesMobile();
312
+ const isMobile = options == null ? void 0 : options.isMobile;
277
313
  const updatePosition = (0, import_react4.useCallback)(() => {
278
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
314
+ var _a, _b, _c;
279
315
  if (!(elementRef == null ? void 0 : elementRef.current)) return;
280
316
  const triggerRect = elementRef.current.getBoundingClientRect();
281
317
  const menuRect = (_b = (_a = options == null ? void 0 : options.menuRef) == null ? void 0 : _a.current) == null ? void 0 : _b.getBoundingClientRect();
@@ -294,15 +330,27 @@ function useMenuPosition(elementRef, position = "bottom", options) {
294
330
  } else if (position === "bottom-right") {
295
331
  left = triggerRect.right + window.scrollX - menuWidth;
296
332
  } else if (position === "right") {
297
- left = triggerRect.right + window.scrollX;
333
+ if (isMobile) {
334
+ left = triggerRect.left + window.scrollX;
335
+ } else {
336
+ left = triggerRect.right + window.scrollX;
337
+ }
338
+ }
339
+ const overflowsRightViewport = left + menuWidth > viewportWidth;
340
+ if (overflowsRightViewport) {
341
+ const newLeft = triggerRect.left - menuWidth;
342
+ const overflowsLeftViewport = newLeft < 0;
343
+ if (overflowsLeftViewport) {
344
+ left = (viewportWidth - menuWidth) / 2;
345
+ } else {
346
+ left = newLeft;
347
+ }
298
348
  }
299
- const overflowsLeftViewport = left + menuWidth > viewportWidth;
300
- if (overflowsLeftViewport) {
301
- left = triggerRect.left - menuWidth;
349
+ if (isMobile && position === "right") {
350
+ top = triggerRect.top + triggerRect.height + topOffset;
302
351
  }
303
- if (isMobile) {
304
- left = triggerRect.left + menuWidth > viewportWidth ? Math.max(viewportWidth - menuWidth, 0) - 8 : triggerRect.left;
305
- 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;
352
+ if (isMobile && menuWidth > viewportWidth) {
353
+ left = 0;
306
354
  }
307
355
  setMenuPosition({
308
356
  top,
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  useMenuPosition,
4
4
  useSubMenuSystem
5
- } from "../chunk-5GUW4DUY.js";
5
+ } from "../chunk-AEDQLVKH.js";
6
6
  import "../chunk-WNQ53SVY.js";
7
7
  import "../chunk-ORMEWXMH.js";
8
8
  export {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dmsi/wedgekit-react",
3
3
  "private": false,
4
- "version": "0.0.185",
4
+ "version": "0.0.186",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "build": "tsup",
@@ -67,6 +67,7 @@ export const Menu = ({
67
67
  setIsOpen: setShow,
68
68
  menuRef: internalRef,
69
69
  topOffset,
70
+ isMobile: !!(isMobile && mobilePositionTo)
70
71
  },
71
72
  );
72
73
 
@@ -158,6 +159,7 @@ export const Menu = ({
158
159
  "shadow-4 rounded-base bg-background-grouped-primary-normal overflow-x-hidden overflow-y-auto flex flex-col outline-0",
159
160
  "fixed",
160
161
  "z-50",
162
+ "max-w-screen",
161
163
  mobileHide && "opacity-0 pointer-events-none",
162
164
  className,
163
165
  )}
@@ -38,6 +38,7 @@ type BaseProps = PropsWithChildren<{
38
38
  onSubMenuHover: (menuId: string, level: number) => void;
39
39
  onSubMenuLeave: (level: number) => void;
40
40
  onSubMenuEnter: () => void;
41
+ onMouseMove: () => void;
41
42
  toggleMenu: (id: string, level: number) => void;
42
43
  activeMenu: string;
43
44
  closeSubMenuLevel: (level: number) => void;
@@ -48,6 +49,7 @@ type BaseProps = PropsWithChildren<{
48
49
  onSubMenuHover?: (menuId: string, level: number) => void;
49
50
  onSubMenuLeave?: (level: number) => void;
50
51
  onSubMenuEnter?: () => void;
52
+ onMouseMove?: () => void;
51
53
  toggleMenu?: (id: string, level: number) => void;
52
54
  closeSubMenuLevel?: (level: number) => void;
53
55
  activeMenu?: string;
@@ -98,6 +100,7 @@ export const MenuOption = ({
98
100
  mobilePositionTo,
99
101
  highlightMatchingText = false,
100
102
  menuValue,
103
+ onMouseMove
101
104
  }: MenuOptionProps) => {
102
105
  const uniqueId = useId();
103
106
  const internalRef = useRef(null);
@@ -117,6 +120,12 @@ export const MenuOption = ({
117
120
  }
118
121
  };
119
122
 
123
+ const handleMouseMove = () => {
124
+ if (subMenu && onMouseMove && !disabled) {
125
+ onMouseMove();
126
+ }
127
+ }
128
+
120
129
  const handleSubMenuEnter = () => {
121
130
  if (onSubMenuEnter) {
122
131
  onSubMenuEnter();
@@ -209,6 +218,7 @@ export const MenuOption = ({
209
218
  }}
210
219
  onMouseEnter={handleMouseEnter}
211
220
  onMouseLeave={handleMouseLeave}
221
+ onMouseMove={handleMouseMove}
212
222
  {...additionalAttributes}
213
223
  tabIndex={-1}
214
224
  role="menuitem"
@@ -23,6 +23,10 @@ export function useSubMenuSystem(
23
23
  const subMenuRefs = useRef<{ [id: string]: HTMLElement | null }>({});
24
24
  const hoverTimeoutRef = useRef<NodeJS.Timeout | null>(null);
25
25
  const closeTimeoutRef = useRef<NodeJS.Timeout | null>(null);
26
+ const mouseStopTimeoutRef = useRef<NodeJS.Timeout | null>(null);
27
+ const isMouseMovingRef = useRef(false);
28
+ const pendingOpenActionRef = useRef<(() => void) | null>(null);
29
+ const pendingCloseActionRef = useRef<(() => void) | null>(null);
26
30
  const isMobile = useMatchesMobile();
27
31
 
28
32
  const toggleMenu = (menuId: string, level: number) => {
@@ -72,18 +76,36 @@ export function useSubMenuSystem(
72
76
  });
73
77
  };
74
78
 
79
+ const executePendingActions = useCallback(() => {
80
+ if (pendingCloseActionRef.current) {
81
+ pendingCloseActionRef.current();
82
+ pendingCloseActionRef.current = null;
83
+ }
84
+
85
+ if (pendingOpenActionRef.current) {
86
+ pendingOpenActionRef.current();
87
+ pendingOpenActionRef.current = null;
88
+ }
89
+ }, []);
90
+
75
91
  const openMenuWithDelay = (menuId: string, level: number, delay = 150) => {
76
92
  if (isMobile) {
77
93
  return;
78
94
  }
79
95
 
80
- if (hoverTimeoutRef.current) {
81
- clearTimeout(hoverTimeoutRef.current);
96
+ pendingOpenActionRef.current = () => {
97
+ if (hoverTimeoutRef.current) {
98
+ clearTimeout(hoverTimeoutRef.current);
99
+ }
100
+
101
+ hoverTimeoutRef.current = setTimeout(() => {
102
+ openMenu(menuId, level);
103
+ }, delay);
82
104
  }
83
105
 
84
- hoverTimeoutRef.current = setTimeout(() => {
85
- openMenu(menuId, level);
86
- }, delay);
106
+ if (!isMouseMovingRef.current) {
107
+ executePendingActions();
108
+ }
87
109
  };
88
110
 
89
111
  const closeMenuWithDelay = (level: number, delay = 500) => {
@@ -91,14 +113,33 @@ export function useSubMenuSystem(
91
113
  return;
92
114
  }
93
115
 
94
- if (hoverTimeoutRef.current) {
95
- clearTimeout(hoverTimeoutRef.current);
96
- hoverTimeoutRef.current = null;
116
+ pendingCloseActionRef.current = () => {
117
+ if (hoverTimeoutRef.current) {
118
+ clearTimeout(hoverTimeoutRef.current);
119
+ hoverTimeoutRef.current = null;
120
+ }
121
+
122
+ closeTimeoutRef.current = setTimeout(() => {
123
+ closeSubMenuLevel(level);
124
+ }, delay);
125
+ }
126
+
127
+ if (!isMouseMovingRef.current) {
128
+ executePendingActions();
97
129
  }
130
+ };
98
131
 
99
- closeTimeoutRef.current = setTimeout(() => {
100
- closeSubMenuLevel(level);
101
- }, delay);
132
+ const handleMouseMove = () => {
133
+ isMouseMovingRef.current = true;
134
+
135
+ if (mouseStopTimeoutRef.current) {
136
+ clearTimeout(mouseStopTimeoutRef.current);
137
+ }
138
+
139
+ mouseStopTimeoutRef.current = setTimeout(() => {
140
+ isMouseMovingRef.current = false;
141
+ executePendingActions();
142
+ }, 200);
102
143
  };
103
144
 
104
145
  const cancelCloseTimeout = () => {
@@ -106,9 +147,10 @@ export function useSubMenuSystem(
106
147
  return;
107
148
  }
108
149
 
109
- if (closeTimeoutRef.current) {
110
- clearTimeout(closeTimeoutRef.current);
111
- closeTimeoutRef.current = null;
150
+ if (mouseStopTimeoutRef.current) {
151
+ clearTimeout(mouseStopTimeoutRef.current);
152
+ mouseStopTimeoutRef.current = null;
153
+ isMouseMovingRef.current = false;
112
154
  }
113
155
  };
114
156
 
@@ -250,6 +292,7 @@ export function useSubMenuSystem(
250
292
  onSubMenuHover: openMenuWithDelay,
251
293
  onSubMenuLeave: closeMenuWithDelay,
252
294
  onSubMenuEnter: cancelCloseTimeout,
295
+ onMouseMove: handleMouseMove,
253
296
  toggleMenu,
254
297
  mobilePositionTo,
255
298
  activeMenu,
@@ -268,6 +311,7 @@ export function useMenuPosition(
268
311
  menuRef?: RefObject<HTMLElement | null>;
269
312
  additionalRefs?: RefObject<HTMLElement | null>[];
270
313
  topOffset?: number | null;
314
+ isMobile?: boolean;
271
315
  },
272
316
  ) {
273
317
  const [menuPosition, setMenuPosition] = useState<MenuPosition>({
@@ -276,7 +320,7 @@ export function useMenuPosition(
276
320
  minWidth: 0,
277
321
  });
278
322
 
279
- const isMobile = useMatchesMobile();
323
+ const isMobile = options?.isMobile;
280
324
 
281
325
  const updatePosition = useCallback(() => {
282
326
  if (!elementRef?.current) return;
@@ -302,25 +346,32 @@ export function useMenuPosition(
302
346
  } else if (position === "bottom-right") {
303
347
  left = triggerRect.right + window.scrollX - menuWidth;
304
348
  } else if (position === "right") {
305
- left = triggerRect.right + window.scrollX;
349
+ if (isMobile) {
350
+ left = triggerRect.left + window.scrollX
351
+ } else {
352
+ left = triggerRect.right + window.scrollX;
353
+ }
306
354
  }
307
355
 
308
- const overflowsLeftViewport = left + menuWidth > viewportWidth;
356
+ const overflowsRightViewport = left + menuWidth > viewportWidth;
357
+
358
+ if (overflowsRightViewport) {
359
+ const newLeft = triggerRect.left - menuWidth;
360
+ const overflowsLeftViewport = newLeft < 0;
361
+
362
+ if (overflowsLeftViewport) {
363
+ left = (viewportWidth - menuWidth) / 2;
364
+ } else {
365
+ left = newLeft;
366
+ }
367
+ }
309
368
 
310
- if (overflowsLeftViewport) {
311
- left = triggerRect.left - menuWidth;
369
+ if (isMobile && position === "right") {
370
+ top = triggerRect.top + triggerRect.height + topOffset;
312
371
  }
313
372
 
314
- if (isMobile) {
315
- left =
316
- triggerRect.left + menuWidth > viewportWidth
317
- ? Math.max(viewportWidth - menuWidth, 0) - 8
318
- : triggerRect.left;
319
- top =
320
- (elementRef.current.parentElement?.getBoundingClientRect()?.top ?? 0) +
321
- (elementRef.current.parentElement?.getBoundingClientRect()?.height ??
322
- 0) +
323
- topOffset;
373
+ if (isMobile && menuWidth > viewportWidth) {
374
+ left = 0;
324
375
  }
325
376
 
326
377
  setMenuPosition({
@@ -1,11 +1,11 @@
1
+ import {
2
+ Label
3
+ } from "./chunk-JWCT72WR.js";
1
4
  import {
2
5
  formatCurrencyDisplay,
3
6
  formatDecimalValue,
4
7
  getDecimalPlaceholder
5
8
  } from "./chunk-5UH6QUFB.js";
6
- import {
7
- Label
8
- } from "./chunk-JWCT72WR.js";
9
9
  import {
10
10
  Icon
11
11
  } from "./chunk-NKUETCDA.js";
@@ -13,12 +13,12 @@ import {
13
13
  import {
14
14
  ModalScrim
15
15
  } from "./chunk-ZFOANBWG.js";
16
- import {
17
- useMatchesMobile
18
- } from "./chunk-WNQ53SVY.js";
19
16
  import {
20
17
  findDocumentRoot
21
18
  } from "./chunk-6LN6QT6M.js";
19
+ import {
20
+ useMatchesMobile
21
+ } from "./chunk-WNQ53SVY.js";
22
22
 
23
23
  // src/components/Modal.tsx
24
24
  import clsx from "clsx";