@homebound/beam 4.41.0 → 4.42.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.
package/dist/index.d.cts CHANGED
@@ -5974,6 +5974,8 @@ type RowProps<R extends Kinded> = {
5974
5974
  setResizedWidth: (columnId: string, width: number, columnIndex: number) => void;
5975
5975
  disableColumnResizing: boolean;
5976
5976
  calculatePreviewWidth: (columnId: string, newWidth: number, columnIndex: number) => number;
5977
+ /** Column ids that take `columnStriping`. Stable until the visible columns change. */
5978
+ stripedColumnIds?: ReadonlySet<string>;
5977
5979
  onDragStart?: (row: GridDataRow<R>, event: React__default.DragEvent<HTMLElement>) => void;
5978
5980
  onDragEnd?: (row: GridDataRow<R>, event: React__default.DragEvent<HTMLElement>) => void;
5979
5981
  onDrop?: (row: GridDataRow<R>, event: React__default.DragEvent<HTMLElement>) => void;
@@ -6324,6 +6326,8 @@ type GridStyle = {
6324
6326
  });
6325
6327
  /** Allows for customization of the background color used to denote an "active" row */
6326
6328
  activeBgColor?: BeamColor;
6329
+ /** Resolved `columnStriping` color. */
6330
+ columnStripeColor?: BeamColor;
6327
6331
  /** Defines styles for the group row which holds the selected rows that have been filtered out */
6328
6332
  keptGroupRowCss?: Properties;
6329
6333
  /** Defines styles for the last row `keptGroup` to provide separation from the rest of the table */
@@ -6356,6 +6360,11 @@ type GridStyleDef = {
6356
6360
  highlightOnHover?: boolean;
6357
6361
  /** Rounds the top corners of the first head-row cells. Defaults to true */
6358
6362
  roundedHeader?: boolean;
6363
+ /**
6364
+ * Zebra on the 2nd, 4th, 6th… content column. A leading group is striped only when a content column precedes it.
6365
+ * Select, collapse, and gutter columns are skipped. A column `bgColor` wins.
6366
+ */
6367
+ columnStriping?: BeamColor;
6359
6368
  };
6360
6369
  declare const getTableStyles: (props?: GridStyleDef) => GridStyle;
6361
6370
  /** Defines row-specific styling for each given row `kind` in `R` */
