@homebound/beam 2.224.0 → 2.225.0

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.
@@ -10,6 +10,7 @@ const PresentationContext_1 = require("./PresentationContext");
10
10
  const SnackbarContext_1 = require("./Snackbar/SnackbarContext");
11
11
  const SuperDrawer_1 = require("./SuperDrawer/SuperDrawer");
12
12
  const index_1 = require("../utils/index");
13
+ const Layout_1 = require("./Layout");
13
14
  const ToastContext_1 = require("./Toast/ToastContext");
14
15
  /** This is only exported internally, for useModal and useSuperDrawer, it's not a public API. */
15
16
  exports.BeamContext = (0, react_1.createContext)({
@@ -60,7 +61,7 @@ function BeamProvider({ children, ...presentationProps }) {
60
61
  sdHeaderDiv,
61
62
  };
62
63
  }, [modalBodyDiv, modalFooterDiv]);
63
- return ((0, jsx_runtime_1.jsx)(exports.BeamContext.Provider, Object.assign({ value: { ...context } }, { children: (0, jsx_runtime_1.jsx)(PresentationContext_1.PresentationProvider, Object.assign({}, presentationProps, { children: (0, jsx_runtime_1.jsx)(form_state_1.AutoSaveStatusProvider, { children: (0, jsx_runtime_1.jsx)(SnackbarContext_1.SnackbarProvider, { children: (0, jsx_runtime_1.jsxs)(ToastContext_1.ToastProvider, { children: [(0, jsx_runtime_1.jsxs)(react_aria_1.OverlayProvider, { children: [children, modalRef.current && (0, jsx_runtime_1.jsx)(Modal_1.Modal, Object.assign({}, modalRef.current), void 0)] }, void 0), (0, jsx_runtime_1.jsx)(SuperDrawer_1.SuperDrawer, {}, void 0)] }, void 0) }, void 0) }, void 0) }), void 0) }), void 0));
64
+ return ((0, jsx_runtime_1.jsx)(exports.BeamContext.Provider, Object.assign({ value: { ...context } }, { children: (0, jsx_runtime_1.jsx)(PresentationContext_1.PresentationProvider, Object.assign({}, presentationProps, { children: (0, jsx_runtime_1.jsx)(Layout_1.RightPaneProvider, { children: (0, jsx_runtime_1.jsx)(form_state_1.AutoSaveStatusProvider, { children: (0, jsx_runtime_1.jsx)(SnackbarContext_1.SnackbarProvider, { children: (0, jsx_runtime_1.jsxs)(ToastContext_1.ToastProvider, { children: [(0, jsx_runtime_1.jsxs)(react_aria_1.OverlayProvider, { children: [children, modalRef.current && (0, jsx_runtime_1.jsx)(Modal_1.Modal, Object.assign({}, modalRef.current), void 0)] }, void 0), (0, jsx_runtime_1.jsx)(SuperDrawer_1.SuperDrawer, {}, void 0)] }, void 0) }, void 0) }, void 0) }, void 0) }), void 0) }), void 0));
64
65
  }
65
66
  exports.BeamProvider = BeamProvider;
66
67
  /** Looks like a ref, but invokes a re-render on set (w/o changing the setter identity). */
