@homebound/beam 2.157.0 → 2.157.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.
@@ -33,6 +33,7 @@ const utils_1 = require("../../utils");
33
33
  * above the SuperDrawer.
34
34
  */
35
35
  function SuperDrawer() {
36
+ var _a, _b;
36
37
  const { drawerContentStack: contentStack, modalState, modalBodyDiv, modalFooterDiv, modalHeaderDiv, } = (0, BeamContext_1.useBeamContext)();
37
38
  const { closeDrawer } = (0, components_1.useSuperDrawer)();
38
39
  const drawerHeaderRef = (0, react_3.useRef)(null);
@@ -48,17 +49,16 @@ function SuperDrawer() {
48
49
  }
49
50
  // eslint-disable-next-line react-hooks/exhaustive-deps
50
51
  }, [modalBodyRef.current, modalFooterRef.current, modalState.current]);
51
- if (contentStack.current.length === 0) {
52
- return null;
53
- }
54
52
  // Get the latest element on the stack
55
- const currentContent = contentStack.current[contentStack.current.length - 1].opts;
56
- const { content } = currentContent;
53
+ // We use undefined, nullish operators and empty object here to allow AnimatePresence
54
+ // to animate the drawers exit transition when our stack is empty
55
+ const currentContent = (_a = contentStack.current[contentStack.current.length - 1]) === null || _a === void 0 ? void 0 : _a.opts;
56
+ const { content } = currentContent !== null && currentContent !== void 0 ? currentContent : {};
57
57
  // Also get the first / non-detail element on the stack
58
- const firstContent = contentStack.current[0].opts;
59
- const { onPrevClick, onNextClick, titleRightContent, titleLeftContent, hideControls } = firstContent;
58
+ const firstContent = (_b = contentStack.current[0]) === null || _b === void 0 ? void 0 : _b.opts;
59
+ const { onPrevClick, onNextClick, titleRightContent, titleLeftContent, hideControls } = firstContent !== null && firstContent !== void 0 ? firstContent : {};
60
60
  const isDetail = currentContent !== firstContent;
61
- const title = currentContent.title || firstContent.title;
61
+ const title = content === undefined ? '' : currentContent.title || firstContent.title;
62
62
  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
63
  // Key is required for framer-motion animations
64
64
  key: "superDrawer",
@@ -15,10 +15,11 @@ const Css_1 = require("../../Css");
15
15
  * that knows how to handle the title, prev/next link and the onClose handler.
16
16
  */
17
17
  const SuperDrawerContent = ({ children, actions }) => {
18
+ var _a;
18
19
  const { closeDrawerDetail } = (0, useSuperDrawer_1.useSuperDrawer)();
19
20
  const { drawerContentStack: contentStack } = (0, BeamContext_1.useBeamContext)();
20
21
  // Determine if the current element is a new content element or an detail element
21
- const { kind } = contentStack.current[contentStack.current.length - 1];
22
+ const { kind } = (_a = contentStack.current[contentStack.current.length - 1]) !== null && _a !== void 0 ? _a : {};
22
23
  function wrapWithMotionAndMaybeBack(children) {
23
24
  if (kind === "open") {
24
25
  return ((0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, Object.assign({ css: Css_1.Css.p3.fg1.overflowAuto.$ }, { children: children }), "content"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.157.0",
3
+ "version": "2.157.1",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",