@sproutsocial/seeds-react-menu 0.1.0 → 0.2.1
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/.eslintignore +6 -0
- package/.eslintrc.js +6 -2
- package/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +23 -1
- package/dist/esm/index.js +243 -217
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +104 -38
- package/dist/index.d.ts +104 -38
- package/dist/index.js +272 -243
- package/dist/index.js.map +1 -1
- package/package.json +10 -7
- package/src/ActionMenu/ActionMenu.feature +9 -3
- package/src/ActionMenu/ActionMenu.tsx +76 -42
- package/src/ActionMenu/__tests__/ActionMenu.test.tsx +36 -42
- package/src/ActionMenu/__tests__/ActionMenu.typetest.tsx +13 -13
- package/src/MenuContent/MenuContent.tsx +31 -1
- package/src/MenuContent/MenuContentTypes.ts +3 -4
- package/src/MenuContent/styles.tsx +10 -6
- package/src/MenuContext.tsx +1 -6
- package/src/MenuFooter/MenuFooter.feature +1 -1
- package/src/MenuFooter/MenuFooter.tsx +8 -0
- package/src/MenuFooter/__tests__/MenuFooter.test.tsx +53 -26
- package/src/MenuFooter/styles.tsx +1 -1
- package/src/MenuGroup/MenuGroup.feature +14 -26
- package/src/MenuGroup/MenuGroup.tsx +21 -1
- package/src/MenuGroup/MenuGroupTypes.ts +1 -0
- package/src/MenuGroup/__tests__/MenuGroup.test.tsx +41 -6
- package/src/MenuGroup/styles.tsx +4 -3
- package/src/MenuHeader/MenuHeader.tsx +16 -5
- package/src/MenuHeader/__tests__/MenuHeader.test.tsx +50 -6
- package/src/MenuHeader/__tests__/MenuHeader.typetest.tsx +1 -0
- package/src/MenuHeader/styles.tsx +21 -22
- package/src/MenuItem/MenuItem.feature +66 -26
- package/src/MenuItem/MenuItem.tsx +39 -20
- package/src/MenuItem/MenuItemTypes.ts +13 -1
- package/src/MenuItem/__tests__/MenuItem.test.tsx +431 -154
- package/src/MenuItem/__tests__/MenuItem.typetest.tsx +57 -38
- package/src/MenuItem/styles.tsx +44 -3
- package/src/{MenuItemSelectable/MenuItemSelectable.tsx → MenuItem/useOptionProps.tsx} +32 -54
- package/src/MenuRoot/MenuRoot.feature +20 -10
- package/src/MenuRoot/MenuRoot.tsx +14 -18
- package/src/MenuRoot/__tests__/MenuRoot.test.tsx +168 -34
- package/src/MenuRoot/__tests__/MenuRoot.typetest.tsx +10 -10
- package/src/MultiSelectMenu/MultiSelectMenu.feature +2 -13
- package/src/MultiSelectMenu/MultiSelectMenu.tsx +9 -1
- package/src/MultiSelectMenu/__tests__/MultiSelectMenu.test.tsx +154 -153
- package/src/MultiSelectMenu/__tests__/MultiSelectMenu.typetest.tsx +10 -10
- package/src/SingleSelectMenu/SingleSelectMenu.feature +11 -0
- package/src/SingleSelectMenu/SingleSelectMenu.tsx +10 -0
- package/src/SingleSelectMenu/__tests__/SingleSelectMenu.test.tsx +11 -14
- package/src/SingleSelectMenu/__tests__/SingleSelectMenu.typetest.tsx +14 -14
- package/src/__tests__/Menu.test.tsx +20 -16
- package/src/hooks/useItemsFromChildren.tsx +2 -4
- package/src/index.ts +0 -1
- package/src/menuTestingUtils.tsx +7 -4
- package/tsconfig.json +1 -1
- package/src/MenuItemSelectable/MenuItemSelectable.feature +0 -99
- package/src/MenuItemSelectable/MenuItemSelectableTypes.ts +0 -15
- package/src/MenuItemSelectable/__tests__/MenuItemSelectable.test.tsx +0 -303
- package/src/MenuItemSelectable/__tests__/MenuItemSelectable.typetest.tsx +0 -56
- package/src/MenuItemSelectable/index.ts +0 -5
- package/src/MenuItemSelectable/styles.tsx +0 -21
package/dist/esm/index.js
CHANGED
|
@@ -95,14 +95,10 @@ var require_object_assign = __commonJS({
|
|
|
95
95
|
});
|
|
96
96
|
|
|
97
97
|
// src/MenuItem/MenuItem.tsx
|
|
98
|
-
import { useContext as
|
|
98
|
+
import { useContext as useContext3 } from "react";
|
|
99
99
|
|
|
100
100
|
// src/MenuContext.tsx
|
|
101
|
-
import {
|
|
102
|
-
createContext,
|
|
103
|
-
useMemo,
|
|
104
|
-
useContext
|
|
105
|
-
} from "react";
|
|
101
|
+
import { createContext, useMemo, useContext } from "react";
|
|
106
102
|
import { jsx } from "react/jsx-runtime";
|
|
107
103
|
var defaultMenuContext = {
|
|
108
104
|
items: [],
|
|
@@ -148,15 +144,6 @@ var useMenuContext = () => {
|
|
|
148
144
|
return menuContextValue;
|
|
149
145
|
};
|
|
150
146
|
|
|
151
|
-
// src/constants.ts
|
|
152
|
-
var MENU_ITEM_ROLES = {
|
|
153
|
-
MENUITEM: "menuitem",
|
|
154
|
-
LISTITEM: "listitem",
|
|
155
|
-
OPTION: "option",
|
|
156
|
-
RADIO: "menuitemradio",
|
|
157
|
-
CHECKBOX: "menuitemcheckbox"
|
|
158
|
-
};
|
|
159
|
-
|
|
160
147
|
// src/MenuItem/styles.tsx
|
|
161
148
|
import styled, { css as css4 } from "styled-components";
|
|
162
149
|
|
|
@@ -1710,19 +1697,39 @@ var highlightedStyles = css4`
|
|
|
1710
1697
|
cursor: pointer;
|
|
1711
1698
|
border: 1px solid ${({ theme: theme2 }) => theme2.colors.listItem.border.base};
|
|
1712
1699
|
background-color: ${({ theme: theme2 }) => theme2.colors.listItem.background.hover};
|
|
1700
|
+
color: ${({ theme: theme2 }) => theme2.colors.text.body};
|
|
1701
|
+
text-decoration: none;
|
|
1713
1702
|
`;
|
|
1714
1703
|
var MenuItemContainer = styled.li`
|
|
1704
|
+
box-sizing: border-box;
|
|
1705
|
+
list-style-type: none;
|
|
1706
|
+
margin-left: ${({ theme: theme2 }) => theme2.space[300]};
|
|
1707
|
+
margin-right: ${({ theme: theme2 }) => theme2.space[300]};
|
|
1708
|
+
transition: all ${({ theme: theme2 }) => theme2.duration["fast"]};
|
|
1709
|
+
|
|
1710
|
+
&:first-child {
|
|
1711
|
+
margin-top: ${({ theme: theme2 }) => theme2.space[300]};
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1714
|
+
&:last-child {
|
|
1715
|
+
margin-bottom: ${({ theme: theme2 }) => theme2.space[300]};
|
|
1716
|
+
}
|
|
1717
|
+
`;
|
|
1718
|
+
var StyledMenuItem = styled.div`
|
|
1719
|
+
display: block;
|
|
1720
|
+
box-sizing: border-box;
|
|
1721
|
+
width: 100%;
|
|
1715
1722
|
border-radius: ${({ theme: theme2 }) => theme2.radii[500]};
|
|
1716
1723
|
background-color: ${({ theme: theme2 }) => theme2.colors.listItem.background.base};
|
|
1717
1724
|
border: 1px solid ${({ theme: theme2 }) => theme2.colors.listItem.background.base};
|
|
1718
1725
|
color: ${({ theme: theme2 }) => theme2.colors.text.body};
|
|
1719
1726
|
font-family: ${({ theme: theme2 }) => theme2.fontFamily};
|
|
1720
1727
|
font-weight: ${({ theme: theme2 }) => theme2.fontWeights.normal};
|
|
1728
|
+
text-align: left;
|
|
1729
|
+
text-decoration: none;
|
|
1721
1730
|
padding: ${({ theme: theme2 }) => theme2.space[300]};
|
|
1722
|
-
list-style-type: none;
|
|
1723
1731
|
outline: 0;
|
|
1724
1732
|
${({ theme: theme2 }) => theme2.typography[200]};
|
|
1725
|
-
transition: all ${({ theme: theme2 }) => theme2.duration["fast"]};
|
|
1726
1733
|
|
|
1727
1734
|
/* Highlighted */
|
|
1728
1735
|
${({ $highlighted }) => $highlighted && highlightedStyles}
|
|
@@ -1764,76 +1771,33 @@ var MenuItemContainer = styled.li`
|
|
|
1764
1771
|
${layout}
|
|
1765
1772
|
${space}
|
|
1766
1773
|
`;
|
|
1767
|
-
|
|
1768
|
-
// src/MenuItem/MenuItem.tsx
|
|
1769
|
-
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
1770
|
-
var MenuItem = ({
|
|
1771
|
-
id,
|
|
1772
|
-
children,
|
|
1773
|
-
role = "menuitem",
|
|
1774
|
-
label,
|
|
1775
|
-
onClick,
|
|
1776
|
-
onKeyDown,
|
|
1777
|
-
disabled: disabled2 = false,
|
|
1778
|
-
ref,
|
|
1779
|
-
color: color2,
|
|
1780
|
-
...props
|
|
1781
|
-
}) => {
|
|
1782
|
-
const { getItemProps, itemsMap, highlightedIndex, isListbox } = useContext2(MenuContext);
|
|
1783
|
-
const item = itemsMap[id] || { index: 0, id };
|
|
1784
|
-
const highlighted = highlightedIndex === item?.index;
|
|
1785
|
-
return /* @__PURE__ */ jsx2(
|
|
1786
|
-
MenuItemContainer,
|
|
1787
|
-
{
|
|
1788
|
-
id,
|
|
1789
|
-
tabIndex: role !== MENU_ITEM_ROLES.LISTITEM && !disabled2 ? -1 : void 0,
|
|
1790
|
-
$highlighted: highlighted,
|
|
1791
|
-
...getItemProps?.({
|
|
1792
|
-
...isListbox ? {} : { role: "menuitem" },
|
|
1793
|
-
item,
|
|
1794
|
-
index: item.index,
|
|
1795
|
-
// This prop no longer supported in downshift
|
|
1796
|
-
// disabled,
|
|
1797
|
-
onClick,
|
|
1798
|
-
onKeyDown
|
|
1799
|
-
}),
|
|
1800
|
-
...props,
|
|
1801
|
-
children
|
|
1802
|
-
}
|
|
1803
|
-
);
|
|
1804
|
-
};
|
|
1805
|
-
|
|
1806
|
-
// src/MenuItemSelectable/MenuItemSelectable.tsx
|
|
1807
|
-
import { useContext as useContext3, useMemo as useMemo2 } from "react";
|
|
1808
|
-
import { Icon } from "@sproutsocial/seeds-react-icon";
|
|
1809
|
-
import { Checkbox } from "@sproutsocial/seeds-react-checkbox";
|
|
1810
|
-
import { Switch } from "@sproutsocial/seeds-react-switch";
|
|
1811
|
-
import { Radio } from "@sproutsocial/seeds-react-radio";
|
|
1812
|
-
import { useTheme } from "styled-components";
|
|
1813
|
-
import { Box } from "@sproutsocial/seeds-react-box";
|
|
1814
|
-
|
|
1815
|
-
// src/MenuItemSelectable/styles.tsx
|
|
1816
|
-
import styled2 from "styled-components";
|
|
1817
|
-
var MenuItemSelectableRow = styled2.div`
|
|
1774
|
+
var MenuItemRow = styled.div`
|
|
1818
1775
|
display: flex;
|
|
1819
1776
|
align-items: center;
|
|
1820
1777
|
pointer-events: none;
|
|
1821
1778
|
`;
|
|
1822
|
-
var
|
|
1779
|
+
var MenuItemAction = styled.div`
|
|
1823
1780
|
margin-right: ${({ theme: theme2 }) => theme2.space[300]};
|
|
1824
1781
|
display: flex;
|
|
1825
1782
|
align-items: center;
|
|
1826
1783
|
justify-content: center;
|
|
1827
1784
|
flex-shrink: 0;
|
|
1828
1785
|
`;
|
|
1829
|
-
var
|
|
1786
|
+
var MenuItemText = styled.div`
|
|
1830
1787
|
word-break: break-word;
|
|
1831
1788
|
flex-grow: 1;
|
|
1832
1789
|
min-width: 0;
|
|
1833
1790
|
`;
|
|
1834
1791
|
|
|
1835
|
-
// src/
|
|
1836
|
-
import {
|
|
1792
|
+
// src/MenuItem/useOptionProps.tsx
|
|
1793
|
+
import { useContext as useContext2, useMemo as useMemo2 } from "react";
|
|
1794
|
+
import { Icon } from "@sproutsocial/seeds-react-icon";
|
|
1795
|
+
import { Checkbox } from "@sproutsocial/seeds-react-checkbox";
|
|
1796
|
+
import { Switch } from "@sproutsocial/seeds-react-switch";
|
|
1797
|
+
import { Radio } from "@sproutsocial/seeds-react-radio";
|
|
1798
|
+
import { useTheme } from "styled-components";
|
|
1799
|
+
import { Box } from "@sproutsocial/seeds-react-box";
|
|
1800
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
1837
1801
|
var SelectionIndicator = ({
|
|
1838
1802
|
id,
|
|
1839
1803
|
inputType = "icon",
|
|
@@ -1846,88 +1810,127 @@ var SelectionIndicator = ({
|
|
|
1846
1810
|
};
|
|
1847
1811
|
switch (inputType) {
|
|
1848
1812
|
case "checkbox":
|
|
1849
|
-
return /* @__PURE__ */
|
|
1813
|
+
return /* @__PURE__ */ jsx2(
|
|
1850
1814
|
Checkbox,
|
|
1851
1815
|
{
|
|
1852
1816
|
onChange: () => {
|
|
1853
1817
|
},
|
|
1854
1818
|
checked: selected,
|
|
1855
1819
|
"aria-labelledby": labeledBy,
|
|
1856
|
-
id: `
|
|
1820
|
+
id: `MenuItem-${inputType}-${id}`
|
|
1857
1821
|
}
|
|
1858
1822
|
);
|
|
1859
1823
|
case "switch":
|
|
1860
|
-
return /* @__PURE__ */
|
|
1824
|
+
return /* @__PURE__ */ jsx2(
|
|
1861
1825
|
Switch,
|
|
1862
1826
|
{
|
|
1863
1827
|
onClick: inputStub,
|
|
1864
1828
|
checked: !!selected,
|
|
1865
1829
|
"aria-labelledby": labeledBy,
|
|
1866
|
-
id: `
|
|
1830
|
+
id: `MenuItem-${inputType}-${id}`
|
|
1867
1831
|
}
|
|
1868
1832
|
);
|
|
1869
1833
|
case "radio":
|
|
1870
|
-
return /* @__PURE__ */
|
|
1834
|
+
return /* @__PURE__ */ jsx2(
|
|
1871
1835
|
Radio,
|
|
1872
1836
|
{
|
|
1873
1837
|
checked: selected,
|
|
1874
|
-
id: `
|
|
1875
|
-
name: `
|
|
1838
|
+
id: `MenuItem-${inputType}-${id}`,
|
|
1839
|
+
name: `MenuItem-${inputType}`,
|
|
1876
1840
|
"aria-labelledby": labeledBy
|
|
1877
1841
|
}
|
|
1878
1842
|
);
|
|
1879
1843
|
case "icon":
|
|
1880
1844
|
if (selected) {
|
|
1881
|
-
return /* @__PURE__ */
|
|
1845
|
+
return /* @__PURE__ */ jsx2(Icon, { name: "check-solid", "aria-hidden": true, size: "small" });
|
|
1882
1846
|
} else {
|
|
1883
|
-
return /* @__PURE__ */
|
|
1847
|
+
return /* @__PURE__ */ jsx2(Box, { width: space2["400"] });
|
|
1884
1848
|
}
|
|
1885
1849
|
default:
|
|
1886
1850
|
return null;
|
|
1887
1851
|
}
|
|
1888
1852
|
};
|
|
1889
|
-
var
|
|
1853
|
+
var useOptionProps = ({
|
|
1890
1854
|
id,
|
|
1891
1855
|
children,
|
|
1892
1856
|
inputType = "icon",
|
|
1893
|
-
|
|
1857
|
+
inputLabelId,
|
|
1894
1858
|
...props
|
|
1895
1859
|
}) => {
|
|
1896
|
-
const { selectedItem, selectedItems, isListbox } =
|
|
1860
|
+
const { selectedItem, selectedItems, isListbox } = useContext2(MenuContext);
|
|
1897
1861
|
const selected = useMemo2(
|
|
1898
1862
|
() => selectedItem?.id === id || !!selectedItems?.find((item) => item?.id === id),
|
|
1863
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1899
1864
|
[selectedItem, selectedItems]
|
|
1900
1865
|
);
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1866
|
+
const label = inputLabelId || `menu-item-child-${id}`;
|
|
1867
|
+
return isListbox ? {
|
|
1868
|
+
active: selected,
|
|
1869
|
+
["aria-selected"]: selected,
|
|
1870
|
+
children: /* @__PURE__ */ jsxs(MenuItemRow, { children: [
|
|
1871
|
+
/* @__PURE__ */ jsx2(MenuItemAction, { children: /* @__PURE__ */ jsx2(
|
|
1872
|
+
SelectionIndicator,
|
|
1873
|
+
{
|
|
1874
|
+
id,
|
|
1875
|
+
"aria-labelledby": label,
|
|
1876
|
+
inputType,
|
|
1877
|
+
selected: !!selected
|
|
1878
|
+
}
|
|
1879
|
+
) }),
|
|
1880
|
+
/* @__PURE__ */ jsx2(MenuItemText, { id: label, children })
|
|
1881
|
+
] }),
|
|
1882
|
+
...props
|
|
1883
|
+
} : {};
|
|
1884
|
+
};
|
|
1885
|
+
|
|
1886
|
+
// src/MenuItem/MenuItem.tsx
|
|
1887
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
1888
|
+
var MenuItem = ({
|
|
1889
|
+
id,
|
|
1890
|
+
children,
|
|
1891
|
+
onClick,
|
|
1892
|
+
onKeyDown,
|
|
1893
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1894
|
+
disabled: disabled2 = false,
|
|
1895
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1896
|
+
ref,
|
|
1897
|
+
href,
|
|
1898
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1899
|
+
color: color2,
|
|
1900
|
+
...props
|
|
1901
|
+
}) => {
|
|
1902
|
+
const { getItemProps, itemsMap, highlightedIndex, isListbox } = useContext3(MenuContext);
|
|
1903
|
+
const { ...optionProps } = useOptionProps({
|
|
1904
|
+
id,
|
|
1905
|
+
children,
|
|
1906
|
+
...props
|
|
1907
|
+
});
|
|
1908
|
+
const item = itemsMap[id] || { index: 0, id };
|
|
1909
|
+
const highlighted = highlightedIndex === item?.index;
|
|
1910
|
+
return /* @__PURE__ */ jsx3(MenuItemContainer, { role: "none", children: /* @__PURE__ */ jsx3(
|
|
1911
|
+
StyledMenuItem,
|
|
1909
1912
|
{
|
|
1910
|
-
active: selected,
|
|
1911
1913
|
id,
|
|
1912
|
-
|
|
1913
|
-
...
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1914
|
+
$highlighted: highlighted,
|
|
1915
|
+
...getItemProps?.({
|
|
1916
|
+
...isListbox ? {} : { role: "menuitem" },
|
|
1917
|
+
item,
|
|
1918
|
+
index: item.index,
|
|
1919
|
+
// This prop no longer supported in downshift
|
|
1920
|
+
// disabled,
|
|
1921
|
+
onClick,
|
|
1922
|
+
onKeyDown
|
|
1923
|
+
}),
|
|
1924
|
+
as: isListbox ? void 0 : href ? "a" : "button",
|
|
1925
|
+
href,
|
|
1926
|
+
children,
|
|
1927
|
+
...optionProps,
|
|
1928
|
+
...props
|
|
1926
1929
|
}
|
|
1927
|
-
);
|
|
1930
|
+
) });
|
|
1928
1931
|
};
|
|
1929
1932
|
|
|
1930
|
-
// src/
|
|
1933
|
+
// src/MenuItem/MenuItemTypes.ts
|
|
1931
1934
|
var INPUT_TYPES = {
|
|
1932
1935
|
CHECKBOX: "checkbox",
|
|
1933
1936
|
RADIO: "radio",
|
|
@@ -1939,8 +1942,8 @@ var INPUT_TYPES = {
|
|
|
1939
1942
|
import "react";
|
|
1940
1943
|
|
|
1941
1944
|
// src/MenuHeader/styles.tsx
|
|
1942
|
-
import
|
|
1943
|
-
var MenuHeaderContainer =
|
|
1945
|
+
import styled2 from "styled-components";
|
|
1946
|
+
var MenuHeaderContainer = styled2.div`
|
|
1944
1947
|
border-color: ${({ theme: theme2 }) => theme2.colors.container.border.base};
|
|
1945
1948
|
border-bottom-width: 1px;
|
|
1946
1949
|
border-bottom-style: solid;
|
|
@@ -1948,26 +1951,9 @@ var MenuHeaderContainer = styled3.div`
|
|
|
1948
1951
|
width: 100%;
|
|
1949
1952
|
font-size: ${({ theme: theme2 }) => theme2.typography[200].fontSize};
|
|
1950
1953
|
display: flex;
|
|
1954
|
+
flex-direction: column;
|
|
1951
1955
|
padding: ${({ theme: theme2 }) => theme2.space[350]} ${({ theme: theme2 }) => theme2.space[400]};
|
|
1952
1956
|
|
|
1953
|
-
> a {
|
|
1954
|
-
white-space: nowrap;
|
|
1955
|
-
}
|
|
1956
|
-
|
|
1957
|
-
&:first-child {
|
|
1958
|
-
flex-grow: 1;
|
|
1959
|
-
justify-self: start;
|
|
1960
|
-
}
|
|
1961
|
-
|
|
1962
|
-
&:last-child {
|
|
1963
|
-
flex-grow: 1;
|
|
1964
|
-
justify-self: end;
|
|
1965
|
-
}
|
|
1966
|
-
|
|
1967
|
-
${({ $leftAction, theme: theme2 }) => $leftAction && `
|
|
1968
|
-
padding-left: ${theme2.space[350]};
|
|
1969
|
-
`}
|
|
1970
|
-
|
|
1971
1957
|
${border}
|
|
1972
1958
|
${color}
|
|
1973
1959
|
${flexbox}
|
|
@@ -1976,23 +1962,40 @@ var MenuHeaderContainer = styled3.div`
|
|
|
1976
1962
|
${space}
|
|
1977
1963
|
${position}
|
|
1978
1964
|
`;
|
|
1979
|
-
var MenuTitleText =
|
|
1965
|
+
var MenuTitleText = styled2.h3`
|
|
1980
1966
|
color: ${({ theme: theme2 }) => theme2.colors.text.headline};
|
|
1981
1967
|
font-weight: ${({ theme: theme2 }) => theme2.fontWeights.bold};
|
|
1982
1968
|
margin: 0px;
|
|
1983
1969
|
flex-grow: 2;
|
|
1984
1970
|
justify-self: start;
|
|
1985
1971
|
|
|
1972
|
+
${({ theme: theme2 }) => theme2.typography[200]}
|
|
1973
|
+
|
|
1986
1974
|
${({ $leftAction, theme: theme2 }) => $leftAction && `
|
|
1987
1975
|
padding-left: ${theme2.space[350]};
|
|
1988
1976
|
`}
|
|
1989
|
-
|
|
1990
|
-
${({ theme: theme2 }) => theme2.typography[200]}
|
|
1991
1977
|
`;
|
|
1992
|
-
var MenuChildrenContainer =
|
|
1978
|
+
var MenuChildrenContainer = styled2.div`
|
|
1993
1979
|
grid-column: 1 / -1;
|
|
1994
1980
|
margin-top: ${({ theme: theme2 }) => theme2.space[300]};
|
|
1995
1981
|
`;
|
|
1982
|
+
var MenuHeaderFeatures = styled2.div`
|
|
1983
|
+
display: flex;
|
|
1984
|
+
|
|
1985
|
+
> a {
|
|
1986
|
+
white-space: nowrap;
|
|
1987
|
+
}
|
|
1988
|
+
|
|
1989
|
+
&:first-child {
|
|
1990
|
+
flex-grow: 1;
|
|
1991
|
+
justify-self: start;
|
|
1992
|
+
}
|
|
1993
|
+
|
|
1994
|
+
&:last-child {
|
|
1995
|
+
flex-grow: 1;
|
|
1996
|
+
justify-self: end;
|
|
1997
|
+
}
|
|
1998
|
+
`;
|
|
1996
1999
|
|
|
1997
2000
|
// src/MenuHeader/MenuHeader.tsx
|
|
1998
2001
|
import { Fragment, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
@@ -2004,21 +2007,21 @@ var MenuHeader = ({
|
|
|
2004
2007
|
...rest
|
|
2005
2008
|
}) => {
|
|
2006
2009
|
return /* @__PURE__ */ jsx4(Fragment, { children: /* @__PURE__ */ jsxs2(MenuHeaderContainer, { $leftAction: !!leftAction, ...rest, children: [
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
+
/* @__PURE__ */ jsxs2(MenuHeaderFeatures, { $leftAction: !!leftAction, children: [
|
|
2011
|
+
leftAction && leftAction,
|
|
2012
|
+
title && /* @__PURE__ */ jsx4(MenuTitleText, { $leftAction: !!leftAction, children: title }),
|
|
2013
|
+
rightAction && rightAction
|
|
2014
|
+
] }),
|
|
2010
2015
|
children && /* @__PURE__ */ jsx4(MenuChildrenContainer, { children })
|
|
2011
2016
|
] }) });
|
|
2012
2017
|
};
|
|
2013
2018
|
|
|
2014
2019
|
// src/MenuContent/styles.tsx
|
|
2015
|
-
import
|
|
2016
|
-
|
|
2020
|
+
import styled3 from "styled-components";
|
|
2021
|
+
import { motion } from "motion/react";
|
|
2022
|
+
var StyledMenuContent = styled3(motion.ul)`
|
|
2017
2023
|
margin: 0;
|
|
2018
|
-
padding:
|
|
2019
|
-
&:focus {
|
|
2020
|
-
${focusRing}
|
|
2021
|
-
}
|
|
2024
|
+
padding: 0;
|
|
2022
2025
|
`;
|
|
2023
2026
|
|
|
2024
2027
|
// src/MenuContent/MenuContent.tsx
|
|
@@ -2028,7 +2031,7 @@ var MenuContent = ({
|
|
|
2028
2031
|
children,
|
|
2029
2032
|
...rest
|
|
2030
2033
|
}) => {
|
|
2031
|
-
const { getToggleButtonProps } = useMenuContext();
|
|
2034
|
+
const { getToggleButtonProps, getMenuProps, isListbox } = useMenuContext();
|
|
2032
2035
|
return /* @__PURE__ */ jsx5(
|
|
2033
2036
|
StyledMenuContent,
|
|
2034
2037
|
{
|
|
@@ -2037,6 +2040,13 @@ var MenuContent = ({
|
|
|
2037
2040
|
tabIndex: 0,
|
|
2038
2041
|
onKeyDown: getToggleButtonProps?.().onKeyDown,
|
|
2039
2042
|
"aria-activedescendant": getToggleButtonProps?.()["aria-activedescendant"],
|
|
2043
|
+
...getMenuProps?.(
|
|
2044
|
+
{
|
|
2045
|
+
...isListbox ? {} : { role: "menu" }
|
|
2046
|
+
},
|
|
2047
|
+
// Suppress ref error for now
|
|
2048
|
+
{ suppressRefError: true }
|
|
2049
|
+
),
|
|
2040
2050
|
...rest,
|
|
2041
2051
|
children
|
|
2042
2052
|
}
|
|
@@ -2047,10 +2057,10 @@ var MenuContent = ({
|
|
|
2047
2057
|
import "react";
|
|
2048
2058
|
|
|
2049
2059
|
// src/MenuFooter/styles.tsx
|
|
2050
|
-
import
|
|
2060
|
+
import styled4 from "styled-components";
|
|
2051
2061
|
import { Box as Box2 } from "@sproutsocial/seeds-react-box";
|
|
2052
|
-
var StyledMenuFooterBox =
|
|
2053
|
-
padding: ${(p) => p.theme.space[
|
|
2062
|
+
var StyledMenuFooterBox = styled4(Box2)`
|
|
2063
|
+
padding: ${(p) => p.theme.space[400]};
|
|
2054
2064
|
border-top: 1px solid ${(p) => p.theme.colors.container.border.base};
|
|
2055
2065
|
`;
|
|
2056
2066
|
|
|
@@ -2064,12 +2074,12 @@ var MenuFooter = ({ children, ...rest }) => {
|
|
|
2064
2074
|
import "react";
|
|
2065
2075
|
|
|
2066
2076
|
// src/MenuGroup/styles.tsx
|
|
2067
|
-
import
|
|
2077
|
+
import styled6 from "styled-components";
|
|
2068
2078
|
|
|
2069
2079
|
// ../seeds-react-text/dist/esm/index.js
|
|
2070
2080
|
import "react";
|
|
2071
2081
|
import styled22 from "styled-components";
|
|
2072
|
-
import
|
|
2082
|
+
import styled5, { css as css5 } from "styled-components";
|
|
2073
2083
|
import {
|
|
2074
2084
|
COMMON,
|
|
2075
2085
|
LAYOUT,
|
|
@@ -2079,7 +2089,7 @@ import {
|
|
|
2079
2089
|
} from "@sproutsocial/seeds-react-system-props";
|
|
2080
2090
|
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
2081
2091
|
import "react";
|
|
2082
|
-
var Container =
|
|
2092
|
+
var Container = styled5.span`
|
|
2083
2093
|
margin: 0;
|
|
2084
2094
|
padding-left: 0;
|
|
2085
2095
|
padding-right: 0;
|
|
@@ -2152,31 +2162,45 @@ var Text = ({ fontSize: fontSize2, children, qa, color: color2, ...rest }) => {
|
|
|
2152
2162
|
}
|
|
2153
2163
|
);
|
|
2154
2164
|
};
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
Text.
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
Text.
|
|
2167
|
-
|
|
2168
|
-
|
|
2165
|
+
var withTextLogic = (Component) => {
|
|
2166
|
+
return ({ children, ...props }) => {
|
|
2167
|
+
const qaText = typeof children === "string" ? children : void 0;
|
|
2168
|
+
return /* @__PURE__ */ jsx7(Component, { "data-qa-text": qaText, ...props, children });
|
|
2169
|
+
};
|
|
2170
|
+
};
|
|
2171
|
+
var HeadlineWithLogic = withTextLogic(Headline);
|
|
2172
|
+
HeadlineWithLogic.displayName = "Text.Headline";
|
|
2173
|
+
Text.Headline = HeadlineWithLogic;
|
|
2174
|
+
var SubHeadlineWithLogic = withTextLogic(SubHeadline);
|
|
2175
|
+
SubHeadlineWithLogic.displayName = "Text.SubHeadline";
|
|
2176
|
+
Text.SubHeadline = SubHeadlineWithLogic;
|
|
2177
|
+
var SmallSubHeadlineWithLogic = withTextLogic(SmallSubHeadline);
|
|
2178
|
+
SmallSubHeadlineWithLogic.displayName = "Text.SmallSubHeadline";
|
|
2179
|
+
Text.SmallSubHeadline = SmallSubHeadlineWithLogic;
|
|
2180
|
+
var BylineWithLogic = withTextLogic(Byline);
|
|
2181
|
+
BylineWithLogic.displayName = "Text.Byline";
|
|
2182
|
+
Text.Byline = BylineWithLogic;
|
|
2183
|
+
var SmallBylineWithLogic = withTextLogic(SmallByline);
|
|
2184
|
+
SmallBylineWithLogic.displayName = "Text.SmallByline";
|
|
2185
|
+
Text.SmallByline = SmallBylineWithLogic;
|
|
2186
|
+
var BodyCopyWithLogic = withTextLogic(BodyCopy);
|
|
2187
|
+
BodyCopyWithLogic.displayName = "Text.BodyCopy";
|
|
2188
|
+
Text.BodyCopy = BodyCopyWithLogic;
|
|
2189
|
+
var SmallBodyCopyWithLogic = withTextLogic(SmallBodyCopy);
|
|
2190
|
+
SmallBodyCopyWithLogic.displayName = "Text.SmallBodyCopy";
|
|
2191
|
+
Text.SmallBodyCopy = SmallBodyCopyWithLogic;
|
|
2169
2192
|
var Text_default = Text;
|
|
2170
2193
|
var src_default = Text_default;
|
|
2171
2194
|
|
|
2172
2195
|
// src/MenuGroup/styles.tsx
|
|
2173
|
-
var StyledMenuGroup =
|
|
2196
|
+
var StyledMenuGroup = styled6.li`
|
|
2174
2197
|
&:not(:last-child) {
|
|
2175
2198
|
border-bottom: 1px solid
|
|
2176
2199
|
${({ theme: theme2 }) => theme2.colors.container.border.base};
|
|
2177
2200
|
}
|
|
2178
2201
|
list-style: none;
|
|
2179
2202
|
margin: 0;
|
|
2203
|
+
|
|
2180
2204
|
${border}
|
|
2181
2205
|
${position}
|
|
2182
2206
|
${color}
|
|
@@ -2185,13 +2209,13 @@ var StyledMenuGroup = styled7.li`
|
|
|
2185
2209
|
${layout}
|
|
2186
2210
|
${space}
|
|
2187
2211
|
`;
|
|
2188
|
-
var StyledTitle =
|
|
2189
|
-
margin: ${({ theme: theme2 }) => theme2.space[
|
|
2190
|
-
|
|
2212
|
+
var StyledTitle = styled6(src_default.SmallSubHeadline)`
|
|
2213
|
+
margin: ${({ theme: theme2 }) => theme2.space[400]} ${({ theme: theme2 }) => theme2.space[400]}
|
|
2214
|
+
0px ${({ theme: theme2 }) => theme2.space[400]};
|
|
2191
2215
|
`;
|
|
2192
|
-
var StyledMenuGroupUl =
|
|
2216
|
+
var StyledMenuGroupUl = styled6.ul`
|
|
2193
2217
|
margin: 0;
|
|
2194
|
-
padding:
|
|
2218
|
+
padding: 0;
|
|
2195
2219
|
`;
|
|
2196
2220
|
|
|
2197
2221
|
// src/MenuGroup/MenuGroup.tsx
|
|
@@ -2212,7 +2236,7 @@ var MenuGroup = ({
|
|
|
2212
2236
|
color: color2,
|
|
2213
2237
|
...rest,
|
|
2214
2238
|
children: [
|
|
2215
|
-
title && /* @__PURE__ */ jsx8(StyledTitle, { as: titleAs, id: titleId, children: title }),
|
|
2239
|
+
title && /* @__PURE__ */ jsx8(StyledTitle, { role: "heading", as: titleAs, id: titleId, children: title }),
|
|
2216
2240
|
/* @__PURE__ */ jsx8(StyledMenuGroupUl, { children })
|
|
2217
2241
|
]
|
|
2218
2242
|
}
|
|
@@ -2221,22 +2245,22 @@ var MenuGroup = ({
|
|
|
2221
2245
|
|
|
2222
2246
|
// src/MenuRoot/MenuRoot.tsx
|
|
2223
2247
|
import { useCallback } from "react";
|
|
2224
|
-
import
|
|
2248
|
+
import styled7 from "styled-components";
|
|
2225
2249
|
import { Popout } from "@sproutsocial/seeds-react-popout";
|
|
2226
2250
|
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
2227
|
-
var CustomPopoutContent =
|
|
2251
|
+
var CustomPopoutContent = styled7(Popout.Content)`
|
|
2228
2252
|
padding: 0;
|
|
2229
2253
|
margin-left: 0;
|
|
2230
2254
|
margin-right: 0;
|
|
2231
2255
|
`;
|
|
2232
2256
|
var MenuRoot = ({
|
|
2233
2257
|
children,
|
|
2234
|
-
|
|
2258
|
+
menuToggleElement,
|
|
2235
2259
|
popoutProps,
|
|
2236
2260
|
width: width2 = "300px",
|
|
2237
2261
|
...contextProps
|
|
2238
2262
|
}) => {
|
|
2239
|
-
const {
|
|
2263
|
+
const { isOpen, openMenu, closeMenu } = contextProps;
|
|
2240
2264
|
const setIsOpen = useCallback(
|
|
2241
2265
|
(newIsOpen) => {
|
|
2242
2266
|
newIsOpen ? openMenu?.() : closeMenu?.();
|
|
@@ -2248,19 +2272,7 @@ var MenuRoot = ({
|
|
|
2248
2272
|
{
|
|
2249
2273
|
isOpen: !!isOpen,
|
|
2250
2274
|
setIsOpen,
|
|
2251
|
-
content: /* @__PURE__ */ jsx9(CustomPopoutContent, { width: width2, children
|
|
2252
|
-
"div",
|
|
2253
|
-
{
|
|
2254
|
-
...getMenuProps?.(
|
|
2255
|
-
{
|
|
2256
|
-
...isListbox ? {} : { role: "menu" }
|
|
2257
|
-
},
|
|
2258
|
-
// Suppress ref error for now
|
|
2259
|
-
{ suppressRefError: true }
|
|
2260
|
-
),
|
|
2261
|
-
children
|
|
2262
|
-
}
|
|
2263
|
-
) }),
|
|
2275
|
+
content: /* @__PURE__ */ jsx9(CustomPopoutContent, { width: width2, children }),
|
|
2264
2276
|
focusLockProps: {
|
|
2265
2277
|
// correct jerking motion when scrolling while the Popout is open
|
|
2266
2278
|
// returnFocus: false,
|
|
@@ -2268,7 +2280,7 @@ var MenuRoot = ({
|
|
|
2268
2280
|
},
|
|
2269
2281
|
disableWrapperAria: true,
|
|
2270
2282
|
...popoutProps,
|
|
2271
|
-
children:
|
|
2283
|
+
children: menuToggleElement
|
|
2272
2284
|
}
|
|
2273
2285
|
) });
|
|
2274
2286
|
};
|
|
@@ -2307,7 +2319,7 @@ var MenuToggleButton = ({
|
|
|
2307
2319
|
};
|
|
2308
2320
|
|
|
2309
2321
|
// src/ActionMenu/ActionMenu.tsx
|
|
2310
|
-
import "react";
|
|
2322
|
+
import React11, { useEffect } from "react";
|
|
2311
2323
|
import {
|
|
2312
2324
|
useSelect as useSelect2
|
|
2313
2325
|
} from "downshift";
|
|
@@ -2336,7 +2348,7 @@ var checkIfIsElement = (element, name) => {
|
|
|
2336
2348
|
var getAllMenuItems = (children) => {
|
|
2337
2349
|
const allMenuItems = [];
|
|
2338
2350
|
walkAllChildren(children, (element, parents) => {
|
|
2339
|
-
if (checkIfIsElement(element, "MenuItem")
|
|
2351
|
+
if (checkIfIsElement(element, "MenuItem")) {
|
|
2340
2352
|
allMenuItems.push({
|
|
2341
2353
|
element,
|
|
2342
2354
|
parents
|
|
@@ -2396,37 +2408,50 @@ var itemToString = (item) => {
|
|
|
2396
2408
|
|
|
2397
2409
|
// src/ActionMenu/ActionMenu.tsx
|
|
2398
2410
|
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
2411
|
+
var handleStateChange = (changes, currentSelectedItem) => {
|
|
2412
|
+
if (!(changes.type === useSelect2.stateChangeTypes.ToggleButtonKeyDownEnter || changes.type === useSelect2.stateChangeTypes.ToggleButtonKeyDownSpaceButton)) {
|
|
2413
|
+
return;
|
|
2414
|
+
}
|
|
2415
|
+
const selectedItem = changes.selectedItem || currentSelectedItem;
|
|
2416
|
+
if (!selectedItem)
|
|
2417
|
+
return;
|
|
2418
|
+
if (selectedItem.element?.props?.disabled) {
|
|
2419
|
+
return;
|
|
2420
|
+
}
|
|
2421
|
+
const isEnterKeyDown = changes.type === useSelect2.stateChangeTypes.ToggleButtonKeyDownEnter;
|
|
2422
|
+
const selectedItemProps = selectedItem.element?.props;
|
|
2423
|
+
if (selectedItemProps?.onClick) {
|
|
2424
|
+
const syntheticKeyboardEvent = new KeyboardEvent("keydown", {
|
|
2425
|
+
key: isEnterKeyDown ? "Enter" : " ",
|
|
2426
|
+
code: isEnterKeyDown ? "Enter" : "Space",
|
|
2427
|
+
bubbles: true,
|
|
2428
|
+
cancelable: true,
|
|
2429
|
+
view: window
|
|
2430
|
+
});
|
|
2431
|
+
selectedItemProps?.onClick?.(
|
|
2432
|
+
syntheticKeyboardEvent
|
|
2433
|
+
);
|
|
2434
|
+
}
|
|
2435
|
+
if (selectedItemProps?.href) {
|
|
2436
|
+
if (selectedItemProps.target) {
|
|
2437
|
+
window.open(selectedItemProps.href, selectedItemProps.target);
|
|
2438
|
+
} else {
|
|
2439
|
+
window.location.href = selectedItemProps?.href;
|
|
2440
|
+
}
|
|
2441
|
+
}
|
|
2442
|
+
};
|
|
2399
2443
|
var ActionMenu = ({
|
|
2400
2444
|
children,
|
|
2401
2445
|
stateReducer: externalStateReducer,
|
|
2402
2446
|
...useSelectProps
|
|
2403
2447
|
}) => {
|
|
2404
2448
|
const { allMenuItems, menuItemsMap } = useItemsFromChildren({ children });
|
|
2405
|
-
const
|
|
2406
|
-
const { selectedItem } = changes;
|
|
2407
|
-
if (selectedItem.element?.props?.disabled) {
|
|
2408
|
-
return;
|
|
2409
|
-
}
|
|
2410
|
-
if (changes.type === useSelect2.stateChangeTypes.ToggleButtonKeyDownEnter || changes.type === useSelect2.stateChangeTypes.ToggleButtonKeyDownSpaceButton) {
|
|
2411
|
-
const isEnterKeyDown = changes.type === useSelect2.stateChangeTypes.ToggleButtonKeyDownEnter;
|
|
2412
|
-
const selectedItemProps = selectedItem.element?.props;
|
|
2413
|
-
const syntheticKeyboardEvent = new KeyboardEvent("keydown", {
|
|
2414
|
-
key: isEnterKeyDown ? "Enter" : " ",
|
|
2415
|
-
code: isEnterKeyDown ? "Enter" : "Space",
|
|
2416
|
-
bubbles: true,
|
|
2417
|
-
cancelable: true,
|
|
2418
|
-
view: window
|
|
2419
|
-
});
|
|
2420
|
-
selectedItemProps?.onClick?.(
|
|
2421
|
-
syntheticKeyboardEvent
|
|
2422
|
-
);
|
|
2423
|
-
}
|
|
2424
|
-
};
|
|
2449
|
+
const [currentSelectedItem, setCurrentSelectedItem] = React11.useState(null);
|
|
2425
2450
|
const { isOpen, ...useSelectReturnProps } = useSelect2({
|
|
2426
2451
|
...defaultUseSelectProps,
|
|
2427
2452
|
items: allMenuItems,
|
|
2428
2453
|
itemToString,
|
|
2429
|
-
|
|
2454
|
+
onStateChange: (changes) => handleStateChange(changes, currentSelectedItem),
|
|
2430
2455
|
stateReducer: (state, actionAndChanges) => {
|
|
2431
2456
|
let newState;
|
|
2432
2457
|
newState = useSelectStateReducer(state, actionAndChanges);
|
|
@@ -2437,6 +2462,9 @@ var ActionMenu = ({
|
|
|
2437
2462
|
},
|
|
2438
2463
|
...useSelectProps
|
|
2439
2464
|
});
|
|
2465
|
+
useEffect(() => {
|
|
2466
|
+
setCurrentSelectedItem(useSelectReturnProps.selectedItem);
|
|
2467
|
+
}, [useSelectReturnProps.selectedItem]);
|
|
2440
2468
|
return /* @__PURE__ */ jsx12(
|
|
2441
2469
|
MenuRoot,
|
|
2442
2470
|
{
|
|
@@ -2569,7 +2597,6 @@ var MultiSelectMenu = ({
|
|
|
2569
2597
|
case useSelect4.stateChangeTypes.ToggleButtonKeyDownEnter:
|
|
2570
2598
|
case useSelect4.stateChangeTypes.ToggleButtonKeyDownSpaceButton:
|
|
2571
2599
|
case useSelect4.stateChangeTypes.ItemClick:
|
|
2572
|
-
case useSelect4.stateChangeTypes.ToggleButtonBlur:
|
|
2573
2600
|
if (!newSelectedItem)
|
|
2574
2601
|
break;
|
|
2575
2602
|
if (selectedItems?.find((item) => item?.id === newSelectedItem.id)) {
|
|
@@ -2618,20 +2645,19 @@ export {
|
|
|
2618
2645
|
MenuGroup,
|
|
2619
2646
|
MenuHeader,
|
|
2620
2647
|
MenuItem,
|
|
2648
|
+
MenuItemAction,
|
|
2621
2649
|
MenuItemContainer,
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
MenuItemSelectableRow,
|
|
2625
|
-
MenuItemSelectableText,
|
|
2650
|
+
MenuItemRow,
|
|
2651
|
+
MenuItemText,
|
|
2626
2652
|
MenuLabel,
|
|
2627
2653
|
MenuProvider,
|
|
2628
2654
|
MenuRoot,
|
|
2629
2655
|
MenuToggleButton,
|
|
2630
2656
|
MultiSelectMenu,
|
|
2631
|
-
SelectionIndicator,
|
|
2632
2657
|
SingleSelectMenu,
|
|
2633
2658
|
StyledMenuGroup,
|
|
2634
2659
|
StyledMenuGroupUl,
|
|
2660
|
+
StyledMenuItem,
|
|
2635
2661
|
StyledTitle,
|
|
2636
2662
|
defaultUseSelectProps,
|
|
2637
2663
|
useItemsFromChildren,
|