@homebound/beam 2.148.0 → 2.150.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.
@@ -222,6 +222,7 @@ export declare type DiscriminateUnion<T, K extends keyof T, V extends T[K]> = T
222
222
  declare type GridRowKind<R extends Kinded, P extends R["kind"]> = DiscriminateUnion<R, "kind", P> & {
223
223
  id: string;
224
224
  children: GridDataRow<R>[];
225
+ selectable?: false;
225
226
  };
226
227
  /**
227
228
  * Defines how a single column will render each given row `kind` in `R`.
@@ -307,10 +308,12 @@ export declare type GridCellContent = {
307
308
  indent?: 1 | 2;
308
309
  colspan?: number;
309
310
  typeScale?: Typography;
310
- /** Allows the cell to stay in place when the user scrolls horizontally */
311
+ /** Allows the cell to stay in place when the user scrolls horizontally, i.e. frozen columns. */
311
312
  sticky?: "left" | "right";
312
313
  /** If provided, content of the cell will be wrapped within a <button /> or <a /> tag depending on if the value is a function or a string. */
313
314
  onClick?: () => {} | string;
315
+ /** Custom css to apply directly to this cell, i.e. cell-specific borders. */
316
+ css?: Properties;
314
317
  };
315
318
  declare type MaybeFn<T> = T | (() => T);
316
319
  /**
@@ -333,6 +336,8 @@ export declare type GridDataRow<R extends Kinded> = {
333
336
  data: unknown;
334
337
  /** Whether to have the row collapsed (children not visible) on initial load. This will be ignore in subsequent re-renders of the table */
335
338
  initCollapsed?: boolean;
339
+ /** Whether row can be selected */
340
+ selectable?: false;
336
341
  } & IfAny<R, {}, DiscriminateUnion<R, "kind", R["kind"]>>;
337
342
  declare type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N;
338
343
  /** Return the content for a given column def applied to a given row. */
@@ -588,6 +588,8 @@ function GridRow(props) {
588
588
  : {}),
589
589
  // Add any cell specific style overrides
590
590
  ...(isGridCellContent(maybeContent) && maybeContent.typeScale ? Css_1.Css[maybeContent.typeScale].$ : {}),
591
+ // And any cell specific css
592
+ ...(isGridCellContent(maybeContent) && maybeContent.css ? maybeContent.css : {}),
591
593
  // Define the width of the column on each cell. Supports col spans.
