@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/index.d.mts CHANGED
@@ -129,8 +129,17 @@ declare const PeekInPanel: React.FC<TypePeekInPanelProps>;
129
129
 
130
130
  declare const PeekInTrigger: React.FC<TypePeekInTriggerProps>;
131
131
 
132
+ /**
133
+ * PeekIn component. Automatically routes between the Tailwind implementation
134
+ * (preferred) and the styled-system implementation (for consumers using system
135
+ * props or a styled() extension).
136
+ *
137
+ * Defined as a self-named component (rather than a bare re-export of
138
+ * PeekInHybrid) so the `react-docgen` props-docs generation in the Publish
139
+ * pipeline has a suitable component definition to analyze.
140
+ */
132
141
  declare const PeekIn: {
133
- ({ open, defaultOpen, onOpenChange, closeButtonAriaLabel, actions, panelToggle, snapPoints, defaultSnapPoint, snapPoint, onSnapPointChange, snapToSequentialPoints, disableCloseOnClickOutside, actionsInHeader, children, }: TypePeekInProps): react_jsx_runtime.JSX.Element;
142
+ (props: TypePeekInProps): react_jsx_runtime.JSX.Element;
134
143
  displayName: string;
135
144
  };
136
145
 
package/dist/index.d.ts CHANGED
@@ -129,8 +129,17 @@ declare const PeekInPanel: React.FC<TypePeekInPanelProps>;
129
129
 
130
130
  declare const PeekInTrigger: React.FC<TypePeekInTriggerProps>;
131
131
 
132
+ /**
133
+ * PeekIn component. Automatically routes between the Tailwind implementation
134
+ * (preferred) and the styled-system implementation (for consumers using system
135
+ * props or a styled() extension).
136
+ *
137
+ * Defined as a self-named component (rather than a bare re-export of
138
+ * PeekInHybrid) so the `react-docgen` props-docs generation in the Publish
139
+ * pipeline has a suitable component definition to analyze.
140
+ */
132
141
  declare const PeekIn: {
133
- ({ open, defaultOpen, onOpenChange, closeButtonAriaLabel, actions, panelToggle, snapPoints, defaultSnapPoint, snapPoint, onSnapPointChange, snapToSequentialPoints, disableCloseOnClickOutside, actionsInHeader, children, }: TypePeekInProps): react_jsx_runtime.JSX.Element;
142
+ (props: TypePeekInProps): react_jsx_runtime.JSX.Element;
134
143
  displayName: string;
135
144
  };
136
145
 
package/dist/index.js CHANGED
@@ -38,7 +38,10 @@ __export(index_exports, {
38
38
  });
39
39
  module.exports = __toCommonJS(index_exports);
40
40
 
41
- // src/PeekIn.tsx
41
+ // src/PeekInHybrid.tsx
42
+ var import_seeds_react_system_props = require("@sproutsocial/seeds-react-system-props");
43
+
44
+ // src/PeekInStyled.tsx
42
45
  var React21 = __toESM(require("react"));
43
46
  var import_seeds_react_box4 = __toESM(require("@sproutsocial/seeds-react-box"));
44
47
  var import_seeds_react_button2 = __toESM(require("@sproutsocial/seeds-react-button"));
