@homebound/beam 2.71.4 → 2.71.8

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.
@@ -0,0 +1,6 @@
1
+ import { ReactElement } from "react";
2
+ /** Provides a way to extend the full width of the ScrollableParent */
3
+ export declare function FullBleed({ children, omitPadding }: {
4
+ children: ReactElement;
5
+ omitPadding?: boolean;
6
+ }): ReactElement<any, string | import("react").JSXElementConstructor<any>>;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FullBleed = void 0;
4
+ const react_1 = require("react");
5
+ const ScrollableParent_1 = require("./ScrollableParent");
6
+ const Css_1 = require("../../Css");
7
+ /** Provides a way to extend the full width of the ScrollableParent */
8
+ function FullBleed({ children, omitPadding = false }) {
9
+ const { pr, pl } = (0, ScrollableParent_1.useScrollableParent)();
10
+ return !pr && !pl
11
+ ? children
12
+ : (0, react_1.cloneElement)(children, {
13
+ style: Css_1.Css.ml(`-${pl}`).mr(`-${pr}`).if(!omitPadding).pl(pl).pr(pr).$,
14
+ });
15
+ }
16
+ exports.FullBleed = FullBleed;
@@ -1,5 +1,6 @@
1
1
  import { ReactNode, ReactPortal } from "react";
2
2
  /** Helper component for placing scrollable content within a `NestedScrollProvider`. */
3
- export declare function ScrollableContent({ children }: {
3
+ export declare function ScrollableContent({ children, virtualized, }: {
4
4
  children: ReactNode;
5
+ virtualized?: boolean;
5
6
  }): ReactPortal;
@@ -1,11 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ScrollableContent = void 0;
4
+ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
4
5
  const react_dom_1 = require("react-dom");
6
+ const FullBleed_1 = require("./FullBleed");
5
7
  const ScrollableParent_1 = require("./ScrollableParent");
8
+ const Css_1 = require("../../Css");
6
9
  /** Helper component for placing scrollable content within a `NestedScrollProvider`. */
7
- function ScrollableContent({ children }) {
8
- const { scrollableEl } = (0, ScrollableParent_1.useScrollableParent)();
9
- return (0, react_dom_1.createPortal)(children, scrollableEl);
10
+ function ScrollableContent({ children, virtualized = false, }) {
11
+ const { scrollableEl, pl } = (0, ScrollableParent_1.useScrollableParent)();
12
+ return (0, react_dom_1.createPortal)(!virtualized ? (children) : (
13
+ // To prevent Virtuoso's scrollbar from being set in based on the Layout's padding, we will use the FullBleed component w/o padding to push it back over
14
+ (0, jsx_runtime_1.jsx)(FullBleed_1.FullBleed, Object.assign({ omitPadding: true }, { children: (0, jsx_runtime_1.jsx)("div", Object.assign({ css: Css_1.Css.h100.pl(pl).$ }, { children: children }), void 0) }), void 0)), scrollableEl);
10
15
  }
11
16
  exports.ScrollableContent = ScrollableContent;
@@ -2,6 +2,8 @@ import { PropsWithChildren } from "react";
2
2
  import { Properties } from "../../Css";
3
3
  interface ScrollableParentContextProps {
4
4
  scrollableEl: HTMLElement;
5
+ pr: string | number;
6
+ pl: string | number;
5
7
  }
6
8
  interface ScrollableParentContextProviderProps {
7
9
  xss?: Properties;
@@ -6,15 +6,23 @@ const react_1 = require("react");
6
6
  const Css_1 = require("../../Css");
7
7
  const ScrollableParentContext = (0, react_1.createContext)({
8
8
  scrollableEl: document.createElement("div"),
9
+ pr: 0,
10
+ pl: 0,
9
11
  });
10
12
  function ScrollableParent({ children, xss }) {
11
- const scrollableEl = (0, react_1.useMemo)(() => document.createElement("div"), []);
13
+ const scrollableEl = (0, react_1.useMemo)(() => {
14
+ const el = document.createElement("div");
15
+ // Ensure this wrapping div takes up the full height of its container
16
+ el.style.height = "100%";
17
+ return el;
18
+ }, []);
12
19
  const scrollableRef = (0, react_1.useRef)(null);
13
- const context = { scrollableEl };
20
+ const { paddingLeft, paddingRight, ...otherXss } = xss || {};
21
+ const context = { scrollableEl, pl: paddingLeft !== null && paddingLeft !== void 0 ? paddingLeft : 0, pr: paddingRight !== null && paddingRight !== void 0 ? paddingRight : 0 };
14
22
  (0, react_1.useEffect)(() => {
15
23
  scrollableRef.current.appendChild(scrollableEl);
16
24
  }, [scrollableEl]);
17
- return ((0, jsx_runtime_1.jsx)(ScrollableParentContext.Provider, Object.assign({ value: context }, { children: (0, jsx_runtime_1.jsxs)("div", Object.assign({ css: { ...Css_1.Css.mh0.mw0.df.fdc.$, ...xss } }, { children: [children, (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.overflowAuto.$, ref: scrollableRef }, void 0)] }), void 0) }), void 0));
25
+ return ((0, jsx_runtime_1.jsx)(ScrollableParentContext.Provider, Object.assign({ value: context }, { children: (0, jsx_runtime_1.jsxs)("div", Object.assign({ css: { ...Css_1.Css.mh0.mw0.df.fdc.$, ...otherXss } }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ css: Css_1.Css.pl(context.pl).pr(context.pr).$ }, { children: children }), void 0), (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.fg1.overflowAuto.pl(context.pl).pr(context.pr).$, ref: scrollableRef }, void 0)] }), void 0) }), void 0));
18
26
  }
