@homebound/beam 2.104.0 → 2.105.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.
@@ -2,14 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Chip = void 0;
4
4
  const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
5
+ const PresentationContext_1 = require("./PresentationContext");
5
6
  const Css_1 = require("../Css");
6
7
  const useTestIds_1 = require("../utils/useTestIds");
7
8
  /** Kinda like a chip, but read-only, so no `onClick` or `hover`. */
8
9
  function Chip(props) {
10
+ var _a;
9
11
  const { text, xss = {} } = props;
12
+ const { fieldProps } = (0, PresentationContext_1.usePresentationContext)();
13
+ const typeScale = (_a = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.typeScale) !== null && _a !== void 0 ? _a : "sm";
10
14
  const tid = (0, useTestIds_1.useTestIds)(props, "chip");
11
15
  return ((0, jsx_runtime_1.jsx)("span", Object.assign({ css: {
12
- ...Css_1.Css.dif.aic.br16.sm.pl1.px1.pyPx(2).gray900.bgGray200.$,
16
+ ...Css_1.Css[typeScale].dif.aic.br16.pl1.px1.pyPx(2).gray900.bgGray200.$,
13
17
  ...xss,
14
18
  } }, tid, { title: text }, { children: (0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.lineClamp1.breakAll.$ }, { children: text }), void 0) }), void 0));
15
19
  }
@@ -3,10 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Chips = void 0;
4
4
  const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
5
5
  const Chip_1 = require("./Chip");
6
+ const PresentationContext_1 = require("./PresentationContext");
6
7
  const Css_1 = require("../Css");
7
8
  /** Renders a list of `Chip`s, with wrapping & appropriate margin between each `Chip`. */
8
9
  function Chips(props) {
10
+ const { wrap } = (0, PresentationContext_1.usePresentationContext)();
9
11
  const { values, xss = {} } = props;
10
- return ((0, jsx_runtime_1.jsx)("div", Object.assign({ css: { ...Css_1.Css.df.add({ flexWrap: "wrap" }).my1.$, ...xss } }, { children: values.map((value, i) => ((0, jsx_runtime_1.jsx)(Chip_1.Chip, { text: value, xss: Css_1.Css.mr1.mb1.$ }, i))) }), void 0));
12
+ return ((0, jsx_runtime_1.jsx)("div", Object.assign({ css: {
13
+ ...Css_1.Css.df.gap1.whiteSpace("normal").$,
14
+ ...(wrap !== false ? Css_1.Css.add({ flexWrap: "wrap" }).$ : {}),
15
+ ...xss,
16
+ } }, { children: values.map((value, i) => ((0, jsx_runtime_1.jsx)(Chip_1.Chip, { text: value }, i))) }), void 0));
11
17
  }
12
18
  exports.Chips = Chips;