@@ -1610,7 +1613,7 @@ var PeekInTrigger = ({
1610
1613
  };
1611
1614
  PeekInTrigger.displayName = "PeekInTrigger";
1612
1615
 
1613
- // src/PeekIn.tsx
1616
+ // src/PeekInStyled.tsx
1614
1617
  var import_jsx_runtime12 = require("react/jsx-runtime");
1615
1618
  function getChildByType(children, type) {
1616
1619
  const childArray = React21.Children.toArray(children);
@@ -1618,7 +1621,7 @@ function getChildByType(children, type) {
1618
1621
  (child) => React21.isValidElement(child) && child.type === type
1619
1622
  ) || null;
1620
1623
  }
1621
- var PeekInRoot = ({
1624
+ var PeekInStyled = ({
1622
1625
  open,
1623
1626
  defaultOpen,
1624
1627
  onOpenChange,
@@ -1831,8 +1834,230 @@ var PeekInRoot = ({
1831
1834
  }
1832
1835
  ) });
1833
1836
  };
1834
- PeekInRoot.displayName = "PeekIn";
1835
- var PeekIn = PeekInRoot;
1837
+ PeekInStyled.displayName = "PeekIn";
1838
+
1839
+ // src/PeekInTailwind.tsx
1840
+ var React24 = __toESM(require("react"));
1841
+ var import_seeds_react_button3 = __toESM(require("@sproutsocial/seeds-react-button"));
1842
+ var import_seeds_react_drawer3 = __toESM(require("@sproutsocial/seeds-react-drawer"));
1843
+ var import_seeds_react_icon3 = __toESM(require("@sproutsocial/seeds-react-icon"));
1844
+ var import_seeds_react_text3 = __toESM(require("@sproutsocial/seeds-react-text"));
1845
+ var import_seeds_react_hooks3 = require("@sproutsocial/seeds-react-hooks");
1846
+ var import_v22 = require("@sproutsocial/seeds-react-modal/v2");
1847
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1848
+ function getChildByType2(children, type) {
1849
+ const childArray = React24.Children.toArray(children);
1850
+ return childArray.find(
1851
+ (child) => React24.isValidElement(child) && child.type === type
1852
+ ) || null;
1853
+ }
1854
+ var PeekInTailwind = ({
1855
+ open,
1856
+ defaultOpen,
1857
+ onOpenChange,
1858
+ closeButtonAriaLabel = "Close",
1859
+ actions,
1860
+ panelToggle,
1861
+ snapPoints,
1862
+ defaultSnapPoint,
1863
+ snapPoint,
1864
+ onSnapPointChange,
1865
+ snapToSequentialPoints,
1866
+ disableCloseOnClickOutside,
1867
+ actionsInHeader,
1868
+ children
1869
+ }) => {
1870
+ const header = getChildByType2(children, PeekInHeader);
1871
+ const content = getChildByType2(children, PeekInContent);
1872
+ const panel = getChildByType2(children, PeekInPanel);
1873
+ const trigger = getChildByType2(children, PeekInTrigger);
1874
+ const panelDefaultOpen = panel?.props?.defaultOpen ?? true;
1875
+ const [panelOpen, setPanelOpen] = React24.useState(panelDefaultOpen);
1876
+ const panelId = React24.useId();
1877
+ const handleClose = React24.useCallback(() => {
1878
+ onOpenChange?.(false);
1879
+ }, [onOpenChange]);
1880
+ const contextValue = React24.useMemo(
1881
+ () => ({ onClose: handleClose, panelOpen, setPanelOpen, panelId }),
1882
+ [handleClose, panelOpen, panelId]
1883
+ );
1884
+ const ariaLabel = typeof header?.props?.title === "string" ? header.props.title : "Dialog";
1885
+ const triggerElement = trigger ? trigger.props.children : void 0;
1886
+ const modalActions = React24.useMemo(() => {
1887
+ const result = [];
1888
+ if (panelToggle && panel) {
1889
+ result.push({
1890
+ "aria-label": panelToggle["aria-label"] ?? "Toggle panel",
1891
+ iconName: panelToggle.iconName,
1892
+ onClick: () => setPanelOpen((prev) => !prev),
1893
+ "aria-expanded": panelOpen,
1894
+ "aria-controls": panelId
1895
+ });
1896
+ }
1897
+ if (actions) {
1898
+ result.push(...actions);
1899
+ }
1900
+ return result.length > 0 ? result : void 0;
1901
+ }, [panelToggle, panel, actions, panelOpen, panelId]);
1902
+ const drawerActions = React24.useMemo(() => {
1903
+ const result = [];
1904
+ if (panelToggle && panel) {
1905
+ result.push({
1906
+ "aria-label": panelToggle["aria-label"] ?? "Toggle panel",
1907
+ iconName: panelToggle.iconName,
1908
+ onClick: () => setPanelOpen((prev) => !prev),
1909
+ "aria-expanded": panelOpen,
1910
+ "aria-controls": panelId
1911
+ });
1912
+ }
1913
+ if (actions) {
1914
+ result.push(...actions);
1915
+ }
1916
+ return result.length > 0 ? result : void 0;
1917
+ }, [panelToggle, panel, actions, panelOpen, panelId]);
1918
+ const isMobile = (0, import_seeds_react_hooks3.useIsMobile)();
1919
+ const isControlled = open !== void 0;
1920
+ const [internalOpen, setInternalOpen] = React24.useState(defaultOpen ?? false);
1921
+ const effectiveMobileOpen = isControlled ? open ?? false : internalOpen;
1922
+ const handleMobileOpen = React24.useCallback(() => {
1923
+ if (!isControlled) setInternalOpen(true);
1924
+ onOpenChange?.(true);
1925
+ }, [isControlled, onOpenChange]);
1926
+ const handleMobileClose = React24.useCallback(() => {
1927
+ if (!isControlled) setInternalOpen(false);
1928
+ onOpenChange?.(false);
1929
+ }, [isControlled, onOpenChange]);
1930
+ const mobileTrigger = trigger ? React24.cloneElement(trigger.props.children, {
1931
+ onClick: handleMobileOpen
1932
+ }) : void 0;
1933
+ if (isMobile) {
1934
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(PeekInContext.Provider, { value: contextValue, children: [
1935
+ mobileTrigger,
1936
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
1937
+ import_seeds_react_drawer3.default,
1938
+ {
1939
+ open: effectiveMobileOpen,
1940
+ onClose: handleMobileClose,
1941
+ direction: "bottom",
1942
+ closeButtonLabel: closeButtonAriaLabel,
1943
+ snapPoints,
1944
+ defaultSnapPoint,
1945
+ snapPoint,
1946
+ onSnapPointChange,
1947
+ snapToSequentialPoints,
1948
+ disableCloseOnClickOutside,
1949
+ actions: drawerActions,
1950
+ actionsInHeader,
1951
+ "aria-label": ariaLabel,
1952
+ children: [
1953
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1954
+ import_seeds_react_drawer3.default.Header,
1955
+ {
1956
+ render: (ctx) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "seeds-peek-in-drawer-header", children: [
1957
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "seeds-peek-in-titlegroup", children: [
1958
+ header?.props?.onBack && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1959
+ import_seeds_react_button3.default,
1960
+ {
1961
+ appearance: "unstyled",
1962
+ onClick: header.props.onBack,
1963
+ "aria-label": "Back",
1964
+ "data-qa-peek-in-back": true,
1965
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_seeds_react_icon3.default, { name: "arrow-left-outline", size: "small" })
1966
+ }
1967
+ ),
1968
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1969
+ import_seeds_react_text3.default,
1970
+ {
1971
+ as: "h2",
1972
+ fontSize: 400,
1973
+ fontWeight: "semibold",
1974
+ color: "text.headline",
1975
+ "data-qa-peek-in-title": true,
1976
+ children: header?.props?.title
1977
+ }
1978
+ )
1979
+ ] }),
1980
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "seeds-peek-in-header-actions", children: [
1981
+ header?.props?.children,
1982
+ actionsInHeader && panelToggle && panel && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1983
+ import_seeds_react_button3.default,
1984
+ {
1985
+ appearance: "pill",
1986
+ "aria-label": panelToggle["aria-label"] ?? "Toggle panel",
1987
+ onClick: () => setPanelOpen((p) => !p),
1988
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_seeds_react_icon3.default, { "aria-hidden": true, name: panelToggle.iconName })
1989
+ }
1990
+ ),
1991
+ actionsInHeader && actions?.map((action, i) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1992
+ import_seeds_react_button3.default,
1993
+ {
1994
+ appearance: "pill",
1995
+ "aria-label": action["aria-label"],
1996
+ onClick: action.onClick,
1997
+ disabled: action.disabled,
1998
+ children: action.iconName && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_seeds_react_icon3.default, { "aria-hidden": true, name: action.iconName })
1999
+ },
2000
+ i
2001
+ )),
2002
+ (actionsInHeader || !drawerActions) && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2003
+ import_seeds_react_button3.default,
2004
+ {
2005
+ appearance: "pill",
2006
+ "aria-label": ctx.closeButtonLabel,
2007
+ onClick: ctx.onClose,
2008
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_seeds_react_icon3.default, { "aria-hidden": true, name: "x-outline" })
2009
+ }
2010
+ )
2011
+ ] })
2012
+ ] })
2013
+ }
2014
+ ),
2015
+ content,
2016
+ panel
2017
+ ]
2018
+ }
2019
+ )
2020
+ ] });
2021
+ }
2022
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(PeekInContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2023
+ import_v22.Modal,
2024
+ {
2025
+ open,
2026
+ defaultOpen,
2027
+ onOpenChange,
2028
+ width: PEEK_IN_WIDTH,
2029
+ height: PEEK_IN_HEIGHT,
2030
+ closeButtonAriaLabel,
2031
+ "aria-label": ariaLabel,
2032
+ modalTrigger: triggerElement,
2033
+ actions: modalActions,
2034
+ bg: "transparent",
2035
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_v22.ModalBody, { padding: 0, display: "flex", overflow: "hidden", children: [
2036
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "seeds-peek-in-main", children: [
2037
+ header,
2038
+ content
2039
+ ] }),
2040
+ panel
2041
+ ] })
2042
+ }
2043
+ ) });
2044
+ };
2045
+ PeekInTailwind.displayName = "PeekIn";
2046
+
2047
+ // src/PeekInHybrid.tsx
2048
+ var import_jsx_runtime14 = require("react/jsx-runtime");
2049
+ var PeekInHybrid = (props) => {
2050
+ if ((0, import_seeds_react_system_props.hasStyledProps)(props)) {
2051
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(PeekInStyled, { ...props });
2052
+ }
2053
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(PeekInTailwind, { ...props });
2054
+ };
2055
+ PeekInHybrid.displayName = "PeekIn";
2056
+
2057
+ // src/PeekIn.tsx
2058
+ var import_jsx_runtime15 = require("react/jsx-runtime");
2059
+ var PeekIn = (props) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(PeekInHybrid, { ...props });
2060
+ PeekIn.displayName = "PeekIn";
1836
2061
  // Annotate the CommonJS export names for ESM import in node:
1837
2062
  0 && (module.exports = {
1838
2063
  PeekIn,