@homebound/beam 2.157.3 → 2.158.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.
@@ -12,6 +12,7 @@ const components_1 = require("..");
12
12
  const BeamContext_1 = require("../BeamContext");
13
13
  const Css_1 = require("../../Css");
14
14
  const utils_1 = require("../../utils");
15
+ const utils_2 = require("./utils");
15
16
  /**
16
17
  * Global drawer component.
17
18
  *
@@ -59,6 +60,7 @@ function SuperDrawer() {
59
60
  const { onPrevClick, onNextClick, titleRightContent, titleLeftContent, hideControls } = firstContent !== null && firstContent !== void 0 ? firstContent : {};
60
61
  const isDetail = currentContent !== firstContent;
61
62
  const title = content === undefined ? '' : currentContent.title || firstContent.title;
63
+ const { width = utils_2.SuperDrawerWidth.Normal } = firstContent !== null && firstContent !== void 0 ? firstContent : {};
62
64
  return (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)(framer_motion_1.AnimatePresence, { children: content && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_2.Global, { styles: { body: Css_1.Css.overflowHidden.$ } }, void 0), (0, react_1.createElement)(framer_motion_1.motion.div, { ...testId,
63
65
  // Key is required for framer-motion animations
64
66
  key: "superDrawer",
@@ -72,11 +74,11 @@ function SuperDrawer() {
72
74
  animate: { opacity: 1 },
73
75
  // Unmount styles
74
76
  exit: { opacity: 0, transition: { delay: 0.2 } }, onClick: closeDrawer },
75
- (0, jsx_runtime_1.jsx)(framer_motion_1.motion.aside, Object.assign({ css: Css_1.Css.bgWhite.h100.maxw((0, Css_1.px)(1040)).w100.df.fdc.relative.$,
77
+ (0, jsx_runtime_1.jsx)(framer_motion_1.motion.aside, Object.assign({ css: Css_1.Css.bgWhite.h100.maxw((0, Css_1.px)(width)).w100.df.fdc.relative.$,
76
78
  // Keeping initial x to 1040 as this will still work if the container is smaller
77
- initial: { x: 1040 }, animate: { x: 0 },
79
+ initial: { x: width }, animate: { x: 0 },
78
80
  // Custom transitions settings for the translateX animation
79
- transition: { ease: "linear", duration: 0.2, delay: 0.2 }, exit: { transition: { ease: "linear", duration: 0.2 }, x: 1040 },
81
+ transition: { ease: "linear", duration: 0.2, delay: 0.2 }, exit: { transition: { ease: "linear", duration: 0.2 }, x: width },
80
82
  // Preventing clicks from triggering parent onClick
81
83
  onClick: (e) => e.stopPropagation() }, { children: (0, jsx_runtime_1.jsxs)(form_state_1.AutoSaveStatusProvider, { children: [(0, jsx_runtime_1.jsxs)("header", Object.assign({ css: Css_1.Css.df.p3.bb.bGray200.df.aic.jcsb.gap2.$ }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.df.aic.$ }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ css: Css_1.Css.xl2Em.gray900.mr2.$ }, testId.title, { ref: drawerHeaderRef }, { children: !modalState.current && (title || null) }), void 0), !modalState.current && (titleLeftContent || null)] }), void 0), !modalState.current && (
82
84
  // Forcing height to 32px to match title height
@@ -7,6 +7,7 @@ const BeamContext_1 = require("../BeamContext");
7
7
  const Button_1 = require("../Button");
8
8
  const useSuperDrawer_1 = require("./useSuperDrawer");
9
9
  const Css_1 = require("../../Css");
10
+ const utils_1 = require("./utils");
10
11
  /**
11
12
  * Helper component to place the given children and actions into the appropriate
12
13
  * DOM format to render inside the SuperDrawer.
@@ -15,17 +16,19 @@ const Css_1 = require("../../Css");
15
16
  * that knows how to handle the title, prev/next link and the onClose handler.
16
17
  */
