@homebound/beam 2.115.0 → 2.117.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.
@@ -188,8 +188,10 @@ export declare type GridTableApi<R extends Kinded> = {
188
188
  scrollToIndex: (index: number) => void;
189
189
  /** Returns the ids of currently-selected rows. */
190
190
  getSelectedRowIds(): string[];
191
+ getSelectedRowIds<K extends R["kind"]>(kind: K): string[];
191
192
  /** Returns the currently-selected rows. */
192
193
  getSelectedRows(): GridDataRow<R>[];
194
+ getSelectedRows<K extends R["kind"]>(kind: K): GridDataRow<DiscriminateUnion<R, "kind", K>>[];
193
195
  /** Sets the internal state of 'activeRowId' */
194
196
  setActiveRowId: (id: string | undefined) => void;
195
197
  };
@@ -259,6 +261,8 @@ export declare type GridColumn<R extends Kinded, S = {}> = {
259
261
  serverSideSortKey?: S;
260
262
  /** Allows the column to stay in place when the user scrolls horizontally */
261
263
  sticky?: "left" | "right";
264
+ /** Prevent column from supporting RowStyle.onClick/rowLink in order to avoid nested interactivity. Defaults to true */
265
+ wrapAction?: false;
262
266
  };
263
267
  export declare const nonKindGridColumnKeys: string[];
264
268
  /** Allows rendering a specific cell. */
@@ -95,12 +95,20 @@ function GridTable(props) {
95
95
  const tableRef = (0, react_1.useRef)(null);
96
96
  const api = (0, react_1.useRef)({
97
97
  scrollToIndex: (index) => virtuosoRef.current && virtuosoRef.current.scrollToIndex(index),
98
- getSelectedRowIds: () => rowState.selectedIds,
99
- getSelectedRows() {
98
+ getSelectedRowIds(kind) {
99
+ if (kind === undefined) {
100
+ return rowState.selectedIds;
101
+ }
102
+ else {
103
+ return this.getSelectedRows(kind).map((row) => row.id);
104
+ }
105
+ },
106
+ // The any is not great, but getting the overload to handle the optional kind is annoying
107
+ getSelectedRows(kind) {
100
108
  const ids = rowState.selectedIds;
101
109
  const selected = [];
102
110
  (0, visitor_1.visit)(rows, (row) => {
103
- if (ids.includes(row.id)) {
111
+ if (ids.includes(row.id) && (!kind || row.kind === kind)) {
104
112
  selected.push(row);
105
113
  }
106
114
  });
@@ -113,7 +121,7 @@ function GridTable(props) {
113
121
  }
114
122
  (0, react_1.useEffect)(() => {
115
123
  rowState.activeRowId = activeRowId;
116
- }, [activeRowId]);
124
+ }, [rowState, activeRowId]);
117
125
  // We track render count at the table level, which seems odd (we should be able to track this
118
126
  // internally within each GridRow using a useRef), but we have suspicions that react-virtuoso
119
127
  // (or us) is resetting component state more than necessary, so we track render counts from
@@ -209,6 +217,7 @@ function GridTable(props) {
209
217
  observeRows,
210
218
  columnSizes,
211
219
  collapsedIds,
220
+ getCount,
212
221
  ]);
213
222
  let tooManyClientSideRows = false;
214
223
  if (filterMaxRows && filteredRows.length > filterMaxRows) {
@@ -487,6 +496,7 @@ function GridRow(props) {
487
496
  let currentColspan = 1;
488
497
  const rowNode = ((0, jsx_runtime_1.jsx)(Row, Object.assign({ css: rowCss }, others, { "data-gridrow": true }, getCount(row.id), { children: columns.map((column, columnIndex) => {
489
498
  var _a, _b, _c, _d, _e;
499
+ const { wrapAction = true } = column;
490
500
  if (column.mw) {
491
501
  // Validate the column's minWidth definition if set.
492
502
  if (!column.mw.endsWith("px") && !column.mw.endsWith("%")) {
@@ -569,11 +579,11 @@ function GridRow(props) {
569
579
  },
570
580
  ...(column.mw ? Css_1.Css.mw(column.mw).$ : {}),
571
581
  };
572
- const renderFn = (rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.renderCell) || (rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.rowLink)
582
+ const renderFn = ((rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.renderCell) || (rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.rowLink)) && wrapAction
573
583
  ? rowLinkRenderFn(as)
574
584
  : isHeader
575
585
  ? headerRenderFn(columns, column, sortState, setSortKey, as)
576
- : (rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.onClick)
586
+ : (rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.onClick) && wrapAction
577
587
  ? rowClickRenderFn(as, api)
578
588
  : defaultRenderFn(as);
579
589
  return renderFn(columnIndex, cellCss, content, row, rowStyle);
@@ -41,6 +41,7 @@ function selectColumn(columnDef) {
41
41
  align: "center",
42
42
  // Defining `w: 48px` to accommodate for the `16px` wide checkbox and `16px` of padding on either side.
43
43
  w: "48px",
44
+ wrapAction: false,
44
45
  // Use any of the user's per-row kind methods if they have them.
45
46
  ...columnDef,
46
47
  };
@@ -63,6 +64,7 @@ function collapseColumn(columnDef) {
63
64
  align: "center",
64
65
  // Defining `w: 38px` based on the designs
65
66
  w: "38px",
67
+ wrapAction: false,
66
68
  ...columnDef,
67
69
  };
68
70
  return (0, index_1.newMethodMissingProxy)(base, (key) => {
@@ -13,7 +13,7 @@ exports.defaultStyle = {
13
13
  indentOneCss: Css_1.Css.pl4.$,
14
14
  indentTwoCss: Css_1.Css.pl7.$,
15
15
  headerCellCss: Css_1.Css.nowrap.py1.bgGray100.aife.$,
16
- firstRowMessageCss: Css_1.Css.tc.p3.$,
16
+ firstRowMessageCss: Css_1.Css.tc.py3.$,
17
17
  };
18
18
  /** Tightens up the padding of rows, great for rows that have form elements in them. */
19
19
  exports.condensedStyle = {
@@ -21,6 +21,7 @@ exports.condensedStyle = {
21
21
  headerCellCss: Css_1.Css.bgGray100.tinyEm.$,
22
22
  cellCss: Css_1.Css.aic.sm.py1.px2.$,
23
23
  rootCss: Css_1.Css.dg.gray700.xs.$,
24
+ firstRowMessageCss: Css_1.Css.tc.py2.$,
24
25
  };
25
26
  /** Renders each row as a card. */
26
27
  exports.cardStyle = {
@@ -44,6 +45,7 @@ exports.beamFixedStyle = {
44
45
  cellCss: Css_1.Css.gray900.xs.bgWhite.aic.nowrap.pxPx(12).hPx(36).boxShadow(`inset 0 -1px 0 ${Css_1.Palette.Gray100}`).$,
45
46
  emptyCell: "-",
46
47
  presentationSettings: { borderless: true, typeScale: "xs", wrap: false },
48
+ firstRowMessageCss: Css_1.Css.tc.py3.$,
47
49
  // Included as a hacky "treat indent as deprecated for this table" hint to GridTable
48
50
  levels: {},
49
51
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.115.0",
3
+ "version": "2.117.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",