@vuu-ui/vuu-popups 0.8.23-debug → 0.8.24-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 +99 -36
- package/cjs/index.js.map +4 -4
- package/esm/index.js +106 -43
- package/esm/index.js.map +4 -4
- package/index.css +1 -28
- package/index.css.map +2 -2
- package/package.json +6 -6
- package/types/popup-menu/PopupMenu.d.ts +4 -1
- package/types/popup-menu/usePopupMenu.d.ts +19 -0
package/esm/index.js
CHANGED
|
@@ -281,7 +281,6 @@ import { useCallback, useLayoutEffect, useRef, useState } from "react";
|
|
|
281
281
|
// src/popup/getPositionRelativeToAnchor.ts
|
|
282
282
|
var getPositionRelativeToAnchor = (anchorElement, placement, offsetLeft, offsetTop, minWidth, dimensions) => {
|
|
283
283
|
const { bottom, height, left, right, top, width } = anchorElement.getBoundingClientRect();
|
|
284
|
-
console.log({ top });
|
|
285
284
|
switch (placement) {
|
|
286
285
|
case "below":
|
|
287
286
|
return { left: left + offsetLeft, top: bottom + offsetTop };
|
|
@@ -1577,38 +1576,33 @@ var showContextMenu = (e, menuDescriptors, handleContextMenuAction, {
|
|
|
1577
1576
|
};
|
|
1578
1577
|
|
|
1579
1578
|
// src/popup-menu/PopupMenu.tsx
|
|
1579
|
+
import { Icon, IconButton } from "@vuu-ui/vuu-ui-controls";
|
|
1580
1580
|
import { useId as useId3 } from "@vuu-ui/vuu-utils";
|
|
1581
1581
|
import { Button as Button2 } from "@salt-ds/core";
|
|
1582
1582
|
import cx7 from "clsx";
|
|
1583
|
+
|
|
1584
|
+
// src/popup-menu/usePopupMenu.ts
|
|
1583
1585
|
import {
|
|
1584
1586
|
useCallback as useCallback10,
|
|
1585
1587
|
useRef as useRef8,
|
|
1586
1588
|
useState as useState6
|
|
1587
1589
|
} from "react";
|
|
1588
|
-
|
|
1589
|
-
var classBase4 = "vuuPopupMenu";
|
|
1590
|
-
var PopupMenu = ({
|
|
1590
|
+
var usePopupMenu = ({
|
|
1591
1591
|
anchorElement,
|
|
1592
|
-
|
|
1593
|
-
label,
|
|
1594
|
-
icon = label ? "chevron-down" : "more-vert",
|
|
1595
|
-
id: idProp,
|
|
1592
|
+
id,
|
|
1596
1593
|
menuActionHandler,
|
|
1597
1594
|
menuBuilder,
|
|
1598
1595
|
menuClassName,
|
|
1599
|
-
menuLocation
|
|
1596
|
+
menuLocation,
|
|
1600
1597
|
menuOptions,
|
|
1601
1598
|
onMenuClose,
|
|
1602
1599
|
onMenuOpen,
|
|
1603
|
-
popupPlacement
|
|
1604
|
-
tabIndex
|
|
1605
|
-
...htmlAttributes
|
|
1600
|
+
popupPlacement,
|
|
1601
|
+
tabIndex
|
|
1606
1602
|
}) => {
|
|
1607
|
-
const rootRef = useRef8(null);
|
|
1608
|
-
const suppressShowMenuRef = useRef8(false);
|
|
1609
1603
|
const [menuOpen, _setMenuOpen] = useState6(false);
|
|
1610
|
-
const
|
|
1611
|
-
const
|
|
1604
|
+
const suppressShowMenuRef = useRef8(false);
|
|
1605
|
+
const rootRef = useRef8(null);
|
|
1612
1606
|
const setMenuOpen = useCallback10(
|
|
1613
1607
|
(isOpen) => {
|
|
1614
1608
|
_setMenuOpen(isOpen);
|
|
@@ -1618,6 +1612,7 @@ var PopupMenu = ({
|
|
|
1618
1612
|
},
|
|
1619
1613
|
[onMenuOpen]
|
|
1620
1614
|
);
|
|
1615
|
+
const [showContextMenu2] = useContextMenu(menuBuilder, menuActionHandler);
|
|
1621
1616
|
const handleOpenMenu = useCallback10((el) => {
|
|
1622
1617
|
console.log(`menu Open `, {
|
|
1623
1618
|
el
|
|
@@ -1689,26 +1684,94 @@ var PopupMenu = ({
|
|
|
1689
1684
|
showContextMenu2
|
|
1690
1685
|
]
|
|
1691
1686
|
);
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1687
|
+
const ariaAttributes = {
|
|
1688
|
+
"aria-controls": menuOpen ? `${id}-menu` : void 0,
|
|
1689
|
+
"aria-expanded": menuOpen,
|
|
1690
|
+
"aria-haspopup": "menu"
|
|
1691
|
+
};
|
|
1692
|
+
const buttonProps = {
|
|
1693
|
+
id,
|
|
1694
|
+
onClick: showMenu,
|
|
1695
|
+
tabIndex
|
|
1696
|
+
};
|
|
1697
|
+
return { ariaAttributes, buttonProps, menuOpen, rootRef };
|
|
1698
|
+
};
|
|
1699
|
+
|
|
1700
|
+
// src/popup-menu/PopupMenu.tsx
|
|
1701
|
+
import { jsx as jsx9, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1702
|
+
var classBase4 = "vuuPopupMenu";
|
|
1703
|
+
var PopupMenu = ({
|
|
1704
|
+
anchorElement,
|
|
1705
|
+
className,
|
|
1706
|
+
disabled = false,
|
|
1707
|
+
label,
|
|
1708
|
+
icon = label ? "chevron-down" : "more-vert",
|
|
1709
|
+
id: idProp,
|
|
1710
|
+
menuActionHandler,
|
|
1711
|
+
menuBuilder,
|
|
1712
|
+
menuClassName,
|
|
1713
|
+
menuLocation = "header",
|
|
1714
|
+
menuOptions,
|
|
1715
|
+
onMenuClose,
|
|
1716
|
+
onMenuOpen,
|
|
1717
|
+
popupPlacement = "below-right",
|
|
1718
|
+
tabIndex = 0,
|
|
1719
|
+
variant = "secondary",
|
|
1720
|
+
...htmlAttributes
|
|
1721
|
+
}) => {
|
|
1722
|
+
const id = useId3(idProp);
|
|
1723
|
+
const { ariaAttributes, buttonProps, menuOpen, rootRef } = usePopupMenu({
|
|
1724
|
+
anchorElement,
|
|
1725
|
+
id,
|
|
1726
|
+
menuActionHandler,
|
|
1727
|
+
menuBuilder,
|
|
1728
|
+
menuClassName,
|
|
1729
|
+
menuLocation,
|
|
1730
|
+
onMenuClose,
|
|
1731
|
+
onMenuOpen,
|
|
1732
|
+
menuOptions,
|
|
1733
|
+
popupPlacement,
|
|
1734
|
+
tabIndex
|
|
1735
|
+
});
|
|
1736
|
+
if (label) {
|
|
1737
|
+
return /* @__PURE__ */ jsxs3(
|
|
1738
|
+
Button2,
|
|
1739
|
+
{
|
|
1740
|
+
...htmlAttributes,
|
|
1741
|
+
...ariaAttributes,
|
|
1742
|
+
...buttonProps,
|
|
1743
|
+
className: cx7(classBase4, className, `${classBase4}-withCaption`, {
|
|
1744
|
+
"saltButton-active": menuOpen
|
|
1745
|
+
}),
|
|
1746
|
+
disabled,
|
|
1747
|
+
ref: rootRef,
|
|
1748
|
+
variant: "secondary",
|
|
1749
|
+
children: [
|
|
1750
|
+
icon ? /* @__PURE__ */ jsx9(Icon, { name: icon }) : null,
|
|
1751
|
+
label
|
|
1752
|
+
]
|
|
1753
|
+
}
|
|
1754
|
+
);
|
|
1755
|
+
} else if (icon) {
|
|
1756
|
+
return /* @__PURE__ */ jsx9(
|
|
1757
|
+
IconButton,
|
|
1758
|
+
{
|
|
1759
|
+
...htmlAttributes,
|
|
1760
|
+
...ariaAttributes,
|
|
1761
|
+
...buttonProps,
|
|
1762
|
+
className: cx7(classBase4, className, {
|
|
1763
|
+
"saltButton-active": menuOpen
|
|
1764
|
+
}),
|
|
1765
|
+
disabled,
|
|
1766
|
+
icon,
|
|
1767
|
+
ref: rootRef,
|
|
1768
|
+
variant
|
|
1769
|
+
}
|
|
1770
|
+
);
|
|
1771
|
+
} else {
|
|
1772
|
+
console.error("PopupMenu must have a label or an icon (or both)");
|
|
1773
|
+
return null;
|
|
1774
|
+
}
|
|
1712
1775
|
};
|
|
1713
1776
|
|
|
1714
1777
|
// src/prompt/Prompt.tsx
|
|
@@ -1716,7 +1779,7 @@ import { useThemeAttributes as useThemeAttributes4 } from "@vuu-ui/vuu-utils";
|
|
|
1716
1779
|
import { Button as Button3 } from "@salt-ds/core";
|
|
1717
1780
|
import cx8 from "clsx";
|
|
1718
1781
|
import { useLayoutEffect as useLayoutEffect5, useRef as useRef9 } from "react";
|
|
1719
|
-
import { jsx as jsx10, jsxs as
|
|
1782
|
+
import { jsx as jsx10, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1720
1783
|
var classBase5 = "vuuPrompt";
|
|
1721
1784
|
var AnchorBody2 = { current: document.body };
|
|
1722
1785
|
var EMPTY_PROPS2 = {};
|
|
@@ -1768,10 +1831,10 @@ var Prompt = ({
|
|
|
1768
1831
|
"data-mode": dataMode,
|
|
1769
1832
|
ref: rootRef,
|
|
1770
1833
|
style: { ...style, ...position },
|
|
1771
|
-
children: /* @__PURE__ */
|
|
1834
|
+
children: /* @__PURE__ */ jsxs4("form", { className: `${classBase5}-form`, children: [
|
|
1772
1835
|
/* @__PURE__ */ jsx10("div", { className: `${classBase5}-header`, "data-icon": icon, children: title }),
|
|
1773
1836
|
/* @__PURE__ */ jsx10("div", { className: `${classBase5}-text`, children: text }),
|
|
1774
|
-
/* @__PURE__ */
|
|
1837
|
+
/* @__PURE__ */ jsxs4("div", { className: `${classBase5}-buttonBar`, children: [
|
|
1775
1838
|
/* @__PURE__ */ jsx10(Button3, { onClick: onCancel, variant: "secondary", children: cancelButtonLabel }),
|
|
1776
1839
|
/* @__PURE__ */ jsx10(Button3, { onClick: onConfirm, ref: confirmRef, value: "default", children: confirmButtonLabel })
|
|
1777
1840
|
] })
|
|
@@ -1954,7 +2017,7 @@ var useTooltip = ({
|
|
|
1954
2017
|
import React4, { useState as useState9, useContext as useContext2, useCallback as useCallback12, useEffect } from "react";
|
|
1955
2018
|
import classNames from "clsx";
|
|
1956
2019
|
import { getUniqueId } from "@vuu-ui/vuu-utils";
|
|
1957
|
-
import { jsx as jsx12, jsxs as
|
|
2020
|
+
import { jsx as jsx12, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1958
2021
|
var toastOffsetTop = 60;
|
|
1959
2022
|
var toastDisplayDuration = 6e3;
|
|
1960
2023
|
var horizontalTransitionDuration = 1e3;
|
|
@@ -1984,7 +2047,7 @@ var NotificationsProvider = (props) => {
|
|
|
1984
2047
|
setNotifications((prev) => prev.filter((n) => n !== newNotification));
|
|
1985
2048
|
}, toastDisplayDuration + horizontalTransitionDuration * 2);
|
|
1986
2049
|
}, []);
|
|
1987
|
-
return /* @__PURE__ */
|
|
2050
|
+
return /* @__PURE__ */ jsxs5(NotificationsContext.Provider, { value: { notify }, children: [
|
|
1988
2051
|
/* @__PURE__ */ jsx12(
|
|
1989
2052
|
"div",
|
|
1990
2053
|
{
|
|
@@ -2017,7 +2080,7 @@ var ToastNotification = (props) => {
|
|
|
2017
2080
|
);
|
|
2018
2081
|
}
|
|
2019
2082
|
}, [animated]);
|
|
2020
|
-
return /* @__PURE__ */ jsx12(Portal, { children: /* @__PURE__ */
|
|
2083
|
+
return /* @__PURE__ */ jsx12(Portal, { children: /* @__PURE__ */ jsxs5(
|
|
2021
2084
|
"div",
|
|
2022
2085
|
{
|
|
2023
2086
|
className: classNames(`${classBase7}-toast`, notification.type),
|
|
@@ -2038,7 +2101,7 @@ var ToastNotification = (props) => {
|
|
|
2038
2101
|
)
|
|
2039
2102
|
}
|
|
2040
2103
|
),
|
|
2041
|
-
/* @__PURE__ */
|
|
2104
|
+
/* @__PURE__ */ jsxs5("div", { className: `${classBase7}-toastContent`, children: [
|
|
2042
2105
|
/* @__PURE__ */ jsx12("strong", { className: `${classBase7}-toastHeader`, children: notification.header }),
|
|
2043
2106
|
/* @__PURE__ */ jsx12("div", { children: notification.body })
|
|
2044
2107
|
] })
|