@homebound/beam 2.325.2 → 2.326.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.
@@ -60,10 +60,7 @@ function BeamProvider({ children, ...presentationProps }) {
60
60
  drawerCanCloseDetailsChecks,
61
61
  sdHeaderDiv,
62
62
  };
63
- },
64
- // TODO: validate this eslint-disable. It was automatically ignored as part of https://app.shortcut.com/homebound-team/story/40033/enable-react-hooks-exhaustive-deps-for-react-projects
65
- // eslint-disable-next-line react-hooks/exhaustive-deps
66
- [modalBodyDiv, modalFooterDiv]);
63
+ }, [modalBodyDiv, modalFooterDiv, modalHeaderDiv, sdHeaderDiv]);
67
64
  return ((0, jsx_runtime_1.jsx)(exports.BeamContext.Provider, { value: { ...context }, children: (0, jsx_runtime_1.jsx)(PresentationContext_1.PresentationProvider, { ...presentationProps, children: (0, jsx_runtime_1.jsx)(Layout_1.RightPaneProvider, { children: (0, jsx_runtime_1.jsx)(index_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, { ...modalRef.current })] }), (0, jsx_runtime_1.jsx)(SuperDrawer_1.SuperDrawer, {})] }) }) }) }) }) }));
68
65
  }
69
66
  exports.BeamProvider = BeamProvider;
@@ -12,6 +12,7 @@ const IconButton_1 = require("../IconButton");
12
12
  const useModal_1 = require("./useModal");
13
13
  const Css_1 = require("../../Css");
14
14
  const utils_2 = require("../../utils");
