@sproutsocial/seeds-react-peek-in 0.3.10 → 0.4.2
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/dist/esm/index.js +230 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +230 -5
- package/dist/index.js.map +1 -1
- package/dist/peek-in.css +54 -0
- package/package.json +20 -11
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/PeekInHybrid.tsx
|
|
2
|
+
import { hasStyledProps } from "@sproutsocial/seeds-react-system-props";
|
|
3
|
+
|
|
4
|
+
// src/PeekInStyled.tsx
|
|
2
5
|
import * as React21 from "react";
|
|
3
6
|
import Box4 from "@sproutsocial/seeds-react-box";
|
|
4
7
|
import Button2 from "@sproutsocial/seeds-react-button";
|
|
@@ -1570,7 +1573,7 @@ var PeekInTrigger = ({
|
|
|
1570
1573
|
};
|
|
1571
1574
|
PeekInTrigger.displayName = "PeekInTrigger";
|
|
1572
1575
|
|
|
1573
|
-
// src/
|
|
1576
|
+
// src/PeekInStyled.tsx
|
|
1574
1577
|
import { jsx as jsx12, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1575
1578
|
function getChildByType(children, type) {
|
|
1576
1579
|
const childArray = React21.Children.toArray(children);
|
|
@@ -1578,7 +1581,7 @@ function getChildByType(children, type) {
|
|
|
1578
1581
|
(child) => React21.isValidElement(child) && child.type === type
|
|
1579
1582
|
) || null;
|
|
1580
1583
|
}
|
|
1581
|
-
var
|
|
1584
|
+
var PeekInStyled = ({
|
|
1582
1585
|
open,
|
|
1583
1586
|
defaultOpen,
|
|
1584
1587
|
onOpenChange,
|
|
@@ -1791,8 +1794,230 @@ var PeekInRoot = ({
|
|
|
1791
1794
|
}
|
|
1792
1795
|
) });
|
|
1793
1796
|
};
|
|
1794
|
-
|
|
1795
|
-
|
|
1797
|
+
PeekInStyled.displayName = "PeekIn";
|
|
1798
|
+
|
|
1799
|
+
// src/PeekInTailwind.tsx
|
|
1800
|
+
import * as React24 from "react";
|
|
1801
|
+
import Button3 from "@sproutsocial/seeds-react-button";
|
|
1802
|
+
import Drawer3 from "@sproutsocial/seeds-react-drawer";
|
|
1803
|
+
import Icon3 from "@sproutsocial/seeds-react-icon";
|
|
1804
|
+
import Text3 from "@sproutsocial/seeds-react-text";
|
|
1805
|
+
import { useIsMobile as useIsMobile3 } from "@sproutsocial/seeds-react-hooks";
|
|
1806
|
+
import { Modal as Modal2, ModalBody as ModalBody2 } from "@sproutsocial/seeds-react-modal/v2";
|
|
1807
|
+
import { jsx as jsx13, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1808
|
+
function getChildByType2(children, type) {
|
|
1809
|
+
const childArray = React24.Children.toArray(children);
|
|
1810
|
+
return childArray.find(
|
|
1811
|
+
(child) => React24.isValidElement(child) && child.type === type
|
|
1812
|
+
) || null;
|
|
1813
|
+
}
|
|
1814
|
+
var PeekInTailwind = ({
|
|
1815
|
+
open,
|
|
1816
|
+
defaultOpen,
|
|
1817
|
+
onOpenChange,
|
|
1818
|
+
closeButtonAriaLabel = "Close",
|
|
1819
|
+
actions,
|
|
1820
|
+
panelToggle,
|
|
1821
|
+
snapPoints,
|
|
1822
|
+
defaultSnapPoint,
|
|
1823
|
+
snapPoint,
|
|
1824
|
+
onSnapPointChange,
|
|
1825
|
+
snapToSequentialPoints,
|
|
1826
|
+
disableCloseOnClickOutside,
|
|
1827
|
+
actionsInHeader,
|
|
1828
|
+
children
|
|
1829
|
+
}) => {
|
|
1830
|
+
const header = getChildByType2(children, PeekInHeader);
|
|
1831
|
+
const content = getChildByType2(children, PeekInContent);
|
|
1832
|
+
const panel = getChildByType2(children, PeekInPanel);
|
|
1833
|
+
const trigger = getChildByType2(children, PeekInTrigger);
|
|
1834
|
+
const panelDefaultOpen = panel?.props?.defaultOpen ?? true;
|
|
1835
|
+
const [panelOpen, setPanelOpen] = React24.useState(panelDefaultOpen);
|
|
1836
|
+
const panelId = React24.useId();
|
|
1837
|
+
const handleClose = React24.useCallback(() => {
|
|
1838
|
+
onOpenChange?.(false);
|
|
1839
|
+
}, [onOpenChange]);
|
|
1840
|
+
const contextValue = React24.useMemo(
|
|
1841
|
+
() => ({ onClose: handleClose, panelOpen, setPanelOpen, panelId }),
|
|
1842
|
+
[handleClose, panelOpen, panelId]
|
|
1843
|
+
);
|
|
1844
|
+
const ariaLabel = typeof header?.props?.title === "string" ? header.props.title : "Dialog";
|
|
1845
|
+
const triggerElement = trigger ? trigger.props.children : void 0;
|
|
1846
|
+
const modalActions = React24.useMemo(() => {
|
|
1847
|
+
const result = [];
|
|
1848
|
+
if (panelToggle && panel) {
|
|
1849
|
+
result.push({
|
|
1850
|
+
"aria-label": panelToggle["aria-label"] ?? "Toggle panel",
|
|
1851
|
+
iconName: panelToggle.iconName,
|
|
1852
|
+
onClick: () => setPanelOpen((prev) => !prev),
|
|
1853
|
+
"aria-expanded": panelOpen,
|
|
1854
|
+
"aria-controls": panelId
|
|
1855
|
+
});
|
|
1856
|
+
}
|
|
1857
|
+
if (actions) {
|
|
1858
|
+
result.push(...actions);
|
|
1859
|
+
}
|
|
1860
|
+
return result.length > 0 ? result : void 0;
|
|
1861
|
+
}, [panelToggle, panel, actions, panelOpen, panelId]);
|
|
1862
|
+
const drawerActions = React24.useMemo(() => {
|
|
1863
|
+
const result = [];
|
|
1864
|
+
if (panelToggle && panel) {
|
|
1865
|
+
result.push({
|
|
1866
|
+
"aria-label": panelToggle["aria-label"] ?? "Toggle panel",
|
|
1867
|
+
iconName: panelToggle.iconName,
|
|
1868
|
+
onClick: () => setPanelOpen((prev) => !prev),
|
|
1869
|
+
"aria-expanded": panelOpen,
|
|
1870
|
+
"aria-controls": panelId
|
|
1871
|
+
});
|
|
1872
|
+
}
|
|
1873
|
+
if (actions) {
|
|
1874
|
+
result.push(...actions);
|
|
1875
|
+
}
|
|
1876
|
+
return result.length > 0 ? result : void 0;
|
|
1877
|
+
}, [panelToggle, panel, actions, panelOpen, panelId]);
|
|
1878
|
+
const isMobile = useIsMobile3();
|
|
1879
|
+
const isControlled = open !== void 0;
|
|
1880
|
+
const [internalOpen, setInternalOpen] = React24.useState(defaultOpen ?? false);
|
|
1881
|
+
const effectiveMobileOpen = isControlled ? open ?? false : internalOpen;
|
|
1882
|
+
const handleMobileOpen = React24.useCallback(() => {
|
|
1883
|
+
if (!isControlled) setInternalOpen(true);
|
|
1884
|
+
onOpenChange?.(true);
|
|
1885
|
+
}, [isControlled, onOpenChange]);
|
|
1886
|
+
const handleMobileClose = React24.useCallback(() => {
|
|
1887
|
+
if (!isControlled) setInternalOpen(false);
|
|
1888
|
+
onOpenChange?.(false);
|
|
1889
|
+
}, [isControlled, onOpenChange]);
|
|
1890
|
+
const mobileTrigger = trigger ? React24.cloneElement(trigger.props.children, {
|
|
1891
|
+
onClick: handleMobileOpen
|
|
1892
|
+
}) : void 0;
|
|
1893
|
+
if (isMobile) {
|
|
1894
|
+
return /* @__PURE__ */ jsxs5(PeekInContext.Provider, { value: contextValue, children: [
|
|
1895
|
+
mobileTrigger,
|
|
1896
|
+
/* @__PURE__ */ jsxs5(
|
|
1897
|
+
Drawer3,
|
|
1898
|
+
{
|
|
1899
|
+
open: effectiveMobileOpen,
|
|
1900
|
+
onClose: handleMobileClose,
|
|
1901
|
+
direction: "bottom",
|
|
1902
|
+
closeButtonLabel: closeButtonAriaLabel,
|
|
1903
|
+
snapPoints,
|
|
1904
|
+
defaultSnapPoint,
|
|
1905
|
+
snapPoint,
|
|
1906
|
+
onSnapPointChange,
|
|
1907
|
+
snapToSequentialPoints,
|
|
1908
|
+
disableCloseOnClickOutside,
|
|
1909
|
+
actions: drawerActions,
|
|
1910
|
+
actionsInHeader,
|
|
1911
|
+
"aria-label": ariaLabel,
|
|
1912
|
+
children: [
|
|
1913
|
+
/* @__PURE__ */ jsx13(
|
|
1914
|
+
Drawer3.Header,
|
|
1915
|
+
{
|
|
1916
|
+
render: (ctx) => /* @__PURE__ */ jsxs5("div", { className: "seeds-peek-in-drawer-header", children: [
|
|
1917
|
+
/* @__PURE__ */ jsxs5("div", { className: "seeds-peek-in-titlegroup", children: [
|
|
1918
|
+
header?.props?.onBack && /* @__PURE__ */ jsx13(
|
|
1919
|
+
Button3,
|
|
1920
|
+
{
|
|
1921
|
+
appearance: "unstyled",
|
|
1922
|
+
onClick: header.props.onBack,
|
|
1923
|
+
"aria-label": "Back",
|
|
1924
|
+
"data-qa-peek-in-back": true,
|
|
1925
|
+
children: /* @__PURE__ */ jsx13(Icon3, { name: "arrow-left-outline", size: "small" })
|
|
1926
|
+
}
|
|
1927
|
+
),
|
|
1928
|
+
/* @__PURE__ */ jsx13(
|
|
1929
|
+
Text3,
|
|
1930
|
+
{
|
|
1931
|
+
as: "h2",
|
|
1932
|
+
fontSize: 400,
|
|
1933
|
+
fontWeight: "semibold",
|
|
1934
|
+
color: "text.headline",
|
|
1935
|
+
"data-qa-peek-in-title": true,
|
|
1936
|
+
children: header?.props?.title
|
|
1937
|
+
}
|
|
1938
|
+
)
|
|
1939
|
+
] }),
|
|
1940
|
+
/* @__PURE__ */ jsxs5("div", { className: "seeds-peek-in-header-actions", children: [
|
|
1941
|
+
header?.props?.children,
|
|
1942
|
+
actionsInHeader && panelToggle && panel && /* @__PURE__ */ jsx13(
|
|
1943
|
+
Button3,
|
|
1944
|
+
{
|
|
1945
|
+
appearance: "pill",
|
|
1946
|
+
"aria-label": panelToggle["aria-label"] ?? "Toggle panel",
|
|
1947
|
+
onClick: () => setPanelOpen((p) => !p),
|
|
1948
|
+
children: /* @__PURE__ */ jsx13(Icon3, { "aria-hidden": true, name: panelToggle.iconName })
|
|
1949
|
+
}
|
|
1950
|
+
),
|
|
1951
|
+
actionsInHeader && actions?.map((action, i) => /* @__PURE__ */ jsx13(
|
|
1952
|
+
Button3,
|
|
1953
|
+
{
|
|
1954
|
+
appearance: "pill",
|
|
1955
|
+
"aria-label": action["aria-label"],
|
|
1956
|
+
onClick: action.onClick,
|
|
1957
|
+
disabled: action.disabled,
|
|
1958
|
+
children: action.iconName && /* @__PURE__ */ jsx13(Icon3, { "aria-hidden": true, name: action.iconName })
|
|
1959
|
+
},
|
|
1960
|
+
i
|
|
1961
|
+
)),
|
|
1962
|
+
(actionsInHeader || !drawerActions) && /* @__PURE__ */ jsx13(
|
|
1963
|
+
Button3,
|
|
1964
|
+
{
|
|
1965
|
+
appearance: "pill",
|
|
1966
|
+
"aria-label": ctx.closeButtonLabel,
|
|
1967
|
+
onClick: ctx.onClose,
|
|
1968
|
+
children: /* @__PURE__ */ jsx13(Icon3, { "aria-hidden": true, name: "x-outline" })
|
|
1969
|
+
}
|
|
1970
|
+
)
|
|
1971
|
+
] })
|
|
1972
|
+
] })
|
|
1973
|
+
}
|
|
1974
|
+
),
|
|
1975
|
+
content,
|
|
1976
|
+
panel
|
|
1977
|
+
]
|
|
1978
|
+
}
|
|
1979
|
+
)
|
|
1980
|
+
] });
|
|
1981
|
+
}
|
|
1982
|
+
return /* @__PURE__ */ jsx13(PeekInContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx13(
|
|
1983
|
+
Modal2,
|
|
1984
|
+
{
|
|
1985
|
+
open,
|
|
1986
|
+
defaultOpen,
|
|
1987
|
+
onOpenChange,
|
|
1988
|
+
width: PEEK_IN_WIDTH,
|
|
1989
|
+
height: PEEK_IN_HEIGHT,
|
|
1990
|
+
closeButtonAriaLabel,
|
|
1991
|
+
"aria-label": ariaLabel,
|
|
1992
|
+
modalTrigger: triggerElement,
|
|
1993
|
+
actions: modalActions,
|
|
1994
|
+
bg: "transparent",
|
|
1995
|
+
children: /* @__PURE__ */ jsxs5(ModalBody2, { padding: 0, display: "flex", overflow: "hidden", children: [
|
|
1996
|
+
/* @__PURE__ */ jsxs5("div", { className: "seeds-peek-in-main", children: [
|
|
1997
|
+
header,
|
|
1998
|
+
content
|
|
1999
|
+
] }),
|
|
2000
|
+
panel
|
|
2001
|
+
] })
|
|
2002
|
+
}
|
|
2003
|
+
) });
|
|
2004
|
+
};
|
|
2005
|
+
PeekInTailwind.displayName = "PeekIn";
|
|
2006
|
+
|
|
2007
|
+
// src/PeekInHybrid.tsx
|
|
2008
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
2009
|
+
var PeekInHybrid = (props) => {
|
|
2010
|
+
if (hasStyledProps(props)) {
|
|
2011
|
+
return /* @__PURE__ */ jsx14(PeekInStyled, { ...props });
|
|
2012
|
+
}
|
|
2013
|
+
return /* @__PURE__ */ jsx14(PeekInTailwind, { ...props });
|
|
2014
|
+
};
|
|
2015
|
+
PeekInHybrid.displayName = "PeekIn";
|
|
2016
|
+
|
|
2017
|
+
// src/PeekIn.tsx
|
|
2018
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
2019
|
+
var PeekIn = (props) => /* @__PURE__ */ jsx15(PeekInHybrid, { ...props });
|
|
2020
|
+
PeekIn.displayName = "PeekIn";
|
|
1796
2021
|
export {
|
|
1797
2022
|
PeekIn,
|
|
1798
2023
|
PeekInContent,
|