@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/cjs/index.js
CHANGED
|
@@ -344,7 +344,6 @@ var import_react2 = require("react");
|
|
|
344
344
|
// src/popup/getPositionRelativeToAnchor.ts
|
|
345
345
|
var getPositionRelativeToAnchor = (anchorElement, placement, offsetLeft, offsetTop, minWidth, dimensions) => {
|
|
346
346
|
const { bottom, height, left, right, top, width } = anchorElement.getBoundingClientRect();
|
|
347
|
-
console.log({ top });
|
|
348
347
|
switch (placement) {
|
|
349
348
|
case "below":
|
|
350
349
|
return { left: left + offsetLeft, top: bottom + offsetTop };
|
|
@@ -1623,34 +1622,29 @@ var showContextMenu = (e, menuDescriptors, handleContextMenuAction, {
|
|
|
1623
1622
|
};
|
|
1624
1623
|
|
|
1625
1624
|
// src/popup-menu/PopupMenu.tsx
|
|
1625
|
+
var import_vuu_ui_controls = require("@vuu-ui/vuu-ui-controls");
|
|
1626
1626
|
var import_vuu_utils7 = require("@vuu-ui/vuu-utils");
|
|
1627
1627
|
var import_core2 = require("@salt-ds/core");
|
|
1628
1628
|
var import_clsx7 = __toESM(require("clsx"));
|
|
1629
|
+
|
|
1630
|
+
// src/popup-menu/usePopupMenu.ts
|
|
1629
1631
|
var import_react14 = require("react");
|
|
1630
|
-
var
|
|
1631
|
-
var classBase4 = "vuuPopupMenu";
|
|
1632
|
-
var PopupMenu = ({
|
|
1632
|
+
var usePopupMenu = ({
|
|
1633
1633
|
anchorElement,
|
|
1634
|
-
|
|
1635
|
-
label,
|
|
1636
|
-
icon = label ? "chevron-down" : "more-vert",
|
|
1637
|
-
id: idProp,
|
|
1634
|
+
id,
|
|
1638
1635
|
menuActionHandler,
|
|
1639
1636
|
menuBuilder,
|
|
1640
1637
|
menuClassName,
|
|
1641
|
-
menuLocation
|
|
1638
|
+
menuLocation,
|
|
1642
1639
|
menuOptions,
|
|
1643
1640
|
onMenuClose,
|
|
1644
1641
|
onMenuOpen,
|
|
1645
|
-
popupPlacement
|
|
1646
|
-
tabIndex
|
|
1647
|
-
...htmlAttributes
|
|
1642
|
+
popupPlacement,
|
|
1643
|
+
tabIndex
|
|
1648
1644
|
}) => {
|
|
1649
|
-
const rootRef = (0, import_react14.useRef)(null);
|
|
1650
|
-
const suppressShowMenuRef = (0, import_react14.useRef)(false);
|
|
1651
1645
|
const [menuOpen, _setMenuOpen] = (0, import_react14.useState)(false);
|
|
1652
|
-
const
|
|
1653
|
-
const
|
|
1646
|
+
const suppressShowMenuRef = (0, import_react14.useRef)(false);
|
|
1647
|
+
const rootRef = (0, import_react14.useRef)(null);
|
|
1654
1648
|
const setMenuOpen = (0, import_react14.useCallback)(
|
|
1655
1649
|
(isOpen) => {
|
|
1656
1650
|
_setMenuOpen(isOpen);
|
|
@@ -1660,6 +1654,7 @@ var PopupMenu = ({
|
|
|
1660
1654
|
},
|
|
1661
1655
|
[onMenuOpen]
|
|
1662
1656
|
);
|
|
1657
|
+
const [showContextMenu2] = useContextMenu(menuBuilder, menuActionHandler);
|
|
1663
1658
|
const handleOpenMenu = (0, import_react14.useCallback)((el) => {
|
|
1664
1659
|
console.log(`menu Open `, {
|
|
1665
1660
|
el
|
|
@@ -1731,26 +1726,94 @@ var PopupMenu = ({
|
|
|
1731
1726
|
showContextMenu2
|
|
1732
1727
|
]
|
|
1733
1728
|
);
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1729
|
+
const ariaAttributes = {
|
|
1730
|
+
"aria-controls": menuOpen ? `${id}-menu` : void 0,
|
|
1731
|
+
"aria-expanded": menuOpen,
|
|
1732
|
+
"aria-haspopup": "menu"
|
|
1733
|
+
};
|
|
1734
|
+
const buttonProps = {
|
|
1735
|
+
id,
|
|
1736
|
+
onClick: showMenu,
|
|
1737
|
+
tabIndex
|
|
1738
|
+
};
|
|
1739
|
+
return { ariaAttributes, buttonProps, menuOpen, rootRef };
|
|
1740
|
+
};
|
|
1741
|
+
|
|
1742
|
+
// src/popup-menu/PopupMenu.tsx
|
|
1743
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1744
|
+
var classBase4 = "vuuPopupMenu";
|
|
1745
|
+
var PopupMenu = ({
|
|
1746
|
+
anchorElement,
|
|
1747
|
+
className,
|
|
1748
|
+
disabled = false,
|
|
1749
|
+
label,
|
|
1750
|
+
icon = label ? "chevron-down" : "more-vert",
|
|
1751
|
+
id: idProp,
|
|
1752
|
+
menuActionHandler,
|
|
1753
|
+
menuBuilder,
|
|
1754
|
+
menuClassName,
|
|
1755
|
+
menuLocation = "header",
|
|
1756
|
+
menuOptions,
|
|
1757
|
+
onMenuClose,
|
|
1758
|
+
onMenuOpen,
|
|
1759
|
+
popupPlacement = "below-right",
|
|
1760
|
+
tabIndex = 0,
|
|
1761
|
+
variant = "secondary",
|
|
1762
|
+
...htmlAttributes
|
|
1763
|
+
}) => {
|
|
1764
|
+
const id = (0, import_vuu_utils7.useId)(idProp);
|
|
1765
|
+
const { ariaAttributes, buttonProps, menuOpen, rootRef } = usePopupMenu({
|
|
1766
|
+
anchorElement,
|
|
1767
|
+
id,
|
|
1768
|
+
menuActionHandler,
|
|
1769
|
+
menuBuilder,
|
|
1770
|
+
menuClassName,
|
|
1771
|
+
menuLocation,
|
|
1772
|
+
onMenuClose,
|
|
1773
|
+
onMenuOpen,
|
|
1774
|
+
menuOptions,
|
|
1775
|
+
popupPlacement,
|
|
1776
|
+
tabIndex
|
|
1777
|
+
});
|
|
1778
|
+
if (label) {
|
|
1779
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1780
|
+
import_core2.Button,
|
|
1781
|
+
{
|
|
1782
|
+
...htmlAttributes,
|
|
1783
|
+
...ariaAttributes,
|
|
1784
|
+
...buttonProps,
|
|
1785
|
+
className: (0, import_clsx7.default)(classBase4, className, `${classBase4}-withCaption`, {
|
|
1786
|
+
"saltButton-active": menuOpen
|
|
1787
|
+
}),
|
|
1788
|
+
disabled,
|
|
1789
|
+
ref: rootRef,
|
|
1790
|
+
variant: "secondary",
|
|
1791
|
+
children: [
|
|
1792
|
+
icon ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_vuu_ui_controls.Icon, { name: icon }) : null,
|
|
1793
|
+
label
|
|
1794
|
+
]
|
|
1795
|
+
}
|
|
1796
|
+
);
|
|
1797
|
+
} else if (icon) {
|
|
1798
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1799
|
+
import_vuu_ui_controls.IconButton,
|
|
1800
|
+
{
|
|
1801
|
+
...htmlAttributes,
|
|
1802
|
+
...ariaAttributes,
|
|
1803
|
+
...buttonProps,
|
|
1804
|
+
className: (0, import_clsx7.default)(classBase4, className, {
|
|
1805
|
+
"saltButton-active": menuOpen
|
|
1806
|
+
}),
|
|
1807
|
+
disabled,
|
|
1808
|
+
icon,
|
|
1809
|
+
ref: rootRef,
|
|
1810
|
+
variant
|
|
1811
|
+
}
|
|
1812
|
+
);
|
|
1813
|
+
} else {
|
|
1814
|
+
console.error("PopupMenu must have a label or an icon (or both)");
|
|
1815
|
+
return null;
|
|
1816
|
+
}
|
|
1754
1817
|
};
|
|
1755
1818
|
|
|
1756
1819
|
// src/prompt/Prompt.tsx
|