@@ -0,0 +1,16 @@
1
+ import React, { ReactNode } from "react";
2
+ export interface OpenRightPaneOpts {
3
+ content: ReactNode;
4
+ }
5
+ export declare type RightPaneLayoutContextProps = {
6
+ openInPane: (opts: OpenRightPaneOpts) => void;
7
+ closePane: () => void;
8
+ clearPane: () => void;
9
+ isRightPaneOpen: Boolean;
10
+ rightPaneContent: ReactNode;
11
+ };
12
+ export declare const RightPaneContext: React.Context<RightPaneLayoutContextProps>;
13
+ export declare function RightPaneProvider({ children }: {
14
+ children: ReactNode;
15
+ }): import("@emotion/react/jsx-runtime").JSX.Element;
16
+ export declare function useRightPaneContext(): RightPaneLayoutContextProps;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.useRightPaneContext = exports.RightPaneProvider = exports.RightPaneContext = void 0;
23
+ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
24
+ const react_1 = __importStar(require("react"));
25
+ exports.RightPaneContext = react_1.default.createContext({
26
+ openInPane: () => { },
27
+ closePane: () => { },
28
+ clearPane: () => { },
29
+ isRightPaneOpen: false,
30
+ rightPaneContent: null,
31
+ });
32
+ function RightPaneProvider({ children }) {
33
+ // Note: separating the pane content from isOpen state to prevent animating when updating content.
34
+ const [rightPaneContent, setRightPaneContent] = (0, react_1.useState)(undefined);
35
+ const [isRightPaneOpen, setIsRightPaneOpen] = (0, react_1.useState)(false);
36
+ const openInPane = (0, react_1.useCallback)((opts) => {
37
+ setRightPaneContent(opts === null || opts === void 0 ? void 0 : opts.content);
38
+ setIsRightPaneOpen(true);
39
+ }, [setRightPaneContent]);
40
+ const closePane = (0, react_1.useCallback)(() => setIsRightPaneOpen(false), [setRightPaneContent]);
41
+ const clearPane = (0, react_1.useCallback)(() => setRightPaneContent(undefined), [setRightPaneContent]);
42
+ const context = (0, react_1.useMemo)(() => ({ openInPane, closePane, clearPane, rightPaneContent, isRightPaneOpen }), [openInPane, closePane, rightPaneContent, clearPane, isRightPaneOpen]);
43
+ return (0, jsx_runtime_1.jsx)(exports.RightPaneContext.Provider, Object.assign({ value: context }, { children: children }), void 0);
44
+ }
45
+ exports.RightPaneProvider = RightPaneProvider;
46
+ function useRightPaneContext() {
47
+ return (0, react_1.useContext)(exports.RightPaneContext);
48
+ }
49
+ exports.useRightPaneContext = useRightPaneContext;
@@ -0,0 +1,7 @@
1
+ import { ReactElement } from "react";
2
+ import { Palette } from "../../../Css";
3
+ export declare function RightPaneLayout({ children, paneBgColor, paneWidth, }: {
4
+ children: ReactElement;
5
+ paneBgColor?: Palette;
6
+ paneWidth?: number;
7
+ }): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RightPaneLayout = void 0;
4
+ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
5
+ const framer_motion_1 = require("framer-motion");
6
+ const Css_1 = require("../../../Css");
7
+ const RightPaneContext_1 = require("./RightPaneContext");
8
+ function RightPaneLayout({ children, paneBgColor = Css_1.Palette.White, paneWidth = 450, }) {
9
+ const { isRightPaneOpen, rightPaneContent, clearPane } = (0, RightPaneContext_1.useRightPaneContext)();
10
+ return ((0, jsx_runtime_1.jsx)("div", Object.assign({ css: Css_1.Css.h100.df.overflowXHidden.$ }, { children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ css: Css_1.Css.w(`calc(100% - ${paneWidth + 24}px)`)
11
+ .add("transition", "width .2s linear")
12
+ .h100.mr3.overflowXAuto.if(!isRightPaneOpen).w100.mr0.$ }, { children: children }), void 0), (0, jsx_runtime_1.jsx)(framer_motion_1.AnimatePresence, { children: isRightPaneOpen && ((0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, Object.assign({ layout: "position", "data-testid": "rightPaneContent", css: Css_1.Css.bgColor(paneBgColor).h100.wPx(paneWidth).$,
13
+ // Keeping initial x to offset pane width and space between panel and page content
14
+ initial: { x: paneWidth + 24 }, animate: { x: 0 }, transition: { ease: "linear", duration: 0.2 }, exit: { transition: { ease: "linear", duration: 0.2 }, x: paneWidth },
15
+ // Clear the content of the detail pane when the animation is completed and only when pane is closing
16
+ onAnimationComplete: (definition) => definition.x !== 0 && clearPane() }, { children: rightPaneContent }), "rightPane")) }, void 0)] }, void 0) }), void 0));
17
+ }
18
+ exports.RightPaneLayout = RightPaneLayout;
@@ -0,0 +1,3 @@
1
+ export * from "./RightPaneContext";
2
+ export * from "./RightPaneLayout";
3
+ export * from "./useRightPane";
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./RightPaneContext"), exports);
14
+ __exportStar(require("./RightPaneLayout"), exports);
15
+ __exportStar(require("./useRightPane"), exports);
@@ -0,0 +1,8 @@
1
+ import { OpenRightPaneOpts } from "./RightPaneContext";
2
+ export interface UseRightPaneHook {
3
+ /** Opens a right pane */
4
+ openRightPane: (opts: OpenRightPaneOpts) => void;
5
+ /** Closes the right pane */
6
+ closeRightPane: () => void;
7
+ }
8
+ export declare function useRightPane(): UseRightPaneHook;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useRightPane = void 0;
4
+ const RightPaneContext_1 = require("./RightPaneContext");
5
+ function useRightPane() {
6
+ const { openInPane, closePane } = (0, RightPaneContext_1.useRightPaneContext)();
7
+ return {
8
+ openRightPane: openInPane,
9
+ closeRightPane: closePane,
10
+ };
11
+ }
12
+ exports.useRightPane = useRightPane;
@@ -1,4 +1,5 @@
1
1
  export * from "./FullBleed";
2
2
  export * from "./PreventBrowserScroll";
3
+ export * from "./RightPaneLayout";
3
4
  export * from "./ScrollableContent";
4
5
  export * from "./ScrollableParent";
@@ -12,5 +12,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./FullBleed"), exports);
14
14
  __exportStar(require("./PreventBrowserScroll"), exports);
15
+ __exportStar(require("./RightPaneLayout"), exports);
15
16
  __exportStar(require("./ScrollableContent"), exports);
16
17
  __exportStar(require("./ScrollableParent"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.224.0",
3
+ "version": "2.225.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",