@@ -10336,8 +10345,6 @@ declare function useSetupColumnSizes<R extends Kinded>(style: GridStyle, columns
10336
10345
  declare function groupColumns<T extends Kinded>(opts: {
10337
10346
  id: string;
10338
10347
  header: string;
10339
- /** Paints every cell in the group. A leaf's own `bgColor` wins. */
10340
- bgColor?: BeamColor;
10341
10348
  columns: Array<Omit<GridColumn<T>, "groupHeader">>;
10342
10349
  }): GridColumn<T>[];
10343
10350
  /** Provides default styling for a GridColumn representing a Date. */
package/dist/index.d.ts CHANGED
@@ -5974,6 +5974,8 @@ type RowProps<R extends Kinded> = {
5974
5974
  setResizedWidth: (columnId: string, width: number, columnIndex: number) => void;
5975
5975
  disableColumnResizing: boolean;
5976
5976
  calculatePreviewWidth: (columnId: string, newWidth: number, columnIndex: number) => number;
5977
+ /** Column ids that take `columnStriping`. Stable until the visible columns change. */
5978
+ stripedColumnIds?: ReadonlySet<string>;
5977
5979
  onDragStart?: (row: GridDataRow<R>, event: React__default.DragEvent<HTMLElement>) => void;
5978
5980
  onDragEnd?: (row: GridDataRow<R>, event: React__default.DragEvent<HTMLElement>) => void;
5979
5981
  onDrop?: (row: GridDataRow<R>, event: React__default.DragEvent<HTMLElement>) => void;
@@ -6324,6 +6326,8 @@ type GridStyle = {
6324
6326
  });
6325
6327
  /** Allows for customization of the background color used to denote an "active" row */
6326
6328
  activeBgColor?: BeamColor;
6329
+ /** Resolved `columnStriping` color. */
6330
+ columnStripeColor?: BeamColor;
6327
6331
  /** Defines styles for the group row which holds the selected rows that have been filtered out */
6328
6332
  keptGroupRowCss?: Properties;
6329
6333
  /** Defines styles for the last row `keptGroup` to provide separation from the rest of the table */
@@ -6356,6 +6360,11 @@ type GridStyleDef = {
6356
6360
  highlightOnHover?: boolean;
6357
6361
  /** Rounds the top corners of the first head-row cells. Defaults to true */
6358
6362
  roundedHeader?: boolean;
6363
+ /**
6364
+ * Zebra on the 2nd, 4th, 6th… content column. A leading group is striped only when a content column precedes it.
6365
+ * Select, collapse, and gutter columns are skipped. A column `bgColor` wins.
6366
+ */
6367
+ columnStriping?: BeamColor;
6359
6368
  };
6360
6369
  declare const getTableStyles: (props?: GridStyleDef) => GridStyle;
6361
6370
  /** Defines row-specific styling for each given row `kind` in `R` */
@@ -10336,8 +10345,6 @@ declare function useSetupColumnSizes<R extends Kinded>(style: GridStyle, columns
10336
10345
  declare function groupColumns<T extends Kinded>(opts: {
10337
10346
  id: string;
10338
10347
  header: string;
10339
- /** Paints every cell in the group. A leaf's own `bgColor` wins. */
10340
- bgColor?: BeamColor;
10341
10348
  columns: Array<Omit<GridColumn<T>, "groupHeader">>;
10342
10349
  }): GridColumn<T>[];
10343
10350
  /** Provides default styling for a GridColumn representing a Date. */
package/dist/index.js CHANGED
@@ -6440,7 +6440,8 @@ function memoizedTableStyles() {
6440
6440
  vAlign = rowHeight === "fixed" ? "center" : "top",
6441
6441
  cellTypography = "xs",
6442
6442
  highlightOnHover = true,
6443
- roundedHeader = true
6443
+ roundedHeader = true,
6444
+ columnStriping
6444
6445
  } = props;
6445
6446
  const key = safeKeys(props).sort().map((k) => `${k}_${props[k]}`).join("|");
6446
6447
  if (!cache[key]) {
@@ -6749,6 +6750,9 @@ function memoizedTableStyles() {
6749
6750
  paddingTop: "pt_4px",
6750
6751
  paddingBottom: "pb_4px"
6751
6752
  }
6753
+ } : {},
6754
+ ...columnStriping ? {
6755
+ columnStripeColor: columnStriping
6752
6756
  } : {}
6753
6757
  };
6754
6758
  }
@@ -6857,7 +6861,8 @@ var gridStyleDefKeysRecord = {
6857
6861
  vAlign: true,
6858
6862
  cellTypography: true,
6859
6863
  highlightOnHover: true,
6860
- roundedHeader: true
6864
+ roundedHeader: true,
6865
+ columnStriping: true
6861
6866
  };
