@homebound/beam 2.190.0 → 2.191.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.
@@ -101,7 +101,7 @@ export interface GridTableProps<R extends Kinded, S, X> {
101
101
  activeRowId?: string;
102
102
  /**
103
103
  * Defines which cell in the table should be provided with an "active" styling.
104
- * Expected format is `${row.kind}_${row.id}_${column.name}`.
104
+ * Expected format is `${row.kind}_${row.id}_${column.id}`.
105
105
  */
106
106
  activeCellId?: string;
107
107
  }
@@ -252,6 +252,8 @@ function renderDiv(style, id, columns, headerRows, totalsRows, visibleDataRows,
252
252
  ? Css_1.Css.addIn(`& > div:nth-of-type(n+${headerRows.length + totalsRows.length + 2}) > *`, style.betweenRowsCss).$
253
253
  : {}),
254
254
  ...(style.firstNonHeaderRowCss ? Css_1.Css.addIn(`& > div:nth-of-type(2) > *`, style.firstNonHeaderRowCss).$ : {}),
255
+ ...(style.lastRowCss && Css_1.Css.addIn("& > div:last-of-type", style.lastRowCss).$),
256
+ ...(style.firstRowCss && Css_1.Css.addIn("& > div:first-of-type", style.firstRowCss).$),
255
257
  ...style.rootCss,
256
258
  ...(style.minWidthPx ? Css_1.Css.mwPx(style.minWidthPx).$ : {}),
257
259
  ...xss,
