@homebound/beam 2.194.1 → 2.196.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.
@@ -56,7 +56,7 @@ function BeamProvider({ children, ...presentationProps }) {
56
56
  drawerCanCloseDetailsChecks,
57
57
  };
58
58
  }, [modalBodyDiv, modalFooterDiv]);
59
- 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.jsxs)(SnackbarContext_1.SnackbarProvider, { children: [(0, jsx_runtime_1.jsxs)(react_aria_1.OverlayProvider, { children: [children, modalRef.current && drawerContentStackRef.current.length === 0 && (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));
59
+ 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.jsxs)(SnackbarContext_1.SnackbarProvider, { 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));
60
60
  }
61
61
  exports.BeamProvider = BeamProvider;
62
62
  /** Looks like a ref, but invokes a re-render on set (w/o changing the setter identity). */
@@ -24,7 +24,7 @@ function Modal(props) {
24
24
  const { size = "md", content, forceScrolling, api, drawHeaderBorder = false } = props;
25
25
  const isFixedHeight = typeof size !== "string";
26
26
  const ref = (0, react_1.useRef)(null);
27
- const { modalBodyDiv, modalFooterDiv, modalHeaderDiv, drawerContentStack } = (0, BeamContext_1.useBeamContext)();
27
+ const { modalBodyDiv, modalFooterDiv, modalHeaderDiv } = (0, BeamContext_1.useBeamContext)();
28
28
  const { closeModal } = (0, useModal_1.useModal)();
29
29
  const { overlayProps, underlayProps } = (0, react_aria_1.useOverlay)({
30
30
  ...props,
@@ -56,10 +56,6 @@ function Modal(props) {
56
56
  // Even though we use raw-divs for the createPortal calls, we do actually need to
57
57
  // use refs + useEffect to stitch those raw divs back into the React component tree.
58
58
  (0, react_1.useEffect)(() => {
59
- // If the superdrawer is open, let it own the modal content
60
- if (drawerContentStack.current.length > 0) {
61
- return;
62
- }
63
59
  modalHeaderRef.current.appendChild(modalHeaderDiv);
64
60
  modalBodyRef.current.appendChild(modalBodyDiv);
65
61
  modalFooterRef.current.appendChild(modalFooterDiv);
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ConfirmCloseModal = void 0;
4
4
  const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
5
5
  const components_1 = require("..");
6
- const Css_1 = require("../../Css");
7
6
  const BeamContext_1 = require("../BeamContext");
8
7
  /** Modal content to appear when a close checks fails */
9
8
  function ConfirmCloseModal(props) {
@@ -15,10 +14,10 @@ function ConfirmCloseModal(props) {
15
14
  // after a close and could/will cause other close attempts to fail.
16
15
  modalState.current = undefined;
17
16
  }
18
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(components_1.ModalBody, { children: (0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.tc.wPx(400).$ }, { children: [(0, jsx_runtime_1.jsx)("p", Object.assign({ css: Css_1.Css.lgSb.gray900.mb1.$ }, { children: "Are you sure you want to cancel?" }), void 0), (0, jsx_runtime_1.jsx)("p", Object.assign({ css: Css_1.Css.base.gray700.$ }, { children: "Any changes you've made so far will be lost." }), void 0)] }), void 0) }, void 0), (0, jsx_runtime_1.jsx)(components_1.ModalFooter, Object.assign({ xss: Css_1.Css.jcc.$ }, { children: (0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.df.fdc.gap1.aic.$ }, { children: [(0, jsx_runtime_1.jsx)(components_1.Button, { label: continueText, onClick: closeModal }, void 0), (0, jsx_runtime_1.jsx)(components_1.Button, { variant: "tertiary", label: discardText, onClick: () => {
19
- // The order of these calls doesn't really matter; close this modal and tell the call to do their close
20
- onClose();
21
- closeModal();
22
- } }, void 0)] }), void 0) }), void 0)] }, void 0));
17
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(components_1.ModalHeader, { children: "Are you sure you want to cancel?" }, void 0), (0, jsx_runtime_1.jsx)(components_1.ModalBody, { children: (0, jsx_runtime_1.jsx)("p", { children: "Any changes you've made so far will be lost." }, void 0) }, void 0), (0, jsx_runtime_1.jsxs)(components_1.ModalFooter, { children: [(0, jsx_runtime_1.jsx)(components_1.Button, { variant: "tertiary", label: discardText, onClick: () => {
18
+ // The order of these calls doesn't really matter; close this modal and tell the call to do their close
19
+ onClose();
20
+ closeModal();
21
+ } }, void 0), (0, jsx_runtime_1.jsx)(components_1.Button, { label: continueText, onClick: closeModal }, void 0)] }, void 0)] }, void 0));
23
22
  }
24
23
  exports.ConfirmCloseModal = ConfirmCloseModal;
@@ -35,19 +35,11 @@ const utils_2 = require("./utils");
35
35
  */
