@homebound/beam 2.105.8 → 2.106.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.
@@ -48,6 +48,12 @@ export interface GridStyle {
48
48
  /** Default content to put into an empty cell */
49
49
  emptyCell?: ReactNode;
50
50
  presentationSettings?: Pick<PresentationFieldProps, "borderless" | "typeScale"> & Pick<PresentationContextProps, "wrap">;
51
+ /** Minimum table width in pixels. Used when calculating columns sizes */
52
+ minWidthPx?: number;
53
+ /** Css to apply at each level of a parent/child nested table. */
54
+ levels?: Record<number, {
55
+ cellCss: Properties;
56
+ }>;
51
57
  }
52
58
  export declare type NestedCardStyleByKind = Record<string, NestedCardStyle>;
53
59
  export interface NestedCardsStyle {
@@ -164,6 +170,8 @@ export interface GridTableProps<R extends Kinded, S, X> {
164
170
  xss?: X;
165
171
  /** Experimental API allowing one to scroll to a table index. Primarily intended for stories at the moment */
166
172
  api?: MutableRefObject<GridTableApi | undefined>;
173
+ /** Experimental, expecting to be removed - Specify the element in which the table should resize its columns against. If not set, the table will resize columns based on its owns container's width */
174
+ resizeTarget?: MutableRefObject<HTMLElement | null>;
167
175
  }
168
176
  /** NOTE: This API is experimental and primarily intended for story and testing purposes */
169
177
  export declare type GridTableApi = {
@@ -190,7 +198,7 @@ export declare function GridTable<R extends Kinded, S = {}, X extends Only<GridT
190
198
  * Calculates column widths using a flexible `calc()` definition that allows for consistent column alignment without the use of `<table />`, CSS Grid, etc layouts.
191
199
  * Enforces only fixed-sized units (% and px)
192
200
  */
193
- export declare function calcColumnSizes(columns: GridColumn<any>[], firstLastColumnWidth: number | undefined): string[];
201
+ export declare function calcColumnSizes(columns: GridColumn<any>[], firstLastColumnWidth: number | undefined, tableWidth: number | undefined, tableMinWidthPx?: number): string[];
194
202
  /**
195
203
  * Given an ADT of type T, performs a look up and returns the type of kind K.
196
204
  *
@@ -24,6 +24,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
25
  exports.matchesFilter = exports.GridCollapseContext = exports.applyRowFn = exports.calcColumnSizes = exports.GridTable = exports.setGridTableDefaults = exports.setDefaultStyle = exports.setRunningInJest = exports.emptyCell = exports.DESC = exports.ASC = void 0;
26
26
  const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
27
+ const utils_1 = require("@react-aria/utils");
27
28
  const memoize_one_1 = __importDefault(require("memoize-one"));
28
29
  const mobx_react_1 = require("mobx-react");
29
30
  const react_1 = __importStar(require("react"));
@@ -39,6 +40,7 @@ const sortRows_1 = require("./sortRows");
39
40
  const useSortState_1 = require("./useSortState");
40
41
  const Css_1 = require("../../Css");
41
42
  const tinycolor2_1 = __importDefault(require("tinycolor2"));
43
+ const use_debounce_1 = require("use-debounce");
42
44
  const _1 = require(".");
43
45
  exports.ASC = "ASC";
44
46
  exports.DESC = "DESC";
@@ -81,10 +83,11 @@ exports.setGridTableDefaults = setGridTableDefaults;
81
83
  */
82
84
  function GridTable(props) {
83
85
  var _a, _b, _c, _d, _e;
84
- const { id = "gridTable", as = "div", columns, rows, style = defaults.style, rowStyles, stickyHeader = defaults.stickyHeader, stickyOffset = "0", xss, sorting, filter, filterMaxRows, fallbackMessage = "No rows found.", infoMessage, setRowCount, observeRows, persistCollapse, api, } = props;
86
+ const { id = "gridTable", as = "div", columns, rows, style = defaults.style, rowStyles, stickyHeader = defaults.stickyHeader, stickyOffset = "0", xss, sorting, filter, filterMaxRows, fallbackMessage = "No rows found.", infoMessage, setRowCount, observeRows, persistCollapse, api, resizeTarget, } = props;
85
87
  const [collapsedIds, collapseAllContext, collapseRowContext] = useToggleIds(rows, persistCollapse);
86
88
  // We only use this in as=virtual mode, but keep this here for rowLookup to use
87
89
  const virtuosoRef = (0, react_1.useRef)(null);
90
+ const tableRef = (0, react_1.useRef)(null);
88
91
  if (api) {
89
92
  api.current = {
90
93
  scrollToIndex: (index) => virtuosoRef.current && virtuosoRef.current.scrollToIndex(index),
@@ -98,12 +101,42 @@ function GridTable(props) {
98
101
  }
99
102
  return rows;
100
103
  }, [columns, rows, sorting, sortState]);
101
- const columnSizes = (0, react_1.useMemo)(() => { var _a; return calcColumnSizes(columns, (_a = style.nestedCards) === null || _a === void 0 ? void 0 : _a.firstLastColumnWidth); }, [columns, (_a = style.nestedCards) === null || _a === void 0 ? void 0 : _a.firstLastColumnWidth]);
104
+ // Calculate the column sizes immediately rather than via the `debounce` method.
105
+ // We do this for Storybook integrations that may use MockDate. MockDate changes the behavior of `new Date()`, which is used by `useDebounce` and essentially turns off the callback.
106
+ const calculateImmediately = (0, react_1.useRef)(true);
107
+ const [tableWidth, setTableWidth] = (0, react_1.useState)();
108
+ // Calc our initial/first render sizes where we won't have a width yet
109
+ const [columnSizes, setColumnSizes] = (0, react_1.useState)(calcColumnSizes(columns, (_a = style.nestedCards) === null || _a === void 0 ? void 0 : _a.firstLastColumnWidth, tableWidth, style.minWidthPx));
110
+ const setTableAndColumnWidths = (0, react_1.useCallback)((width) => {
111
+ var _a;
112
+ setTableWidth(width);
113
+ setColumnSizes(calcColumnSizes(columns, (_a = style.nestedCards) === null || _a === void 0 ? void 0 : _a.firstLastColumnWidth, width, style.minWidthPx));
114
+ }, [setTableWidth, setColumnSizes, columns, style]);
115
+ const setTableAndColumnWidthsDebounced = (0, use_debounce_1.useDebouncedCallback)(setTableAndColumnWidths, 100);
116
+ const onResize = (0, react_1.useCallback)(() => {
117
+ const target = (resizeTarget === null || resizeTarget === void 0 ? void 0 : resizeTarget.current) ? resizeTarget.current : tableRef.current;
118
+ if (target && target.clientWidth !== tableWidth) {
119
+ if (calculateImmediately.current) {
120
+ calculateImmediately.current = false;
121
+ setTableAndColumnWidths(target.clientWidth);
122
+ }
123
+ else {
124
+ setTableAndColumnWidthsDebounced(target.clientWidth);
125
+ }
126
+ }
127
+ }, [
128
+ resizeTarget === null || resizeTarget === void 0 ? void 0 : resizeTarget.current,
129
+ tableRef.current,
130
+ setTableAndColumnWidths,
131
+ calculateImmediately,
132
+ setTableAndColumnWidthsDebounced,
133
+ ]);
134
+ (0, utils_1.useResizeObserver)({ ref: resizeTarget !== null && resizeTarget !== void 0 ? resizeTarget : tableRef, onResize });
102
135
  // Filter + flatten + component-ize the sorted rows.
103
136
  let [headerRows, filteredRows] = (0, react_1.useMemo)(() => {
104
137
  // Break up "foo bar" into `[foo, bar]` and a row must match both `foo` and `bar`
105
138
  const filters = (filter && filter.split(/ +/)) || [];
106
- function makeRowComponent(row) {
139
+ function makeRowComponent(row, level) {
107
140
  // We only pass sortState to header rows, b/c non-headers rows shouldn't have to re-render on sorting
108
141
  // changes, and so by not passing the sortProps, it means the data rows' React.memo will still cache them.
109
142
  const sortProps = row.kind === "header" ? { sorting, sortState, setSortKey } : { sorting };
@@ -118,6 +151,7 @@ function GridTable(props) {
118
151
  stickyOffset,
119
152
  openCards: nestedCards ? nestedCards.currentOpenCards() : undefined,
120
153
  columnSizes,
154
+ level,
121
155
  ...sortProps,
122
156
  }), void 0) }), `${row.kind}-${row.id}`));
123
157
  }
