@homebound/beam 2.101.5 → 2.102.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/Table/GridTable.js +10 -6
- package/dist/components/Table/SortHeader.d.ts +1 -0
- package/dist/components/Table/SortHeader.js +8 -5
- package/dist/components/Table/columns.d.ts +2 -0
- package/dist/components/Table/columns.js +7 -1
- package/dist/components/Table/styles.d.ts +2 -0
- package/dist/components/Table/styles.js +11 -1
- package/dist/inputs/Checkbox.d.ts +1 -0
- package/dist/inputs/CheckboxBase.d.ts +1 -0
- package/dist/inputs/CheckboxBase.js +6 -3
- package/package.json +1 -1
|
@@ -492,7 +492,9 @@ function GridRow(props) {
|
|
|
492
492
|
currentColspan = isGridCellContent(maybeContent) ? (_a = maybeContent.colspan) !== null && _a !== void 0 ? _a : 1 : 1;
|
|
493
493
|
const canSortColumn = ((sorting === null || sorting === void 0 ? void 0 : sorting.on) === "client" && column.clientSideSort !== false) ||
|
|
494
494
|
((sorting === null || sorting === void 0 ? void 0 : sorting.on) === "server" && !!column.serverSideSortKey);
|
|
495
|
-
const
|
|
495
|
+
const alignment = getAlignment(column, maybeContent);
|
|
496
|
+
const justificationCss = getJustification(column, maybeContent, as, alignment);
|
|
497
|
+
const content = toContent(maybeContent, isHeader, canSortColumn, (sorting === null || sorting === void 0 ? void 0 : sorting.on) === "client", style, as, alignment);
|
|
496
498
|
(0, sortRows_1.ensureClientSideSortValueIsSortable)(sorting, isHeader, column, columnIndex, maybeContent);
|
|
497
499
|
const maybeNestedCardColumnIndex = columnIndex + (style.nestedCards ? 1 : 0);
|
|
498
500
|
// Note that it seems expensive to calc a per-cell class name/CSS-in-JS output,
|
|
@@ -512,7 +514,7 @@ function GridRow(props) {
|
|
|
512
514
|
// Then override with first/last cell styling
|
|
513
515
|
...getFirstOrLastCellCss(style, columnIndex, columns),
|
|
514
516
|
// Then override with per-cell/per-row justification/indentation
|
|
515
|
-
...
|
|
517
|
+
...justificationCss,
|
|
516
518
|
...getIndentationCss(style, rowStyle, columnIndex, maybeContent),
|
|
517
519
|
// Then apply any header-specific override
|
|
518
520
|
...(isHeader && style.headerCellCss),
|
|
@@ -553,7 +555,7 @@ function isJSX(content) {
|
|
|
553
555
|
return typeof content === "object" && content && "type" in content && "props" in content;
|
|
554
556
|
}
|
|
555
557
|
/** If a column def return just string text for a given row, apply some default styling. */
|
|
556
|
-
function toContent(content, isHeader, canSortColumn, isClientSideSorting, style, as) {
|
|
558
|
+
function toContent(content, isHeader, canSortColumn, isClientSideSorting, style, as, alignment) {
|
|
557
559
|
content = isGridCellContent(content) ? content.content : content;
|
|
558
560
|
if (typeof content === "function") {
|
|
559
561
|
// Actually create the JSX by calling `content()` here (which should be as late as
|
|
@@ -572,7 +574,7 @@ function toContent(content, isHeader, canSortColumn, isClientSideSorting, style,
|
|
|
572
574
|
throw new Error("GridTables with as=virtual & sortable columns should use functions that return JSX, instead of JSX");
|
|
573
575
|
}
|
|
574
576
|
if (content && typeof content === "string" && isHeader && canSortColumn) {
|
|
575
|
-
return (0, jsx_runtime_1.jsx)(SortHeader_1.SortHeader, { content: content }, void 0);
|
|
577
|
+
return (0, jsx_runtime_1.jsx)(SortHeader_1.SortHeader, { content: content, iconOnLeft: alignment === "right" }, void 0);
|
|
576
578
|
}
|
|
577
579
|
else if (style.emptyCell && isContentEmpty(content)) {
|
|
578
580
|
// If the content is empty and the user specified an `emptyCell` node, return that.
|
|
@@ -650,9 +652,11 @@ const alignmentToTextAlign = {
|
|
|
650
652
|
center: "center",
|
|
651
653
|
right: "right",
|
|
652
654
|
};
|
|
655
|
+
function getAlignment(column, maybeContent) {
|
|
656
|
+
return (isGridCellContent(maybeContent) && maybeContent.alignment) || column.align || "left";
|
|
657
|
+
}
|
|
653
658
|
// For alignment, use: 1) cell def, else 2) column def, else 3) left.
|
|
654
|
-
function getJustification(column, maybeContent, as) {
|
|
655
|
-
const alignment = (isGridCellContent(maybeContent) && maybeContent.alignment) || column.align || "left";
|
|
659
|
+
function getJustification(column, maybeContent, as, alignment) {
|
|
656
660
|
// Always apply text alignment.
|
|
657
661
|
const textAlign = Css_1.Css.add("textAlign", alignmentToTextAlign[alignment]).$;
|
|
658
662
|
if (as === "table") {
|
|
@@ -20,13 +20,16 @@ const useTestIds_1 = require("../../utils/useTestIds");
|
|
|
20
20
|
* current sort state + `toggleSort` function
|
|
21
21
|
*/
|
|
22
22
|
function SortHeader(props) {
|
|
23
|
-
const { content, xss } = props;
|
|
23
|
+
const { content, xss, iconOnLeft = false } = props;
|
|
24
24
|
const { isHovered, hoverProps } = (0, hooks_1.useHover)({});
|
|
25
25
|
const { sorted, toggleSort } = (0, react_1.useContext)(GridSortContext_1.GridSortContext);
|
|
26
26
|
const tid = (0, useTestIds_1.useTestIds)(props, "sortHeader");
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
const icon = ((0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.fs0.$ }, { children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, Object.assign({ icon: sorted === "DESC" ? "sortDown" : "sortUp", color: sorted !== undefined ? Css_1.Palette.LightBlue700 : Css_1.Palette.Gray400, xss: {
|
|
28
|
+
...Css_1.Css.ml1.if(iconOnLeft).mr1.ml0.$,
|
|
29
|
+
...Css_1.Css.visibility("hidden")
|
|
30
|
+
.if(isHovered || sorted !== undefined)
|
|
31
|
+
.visibility("visible").$,
|
|
32
|
+
}, inc: 2 }, tid.icon), void 0) }), void 0));
|
|
33
|
+
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({}, tid, { css: { ...Css_1.Css.df.aic.h100.cursorPointer.selectNone.$, ...xss } }, hoverProps, { onClick: toggleSort }, { children: [iconOnLeft && icon, content, !iconOnLeft && icon] }), void 0));
|
|
31
34
|
}
|
|
32
35
|
exports.SortHeader = SortHeader;
|
|
@@ -8,3 +8,5 @@ export declare function dateColumn<T extends Kinded, S = {}>(columnDef: GridColu
|
|
|
8
8
|
export declare function numericColumn<T extends Kinded, S = {}>(columnDef: GridColumn<T, S>): GridColumn<T, S>;
|
|
9
9
|
/** Provides default styling for a GridColumn representing an Action. */
|
|
10
10
|
export declare function actionColumn<T extends Kinded, S = {}>(columnDef: GridColumn<T, S>): GridColumn<T, S>;
|
|
11
|
+
/** Provides default styling for a GridColumn containing a checkbox. */
|
|
12
|
+
export declare function selectColumn<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.actionColumn = exports.numericColumn = exports.dateColumn = exports.column = void 0;
|
|
3
|
+
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 };
|
|
@@ -22,3 +22,9 @@ function actionColumn(columnDef) {
|
|
|
22
22
|
return { clientSideSort: false, ...columnDef, align: "center" };
|
|
23
23
|
}
|
|
24
24
|
exports.actionColumn = actionColumn;
|
|
25
|
+
/** Provides default styling for a GridColumn containing a checkbox. */
|
|
26
|
+
function selectColumn(columnDef) {
|
|
27
|
+
// Defining `w: 48px` to accommodate for the `16px` wide checkbox and `16px` of padding on either side.
|
|
28
|
+
return { clientSideSort: false, ...columnDef, align: "center", w: "48px" };
|
|
29
|
+
}
|
|
30
|
+
exports.selectColumn = selectColumn;
|
|
@@ -5,3 +5,5 @@ export declare const defaultStyle: GridStyle;
|
|
|
5
5
|
export declare const condensedStyle: GridStyle;
|
|
6
6
|
/** Renders each row as a card. */
|
|
7
7
|
export declare const cardStyle: GridStyle;
|
|
8
|
+
export declare const beamFixedStyle: GridStyle;
|
|
9
|
+
export declare const beamFlexibleStyle: GridStyle;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cardStyle = exports.condensedStyle = exports.defaultStyle = void 0;
|
|
3
|
+
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 = {
|
|
@@ -39,3 +39,13 @@ exports.cardStyle = {
|
|
|
39
39
|
}).p1.m0.xsEm.gray700.$,
|
|
40
40
|
},
|
|
41
41
|
};
|
|
42
|
+
// Once completely rolled out across all tables in Blueprint, this will change to be the `defaultStyle`.
|
|
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}`).$,
|
|
49
|
+
};
|
|
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.$ };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
export interface CheckboxProps {
|
|
3
3
|
label: string;
|
|
4
|
+
checkboxOnly?: boolean;
|
|
4
5
|
/** Handler that is called when the element's selection state changes. */
|
|
5
6
|
onChange: (selected: boolean) => void;
|
|
6
7
|
/** Additional text displayed below label */
|
|
@@ -10,7 +10,7 @@ const ErrorMessage_1 = require("./ErrorMessage");
|
|
|
10
10
|
const utils_1 = require("../utils");
|
|
11
11
|
const defaultTestId_1 = require("../utils/defaultTestId");
|
|
12
12
|
function CheckboxBase(props) {
|
|
13
|
-
const { ariaProps, description, isDisabled = false, isIndeterminate = false, isSelected, inputProps, label, errorMsg, helperText, } = props;
|
|
13
|
+
const { ariaProps, description, isDisabled = false, isIndeterminate = false, isSelected, inputProps, label, errorMsg, helperText, checkboxOnly = false, } = props;
|
|
14
14
|
const ref = (0, react_1.useRef)(null);
|
|
15
15
|
const { isFocusVisible, focusProps } = (0, react_aria_1.useFocusRing)(ariaProps);
|
|
16
16
|
const { hoverProps, isHovered } = (0, react_aria_1.useHover)({ isDisabled });
|
|
@@ -23,7 +23,7 @@ function CheckboxBase(props) {
|
|
|
23
23
|
.maxw((0, Css_1.px)(320))
|
|
24
24
|
.if(description !== undefined)
|
|
25
25
|
.maxw((0, Css_1.px)(344))
|
|
26
|
-
.if(isDisabled).cursorNotAllowed
|
|
26
|
+
.if(isDisabled).cursorNotAllowed.$, "aria-label": label }, { children: [(0, jsx_runtime_1.jsx)(react_aria_1.VisuallyHidden, { children: (0, jsx_runtime_1.jsx)("input", Object.assign({ ref: ref }, (0, react_aria_1.mergeProps)(inputProps, focusProps), tid), void 0) }, void 0), (0, jsx_runtime_1.jsx)("span", Object.assign({}, hoverProps, { css: {
|
|
27
27
|
...baseStyles,
|
|
28
28
|
...((isSelected || isIndeterminate) && filledBoxStyles),
|
|
29
29
|
...((isSelected || isIndeterminate) && isHovered && filledBoxHoverStyles),
|
|
@@ -31,7 +31,10 @@ function CheckboxBase(props) {
|
|
|
31
31
|
...(isFocusVisible && focusRingStyles),
|
|
32
32
|
...(isHovered && hoverBorderStyles),
|
|
33
33
|
...markStyles,
|
|
34
|
-
}, "aria-hidden": "true" }, { children: markIcon }), void 0),
|
|
34
|
+
}, "aria-hidden": "true" }, { children: markIcon }), void 0), !checkboxOnly && (
|
|
35
|
+
// Use a mtPx(-2) to better align the label with the checkbox.
|
|
36
|
+
// Not using align-items: center as the checkbox would align with all content below, where we really want it to stay only aligned with the label
|
|
37
|
+
(0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.ml1.mtPx(-2).$ }, { children: [label && (0, jsx_runtime_1.jsx)("div", Object.assign({ css: { ...labelStyles, ...(isDisabled && disabledColor) } }, { children: label }), void 0), description && (0, jsx_runtime_1.jsx)("div", Object.assign({ css: { ...descStyles, ...(isDisabled && disabledColor) } }, { children: description }), void 0), errorMsg && (0, jsx_runtime_1.jsx)(ErrorMessage_1.ErrorMessage, Object.assign({ errorMsg: errorMsg }, tid.errorMsg), void 0), helperText && (0, jsx_runtime_1.jsx)(HelperText_1.HelperText, Object.assign({ helperText: helperText }, tid.helperText), void 0)] }), void 0))] }), void 0));
|
|
35
38
|
}
|
|
36
39
|
exports.CheckboxBase = CheckboxBase;
|
|
37
40
|
const baseStyles = Css_1.Css.hPx(16).mw((0, Css_1.px)(16)).relative.ba.bGray300.br4.bgWhite.transition.$;
|