@homebound/beam 2.111.0 → 2.112.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.
@@ -245,6 +245,8 @@ export declare type GridColumn<R extends Kinded, S = {}> = {
245
245
  clientSideSort?: boolean;
246
246
  /** This column's sort by value (if server-side sorting). */
247
247
  serverSideSortKey?: S;
248
+ /** Allows the column to stay in place when the user scrolls horizontally */
249
+ sticky?: "left" | "right";
248
250
  };
249
251
  export declare const nonKindGridColumnKeys: string[];
250
252
  /** Allows rendering a specific cell. */
@@ -284,6 +286,8 @@ export declare type GridCellContent = {
284
286
  indent?: 1 | 2;
285
287
  colspan?: number;
286
288
  typeScale?: Typography;
289
+ /** Allows the cell to stay in place when the user scrolls horizontally */
290
+ sticky?: "left" | "right";
287
291
  };
288
292
  declare type MaybeFn<T> = T | (() => T);
289
293
  /**
@@ -474,12 +474,12 @@ function GridRow(props) {
474
474
  }),
475
475
  ...maybeApplyFunction(row, rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.rowCss),
476
476
  // Maybe add the sticky header styles
477
- ...(isHeader && stickyHeader ? Css_1.Css.sticky.top(stickyOffset).z1.$ : undefined),
477
+ ...(isHeader && stickyHeader ? Css_1.Css.sticky.top(stickyOffset).z2.$ : undefined),
478
478
  ...(0, nestedCards_1.getNestedCardStyles)(row, openCardStyles, style),
479
479
  };
480
480
  let currentColspan = 1;
481
481
  const rowNode = ((0, jsx_runtime_1.jsx)(Row, Object.assign({ css: rowCss }, others, { "data-gridrow": true }, getCount(row.id), { children: columns.map((column, columnIndex) => {
482
- var _a, _b;
482
+ var _a, _b, _c, _d;
483
483
  if (column.mw) {
484
484
  // Validate the column's minWidth definition if set.
485
485
  if (!column.mw.endsWith("px") && !column.mw.endsWith("%")) {
@@ -500,6 +500,27 @@ function GridRow(props) {
500
500
  const content = toContent(maybeContent, isHeader, canSortColumn, (sorting === null || sorting === void 0 ? void 0 : sorting.on) === "client", style, as, alignment);
501
501
  (0, sortRows_1.ensureClientSideSortValueIsSortable)(sorting, isHeader, column, columnIndex, maybeContent);
502
502
  const maybeNestedCardColumnIndex = columnIndex + (style.nestedCards ? 1 : 0);
503
+ const maybeSticky = (_b = ((isGridCellContent(maybeContent) && maybeContent.sticky) || column.sticky)) !== null && _b !== void 0 ? _b : undefined;
504
+ const maybeStickyColumnStyles = maybeSticky && columnSizes
505
+ ? {
506
+ ...Css_1.Css.sticky.z1.$,
507
+ // Need to apply a background to this cell to avoid content beneath it being shown when sticky.
508
+ // Assumes background is white for non-nestedCard styles. This can be overridden via cellCss.
509
+ ...(((_c = style.nestedCards) === null || _c === void 0 ? void 0 : _c.kinds)
510
+ ? Css_1.Css.bgColor((0, nestedCards_1.getCurrentBgColor)(row, openCardStyles, style.nestedCards.kinds)).$
511
+ : Css_1.Css.bgWhite.$),
512
+ ...(maybeSticky === "left"
513
+ ? Css_1.Css.left(maybeNestedCardColumnIndex === 0
514
+ ? 0
515
+ : `calc(${columnSizes.slice(0, maybeNestedCardColumnIndex).join(" + ")})`).$
516
+ : {}),
517
+ ...(maybeSticky === "right"
518
+ ? Css_1.Css.right(maybeNestedCardColumnIndex + 1 === columnSizes.length
519
+ ? 0
520
+ : `calc(${columnSizes.slice(maybeNestedCardColumnIndex + 1 - columnSizes.length).join(" + ")})`).$
521
+ : {}),
522
+ }
523
+ : {};
503
524
  // Note that it seems expensive to calc a per-cell class name/CSS-in-JS output,
504
525
  // vs. setting global/table-wide CSS like `style.cellCss` on the root grid div with
505
526
  // a few descendent selectors. However, that approach means the root grid-applied
@@ -512,6 +533,8 @@ function GridRow(props) {
512
533
  const cellCss = {
513
534
  // Adding display flex so we can align content within the cells
514
535
  ...Css_1.Css.df.$,
536
+ // Apply sticky column/cell styles
537
+ ...maybeStickyColumnStyles,
515
538
  // Apply any static/all-cell styling
516
539
  ...style.cellCss,
517
540
  // Then override with first/last cell styling
@@ -522,7 +545,7 @@ function GridRow(props) {
522
545
  // Then apply any header-specific override
523
546
  ...(isHeader && style.headerCellCss),
524
547
  // Or level-specific styling
525
- ...(!isHeader && !!style.levels && ((_b = style.levels[level]) === null || _b === void 0 ? void 0 : _b.cellCss)),
548
+ ...(!isHeader && !!style.levels && ((_d = style.levels[level]) === null || _d === void 0 ? void 0 : _d.cellCss)),
526
549
  // The specific cell's css (if any from GridCellContent)
527
550
  ...rowStyleCellCss,
528
551
  // Add any cell specific style overrides
@@ -88,6 +88,12 @@ export declare function getNestedCardStyles(row: GridDataRow<any>, openCardStyle
88
88
  paddingLeft?: import("csstype").Property.PaddingLeft<0 | (string & {})> | undefined;
89
89
  paddingRight?: import("csstype").Property.PaddingRight<0 | (string & {})> | undefined;
90
90
  };
91
+ /**
92
+ * Returns the background color for the row.
93
+ * Either based on the current row's card having a defined background color, or the last opened card's background color
94
+ * Defaults to White.
95
+ */
96
+ export declare function getCurrentBgColor(row: GridDataRow<any>, openCardStyles: NestedCardStyle[] | undefined, nestedKinds: NestedCardStyleByKind): string;
91
97
  /**
92
98
  * Create a spacer between rows of children.
93
99
  *
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isLeafRow = exports.dropChromeRows = exports.ChromeRow = exports.makeSpacer = exports.getNestedCardStyles = exports.wrapCard = exports.makeOpenOrCloseCard = exports.NestedCards = void 0;
3
+ exports.isLeafRow = exports.dropChromeRows = exports.ChromeRow = exports.makeSpacer = exports.getCurrentBgColor = exports.getNestedCardStyles = exports.wrapCard = exports.makeOpenOrCloseCard = exports.NestedCards = void 0;
4
4
  const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const Css_1 = require("../../Css");
@@ -176,6 +176,21 @@ function getNestedCardStyles(row, openCardStyles, style) {
176
176
  };
177
177
  }
178
178
  exports.getNestedCardStyles = getNestedCardStyles;
179
+ /**
180
+ * Returns the background color for the row.
181
+ * Either based on the current row's card having a defined background color, or the last opened card's background color
182
+ * Defaults to White.
183
+ */
184
+ function getCurrentBgColor(row, openCardStyles, nestedKinds) {
185
+ if (nestedKinds[row.kind]) {
186
+ return nestedKinds[row.kind].bgColor;
187
+ }
188
+ if (openCardStyles && openCardStyles.length > 0) {
189
+ return openCardStyles[openCardStyles.length - 1].bgColor;
190
+ }
191
+ return Css_1.Palette.White;
192
+ }
193
+ exports.getCurrentBgColor = getCurrentBgColor;
179
194
  /**
180
195
  * Create a spacer between rows of children.
181
196
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.111.0",
3
+ "version": "2.112.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",