@homebound/beam 2.330.0 → 2.331.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.
|
@@ -49,6 +49,8 @@ export interface GridStyle {
|
|
|
49
49
|
minWidthPx?: number;
|
|
50
50
|
/** Css to apply at each level of a parent/child nested table. */
|
|
51
51
|
levels?: Record<number, {
|
|
52
|
+
/** Number of pixels to indent the row. This value will be subtracted from the "first content column" width. First content column is the first column that is not an 'action' column (i.e. non-checkbox or non-collapse button column) */
|
|
53
|
+
rowIndent?: number;
|
|
52
54
|
cellCss?: Properties;
|
|
53
55
|
firstContentColumn?: Properties;
|
|
54
56
|
}>;
|
|
@@ -102,6 +102,10 @@ exports.cardStyle = {
|
|
|
102
102
|
},
|
|
103
103
|
rowHoverColor: "none",
|
|
104
104
|
nonHeaderRowHoverCss: Css_1.Css.bshHover.bGray700.$,
|
|
105
|
+
levels: {
|
|
106
|
+
1: { rowIndent: 24 },
|
|
107
|
+
2: { rowIndent: 48 },
|
|
108
|
+
},
|
|
105
109
|
};
|
|
106
110
|
function resolveStyles(style) {
|
|
107
111
|
const defKeysRecord = {
|
|
@@ -13,7 +13,7 @@ const Css_1 = require("../../../Css");
|
|
|
13
13
|
const utils_2 = require("../../../utils");
|
|
14
14
|
// We extract Row to its own mini-component primarily so we can React.memo'ize it.
|
|
15
15
|
function RowImpl(props) {
|
|
16
|
-
var _a, _b;
|
|
16
|
+
var _a, _b, _c;
|
|
17
17
|
const { as, rs, style, rowStyles, columnSizes, getCount, cellHighlight, omitRowHover, hasExpandableHeader, ...others } = props;
|
|
18
18
|
const { tableState } = (0, react_1.useContext)(TableState_1.TableStateContext);
|
|
19
19
|
// We're wrapped in observer, so can access these without useComputeds
|
|
@@ -30,18 +30,20 @@ function RowImpl(props) {
|
|
|
30
30
|
const revealOnRowHoverClass = "revealOnRowHover";
|
|
31
31
|
const showRowHoverColor = !utils_1.reservedRowKinds.includes(row.kind) && !omitRowHover && style.rowHoverColor !== "none";
|
|
32
32
|
const rowStyleCellCss = (0, utils_1.maybeApplyFunction)(row, rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.cellCss);
|
|
33
|
+
const levelIndent = style.levels && ((_b = style.levels[level]) === null || _b === void 0 ? void 0 : _b.rowIndent);
|
|
33
34
|
const rowCss = {
|
|
34
35
|
...(!utils_1.reservedRowKinds.includes(row.kind) && style.nonHeaderRowCss),
|
|
35
36
|
// Optionally include the row hover styles, by default they should be turned on.
|
|
36
37
|
...(showRowHoverColor && {
|
|
37
38
|
// Even though backgroundColor is set on the cellCss, the hover target is the row.
|
|
38
|
-
"&:hover > *": Css_1.Css.bgColor((
|
|
39
|
+
"&:hover > *": Css_1.Css.bgColor((_c = style.rowHoverColor) !== null && _c !== void 0 ? _c : Css_1.Palette.Blue100).$,
|
|
39
40
|
}),
|
|
40
41
|
...(!utils_1.reservedRowKinds.includes(row.kind) &&
|
|
41
42
|
style.nonHeaderRowHoverCss && {
|
|
42
43
|
// Need to spread this to make TS happy.
|
|
43
44
|
":hover": { ...style.nonHeaderRowHoverCss },
|
|
44
45
|
}),
|
|
46
|
+
...(levelIndent && Css_1.Css.mlPx(levelIndent).$),
|
|
45
47
|
// For virtual tables use `display: flex` to keep all cells on the same row. For each cell in the row use `flexNone` to ensure they stay their defined widths
|
|
46
48
|
...(as === "table" ? {} : Css_1.Css.relative.df.fg1.fs1.addIn("&>*", Css_1.Css.flexNone.$).$),
|
|
47
49
|
// Apply `cursorPointer` to the row if it has a link or `onClick` value.
|
|
@@ -195,7 +197,8 @@ function RowImpl(props) {
|
|
|
195
197
|
// Apply cell highlight styles to active cell and hover
|
|
196
198
|
...Css_1.Css.if(applyCellHighlight && isCellActive).br4.boxShadow(`inset 0 0 0 1px ${Css_1.Palette.Blue700}`).$,
|
|
197
199
|
// Define the width of the column on each cell. Supports col spans.
|
|
198
|
-
|
|
200
|
+
// If we have a 'levelIndent' defined, then subtract that amount from the first content column's width to ensure all columns will still line up properly
|
|
201
|
+
width: `calc(${columnSizes.slice(columnIndex, columnIndex + currentColspan).join(" + ")}${applyFirstContentColumnStyles && levelIndent ? ` - ${levelIndent}px` : ""})`,
|
|
199
202
|
...(typeof column.mw === "string" ? Css_1.Css.mw(column.mw).$ : {}),
|
|
200
203
|
};
|
|
201
204
|
const cellClassNames = revealOnRowHover ? revealOnRowHoverClass : undefined;
|