36
36
  function SuperDrawer() {
37
37
  var _a, _b;
38
- const { drawerContentStack: contentStack, modalState, modalBodyDiv, modalFooterDiv, modalHeaderDiv, } = (0, BeamContext_1.useBeamContext)();
38
+ const { drawerContentStack: contentStack } = (0, BeamContext_1.useBeamContext)();
39
39
  const { closeDrawer } = (0, components_1.useSuperDrawer)();
40
40
  const modalBodyRef = (0, react_3.useRef)(null);
41
41
  const modalFooterRef = (0, react_3.useRef)(null);
42
42
  const testId = (0, utils_1.useTestIds)({}, "superDrawer");
43
- // Steal the modal body/footer portals from Modal, if we're open
44
- (0, react_3.useEffect)(() => {
45
- if (modalBodyRef.current && modalFooterRef.current && modalState.current) {
46
- modalBodyRef.current.appendChild(modalBodyDiv);
47
- modalFooterRef.current.appendChild(modalFooterDiv);
48
- }
49
- // eslint-disable-next-line react-hooks/exhaustive-deps
50
- }, [modalBodyRef.current, modalFooterRef.current, modalState.current]);
51
43
  // Get the latest element on the stack
52
44
  // We use undefined, nullish operators and empty object here to allow AnimatePresence
53
45
  // to animate the drawers exit transition when our stack is empty
@@ -78,7 +70,7 @@ function SuperDrawer() {
78
70
  // Custom transitions settings for the translateX animation
79
71
  transition: { ease: "linear", duration: 0.2, delay: 0.2 }, exit: { transition: { ease: "linear", duration: 0.2 }, x: width },
80
72
  // Preventing clicks from triggering parent onClick
81
- 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.if(!!modalState.current).bn.$ }, { 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.xl2Sb.gray900.mr2.$ }, testId.title, { children: title !== null && title !== void 0 ? title : null }), void 0), titleLeftContent !== null && titleLeftContent !== void 0 ? titleLeftContent : null] }), void 0), (0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.df.gap3.aic.hPx(32).fs0.$ }, { children: [titleRightContent || null, !hideControls && ((0, jsx_runtime_1.jsx)(components_1.ButtonGroup, Object.assign({ buttons: [
73
+ 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.xl2Sb.gray900.mr2.$ }, testId.title, { children: title !== null && title !== void 0 ? title : null }), void 0), titleLeftContent !== null && titleLeftContent !== void 0 ? titleLeftContent : null] }), void 0), (0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.df.gap3.aic.hPx(32).fs0.$ }, { children: [titleRightContent || null, !hideControls && ((0, jsx_runtime_1.jsx)(components_1.ButtonGroup, Object.assign({ buttons: [
82
74
  {
83
75
  icon: "chevronLeft",
84
76
  onClick: () => onPrevClick && onPrevClick(),
@@ -89,8 +81,6 @@ function SuperDrawer() {
89
81
  onClick: () => onNextClick && onNextClick(),
90
82
  disabled: !onNextClick || isDetail,
91
83
  },
92
- ] }, testId.headerActions), void 0)), (0, jsx_runtime_1.jsx)(components_1.IconButton, Object.assign({ icon: "x", onClick: closeDrawer }, testId.close), void 0)] }), void 0)] }), void 0), content, modalState.current && (
93
- // Forcing some design constraints on the modal component
94
- (0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.fg1.top0.left0.right0.bottom0.absolute.bgWhite.df.aic.jcc.fg1.fdc.z5.$ }, { children: [modalState.current.content, (0, jsx_runtime_1.jsx)("div", { ref: modalBodyRef }, void 0), (0, jsx_runtime_1.jsx)("div", { ref: modalFooterRef }, void 0)] }), void 0))] }, void 0) }), "superDrawerContainer"))] }, void 0)) }, void 0), document.body);
84
+ ] }, testId.headerActions), void 0)), (0, jsx_runtime_1.jsx)(components_1.IconButton, Object.assign({ icon: "x", onClick: closeDrawer }, testId.close), void 0)] }), void 0)] }), void 0), content] }, void 0) }), "superDrawerContainer"))] }, void 0)) }, void 0), document.body);
95
85
  }
96
86
  exports.SuperDrawer = SuperDrawer;
@@ -137,6 +137,7 @@ function GridTable(props) {
137
137
  getCount,
138
138
  api,
139
139
  cellHighlight: "cellHighlight" in maybeStyle && maybeStyle.cellHighlight === true,
140
+ omitRowHover: "rowHover" in maybeStyle && maybeStyle.rowHover === false,
140
141
  ...sortProps,
141
142
  }), `${row.kind}-${row.id}`));
142
143
  }
@@ -157,7 +158,6 @@ function GridTable(props) {
157
158
  }
158
159
  }