@@ -127,7 +161,7 @@ function GridTable(props) {
127
161
  // Misc state to track our nested card-ification, i.e. interleaved actual rows + chrome rows
128
162
  const nestedCards = !!style.nestedCards && new nestedCards_1.NestedCards(columns, filteredRows, style.nestedCards);
129
163
  // Depth-first to filter
130
- function visit(row) {
164
+ function visit(row, level) {
131
165
  var _a;
132
166
  const matches = filters.length === 0 ||
133
167
  row.pin ||
@@ -136,28 +170,28 @@ function GridTable(props) {
136
170
  let isCard = false;
137
171
  if (matches) {
138
172
  isCard = nestedCards && nestedCards.maybeOpenCard(row);
139
- filteredRows.push([row, makeRowComponent(row)]);
173
+ filteredRows.push([row, makeRowComponent(row, level)]);
140
174
  }
141
175
  const isCollapsed = collapsedIds.includes(row.id);
142
176
  if (!isCollapsed && !!((_a = row.children) === null || _a === void 0 ? void 0 : _a.length)) {
143
177
  nestedCards && matches && nestedCards.addSpacer();
144
- visitRows(row.children, isCard);
178
+ visitRows(row.children, isCard, level + 1);
145
179
  }
146
180
  !(0, nestedCards_1.isLeafRow)(row) && isCard && nestedCards && nestedCards.closeCard();
147
181
  }
148
- function visitRows(rows, addSpacer) {
182
+ function visitRows(rows, addSpacer, level) {
149
183
  const length = rows.length;
150
184
  rows.forEach((row, i) => {
151
185
  if (row.kind === "header") {
152
- headerRows.push([row, makeRowComponent(row)]);
186
+ headerRows.push([row, makeRowComponent(row, level)]);
153
187
  return;
154
188
  }
155
- visit(row);
189
+ visit(row, level);
156
190
  addSpacer && nestedCards && i !== length - 1 && nestedCards.addSpacer();
157
191
  });
158
192
  }
159
193
  // If nestedCards is set, we assume the top-level kind is a card, and so should add spacers between them
160
- visitRows(maybeSorted, !!nestedCards);
194
+ visitRows(maybeSorted, !!nestedCards, 0);
161
195
  nestedCards && nestedCards.done();
162
196
  return [headerRows, filteredRows];
163
197
  }, [
@@ -176,6 +210,7 @@ function GridTable(props) {
176
210
  collapseAllContext,
177
211
  collapseRowContext,
178
212
  observeRows,
213
+ columnSizes,
179
214
  ]);
180
215
  let tooManyClientSideRows = false;
181
216
  if (filterMaxRows && filteredRows.length > filterMaxRows) {
@@ -208,7 +243,7 @@ function GridTable(props) {
208
243
  // just trust the GridTable impl that, at runtime, `as=virtual` will (other than being virtualized)
209
244
  // behave semantically the same as `as=div` did for its tests.
210
245
  const _as = as === "virtual" && runningInJest ? "div" : as;
211
- return ((0, jsx_runtime_1.jsx)(PresentationContext_1.PresentationProvider, Object.assign({ fieldProps: fieldProps, wrap: (_d = style === null || style === void 0 ? void 0 : style.presentationSettings) === null || _d === void 0 ? void 0 : _d.wrap }, { children: renders[_as](style, id, columns, headerRows, filteredRows, firstRowMessage, stickyHeader, (_e = style.nestedCards) === null || _e === void 0 ? void 0 : _e.firstLastColumnWidth, xss, virtuosoRef) }), void 0));
246
+ return ((0, jsx_runtime_1.jsx)(PresentationContext_1.PresentationProvider, Object.assign({ fieldProps: fieldProps, wrap: (_d = style === null || style === void 0 ? void 0 : style.presentationSettings) === null || _d === void 0 ? void 0 : _d.wrap }, { children: renders[_as](style, id, columns, headerRows, filteredRows, firstRowMessage, stickyHeader, (_e = style.nestedCards) === null || _e === void 0 ? void 0 : _e.firstLastColumnWidth, xss, virtuosoRef, tableRef) }), void 0));
212
247
  }
213
248
  exports.GridTable = GridTable;
214
249
  // Determine which HTML element to use to build the GridTable
@@ -218,10 +253,8 @@ const renders = {
218
253
  virtual: renderVirtual,
219
254
  };
220
255
  /** Renders table using divs with flexbox rows, which is the default render */
221
- function renderDiv(style, id, columns, headerRows, filteredRows, firstRowMessage, _stickyHeader, firstLastColumnWidth, xss, _virtuosoRef) {
222
- return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ css: {
223
- // Ensure all rows extend the same width
224
- ...Css_1.Css.mw("fit-content").$,
256
+ function renderDiv(style, id, columns, headerRows, filteredRows, firstRowMessage, _stickyHeader, firstLastColumnWidth, xss, _virtuosoRef, tableRef) {
257
+ return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ ref: tableRef, css: {
225
258
  /*
226
259
  Using (n + 3) here to target all rows that are after the first non-header row. Since n starts at 0, we can use
227
260
  the + operator as an offset.
@@ -230,17 +263,19 @@ function renderDiv(style, id, columns, headerRows, filteredRows, firstRowMessage
230
263
  ...(style.betweenRowsCss ? Css_1.Css.addIn(`& > div:nth-of-type(n+3) > *`, style.betweenRowsCss).$ : {}),
231
264
  ...(style.firstNonHeaderRowCss ? Css_1.Css.addIn(`& > div:nth-of-type(2) > *`, style.firstNonHeaderRowCss).$ : {}),
232
265
  ...style.rootCss,
266
+ ...(style.minWidthPx ? Css_1.Css.mwPx(style.minWidthPx).$ : {}),
233
267
  ...xss,
234
268
  }, "data-testid": id }, { children: [headerRows.map(([, node]) => node), firstRowMessage && ((0, jsx_runtime_1.jsx)("div", Object.assign({ css: { ...style.firstRowMessageCss }, "data-gridrow": true }, { children: firstRowMessage }), void 0)), filteredRows.map(([, node]) => node)] }), void 0));
235
269
  }
236
270
  /** Renders as a table, primarily/solely for good print support. */
237
- function renderTable(style, id, columns, headerRows, filteredRows, firstRowMessage, _stickyHeader, _firstLastColumnWidth, xss, _virtuosoRef) {
238
- return ((0, jsx_runtime_1.jsxs)("table", Object.assign({ css: {
271
+ function renderTable(style, id, columns, headerRows, filteredRows, firstRowMessage, _stickyHeader, _firstLastColumnWidth, xss, _virtuosoRef, tableRef) {
272
+ return ((0, jsx_runtime_1.jsxs)("table", Object.assign({ ref: tableRef, css: {
239
273
  ...Css_1.Css.w100.add("borderCollapse", "collapse").$,
240
274
  ...Css_1.Css.addIn("& > tbody > tr ", style.betweenRowsCss || {})
241
275
  // removes border between header and second row
242
276
  .addIn("& > tbody > tr:first-of-type", style.firstNonHeaderRowCss || {}).$,
243
277
  ...style.rootCss,
278
+ ...(style.minWidthPx ? Css_1.Css.mwPx(style.minWidthPx).$ : {}),
244
279
  ...xss,
245
280
  }, "data-testid": id }, { children: [(0, jsx_runtime_1.jsx)("thead", { children: headerRows.map(([, node]) => node) }, void 0), (0, jsx_runtime_1.jsxs)("tbody", { children: [firstRowMessage && ((0, jsx_runtime_1.jsx)("tr", { children: (0, jsx_runtime_1.jsx)("td", Object.assign({ colSpan: columns.length, css: { ...style.firstRowMessageCss } }, { children: firstRowMessage }), void 0) }, void 0)), filteredRows.map(([, node]) => node)] }, void 0)] }), void 0));
246
281
  }
@@ -264,16 +299,19 @@ function renderTable(style, id, columns, headerRows, filteredRows, firstRowMessa
264
299
  * [2]: https://github.com/tannerlinsley/react-virtual/issues/85
265
300
  * [3]: https://github.com/tannerlinsley/react-virtual/issues/108
266
301
  */
267
- function renderVirtual(style, id, columns, headerRows, filteredRows, firstRowMessage, stickyHeader, firstLastColumnWidth, xss, virtuosoRef) {
302
+ function renderVirtual(style, id, columns, headerRows, filteredRows, firstRowMessage, stickyHeader, firstLastColumnWidth, xss, virtuosoRef, tableRef) {
268
303
  // eslint-disable-next-line react-hooks/rules-of-hooks
269
304
  const { footerStyle, listStyle } = (0, react_1.useMemo)(() => {
270
305
  var _a;
271
306
  const { paddingBottom, ...otherRootStyles } = (_a = style.rootCss) !== null && _a !== void 0 ? _a : {};
272
307
  return { footerStyle: { paddingBottom }, listStyle: { ...style, rootCss: otherRootStyles } };
273
308
  }, [style]);
274
- return ((0, jsx_runtime_1.jsx)(react_virtuoso_1.Virtuoso, { overscan: 5, ref: virtuosoRef,
275
- // Add `minWidth: fit-content` to ensure a sticky header and the virtualized table body maintain same width
276
- style: { minWidth: "fit-content" }, components: {
309
+ return ((0, jsx_runtime_1.jsx)(react_virtuoso_1.Virtuoso, { overscan: 5, ref: virtuosoRef, scrollerRef: (ref) => {
310
+ // This is fired multiple times per render. Only set `tableRef.current` if it has changed
311
+ if (ref && tableRef.current !== ref) {
312
+ tableRef.current = ref;
313
+ }
314
+ }, components: {
277
315
  List: VirtualRoot(listStyle, columns, id, firstLastColumnWidth, xss),
278
316
  Footer: () => (0, jsx_runtime_1.jsx)("div", { css: footerStyle }, void 0),
279
317
  },
@@ -330,6 +368,7 @@ const VirtualRoot = (0, memoize_one_1.default)((gs, _columns, id, _firstLastColu
330
368
  ...Css_1.Css.addIn("& > div:first-of-type > *", gs.firstNonHeaderRowCss).$,
331
369
  }),
332
370
  ...gs.rootCss,
371
+ ...(gs.minWidthPx ? Css_1.Css.mwPx(gs.minWidthPx).$ : {}),
333
372
  ...xss,
334
373
  }, "data-testid": id }, { children: children }), void 0));
335
374
  });
@@ -338,7 +377,7 @@ const VirtualRoot = (0, memoize_one_1.default)((gs, _columns, id, _firstLastColu
338
377
  * Calculates column widths using a flexible `calc()` definition that allows for consistent column alignment without the use of `<table />`, CSS Grid, etc layouts.
339
378
  * Enforces only fixed-sized units (% and px)
340
379
  */
341
- function calcColumnSizes(columns, firstLastColumnWidth) {
380
+ function calcColumnSizes(columns, firstLastColumnWidth, tableWidth, tableMinWidthPx = 0) {
342
381
  // For both default columns (1fr) as well as `w: 4fr` columns, we translate the width into an expression that looks like:
343
382
  // calc((100% - allOtherPercent - allOtherPx) * ((myFr / totalFr))`
344
383
  //
@@ -369,6 +408,14 @@ function calcColumnSizes(columns, firstLastColumnWidth) {
369
408
  }, { claimedPercentages: 0, claimedPixels: 0, totalFr: 0 });
370
409
  // This is our "fake but for some reason it lines up better" fr calc
371
410
  function fr(myFr) {
411
+ // If the tableWidth, then return a pixel value
412
+ if (tableWidth) {
413
+ const widthBasis = Math.max(tableWidth, tableMinWidthPx);
414
+ // When the tableWidth is defined, then we need to account for the `firstLastColumnWidth`s.
415
+ return `(${(widthBasis - (claimedPercentages / 100) * widthBasis - claimedPixels - (firstLastColumnWidth !== null && firstLastColumnWidth !== void 0 ? firstLastColumnWidth : 0) * 2) *
416
+ (myFr / totalFr)}px)`;
417
+ }
418
+ // Otherwise return the `calc()` value
372
419
  return `((100% - ${claimedPercentages}% - ${claimedPixels}px) * (${myFr} / ${totalFr}))`;
373
420
  }
374
421
  let sizes = columns.map(({ w }) => {
@@ -390,16 +437,16 @@ function calcColumnSizes(columns, firstLastColumnWidth) {
390
437
  return fr(w);
391
438
  }
392
439
  });
393
- return maybeAddCardColumns(sizes, firstLastColumnWidth);
394
- }
395
- exports.calcColumnSizes = calcColumnSizes;
396
- // If we're doing nested cards, we add extra 1st/last cells...
397
- function maybeAddCardColumns(sizes, firstLastColumnWidth) {
440
+ // If we're doing nested cards, we add extra 1st/last cells...
398
441
  return !firstLastColumnWidth ? sizes : [`${firstLastColumnWidth}px`, ...sizes, `${firstLastColumnWidth}px`];
399
442
  }
443
+ exports.calcColumnSizes = calcColumnSizes;
400
444
  function getIndentationCss(style, rowStyle, columnIndex, maybeContent) {
401
445
  // Look for cell-specific indent or row-specific indent (row-specific is only one the first column)
402
446
  const indent = (isGridCellContent(maybeContent) && maybeContent.indent) || (columnIndex === 0 && (rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.indent));
447
+ if (typeof indent === "number" && style.levels !== undefined) {
448
+ throw new Error("The indent param is deprecated for new beam fixed & flexible styles, use beamNestedFixedStyle or beamNestedFlexibleStyle");
449
+ }
403
450
  return indent === 1 ? style.indentOneCss || {} : indent === 2 ? style.indentTwoCss || {} : {};
404
451
  }
405
452
  function getFirstOrLastCellCss(style, columnIndex, columns) {
@@ -410,7 +457,7 @@ function getFirstOrLastCellCss(style, columnIndex, columns) {
410
457
  }
411
458
  // We extract GridRow to its own mini-component primarily so we can React.memo'ize it.
412
459
  function GridRow(props) {
413
- const { as, columns, row, style, rowStyles, stickyHeader, stickyOffset, sorting, sortState, setSortKey, openCards, columnSizes, ...others } = props;
460
+ const { as, columns, row, style, rowStyles, stickyHeader, stickyOffset, sorting, sortState, setSortKey, openCards, columnSizes, level, ...others } = props;
414
461
  // We treat the "header" kind as special for "good defaults" styling
415
462
  const isHeader = row.kind === "header";
416
463
  const rowStyle = rowStyles === null || rowStyles === void 0 ? void 0 : rowStyles[row.kind];
@@ -437,7 +484,7 @@ function GridRow(props) {
437
484
  };
438
485
  let currentColspan = 1;
439
486
  const rowNode = ((0, jsx_runtime_1.jsx)(Row, Object.assign({ css: rowCss }, others, { "data-gridrow": true }, { children: columns.map((column, columnIndex) => {
440
- var _a;
487
+ var _a, _b;
441
488
  if (column.mw) {
442
489
  // Validate the column's minWidth definition if set.
443
490
  if (!column.mw.endsWith("px") && !column.mw.endsWith("%")) {
@@ -479,17 +526,19 @@ function GridRow(props) {
479
526
  ...getIndentationCss(style, rowStyle, columnIndex, maybeContent),
480
527
  // Then apply any header-specific override
481
528
  ...(isHeader && style.headerCellCss),
529
+ // Or level-specific styling
530
+ ...(!isHeader && !!style.levels && ((_b = style.levels[level]) === null || _b === void 0 ? void 0 : _b.cellCss)),
482
531
  // The specific cell's css (if any from GridCellContent)
483
532
  ...rowStyleCellCss,
484
533
  // Add any cell specific style overrides
485
534
  ...(isGridCellContent(maybeContent) && maybeContent.typeScale ? Css_1.Css[maybeContent.typeScale].$ : {}),
486
535
  // Define the width of the column on each cell. Supports col spans.
487
- ...(columnSizes && {
536
+ ...{
488
537
  width: `calc(${columnSizes
489
538
  .slice(maybeNestedCardColumnIndex, maybeNestedCardColumnIndex + currentColspan)
490
539
  .join(" + ")})`,
491
- ...(column.mw ? Css_1.Css.mw(column.mw).$ : {}),
492
- }),
540
+ },
541
+ ...(column.mw ? Css_1.Css.mw(column.mw).$ : {}),
493
542
  };
494
543
  const renderFn = (rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.renderCell) || (rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.rowLink)
495
544
  ? rowLinkRenderFn(as)
@@ -97,9 +97,8 @@ export declare function getNestedCardStyles(row: GridDataRow<any>, openCardStyle
97
97
  export declare function makeSpacer(height: number, openCards: string[], styles: NestedCardsStyle): Chrome;
98
98
  interface ChromeRowProps {
99
99
  chromeBuffer: ChromeBuffer;
100
- columns: number;
101
100
  }
102
- export declare function ChromeRow({ chromeBuffer, columns }: ChromeRowProps): import("@emotion/react/jsx-runtime").JSX.Element;
101
+ export declare function ChromeRow({ chromeBuffer }: ChromeRowProps): import("@emotion/react/jsx-runtime").JSX.Element;
103
102
  export declare function dropChromeRows<R extends Kinded>(rows: RowTuple<R>[]): [GridDataRow<R>, ReactElement][];
104
103
  export declare function isLeafRow<R extends Kinded>(row: GridDataRow<R>): boolean;
105
104
  export {};
@@ -82,10 +82,7 @@ class NestedCards {
82
82
  */
83
83
  maybeCreateChromeRow() {
84
84
  if (this.chromeBuffer.length > 0) {
85
- this.rows.push([
86
- undefined,
87
- (0, jsx_runtime_1.jsx)(ChromeRow, { chromeBuffer: [...this.chromeBuffer], columns: this.columns.length }, this.chromeRowIndex++),
88
- ]);
85
+ this.rows.push([undefined, (0, jsx_runtime_1.jsx)(ChromeRow, { chromeBuffer: [...this.chromeBuffer] }, this.chromeRowIndex++)]);
89
86
  // clear the Chrome buffer
90
87
  this.chromeBuffer.splice(0, this.chromeBuffer.length);
91
88
  }
@@ -201,10 +198,8 @@ function makeSpacer(height, openCards, styles) {
201
198
  };
202
199
  }
203
200
  exports.makeSpacer = makeSpacer;
204
- function ChromeRow({ chromeBuffer, columns }) {
205
- return (
206
- // We add 2 to account for our dedicated open/close columns
207
- (0, jsx_runtime_1.jsx)("div", Object.assign({ css: Css_1.Css.gc(`span ${columns + 2}`).$ }, { children: chromeBuffer.map((c, i) => ((0, jsx_runtime_1.jsx)(react_1.Fragment, { children: c() }, i))) }), void 0));
201
+ function ChromeRow({ chromeBuffer }) {
202
+ return ((0, jsx_runtime_1.jsx)("div", { children: chromeBuffer.map((c, i) => ((0, jsx_runtime_1.jsx)(react_1.Fragment, { children: c() }, i))) }, void 0));
208
203
  }
209
204
  exports.ChromeRow = ChromeRow;
210
205
  function dropChromeRows(rows) {
@@ -7,6 +7,10 @@ export declare const condensedStyle: GridStyle;
7
7
  /** Renders each row as a card. */
8
8
  export declare const cardStyle: GridStyle;
9
9
  export declare const beamFixedStyle: GridStyle;
10
- export declare const beamFlexibleStyle: GridStyle;
11
10
  export declare const beamGroupRowStyle: Properties;
12
11
  export declare const beamTotalsRowStyle: Properties;
12
+ export declare const beamNestedFixedStyle: GridStyle;
13
+ export declare const beamTotalsFixedStyle: GridStyle;
14
+ export declare const beamFlexibleStyle: GridStyle;
15
+ export declare const beamNestedFlexibleStyle: GridStyle;
16
+ export declare const beamTotalsFlexibleStyle: GridStyle;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.beamTotalsRowStyle = exports.beamGroupRowStyle = exports.beamFlexibleStyle = exports.beamFixedStyle = exports.cardStyle = exports.condensedStyle = exports.defaultStyle = void 0;
3
+ exports.beamTotalsFlexibleStyle = exports.beamNestedFlexibleStyle = exports.beamFlexibleStyle = exports.beamTotalsFixedStyle = exports.beamNestedFixedStyle = exports.beamTotalsRowStyle = exports.beamGroupRowStyle = exports.beamFixedStyle = exports.cardStyle = exports.condensedStyle = exports.defaultStyle = void 0;
4
4
  const Css_1 = require("../../Css");
5
5
  /** Our original table look & feel/style. */
6
6
  exports.defaultStyle = {
@@ -46,13 +46,33 @@ exports.beamFixedStyle = {
46
46
  emptyCell: "-",
47
47
  presentationSettings: { borderless: true, typeScale: "xs", wrap: false },
48
48
  rowHoverColor: Css_1.Palette.Gray200,
49
+ // Included as a hacky "treat indent as deprecated for this table" hint to GridTable
50
+ levels: {},
51
+ };
52
+ // The look & feel for parent rows' cells in a nested parent/child table.
53
+ exports.beamGroupRowStyle = Css_1.Css.xsEm
54
+ .mhPx(56)
55
+ .gray700.bgGray100.boxShadow(`inset 0 -1px 0 ${Css_1.Palette.Gray200}`).$;
56
+ // The look & feel for a totals row's cells.
57
+ exports.beamTotalsRowStyle = Css_1.Css.gray700.smEm.hPx(40).mb1.bgWhite.boxShadow("none").$;
58
+ exports.beamNestedFixedStyle = {
59
+ ...exports.beamFixedStyle,
60
+ levels: { 0: { cellCss: exports.beamGroupRowStyle } },
61
+ };
62
+ exports.beamTotalsFixedStyle = {
63
+ ...exports.beamFixedStyle,
64
+ cellCss: { ...exports.beamFixedStyle.cellCss, ...exports.beamTotalsRowStyle },
49
65
  };
50
66
  exports.beamFlexibleStyle = {
51
67
  ...exports.beamFixedStyle,
52
68
  cellCss: Css_1.Css.xs.bgWhite.aic.p2.boxShadow(`inset 0 -1px 0 ${Css_1.Palette.Gray100}`).$,
53
69
  presentationSettings: { borderless: false, typeScale: "xs", wrap: true },
54
70
  };
55
- exports.beamGroupRowStyle = Css_1.Css.xsEm
56
- .mhPx(56)
57
- .gray700.bgGray100.boxShadow(`inset 0 -1px 0 ${Css_1.Palette.Gray200}`).$;
58
- exports.beamTotalsRowStyle = Css_1.Css.gray700.smEm.hPx(40).mb1.bgWhite.boxShadow("none").$;
71
+ exports.beamNestedFlexibleStyle = {
72
+ ...exports.beamFlexibleStyle,
73
+ levels: { 0: { cellCss: exports.beamGroupRowStyle } },
74
+ };
75
+ exports.beamTotalsFlexibleStyle = {
76
+ ...exports.beamFlexibleStyle,
77
+ cellCss: { ...exports.beamFlexibleStyle.cellCss, ...exports.beamTotalsRowStyle },
78
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.105.8",
3
+ "version": "2.106.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -53,7 +53,8 @@
53
53
  "tinycolor2": "^1.4.2",
54
54
  "tributejs": "^5.1.3",
55
55
  "trix": "^1.3.1",
56
- "use-query-params": "^1.2.2"
56
+ "use-query-params": "^1.2.2",
57
+ "use-debounce": "^7.0.1"
57
58
  },
58
59
  "peerDependencies": {
59
60
  "@emotion/react": ">=11",