592
594
  ...{
593
595
  width: `calc(${columnSizes
@@ -39,19 +39,14 @@ class GridTableApiImpl {
39
39
  this.virtuosoRef.current && this.virtuosoRef.current.scrollToIndex(index);
40
40
  }
41
41
  getSelectedRowIds(kind) {
42
- if (kind === undefined) {
43
- return this.rowState.selectedIds;
44
- }
45
- else {
46
- return this.getSelectedRows(kind).map((row) => row.id);
47
- }
42
+ return this.getSelectedRows(kind).map((row) => row.id);
48
43
  }
49
44
  // The any is not great, but getting the overload to handle the optional kind is annoying
50
45
  getSelectedRows(kind) {
51
46
  const ids = this.rowState.selectedIds;
52
47
  const selected = [];
53
48
  (0, visitor_1.visit)(this.rowState.rows, (row) => {
54
- if (ids.includes(row.id) && (!kind || row.kind === kind)) {
49
+ if (row.selectable !== false && ids.includes(row.id) && (!kind || row.kind === kind)) {
55
50
  selected.push(row);
56
51
  }
57
52
  });
@@ -1,4 +1,7 @@
1
- /** Provides a checkbox to show/drive this row's selected state. */
2
- export declare function SelectToggle({ id }: {
1
+ interface SelectToggleProps {
3
2
  id: string;
4
- }): import("@emotion/react/jsx-runtime").JSX.Element;
3
+ disabled?: boolean;
4
+ }
5
+ /** Provides a checkbox to show/drive this row's selected state. */
6
+ export declare function SelectToggle({ id, disabled }: SelectToggleProps): import("@emotion/react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -7,12 +7,12 @@ const RowState_1 = require("./RowState");
7
7
  const index_1 = require("../../hooks/index");
8
8
  const index_2 = require("../../inputs/index");
9
9
  /** Provides a checkbox to show/drive this row's selected state. */
10
- function SelectToggle({ id }) {
10
+ function SelectToggle({ id, disabled }) {
11
11
  const { rowState } = (0, react_1.useContext)(RowState_1.RowStateContext);
12
12
  const state = (0, index_1.useComputed)(() => rowState.getSelected(id), [rowState]);
13
13
  const selected = state === "checked" ? true : state === "unchecked" ? false : "indeterminate";
14
- return ((0, jsx_runtime_1.jsx)(index_2.Checkbox, { label: "Select", checkboxOnly: true, selected: selected, onChange: (selected) => {
14
+ return ((0, jsx_runtime_1.jsx)(index_2.Checkbox, { checkboxOnly: true, disabled: disabled, label: "Select", onChange: (selected) => {
15
15
  rowState.selectRow(id, selected);
16
- } }, void 0));
16
+ }, selected: selected }, void 0));
17
17
  }
18
18
  exports.SelectToggle = SelectToggle;
@@ -47,7 +47,9 @@ function selectColumn(columnDef) {
47
47
  ...columnDef,
48
48
  };
49
49
  return (0, index_1.newMethodMissingProxy)(base, (key) => {
50
- return (data, { row }) => ({ content: (0, jsx_runtime_1.jsx)(SelectToggle_1.SelectToggle, { id: row.id }, void 0) });
50
+ return (data, { row }) => ({
51
+ content: (0, jsx_runtime_1.jsx)(SelectToggle_1.SelectToggle, { id: row.id, disabled: row.selectable === false }, void 0),
52
+ });
51
53
  });
52
54
  }
53
55
  exports.selectColumn = selectColumn;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from "./Css";
2
- export type { HasIdAndName, CheckFn } from "./types";
2
+ export type { HasIdAndName, CheckFn, DateRange } from "./types";
3
3
  export * from "./components";
4
4
  export * from "./forms";
5
5
  export * from "./hooks";
@@ -25,9 +25,10 @@ function CheckboxBase(props) {
25
25
  .maxw((0, Css_1.px)(344))
26
26
  .if(isDisabled).cursorNotAllowed.$, "aria-label": label }, { children: [(0, jsx_runtime_1.jsx)(react_aria_1.VisuallyHidden, { children: (0, jsx_runtime_1.jsx)("input", Object.assign({ ref: ref }, (0, react_aria_1.mergeProps)(inputProps, focusProps), tid), void 0) }, void 0), (0, jsx_runtime_1.jsx)("span", Object.assign({}, hoverProps, { css: {
27
27
  ...baseStyles,
28
- ...((isSelected || isIndeterminate) && filledBoxStyles),
29
- ...((isSelected || isIndeterminate) && isHovered && filledBoxHoverStyles),
28
+ ...(((isSelected && !isDisabled) || isIndeterminate) && filledBoxStyles),
29
+ ...(((isSelected && !isDisabled) || isIndeterminate) && isHovered && filledBoxHoverStyles),
30
30
  ...(isDisabled && disabledBoxStyles),
31
+ ...(isDisabled && isSelected && disabledSelectedBoxStyles),
31
32
  ...(isFocusVisible && focusRingStyles),
32
33
  ...(isHovered && hoverBorderStyles),
33
34
  ...markStyles,
@@ -40,7 +41,8 @@ exports.CheckboxBase = CheckboxBase;
40
41
  const baseStyles = Css_1.Css.hPx(16).mw((0, Css_1.px)(16)).relative.ba.bGray300.br4.bgWhite.transition.$;
41
42
  const filledBoxStyles = Css_1.Css.bLightBlue700.bgLightBlue700.$;
42
43
  const filledBoxHoverStyles = Css_1.Css.bgLightBlue900.$;
43
- const disabledBoxStyles = Css_1.Css.bGray400.bGray100.$;
44
+ const disabledBoxStyles = Css_1.Css.bgGray50.bGray100.$;
45
+ const disabledSelectedBoxStyles = Css_1.Css.bgGray400.bGray400.$;
44
46
  const disabledColor = Css_1.Css.gray300.$;
45
47
  const focusRingStyles = Css_1.Css.bshFocus.$;
46
48
  const hoverBorderStyles = Css_1.Css.bLightBlue900.$;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.148.0",
3
+ "version": "2.150.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",