@homebound/beam 2.71.4 → 2.71.5

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.
@@ -1,8 +1,16 @@
1
1
  import { ModalProps } from "./Modal";
2
+ export interface OpenModalProps {
3
+ /** The custom modal content to show. */
4
+ children: JSX.Element;
5
+ /** The size to use. */
6
+ size?: ModalProps["size"];
7
+ /** Whether to force the modal to stay open. This is useful for stories where ruler/tape extensions cause the modal to close. */
8
+ keepOpen?: boolean;
9
+ }
2
10
  /**
3
- * A component for testing open modals in unit tests.
11
+ * A component for testing open modals in stories and unit tests.
4
12
  *
5
- * Current, calling `render(<ModalComponent />)` in a test currently doesn't work, because
13
+ * Currently, calling `render(<ModalComponent />)` in a test currently doesn't work, because
6
14
  * nothing has called `useModal` to get the header & footer mounted into the DOM.
7
15
  *
8
16
  * So instead tests can call:
@@ -18,7 +26,4 @@ import { ModalProps } from "./Modal";
18
26
  * And `OpenModal` will do a boilerplate `openModal` call, so that the content
19
27
  * shows up in the DOM as expected.
20
28
  */
21
- export declare function OpenModal(props: {
22
- children: JSX.Element;
23
- size?: ModalProps["size"];
24
- }): JSX.Element;
29
+ export declare function OpenModal(props: OpenModalProps): JSX.Element;
@@ -3,11 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OpenModal = void 0;
4
4
  const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
5
5
  const react_1 = require("react");
6
+ const Modal_1 = require("./Modal");
6
7
  const useModal_1 = require("./useModal");
7
8
  /**
8
- * A component for testing open modals in unit tests.
9
+ * A component for testing open modals in stories and unit tests.
9
10
  *
10
- * Current, calling `render(<ModalComponent />)` in a test currently doesn't work, because
11
+ * Currently, calling `render(<ModalComponent />)` in a test currently doesn't work, because
11
12
  * nothing has called `useModal` to get the header & footer mounted into the DOM.
12
13
  *
13
14
  * So instead tests can call:
@@ -25,8 +26,17 @@ const useModal_1 = require("./useModal");
25
26
  */
26
27
  function OpenModal(props) {
27
28
  const { openModal } = (0, useModal_1.useModal)();
28
- const { size, children } = props;
29
- (0, react_1.useEffect)(() => openModal({ size, content: children }), [openModal, size, children]);
30
- return (0, jsx_runtime_1.jsx)("div", { children: "dummy content" }, void 0);
29
+ const { size, children, keepOpen } = props;
30
+ (0, react_1.useEffect)(() => {
31
+ if (!keepOpen) {
32
+ openModal({ size, content: children });
33
+ }
34
+ }, [keepOpen, openModal, size, children]);
35
+ if (keepOpen) {
36
+ return (0, jsx_runtime_1.jsx)(Modal_1.Modal, { size: size, content: children }, void 0);
37
+ }
38
+ else {
39
+ return (0, jsx_runtime_1.jsx)("div", { children: "dummy content" }, void 0);
40
+ }
31
41
  }
32
42
  exports.OpenModal = OpenModal;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.71.4",
3
+ "version": "2.71.5",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",