6862
6867
  function isGridStyleDef(style) {
6863
6868
  const keys = safeKeys(style);
@@ -9102,7 +9107,6 @@ function groupColumns(opts) {
9102
9107
  const {
9103
9108
  id,
9104
9109
  header,
9105
- bgColor,
9106
9110
  columns
9107
9111
  } = opts;
9108
9112
  return columns.map((column2) => ({
@@ -9112,7 +9116,6 @@ function groupColumns(opts) {
9112
9116
  groupId: id,
9113
9117
  groupLabel: header,
9114
9118
  groupHeader: header,
9115
- bgColor: column2.bgColor ?? bgColor,
9116
9119
  name: prefixGroupColumnName(header, column2.name)
9117
9120
  }));
9118
9121
  }
@@ -10463,6 +10466,7 @@ function RowImpl(props) {
10463
10466
  setResizedWidth,
10464
10467
  disableColumnResizing = true,
10465
10468
  calculatePreviewWidth,
10469
+ stripedColumnIds,
10466
10470
  onDragStart,
10467
10471
  onDragEnd,
10468
10472
  onDrop,
@@ -10477,6 +10481,7 @@ function RowImpl(props) {
10477
10481
  api,
10478
10482
  visibleColumns: columns
10479
10483
  } = tableState;
10484
+ const columnStripeColor = style.columnStripeColor;
10480
10485
  const {
10481
10486
  row,
10482
10487
  api: rowApi,
@@ -10674,6 +10679,12 @@ function RowImpl(props) {
10674
10679
  // Add right border on expandable header cells except the last column
10675
10680
  ...isExpandableHeader && columnIndex + currentColspan < columns.length && style.expandableHeaderNonLastColumnCss,
10676
10681
  ...isGroupHeader && style.groupHeaderCss,
10682
+ ...columnStripeColor && stripedColumnIds?.has(column2.id) && {
10683
+ backgroundColor: ["bgColor_var", {
10684
+ "--backgroundColor": maybeCssVar_12(maybeCssVar(columnStripeColor))
10685
+ }]
10686
+ },
10687
+ // A leaf background is explicit and wins over the stripe.
10677
10688
  ...column2.bgColor && {
10678
10689
  backgroundColor: ["bgColor_var", {
10679
10690
  "--backgroundColor": maybeCssVar_12(column2.bgColor)
@@ -14127,6 +14138,7 @@ function GridTable(props) {
14127
14138
  const columns = useComputed(() => {
14128
14139
  return tableState.visibleColumns;
14129
14140
  }, [tableState]);
14141
+ const stripedColumnIds = useMemo16(() => style.columnStripeColor ? getStripedColumnIds(columns) : void 0, [columns, style.columnStripeColor]);
14130
14142
  tableState.initSortState(props.sorting, columns);
14131
14143
  const {
14132
14144
  getCount
@@ -14256,7 +14268,8 @@ function GridTable(props) {
14256
14268
  resizedWidths,
14257
14269
  setResizedWidth: handleColumnResize,
14258
14270
  disableColumnResizing,
14259
- calculatePreviewWidth
14271
+ calculatePreviewWidth,
14272
+ stripedColumnIds
14260
14273
  } }, rs.key);
14261
14274
  const makeCompanionRow = (rs, resolved, isFirstBodyRow, isLastBodyRow) => {
14262
14275
  const levelStyle = style.levels && (typeof style.levels === "function" ? style.levels(rs.level) : style.levels[rs.level]);
@@ -14307,7 +14320,7 @@ function GridTable(props) {
14307
14320
  visibleDataRows2 = visibleDataRows2.slice(0, filterMaxRows);
14308
14321
  }
14309
14322
  return [tableHeadRows2, visibleDataRows2, keptSelectedRows2, pinnedRows2, tooManyClientSideRows2];
14310
- }, [as, api, style, rowStyles, maybeStyle, columnSizes, columns.length, getCount, filterMaxRows, cardHeight, cardImageFit]);
14323
+ }, [as, api, style, rowStyles, maybeStyle, columnSizes, columns.length, stripedColumnIds, getCount, filterMaxRows, cardHeight, cardImageFit]);
14311
14324
  if (props.rowLookup) props.rowLookup.current = api.lookup;
14312
14325
  const noData = visibleDataRows.length === 0 && pinnedRows.length === 0;
14313
14326
  const firstRowMessage = noData && !emptyState && fallbackMessage || tooManyClientSideRows && "Hiding some rows, use filter..." || infoMessage;
@@ -14716,6 +14729,32 @@ function useColumnMeasureWidth() {
14716
14729
  return void 0;
14717
14730
  }
14718
14731
  var CARD_MIN_WIDTH_PX = 330;
14732
+ function getStripedColumnIds(columns) {
14733
+ const ids = /* @__PURE__ */ new Set();
14734
+ const contentColumns = columns.filter(isContentColumn);
14735
+ if (contentColumns.some((column2) => column2.groupId)) {
14736
+ const firstGroupStripes = contentColumns.findIndex((column2) => column2.groupId) > 0;
14737
+ const ordinals = /* @__PURE__ */ new Map();
14738
+ for (const column2 of contentColumns) {
14739
+ const {
14740
+ groupId
14741
+ } = column2;
14742
+ if (!groupId) continue;
14743
+ let ordinal = ordinals.get(groupId);
14744
+ if (ordinal === void 0) {
14745
+ ordinal = ordinals.size;
14746
+ ordinals.set(groupId, ordinal);
14747
+ }
14748
+ const stripes = firstGroupStripes ? ordinal % 2 === 0 : ordinal % 2 === 1;
14749
+ if (stripes) ids.add(column2.id);
14750
+ }
14751
+ return ids;
14752
+ }
14753
+ contentColumns.forEach((column2, ordinal) => {
14754
+ if (ordinal % 2 === 1) ids.add(column2.id);
14755
+ });
14756
+ return ids;
14757
+ }
14719
14758
 
14720
14759
  // src/components/ToggleChip.tsx
14721
14760
  import { trussProps as trussProps34 } from "@homebound/truss/runtime";