@homebound/beam 4.41.0 → 4.42.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.
package/dist/index.cjs CHANGED
@@ -6937,7 +6937,8 @@ function memoizedTableStyles() {
6937
6937
  vAlign = rowHeight === "fixed" ? "center" : "top",
6938
6938
  cellTypography = "xs",
6939
6939
  highlightOnHover = true,
6940
- roundedHeader = true
6940
+ roundedHeader = true,
6941
+ columnStriping
6941
6942
  } = props;
6942
6943
  const key = safeKeys(props).sort().map((k) => `${k}_${props[k]}`).join("|");
6943
6944
  if (!cache[key]) {
@@ -7246,6 +7247,9 @@ function memoizedTableStyles() {
7246
7247
  paddingTop: "pt_4px",
7247
7248
  paddingBottom: "pb_4px"
7248
7249
  }
7250
+ } : {},
7251
+ ...columnStriping ? {
7252
+ columnStripeColor: columnStriping
7249
7253
  } : {}
7250
7254
  };
7251
7255
  }
@@ -7354,7 +7358,8 @@ var gridStyleDefKeysRecord = {
7354
7358
  vAlign: true,
7355
7359
  cellTypography: true,
7356
7360
  highlightOnHover: true,
7357
- roundedHeader: true
7361
+ roundedHeader: true,
7362
+ columnStriping: true
7358
7363
  };
7359
7364
  function isGridStyleDef(style) {
7360
7365
  const keys = safeKeys(style);
@@ -9599,7 +9604,6 @@ function groupColumns(opts) {
9599
9604
  const {
9600
9605
  id,
9601
9606
  header,
9602
- bgColor,
9603
9607
  columns
9604
9608
  } = opts;
9605
9609
  return columns.map((column2) => ({
@@ -9609,7 +9613,6 @@ function groupColumns(opts) {
9609
9613
  groupId: id,
9610
9614
  groupLabel: header,
9611
9615
  groupHeader: header,
9612
- bgColor: column2.bgColor ?? bgColor,
9613
9616
  name: prefixGroupColumnName(header, column2.name)
9614
9617
  }));
9615
9618
  }
@@ -10960,6 +10963,7 @@ function RowImpl(props) {
10960
10963
  setResizedWidth,
10961
10964
  disableColumnResizing = true,
10962
10965
  calculatePreviewWidth,
10966
+ stripedColumnIds,
10963
10967
  onDragStart,
10964
10968
  onDragEnd,
10965
10969
  onDrop,
@@ -10974,6 +10978,7 @@ function RowImpl(props) {
10974
10978
  api,
10975
10979
  visibleColumns: columns
10976
10980
  } = tableState;
10981
+ const columnStripeColor = style.columnStripeColor;
10977
10982
  const {
10978
10983
  row,
10979
10984
  api: rowApi,
@@ -11171,6 +11176,12 @@ function RowImpl(props) {
11171
11176
  // Add right border on expandable header cells except the last column
11172
11177
  ...isExpandableHeader && columnIndex + currentColspan < columns.length && style.expandableHeaderNonLastColumnCss,
11173
11178
  ...isGroupHeader && style.groupHeaderCss,
11179
+ ...columnStripeColor && stripedColumnIds?.has(column2.id) && {
11180
+ backgroundColor: ["bgColor_var", {
11181
+ "--backgroundColor": (0, import_runtime24.maybeCssVar)(maybeCssVar(columnStripeColor))
11182
+ }]
11183
+ },
11184
+ // A leaf background is explicit and wins over the stripe.
11174
11185
  ...column2.bgColor && {
11175
11186
  backgroundColor: ["bgColor_var", {
11176
11187
  "--backgroundColor": (0, import_runtime24.maybeCssVar)(column2.bgColor)
@@ -14624,6 +14635,7 @@ function GridTable(props) {
14624
14635
  const columns = useComputed(() => {
14625
14636
  return tableState.visibleColumns;
14626
14637
  }, [tableState]);
14638
+ const stripedColumnIds = (0, import_react51.useMemo)(() => style.columnStripeColor ? getStripedColumnIds(columns) : void 0, [columns, style.columnStripeColor]);
14627
14639
  tableState.initSortState(props.sorting, columns);
14628
14640
  const {
14629
14641
  getCount
@@ -14753,7 +14765,8 @@ function GridTable(props) {
14753
14765
  resizedWidths,
14754
14766
  setResizedWidth: handleColumnResize,
14755
14767
  disableColumnResizing,
14756
- calculatePreviewWidth
14768
+ calculatePreviewWidth,
14769
+ stripedColumnIds
14757
14770
  } }, rs.key);
14758
14771
  const makeCompanionRow = (rs, resolved, isFirstBodyRow, isLastBodyRow) => {
14759
14772
  const levelStyle = style.levels && (typeof style.levels === "function" ? style.levels(rs.level) : style.levels[rs.level]);
@@ -14804,7 +14817,7 @@ function GridTable(props) {
14804
14817
  visibleDataRows2 = visibleDataRows2.slice(0, filterMaxRows);
14805
14818
  }
14806
14819
  return [tableHeadRows2, visibleDataRows2, keptSelectedRows2, pinnedRows2, tooManyClientSideRows2];
14807
- }, [as, api, style, rowStyles, maybeStyle, columnSizes, columns.length, getCount, filterMaxRows, cardHeight, cardImageFit]);
14820
+ }, [as, api, style, rowStyles, maybeStyle, columnSizes, columns.length, stripedColumnIds, getCount, filterMaxRows, cardHeight, cardImageFit]);
14808
14821
  if (props.rowLookup) props.rowLookup.current = api.lookup;
14809
14822
  const noData = visibleDataRows.length === 0 && pinnedRows.length === 0;
14810
14823
  const firstRowMessage = noData && !emptyState && fallbackMessage || tooManyClientSideRows && "Hiding some rows, use filter..." || infoMessage;
@@ -15213,6 +15226,32 @@ function useColumnMeasureWidth() {
15213
15226
  return void 0;
15214
15227
  }
15215
15228
  var CARD_MIN_WIDTH_PX = 330;
15229
+ function getStripedColumnIds(columns) {
15230
+ const ids = /* @__PURE__ */ new Set();
15231
+ const contentColumns = columns.filter(isContentColumn);
15232
+ if (contentColumns.some((column2) => column2.groupId)) {
15233
+ const firstGroupStripes = contentColumns.findIndex((column2) => column2.groupId) > 0;
15234
+ const ordinals = /* @__PURE__ */ new Map();
15235
+ for (const column2 of contentColumns) {
15236
+ const {
15237
+ groupId
15238
+ } = column2;
15239
+ if (!groupId) continue;
15240
+ let ordinal = ordinals.get(groupId);
15241
+ if (ordinal === void 0) {
15242
+ ordinal = ordinals.size;
15243
+ ordinals.set(groupId, ordinal);
15244
+ }
15245
+ const stripes = firstGroupStripes ? ordinal % 2 === 0 : ordinal % 2 === 1;
15246
+ if (stripes) ids.add(column2.id);
15247
+ }
15248
+ return ids;
15249
+ }
15250
+ contentColumns.forEach((column2, ordinal) => {
15251
+ if (ordinal % 2 === 1) ids.add(column2.id);
15252
+ });
15253
+ return ids;
15254
+ }
15216
15255
 
15217
15256
  // src/components/ToggleChip.tsx
15218
15257
  var import_runtime44 = require("@homebound/truss/runtime");