159
160
  function visitRows(rows, level, visible) {
160
- const length = rows.length;
161
161
  rows.forEach((row, i) => {
162
162
  if (row[0].kind === "header") {
163
163
  headerRows.push([row[0], makeRowComponent(row[0], level)]);
@@ -61,6 +61,7 @@ export interface GridStyleDef {
61
61
  cellHighlight?: boolean;
62
62
  allWhite?: boolean;
63
63
  bordered?: boolean;
64
+ rowHover?: boolean;
64
65
  }
65
66
  export declare const getTableStyles: (props?: GridStyleDef) => GridStyle;
66
67
  /** Defines row-specific styling for each given row `kind` in `R` */
@@ -7,7 +7,7 @@ const utils_1 = require("../../utils");
7
7
  function memoizedTableStyles() {
8
8
  const cache = {};
9
9
  return (props = {}) => {
10
- const { inlineEditing = false, grouped = false, rowHeight = "flexible", cellHighlight = false, allWhite = false, bordered = false, } = props;
10
+ const { inlineEditing = false, grouped = false, rowHeight = "flexible", cellHighlight = false, allWhite = false, bordered = false, rowHover = true, } = props;
11
11
  const key = (0, utils_1.safeKeys)(props)
12
12
  .sort()
13
13
  .map((k) => `${k}_${props[k]}`)
@@ -50,6 +50,7 @@ function memoizedTableStyles() {
50
50
  }),
51
51
  presentationSettings: { borderless: true, typeScale: "xs", wrap: rowHeight === "flexible" },
52
52
  levels: grouped ? groupedLevels : defaultLevels,
53
+ rowHoverColor: Css_1.Palette.LightBlue100,
53
54
  };
54
55
  }
55
56
  return cache[key];
@@ -114,6 +115,7 @@ function resolveStyles(style) {
114
115
  "cellHighlight",
115
116
  "allWhite",
116
117
  "bordered",
118
+ "rowHover",
117
119
  ];
118
120
  const keys = (0, utils_1.safeKeys)(style);
119
121
  if (keys.length === 0 || keys.some((k) => defKeys.includes(k))) {
@@ -19,6 +19,7 @@ interface RowProps<R extends Kinded, S> {
19
19
  getCount: (id: string) => object;
20
20
  api: GridTableApi<R>;
21
21
  cellHighlight: boolean;
22
+ omitRowHover: boolean;
22
23
  }
23
24
  declare function RowImpl<R extends Kinded, S>(props: RowProps<R, S>): ReactElement;
24
25
  /**
@@ -33,7 +33,7 @@ const shallowEqual_1 = require("../../../utils/shallowEqual");
33
33
  // We extract Row to its own mini-component primarily so we can React.memo'ize it.
34
34
  function RowImpl(props) {
35
35
  var _a;
36
- const { as, columns, row, style, rowStyles, stickyHeader, stickyOffset, sortOn, sortState, setSortKey, columnSizes, level, getCount, api, cellHighlight, ...others } = props;
36
+ const { as, columns, row, style, rowStyles, stickyHeader, stickyOffset, sortOn, sortState, setSortKey, columnSizes, level, getCount, api, cellHighlight, omitRowHover, ...others } = props;
37
37
  const { rowState } = (0, react_1.useContext)(RowState_1.RowStateContext);
38
38
  const rowId = `${row.kind}_${row.id}`;
39
39
  const isActive = (0, hooks_1.useComputed)(() => rowState.activeRowId === rowId, [rowId, rowState]);
@@ -45,12 +45,15 @@ function RowImpl(props) {
45
45
  const revealOnRowHoverClass = "revealOnRowHover";
46
46
  const rowStyleCellCss = (0, utils_1.maybeApplyFunction)(row, rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.cellCss);
47
47
  const rowCss = {
48
- // For virtual tables use `display: flex` to keep all cells on the same row. For each cell in the row use `flexNone` to ensure they stay their defined widths
49
- ...(as === "table" ? {} : Css_1.Css.relative.df.fg1.fs1.addIn("&>*", Css_1.Css.flexNone.$).$),
50
- ...(((rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.rowLink) || (rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.onClick)) && {
48
+ // Optionally include the row hover styles, by default they should be turned on.
49
+ ...(!omitRowHover && {
51
50
  // Even though backgroundColor is set on the cellCss, the hover target is the row.
52
- "&:hover > *": Css_1.Css.cursorPointer.bgColor((_a = style.rowHoverColor) !== null && _a !== void 0 ? _a : Css_1.Palette.LightBlue100).$,
51
+ "&:hover > *": Css_1.Css.bgColor((_a = style.rowHoverColor) !== null && _a !== void 0 ? _a : Css_1.Palette.LightBlue100).$,
53
52
  }),
53
+ // For virtual tables use `display: flex` to keep all cells on the same row. For each cell in the row use `flexNone` to ensure they stay their defined widths
54
+ ...(as === "table" ? {} : Css_1.Css.relative.df.fg1.fs1.addIn("&>*", Css_1.Css.flexNone.$).$),
55
+ // Apply `cursorPointer` to the row if it has a link or `onClick` value.
56
+ ...(((rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.rowLink) || (rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.onClick)) && { "&:hover": Css_1.Css.cursorPointer.$ }),
54
57
  ...(0, utils_1.maybeApplyFunction)(row, rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.rowCss),
55
58
  // Maybe add the sticky header styles
56
59
  ...((isHeader || isTotals) && stickyHeader ? Css_1.Css.sticky.topPx(stickyOffset).z2.$ : undefined),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.194.1",
3
+ "version": "2.196.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",