19
27
  exports.ScrollableParent = ScrollableParent;
20
28
  function useScrollableParent() {
@@ -1,3 +1,4 @@
1
+ export * from "./FullBleed";
1
2
  export * from "./PreventBrowserScroll";
2
3
  export * from "./ScrollableContent";
3
4
  export * from "./ScrollableParent";
@@ -10,6 +10,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./FullBleed"), exports);
13
14
  __exportStar(require("./PreventBrowserScroll"), exports);
14
15
  __exportStar(require("./ScrollableContent"), exports);
15
16
  __exportStar(require("./ScrollableParent"), exports);
@@ -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;
@@ -130,7 +130,7 @@ function GridTable(props) {
130
130
  return rows;
131
131
  }, [columns, rows, sorting, sortState]);
132
132
  // Filter + flatten + component-ize the sorted rows.
133
- let [headerRows, filteredRows] = (0, react_1.useMemo)(() => {
133
+ let [headerRows, filteredRows, maxCardPadding] = (0, react_1.useMemo)(() => {
134
134
  // Break up "foo bar" into `[foo, bar]` and a row must match both `foo` and `bar`
135
135
  const filters = (filter && filter.split(/ +/)) || [];
136
136
  function makeRowComponent(row) {
@@ -161,6 +161,8 @@ function GridTable(props) {
161
161
  // Split out the header rows from the data rows so that we can put an `infoMessage` in between them (if needed).
162
162
  const headerRows = [];
163
163
  const filteredRows = [];
164
+ // If we're doing nested cards, we will add extra first/last columns, and need to know how wide to make them
165
+ let maxCardPadding = undefined;
164
166
  // Misc state to track our nested card-ification, i.e. interleaved actual rows + chrome rows
165
167
  const nestedCards = !!style.nestedCards && new nestedCards_1.NestedCards(columns, filteredRows, style);
166
168
  // Depth-first to filter
@@ -171,6 +173,9 @@ function GridTable(props) {
171
173
  let isCard = false;
172
174
  if (matches) {
173
175
  isCard = nestedCards && nestedCards.maybeOpenCard(row);
176
+ if (isCard && nestedCards) {
177
+ maxCardPadding = nestedCards.maxCardPadding(maxCardPadding);
178
+ }
174
179
  filteredRows.push([row, makeRowComponent(row)]);
175
180
  }
176
181
  const isCollapsed = collapsedIds.includes(row.id);
@@ -193,7 +198,7 @@ function GridTable(props) {
193
198
  // If nestedCards is set, we assume the top-level kind is a card, and so should add spacers between them
194
199
  visitRows(maybeSorted, !!nestedCards);
195
200
  nestedCards && nestedCards.done();
196
- return [headerRows, filteredRows];
201
+ return [headerRows, filteredRows, maxCardPadding];
197
202
  }, [
198
203
  as,
199
204
  maybeSorted,
@@ -231,7 +236,7 @@ function GridTable(props) {
231
236
  // just trust the GridTable impl that, at runtime, `as=virtual` will (other than being virtualized)
232
237
  // behave semantically the same as `as=div` did for its tests.
233
238
  const _as = as === "virtual" && runningInJest ? "div" : as;
234
- return renders[_as](style, id, columns, headerRows, filteredRows, firstRowMessage, stickyHeader, xss, virtuosoRef);
239
+ return renders[_as](style, id, columns, headerRows, filteredRows, firstRowMessage, stickyHeader, maxCardPadding, xss, virtuosoRef);
235
240
  }
236
241
  exports.GridTable = GridTable;
237
242
  // Determine which HTML element to use to build the GridTable
@@ -241,9 +246,9 @@ const renders = {
241
246
  virtual: renderVirtual,
242
247
  };
243
248
  /** Renders as a CSS Grid, which is the default / most well-supported rendered. */
244
- function renderCssGrid(style, id, columns, headerRows, filteredRows, firstRowMessage, stickyHeader, xss, virtuosoRef) {
249
+ function renderCssGrid(style, id, columns, headerRows, filteredRows, firstRowMessage, stickyHeader, maxCardPadding, xss, virtuosoRef) {
245
250
  return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ css: {
246
- ...Css_1.Css.dg.gtc(calcGridColumns(columns)).$,
251
+ ...Css_1.Css.dg.gtc(calcGridColumns(columns, maxCardPadding)).$,
247
252
  ...Css_1.Css
248
253
  // Apply the between-row styling with `div + div > *` so that we don't have to have conditional
249
254
  // `if !lastRow add border` CSS applied via JS that would mean the row can't be React.memo'd.
@@ -256,7 +261,7 @@ function renderCssGrid(style, id, columns, headerRows, filteredRows, firstRowMes
256
261
  }, "data-testid": id }, { children: [headerRows.map(([, node]) => node), firstRowMessage && ((0, jsx_runtime_1.jsx)("div", Object.assign({ css: Css_1.Css.add("gridColumn", `${columns.length} span`).$ }, { children: (0, jsx_runtime_1.jsx)("div", Object.assign({ css: { ...style.firstRowMessageCss } }, { children: firstRowMessage }), void 0) }), void 0)), filteredRows.map(([, node]) => node)] }), void 0));
257
262
  }
258
263
  /** Renders as a table, primarily/solely for good print support. */
259
- function renderTable(style, id, columns, headerRows, filteredRows, firstRowMessage, stickyHeader, xss, virtuosoRef) {
264
+ function renderTable(style, id, columns, headerRows, filteredRows, firstRowMessage, stickyHeader, maxCardPadding, xss, virtuosoRef) {
260
265
  return ((0, jsx_runtime_1.jsxs)("table", Object.assign({ css: {
261
266
  ...Css_1.Css.w100.add("borderCollapse", "collapse").$,
262
267
  ...Css_1.Css.addIn("& > tbody > tr ", style.betweenRowsCss || {})
@@ -286,8 +291,8 @@ function renderTable(style, id, columns, headerRows, filteredRows, firstRowMessa
286
291
  * [2]: https://github.com/tannerlinsley/react-virtual/issues/85
287
292
  * [3]: https://github.com/tannerlinsley/react-virtual/issues/108
288
293
  */
289
- function renderVirtual(style, id, columns, headerRows, filteredRows, firstRowMessage, stickyHeader, xss, virtuosoRef) {
290
- return ((0, jsx_runtime_1.jsx)(react_virtuoso_1.Virtuoso, { ref: virtuosoRef, components: { List: VirtualRoot(style, columns, id, xss) },
294
+ function renderVirtual(style, id, columns, headerRows, filteredRows, firstRowMessage, stickyHeader, maxCardPadding, xss, virtuosoRef) {
295
+ return ((0, jsx_runtime_1.jsx)(react_virtuoso_1.Virtuoso, { ref: virtuosoRef, components: { List: VirtualRoot(style, columns, id, maxCardPadding, xss) },
291
296
  // Pin/sticky both the header row(s) + firstRowMessage to the top
292
297
  topItemCount: (stickyHeader ? headerRows.length : 0) + (firstRowMessage ? 1 : 0),
293
298
  // Both the `Item` and `itemContent` use `display: contents`, so their height is 0,
@@ -316,11 +321,11 @@ function renderVirtual(style, id, columns, headerRows, filteredRows, firstRowMes
316
321
  * identity, even though technically we have a different "component" per the given set of props
317
322
  * (solely to capture as params that we can't pass through react-virtuoso's API as props).
318
323
  */
319
- const VirtualRoot = (0, memoize_one_1.default)((gs, columns, id, xss) => {
324
+ const VirtualRoot = (0, memoize_one_1.default)((gs, columns, id, maxCardPadding, xss) => {
320
325
  return react_1.default.forwardRef(({ style, children }, ref) => {
321
326
  // This re-renders each time we have new children in the view port
322
327
  return ((0, jsx_runtime_1.jsx)("div", Object.assign({ ref: ref, style: style, css: {
323
- ...Css_1.Css.dg.gtc(calcGridColumns(columns)).$,
328
+ ...Css_1.Css.dg.gtc(calcGridColumns(columns, maxCardPadding)).$,
324
329
  // Add an extra `> div` due to Item + itemContent both having divs
325
330
  ...Css_1.Css.addIn("& > div + div > div > *", gs.betweenRowsCss || {}).$,
326
331
  // Add `display:contents` to Item to flatten it like we do GridRow
@@ -330,11 +335,16 @@ const VirtualRoot = (0, memoize_one_1.default)((gs, columns, id, xss) => {
330
335
  }, "data-testid": id }, { children: children }), void 0));
331
336
  });
332
337
  });
333
- function calcGridColumns(columns) {
334
- return (columns
338
+ function calcGridColumns(columns, maxCardPadding) {
339
+ let sizes = columns.map((c) => {
335
340
  // Default to auto, but use `c.w` as a fr if numeric or else `c.w` as-if if a string
336
- .map((c) => (typeof c.w === "string" ? c.w : c.w !== undefined ? `${c.w}fr` : "auto"))
337
- .join(" "));
341
+ return typeof c.w === "string" ? c.w : c.w !== undefined ? `${c.w}fr` : "auto";
342
+ });
343
+ // If we're doing nested cards, we add extra 1st/last cells...
344
+ if (maxCardPadding) {
345
+ sizes = [`${maxCardPadding}px`, ...sizes, `${maxCardPadding}px`];
346
+ }
347
+ return sizes.join(" ");
338
348
  }
339
349
  function getIndentationCss(style, rowStyle, columnIndex, maybeContent) {
340
350
  // Look for cell-specific indent or row-specific indent (row-specific is only one the first column)
@@ -369,52 +379,49 @@ function GridRow(props) {
369
379
  ...maybeApplyFunction(row, rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.rowCss),
370
380
  };
371
381
  const Row = as === "table" ? "tr" : "div";
372
- const div = ((0, jsx_runtime_1.jsx)(Row, Object.assign({ css: rowCss }, others, { children: columns.map((column, columnIndex) => {
373
- const maybeContent = applyRowFn(column, row);
374
- const canSortColumn = ((sorting === null || sorting === void 0 ? void 0 : sorting.on) === "client" && column.clientSideSort !== false) ||
375
- ((sorting === null || sorting === void 0 ? void 0 : sorting.on) === "server" && !!column.serverSideSortKey);
376
- const content = toContent(maybeContent, isHeader, canSortColumn);
377
- (0, sortRows_1.ensureClientSideSortValueIsSortable)(sorting, isHeader, column, columnIndex, maybeContent);
378
- const card = openCards && openCards.length > 0 && openCards[openCards.length - 1];
379
- // Note that it seems expensive to calc a per-cell class name/CSS-in-JS output,
380
- // vs. setting global/table-wide CSS like `style.cellCss` on the root grid div with
381
- // a few descendent selectors. However, that approach means the root grid-applied
382
- // CSS has a high-specificity and so its harder for per-page/per-cell business logic
383
- // to override it. So, we just calc the combined table-wide+per-cell-overridden CSS here,
384
- // in a very CSS-in-JS idiomatic manner.
385
- //
386
- // In practice we've not seen any performance issues with this from our "large but
387
- // not Google spreadsheets" tables.
388
- const cellCss = {
389
- // Adding display flex so we can align content within the cells
390
- ...Css_1.Css.df.$,
391
- // Apply any static/all-cell styling
392
- ...style.cellCss,
393
- // Then override with first/last cell styling
394
- ...getFirstOrLastCellCss(style, columnIndex, columns),
395
- // Then override with per-cell/per-row justification/indentation
396
- ...getJustification(column, maybeContent, as),
397
- ...getIndentationCss(style, rowStyle, columnIndex, maybeContent),
398
- // Then apply any header-specific override
399
- ...(isHeader && style.headerCellCss),
400
- ...(isHeader && stickyHeader && Css_1.Css.sticky.top(stickyOffset).z1.$),
401
- // And finally the specific cell's css (if any from GridCellContent)
402
- ...rowStyleCellCss,
403
- };
404
- const renderFn = (rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.renderCell) || (rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.rowLink)
405
- ? rowLinkRenderFn(as)
406
- : isHeader
407
- ? headerRenderFn(columns, column, sortState, setSortKey, as)
408
- : (rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.onClick)
409
- ? rowClickRenderFn(as)
410
- : defaultRenderFn(as);
411
- let rendered = renderFn(columnIndex, cellCss, content, row, rowStyle);
412
- // Sneak in card padding for the 1st / last cells
413
- if (card) {
414
- rendered = (0, nestedCards_1.maybeAddCardPadding)(columns, openCards, columnIndex, rendered);
415
- }
416
- return rendered;
417
- }) }), void 0));
382
+ const currentCard = openCards && openCards.length > 0 && openCards[openCards.length - 1];
383
+ const div = ((0, jsx_runtime_1.jsxs)(Row, Object.assign({ css: rowCss }, others, { children: [openCards && (0, nestedCards_1.maybeAddCardPadding)(openCards, "first"), columns.map((column, columnIndex) => {
384
+ const maybeContent = applyRowFn(column, row);
385
+ const canSortColumn = ((sorting === null || sorting === void 0 ? void 0 : sorting.on) === "client" && column.clientSideSort !== false) ||
386
+ ((sorting === null || sorting === void 0 ? void 0 : sorting.on) === "server" && !!column.serverSideSortKey);
387
+ const content = toContent(maybeContent, isHeader, canSortColumn);
388
+ (0, sortRows_1.ensureClientSideSortValueIsSortable)(sorting, isHeader, column, columnIndex, maybeContent);
389
+ // Note that it seems expensive to calc a per-cell class name/CSS-in-JS output,
390
+ // vs. setting global/table-wide CSS like `style.cellCss` on the root grid div with
391
+ // a few descendent selectors. However, that approach means the root grid-applied
392
+ // CSS has a high-specificity and so its harder for per-page/per-cell business logic
393
+ // to override it. So, we just calc the combined table-wide+per-cell-overridden CSS here,
394
+ // in a very CSS-in-JS idiomatic manner.
395
+ //
396
+ // In practice we've not seen any performance issues with this from our "large but
397
+ // not Google spreadsheets" tables.
398
+ const cellCss = {
399
+ // Adding display flex so we can align content within the cells
400
+ ...Css_1.Css.df.$,
401
+ // Apply any static/all-cell styling
402
+ ...style.cellCss,
403
+ // Then override with first/last cell styling
404
+ ...getFirstOrLastCellCss(style, columnIndex, columns),
405
+ // Then override with per-cell/per-row justification/indentation
406
+ ...getJustification(column, maybeContent, as),
407
+ ...getIndentationCss(style, rowStyle, columnIndex, maybeContent),
408
+ // Then apply any header-specific override
409
+ ...(isHeader && style.headerCellCss),
410
+ ...(isHeader && stickyHeader && Css_1.Css.sticky.top(stickyOffset).z1.$),
411
+ // If we're within a card, use its background color
412
+ ...(currentCard && Css_1.Css.bgColor(currentCard.bgColor).$),
413
+ // And finally the specific cell's css (if any from GridCellContent)
414
+ ...rowStyleCellCss,
415
+ };
416
+ const renderFn = (rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.renderCell) || (rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.rowLink)
417
+ ? rowLinkRenderFn(as)
418
+ : isHeader
419
+ ? headerRenderFn(columns, column, sortState, setSortKey, as)
420
+ : (rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.onClick)
421
+ ? rowClickRenderFn(as)
422
+ : defaultRenderFn(as);
423
+ return renderFn(columnIndex, cellCss, content, row, rowStyle);
424
+ }), openCards && (0, nestedCards_1.maybeAddCardPadding)(openCards, "final")] }), void 0));
418
425
  // Because of useToggleIds, this provider should basically never trigger a re-render, which is
419
426
  // good because we don't want the context to change and re-render every row just because some
420
427
  // other unrelated rows have collapsed/uncollapsed.
@@ -24,6 +24,7 @@ export declare class NestedCards {
24
24
  closeCard(): void;
25
25
  addSpacerBetweenChildren(): void;
26
26
  done(): void;
27
+ maxCardPadding(current: number | undefined): number;
27
28
  /** Return a stable copy of the cards, so it won't change as we keep going. */
28
29
  currentOpenCards(): NestedCardStyle[];
29
30
  }
@@ -45,7 +46,7 @@ export declare function makeOpenOrCloseCard(openCards: NestedCardStyle[], kind:
45
46
  * For the first or last cell of actual content, wrap them in divs that re-create the
46
47
  * outer cards' padding + background.
47
48
  */
48
- export declare function maybeAddCardPadding(columns: GridColumn<any>[], openCards: NestedCardStyle[], columnIndex: number, div: any): any;
49
+ export declare function maybeAddCardPadding(openCards: NestedCardStyle[], column: "first" | "final"): any;
49
50
  /**
50
51
  * Create a spacer between rows of children.
51
52
  *
@@ -63,7 +64,7 @@ export declare function makeSpacer(height: number, openCards: NestedCardStyle[])
63
64
  * - card1 content row
64
65
  * - chrome row (card2 open)
65
66
  * - nested card2 content row
66
- * - chrome row (card2 close, card1 cloard)
67
+ * - chrome row (card2 close, card1 close)
67
68
  */
68
69
  export declare function maybeCreateChromeRow(columns: GridColumn<any>[], filteredRows: RowTuple<any>[], chromeBuffer: JSX.Element[]): void;
69
70
  export declare function dropChromeRows<R extends Kinded>(filteredRows: RowTuple<R>[]): [GridDataRow<R>, ReactElement][];
@@ -51,6 +51,10 @@ class NestedCards {
51
51
  done() {
52
52
  maybeCreateChromeRow(this.columns, this.filteredRows, this.chromeBuffer);
53
53
  }
54
+ maxCardPadding(current) {
55
+ const padding = this.openCards.map((c) => c.pxPx + (!!c.bColor ? 1 : 0)).reduce((a, b) => a + b, 0);
56
+ return Math.max(padding, current || 0);
57
+ }
54
58
  /** Return a stable copy of the cards, so it won't change as we keep going. */
55
59
  currentOpenCards() {
56
60
  return [...this.openCards];
@@ -71,7 +75,7 @@ exports.NestedCards = NestedCards;
71
75
  * row separate from the card's actual content.
72
76
  */
73
77
  function makeOpenOrCloseCard(openCards, kind) {
74
- let div = null;
78
+ let div = (0, jsx_runtime_1.jsx)("div", {}, void 0);
75
79
  const place = kind === "open" ? "Top" : "Bottom";
76
80
  const btOrBb = kind === "open" ? "bt" : "bb";
77
81
  // Create nesting for the all open cards, i.e.:
@@ -80,16 +84,17 @@ function makeOpenOrCloseCard(openCards, kind) {
80
84
  // | card1 | card2 / ... card3 ... \ card2 | card1 |
81
85
  // | card1 | card2 | ... card3 ... | card2 | card1 |
82
86
  //
83
- [...openCards].reverse().forEach((card) => {
87
+ [...openCards].reverse().forEach((card, i) => {
88
+ const first = i === 0;
84
89
  div = ((0, jsx_runtime_1.jsx)("div", Object.assign({ css: {
85
90
  ...Css_1.Css.bgColor(card.bgColor).pxPx(card.pxPx).$,
86
91
  // Only the 1st div needs border left/right radius + border top/bottom.
87
- ...(!div &&
92
+ ...(first &&
88
93
  Css_1.Css.add({
89
94
  [`border${place}RightRadius`]: `${card.brPx}px`,
90
95
  [`border${place}LeftRadius`]: `${card.brPx}px`,
91
96
  }).hPx(card.brPx).$),
92
- ...(card.bColor && Css_1.Css.bc(card.bColor).bl.br.if(!div)[btOrBb].$),
97
+ ...(card.bColor && Css_1.Css.bc(card.bColor).bl.br.if(first)[btOrBb].$),
93
98
  } }, { children: div }), void 0));
94
99
  });
95
100
  return div;
@@ -99,20 +104,13 @@ exports.makeOpenOrCloseCard = makeOpenOrCloseCard;
99
104
  * For the first or last cell of actual content, wrap them in divs that re-create the
100
105
  * outer cards' padding + background.
101
106
  */
102
- function maybeAddCardPadding(columns, openCards, columnIndex, div) {
103
- const isFirst = columnIndex === 0;
104
- const isFinal = columnIndex === columns.length - 1;
105
- if (!isFirst && !isFinal) {
106
- // Even if we don't need the nested color+padding of each open card, at
107
- // least add the background color of the closed open card.
108
- const card = openCards[openCards.length - 1];
109
- return !card ? div : (0, jsx_runtime_1.jsx)("div", Object.assign({ css: Css_1.Css.bgColor(card.bgColor).$ }, { children: div }), void 0);
110
- }
107
+ function maybeAddCardPadding(openCards, column) {
108
+ let div = (0, jsx_runtime_1.jsx)("div", {}, void 0);
111
109
  [...openCards].reverse().forEach((card) => {
112
110
  div = ((0, jsx_runtime_1.jsx)("div", Object.assign({ css: {
113
- ...Css_1.Css.bgColor(card.bgColor).if(!!card.bColor).bc(card.bColor).$,
114
- ...(isFirst && Css_1.Css.plPx(card.pxPx).if(!!card.bColor).bl.$),
115
- ...(isFinal && Css_1.Css.prPx(card.pxPx).if(!!card.bColor).br.$),
111
+ ...Css_1.Css.h100.bgColor(card.bgColor).if(!!card.bColor).bc(card.bColor).$,
112
+ ...(column === "first" && Css_1.Css.plPx(card.pxPx).if(!!card.bColor).bl.$),
113
+ ...(column === "final" && Css_1.Css.prPx(card.pxPx).if(!!card.bColor).br.$),
116
114
  } }, { children: div }), void 0));
117
115
  });
118
116
  return div;
@@ -144,13 +142,14 @@ exports.makeSpacer = makeSpacer;
144
142
  * - card1 content row
145
143
  * - chrome row (card2 open)
146
144
  * - nested card2 content row
147
- * - chrome row (card2 close, card1 cloard)
145
+ * - chrome row (card2 close, card1 close)
148
146
  */
149
147
  function maybeCreateChromeRow(columns, filteredRows, chromeBuffer) {
150
148
  if (chromeBuffer.length > 0) {
151
149
  filteredRows.push([
152
150
  undefined,
153
- (0, jsx_runtime_1.jsx)("div", Object.assign({ css: Css_1.Css.gc(`span ${columns.length}`).$ }, { children: chromeBuffer.map((c, i) => ((0, jsx_runtime_1.jsx)(react_1.Fragment, { children: c }, i))) }), void 0),
151
+ // We add 2 to account for our dedicated open/close columns
152
+ (0, jsx_runtime_1.jsx)("div", Object.assign({ css: Css_1.Css.gc(`span ${columns.length + 2}`).$ }, { children: chromeBuffer.map((c, i) => ((0, jsx_runtime_1.jsx)(react_1.Fragment, { children: c }, i))) }), void 0),
154
153
  ]);
155
154
  // clear the buffer
156
155
  chromeBuffer.splice(0, chromeBuffer.length);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.71.4",
3
+ "version": "2.71.8",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",