@homebound/beam 2.124.3 → 2.126.1
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/components/Table/GridTable.d.ts +3 -2
- package/dist/components/Table/GridTable.js +13 -2
- package/dist/components/Table/GridTableApi.d.ts +3 -0
- package/dist/components/Table/GridTableApi.js +3 -0
- package/dist/components/Table/index.d.ts +1 -1
- package/dist/components/Table/index.js +2 -7
- package/dist/components/Table/styles.d.ts +7 -9
- package/dist/components/Table/styles.js +32 -38
- package/dist/inputs/TextFieldBase.js +5 -1
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@ import { MutableRefObject, ReactElement, ReactNode } from "react";
|
|
|
2
2
|
import { PresentationContextProps, PresentationFieldProps } from "../PresentationContext";
|
|
3
3
|
import { GridRowLookup } from "./GridRowLookup";
|
|
4
4
|
import { GridTableApi } from "./GridTableApi";
|
|
5
|
+
import { GridStyleDef } from "./styles";
|
|
5
6
|
import { Margin, Only, Palette, Properties, Typography, Xss } from "../../Css";
|
|
6
7
|
export declare type Kinded = {
|
|
7
8
|
kind: string;
|
|
@@ -92,7 +93,7 @@ export interface NestedCardStyle {
|
|
|
92
93
|
pxPx: number;
|
|
93
94
|
}
|
|
94
95
|
export interface GridTableDefaults {
|
|
95
|
-
style: GridStyle;
|
|
96
|
+
style: GridStyle | GridStyleDef;
|
|
96
97
|
stickyHeader: boolean;
|
|
97
98
|
}
|
|
98
99
|
/** Configures the default/app-wide GridStyle. */
|
|
@@ -166,7 +167,7 @@ export interface GridTableProps<R extends Kinded, S, X> {
|
|
|
166
167
|
/** Sets the rows to be wrapped by mobx observers. */
|
|
167
168
|
observeRows?: boolean;
|
|
168
169
|
/** A combination of CSS settings to set the static look & feel (vs. rowStyles which is per-row styling). */
|
|
169
|
-
style?: GridStyle;
|
|
170
|
+
style?: GridStyle | GridStyleDef;
|
|
170
171
|
/**
|
|
171
172
|
* If provided, collapsed rows on the table persists when the page is reloaded.
|
|
172
173
|
*
|
|
@@ -39,10 +39,12 @@ const nestedCards_1 = require("./nestedCards");
|
|
|
39
39
|
const RowState_1 = require("./RowState");
|
|
40
40
|
const SortHeader_1 = require("./SortHeader");
|
|
41
41
|
const sortRows_1 = require("./sortRows");
|
|
42
|
+
const styles_1 = require("./styles");
|
|
42
43
|
const useSortState_1 = require("./useSortState");
|
|
43
44
|
const Css_1 = require("../../Css");
|
|
44
45
|
const hooks_1 = require("../../hooks");
|
|
45
46
|
const useRenderCount_1 = require("../../hooks/useRenderCount");
|
|
47
|
+
const utils_1 = require("../../utils");
|
|
46
48
|
const shallowEqual_1 = require("../../utils/shallowEqual");
|
|
47
49
|
const _1 = require(".");
|
|
48
50
|
exports.ASC = "ASC";
|
|
@@ -86,7 +88,7 @@ exports.setGridTableDefaults = setGridTableDefaults;
|
|
|
86
88
|
*/
|
|
87
89
|
function GridTable(props) {
|
|
88
90
|
var _a, _b, _c, _d;
|
|
89
|
-
const { id = "gridTable", as = "div", columns, rows, style = defaults.style, rowStyles, stickyHeader = defaults.stickyHeader, stickyOffset = "0", xss, filter, filterMaxRows, fallbackMessage = "No rows found.", infoMessage, setRowCount, observeRows, persistCollapse, resizeTarget, activeRowId, } = props;
|
|
91
|
+
const { id = "gridTable", as = "div", columns, rows, style: maybeStyle = defaults.style, rowStyles, stickyHeader = defaults.stickyHeader, stickyOffset = "0", xss, filter, filterMaxRows, fallbackMessage = "No rows found.", infoMessage, setRowCount, observeRows, persistCollapse, resizeTarget, activeRowId, } = props;
|
|
90
92
|
// We only use this in as=virtual mode, but keep this here for rowLookup to use
|
|
91
93
|
const virtuosoRef = (0, react_1.useRef)(null);
|
|
92
94
|
const tableRef = (0, react_1.useRef)(null);
|
|
@@ -97,6 +99,7 @@ function GridTable(props) {
|
|
|
97
99
|
api.setActiveRowId(activeRowId);
|
|
98
100
|
return api;
|
|
99
101
|
}, [props.api]);
|
|
102
|
+
const style = resolveStyles(maybeStyle);
|
|
100
103
|
const { rowState } = api;
|
|
101
104
|
rowState.rows = rows;
|
|
102
105
|
(0, react_1.useEffect)(() => {
|
|
@@ -498,7 +501,7 @@ function GridRow(props) {
|
|
|
498
501
|
const rowNode = ((0, jsx_runtime_1.jsx)(Row, Object.assign({ css: rowCss }, others, { "data-gridrow": true }, getCount(row.id), { children: columns.map((column, columnIndex) => {
|
|
499
502
|
var _a, _b, _c, _d, _e, _f;
|
|
500
503
|
const { wrapAction = true, isAction = false } = column;
|
|
501
|
-
const applyFirstContentColumnStyles = !isAction && !firstContentColumnStylesApplied;
|
|
504
|
+
const applyFirstContentColumnStyles = !isHeader && !isAction && !firstContentColumnStylesApplied;
|
|
502
505
|
firstContentColumnStylesApplied || (firstContentColumnStylesApplied = applyFirstContentColumnStyles);
|
|
503
506
|
if (column.mw) {
|
|
504
507
|
// Validate the column's minWidth definition if set.
|
|
@@ -766,3 +769,11 @@ function tableRowStyles(as, column) {
|
|
|
766
769
|
}
|
|
767
770
|
: {};
|
|
768
771
|
}
|
|
772
|
+
function resolveStyles(style) {
|
|
773
|
+
const defKeys = ["inlineEditing", "grouped", "totals", "rowHeight"];
|
|
774
|
+
const keys = (0, utils_1.safeKeys)(style);
|
|
775
|
+
if (keys.length === 0 || keys.some((k) => defKeys.includes(k))) {
|
|
776
|
+
return (0, styles_1.getTableStyles)(style);
|
|
777
|
+
}
|
|
778
|
+
return style;
|
|
779
|
+
}
|
|
@@ -28,6 +28,8 @@ export declare type GridTableApi<R extends Kinded> = {
|
|
|
28
28
|
/** Returns the currently-selected rows. */
|
|
29
29
|
getSelectedRows(): GridDataRow<R>[];
|
|
30
30
|
getSelectedRows<K extends R["kind"]>(kind: K): GridDataRow<DiscriminateUnion<R, "kind", K>>[];
|
|
31
|
+
/** Deselects all rows */
|
|
32
|
+
clearSelections(): void;
|
|
31
33
|
/** Sets the internal state of 'activeRowId' */
|
|
32
34
|
setActiveRowId: (id: string | undefined) => void;
|
|
33
35
|
};
|
|
@@ -39,5 +41,6 @@ export declare class GridTableApiImpl<R extends Kinded> implements GridTableApi<
|
|
|
39
41
|
scrollToIndex(index: number): void;
|
|
40
42
|
getSelectedRowIds(kind?: string): string[];
|
|
41
43
|
getSelectedRows(kind?: string): any;
|
|
44
|
+
clearSelections(id?: string): void;
|
|
42
45
|
setActiveRowId(id: string | undefined): void;
|
|
43
46
|
}
|
|
@@ -11,4 +11,4 @@ export * from "./SelectToggle";
|
|
|
11
11
|
export { simpleDataRows, simpleHeader } from "./simpleHelpers";
|
|
12
12
|
export type { SimpleHeaderAndData } from "./simpleHelpers";
|
|
13
13
|
export { SortHeader } from "./SortHeader";
|
|
14
|
-
export {
|
|
14
|
+
export { cardStyle, condensedStyle, defaultStyle, getTableStyles } from "./styles";
|
|
@@ -10,7 +10,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.
|
|
13
|
+
exports.getTableStyles = exports.defaultStyle = exports.condensedStyle = exports.cardStyle = exports.SortHeader = exports.simpleHeader = exports.simpleDataRows = exports.RowStateContext = exports.RowState = exports.useGridTableApi = exports.setGridTableDefaults = exports.setDefaultStyle = exports.GridTable = exports.DESC = exports.ASC = exports.GridSortContext = void 0;
|
|
14
14
|
__exportStar(require("./CollapseToggle"), exports);
|
|
15
15
|
__exportStar(require("./columns"), exports);
|
|
16
16
|
var GridSortContext_1 = require("./GridSortContext");
|
|
@@ -33,12 +33,7 @@ Object.defineProperty(exports, "simpleHeader", { enumerable: true, get: function
|
|
|
33
33
|
var SortHeader_1 = require("./SortHeader");
|
|
34
34
|
Object.defineProperty(exports, "SortHeader", { enumerable: true, get: function () { return SortHeader_1.SortHeader; } });
|
|
35
35
|
var styles_1 = require("./styles");
|
|
36
|
-
Object.defineProperty(exports, "beamFixedStyle", { enumerable: true, get: function () { return styles_1.beamFixedStyle; } });
|
|
37
|
-
Object.defineProperty(exports, "beamFlexibleStyle", { enumerable: true, get: function () { return styles_1.beamFlexibleStyle; } });
|
|
38
|
-
Object.defineProperty(exports, "beamNestedFixedStyle", { enumerable: true, get: function () { return styles_1.beamNestedFixedStyle; } });
|
|
39
|
-
Object.defineProperty(exports, "beamNestedFlexibleStyle", { enumerable: true, get: function () { return styles_1.beamNestedFlexibleStyle; } });
|
|
40
|
-
Object.defineProperty(exports, "beamTotalsFixedStyle", { enumerable: true, get: function () { return styles_1.beamTotalsFixedStyle; } });
|
|
41
|
-
Object.defineProperty(exports, "beamTotalsFlexibleStyle", { enumerable: true, get: function () { return styles_1.beamTotalsFlexibleStyle; } });
|
|
42
36
|
Object.defineProperty(exports, "cardStyle", { enumerable: true, get: function () { return styles_1.cardStyle; } });
|
|
43
37
|
Object.defineProperty(exports, "condensedStyle", { enumerable: true, get: function () { return styles_1.condensedStyle; } });
|
|
44
38
|
Object.defineProperty(exports, "defaultStyle", { enumerable: true, get: function () { return styles_1.defaultStyle; } });
|
|
39
|
+
Object.defineProperty(exports, "getTableStyles", { enumerable: true, get: function () { return styles_1.getTableStyles; } });
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Properties } from "../../Css";
|
|
2
1
|
import { GridStyle } from ".";
|
|
3
2
|
/** Our original table look & feel/style. */
|
|
4
3
|
export declare const defaultStyle: GridStyle;
|
|
@@ -6,11 +5,10 @@ export declare const defaultStyle: GridStyle;
|
|
|
6
5
|
export declare const condensedStyle: GridStyle;
|
|
7
6
|
/** Renders each row as a card. */
|
|
8
7
|
export declare const cardStyle: GridStyle;
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export declare const
|
|
16
|
-
export declare const beamTotalsFlexibleStyle: GridStyle;
|
|
8
|
+
export interface GridStyleDef {
|
|
9
|
+
inlineEditing?: boolean;
|
|
10
|
+
grouped?: boolean;
|
|
11
|
+
rowHeight?: "fixed" | "flexible";
|
|
12
|
+
totals?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare const getTableStyles: (props?: GridStyleDef | undefined) => GridStyle;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getTableStyles = 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 = {
|
|
@@ -39,40 +39,34 @@ exports.cardStyle = {
|
|
|
39
39
|
}).p1.m0.xsEm.gray700.$,
|
|
40
40
|
},
|
|
41
41
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
levels: { 0: { cellCss: exports.beamGroupRowStyle }, 2: { firstContentColumn: Css_1.Css.tiny.pl3.$ } },
|
|
74
|
-
};
|
|
75
|
-
exports.beamTotalsFlexibleStyle = {
|
|
76
|
-
...exports.beamFlexibleStyle,
|
|
77
|
-
cellCss: { ...exports.beamFlexibleStyle.cellCss, ...exports.beamTotalsRowStyle },
|
|
78
|
-
};
|
|
42
|
+
function memoizedTableStyles() {
|
|
43
|
+
const cache = {};
|
|
44
|
+
return (props) => {
|
|
45
|
+
const { inlineEditing = false, grouped = false, rowHeight = "flexible", totals = false } = props || {};
|
|
46
|
+
const key = `${inlineEditing}|${grouped}|${rowHeight}|${totals}`;
|
|
47
|
+
if (!cache[key]) {
|
|
48
|
+
const groupedLevels = {
|
|
49
|
+
0: {
|
|
50
|
+
cellCss: Css_1.Css.xsEm.mhPx(56).gray700.bgGray100.boxShadow(`inset 0 -1px 0 ${Css_1.Palette.Gray200}`).$,
|
|
51
|
+
firstContentColumn: Css_1.Css.smEm.$,
|
|
52
|
+
},
|
|
53
|
+
2: { firstContentColumn: Css_1.Css.tiny.pl3.$ },
|
|
54
|
+
};
|
|
55
|
+
const defaultLevels = { 1: { firstContentColumn: Css_1.Css.tiny.pl3.$ } };
|
|
56
|
+
cache[key] = {
|
|
57
|
+
emptyCell: "-",
|
|
58
|
+
firstRowMessageCss: Css_1.Css.tc.py3.$,
|
|
59
|
+
headerCellCss: Css_1.Css.gray700.xsEm.bgGray200.aic.nowrap.pxPx(12).hPx(40).$,
|
|
60
|
+
cellCss: {
|
|
61
|
+
...Css_1.Css.gray900.xs.bgWhite.aic.pxPx(12).boxShadow(`inset 0 -1px 0 ${Css_1.Palette.Gray200}`).$,
|
|
62
|
+
...(rowHeight === "flexible" ? Css_1.Css.py2.$ : Css_1.Css.nowrap.hPx(inlineEditing ? 48 : 36).$),
|
|
63
|
+
...(totals ? Css_1.Css.gray700.smEm.hPx(40).mb1.bgWhite.boxShadow("none").$ : {}),
|
|
64
|
+
},
|
|
65
|
+
presentationSettings: { borderless: true, typeScale: "xs", wrap: rowHeight === "flexible" },
|
|
66
|
+
levels: totals ? {} : grouped ? groupedLevels : defaultLevels,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return cache[key];
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
exports.getTableStyles = memoizedTableStyles();
|
|
@@ -44,7 +44,11 @@ function TextFieldBase(props) {
|
|
|
44
44
|
// When borderless then perceived vertical alignments are misaligned. As there is no longer a border, then the field looks oddly indented.
|
|
45
45
|
// This typically happens in tables when a column has a mix of static text (i.e. "roll up" rows and table headers) and input fields.
|
|
46
46
|
// To remedy this perceived misalignment then we increase the width by the horizontal padding applied (16px), and set a negative margin left margin to re-center the field.
|
|
47
|
-
|
|
47
|
+
// Note: Do not modify width and position of 'compound' fields.
|
|
48
|
+
...(borderless && !compound
|
|
49
|
+
? Css_1.Css.bTransparent.w("calc(100% + 16px)").ml(-1).$
|
|
50
|
+
: Css_1.Css.bGray300.if(contrast).bGray700.$),
|
|
51
|
+
// Do not add borders to compound fields. A compound field is responsible for drawing its own borders
|
|
48
52
|
...(!compound ? Css_1.Css.ba.$ : {}),
|
|
49
53
|
},
|
|
50
54
|
inputWrapperReadOnly: {
|