17
18
  const SuperDrawerContent = ({ children, actions }) => {
18
- var _a;
19
+ var _a, _b;
19
20
  const { closeDrawerDetail } = (0, useSuperDrawer_1.useSuperDrawer)();
20
21
  const { drawerContentStack: contentStack } = (0, BeamContext_1.useBeamContext)();
21
22
  // Determine if the current element is a new content element or an detail element
22
23
  const { kind } = (_a = contentStack.current[contentStack.current.length - 1]) !== null && _a !== void 0 ? _a : {};
24
+ const firstContent = (_b = contentStack.current[0]) === null || _b === void 0 ? void 0 : _b.opts;
25
+ const { width = utils_1.SuperDrawerWidth.Normal } = firstContent !== null && firstContent !== void 0 ? firstContent : {};
23
26
  function wrapWithMotionAndMaybeBack(children) {
24
27
  if (kind === "open") {
25
28
  return ((0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, Object.assign({ css: Css_1.Css.p3.fg1.overflowAuto.$ }, { children: children }), "content"));
26
29
  }
27
30
  else if (kind === "detail") {
28
- return ((0, jsx_runtime_1.jsxs)(framer_motion_1.motion.div, Object.assign({ css: Css_1.Css.px3.pt2.pb3.fg1.$, animate: { overflow: "auto" }, transition: { overflow: { delay: 0.3 } } }, { children: [(0, jsx_runtime_1.jsx)(Button_1.Button, { label: "Back", icon: "chevronLeft", variant: "tertiary", onClick: closeDrawerDetail }, void 0), (0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, Object.assign({ initial: { x: 1040, opacity: 0 }, animate: { x: 0, opacity: 1 }, transition: { ease: "linear", duration: 0.3, opacity: { delay: 0.15 } }, exit: { x: 1040, opacity: 0 }, css: Css_1.Css.pt2.$ }, { children: children }), void 0)] }), "content"));
31
+ return ((0, jsx_runtime_1.jsxs)(framer_motion_1.motion.div, Object.assign({ css: Css_1.Css.px3.pt2.pb3.fg1.$, animate: { overflow: "auto" }, transition: { overflow: { delay: 0.3 } } }, { children: [(0, jsx_runtime_1.jsx)(Button_1.Button, { label: "Back", icon: "chevronLeft", variant: "tertiary", onClick: closeDrawerDetail }, void 0), (0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, Object.assign({ initial: { x: width, opacity: 0 }, animate: { x: 0, opacity: 1 }, transition: { ease: "linear", duration: 0.3, opacity: { delay: 0.15 } }, exit: { x: width, opacity: 0 }, css: Css_1.Css.pt2.$ }, { children: children }), void 0)] }), "content"));
29
32
  }
30
33
  else {
31
34
  // Hides content changes when closing the drawer
@@ -1,3 +1,4 @@
1
1
  export * from "./ConfirmCloseModal";
2
2
  export * from "./SuperDrawerContent";
3
3
  export * from "./useSuperDrawer";
4
+ export * from "./utils";
@@ -14,3 +14,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
14
14
  __exportStar(require("./ConfirmCloseModal"), exports);
15
15
  __exportStar(require("./SuperDrawerContent"), exports);
16
16
  __exportStar(require("./useSuperDrawer"), exports);
17
+ __exportStar(require("./utils"), exports);
@@ -1,5 +1,6 @@
1
1
  import { ReactNode } from "react";
2
2
  import { CanCloseCheck } from "../../types";
3
+ import { SuperDrawerWidth } from "./utils";
3
4
  export interface OpenInDrawerOpts {
4
5
  /** Title of the SuperDrawer */
5
6
  title: string;
@@ -16,6 +17,8 @@ export interface OpenInDrawerOpts {
16
17
  /** Adds a callback that is called _after_ close has definitely happened. */
17
18
  onClose?: () => void;
18
19
  content: ReactNode;
20
+ /** Adds the ability to change the SuperDrawer width based on some pre-defined values */
21
+ width?: SuperDrawerWidth;
19
22
  }
20
23
  export interface OpenDetailOpts {
21
24
  /** Title of the SuperDrawer for this detail page (replaces the original title). */
@@ -0,0 +1,4 @@
1
+ export declare enum SuperDrawerWidth {
2
+ Small = 560,
3
+ Normal = 1040
4
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SuperDrawerWidth = void 0;
4
+ var SuperDrawerWidth;
5
+ (function (SuperDrawerWidth) {
6
+ SuperDrawerWidth[SuperDrawerWidth["Small"] = 560] = "Small";
7
+ SuperDrawerWidth[SuperDrawerWidth["Normal"] = 1040] = "Normal";
8
+ })(SuperDrawerWidth = exports.SuperDrawerWidth || (exports.SuperDrawerWidth = {}));
9
+ ;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.157.3",
3
+ "version": "2.158.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",