15
+ const ModalContext_1 = require("./ModalContext");
15
16
  /**
16
17
  * Internal component for displaying a Modal; see `useModal` for the public API.
17
18
  *
@@ -67,12 +68,12 @@ function Modal(props) {
67
68
  // TODO: validate this eslint-disable. It was automatically ignored as part of https://app.shortcut.com/homebound-team/story/40033/enable-react-hooks-exhaustive-deps-for-react-projects
68
69
  // eslint-disable-next-line react-hooks/exhaustive-deps
69
70
  [modalBodyRef, modalFooterRef, modalHeaderRef]);
70
- return ((0, jsx_runtime_1.jsx)(react_aria_1.OverlayContainer, { children: (0, jsx_runtime_1.jsx)(components_1.AutoSaveStatusProvider, { children: (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.underlay.z4.$, ...underlayProps, ...testId.underlay, children: (0, jsx_runtime_1.jsx)(react_aria_1.FocusScope, { contain: true, restoreFocus: true, autoFocus: true, children: (0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.br24.bgWhite.bshModal.overflowHidden
71
- .maxh("90vh")
72
- .df.fdc.wPx(width)
73
- .mhPx(defaultMinHeight)
74
- .if(isFixedHeight)
75
- .hPx(height).$, ref: ref, ...overlayProps, ...dialogProps, ...modalProps, ...testId, children: [(0, jsx_runtime_1.jsxs)("header", { css: Css_1.Css.df.p3.fs0.if(drawHeaderBorder).bb.bGray200.$, children: [(0, jsx_runtime_1.jsx)("h1", { css: Css_1.Css.fg1.xl2Sb.gray900.$, ref: modalHeaderRef, ...titleProps, ...testId.title }), (0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.fs0.pl1.$, children: (0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { icon: "x", onClick: closeModal, ...testId.titleClose }) })] }), (0, jsx_runtime_1.jsx)("main", { ref: modalBodyRef, css: Css_1.Css.fg1.overflowYAuto.if(hasScroll).bb.bGray200.if(!!forceScrolling).overflowYScroll.$, children: content }), (0, jsx_runtime_1.jsx)("footer", { css: Css_1.Css.fs0.$, children: (0, jsx_runtime_1.jsx)("div", { ref: modalFooterRef }) })] }) }) }) }) }));
71
+ return ((0, jsx_runtime_1.jsx)(ModalContext_1.ModalProvider, { children: (0, jsx_runtime_1.jsx)(react_aria_1.OverlayContainer, { children: (0, jsx_runtime_1.jsx)(components_1.AutoSaveStatusProvider, { children: (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.underlay.z4.$, ...underlayProps, ...testId.underlay, children: (0, jsx_runtime_1.jsx)(react_aria_1.FocusScope, { contain: true, restoreFocus: true, autoFocus: true, children: (0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.br24.bgWhite.bshModal.overflowHidden
72
+ .maxh("90vh")
73
+ .df.fdc.wPx(width)
74
+ .mhPx(defaultMinHeight)
75
+ .if(isFixedHeight)
76
+ .hPx(height).$, ref: ref, ...overlayProps, ...dialogProps, ...modalProps, ...testId, children: [(0, jsx_runtime_1.jsxs)("header", { css: Css_1.Css.df.p3.fs0.if(drawHeaderBorder).bb.bGray200.$, children: [(0, jsx_runtime_1.jsx)("h1", { css: Css_1.Css.fg1.xl2Sb.gray900.$, ref: modalHeaderRef, ...titleProps, ...testId.title }), (0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.fs0.pl1.$, children: (0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { icon: "x", onClick: closeModal, ...testId.titleClose }) })] }), (0, jsx_runtime_1.jsx)("main", { ref: modalBodyRef, css: Css_1.Css.fg1.overflowYAuto.if(hasScroll).bb.bGray200.if(!!forceScrolling).overflowYScroll.$, children: content }), (0, jsx_runtime_1.jsx)("footer", { css: Css_1.Css.fs0.$, children: (0, jsx_runtime_1.jsx)("div", { ref: modalFooterRef }) })] }) }) }) }) }) }));
76
77
  }
77
78
  exports.Modal = Modal;
78
79
  function ModalHeader({ children }) {
@@ -0,0 +1,11 @@
1
+ import { ReactNode } from "react";
2
+ interface ModalContextState {
3
+ inModal: boolean;
4
+ }
5
+ export declare const ModalContext: import("react").Context<ModalContextState>;
6
+ interface ModalProviderProps {
7
+ children: ReactNode;
8
+ }
9
+ export declare function ModalProvider({ children }: ModalProviderProps): import("@emotion/react/jsx-runtime").JSX.Element;
10
+ export declare function useModalContext(): ModalContextState;
11
+ export {};
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useModalContext = exports.ModalProvider = exports.ModalContext = void 0;
4
+ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ exports.ModalContext = (0, react_1.createContext)({ inModal: false });
7
+ function ModalProvider({ children }) {
8
+ const value = (0, react_1.useMemo)(() => ({ inModal: true }), []);
9
+ return (0, jsx_runtime_1.jsx)(exports.ModalContext.Provider, { value: value, children: children });
10
+ }
11
+ exports.ModalProvider = ModalProvider;
12
+ function useModalContext() {
13
+ return (0, react_1.useContext)(exports.ModalContext);
14
+ }
15
+ exports.useModalContext = useModalContext;
@@ -5,5 +5,6 @@ export interface UseModalHook {
5
5
  closeModal: VoidFunction;
6
6
  addCanClose: (canClose: CheckFn) => void;
7
7
  setSize: (size: ModalProps["size"]) => void;
8
+ inModal: boolean;
8
9
  }
9
10
  export declare function useModal(): UseModalHook;
@@ -4,8 +4,10 @@ exports.useModal = void 0;
4
4
  const react_1 = require("react");
5
5
  const BeamContext_1 = require("../BeamContext");
6
6
  const utils_1 = require("../../utils");
7
+ const ModalContext_1 = require("./ModalContext");
7
8
  function useModal() {
8
9
  const { modalState, modalCanCloseChecks } = (0, BeamContext_1.useBeamContext)();
10
+ const { inModal } = (0, ModalContext_1.useModalContext)();
9
11
  const lastCanClose = (0, react_1.useRef)();
10
12
  const api = (0, react_1.useRef)();
11
13
  (0, react_1.useEffect)(() => {
@@ -45,6 +47,7 @@ function useModal() {
45
47
  modalState.current.api.current.setSize(size);
46
48
  }
47
49
  },
48
- }), [modalState, modalCanCloseChecks]);
50
+ inModal,
51
+ }), [inModal, modalState, modalCanCloseChecks]);
49
52
  }
50
53
  exports.useModal = useModal;
@@ -53,9 +53,11 @@ function ChipTextField(props) {
53
53
  }
54
54
  }, onInput: (e) => {
55
55
  var _a, _b, _c;
56
- // Prevent user from pasting content that has new line characters and replace with empty space.
57
56
  const target = e.target;
58
- target.textContent = (_b = (_a = target.textContent) === null || _a === void 0 ? void 0 : _a.replace(/[\n\r]/g, " ")) !== null && _b !== void 0 ? _b : "";
57
+ if ("inputType" in e.nativeEvent && e.nativeEvent.inputType === "insertFromPaste") {
58
+ // Clean up any formatting from pasted text
59
+ target.innerHTML = (_b = (_a = target.textContent) === null || _a === void 0 ? void 0 : _a.replace(/[A\n\r]/g, " ")) !== null && _b !== void 0 ? _b : "";
60
+ }
59
61
  onChange((_c = target.textContent) !== null && _c !== void 0 ? _c : "");
60
62
  }, ...focusProps, css: {
61
63
  ...Css_1.Css[typeScale].dib.br16.pl1.pxPx(10).pyPx(2).gray900.bgGray300.outline0.mwPx(32).$,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.325.2",
3
+ "version": "2.326.1",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",