@vuu-ui/vuu-popups 0.8.10-debug → 0.8.11-debug
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.
- package/cjs/index.js +483 -351
- package/cjs/index.js.map +4 -4
- package/esm/index.js +516 -386
- package/esm/index.js.map +4 -4
- package/index.css +110 -57
- package/index.css.map +3 -3
- package/package.json +7 -7
- package/types/dialog-header/DialogHeader.d.ts +7 -0
- package/types/dialog-header/index.d.ts +1 -0
- package/types/index.d.ts +2 -0
- package/types/menu/ContextMenu.d.ts +3 -2
- package/types/menu/MenuList.d.ts +4 -3
- package/types/menu/use-cascade.d.ts +3 -2
- package/types/menu/use-keyboard-navigation.d.ts +2 -1
- package/types/menu/useContextMenu.d.ts +0 -1
- package/types/notifications/NotificationsProvider.d.ts +30 -0
- package/types/notifications/index.d.ts +1 -0
- package/types/popup/Popup.d.ts +6 -3
- package/types/popup/popup-service.d.ts +1 -14
- package/types/popup/useAnchoredPosition.d.ts +12 -10
- package/types/popup-menu/PopupMenu.d.ts +1 -1
- package/types/portal/Portal.d.ts +12 -1
- package/types/portal-deprecated/index.d.ts +0 -2
- package/types/portal-deprecated/PortalDeprecated.d.ts +0 -8
- package/types/portal-deprecated/portal-utils.d.ts +0 -1
package/esm/index.js
CHANGED
|
@@ -1,86 +1,85 @@
|
|
|
1
1
|
// src/dialog/Dialog.tsx
|
|
2
2
|
import { Scrim } from "@salt-ds/lab";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { useCallback, useRef, useState } from "react";
|
|
6
|
-
|
|
7
|
-
// src/portal-deprecated/PortalDeprecated.tsx
|
|
8
|
-
import { useLayoutEffect, useMemo } from "react";
|
|
9
|
-
import * as ReactDOM2 from "react-dom";
|
|
10
|
-
|
|
11
|
-
// src/portal-deprecated/render-portal.tsx
|
|
12
|
-
import * as ReactDOM from "react-dom";
|
|
13
|
-
import cx from "classnames";
|
|
14
|
-
var containerId = 1;
|
|
15
|
-
var getPortalContainer = ({
|
|
16
|
-
className,
|
|
17
|
-
dataMode,
|
|
18
|
-
x = 0,
|
|
19
|
-
y = 0,
|
|
20
|
-
win = window
|
|
21
|
-
}) => {
|
|
22
|
-
const el = win.document.createElement("div");
|
|
23
|
-
el.className = cx(`vuuPopup ${containerId++}`, className);
|
|
24
|
-
el.style.cssText = `left:${x}px; top:${y}px;`;
|
|
25
|
-
if (dataMode) {
|
|
26
|
-
el.dataset.mode = dataMode;
|
|
27
|
-
}
|
|
28
|
-
win.document.body.appendChild(el);
|
|
29
|
-
return el;
|
|
30
|
-
};
|
|
31
|
-
var createContainer = (props) => getPortalContainer(props);
|
|
32
|
-
var renderPortal = (component, container, x, y, onRender) => {
|
|
33
|
-
container.style.cssText = `left:${x}px; top:${y}px;position: absolute;`;
|
|
34
|
-
ReactDOM.render(component, container, onRender);
|
|
35
|
-
};
|
|
3
|
+
import cx2 from "classnames";
|
|
4
|
+
import { useCallback, useRef as useRef2 } from "react";
|
|
36
5
|
|
|
37
|
-
// src/portal
|
|
6
|
+
// src/portal/Portal.tsx
|
|
38
7
|
import { useThemeAttributes } from "@vuu-ui/vuu-shell";
|
|
39
|
-
import
|
|
40
|
-
|
|
8
|
+
import { useLayoutEffect, useRef, useState } from "react";
|
|
9
|
+
import { createPortal } from "react-dom";
|
|
10
|
+
function getContainer(container) {
|
|
11
|
+
return typeof container === "function" ? container() : container;
|
|
12
|
+
}
|
|
13
|
+
var DEFAULT_ID = "vuu-portal-root";
|
|
14
|
+
var Portal = ({
|
|
41
15
|
children,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
onRender
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
16
|
+
container: containerProp = document.body,
|
|
17
|
+
id = DEFAULT_ID,
|
|
18
|
+
onRender,
|
|
19
|
+
open = true,
|
|
20
|
+
themeAttributes
|
|
21
|
+
}) => {
|
|
22
|
+
var _a;
|
|
23
|
+
const [mounted, setMounted] = useState(false);
|
|
24
|
+
const portalRef = useRef(null);
|
|
25
|
+
const container = (_a = getContainer(containerProp)) != null ? _a : document.body;
|
|
26
|
+
const [themeClass, densityClass, dataMode] = useThemeAttributes(themeAttributes);
|
|
53
27
|
useLayoutEffect(() => {
|
|
54
|
-
|
|
55
|
-
|
|
28
|
+
const root = document.getElementById(id);
|
|
29
|
+
if (root) {
|
|
30
|
+
portalRef.current = root;
|
|
31
|
+
} else {
|
|
32
|
+
portalRef.current = document.createElement("div");
|
|
33
|
+
portalRef.current.id = id;
|
|
34
|
+
}
|
|
35
|
+
const el = portalRef.current;
|
|
36
|
+
if (!container.contains(el)) {
|
|
37
|
+
container.appendChild(el);
|
|
38
|
+
}
|
|
39
|
+
el.classList.add(themeClass, densityClass);
|
|
40
|
+
el.dataset.mode = dataMode;
|
|
41
|
+
setMounted(true);
|
|
42
|
+
}, [id, container, themeClass, densityClass, dataMode]);
|
|
56
43
|
useLayoutEffect(() => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
}, [renderContainer]);
|
|
44
|
+
requestAnimationFrame(() => {
|
|
45
|
+
onRender == null ? void 0 : onRender();
|
|
46
|
+
});
|
|
47
|
+
}, [onRender]);
|
|
48
|
+
if (open && mounted && portalRef.current && children) {
|
|
49
|
+
return createPortal(children, portalRef.current);
|
|
50
|
+
}
|
|
67
51
|
return null;
|
|
68
52
|
};
|
|
69
53
|
|
|
70
|
-
// src/
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
54
|
+
// src/dialog-header/DialogHeader.tsx
|
|
55
|
+
import { Button, Text } from "@salt-ds/core";
|
|
56
|
+
import cx from "classnames";
|
|
57
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
58
|
+
var classBase = "vuuDialogHeader";
|
|
59
|
+
var DialogHeader = ({
|
|
60
|
+
hideCloseButton = false,
|
|
61
|
+
title,
|
|
62
|
+
onClose,
|
|
63
|
+
...htmlAttributes
|
|
64
|
+
}) => {
|
|
65
|
+
return /* @__PURE__ */ jsxs("div", { ...htmlAttributes, className: cx(classBase, "vuuToolbarProxy"), children: [
|
|
66
|
+
/* @__PURE__ */ jsx(Text, { className: "dialogHeader", children: title }),
|
|
67
|
+
!hideCloseButton && /* @__PURE__ */ jsx(
|
|
68
|
+
Button,
|
|
69
|
+
{
|
|
70
|
+
onClick: onClose,
|
|
71
|
+
"data-align": "end",
|
|
72
|
+
"data-icon": "close",
|
|
73
|
+
variant: "secondary"
|
|
74
|
+
},
|
|
75
|
+
"close"
|
|
76
|
+
)
|
|
77
|
+
] });
|
|
79
78
|
};
|
|
80
79
|
|
|
81
80
|
// src/dialog/Dialog.tsx
|
|
82
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
83
|
-
var
|
|
81
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
82
|
+
var classBase2 = "vuuDialog";
|
|
84
83
|
var Dialog = ({
|
|
85
84
|
children,
|
|
86
85
|
className,
|
|
@@ -90,51 +89,43 @@ var Dialog = ({
|
|
|
90
89
|
hideCloseButton = false,
|
|
91
90
|
...props
|
|
92
91
|
}) => {
|
|
93
|
-
const root =
|
|
94
|
-
const [posX] = useState(0);
|
|
95
|
-
const [posY] = useState(0);
|
|
92
|
+
const root = useRef2(null);
|
|
96
93
|
const close = useCallback(() => {
|
|
97
94
|
onClose == null ? void 0 : onClose();
|
|
98
95
|
}, [onClose]);
|
|
99
|
-
const handleRender = useCallback(() => {
|
|
100
|
-
}, []);
|
|
101
96
|
if (!isOpen) {
|
|
102
97
|
return null;
|
|
103
98
|
}
|
|
104
|
-
return /* @__PURE__ */
|
|
105
|
-
/* @__PURE__ */
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
},
|
|
114
|
-
"close"
|
|
115
|
-
)
|
|
116
|
-
] }),
|
|
99
|
+
return /* @__PURE__ */ jsx2(Portal, { children: /* @__PURE__ */ jsx2(Scrim, { className: `${classBase2}-scrim`, open: isOpen, autoFocusRef: root, children: /* @__PURE__ */ jsxs2("div", { ...props, className: cx2(classBase2, className), ref: root, children: [
|
|
100
|
+
/* @__PURE__ */ jsx2(
|
|
101
|
+
DialogHeader,
|
|
102
|
+
{
|
|
103
|
+
hideCloseButton,
|
|
104
|
+
onClose: close,
|
|
105
|
+
title
|
|
106
|
+
}
|
|
107
|
+
),
|
|
117
108
|
children
|
|
118
109
|
] }) }) });
|
|
119
110
|
};
|
|
120
111
|
|
|
121
112
|
// src/menu/ContextMenu.tsx
|
|
122
|
-
import { useCallback as useCallback5, useRef as
|
|
113
|
+
import { useCallback as useCallback5, useRef as useRef6 } from "react";
|
|
123
114
|
|
|
124
115
|
// src/menu/MenuList.tsx
|
|
125
116
|
import React2, {
|
|
126
117
|
useLayoutEffect as useLayoutEffect2,
|
|
127
|
-
useMemo as
|
|
128
|
-
useRef as
|
|
118
|
+
useMemo as useMemo3,
|
|
119
|
+
useRef as useRef4
|
|
129
120
|
} from "react";
|
|
130
|
-
import
|
|
121
|
+
import cx3 from "classnames";
|
|
131
122
|
import { useId } from "@vuu-ui/vuu-layout";
|
|
132
123
|
|
|
133
124
|
// src/menu/use-keyboard-navigation.ts
|
|
134
125
|
import {
|
|
135
126
|
useCallback as useCallback2,
|
|
136
|
-
useMemo
|
|
137
|
-
useRef as
|
|
127
|
+
useMemo,
|
|
128
|
+
useRef as useRef3,
|
|
138
129
|
useState as useState2
|
|
139
130
|
} from "react";
|
|
140
131
|
|
|
@@ -142,7 +133,7 @@ import {
|
|
|
142
133
|
var isRoot = (el) => el.closest(`[data-root='true']`) !== null;
|
|
143
134
|
var hasPopup = (el, idx) => {
|
|
144
135
|
var _a;
|
|
145
|
-
return el.ariaHasPopup === "true" && ((_a = el.dataset) == null ? void 0 : _a.idx) === `${idx}` || el.querySelector(`:scope > [data-
|
|
136
|
+
return el.ariaHasPopup === "true" && ((_a = el.dataset) == null ? void 0 : _a.idx) === `${idx}` || el.querySelector(`:scope > [data-index='${idx}'][aria-haspopup='true']`) !== null;
|
|
146
137
|
};
|
|
147
138
|
|
|
148
139
|
// src/menu/key-code.ts
|
|
@@ -214,7 +205,7 @@ var useKeyboardNavigation = ({
|
|
|
214
205
|
);
|
|
215
206
|
}
|
|
216
207
|
const controlledHighlighting = isValidNumber(highlightedIndexProp);
|
|
217
|
-
const highlightedIndexRef =
|
|
208
|
+
const highlightedIndexRef = useRef3(
|
|
218
209
|
(_a = defaultHighlightedIdx != null ? defaultHighlightedIdx : highlightedIndexProp) != null ? _a : autoHighlightFirstItem ? 0 : -1
|
|
219
210
|
);
|
|
220
211
|
const [, forceRender] = useState2(null);
|
|
@@ -236,8 +227,8 @@ var useKeyboardNavigation = ({
|
|
|
236
227
|
},
|
|
237
228
|
[controlledHighlighting, setHighlightedIdx]
|
|
238
229
|
);
|
|
239
|
-
const keyBoardNavigation =
|
|
240
|
-
const ignoreFocus =
|
|
230
|
+
const keyBoardNavigation = useRef3(true);
|
|
231
|
+
const ignoreFocus = useRef3(false);
|
|
241
232
|
const setIgnoreFocus = (value) => ignoreFocus.current = value;
|
|
242
233
|
const highlightedIndex = controlledHighlighting ? highlightedIndexProp : highlightedIndexRef.current;
|
|
243
234
|
const navigateChildldItems = useCallback2(
|
|
@@ -259,10 +250,10 @@ var useKeyboardNavigation = ({
|
|
|
259
250
|
} else if ((e.key === "ArrowRight" || e.key === "Enter") && hasPopup(e.target, highlightedIndex)) {
|
|
260
251
|
const menuEl = e.target;
|
|
261
252
|
const menuItemEl = menuEl.querySelector(
|
|
262
|
-
`:scope > [data-
|
|
253
|
+
`:scope > [data-index='${highlightedIndex}']`
|
|
263
254
|
);
|
|
264
255
|
if (menuItemEl) {
|
|
265
|
-
onOpenMenu == null ? void 0 : onOpenMenu(menuItemEl);
|
|
256
|
+
onOpenMenu == null ? void 0 : onOpenMenu(menuItemEl, true);
|
|
266
257
|
}
|
|
267
258
|
} else if (e.key === "ArrowLeft" && !isRoot(e.target)) {
|
|
268
259
|
onCloseMenu(highlightedIndex);
|
|
@@ -282,7 +273,7 @@ var useKeyboardNavigation = ({
|
|
|
282
273
|
onOpenMenu
|
|
283
274
|
]
|
|
284
275
|
);
|
|
285
|
-
const listProps =
|
|
276
|
+
const listProps = useMemo(
|
|
286
277
|
() => ({
|
|
287
278
|
onFocus: () => {
|
|
288
279
|
if (highlightedIndex === -1) {
|
|
@@ -337,7 +328,7 @@ function nextItemIdx(count, key, idx) {
|
|
|
337
328
|
}
|
|
338
329
|
|
|
339
330
|
// src/menu/use-items-with-ids-next.ts
|
|
340
|
-
import React, { useCallback as useCallback3, useMemo as
|
|
331
|
+
import React, { useCallback as useCallback3, useMemo as useMemo2 } from "react";
|
|
341
332
|
var isMenuItemGroup = (child) => child.type === MenuItemGroup || !!child.props["data-group"];
|
|
342
333
|
var getLabelFromChildren = (children) => {
|
|
343
334
|
if (Array.isArray(children) && isMenuItemLabel(children[0])) {
|
|
@@ -394,7 +385,7 @@ var useItemsWithIdsNext = (childrenProp, rootId) => {
|
|
|
394
385
|
};
|
|
395
386
|
return collectChildren(childrenProp);
|
|
396
387
|
}, [rootId, childrenProp]);
|
|
397
|
-
const [menus, actions] =
|
|
388
|
+
const [menus, actions] = useMemo2(
|
|
398
389
|
() => normalizeChildren(),
|
|
399
390
|
[normalizeChildren]
|
|
400
391
|
);
|
|
@@ -402,14 +393,19 @@ var useItemsWithIdsNext = (childrenProp, rootId) => {
|
|
|
402
393
|
};
|
|
403
394
|
|
|
404
395
|
// src/menu/MenuList.tsx
|
|
405
|
-
import { Fragment, jsx as
|
|
406
|
-
var
|
|
407
|
-
var Separator = () => /* @__PURE__ */
|
|
396
|
+
import { Fragment, jsx as jsx3 } from "react/jsx-runtime";
|
|
397
|
+
var classBase3 = "vuuMenuList";
|
|
398
|
+
var Separator = () => /* @__PURE__ */ jsx3("li", { className: "vuuMenuItem-divider" });
|
|
408
399
|
var MenuItemGroup = () => null;
|
|
409
|
-
var MenuItem = ({
|
|
410
|
-
|
|
400
|
+
var MenuItem = ({
|
|
401
|
+
children,
|
|
402
|
+
idx,
|
|
403
|
+
options,
|
|
404
|
+
...props
|
|
405
|
+
}) => {
|
|
406
|
+
return /* @__PURE__ */ jsx3("div", { ...props, children });
|
|
411
407
|
};
|
|
412
|
-
var MenuItemLabel = ({ children }) => /* @__PURE__ */
|
|
408
|
+
var MenuItemLabel = ({ children }) => /* @__PURE__ */ jsx3(Fragment, { children });
|
|
413
409
|
MenuItemLabel.displayName = "MenuItemLabel";
|
|
414
410
|
MenuItem.Label = MenuItemLabel;
|
|
415
411
|
var getDisplayName = (item) => React2.isValidElement(item) && typeof item.type !== "string" && "displayName" in item.type ? item.type.displayName : void 0;
|
|
@@ -428,15 +424,15 @@ var MenuList = ({
|
|
|
428
424
|
onHighlightMenuItem,
|
|
429
425
|
onActivate,
|
|
430
426
|
onCloseMenu,
|
|
431
|
-
onOpenMenu,
|
|
427
|
+
openMenu: onOpenMenu,
|
|
432
428
|
...props
|
|
433
429
|
}) => {
|
|
434
430
|
const id = useId(idProp);
|
|
435
|
-
const root =
|
|
436
|
-
const mapIdxToId =
|
|
431
|
+
const root = useRef4(null);
|
|
432
|
+
const mapIdxToId = useMemo3(() => /* @__PURE__ */ new Map(), []);
|
|
437
433
|
const handleActivate = (idx) => {
|
|
438
434
|
var _a;
|
|
439
|
-
const el = (_a = root.current) == null ? void 0 : _a.querySelector(`:scope > [data-
|
|
435
|
+
const el = (_a = root.current) == null ? void 0 : _a.querySelector(`:scope > [data-index='${idx}']`);
|
|
440
436
|
(el == null ? void 0 : el.id) && (onActivate == null ? void 0 : onActivate(el.id));
|
|
441
437
|
};
|
|
442
438
|
const { focusVisible, highlightedIndex, listProps } = useKeyboardNavigation({
|
|
@@ -462,7 +458,7 @@ var MenuList = ({
|
|
|
462
458
|
role: "menuitem"
|
|
463
459
|
};
|
|
464
460
|
const maybeIcon = (childElement, withIcon, iconName) => withIcon ? [
|
|
465
|
-
/* @__PURE__ */
|
|
461
|
+
/* @__PURE__ */ jsx3(
|
|
466
462
|
"span",
|
|
467
463
|
{
|
|
468
464
|
className: "vuuIconContainer",
|
|
@@ -486,7 +482,7 @@ var MenuList = ({
|
|
|
486
482
|
const subMenuShowing = hasSubMenu && childMenuShowing === itemId;
|
|
487
483
|
const ariaControls = subMenuShowing ? `${id}-${itemId}` : void 0;
|
|
488
484
|
list.push(
|
|
489
|
-
/* @__PURE__ */
|
|
485
|
+
/* @__PURE__ */ jsx3(
|
|
490
486
|
MenuItem,
|
|
491
487
|
{
|
|
492
488
|
...props2,
|
|
@@ -517,14 +513,14 @@ var MenuList = ({
|
|
|
517
513
|
}
|
|
518
514
|
return listItems;
|
|
519
515
|
}
|
|
520
|
-
return /* @__PURE__ */
|
|
516
|
+
return /* @__PURE__ */ jsx3(
|
|
521
517
|
"div",
|
|
522
518
|
{
|
|
523
519
|
...props,
|
|
524
520
|
...listProps,
|
|
525
521
|
"aria-activedescendant": getActiveDescendant(),
|
|
526
|
-
className:
|
|
527
|
-
[`${
|
|
522
|
+
className: cx3(classBase3, className, {
|
|
523
|
+
[`${classBase3}-childMenuShowing`]: childMenuShowing !== void 0
|
|
528
524
|
}),
|
|
529
525
|
"data-root": isRoot2 || void 0,
|
|
530
526
|
id,
|
|
@@ -537,9 +533,9 @@ var MenuList = ({
|
|
|
537
533
|
var getMenuItemProps = (itemId, idx, key, highlightedIdx, focusVisible, className, hasSeparator) => ({
|
|
538
534
|
id: `menuitem-${itemId}`,
|
|
539
535
|
key: key != null ? key : idx,
|
|
540
|
-
"data-
|
|
536
|
+
"data-index": idx,
|
|
541
537
|
"data-highlighted": idx === highlightedIdx || void 0,
|
|
542
|
-
className:
|
|
538
|
+
className: cx3("vuuMenuItem", className, {
|
|
543
539
|
"vuuMenuItem-separator": hasSeparator,
|
|
544
540
|
focusVisible: focusVisible === idx
|
|
545
541
|
})
|
|
@@ -549,13 +545,13 @@ MenuList.displayName = "MenuList";
|
|
|
549
545
|
// src/menu/use-cascade.ts
|
|
550
546
|
import {
|
|
551
547
|
useCallback as useCallback4,
|
|
552
|
-
useMemo as
|
|
553
|
-
useRef as
|
|
548
|
+
useMemo as useMemo4,
|
|
549
|
+
useRef as useRef5,
|
|
554
550
|
useState as useState3
|
|
555
551
|
} from "react";
|
|
556
552
|
|
|
557
553
|
// src/menu/list-dom-utils.ts
|
|
558
|
-
var closestListItem = (el) => el == null ? void 0 : el.closest("[data-
|
|
554
|
+
var closestListItem = (el) => el == null ? void 0 : el.closest("[data-index],[aria-posinset]");
|
|
559
555
|
|
|
560
556
|
// src/menu/use-cascade.ts
|
|
561
557
|
var nudge = (menus, distance, pos) => {
|
|
@@ -588,8 +584,13 @@ var getPosition = (el, openMenus) => {
|
|
|
588
584
|
return { left: left + width, top: top + menuTop };
|
|
589
585
|
};
|
|
590
586
|
var getHostMenuId = (id, rootId) => {
|
|
587
|
+
console.log(`getHostMenuId from ${id} and ${rootId}`);
|
|
591
588
|
const pos = id.lastIndexOf("-");
|
|
592
|
-
|
|
589
|
+
if (id.startsWith("menuitem")) {
|
|
590
|
+
return pos > -1 ? id.slice(9, pos) : rootId;
|
|
591
|
+
} else {
|
|
592
|
+
return pos > -1 ? id.slice(0, pos) : rootId;
|
|
593
|
+
}
|
|
593
594
|
};
|
|
594
595
|
var getTargetMenuId = (id) => id.slice(9);
|
|
595
596
|
var getMenuItemDetails = ({ ariaExpanded, ariaHasPopup, id }, rootId) => {
|
|
@@ -612,7 +613,7 @@ var useCascade = ({
|
|
|
612
613
|
position: { x: posX, y: posY }
|
|
613
614
|
}) => {
|
|
614
615
|
const [, forceRefresh] = useState3({});
|
|
615
|
-
const openMenus =
|
|
616
|
+
const openMenus = useRef5([
|
|
616
617
|
{ id: rootId, left: posX, top: posY }
|
|
617
618
|
]);
|
|
618
619
|
const menuIsOpen = useCallback4(
|
|
@@ -627,17 +628,24 @@ var useCascade = ({
|
|
|
627
628
|
return state;
|
|
628
629
|
}, []);
|
|
629
630
|
const setOpenMenus = useCallback4((menus) => {
|
|
631
|
+
console.log(`setOpenMenus`, {
|
|
632
|
+
menus
|
|
633
|
+
});
|
|
630
634
|
openMenus.current = menus;
|
|
631
635
|
forceRefresh({});
|
|
632
636
|
}, []);
|
|
633
|
-
const menuOpenPendingTimeout =
|
|
634
|
-
const menuClosePendingTimeout =
|
|
635
|
-
const menuState =
|
|
637
|
+
const menuOpenPendingTimeout = useRef5();
|
|
638
|
+
const menuClosePendingTimeout = useRef5();
|
|
639
|
+
const menuState = useRef5({ [rootId]: "no-popup" });
|
|
636
640
|
const openMenu = useCallback4(
|
|
637
641
|
(hostMenuId = rootId, targetMenuId, itemId = null) => {
|
|
642
|
+
console.log(
|
|
643
|
+
`open menu hostMenuId ${hostMenuId} targetMenuId ${targetMenuId} itemId ${itemId}`
|
|
644
|
+
);
|
|
638
645
|
if (hostMenuId === rootId && itemId === null) {
|
|
639
646
|
setOpenMenus([{ id: rootId, left: posX, top: posY }]);
|
|
640
647
|
} else {
|
|
648
|
+
console.log(`openMenu set ${hostMenuId} status to popup-open`);
|
|
641
649
|
menuState.current[hostMenuId] = "popup-open";
|
|
642
650
|
const el = document.getElementById(itemId);
|
|
643
651
|
if (el !== null) {
|
|
@@ -654,7 +662,9 @@ var useCascade = ({
|
|
|
654
662
|
);
|
|
655
663
|
const closeMenu = useCallback4(
|
|
656
664
|
(menuId) => {
|
|
665
|
+
console.log(`closeMenu ${menuId}`);
|
|
657
666
|
if (menuId === rootId) {
|
|
667
|
+
console.log("close child menu of root");
|
|
658
668
|
setOpenMenus([]);
|
|
659
669
|
} else {
|
|
660
670
|
const menus = openMenus.current.slice();
|
|
@@ -664,6 +674,9 @@ var useCascade = ({
|
|
|
664
674
|
if (parentMenu) {
|
|
665
675
|
menuState.current[parentMenu.id] = "no-popup";
|
|
666
676
|
}
|
|
677
|
+
console.log(`closeMenu setOpenMenus`, {
|
|
678
|
+
menus
|
|
679
|
+
});
|
|
667
680
|
setOpenMenus(menus);
|
|
668
681
|
}
|
|
669
682
|
},
|
|
@@ -671,17 +684,27 @@ var useCascade = ({
|
|
|
671
684
|
);
|
|
672
685
|
const closeMenus = useCallback4(
|
|
673
686
|
(menuItemId) => {
|
|
687
|
+
console.log(`closeMenus ${menuItemId}`);
|
|
674
688
|
const menus = openMenus.current.slice();
|
|
675
689
|
const menuItemMenuId = menuItemId.slice(9);
|
|
676
690
|
let { id: lastMenuId } = menus.at(-1);
|
|
677
691
|
while (menus.length > 1 && !menuItemMenuId.startsWith(lastMenuId)) {
|
|
678
692
|
const parentMenuId = getHostMenuId(lastMenuId, rootId);
|
|
693
|
+
console.log(
|
|
694
|
+
`parentMenuId of lastMenuId ${lastMenuId} and rootId ${rootId} is ${parentMenuId}`
|
|
695
|
+
);
|
|
679
696
|
menus.pop();
|
|
697
|
+
console.log(
|
|
698
|
+
`set state to no-popup for ${lastMenuId} and ${parentMenuId}`
|
|
699
|
+
);
|
|
680
700
|
menuState.current[lastMenuId] = "no-popup";
|
|
681
701
|
menuState.current[parentMenuId] = "no-popup";
|
|
682
702
|
({ id: lastMenuId } = menus[menus.length - 1]);
|
|
683
703
|
}
|
|
684
704
|
if (menus.length < openMenus.current.length) {
|
|
705
|
+
console.log(`closeMenus setOpenMenus`, {
|
|
706
|
+
menus
|
|
707
|
+
});
|
|
685
708
|
setOpenMenus(menus);
|
|
686
709
|
}
|
|
687
710
|
},
|
|
@@ -694,14 +717,14 @@ var useCascade = ({
|
|
|
694
717
|
}
|
|
695
718
|
}, []);
|
|
696
719
|
const scheduleOpen = useCallback4(
|
|
697
|
-
(hostMenuId, targetMenuId, menuItemId) => {
|
|
720
|
+
(hostMenuId, targetMenuId, menuItemId, delay = 300) => {
|
|
698
721
|
clearAnyScheduledOpenTasks();
|
|
699
722
|
menuOpenPendingTimeout.current = window.setTimeout(() => {
|
|
700
723
|
closeMenus(menuItemId);
|
|
701
724
|
menuState.current[hostMenuId] = "popup-open";
|
|
702
725
|
menuState.current[targetMenuId] = "no-popup";
|
|
703
726
|
openMenu(hostMenuId, targetMenuId, menuItemId);
|
|
704
|
-
},
|
|
727
|
+
}, delay);
|
|
705
728
|
},
|
|
706
729
|
[clearAnyScheduledOpenTasks, closeMenus, openMenu]
|
|
707
730
|
);
|
|
@@ -716,8 +739,8 @@ var useCascade = ({
|
|
|
716
739
|
);
|
|
717
740
|
const handleRender = useCallback4(() => {
|
|
718
741
|
const { current: menus } = openMenus;
|
|
719
|
-
const
|
|
720
|
-
const el = document.getElementById(menu.id);
|
|
742
|
+
const menu = menus.at(-1);
|
|
743
|
+
const el = menu ? document.getElementById(menu.id) : void 0;
|
|
721
744
|
if (el) {
|
|
722
745
|
const { right, bottom } = el.getBoundingClientRect();
|
|
723
746
|
const { clientHeight, clientWidth } = document.body;
|
|
@@ -732,25 +755,26 @@ var useCascade = ({
|
|
|
732
755
|
el.focus();
|
|
733
756
|
}
|
|
734
757
|
} else {
|
|
735
|
-
console.log(`no element found with if ${menu.id}`);
|
|
758
|
+
console.log(`useCascade no element found with if ${menu == null ? void 0 : menu.id}`);
|
|
736
759
|
}
|
|
737
760
|
}, [rootId, setOpenMenus]);
|
|
738
761
|
const triggerChildMenu = useCallback4(
|
|
739
|
-
(menuItemEl) => {
|
|
762
|
+
(menuItemEl, immediate = false) => {
|
|
740
763
|
const { hostMenuId, targetMenuId, menuItemId, isGroup, isOpen } = getMenuItemDetails(menuItemEl, rootId);
|
|
741
764
|
const {
|
|
742
765
|
current: { [hostMenuId]: state }
|
|
743
766
|
} = menuState;
|
|
767
|
+
const delay = immediate ? 0 : void 0;
|
|
744
768
|
if (state === "no-popup" && isGroup) {
|
|
745
769
|
menuState.current[hostMenuId] = "popup-pending";
|
|
746
|
-
scheduleOpen(hostMenuId, targetMenuId, menuItemId);
|
|
770
|
+
scheduleOpen(hostMenuId, targetMenuId, menuItemId, delay);
|
|
747
771
|
} else if (state === "popup-pending" && !isGroup) {
|
|
748
772
|
menuState.current[hostMenuId] = "no-popup";
|
|
749
773
|
clearTimeout(menuOpenPendingTimeout.current);
|
|
750
774
|
menuOpenPendingTimeout.current = void 0;
|
|
751
775
|
} else if (state === "popup-pending" && isGroup) {
|
|
752
776
|
clearTimeout(menuOpenPendingTimeout.current);
|
|
753
|
-
scheduleOpen(hostMenuId, targetMenuId, menuItemId);
|
|
777
|
+
scheduleOpen(hostMenuId, targetMenuId, menuItemId, delay);
|
|
754
778
|
} else if (state === "popup-open") {
|
|
755
779
|
if (menuIsOpen(targetMenuId)) {
|
|
756
780
|
const menuStatus = getOpenMenuStatus(targetMenuId);
|
|
@@ -766,15 +790,20 @@ var useCascade = ({
|
|
|
766
790
|
}
|
|
767
791
|
} else {
|
|
768
792
|
const [parentOfLastOpenedMenu, lastOpenedMenu] = openMenus.current.slice(-2);
|
|
793
|
+
console.log(`about to check id on `, {
|
|
794
|
+
openMenus,
|
|
795
|
+
parentOfLastOpenedMenu,
|
|
796
|
+
lastOpenedMenu
|
|
797
|
+
});
|
|
769
798
|
if (parentOfLastOpenedMenu.id === hostMenuId && menuState.current[lastOpenedMenu.id] !== "pending-close") {
|
|
770
799
|
scheduleClose(hostMenuId, lastOpenedMenu.id, menuItemId);
|
|
771
800
|
if (isGroup && !isOpen) {
|
|
772
|
-
scheduleOpen(hostMenuId, targetMenuId, menuItemId);
|
|
801
|
+
scheduleOpen(hostMenuId, targetMenuId, menuItemId, delay);
|
|
773
802
|
}
|
|
774
803
|
} else if (parentOfLastOpenedMenu.id === hostMenuId && isGroup && menuItemId !== lastOpenedMenu.id && menuState.current[lastOpenedMenu.id] === "pending-close") {
|
|
775
|
-
scheduleOpen(hostMenuId, targetMenuId, menuItemId);
|
|
804
|
+
scheduleOpen(hostMenuId, targetMenuId, menuItemId, delay);
|
|
776
805
|
} else if (isGroup) {
|
|
777
|
-
scheduleOpen(hostMenuId, targetMenuId, menuItemId);
|
|
806
|
+
scheduleOpen(hostMenuId, targetMenuId, menuItemId, delay);
|
|
778
807
|
} else if (!(menuState.current[lastOpenedMenu.id] === "pending-close")) {
|
|
779
808
|
closeMenus(menuItemId);
|
|
780
809
|
}
|
|
@@ -797,14 +826,16 @@ var useCascade = ({
|
|
|
797
826
|
scheduleOpen
|
|
798
827
|
]
|
|
799
828
|
);
|
|
800
|
-
const listItemProps =
|
|
829
|
+
const listItemProps = useMemo4(
|
|
801
830
|
() => ({
|
|
802
831
|
onMouseEnter: (evt) => {
|
|
803
832
|
const menuItemEl = closestListItem(evt.target);
|
|
833
|
+
console.log(`onMouseEnter ${menuItemEl == null ? void 0 : menuItemEl.id}`);
|
|
804
834
|
triggerChildMenu(menuItemEl);
|
|
805
835
|
onMouseEnterItem(evt, menuItemEl.id);
|
|
806
836
|
},
|
|
807
837
|
onClick: (evt) => {
|
|
838
|
+
console.log("click");
|
|
808
839
|
const listItemEl = closestListItem(evt.target);
|
|
809
840
|
const { isGroup, menuItemId } = getMenuItemDetails(listItemEl, rootId);
|
|
810
841
|
if (isGroup) {
|
|
@@ -827,10 +858,11 @@ var useCascade = ({
|
|
|
827
858
|
|
|
828
859
|
// src/menu/ContextMenu.tsx
|
|
829
860
|
import { useId as useId2 } from "@vuu-ui/vuu-layout";
|
|
830
|
-
import { Fragment as Fragment2, jsx as
|
|
861
|
+
import { Fragment as Fragment2, jsx as jsx4 } from "react/jsx-runtime";
|
|
831
862
|
import { createElement } from "react";
|
|
832
863
|
var noop = () => void 0;
|
|
833
864
|
var ContextMenu = ({
|
|
865
|
+
PortalProps: PortalProps2,
|
|
834
866
|
activatedByKeyboard,
|
|
835
867
|
children: childrenProp,
|
|
836
868
|
className,
|
|
@@ -840,12 +872,12 @@ var ContextMenu = ({
|
|
|
840
872
|
style,
|
|
841
873
|
...menuListProps
|
|
842
874
|
}) => {
|
|
843
|
-
const closeHandlerRef =
|
|
875
|
+
const closeHandlerRef = useRef6(onClose);
|
|
844
876
|
closeHandlerRef.current = onClose;
|
|
845
877
|
const id = useId2(idProp);
|
|
846
|
-
const closeMenuRef =
|
|
878
|
+
const closeMenuRef = useRef6(noop);
|
|
847
879
|
const [menus, actions] = useItemsWithIdsNext(childrenProp, id);
|
|
848
|
-
const navigatingWithKeyboard =
|
|
880
|
+
const navigatingWithKeyboard = useRef6(activatedByKeyboard);
|
|
849
881
|
const handleMouseEnterItem = useCallback5(() => {
|
|
850
882
|
navigatingWithKeyboard.current = false;
|
|
851
883
|
}, []);
|
|
@@ -862,7 +894,13 @@ var ContextMenu = ({
|
|
|
862
894
|
},
|
|
863
895
|
[actions, id, onClose]
|
|
864
896
|
);
|
|
865
|
-
const {
|
|
897
|
+
const {
|
|
898
|
+
closeMenu,
|
|
899
|
+
listItemProps,
|
|
900
|
+
openMenu: onOpenMenu,
|
|
901
|
+
openMenus,
|
|
902
|
+
handleRender
|
|
903
|
+
} = useCascade({
|
|
866
904
|
// FIXME
|
|
867
905
|
id: `${id}`,
|
|
868
906
|
onActivate: handleActivate,
|
|
@@ -885,35 +923,43 @@ var ContextMenu = ({
|
|
|
885
923
|
return id2;
|
|
886
924
|
}
|
|
887
925
|
};
|
|
888
|
-
return /* @__PURE__ */
|
|
926
|
+
return /* @__PURE__ */ jsx4(Fragment2, { children: openMenus.map(({ id: menuId, left, top }, i, all) => {
|
|
889
927
|
const childMenuId = getChildMenuId(i);
|
|
890
|
-
return /* @__PURE__ */
|
|
891
|
-
|
|
928
|
+
return /* @__PURE__ */ createElement(Portal, { ...PortalProps2, key: i, onRender: handleRender }, /* @__PURE__ */ jsx4(
|
|
929
|
+
PopupComponent,
|
|
892
930
|
{
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
931
|
+
anchorElement: { current: document.body },
|
|
932
|
+
placement: "absolute",
|
|
933
|
+
position: { left, top },
|
|
934
|
+
children: /* @__PURE__ */ createElement(
|
|
935
|
+
MenuList,
|
|
936
|
+
{
|
|
937
|
+
...menuListProps,
|
|
938
|
+
activatedByKeyboard: navigatingWithKeyboard.current,
|
|
939
|
+
childMenuShowing: childMenuId,
|
|
940
|
+
className,
|
|
941
|
+
id: menuId,
|
|
942
|
+
isRoot: i === 0,
|
|
943
|
+
key: i,
|
|
944
|
+
listItemProps,
|
|
945
|
+
onActivate: handleActivate,
|
|
946
|
+
onHighlightMenuItem: handleHighlightMenuItem,
|
|
947
|
+
onCloseMenu: handleCloseMenu,
|
|
948
|
+
openMenu: onOpenMenu,
|
|
949
|
+
style,
|
|
950
|
+
tabIndex: i === all.length - 1 ? 0 : void 0
|
|
951
|
+
},
|
|
952
|
+
menus[menuId]
|
|
953
|
+
)
|
|
954
|
+
}
|
|
955
|
+
));
|
|
910
956
|
}) });
|
|
911
957
|
};
|
|
912
958
|
ContextMenu.displayName = "ContextMenu";
|
|
913
959
|
|
|
914
960
|
// src/menu/context-menu-provider.tsx
|
|
915
|
-
import { createContext, useCallback as useCallback6, useMemo as
|
|
916
|
-
import { jsx as
|
|
961
|
+
import { createContext, useCallback as useCallback6, useMemo as useMemo5 } from "react";
|
|
962
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
917
963
|
var ContextMenuContext = createContext(
|
|
918
964
|
null
|
|
919
965
|
);
|
|
@@ -923,7 +969,7 @@ var Provider = ({
|
|
|
923
969
|
menuActionHandler,
|
|
924
970
|
menuBuilder
|
|
925
971
|
}) => {
|
|
926
|
-
const menuBuilders =
|
|
972
|
+
const menuBuilders = useMemo5(() => {
|
|
927
973
|
if ((context == null ? void 0 : context.menuBuilders) && menuBuilder) {
|
|
928
974
|
return context.menuBuilders.concat(menuBuilder);
|
|
929
975
|
} else if (menuBuilder) {
|
|
@@ -944,7 +990,7 @@ var Provider = ({
|
|
|
944
990
|
},
|
|
945
991
|
[context, menuActionHandler]
|
|
946
992
|
);
|
|
947
|
-
return /* @__PURE__ */
|
|
993
|
+
return /* @__PURE__ */ jsx5(
|
|
948
994
|
ContextMenuContext.Provider,
|
|
949
995
|
{
|
|
950
996
|
value: {
|
|
@@ -961,7 +1007,7 @@ var ContextMenuProvider = ({
|
|
|
961
1007
|
menuActionHandler,
|
|
962
1008
|
menuBuilder
|
|
963
1009
|
}) => {
|
|
964
|
-
return /* @__PURE__ */
|
|
1010
|
+
return /* @__PURE__ */ jsx5(ContextMenuContext.Consumer, { children: (parentContext) => /* @__PURE__ */ jsx5(
|
|
965
1011
|
Provider,
|
|
966
1012
|
{
|
|
967
1013
|
context: parentContext,
|
|
@@ -974,19 +1020,43 @@ var ContextMenuProvider = ({
|
|
|
974
1020
|
};
|
|
975
1021
|
|
|
976
1022
|
// src/menu/useContextMenu.tsx
|
|
977
|
-
import { useThemeAttributes as useThemeAttributes3 } from "@vuu-ui/vuu-shell";
|
|
978
1023
|
import { isGroupMenuItemDescriptor } from "@vuu-ui/vuu-utils";
|
|
979
|
-
import
|
|
980
|
-
import { cloneElement, useCallback as useCallback7, useContext } from "react";
|
|
1024
|
+
import { cloneElement, useCallback as useCallback8, useContext, useMemo as useMemo6 } from "react";
|
|
981
1025
|
|
|
982
1026
|
// src/popup/popup-service.ts
|
|
983
1027
|
import cx5 from "classnames";
|
|
984
1028
|
import React3, {
|
|
985
|
-
createElement as createElement2
|
|
986
|
-
useEffect,
|
|
987
|
-
useRef as useRef6
|
|
1029
|
+
createElement as createElement2
|
|
988
1030
|
} from "react";
|
|
989
|
-
import
|
|
1031
|
+
import ReactDOM2 from "react-dom";
|
|
1032
|
+
|
|
1033
|
+
// src/portal-deprecated/render-portal.tsx
|
|
1034
|
+
import * as ReactDOM from "react-dom";
|
|
1035
|
+
import cx4 from "classnames";
|
|
1036
|
+
var containerId = 1;
|
|
1037
|
+
var getPortalContainer = ({
|
|
1038
|
+
className,
|
|
1039
|
+
dataMode,
|
|
1040
|
+
x = 0,
|
|
1041
|
+
y = 0,
|
|
1042
|
+
win = window
|
|
1043
|
+
}) => {
|
|
1044
|
+
const el = win.document.createElement("div");
|
|
1045
|
+
el.className = cx4(`vuuPopup ${containerId++}`, className);
|
|
1046
|
+
el.style.cssText = `left:${x}px; top:${y}px;`;
|
|
1047
|
+
if (dataMode) {
|
|
1048
|
+
el.dataset.mode = dataMode;
|
|
1049
|
+
}
|
|
1050
|
+
win.document.body.appendChild(el);
|
|
1051
|
+
return el;
|
|
1052
|
+
};
|
|
1053
|
+
var createContainer = (props) => getPortalContainer(props);
|
|
1054
|
+
var renderPortal = (component, container, x, y, onRender) => {
|
|
1055
|
+
container.style.cssText = `left:${x}px; top:${y}px;position: absolute;`;
|
|
1056
|
+
ReactDOM.render(component, container, onRender);
|
|
1057
|
+
};
|
|
1058
|
+
|
|
1059
|
+
// src/popup/popup-service.ts
|
|
990
1060
|
var _dialogOpen = false;
|
|
991
1061
|
var _popups = [];
|
|
992
1062
|
var reasonIsMenuAction = (reason) => (reason == null ? void 0 : reason.type) === "menu-action";
|
|
@@ -998,14 +1068,16 @@ function specialKeyHandler(e) {
|
|
|
998
1068
|
} else if (_dialogOpen) {
|
|
999
1069
|
const dialogRoot = document.body.querySelector(".vuuDialog");
|
|
1000
1070
|
if (dialogRoot) {
|
|
1001
|
-
|
|
1071
|
+
ReactDOM2.unmountComponentAtNode(dialogRoot);
|
|
1002
1072
|
}
|
|
1003
1073
|
}
|
|
1004
1074
|
}
|
|
1005
1075
|
}
|
|
1006
1076
|
function outsideClickHandler(e) {
|
|
1007
1077
|
if (_popups.length) {
|
|
1008
|
-
const popupContainers = document.body.querySelectorAll(
|
|
1078
|
+
const popupContainers = document.body.querySelectorAll(
|
|
1079
|
+
".vuuPopup,#vuu-portal-root"
|
|
1080
|
+
);
|
|
1009
1081
|
for (let i = 0; i < popupContainers.length; i++) {
|
|
1010
1082
|
if (popupContainers[i].contains(e.target)) {
|
|
1011
1083
|
return;
|
|
@@ -1020,7 +1092,7 @@ function closeAllPopups(reason) {
|
|
|
1020
1092
|
} else if (_popups.length) {
|
|
1021
1093
|
const popupContainers = document.body.querySelectorAll(".vuuPopup");
|
|
1022
1094
|
for (let i = 0; i < popupContainers.length; i++) {
|
|
1023
|
-
|
|
1095
|
+
ReactDOM2.unmountComponentAtNode(popupContainers[i]);
|
|
1024
1096
|
}
|
|
1025
1097
|
popupClosed("*");
|
|
1026
1098
|
}
|
|
@@ -1062,7 +1134,7 @@ function popupClosed(name) {
|
|
|
1062
1134
|
}
|
|
1063
1135
|
}
|
|
1064
1136
|
}
|
|
1065
|
-
var
|
|
1137
|
+
var PopupComponent2 = ({
|
|
1066
1138
|
children,
|
|
1067
1139
|
position,
|
|
1068
1140
|
style
|
|
@@ -1101,7 +1173,7 @@ var PopupService = class {
|
|
|
1101
1173
|
const style = { width };
|
|
1102
1174
|
renderPortal(
|
|
1103
1175
|
createElement2(
|
|
1104
|
-
|
|
1176
|
+
PopupComponent2,
|
|
1105
1177
|
{ key: incrementingKey++, position, style },
|
|
1106
1178
|
component
|
|
1107
1179
|
),
|
|
@@ -1124,7 +1196,7 @@ var PopupService = class {
|
|
|
1124
1196
|
popupClosed(name);
|
|
1125
1197
|
const popupRoot = document.body.querySelector(`.vuuPopup.${group}`);
|
|
1126
1198
|
if (popupRoot) {
|
|
1127
|
-
|
|
1199
|
+
ReactDOM2.unmountComponentAtNode(popupRoot);
|
|
1128
1200
|
}
|
|
1129
1201
|
}
|
|
1130
1202
|
document.removeEventListener(
|
|
@@ -1166,7 +1238,7 @@ var DialogService = class {
|
|
|
1166
1238
|
const containerEl = ".vuuDialog";
|
|
1167
1239
|
const onClose = dialog.props.onClose;
|
|
1168
1240
|
dialogOpened();
|
|
1169
|
-
|
|
1241
|
+
ReactDOM2.render(
|
|
1170
1242
|
React3.cloneElement(dialog, {
|
|
1171
1243
|
container: containerEl,
|
|
1172
1244
|
onClose: () => {
|
|
@@ -1183,75 +1255,18 @@ var DialogService = class {
|
|
|
1183
1255
|
dialogClosed();
|
|
1184
1256
|
const dialogRoot = document.body.querySelector(".vuuDialog");
|
|
1185
1257
|
if (dialogRoot) {
|
|
1186
|
-
|
|
1258
|
+
ReactDOM2.unmountComponentAtNode(dialogRoot);
|
|
1187
1259
|
}
|
|
1188
1260
|
}
|
|
1189
1261
|
};
|
|
1190
|
-
var Popup = (props) => {
|
|
1191
|
-
const pendingTask = useRef6();
|
|
1192
|
-
const ref = useRef6(null);
|
|
1193
|
-
const show = (props2, boundingClientRect) => {
|
|
1194
|
-
const { name, group, depth, width } = props2;
|
|
1195
|
-
let left;
|
|
1196
|
-
let top;
|
|
1197
|
-
if (pendingTask.current) {
|
|
1198
|
-
window.clearTimeout(pendingTask.current);
|
|
1199
|
-
pendingTask.current = void 0;
|
|
1200
|
-
}
|
|
1201
|
-
if (props2.close === true) {
|
|
1202
|
-
PopupService.hidePopup(void 0, name, group);
|
|
1203
|
-
} else {
|
|
1204
|
-
const { position, children: component } = props2;
|
|
1205
|
-
const {
|
|
1206
|
-
left: targetLeft,
|
|
1207
|
-
top: targetTop,
|
|
1208
|
-
width: clientWidth,
|
|
1209
|
-
bottom: targetBottom
|
|
1210
|
-
} = boundingClientRect;
|
|
1211
|
-
if (position === "below") {
|
|
1212
|
-
left = targetLeft;
|
|
1213
|
-
top = targetBottom;
|
|
1214
|
-
} else if (position === "above") {
|
|
1215
|
-
left = targetLeft;
|
|
1216
|
-
top = targetTop;
|
|
1217
|
-
}
|
|
1218
|
-
pendingTask.current = window.setTimeout(() => {
|
|
1219
|
-
PopupService.showPopup({
|
|
1220
|
-
name,
|
|
1221
|
-
group,
|
|
1222
|
-
depth,
|
|
1223
|
-
position,
|
|
1224
|
-
left,
|
|
1225
|
-
top,
|
|
1226
|
-
width: width || clientWidth,
|
|
1227
|
-
component
|
|
1228
|
-
});
|
|
1229
|
-
}, 10);
|
|
1230
|
-
}
|
|
1231
|
-
};
|
|
1232
|
-
useEffect(() => {
|
|
1233
|
-
if (ref.current) {
|
|
1234
|
-
const el = ref.current.parentElement;
|
|
1235
|
-
const boundingClientRect = el == null ? void 0 : el.getBoundingClientRect();
|
|
1236
|
-
if (boundingClientRect) {
|
|
1237
|
-
show(props, boundingClientRect);
|
|
1238
|
-
}
|
|
1239
|
-
}
|
|
1240
|
-
return () => {
|
|
1241
|
-
PopupService.hidePopup(void 0, props.name, props.group);
|
|
1242
|
-
};
|
|
1243
|
-
}, [props]);
|
|
1244
|
-
return React3.createElement("div", { className: "popup-proxy", ref });
|
|
1245
|
-
};
|
|
1246
1262
|
|
|
1247
1263
|
// src/popup/Popup.tsx
|
|
1248
1264
|
import cx6 from "classnames";
|
|
1249
|
-
import { useThemeAttributes as useThemeAttributes2 } from "@vuu-ui/vuu-shell";
|
|
1250
1265
|
|
|
1251
1266
|
// src/popup/useAnchoredPosition.ts
|
|
1252
|
-
import { useLayoutEffect as useLayoutEffect3, useState as useState4 } from "react";
|
|
1253
|
-
var getPositionRelativeToAnchor = (anchorElement, placement, offsetLeft, offsetTop) => {
|
|
1254
|
-
const { bottom, left, right, top, width } = anchorElement.getBoundingClientRect();
|
|
1267
|
+
import { useCallback as useCallback7, useLayoutEffect as useLayoutEffect3, useRef as useRef7, useState as useState4 } from "react";
|
|
1268
|
+
var getPositionRelativeToAnchor = (anchorElement, placement, offsetLeft, offsetTop, minWidth, dimensions) => {
|
|
1269
|
+
const { bottom, height, left, right, top, width } = anchorElement.getBoundingClientRect();
|
|
1255
1270
|
switch (placement) {
|
|
1256
1271
|
case "below":
|
|
1257
1272
|
return { left: left + offsetLeft, top: bottom + offsetTop };
|
|
@@ -1260,7 +1275,26 @@ var getPositionRelativeToAnchor = (anchorElement, placement, offsetLeft, offsetT
|
|
|
1260
1275
|
case "below-center":
|
|
1261
1276
|
return { left: left + width / 2 + offsetLeft, top: bottom + offsetTop };
|
|
1262
1277
|
case "below-full-width":
|
|
1263
|
-
return {
|
|
1278
|
+
return {
|
|
1279
|
+
left: left + offsetLeft,
|
|
1280
|
+
minWidth,
|
|
1281
|
+
top: bottom + offsetTop,
|
|
1282
|
+
width
|
|
1283
|
+
};
|
|
1284
|
+
case "center":
|
|
1285
|
+
if (dimensions) {
|
|
1286
|
+
return {
|
|
1287
|
+
left: width / 2 - dimensions.width / 2 + offsetLeft,
|
|
1288
|
+
top: height / 2 - dimensions.height / 2 + offsetTop,
|
|
1289
|
+
visibility: "visible"
|
|
1290
|
+
};
|
|
1291
|
+
} else {
|
|
1292
|
+
return {
|
|
1293
|
+
left: width / 2 + offsetLeft,
|
|
1294
|
+
top: height / 2 + offsetTop,
|
|
1295
|
+
visibility: "hidden"
|
|
1296
|
+
};
|
|
1297
|
+
}
|
|
1264
1298
|
default:
|
|
1265
1299
|
throw Error(
|
|
1266
1300
|
"Popup getPositionRelativeToAnchor only supported placement values are below and right"
|
|
@@ -1269,52 +1303,89 @@ var getPositionRelativeToAnchor = (anchorElement, placement, offsetLeft, offsetT
|
|
|
1269
1303
|
};
|
|
1270
1304
|
var useAnchoredPosition = ({
|
|
1271
1305
|
anchorElement,
|
|
1306
|
+
minWidth,
|
|
1272
1307
|
offsetLeft = 0,
|
|
1273
1308
|
offsetTop = 0,
|
|
1274
|
-
placement
|
|
1309
|
+
placement,
|
|
1310
|
+
position: positionProp
|
|
1275
1311
|
}) => {
|
|
1276
|
-
const
|
|
1312
|
+
const popupRef = useRef7(null);
|
|
1313
|
+
const [position, setPosition] = useState4(positionProp);
|
|
1277
1314
|
useLayoutEffect3(() => {
|
|
1278
|
-
if (
|
|
1315
|
+
if (placement === "absolute" && positionProp) {
|
|
1316
|
+
setPosition(positionProp);
|
|
1317
|
+
} else if (anchorElement.current) {
|
|
1318
|
+
const dimensions = popupRef.current === null ? void 0 : popupRef.current.getBoundingClientRect();
|
|
1279
1319
|
const position2 = getPositionRelativeToAnchor(
|
|
1280
1320
|
anchorElement.current,
|
|
1281
1321
|
placement,
|
|
1282
1322
|
offsetLeft,
|
|
1283
|
-
offsetTop
|
|
1323
|
+
offsetTop,
|
|
1324
|
+
minWidth,
|
|
1325
|
+
dimensions
|
|
1284
1326
|
);
|
|
1285
1327
|
setPosition(position2);
|
|
1286
1328
|
}
|
|
1287
|
-
}, [anchorElement, offsetLeft, offsetTop, placement]);
|
|
1288
|
-
|
|
1329
|
+
}, [anchorElement, minWidth, offsetLeft, offsetTop, placement, positionProp]);
|
|
1330
|
+
const popupCallbackRef = useCallback7(
|
|
1331
|
+
(el) => {
|
|
1332
|
+
popupRef.current = el;
|
|
1333
|
+
if (el && placement === "center" && anchorElement.current) {
|
|
1334
|
+
const { height, width } = el.getBoundingClientRect();
|
|
1335
|
+
setPosition(
|
|
1336
|
+
getPositionRelativeToAnchor(
|
|
1337
|
+
anchorElement.current,
|
|
1338
|
+
placement,
|
|
1339
|
+
offsetLeft,
|
|
1340
|
+
offsetTop,
|
|
1341
|
+
void 0,
|
|
1342
|
+
{ height, width }
|
|
1343
|
+
)
|
|
1344
|
+
);
|
|
1345
|
+
}
|
|
1346
|
+
},
|
|
1347
|
+
[anchorElement, offsetLeft, offsetTop, placement]
|
|
1348
|
+
);
|
|
1349
|
+
return {
|
|
1350
|
+
position,
|
|
1351
|
+
popupRef: placement === "center" ? popupCallbackRef : void 0
|
|
1352
|
+
};
|
|
1289
1353
|
};
|
|
1290
1354
|
|
|
1291
1355
|
// src/popup/Popup.tsx
|
|
1292
|
-
import { jsx as
|
|
1293
|
-
var
|
|
1356
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
1357
|
+
var PopupComponent = ({
|
|
1294
1358
|
children,
|
|
1295
1359
|
className,
|
|
1296
1360
|
anchorElement,
|
|
1297
|
-
|
|
1361
|
+
minWidth,
|
|
1362
|
+
placement,
|
|
1363
|
+
position: positionProp
|
|
1298
1364
|
}) => {
|
|
1299
|
-
const
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
style: position,
|
|
1307
|
-
children
|
|
1308
|
-
}
|
|
1309
|
-
);
|
|
1365
|
+
const { popupRef, position } = useAnchoredPosition({
|
|
1366
|
+
anchorElement,
|
|
1367
|
+
minWidth,
|
|
1368
|
+
placement,
|
|
1369
|
+
position: positionProp
|
|
1370
|
+
});
|
|
1371
|
+
return position === void 0 ? null : /* @__PURE__ */ jsx6("div", { className: cx6(`vuuPortal`, className), ref: popupRef, style: position, children });
|
|
1310
1372
|
};
|
|
1311
1373
|
|
|
1312
1374
|
// src/menu/useContextMenu.tsx
|
|
1313
|
-
import {
|
|
1375
|
+
import { useThemeAttributes as useThemeAttributes2 } from "@vuu-ui/vuu-shell";
|
|
1376
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
1314
1377
|
var useContextMenu = (menuBuilder, menuActionHandler) => {
|
|
1315
1378
|
const ctx = useContext(ContextMenuContext);
|
|
1316
|
-
const [themeClass, densityClass, dataMode] =
|
|
1317
|
-
const
|
|
1379
|
+
const [themeClass, densityClass, dataMode] = useThemeAttributes2();
|
|
1380
|
+
const themeAttributes = useMemo6(
|
|
1381
|
+
() => ({
|
|
1382
|
+
themeClass,
|
|
1383
|
+
densityClass,
|
|
1384
|
+
dataMode
|
|
1385
|
+
}),
|
|
1386
|
+
[dataMode, densityClass, themeClass]
|
|
1387
|
+
);
|
|
1388
|
+
const buildMenuOptions = useCallback8(
|
|
1318
1389
|
(menuBuilders, location, options) => {
|
|
1319
1390
|
let results = [];
|
|
1320
1391
|
for (const menuBuilder2 of menuBuilders) {
|
|
@@ -1324,7 +1395,7 @@ var useContextMenu = (menuBuilder, menuActionHandler) => {
|
|
|
1324
1395
|
},
|
|
1325
1396
|
[]
|
|
1326
1397
|
);
|
|
1327
|
-
const handleShowContextMenu =
|
|
1398
|
+
const handleShowContextMenu = useCallback8(
|
|
1328
1399
|
(e, location, { ContextMenuProps: ContextMenuProps2, contextMenu, ...options }) => {
|
|
1329
1400
|
var _a, _b;
|
|
1330
1401
|
(_a = e.stopPropagation) == null ? void 0 : _a.call(e);
|
|
@@ -1360,13 +1431,10 @@ var useContextMenu = (menuBuilder, menuActionHandler) => {
|
|
|
1360
1431
|
};
|
|
1361
1432
|
if (menuItemDescriptors.length && menuHandler) {
|
|
1362
1433
|
showContextMenu(e, menuItemDescriptors, menuHandler, {
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
densityClass
|
|
1368
|
-
),
|
|
1369
|
-
"data-mode": dataMode
|
|
1434
|
+
PortalProps: {
|
|
1435
|
+
themeAttributes
|
|
1436
|
+
},
|
|
1437
|
+
...ContextMenuProps2
|
|
1370
1438
|
});
|
|
1371
1439
|
}
|
|
1372
1440
|
} else {
|
|
@@ -1375,18 +1443,10 @@ var useContextMenu = (menuBuilder, menuActionHandler) => {
|
|
|
1375
1443
|
);
|
|
1376
1444
|
}
|
|
1377
1445
|
},
|
|
1378
|
-
[
|
|
1379
|
-
buildMenuOptions,
|
|
1380
|
-
ctx,
|
|
1381
|
-
dataMode,
|
|
1382
|
-
densityClass,
|
|
1383
|
-
menuActionHandler,
|
|
1384
|
-
menuBuilder,
|
|
1385
|
-
themeClass
|
|
1386
|
-
]
|
|
1446
|
+
[buildMenuOptions, ctx, menuActionHandler, menuBuilder, themeAttributes]
|
|
1387
1447
|
);
|
|
1388
|
-
const hideContextMenu =
|
|
1389
|
-
console.log("hide
|
|
1448
|
+
const hideContextMenu = useCallback8(() => {
|
|
1449
|
+
console.log("hide context menu");
|
|
1390
1450
|
}, []);
|
|
1391
1451
|
return [handleShowContextMenu, hideContextMenu];
|
|
1392
1452
|
};
|
|
@@ -1404,7 +1464,7 @@ var showContextMenu = (e, menuDescriptors, handleContextMenuAction, {
|
|
|
1404
1464
|
...contextMenuProps
|
|
1405
1465
|
} = NO_OPTIONS) => {
|
|
1406
1466
|
const menuItems = (menuDescriptors2) => {
|
|
1407
|
-
const fromDescriptor = (menuItem, i) => isGroupMenuItemDescriptor(menuItem) ? /* @__PURE__ */
|
|
1467
|
+
const fromDescriptor = (menuItem, i) => isGroupMenuItemDescriptor(menuItem) ? /* @__PURE__ */ jsx7(MenuItemGroup, { label: menuItem.label, children: menuItem.children.map(fromDescriptor) }, i) : /* @__PURE__ */ jsx7(
|
|
1408
1468
|
MenuItem,
|
|
1409
1469
|
{
|
|
1410
1470
|
action: menuItem.action,
|
|
@@ -1429,11 +1489,10 @@ var showContextMenu = (e, menuDescriptors, handleContextMenuAction, {
|
|
|
1429
1489
|
x: e.clientX,
|
|
1430
1490
|
y: e.clientY
|
|
1431
1491
|
};
|
|
1432
|
-
const component = /* @__PURE__ */
|
|
1492
|
+
const component = /* @__PURE__ */ jsx7(
|
|
1433
1493
|
ContextMenu,
|
|
1434
1494
|
{
|
|
1435
1495
|
...contextMenuProps,
|
|
1436
|
-
className: "vuuContextMenu",
|
|
1437
1496
|
onClose: handleClose,
|
|
1438
1497
|
position,
|
|
1439
1498
|
children: menuItems(menuDescriptors)
|
|
@@ -1444,15 +1503,15 @@ var showContextMenu = (e, menuDescriptors, handleContextMenuAction, {
|
|
|
1444
1503
|
|
|
1445
1504
|
// src/popup-menu/PopupMenu.tsx
|
|
1446
1505
|
import {
|
|
1447
|
-
useCallback as
|
|
1448
|
-
useRef as
|
|
1506
|
+
useCallback as useCallback9,
|
|
1507
|
+
useRef as useRef8,
|
|
1449
1508
|
useState as useState5
|
|
1450
1509
|
} from "react";
|
|
1451
|
-
import
|
|
1510
|
+
import cx7 from "classnames";
|
|
1452
1511
|
import { Button as Button2 } from "@salt-ds/core";
|
|
1453
1512
|
import { useId as useId3 } from "@vuu-ui/vuu-layout";
|
|
1454
|
-
import { jsx as
|
|
1455
|
-
var
|
|
1513
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
1514
|
+
var classBase4 = "vuuPopupMenu";
|
|
1456
1515
|
var getPosition2 = (element) => {
|
|
1457
1516
|
if (element) {
|
|
1458
1517
|
const { bottom, left } = element.getBoundingClientRect();
|
|
@@ -1472,12 +1531,17 @@ var PopupMenu = ({
|
|
|
1472
1531
|
tabIndex = 0,
|
|
1473
1532
|
...htmlAttributes
|
|
1474
1533
|
}) => {
|
|
1475
|
-
const rootRef =
|
|
1476
|
-
const suppressShowMenuRef =
|
|
1534
|
+
const rootRef = useRef8(null);
|
|
1535
|
+
const suppressShowMenuRef = useRef8(false);
|
|
1477
1536
|
const [menuOpen, setMenuOpen] = useState5(false);
|
|
1478
1537
|
const id = useId3(idProp);
|
|
1479
1538
|
const [showContextMenu2] = useContextMenu(menuBuilder, menuActionHandler);
|
|
1480
|
-
const
|
|
1539
|
+
const handleOpenMenu = useCallback9((el) => {
|
|
1540
|
+
console.log(`menu Open `, {
|
|
1541
|
+
el
|
|
1542
|
+
});
|
|
1543
|
+
}, []);
|
|
1544
|
+
const handleMenuClose = useCallback9(
|
|
1481
1545
|
(reason) => {
|
|
1482
1546
|
setMenuOpen(false);
|
|
1483
1547
|
if (reasonIsClickAway(reason)) {
|
|
@@ -1497,7 +1561,7 @@ var PopupMenu = ({
|
|
|
1497
1561
|
},
|
|
1498
1562
|
[onMenuClose, tabIndex]
|
|
1499
1563
|
);
|
|
1500
|
-
const showMenu =
|
|
1564
|
+
const showMenu = useCallback9(
|
|
1501
1565
|
(e) => {
|
|
1502
1566
|
if (suppressShowMenuRef.current) {
|
|
1503
1567
|
suppressShowMenuRef.current = false;
|
|
@@ -1505,27 +1569,34 @@ var PopupMenu = ({
|
|
|
1505
1569
|
setMenuOpen(true);
|
|
1506
1570
|
showContextMenu2(e, menuLocation, {
|
|
1507
1571
|
ContextMenuProps: {
|
|
1508
|
-
className: "vuuPopupMenuList",
|
|
1509
1572
|
id: `${id}-menu`,
|
|
1510
1573
|
onClose: handleMenuClose,
|
|
1574
|
+
openMenu: handleOpenMenu,
|
|
1511
1575
|
position: getPosition2(rootRef.current)
|
|
1512
1576
|
},
|
|
1513
1577
|
...menuOptions
|
|
1514
1578
|
});
|
|
1515
1579
|
}
|
|
1516
1580
|
},
|
|
1517
|
-
[
|
|
1581
|
+
[
|
|
1582
|
+
handleMenuClose,
|
|
1583
|
+
handleOpenMenu,
|
|
1584
|
+
id,
|
|
1585
|
+
menuLocation,
|
|
1586
|
+
menuOptions,
|
|
1587
|
+
showContextMenu2
|
|
1588
|
+
]
|
|
1518
1589
|
);
|
|
1519
|
-
return /* @__PURE__ */
|
|
1590
|
+
return /* @__PURE__ */ jsx8(
|
|
1520
1591
|
Button2,
|
|
1521
1592
|
{
|
|
1522
1593
|
...htmlAttributes,
|
|
1523
1594
|
"aria-controls": `${id}-menu-root`,
|
|
1524
1595
|
"aria-expanded": menuOpen,
|
|
1525
1596
|
"aria-haspopup": "menu",
|
|
1526
|
-
className:
|
|
1527
|
-
[`${
|
|
1528
|
-
[`${
|
|
1597
|
+
className: cx7(classBase4, className, {
|
|
1598
|
+
[`${classBase4}-withCaption`]: label !== void 0,
|
|
1599
|
+
[`${classBase4}-open`]: menuOpen
|
|
1529
1600
|
}),
|
|
1530
1601
|
"data-icon": icon,
|
|
1531
1602
|
id,
|
|
@@ -1538,54 +1609,13 @@ var PopupMenu = ({
|
|
|
1538
1609
|
);
|
|
1539
1610
|
};
|
|
1540
1611
|
|
|
1541
|
-
// src/portal/Portal.tsx
|
|
1542
|
-
import { useThemeAttributes as useThemeAttributes4 } from "@vuu-ui/vuu-shell";
|
|
1543
|
-
import { useLayoutEffect as useLayoutEffect4, useRef as useRef8, useState as useState6 } from "react";
|
|
1544
|
-
import { createPortal } from "react-dom";
|
|
1545
|
-
function getContainer(container) {
|
|
1546
|
-
return typeof container === "function" ? container() : container;
|
|
1547
|
-
}
|
|
1548
|
-
var DEFAULT_ID = "vuu-portal-root";
|
|
1549
|
-
var Portal2 = ({
|
|
1550
|
-
children,
|
|
1551
|
-
container: containerProp = document.body,
|
|
1552
|
-
id = DEFAULT_ID,
|
|
1553
|
-
open = true
|
|
1554
|
-
}) => {
|
|
1555
|
-
var _a;
|
|
1556
|
-
const [mounted, setMounted] = useState6(false);
|
|
1557
|
-
const portalRef = useRef8(null);
|
|
1558
|
-
const container = (_a = getContainer(containerProp)) != null ? _a : document.body;
|
|
1559
|
-
const [themeClass, densityClass, dataMode] = useThemeAttributes4();
|
|
1560
|
-
useLayoutEffect4(() => {
|
|
1561
|
-
const root = document.getElementById(id);
|
|
1562
|
-
if (root) {
|
|
1563
|
-
portalRef.current = root;
|
|
1564
|
-
} else {
|
|
1565
|
-
portalRef.current = document.createElement("div");
|
|
1566
|
-
portalRef.current.id = id;
|
|
1567
|
-
}
|
|
1568
|
-
const el = portalRef.current;
|
|
1569
|
-
if (!container.contains(el)) {
|
|
1570
|
-
container.appendChild(el);
|
|
1571
|
-
}
|
|
1572
|
-
el.classList.add(themeClass, densityClass);
|
|
1573
|
-
el.dataset.mode = dataMode;
|
|
1574
|
-
setMounted(true);
|
|
1575
|
-
}, [id, container, themeClass, densityClass, dataMode]);
|
|
1576
|
-
if (open && mounted && portalRef.current && children) {
|
|
1577
|
-
return createPortal(children, portalRef.current);
|
|
1578
|
-
}
|
|
1579
|
-
return null;
|
|
1580
|
-
};
|
|
1581
|
-
|
|
1582
1612
|
// src/prompt/Prompt.tsx
|
|
1583
|
-
import { useThemeAttributes as
|
|
1613
|
+
import { useThemeAttributes as useThemeAttributes3 } from "@vuu-ui/vuu-shell";
|
|
1584
1614
|
import { Button as Button3 } from "@salt-ds/core";
|
|
1585
|
-
import
|
|
1586
|
-
import { useLayoutEffect as
|
|
1587
|
-
import { jsx as
|
|
1588
|
-
var
|
|
1615
|
+
import cx8 from "classnames";
|
|
1616
|
+
import { useLayoutEffect as useLayoutEffect4, useRef as useRef9 } from "react";
|
|
1617
|
+
import { jsx as jsx9, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1618
|
+
var classBase5 = "vuuPrompt";
|
|
1589
1619
|
var AnchorBody = { current: document.body };
|
|
1590
1620
|
var EMPTY_PROPS = {};
|
|
1591
1621
|
var Prompt = ({
|
|
@@ -1607,8 +1637,8 @@ var Prompt = ({
|
|
|
1607
1637
|
offsetTop = 0,
|
|
1608
1638
|
placement = "below"
|
|
1609
1639
|
} = PopupProps;
|
|
1610
|
-
const [themeClass, densityClass, dataMode] =
|
|
1611
|
-
const position = useAnchoredPosition({
|
|
1640
|
+
const [themeClass, densityClass, dataMode] = useThemeAttributes3();
|
|
1641
|
+
const { position } = useAnchoredPosition({
|
|
1612
1642
|
anchorElement,
|
|
1613
1643
|
offsetLeft,
|
|
1614
1644
|
offsetTop,
|
|
@@ -1616,7 +1646,7 @@ var Prompt = ({
|
|
|
1616
1646
|
});
|
|
1617
1647
|
const rootRef = useRef9(null);
|
|
1618
1648
|
const confirmRef = useRef9(null);
|
|
1619
|
-
|
|
1649
|
+
useLayoutEffect4(() => {
|
|
1620
1650
|
if (rootRef.current) {
|
|
1621
1651
|
rootRef.current.showModal();
|
|
1622
1652
|
if (confirmRef.current) {
|
|
@@ -1628,20 +1658,20 @@ var Prompt = ({
|
|
|
1628
1658
|
}
|
|
1629
1659
|
}
|
|
1630
1660
|
}, [placement]);
|
|
1631
|
-
return /* @__PURE__ */
|
|
1661
|
+
return /* @__PURE__ */ jsx9(
|
|
1632
1662
|
"dialog",
|
|
1633
1663
|
{
|
|
1634
1664
|
...htmlAttributes,
|
|
1635
|
-
className:
|
|
1665
|
+
className: cx8(classBase5, `${classBase5}-${variant}`, themeClass),
|
|
1636
1666
|
"data-mode": dataMode,
|
|
1637
1667
|
ref: rootRef,
|
|
1638
1668
|
style: { ...style, ...position },
|
|
1639
|
-
children: /* @__PURE__ */
|
|
1640
|
-
/* @__PURE__ */
|
|
1641
|
-
/* @__PURE__ */
|
|
1642
|
-
/* @__PURE__ */
|
|
1643
|
-
/* @__PURE__ */
|
|
1644
|
-
/* @__PURE__ */
|
|
1669
|
+
children: /* @__PURE__ */ jsxs3("form", { className: `${classBase5}-form`, children: [
|
|
1670
|
+
/* @__PURE__ */ jsx9("div", { className: `${classBase5}-header`, "data-icon": icon, children: title }),
|
|
1671
|
+
/* @__PURE__ */ jsx9("div", { className: `${classBase5}-text`, children: text }),
|
|
1672
|
+
/* @__PURE__ */ jsxs3("div", { className: `${classBase5}-buttonBar`, children: [
|
|
1673
|
+
/* @__PURE__ */ jsx9(Button3, { onClick: onCancel, variant: "secondary", children: cancelButtonLabel }),
|
|
1674
|
+
/* @__PURE__ */ jsx9(Button3, { onClick: onConfirm, ref: confirmRef, value: "default", children: confirmButtonLabel })
|
|
1645
1675
|
] })
|
|
1646
1676
|
] })
|
|
1647
1677
|
}
|
|
@@ -1649,7 +1679,7 @@ var Prompt = ({
|
|
|
1649
1679
|
};
|
|
1650
1680
|
|
|
1651
1681
|
// src/tooltip/useAnchoredPosition.ts
|
|
1652
|
-
import { useLayoutEffect as
|
|
1682
|
+
import { useLayoutEffect as useLayoutEffect5, useState as useState6 } from "react";
|
|
1653
1683
|
var getPositionRelativeToAnchor2 = (anchorElement, placement, offsetLeft, offsetTop) => {
|
|
1654
1684
|
const { bottom, height, left, right, top, width } = anchorElement.getBoundingClientRect();
|
|
1655
1685
|
const midX = left + width / 2;
|
|
@@ -1675,8 +1705,8 @@ var useAnchoredPosition2 = ({
|
|
|
1675
1705
|
offsetTop = 0,
|
|
1676
1706
|
placement
|
|
1677
1707
|
}) => {
|
|
1678
|
-
const [position, setPosition] =
|
|
1679
|
-
|
|
1708
|
+
const [position, setPosition] = useState6();
|
|
1709
|
+
useLayoutEffect5(() => {
|
|
1680
1710
|
if (anchorElement.current) {
|
|
1681
1711
|
const position2 = getPositionRelativeToAnchor2(
|
|
1682
1712
|
anchorElement.current,
|
|
@@ -1691,8 +1721,8 @@ var useAnchoredPosition2 = ({
|
|
|
1691
1721
|
};
|
|
1692
1722
|
|
|
1693
1723
|
// src/tooltip/Tooltip.tsx
|
|
1694
|
-
import { jsx as
|
|
1695
|
-
var
|
|
1724
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
1725
|
+
var classBase6 = "vuuTooltip";
|
|
1696
1726
|
var Tooltip = ({
|
|
1697
1727
|
anchorElement,
|
|
1698
1728
|
children,
|
|
@@ -1705,17 +1735,17 @@ var Tooltip = ({
|
|
|
1705
1735
|
if (position === void 0) {
|
|
1706
1736
|
return null;
|
|
1707
1737
|
}
|
|
1708
|
-
return /* @__PURE__ */
|
|
1738
|
+
return /* @__PURE__ */ jsx10(Portal, { children: /* @__PURE__ */ jsx10(
|
|
1709
1739
|
"div",
|
|
1710
1740
|
{
|
|
1711
|
-
className:
|
|
1741
|
+
className: classBase6,
|
|
1712
1742
|
"data-align": placement,
|
|
1713
1743
|
id,
|
|
1714
1744
|
style: position,
|
|
1715
|
-
children: /* @__PURE__ */
|
|
1745
|
+
children: /* @__PURE__ */ jsx10(
|
|
1716
1746
|
"span",
|
|
1717
1747
|
{
|
|
1718
|
-
className: `${
|
|
1748
|
+
className: `${classBase6}-content`,
|
|
1719
1749
|
onMouseEnter,
|
|
1720
1750
|
onMouseLeave,
|
|
1721
1751
|
children
|
|
@@ -1726,7 +1756,7 @@ var Tooltip = ({
|
|
|
1726
1756
|
};
|
|
1727
1757
|
|
|
1728
1758
|
// src/tooltip/useTooltip.ts
|
|
1729
|
-
import { useCallback as
|
|
1759
|
+
import { useCallback as useCallback10, useRef as useRef10, useState as useState7 } from "react";
|
|
1730
1760
|
import { useId as useId4 } from "@vuu-ui/vuu-layout";
|
|
1731
1761
|
var useTooltip = ({
|
|
1732
1762
|
id: idProp,
|
|
@@ -1737,26 +1767,26 @@ var useTooltip = ({
|
|
|
1737
1767
|
const anchorElementRef = useRef10(null);
|
|
1738
1768
|
const mouseEnterTimerRef = useRef10();
|
|
1739
1769
|
const mouseLeaveTimerRef = useRef10();
|
|
1740
|
-
const [tooltipProps, setTooltipProps] =
|
|
1770
|
+
const [tooltipProps, setTooltipProps] = useState7();
|
|
1741
1771
|
const id = useId4(idProp);
|
|
1742
|
-
const escapeListener =
|
|
1772
|
+
const escapeListener = useCallback10((evt) => {
|
|
1743
1773
|
var _a;
|
|
1744
1774
|
if (evt.key === "Escape") {
|
|
1745
1775
|
(_a = hideTooltipRef.current) == null ? void 0 : _a.call(hideTooltipRef);
|
|
1746
1776
|
}
|
|
1747
1777
|
}, []);
|
|
1748
|
-
hideTooltipRef.current =
|
|
1778
|
+
hideTooltipRef.current = useCallback10(() => {
|
|
1749
1779
|
setTooltipProps(void 0);
|
|
1750
1780
|
document.removeEventListener("keydown", escapeListener);
|
|
1751
1781
|
}, [escapeListener]);
|
|
1752
|
-
const handleMouseEnterTooltip =
|
|
1782
|
+
const handleMouseEnterTooltip = useCallback10(() => {
|
|
1753
1783
|
window.clearTimeout(mouseLeaveTimerRef.current);
|
|
1754
1784
|
}, []);
|
|
1755
|
-
const handleMouseLeaveTooltip =
|
|
1785
|
+
const handleMouseLeaveTooltip = useCallback10(() => {
|
|
1756
1786
|
var _a;
|
|
1757
1787
|
(_a = hideTooltipRef.current) == null ? void 0 : _a.call(hideTooltipRef);
|
|
1758
1788
|
}, []);
|
|
1759
|
-
const showTooltip =
|
|
1789
|
+
const showTooltip = useCallback10(() => {
|
|
1760
1790
|
const { current: anchorEl } = anchorElementRef;
|
|
1761
1791
|
if (anchorEl) {
|
|
1762
1792
|
setTooltipProps({
|
|
@@ -1778,7 +1808,7 @@ var useTooltip = ({
|
|
|
1778
1808
|
placement,
|
|
1779
1809
|
tooltipContent
|
|
1780
1810
|
]);
|
|
1781
|
-
const handleMouseEnter =
|
|
1811
|
+
const handleMouseEnter = useCallback10(
|
|
1782
1812
|
(evt) => {
|
|
1783
1813
|
const el = evt.target;
|
|
1784
1814
|
if (el) {
|
|
@@ -1788,7 +1818,7 @@ var useTooltip = ({
|
|
|
1788
1818
|
},
|
|
1789
1819
|
[showTooltip]
|
|
1790
1820
|
);
|
|
1791
|
-
const handleMouseLeave =
|
|
1821
|
+
const handleMouseLeave = useCallback10(() => {
|
|
1792
1822
|
if (anchorElementRef.current)
|
|
1793
1823
|
if (mouseEnterTimerRef.current) {
|
|
1794
1824
|
window.clearTimeout(mouseEnterTimerRef.current);
|
|
@@ -1812,32 +1842,132 @@ var useTooltip = ({
|
|
|
1812
1842
|
tooltipProps
|
|
1813
1843
|
};
|
|
1814
1844
|
};
|
|
1845
|
+
|
|
1846
|
+
// src/notifications/NotificationsProvider.tsx
|
|
1847
|
+
import React4, { useState as useState8, useContext as useContext2, useCallback as useCallback11, useEffect } from "react";
|
|
1848
|
+
import classNames from "classnames";
|
|
1849
|
+
import { getUniqueId } from "@vuu-ui/vuu-utils";
|
|
1850
|
+
import { jsx as jsx11, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1851
|
+
var toastDisplayDuration = 6e3;
|
|
1852
|
+
var horizontalTransitionDuration = 1e3;
|
|
1853
|
+
var verticalTransitionDuration = 300;
|
|
1854
|
+
var toastHeight = 56;
|
|
1855
|
+
var toastWidth = 300;
|
|
1856
|
+
var toastContainerContentGap = 10;
|
|
1857
|
+
var toastContainerLeftPadding = 10;
|
|
1858
|
+
var toastContainerRightPadding = 50;
|
|
1859
|
+
var classBase7 = "vuuToastNotifications";
|
|
1860
|
+
var NotificationLevel = /* @__PURE__ */ ((NotificationLevel2) => {
|
|
1861
|
+
NotificationLevel2["Info"] = "info";
|
|
1862
|
+
NotificationLevel2["Success"] = "success";
|
|
1863
|
+
NotificationLevel2["Warning"] = "warning";
|
|
1864
|
+
NotificationLevel2["Error"] = "error";
|
|
1865
|
+
return NotificationLevel2;
|
|
1866
|
+
})(NotificationLevel || {});
|
|
1867
|
+
var NotificationsContext = React4.createContext({
|
|
1868
|
+
notify: () => "have you forgotten to provide a NotificationProvider?"
|
|
1869
|
+
});
|
|
1870
|
+
var NotificationsProvider = (props) => {
|
|
1871
|
+
const [notifications, setNotifications] = useState8([]);
|
|
1872
|
+
const notify = useCallback11((notification) => {
|
|
1873
|
+
const newNotification = { ...notification, id: getUniqueId() };
|
|
1874
|
+
setNotifications((prev) => [...prev, newNotification]);
|
|
1875
|
+
setTimeout(() => {
|
|
1876
|
+
setNotifications((prev) => prev.filter((n) => n !== newNotification));
|
|
1877
|
+
}, toastDisplayDuration + horizontalTransitionDuration * 2);
|
|
1878
|
+
}, []);
|
|
1879
|
+
return /* @__PURE__ */ jsxs4(NotificationsContext.Provider, { value: { notify }, children: [
|
|
1880
|
+
/* @__PURE__ */ jsx11(
|
|
1881
|
+
"div",
|
|
1882
|
+
{
|
|
1883
|
+
className: `${classBase7}-toastContainer`,
|
|
1884
|
+
style: {
|
|
1885
|
+
width: toastWidth + toastContainerRightPadding + toastContainerLeftPadding
|
|
1886
|
+
},
|
|
1887
|
+
children: notifications.map((notification, i) => /* @__PURE__ */ jsx11(
|
|
1888
|
+
ToastNotification,
|
|
1889
|
+
{
|
|
1890
|
+
top: (toastHeight + toastContainerContentGap) * i,
|
|
1891
|
+
notification
|
|
1892
|
+
},
|
|
1893
|
+
notification.id
|
|
1894
|
+
))
|
|
1895
|
+
}
|
|
1896
|
+
),
|
|
1897
|
+
props.children
|
|
1898
|
+
] });
|
|
1899
|
+
};
|
|
1900
|
+
var useNotifications = () => useContext2(NotificationsContext);
|
|
1901
|
+
var ToastNotification = (props) => {
|
|
1902
|
+
const { top, notification, animated = true } = props;
|
|
1903
|
+
const [right, setRight] = useState8(-toastWidth - toastContainerRightPadding);
|
|
1904
|
+
useEffect(() => {
|
|
1905
|
+
setRight(toastContainerRightPadding);
|
|
1906
|
+
if (animated) {
|
|
1907
|
+
setTimeout(
|
|
1908
|
+
() => setRight(-toastWidth - toastContainerRightPadding),
|
|
1909
|
+
toastDisplayDuration + horizontalTransitionDuration
|
|
1910
|
+
);
|
|
1911
|
+
}
|
|
1912
|
+
}, [animated]);
|
|
1913
|
+
return /* @__PURE__ */ jsxs4(
|
|
1914
|
+
"div",
|
|
1915
|
+
{
|
|
1916
|
+
className: classNames(`${classBase7}-toast`, notification.type),
|
|
1917
|
+
style: {
|
|
1918
|
+
height: toastHeight,
|
|
1919
|
+
right,
|
|
1920
|
+
width: toastWidth,
|
|
1921
|
+
top,
|
|
1922
|
+
transition: animated ? `right ${horizontalTransitionDuration}ms, top ${verticalTransitionDuration}ms ` : "none"
|
|
1923
|
+
},
|
|
1924
|
+
children: [
|
|
1925
|
+
/* @__PURE__ */ jsx11(
|
|
1926
|
+
"div",
|
|
1927
|
+
{
|
|
1928
|
+
className: classNames(
|
|
1929
|
+
`${classBase7}-toastIcon`,
|
|
1930
|
+
`${notification.type}-icon`
|
|
1931
|
+
)
|
|
1932
|
+
}
|
|
1933
|
+
),
|
|
1934
|
+
/* @__PURE__ */ jsxs4("div", { className: `${classBase7}-toastContent`, children: [
|
|
1935
|
+
/* @__PURE__ */ jsx11("strong", { className: `${classBase7}-toastHeader`, children: notification.header }),
|
|
1936
|
+
/* @__PURE__ */ jsx11("div", { children: notification.body })
|
|
1937
|
+
] })
|
|
1938
|
+
]
|
|
1939
|
+
}
|
|
1940
|
+
);
|
|
1941
|
+
};
|
|
1815
1942
|
export {
|
|
1816
1943
|
ContextMenu,
|
|
1817
1944
|
ContextMenuContext,
|
|
1818
1945
|
ContextMenuProvider,
|
|
1819
1946
|
Dialog,
|
|
1947
|
+
DialogHeader,
|
|
1820
1948
|
DialogService,
|
|
1821
1949
|
MenuItem,
|
|
1822
1950
|
MenuItemGroup,
|
|
1823
1951
|
MenuList,
|
|
1824
|
-
|
|
1825
|
-
|
|
1952
|
+
NotificationLevel,
|
|
1953
|
+
NotificationsContext,
|
|
1954
|
+
NotificationsProvider,
|
|
1955
|
+
PopupComponent,
|
|
1826
1956
|
PopupMenu,
|
|
1827
1957
|
PopupService,
|
|
1828
|
-
|
|
1829
|
-
PortalDeprecated,
|
|
1958
|
+
Portal,
|
|
1830
1959
|
Prompt,
|
|
1831
1960
|
Separator,
|
|
1961
|
+
ToastNotification,
|
|
1832
1962
|
Tooltip,
|
|
1833
1963
|
createContainer,
|
|
1834
|
-
installTheme,
|
|
1835
1964
|
isMenuItemLabel,
|
|
1836
1965
|
reasonIsClickAway,
|
|
1837
1966
|
reasonIsMenuAction,
|
|
1838
1967
|
renderPortal,
|
|
1839
1968
|
useAnchoredPosition,
|
|
1840
1969
|
useContextMenu,
|
|
1970
|
+
useNotifications,
|
|
1841
1971
|
useTooltip
|
|
1842
1972
|
};
|
|
1843
1973
|
//# sourceMappingURL=index.js.map
|