@@ -260,10 +262,12 @@ function renderDiv(style, id, columns, headerRows, totalsRows, visibleDataRows,
260
262
  /** Renders as a table, primarily/solely for good print support. */
261
263
  function renderTable(style, id, columns, headerRows, totalsRows, visibleDataRows, firstRowMessage, _stickyHeader, xss, _virtuosoRef) {
262
264
  return ((0, jsx_runtime_1.jsxs)("table", Object.assign({ css: {
263
- ...Css_1.Css.w100.add("borderCollapse", "collapse").$,
264
- ...Css_1.Css.addIn("& > tbody > tr ", style.betweenRowsCss || {})
265
+ ...Css_1.Css.w100.add("borderCollapse", "separate").add("borderSpacing", "0").$,
266
+ ...Css_1.Css.addIn("& > tbody > tr > * ", style.betweenRowsCss || {})
265
267
  // removes border between header and second row
266
- .addIn("& > tbody > tr:first-of-type", style.firstNonHeaderRowCss || {}).$,
268
+ .addIn("& > tbody > tr:first-of-type > *", style.firstNonHeaderRowCss || {}).$,
269
+ ...Css_1.Css.addIn("& > tbody > tr:last-of-type", style.lastRowCss).$,
270
+ ...Css_1.Css.addIn("& > tbody > tr:first-of-type", style.firstRowCss).$,
267
271
  ...style.rootCss,
268
272
  ...(style.minWidthPx ? Css_1.Css.mwPx(style.minWidthPx).$ : {}),
269
273
  ...xss,
@@ -356,9 +360,10 @@ const VirtualRoot = (0, memoize_one_1.default)((gs, _columns, id, xss) => {
356
360
  ...Css_1.Css.addIn("& > div + div > div > *", gs.betweenRowsCss || {}).$,
357
361
  // Table list styles only
358
362
  ...(isHeader
359
- ? {}
363
+ ? Css_1.Css.addIn("& > div:first-of-type > *", gs.firstRowCss).$
360
364
  : {
361
365
  ...Css_1.Css.addIn("& > div:first-of-type > *", gs.firstNonHeaderRowCss).$,
366
+ ...Css_1.Css.addIn("& > div:last-of-type > *", gs.lastRowCss).$,
362
367
  }),
363
368
  ...gs.rootCss,
364
369
  ...(gs.minWidthPx ? Css_1.Css.mwPx(gs.minWidthPx).$ : {}),
@@ -0,0 +1,12 @@
1
+ import { ReactNode } from "react";
2
+ import { Margin, Only, Xss } from "../../Css";
3
+ declare type TableActionsXss = Xss<Margin>;
4
+ interface TableActionsProps<X> {
5
+ xss?: X;
6
+ children: ReactNode;
7
+ onlyLeft?: boolean;
8
+ onlyRight?: boolean;
9
+ }
10
+ /** Provides default spacing for Actions sitting above a table (Filters, Search, etc...) */
11
+ export declare function TableActions<X extends Only<TableActionsXss, X>>(props: TableActionsProps<X>): import("@emotion/react/jsx-runtime").JSX.Element;
12
+ export {};
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TableActions = void 0;
4
+ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
5
+ const Css_1 = require("../../Css");
6
+ /** Provides default spacing for Actions sitting above a table (Filters, Search, etc...) */
7
+ function TableActions(props) {
8
+ const { xss, children, onlyLeft, onlyRight } = props;
9
+ const alignmentStyles = onlyLeft ? Css_1.Css.jcfs.$ : onlyRight ? Css_1.Css.jcfe.$ : Css_1.Css.jcsb.$;
10
+ return (0, jsx_runtime_1.jsx)("div", Object.assign({ css: { ...Css_1.Css.df.aic.pb2.gap1.$, ...xss, ...alignmentStyles } }, { children: children }), void 0);
11
+ }
12
+ exports.TableActions = TableActions;
@@ -9,6 +9,10 @@ export interface GridStyle {
9
9
  rootCss?: Properties;
10
10
  /** Applied with the owl operator between rows for rendering border lines. */
11
11
  betweenRowsCss?: Properties;
12
+ /** Applied on the last row of the table. */
13
+ lastRowCss?: Properties;
14
+ /** Applied on the first row of the table (could be the Header or Totals row). */
15
+ firstRowCss?: Properties;
12
16
  /** Applied to the first non-header row, i.e. if you want to cancel out `betweenRowsCss`. */
13
17
  firstNonHeaderRowCss?: Properties;
14
18
  /** Applied to all cell divs (via a selector off the base div). */
@@ -55,6 +59,8 @@ export interface GridStyleDef {
55
59
  rowHeight?: "fixed" | "flexible";
56
60
  /** Enables cells Highlight and hover */
57
61
  cellHighlight?: boolean;
62
+ allWhite?: boolean;
63
+ bordered?: boolean;
58
64
  }
59
65
  export declare const getTableStyles: (props?: GridStyleDef) => GridStyle;
60
66
  /** Defines row-specific styling for each given row `kind` in `R` */
@@ -7,7 +7,7 @@ const utils_1 = require("../../utils");
7
7
  function memoizedTableStyles() {
8
8
  const cache = {};
9
9
  return (props = {}) => {
10
- const { inlineEditing = false, grouped = false, rowHeight = "flexible", cellHighlight = false } = props;
10
+ const { inlineEditing = false, grouped = false, rowHeight = "flexible", cellHighlight = false, allWhite = false, bordered = false, } = props;
11
11
  const key = (0, utils_1.safeKeys)(props)
12
12
  .sort()
13
13
  .map((k) => `${k}_${props[k]}`)
@@ -15,8 +15,11 @@ function memoizedTableStyles() {
15
15
  if (!cache[key]) {
16
16
  const groupedLevels = {
17
17
  0: {
18
- cellCss: Css_1.Css.xsMd.mhPx(56).gray700.bgGray100.boxShadow(`inset 0 -1px 0 ${Css_1.Palette.Gray200}`).$,
19
- firstContentColumn: Css_1.Css.smMd.$,
18
+ cellCss: {
19
+ ...Css_1.Css.xsMd.mhPx(56).gray700.bgGray100.boxShadow(`inset 0 -1px 0 ${Css_1.Palette.Gray200}`).$,
20
+ ...(allWhite && Css_1.Css.bgWhite.$),
21
+ },
22
+ firstContentColumn: { ...Css_1.Css.smMd.$, ...(allWhite && Css_1.Css.smBd.gray900.$) },
20
23
  },
21
24
  2: { firstContentColumn: Css_1.Css.tiny.pl3.$ },
22
25
  };
@@ -24,13 +27,27 @@ function memoizedTableStyles() {
24
27
  cache[key] = {
25
28
  emptyCell: "-",
26
29
  firstRowMessageCss: Css_1.Css.tc.py3.$,
27
- headerCellCss: Css_1.Css.gray700.xsMd.bgGray200.aic.nowrap.pxPx(12).hPx(40).$,
28
- totalsCellCss: Css_1.Css.bgWhite.gray700.smMd.hPx(52).pt0.pbPx(12).boxShadow("none").$,
30
+ headerCellCss: {
31
+ ...Css_1.Css.gray700.xsMd.bgGray200.aic.nowrap.pxPx(12).hPx(40).$,
32
+ ...(allWhite && Css_1.Css.bgWhite.$),
33
+ ...(bordered && Css_1.Css.bt.bGray200.$),
34
+ },
35
+ totalsCellCss: Css_1.Css.bgWhite.gray700.smMd.hPx(52).pt0.boxShadow("none").$,
29
36
  cellCss: {
30
37
  ...Css_1.Css.gray900.xs.bgWhite.aic.pxPx(12).boxShadow(`inset 0 -1px 0 ${Css_1.Palette.Gray200}`).$,
31
38
  ...(rowHeight === "flexible" ? Css_1.Css.pyPx(12).$ : Css_1.Css.nowrap.hPx(inlineEditing ? 48 : 36).$),
32
39
  ...(cellHighlight ? { "&:hover": Css_1.Css.bgGray100.$ } : {}),
40
+ ...(bordered && { "&:first-of-type": Css_1.Css.bl.bGray200.$, "&:last-of-type": Css_1.Css.br.bGray200.$ }),
41
+ },
42
+ firstRowCss: {
43
+ // Only apply border-radius to the corners of the table when `allWhite` is true for now.
44
+ ...(allWhite &&
45
+ Css_1.Css.addIn("& > *:first-of-type", Css_1.Css.borderRadius("8px 0 0 0 ").$).addIn("& > *:last-of-type", Css_1.Css.borderRadius("0 8px 0 0").$).$),
46
+ ...(bordered && Css_1.Css.addIn("& > *", Css_1.Css.bt.bGray200.$).$),
33
47
  },
48
+ ...(allWhite && {
49
+ lastRowCss: Css_1.Css.addIn("& > *:first-of-type", Css_1.Css.borderRadius("0 0 0 8px").$).addIn("& > *:last-of-type", Css_1.Css.borderRadius("0 0 8px 0").$).$,
50
+ }),
34
51
  presentationSettings: { borderless: true, typeScale: "xs", wrap: rowHeight === "flexible" },
35
52
  levels: grouped ? groupedLevels : defaultLevels,
36
53
  };
@@ -58,7 +75,7 @@ exports.condensedStyle = {
58
75
  ...exports.defaultStyle,
59
76
  headerCellCss: Css_1.Css.bgGray100.tinySb.$,
60
77
  cellCss: Css_1.Css.aic.sm.py1.px2.$,
61
- rootCss: Css_1.Css.dg.gray700.xs.$,
78
+ rootCss: Css_1.Css.gray700.xs.$,
62
79
  firstRowMessageCss: Css_1.Css.tc.py2.$,
63
80
  };
64
81
  /** Renders each row as a card. */
@@ -90,7 +107,14 @@ function tableRowStyles(as, column) {
90
107
  }
91
108
  exports.tableRowStyles = tableRowStyles;
92
109
  function resolveStyles(style) {
93
- const defKeys = ["inlineEditing", "grouped", "rowHeight", "cellHighlight"];
110
+ const defKeys = [
111
+ "inlineEditing",
112
+ "grouped",
113
+ "rowHeight",
114
+ "cellHighlight",
115
+ "allWhite",
116
+ "bordered",
117
+ ];
94
118
  const keys = (0, utils_1.safeKeys)(style);
95
119
  if (keys.length === 0 || keys.some((k) => defKeys.includes(k))) {
96
120
  return (0, exports.getTableStyles)(style);
@@ -21,17 +21,17 @@ function EditColumnsButton(props) {
21
21
  // Only include options that can be hidden and have the `name` property defined.
22
22
  if (!column.canHide)
23
23
  return acc;
24
- if (!column.name || column.name.length === 0) {
24
+ if (!column.id || column.id.length === 0) {
25
25
  console.warn("Column is missing 'name' property required by the Edit Columns button", column);
26
26
  return acc;
27
27
  }
28
28
  // Add current column as an option
29
- return { ...acc, options: acc.options.concat({ label: column.name, value: column.name }) };
29
+ return { ...acc, options: acc.options.concat({ label: column.id, value: column.id }) };
30
30
  }, { options: [] });
31
31
  }, [allColumns]);
32
- const selectedValues = selectedColumns.map((column) => column.name);
32
+ const selectedValues = selectedColumns.map((column) => column.id);
33
33
  const setSelectedValues = (0, react_1.useCallback)((values) => {
34
- setSelectedColumns(allColumns.filter((column) => (column.canHide ? values.includes(column.name) : true)));
34
+ setSelectedColumns(allColumns.filter((column) => (column.canHide ? values.includes(column.id) : true)));
35
35
  }, [allColumns, setSelectedColumns]);
36
36
  return ((0, jsx_runtime_1.jsx)(OverlayTrigger_1.OverlayTrigger, Object.assign({}, props, { menuTriggerProps: menuTriggerProps, state: state, buttonRef: buttonRef }, tid, { children: (0, jsx_runtime_1.jsxs)("div", Object.assign({ css: {
37
37
  ...Css_1.Css.bgWhite.py5.px3.maxwPx(380).bshBasic.$,
@@ -100,8 +100,8 @@ function RowImpl(props) {
100
100
  : {}),
101
101
  }
102
102
  : {};
103
- const cellId = `${row.kind}_${row.id}_${column.name}`;
104
- const applyCellHighlight = cellHighlight && !!column.name && !isHeader && !isTotals;
103
+ const cellId = `${row.kind}_${row.id}_${column.id}`;
104
+ const applyCellHighlight = cellHighlight && !!column.id && !isHeader && !isTotals;
105
105
  const isCellActive = rowState.activeCellId === cellId;
106
106
  // Note that it seems expensive to calc a per-cell class name/CSS-in-JS output,
107
107
  // vs. setting global/table-wide CSS like `style.cellCss` on the root grid div with
@@ -6,27 +6,27 @@ const react_1 = require("react");
6
6
  const useSessionStorage_1 = require("../../../hooks/useSessionStorage");
7
7
  function useColumns(tableColumns, maybeStorageKey) {
8
8
  const { selectedColumns, hideColumns } = tableColumns.reduce((acc, column) => {
9
- // Only include options that can be hidden and have the `name` property defined.
10
- if (!column.name || column.name.length === 0) {
11
- console.warn("Column is missing 'name' property required by the Edit Columns button", column);
9
+ // Only include options that can be hidden and have the `id` property defined.
10
+ if (!column.id || column.id.length === 0) {
11
+ console.warn("Column is missing 'id' property required by the Edit Columns button", column);
12
12
  return acc;
13
13
  }
14
14
  // Add hide-able columns
15
15
  if (column.canHide) {
16
- acc.hideColumns.push(column.name);
16
+ acc.hideColumns.push(column.id);
17
17
  }
18
18
  // Add selected columns
19
19
  if (!column.canHide || (column.canHide && column.initVisible)) {
20
- acc.selectedColumns.push(column.name);
20
+ acc.selectedColumns.push(column.id);
21
21
  }
22
22
  return { ...acc };
23
23
  }, { selectedColumns: [], hideColumns: [] });
24
24
  const storageKey = maybeStorageKey !== null && maybeStorageKey !== void 0 ? maybeStorageKey : (0, change_case_1.camelCase)(hideColumns.map((c) => c).join(""));
25
25
  const [storageNames, setStorageNames] = (0, useSessionStorage_1.useSessionStorage)(storageKey, selectedColumns);
26
- const storageColumns = storageNames && storageNames.map((sc) => tableColumns.find((column) => column.name === sc));
26
+ const storageColumns = storageNames && storageNames.map((sc) => tableColumns.find((column) => column.id === sc));
27
27
  const [columns, setColumns] = (0, react_1.useState)(storageColumns);
28
28
  (0, react_1.useEffect)(() => {
29
- setStorageNames(columns.map((column) => column.name));
29
+ setStorageNames(columns.map((column) => column.id));
30
30
  }, [columns]);
31
31
  return [columns, setColumns];
32
32
  }
@@ -64,8 +64,8 @@ export declare type GridColumn<R extends Kinded, S = {}> = {
64
64
  wrapAction?: false;
65
65
  /** Used as a signal to defer adding the 'indent' styling */
66
66
  isAction?: true;
67
- /** Column name that will be used to generate an unique identifier for every row cell */
68
- name?: string;
67
+ /** Column id that will be used to generate an unique identifier for every row cell */
68
+ id?: string;
69
69
  /** Flag that will allow to know which columns are hide-able */
70
70
  canHide?: boolean;
71
71
  /** Flag that will allow to know which hide-able columns are visible on initial load */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.190.0",
3
+ "version": "2.191.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",