@homebound/beam 2.110.0 → 2.113.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.
- package/dist/components/IconButton.d.ts +2 -0
- package/dist/components/IconButton.js +7 -4
- package/dist/components/Table/GridTable.d.ts +6 -2
- package/dist/components/Table/GridTable.js +30 -11
- package/dist/components/Table/nestedCards.d.ts +6 -0
- package/dist/components/Table/nestedCards.js +16 -1
- package/dist/components/Table/styles.js +0 -2
- package/package.json +1 -3
|
@@ -12,6 +12,8 @@ export interface IconButtonProps extends BeamButtonProps, BeamFocusableProps {
|
|
|
12
12
|
/** HTML attributes to apply to the button element when it is being used to trigger a menu. */
|
|
13
13
|
menuTriggerProps?: AriaButtonProps;
|
|
14
14
|
buttonRef?: RefObject<HTMLButtonElement>;
|
|
15
|
+
/** Whether to show a 16x16px version of the IconButton */
|
|
16
|
+
compact?: boolean;
|
|
15
17
|
}
|
|
16
18
|
export declare function IconButton(props: IconButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
17
19
|
export declare const iconButtonStylesHover: {
|
|
@@ -10,7 +10,7 @@ const Css_1 = require("../Css");
|
|
|
10
10
|
const utils_1 = require("../utils");
|
|
11
11
|
const useTestIds_1 = require("../utils/useTestIds");
|
|
12
12
|
function IconButton(props) {
|
|
13
|
-
const { onClick: onPress, disabled, color, icon, autoFocus, inc, buttonRef, tooltip, menuTriggerProps, openInNew, } = props;
|
|
13
|
+
const { onClick: onPress, disabled, color, icon, autoFocus, inc, buttonRef, tooltip, menuTriggerProps, openInNew, compact = false, } = props;
|
|
14
14
|
const isDisabled = !!disabled;
|
|
15
15
|
const ariaProps = { onPress, isDisabled, autoFocus, ...menuTriggerProps };
|
|
16
16
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
@@ -25,12 +25,13 @@ function IconButton(props) {
|
|
|
25
25
|
const testIds = (0, useTestIds_1.useTestIds)(props, icon);
|
|
26
26
|
const styles = (0, react_1.useMemo)(() => ({
|
|
27
27
|
...iconButtonStylesReset,
|
|
28
|
+
...(compact ? iconButtonCompact : iconButtonNormal),
|
|
28
29
|
...(isHovered && exports.iconButtonStylesHover),
|
|
29
30
|
...(isFocusVisible && iconButtonStylesFocus),
|
|
30
31
|
...(isDisabled && iconButtonStylesDisabled),
|
|
31
|
-
}), [isHovered, isFocusVisible, isDisabled]);
|
|
32
|
+
}), [isHovered, isFocusVisible, isDisabled, compact]);
|
|
32
33
|
const buttonAttrs = { ...testIds, ...buttonProps, ...focusProps, ...hoverProps, ref: ref, css: styles };
|
|
33
|
-
const buttonContent = ((0, jsx_runtime_1.jsx)(components_1.Icon, { icon: icon, color: color || (isDisabled ? Css_1.Palette.Gray400 : Css_1.Palette.Gray900), inc: inc }, void 0));
|
|
34
|
+
const buttonContent = ((0, jsx_runtime_1.jsx)(components_1.Icon, { icon: icon, color: color || (isDisabled ? Css_1.Palette.Gray400 : Css_1.Palette.Gray900), inc: compact ? 2 : inc }, void 0));
|
|
34
35
|
const button = typeof onPress === "string" ? ((0, utils_1.isAbsoluteUrl)(onPress) || openInNew ? ((0, jsx_runtime_1.jsx)("a", Object.assign({}, buttonAttrs, { href: onPress, className: components_1.navLink, target: "_blank", rel: "noreferrer noopener" }, { children: buttonContent }), void 0)) : ((0, jsx_runtime_1.jsx)(react_router_dom_1.Link, Object.assign({}, buttonAttrs, { to: onPress, className: components_1.navLink }, { children: buttonContent }), void 0))) : ((0, jsx_runtime_1.jsx)("button", Object.assign({}, buttonAttrs, { children: buttonContent }), void 0));
|
|
35
36
|
// If we're disabled b/c of a non-boolean ReactNode, or the caller specified tooltip text, then show it in a tooltip
|
|
36
37
|
return (0, components_1.maybeTooltip)({
|
|
@@ -40,7 +41,9 @@ function IconButton(props) {
|
|
|
40
41
|
});
|
|
41
42
|
}
|
|
42
43
|
exports.IconButton = IconButton;
|
|
43
|
-
const iconButtonStylesReset = Css_1.Css.
|
|
44
|
+
const iconButtonStylesReset = Css_1.Css.bTransparent.bsSolid.bgTransparent.cursorPointer.outline0.dif.aic.jcc.transition.$;
|
|
45
|
+
const iconButtonNormal = Css_1.Css.hPx(28).wPx(28).br8.bw2.$;
|
|
46
|
+
const iconButtonCompact = Css_1.Css.hPx(18).wPx(18).br4.bw1.$;
|
|
44
47
|
exports.iconButtonStylesHover = Css_1.Css.bgGray200.$;
|
|
45
48
|
const iconButtonStylesFocus = Css_1.Css.bLightBlue700.$;
|
|
46
49
|
const iconButtonStylesDisabled = Css_1.Css.cursorNotAllowed.$;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MutableRefObject, ReactElement, ReactNode } from "react";
|
|
2
2
|
import { PresentationContextProps, PresentationFieldProps } from "../PresentationContext";
|
|
3
3
|
import { GridRowLookup } from "./GridRowLookup";
|
|
4
|
-
import { Margin, Only, Properties, Typography, Xss } from "../../Css";
|
|
4
|
+
import { Margin, Only, Palette, Properties, Typography, Xss } from "../../Css";
|
|
5
5
|
export declare type Kinded = {
|
|
6
6
|
kind: string;
|
|
7
7
|
};
|
|
@@ -42,7 +42,7 @@ export interface GridStyle {
|
|
|
42
42
|
/** Applied if there is a fallback/overflow message showing. */
|
|
43
43
|
firstRowMessageCss?: Properties;
|
|
44
44
|
/** Applied on hover if a row has a rowLink/onClick set. */
|
|
45
|
-
rowHoverColor?:
|
|
45
|
+
rowHoverColor?: Palette;
|
|
46
46
|
/** Styling for our special "nested card" output mode. */
|
|
47
47
|
nestedCards?: NestedCardsStyle;
|
|
48
48
|
/** Default content to put into an empty cell */
|
|
@@ -245,6 +245,8 @@ export declare type GridColumn<R extends Kinded, S = {}> = {
|
|
|
245
245
|
clientSideSort?: boolean;
|
|
246
246
|
/** This column's sort by value (if server-side sorting). */
|
|
247
247
|
serverSideSortKey?: S;
|
|
248
|
+
/** Allows the column to stay in place when the user scrolls horizontally */
|
|
249
|
+
sticky?: "left" | "right";
|
|
248
250
|
};
|
|
249
251
|
export declare const nonKindGridColumnKeys: string[];
|
|
250
252
|
/** Allows rendering a specific cell. */
|
|
@@ -284,6 +286,8 @@ export declare type GridCellContent = {
|
|
|
284
286
|
indent?: 1 | 2;
|
|
285
287
|
colspan?: number;
|
|
286
288
|
typeScale?: Typography;
|
|
289
|
+
/** Allows the cell to stay in place when the user scrolls horizontally */
|
|
290
|
+
sticky?: "left" | "right";
|
|
287
291
|
};
|
|
288
292
|
declare type MaybeFn<T> = T | (() => T);
|
|
289
293
|
/**
|
|
@@ -43,7 +43,6 @@ const visitor_1 = require("./visitor");
|
|
|
43
43
|
const Css_1 = require("../../Css");
|
|
44
44
|
const hooks_1 = require("../../hooks");
|
|
45
45
|
const useRenderCount_1 = require("../../hooks/useRenderCount");
|
|
46
|
-
const tinycolor2_1 = __importDefault(require("tinycolor2"));
|
|
47
46
|
const _1 = require(".");
|
|
48
47
|
exports.ASC = "ASC";
|
|
49
48
|
exports.DESC = "DESC";
|
|
@@ -452,6 +451,7 @@ function getFirstOrLastCellCss(style, columnIndex, columns) {
|
|
|
452
451
|
}
|
|
453
452
|
// We extract GridRow to its own mini-component primarily so we can React.memo'ize it.
|
|
454
453
|
function GridRow(props) {
|
|
454
|
+
var _a;
|
|
455
455
|
const { as, columns, row, style, rowStyles, stickyHeader, stickyOffset, sorting, sortState, setSortKey, openCards, columnSizes, level, getCount, ...others } = props;
|
|
456
456
|
// We treat the "header" kind as special for "good defaults" styling
|
|
457
457
|
const isHeader = row.kind === "header";
|
|
@@ -467,19 +467,18 @@ function GridRow(props) {
|
|
|
467
467
|
const rowCss = {
|
|
468
468
|
// 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
|
|
469
469
|
...(as === "table" ? {} : Css_1.Css.relative.df.fg1.fs1.addIn("&>*", Css_1.Css.flexNone.$).$),
|
|
470
|
-
...(((rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.rowLink) || (rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.onClick)) &&
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
"&:hover > *": Css_1.Css.cursorPointer.bgColor(maybeDarken(rowStyleCellCss === null || rowStyleCellCss === void 0 ? void 0 : rowStyleCellCss.backgroundColor, style.rowHoverColor)).$,
|
|
470
|
+
...(((rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.rowLink) || (rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.onClick)) && {
|
|
471
|
+
// Even though backgroundColor is set on the cellCss, the hover target is the row.
|
|
472
|
+
"&:hover > *": Css_1.Css.cursorPointer.bgColor((_a = style.rowHoverColor) !== null && _a !== void 0 ? _a : Css_1.Palette.LightBlue100).$,
|
|
474
473
|
}),
|
|
475
474
|
...maybeApplyFunction(row, rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.rowCss),
|
|
476
475
|
// Maybe add the sticky header styles
|
|
477
|
-
...(isHeader && stickyHeader ? Css_1.Css.sticky.top(stickyOffset).
|
|
476
|
+
...(isHeader && stickyHeader ? Css_1.Css.sticky.top(stickyOffset).z2.$ : undefined),
|
|
478
477
|
...(0, nestedCards_1.getNestedCardStyles)(row, openCardStyles, style),
|
|
479
478
|
};
|
|
480
479
|
let currentColspan = 1;
|
|
481
480
|
const rowNode = ((0, jsx_runtime_1.jsx)(Row, Object.assign({ css: rowCss }, others, { "data-gridrow": true }, getCount(row.id), { children: columns.map((column, columnIndex) => {
|
|
482
|
-
var _a, _b;
|
|
481
|
+
var _a, _b, _c, _d;
|
|
483
482
|
if (column.mw) {
|
|
484
483
|
// Validate the column's minWidth definition if set.
|
|
485
484
|
if (!column.mw.endsWith("px") && !column.mw.endsWith("%")) {
|
|
@@ -500,6 +499,27 @@ function GridRow(props) {
|
|
|
500
499
|
const content = toContent(maybeContent, isHeader, canSortColumn, (sorting === null || sorting === void 0 ? void 0 : sorting.on) === "client", style, as, alignment);
|
|
501
500
|
(0, sortRows_1.ensureClientSideSortValueIsSortable)(sorting, isHeader, column, columnIndex, maybeContent);
|
|
502
501
|
const maybeNestedCardColumnIndex = columnIndex + (style.nestedCards ? 1 : 0);
|
|
502
|
+
const maybeSticky = (_b = ((isGridCellContent(maybeContent) && maybeContent.sticky) || column.sticky)) !== null && _b !== void 0 ? _b : undefined;
|
|
503
|
+
const maybeStickyColumnStyles = maybeSticky && columnSizes
|
|
504
|
+
? {
|
|
505
|
+
...Css_1.Css.sticky.z1.$,
|
|
506
|
+
// Need to apply a background to this cell to avoid content beneath it being shown when sticky.
|
|
507
|
+
// Assumes background is white for non-nestedCard styles. This can be overridden via cellCss.
|
|
508
|
+
...(((_c = style.nestedCards) === null || _c === void 0 ? void 0 : _c.kinds)
|
|
509
|
+
? Css_1.Css.bgColor((0, nestedCards_1.getCurrentBgColor)(row, openCardStyles, style.nestedCards.kinds)).$
|
|
510
|
+
: Css_1.Css.bgWhite.$),
|
|
511
|
+
...(maybeSticky === "left"
|
|
512
|
+
? Css_1.Css.left(maybeNestedCardColumnIndex === 0
|
|
513
|
+
? 0
|
|
514
|
+
: `calc(${columnSizes.slice(0, maybeNestedCardColumnIndex).join(" + ")})`).$
|
|
515
|
+
: {}),
|
|
516
|
+
...(maybeSticky === "right"
|
|
517
|
+
? Css_1.Css.right(maybeNestedCardColumnIndex + 1 === columnSizes.length
|
|
518
|
+
? 0
|
|
519
|
+
: `calc(${columnSizes.slice(maybeNestedCardColumnIndex + 1 - columnSizes.length).join(" + ")})`).$
|
|
520
|
+
: {}),
|
|
521
|
+
}
|
|
522
|
+
: {};
|
|
503
523
|
// Note that it seems expensive to calc a per-cell class name/CSS-in-JS output,
|
|
504
524
|
// vs. setting global/table-wide CSS like `style.cellCss` on the root grid div with
|
|
505
525
|
// a few descendent selectors. However, that approach means the root grid-applied
|
|
@@ -512,6 +532,8 @@ function GridRow(props) {
|
|
|
512
532
|
const cellCss = {
|
|
513
533
|
// Adding display flex so we can align content within the cells
|
|
514
534
|
...Css_1.Css.df.$,
|
|
535
|
+
// Apply sticky column/cell styles
|
|
536
|
+
...maybeStickyColumnStyles,
|
|
515
537
|
// Apply any static/all-cell styling
|
|
516
538
|
...style.cellCss,
|
|
517
539
|
// Then override with first/last cell styling
|
|
@@ -522,7 +544,7 @@ function GridRow(props) {
|
|
|
522
544
|
// Then apply any header-specific override
|
|
523
545
|
...(isHeader && style.headerCellCss),
|
|
524
546
|
// Or level-specific styling
|
|
525
|
-
...(!isHeader && !!style.levels && ((
|
|
547
|
+
...(!isHeader && !!style.levels && ((_d = style.levels[level]) === null || _d === void 0 ? void 0 : _d.cellCss)),
|
|
526
548
|
// The specific cell's css (if any from GridCellContent)
|
|
527
549
|
...rowStyleCellCss,
|
|
528
550
|
// Add any cell specific style overrides
|
|
@@ -697,9 +719,6 @@ function matchesFilter(maybeContent, filter) {
|
|
|
697
719
|
return false;
|
|
698
720
|
}
|
|
699
721
|
exports.matchesFilter = matchesFilter;
|
|
700
|
-
function maybeDarken(color, defaultColor) {
|
|
701
|
-
return color ? (0, tinycolor2_1.default)(color).darken(4).toString() : defaultColor;
|
|
702
|
-
}
|
|
703
722
|
/** GridTable as Table utility to apply <tr> element override styles. */
|
|
704
723
|
function tableRowStyles(as, column) {
|
|
705
724
|
const thWidth = column === null || column === void 0 ? void 0 : column.w;
|
|
@@ -88,6 +88,12 @@ export declare function getNestedCardStyles(row: GridDataRow<any>, openCardStyle
|
|
|
88
88
|
paddingLeft?: import("csstype").Property.PaddingLeft<0 | (string & {})> | undefined;
|
|
89
89
|
paddingRight?: import("csstype").Property.PaddingRight<0 | (string & {})> | undefined;
|
|
90
90
|
};
|
|
91
|
+
/**
|
|
92
|
+
* Returns the background color for the row.
|
|
93
|
+
* Either based on the current row's card having a defined background color, or the last opened card's background color
|
|
94
|
+
* Defaults to White.
|
|
95
|
+
*/
|
|
96
|
+
export declare function getCurrentBgColor(row: GridDataRow<any>, openCardStyles: NestedCardStyle[] | undefined, nestedKinds: NestedCardStyleByKind): string;
|
|
91
97
|
/**
|
|
92
98
|
* Create a spacer between rows of children.
|
|
93
99
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isLeafRow = exports.dropChromeRows = exports.ChromeRow = exports.makeSpacer = exports.getNestedCardStyles = exports.wrapCard = exports.makeOpenOrCloseCard = exports.NestedCards = void 0;
|
|
3
|
+
exports.isLeafRow = exports.dropChromeRows = exports.ChromeRow = exports.makeSpacer = exports.getCurrentBgColor = exports.getNestedCardStyles = exports.wrapCard = exports.makeOpenOrCloseCard = exports.NestedCards = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const Css_1 = require("../../Css");
|
|
@@ -176,6 +176,21 @@ function getNestedCardStyles(row, openCardStyles, style) {
|
|
|
176
176
|
};
|
|
177
177
|
}
|
|
178
178
|
exports.getNestedCardStyles = getNestedCardStyles;
|
|
179
|
+
/**
|
|
180
|
+
* Returns the background color for the row.
|
|
181
|
+
* Either based on the current row's card having a defined background color, or the last opened card's background color
|
|
182
|
+
* Defaults to White.
|
|
183
|
+
*/
|
|
184
|
+
function getCurrentBgColor(row, openCardStyles, nestedKinds) {
|
|
185
|
+
if (nestedKinds[row.kind]) {
|
|
186
|
+
return nestedKinds[row.kind].bgColor;
|
|
187
|
+
}
|
|
188
|
+
if (openCardStyles && openCardStyles.length > 0) {
|
|
189
|
+
return openCardStyles[openCardStyles.length - 1].bgColor;
|
|
190
|
+
}
|
|
191
|
+
return Css_1.Palette.White;
|
|
192
|
+
}
|
|
193
|
+
exports.getCurrentBgColor = getCurrentBgColor;
|
|
179
194
|
/**
|
|
180
195
|
* Create a spacer between rows of children.
|
|
181
196
|
*
|
|
@@ -14,7 +14,6 @@ exports.defaultStyle = {
|
|
|
14
14
|
indentTwoCss: Css_1.Css.pl7.$,
|
|
15
15
|
headerCellCss: Css_1.Css.nowrap.py1.bgGray100.aife.$,
|
|
16
16
|
firstRowMessageCss: Css_1.Css.px1.py2.$,
|
|
17
|
-
rowHoverColor: Css_1.Palette.Gray200,
|
|
18
17
|
};
|
|
19
18
|
/** Tightens up the padding of rows, great for rows that have form elements in them. */
|
|
20
19
|
exports.condensedStyle = {
|
|
@@ -45,7 +44,6 @@ exports.beamFixedStyle = {
|
|
|
45
44
|
cellCss: Css_1.Css.gray900.xs.bgWhite.aic.nowrap.pxPx(12).hPx(36).boxShadow(`inset 0 -1px 0 ${Css_1.Palette.Gray100}`).$,
|
|
46
45
|
emptyCell: "-",
|
|
47
46
|
presentationSettings: { borderless: true, typeScale: "xs", wrap: false },
|
|
48
|
-
rowHoverColor: Css_1.Palette.Gray200,
|
|
49
47
|
// Included as a hacky "treat indent as deprecated for this table" hint to GridTable
|
|
50
48
|
levels: {},
|
|
51
49
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@homebound/beam",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.113.0",
|
|
4
4
|
"author": "Homebound",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -37,7 +37,6 @@
|
|
|
37
37
|
"@internationalized/number": "^3.0.3",
|
|
38
38
|
"@react-aria/utils": "^3.9.0",
|
|
39
39
|
"@react-hook/resize-observer": "^1.2.2",
|
|
40
|
-
"@types/tinycolor2": "^1.4.2",
|
|
41
40
|
"change-case": "^4.1.2",
|
|
42
41
|
"date-fns": "^2.21.3",
|
|
43
42
|
"dompurify": "^2.3.0",
|
|
@@ -50,7 +49,6 @@
|
|
|
50
49
|
"react-router-dom": "^5.2.0",
|
|
51
50
|
"react-stately": "^3.9.0",
|
|
52
51
|
"react-virtuoso": "^2.4.0",
|
|
53
|
-
"tinycolor2": "^1.4.2",
|
|
54
52
|
"tributejs": "^5.1.3",
|
|
55
53
|
"trix": "^1.3.1",
|
|
56
54
|
"use-query-params": "^1.2.2",
|