@@ -13,6 +13,7 @@ export interface PresentationFieldProps {
13
13
  export declare type PresentationContextProps = {
14
14
  fieldProps?: PresentationFieldProps;
15
15
  gridTableStyle?: GridStyle;
16
+ wrap?: boolean;
16
17
  };
17
18
  export declare const PresentationContext: import("react").Context<PresentationContextProps>;
18
19
  export declare function PresentationProvider(props: PropsWithChildren<PresentationContextProps>): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -1,4 +1,5 @@
1
1
  import React, { MutableRefObject, ReactElement, ReactNode } from "react";
2
+ import { PresentationContextProps, PresentationFieldProps } from "../PresentationContext";
2
3
  import { GridRowLookup } from "./GridRowLookup";
3
4
  import { Margin, Only, Properties, Xss } from "../../Css";
4
5
  export declare type Kinded = {
@@ -46,6 +47,7 @@ export interface GridStyle {
46
47
  nestedCards?: NestedCardsStyle;
47
48
  /** Default content to put into an empty cell */
48
49
  emptyCell?: ReactNode;
50
+ presentationSettings?: Pick<PresentationFieldProps, "borderless" | "typeScale"> & Pick<PresentationContextProps, "wrap">;
49
51
  }
50
52
  export declare type NestedCardStyleByKind = Record<string, NestedCardStyle>;
51
53
  export interface NestedCardsStyle {
@@ -80,7 +80,7 @@ exports.setGridTableDefaults = setGridTableDefaults;
80
80
  * special styling to the row that uses `kind: "header"`.)
81
81
  */
82
82
  function GridTable(props) {
83
- var _a;
83
+ var _a, _b, _c, _d, _e;
84
84
  const { id = "gridTable", as = "div", columns, rows, style = defaults.style, rowStyles, stickyHeader = defaults.stickyHeader, stickyOffset = "0", xss, sorting, filter, filterMaxRows, fallbackMessage = "No rows found.", infoMessage, setRowCount, observeRows, persistCollapse, api, } = props;
85
85
  const [collapsedIds, collapseAllContext, collapseRowContext] = useToggleIds(rows, persistCollapse);
86
86
  // We only use this in as=virtual mode, but keep this here for rowLookup to use
@@ -98,12 +98,11 @@ function GridTable(props) {
98
98
  }
99
99
  return rows;
100
100
  }, [columns, rows, sorting, sortState]);
101
+ const columnSizes = (0, react_1.useMemo)(() => { var _a; return calcColumnSizes(columns, (_a = style.nestedCards) === null || _a === void 0 ? void 0 : _a.firstLastColumnWidth); }, [columns, (_a = style.nestedCards) === null || _a === void 0 ? void 0 : _a.firstLastColumnWidth]);
101
102
  // Filter + flatten + component-ize the sorted rows.
102
103
  let [headerRows, filteredRows] = (0, react_1.useMemo)(() => {
103
- var _a;
104
104
  // Break up "foo bar" into `[foo, bar]` and a row must match both `foo` and `bar`
105
105
  const filters = (filter && filter.split(/ +/)) || [];
106
- const columnSizes = calcColumnSizes(columns, (_a = style.nestedCards) === null || _a === void 0 ? void 0 : _a.firstLastColumnWidth);
107
106
  function makeRowComponent(row) {
108
107
  // We only pass sortState to header rows, b/c non-headers rows shouldn't have to re-render on sorting
109
108
  // changes, and so by not passing the sortProps, it means the data rows' React.memo will still cache them.
@@ -194,12 +193,22 @@ function GridTable(props) {
194
193
  }, [filteredRows === null || filteredRows === void 0 ? void 0 : filteredRows.length, setRowCount]);
195
194
  const noData = filteredRows.length === 0;
196
195
  const firstRowMessage = (noData && fallbackMessage) || (tooManyClientSideRows && "Hiding some rows, use filter...") || infoMessage;
196
+ const borderless = (_b = style === null || style === void 0 ? void 0 : style.presentationSettings) === null || _b === void 0 ? void 0 : _b.borderless;
197
+ const typeScale = (_c = style === null || style === void 0 ? void 0 : style.presentationSettings) === null || _c === void 0 ? void 0 : _c.typeScale;
198
+ const fieldProps = (0, react_1.useMemo)(() => ({
199
+ hideLabel: true,
200
+ numberAlignment: "right",
201
+ compact: true,
202
+ // Avoid passing `undefined` as it will unset existing PresentationContext settings
203
+ ...(borderless !== undefined ? { borderless } : {}),
204
+ ...(typeScale !== undefined ? { typeScale } : {}),
205
+ }), [borderless, typeScale]);
197
206
  // If we're running in Jest, force using `as=div` b/c jsdom doesn't support react-virtuoso.
198
207
  // This enables still putting the application's business/rendering logic under test, and letting it
199
208
  // just trust the GridTable impl that, at runtime, `as=virtual` will (other than being virtualized)
200
209
  // behave semantically the same as `as=div` did for its tests.
201
210
  const _as = as === "virtual" && runningInJest ? "div" : as;
202
- return ((0, jsx_runtime_1.jsx)(PresentationContext_1.PresentationProvider, Object.assign({ fieldProps: { hideLabel: true, numberAlignment: "right", compact: true } }, { children: renders[_as](style, id, columns, headerRows, filteredRows, firstRowMessage, stickyHeader, (_a = style.nestedCards) === null || _a === void 0 ? void 0 : _a.firstLastColumnWidth, xss, virtuosoRef) }), void 0));
211
+ return ((0, jsx_runtime_1.jsx)(PresentationContext_1.PresentationProvider, Object.assign({ fieldProps: fieldProps, wrap: (_d = style === null || style === void 0 ? void 0 : style.presentationSettings) === null || _d === void 0 ? void 0 : _d.wrap }, { children: renders[_as](style, id, columns, headerRows, filteredRows, firstRowMessage, stickyHeader, (_e = style.nestedCards) === null || _e === void 0 ? void 0 : _e.firstLastColumnWidth, xss, virtuosoRef) }), void 0));
203
212
  }
204
213
  exports.GridTable = GridTable;
205
214
  // Determine which HTML element to use to build the GridTable
@@ -497,6 +506,7 @@ function isJSX(content) {
497
506
  }
498
507
  /** If a column def return just string text for a given row, apply some default styling. */
499
508
  function toContent(content, isHeader, canSortColumn, isClientSideSorting, style, as, alignment) {
509
+ var _a;
500
510
  content = isGridCellContent(content) ? content.content : content;
501
511
  if (typeof content === "function") {
502
512
  // Actually create the JSX by calling `content()` here (which should be as late as
@@ -517,6 +527,9 @@ function toContent(content, isHeader, canSortColumn, isClientSideSorting, style,
517
527
  if (content && typeof content === "string" && isHeader && canSortColumn) {
518
528
  return (0, jsx_runtime_1.jsx)(SortHeader_1.SortHeader, { content: content, iconOnLeft: alignment === "right" }, void 0);
519
529
  }
530
+ else if (content && typeof content === "string" && ((_a = style === null || style === void 0 ? void 0 : style.presentationSettings) === null || _a === void 0 ? void 0 : _a.wrap) === false) {
531
+ return ((0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.mw0.truncate.$, title: content }, { children: content }), void 0));
532
+ }
520
533
  else if (style.emptyCell && isContentEmpty(content)) {
521
534
  // If the content is empty and the user specified an `emptyCell` node, return that.
522
535
  return style.emptyCell;
@@ -10,3 +10,5 @@ export declare function numericColumn<T extends Kinded, S = {}>(columnDef: GridC
10
10
  export declare function actionColumn<T extends Kinded, S = {}>(columnDef: GridColumn<T, S>): GridColumn<T, S>;
11
11
  /** Provides default styling for a GridColumn containing a checkbox. */
12
12
  export declare function selectColumn<T extends Kinded, S = {}>(columnDef: GridColumn<T, S>): GridColumn<T, S>;
13
+ /** Provides default styling for a GridColumn containing the CollapseToggle component. */
14
+ export declare function collapseColumn<T extends Kinded, S = {}>(columnDef: GridColumn<T, S>): GridColumn<T, S>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.selectColumn = exports.actionColumn = exports.numericColumn = exports.dateColumn = exports.column = void 0;
3
+ exports.collapseColumn = exports.selectColumn = exports.actionColumn = exports.numericColumn = exports.dateColumn = exports.column = void 0;
4
4
  /** Provides default styling for a GridColumn representing a Date. */
5
5
  function column(columnDef) {
6
6
  return { ...columnDef };
@@ -28,3 +28,9 @@ function selectColumn(columnDef) {
28
28
  return { clientSideSort: false, ...columnDef, align: "center", w: "48px" };
29
29
  }
30
30
  exports.selectColumn = selectColumn;
31
+ /** Provides default styling for a GridColumn containing the CollapseToggle component. */
32
+ function collapseColumn(columnDef) {
33
+ // Defining `w: 38px` based on the designs
34
+ return { ...columnDef, clientSideSort: false, align: "center", w: "38px" };
35
+ }
36
+ exports.collapseColumn = collapseColumn;
@@ -1,3 +1,4 @@
1
+ import { Properties } from "../../Css";
1
2
  import { GridStyle } from ".";
2
3
  /** Our original table look & feel/style. */
3
4
  export declare const defaultStyle: GridStyle;
@@ -7,3 +8,5 @@ export declare const condensedStyle: GridStyle;
7
8
  export declare const cardStyle: GridStyle;
8
9
  export declare const beamFixedStyle: GridStyle;
9
10
  export declare const beamFlexibleStyle: GridStyle;
11
+ export declare const beamGroupRowStyle: Properties;
12
+ export declare const beamTotalsRowStyle: Properties;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.beamFlexibleStyle = exports.beamFixedStyle = exports.cardStyle = exports.condensedStyle = exports.defaultStyle = void 0;
3
+ exports.beamTotalsRowStyle = exports.beamGroupRowStyle = exports.beamFlexibleStyle = exports.beamFixedStyle = exports.cardStyle = exports.condensedStyle = exports.defaultStyle = void 0;
4
4
  const Css_1 = require("../../Css");
5
5
  /** Our original table look & feel/style. */
6
6
  exports.defaultStyle = {
@@ -41,11 +41,18 @@ exports.cardStyle = {
41
41
  };
42
42
  // Once completely rolled out across all tables in Blueprint, this will change to be the `defaultStyle`.
43
43
  exports.beamFixedStyle = {
44
- rootCss: Css_1.Css.gray700.$,
45
- // Doing a mix of `min` and `max` height of 40 as each cell is currently defining `h100`.
46
- headerCellCss: Css_1.Css.xsEm.bgGray200.aic.nowrap.px2.mhPx(40).maxhPx(40).$,
47
- // TODO: `cellCss` has incomplete styling at the moment. Will be done as part of SC-8145
48
- cellCss: Css_1.Css.xs.bgWhite.aic.nowrap.px2.hPx(40).boxShadow(`inset 0 -1px 0 ${Css_1.Palette.Gray100}`).$,
44
+ headerCellCss: Css_1.Css.gray700.xsEm.bgGray200.aic.nowrap.pxPx(12).hPx(40).$,
45
+ cellCss: Css_1.Css.gray900.xs.bgWhite.aic.nowrap.pxPx(12).hPx(36).boxShadow(`inset 0 -1px 0 ${Css_1.Palette.Gray100}`).$,
46
+ emptyCell: "-",
47
+ presentationSettings: { borderless: true, typeScale: "xs", wrap: false },
48
+ rowHoverColor: Css_1.Palette.Gray200,
49
+ };
50
+ exports.beamFlexibleStyle = {
51
+ ...exports.beamFixedStyle,
52
+ cellCss: Css_1.Css.xs.bgWhite.aic.p2.boxShadow(`inset 0 -1px 0 ${Css_1.Palette.Gray100}`).$,
53
+ presentationSettings: { borderless: false, typeScale: "xs", wrap: true },
49
54
  };
50
- // TODO: `cellCss` has incomplete styling at the moment. Will be done as part of SC-8145
51
- exports.beamFlexibleStyle = { ...exports.beamFixedStyle, cellCss: Css_1.Css.p2.$ };
55
+ exports.beamGroupRowStyle = Css_1.Css.smEm
56
+ .mhPx(56)
57
+ .gray700.bgGray100.boxShadow(`inset 0 -1px 0 ${Css_1.Palette.Gray200}`).$;
58
+ exports.beamTotalsRowStyle = Css_1.Css.gray700.smEm.hPx(40).mb1.bgWhite.boxShadow("none").$;
@@ -56,7 +56,7 @@ function TextFieldBase(props) {
56
56
  ...(!contrast ? Css_1.Css.bgWhite.$ : Css_1.Css.bgGray700.addIn("&::selection", Css_1.Css.bgGray800.$).$),
57
57
  },
58
58
  hover: Css_1.Css.bgGray100.if(contrast).bgGray600.bGray600.$,
59
- focus: borderless ? Css_1.Css.bshFocus.$ : Css_1.Css.bLightBlue700.if(contrast).bLightBlue500.$,
59
+ focus: borderless ? Css_1.Css.bshFocus.z1.$ : Css_1.Css.bLightBlue700.if(contrast).bLightBlue500.$,
60
60
  disabled: visuallyDisabled
61
61
  ? Css_1.Css.cursorNotAllowed.gray400.bgGray100.if(contrast).gray500.bgGray700.$
62
62
  : Css_1.Css.cursorNotAllowed.$,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.104.0",
3
+ "version": "2.105.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",