@homebound/beam 2.104.0 → 2.105.3
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/Chip.js +5 -1
- package/dist/components/Chips.js +7 -1
- package/dist/components/PresentationContext.d.ts +1 -0
- package/dist/components/Table/GridTable.d.ts +2 -0
- package/dist/components/Table/GridTable.js +17 -4
- package/dist/components/Table/columns.d.ts +2 -0
- package/dist/components/Table/columns.js +7 -1
- package/dist/components/Table/styles.d.ts +3 -0
- package/dist/components/Table/styles.js +15 -8
- package/dist/components/Tooltip.d.ts +4 -2
- package/dist/components/Tooltip.js +4 -1
- package/dist/inputs/TextField.d.ts +3 -1
- package/dist/inputs/TextFieldBase.js +1 -1
- package/package.json +1 -1
package/dist/components/Chip.js
CHANGED
|
@@ -2,14 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Chip = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
|
+
const PresentationContext_1 = require("./PresentationContext");
|
|
5
6
|
const Css_1 = require("../Css");
|
|
6
7
|
const useTestIds_1 = require("../utils/useTestIds");
|
|
7
8
|
/** Kinda like a chip, but read-only, so no `onClick` or `hover`. */
|
|
8
9
|
function Chip(props) {
|
|
10
|
+
var _a;
|
|
9
11
|
const { text, xss = {} } = props;
|
|
12
|
+
const { fieldProps } = (0, PresentationContext_1.usePresentationContext)();
|
|
13
|
+
const typeScale = (_a = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.typeScale) !== null && _a !== void 0 ? _a : "sm";
|
|
10
14
|
const tid = (0, useTestIds_1.useTestIds)(props, "chip");
|
|
11
15
|
return ((0, jsx_runtime_1.jsx)("span", Object.assign({ css: {
|
|
12
|
-
...Css_1.Css.dif.aic.br16.
|
|
16
|
+
...Css_1.Css[typeScale].dif.aic.br16.pl1.px1.pyPx(2).gray900.bgGray200.$,
|
|
13
17
|
...xss,
|
|
14
18
|
} }, tid, { title: text }, { children: (0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.lineClamp1.breakAll.$ }, { children: text }), void 0) }), void 0));
|
|
15
19
|
}
|
package/dist/components/Chips.js
CHANGED
|
@@ -3,10 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Chips = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const Chip_1 = require("./Chip");
|
|
6
|
+
const PresentationContext_1 = require("./PresentationContext");
|
|
6
7
|
const Css_1 = require("../Css");
|
|
7
8
|
/** Renders a list of `Chip`s, with wrapping & appropriate margin between each `Chip`. */
|
|
8
9
|
function Chips(props) {
|
|
10
|
+
const { wrap } = (0, PresentationContext_1.usePresentationContext)();
|
|
9
11
|
const { values, xss = {} } = props;
|
|
10
|
-
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ css: {
|
|
12
|
+
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ css: {
|
|
13
|
+
...Css_1.Css.df.aifs.gap1.whiteSpace("normal").$,
|
|
14
|
+
...(wrap !== false ? Css_1.Css.add({ flexWrap: "wrap" }).$ : {}),
|
|
15
|
+
...xss,
|
|
16
|
+
} }, { children: values.map((value, i) => ((0, jsx_runtime_1.jsx)(Chip_1.Chip, { text: value }, i))) }), void 0));
|
|
11
17
|
}
|
|
12
18
|
exports.Chips = Chips;
|
|
@@ -13,6 +13,7 @@ export interface PresentationFieldProps {
|
|
|
13
13
|
export declare type PresentationContextProps = {
|
|
14
14
|
fieldProps?: PresentationFieldProps;
|
|
15
15
|
gridTableStyle?: GridStyle;
|
|
16
|
+
wrap?: boolean;
|
|
16
17
|
};
|
|
17
18
|
export declare const PresentationContext: import("react").Context<PresentationContextProps>;
|
|
18
19
|
export declare function PresentationProvider(props: PropsWithChildren<PresentationContextProps>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { MutableRefObject, ReactElement, ReactNode } from "react";
|
|
2
|
+
import { PresentationContextProps, PresentationFieldProps } from "../PresentationContext";
|
|
2
3
|
import { GridRowLookup } from "./GridRowLookup";
|
|
3
4
|
import { Margin, Only, Properties, Xss } from "../../Css";
|
|
4
5
|
export declare type Kinded = {
|
|
@@ -46,6 +47,7 @@ export interface GridStyle {
|
|
|
46
47
|
nestedCards?: NestedCardsStyle;
|
|
47
48
|
/** Default content to put into an empty cell */
|
|
48
49
|
emptyCell?: ReactNode;
|
|
50
|
+
presentationSettings?: Pick<PresentationFieldProps, "borderless" | "typeScale"> & Pick<PresentationContextProps, "wrap">;
|
|
49
51
|
}
|
|
50
52
|
export declare type NestedCardStyleByKind = Record<string, NestedCardStyle>;
|
|
51
53
|
export interface NestedCardsStyle {
|
|
@@ -80,7 +80,7 @@ exports.setGridTableDefaults = setGridTableDefaults;
|
|
|
80
80
|
* special styling to the row that uses `kind: "header"`.)
|
|
81
81
|
*/
|
|
82
82
|
function GridTable(props) {
|
|
83
|
-
var _a;
|
|
83
|
+
var _a, _b, _c, _d, _e;
|
|
84
84
|
const { id = "gridTable", as = "div", columns, rows, style = defaults.style, rowStyles, stickyHeader = defaults.stickyHeader, stickyOffset = "0", xss, sorting, filter, filterMaxRows, fallbackMessage = "No rows found.", infoMessage, setRowCount, observeRows, persistCollapse, api, } = props;
|
|
85
85
|
const [collapsedIds, collapseAllContext, collapseRowContext] = useToggleIds(rows, persistCollapse);
|
|
86
86
|
// We only use this in as=virtual mode, but keep this here for rowLookup to use
|
|
@@ -98,12 +98,11 @@ function GridTable(props) {
|
|
|
98
98
|
}
|
|
99
99
|
return rows;
|
|
100
100
|
}, [columns, rows, sorting, sortState]);
|
|
101
|
+
const columnSizes = (0, react_1.useMemo)(() => { var _a; return calcColumnSizes(columns, (_a = style.nestedCards) === null || _a === void 0 ? void 0 : _a.firstLastColumnWidth); }, [columns, (_a = style.nestedCards) === null || _a === void 0 ? void 0 : _a.firstLastColumnWidth]);
|
|
101
102
|
// Filter + flatten + component-ize the sorted rows.
|
|
102
103
|
let [headerRows, filteredRows] = (0, react_1.useMemo)(() => {
|
|
103
|
-
var _a;
|
|
104
104
|
// Break up "foo bar" into `[foo, bar]` and a row must match both `foo` and `bar`
|
|
105
105
|
const filters = (filter && filter.split(/ +/)) || [];
|
|
106
|
-
const columnSizes = calcColumnSizes(columns, (_a = style.nestedCards) === null || _a === void 0 ? void 0 : _a.firstLastColumnWidth);
|
|
107
106
|
function makeRowComponent(row) {
|
|
108
107
|
// We only pass sortState to header rows, b/c non-headers rows shouldn't have to re-render on sorting
|
|
109
108
|
// changes, and so by not passing the sortProps, it means the data rows' React.memo will still cache them.
|
|
@@ -194,12 +193,22 @@ function GridTable(props) {
|
|
|
194
193
|
}, [filteredRows === null || filteredRows === void 0 ? void 0 : filteredRows.length, setRowCount]);
|
|
195
194
|
const noData = filteredRows.length === 0;
|
|
196
195
|
const firstRowMessage = (noData && fallbackMessage) || (tooManyClientSideRows && "Hiding some rows, use filter...") || infoMessage;
|
|
196
|
+
const borderless = (_b = style === null || style === void 0 ? void 0 : style.presentationSettings) === null || _b === void 0 ? void 0 : _b.borderless;
|
|
197
|
+
const typeScale = (_c = style === null || style === void 0 ? void 0 : style.presentationSettings) === null || _c === void 0 ? void 0 : _c.typeScale;
|
|
198
|
+
const fieldProps = (0, react_1.useMemo)(() => ({
|
|
199
|
+
hideLabel: true,
|
|
200
|
+
numberAlignment: "right",
|
|
201
|
+
compact: true,
|
|
202
|
+
// Avoid passing `undefined` as it will unset existing PresentationContext settings
|
|
203
|
+
...(borderless !== undefined ? { borderless } : {}),
|
|
204
|
+
...(typeScale !== undefined ? { typeScale } : {}),
|
|
205
|
+
}), [borderless, typeScale]);
|
|
197
206
|
// If we're running in Jest, force using `as=div` b/c jsdom doesn't support react-virtuoso.
|
|
198
207
|
// This enables still putting the application's business/rendering logic under test, and letting it
|
|
199
208
|
// just trust the GridTable impl that, at runtime, `as=virtual` will (other than being virtualized)
|
|
200
209
|
// behave semantically the same as `as=div` did for its tests.
|
|
201
210
|
const _as = as === "virtual" && runningInJest ? "div" : as;
|
|
202
|
-
return ((0, jsx_runtime_1.jsx)(PresentationContext_1.PresentationProvider, Object.assign({ fieldProps:
|
|
211
|
+
return ((0, jsx_runtime_1.jsx)(PresentationContext_1.PresentationProvider, Object.assign({ fieldProps: fieldProps, wrap: (_d = style === null || style === void 0 ? void 0 : style.presentationSettings) === null || _d === void 0 ? void 0 : _d.wrap }, { children: renders[_as](style, id, columns, headerRows, filteredRows, firstRowMessage, stickyHeader, (_e = style.nestedCards) === null || _e === void 0 ? void 0 : _e.firstLastColumnWidth, xss, virtuosoRef) }), void 0));
|
|
203
212
|
}
|
|
204
213
|
exports.GridTable = GridTable;
|
|
205
214
|
// Determine which HTML element to use to build the GridTable
|
|
@@ -497,6 +506,7 @@ function isJSX(content) {
|
|
|
497
506
|
}
|
|
498
507
|
/** If a column def return just string text for a given row, apply some default styling. */
|
|
499
508
|
function toContent(content, isHeader, canSortColumn, isClientSideSorting, style, as, alignment) {
|
|
509
|
+
var _a;
|
|
500
510
|
content = isGridCellContent(content) ? content.content : content;
|
|
501
511
|
if (typeof content === "function") {
|
|
502
512
|
// Actually create the JSX by calling `content()` here (which should be as late as
|
|
@@ -517,6 +527,9 @@ function toContent(content, isHeader, canSortColumn, isClientSideSorting, style,
|
|
|
517
527
|
if (content && typeof content === "string" && isHeader && canSortColumn) {
|
|
518
528
|
return (0, jsx_runtime_1.jsx)(SortHeader_1.SortHeader, { content: content, iconOnLeft: alignment === "right" }, void 0);
|
|
519
529
|
}
|
|
530
|
+
else if (content && typeof content === "string" && ((_a = style === null || style === void 0 ? void 0 : style.presentationSettings) === null || _a === void 0 ? void 0 : _a.wrap) === false) {
|
|
531
|
+
return ((0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.mw0.truncate.$, title: content }, { children: content }), void 0));
|
|
532
|
+
}
|
|
520
533
|
else if (style.emptyCell && isContentEmpty(content)) {
|
|
521
534
|
// If the content is empty and the user specified an `emptyCell` node, return that.
|
|
522
535
|
return style.emptyCell;
|
|
@@ -10,3 +10,5 @@ export declare function numericColumn<T extends Kinded, S = {}>(columnDef: GridC
|
|
|
10
10
|
export declare function actionColumn<T extends Kinded, S = {}>(columnDef: GridColumn<T, S>): GridColumn<T, S>;
|
|
11
11
|
/** Provides default styling for a GridColumn containing a checkbox. */
|
|
12
12
|
export declare function selectColumn<T extends Kinded, S = {}>(columnDef: GridColumn<T, S>): GridColumn<T, S>;
|
|
13
|
+
/** Provides default styling for a GridColumn containing the CollapseToggle component. */
|
|
14
|
+
export declare function collapseColumn<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.selectColumn = exports.actionColumn = exports.numericColumn = exports.dateColumn = exports.column = void 0;
|
|
3
|
+
exports.collapseColumn = 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 };
|
|
@@ -28,3 +28,9 @@ function selectColumn(columnDef) {
|
|
|
28
28
|
return { clientSideSort: false, ...columnDef, align: "center", w: "48px" };
|
|
29
29
|
}
|
|
30
30
|
exports.selectColumn = selectColumn;
|
|
31
|
+
/** Provides default styling for a GridColumn containing the CollapseToggle component. */
|
|
32
|
+
function collapseColumn(columnDef) {
|
|
33
|
+
// Defining `w: 38px` based on the designs
|
|
34
|
+
return { ...columnDef, clientSideSort: false, align: "center", w: "38px" };
|
|
35
|
+
}
|
|
36
|
+
exports.collapseColumn = collapseColumn;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Properties } from "../../Css";
|
|
1
2
|
import { GridStyle } from ".";
|
|
2
3
|
/** Our original table look & feel/style. */
|
|
3
4
|
export declare const defaultStyle: GridStyle;
|
|
@@ -7,3 +8,5 @@ export declare const condensedStyle: GridStyle;
|
|
|
7
8
|
export declare const cardStyle: GridStyle;
|
|
8
9
|
export declare const beamFixedStyle: GridStyle;
|
|
9
10
|
export declare const beamFlexibleStyle: GridStyle;
|
|
11
|
+
export declare const beamGroupRowStyle: Properties;
|
|
12
|
+
export declare const beamTotalsRowStyle: Properties;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.beamFlexibleStyle = exports.beamFixedStyle = exports.cardStyle = exports.condensedStyle = exports.defaultStyle = void 0;
|
|
3
|
+
exports.beamTotalsRowStyle = exports.beamGroupRowStyle = 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 = {
|
|
@@ -41,11 +41,18 @@ exports.cardStyle = {
|
|
|
41
41
|
};
|
|
42
42
|
// Once completely rolled out across all tables in Blueprint, this will change to be the `defaultStyle`.
|
|
43
43
|
exports.beamFixedStyle = {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
headerCellCss: Css_1.Css.gray700.xsEm.bgGray200.aic.nowrap.pxPx(12).hPx(40).$,
|
|
45
|
+
cellCss: Css_1.Css.gray900.xs.bgWhite.aic.nowrap.pxPx(12).hPx(36).boxShadow(`inset 0 -1px 0 ${Css_1.Palette.Gray100}`).$,
|
|
46
|
+
emptyCell: "-",
|
|
47
|
+
presentationSettings: { borderless: true, typeScale: "xs", wrap: false },
|
|
48
|
+
rowHoverColor: Css_1.Palette.Gray200,
|
|
49
|
+
};
|
|
50
|
+
exports.beamFlexibleStyle = {
|
|
51
|
+
...exports.beamFixedStyle,
|
|
52
|
+
cellCss: Css_1.Css.xs.bgWhite.aic.p2.boxShadow(`inset 0 -1px 0 ${Css_1.Palette.Gray100}`).$,
|
|
53
|
+
presentationSettings: { borderless: false, typeScale: "xs", wrap: true },
|
|
49
54
|
};
|
|
50
|
-
|
|
51
|
-
|
|
55
|
+
exports.beamGroupRowStyle = Css_1.Css.smEm
|
|
56
|
+
.mhPx(56)
|
|
57
|
+
.gray700.bgGray100.boxShadow(`inset 0 -1px 0 ${Css_1.Palette.Gray200}`).$;
|
|
58
|
+
exports.beamTotalsRowStyle = Css_1.Css.gray700.smEm.hPx(40).mb1.bgWhite.boxShadow("none").$;
|
|
@@ -2,13 +2,15 @@ import { ReactElement, ReactNode } from "react";
|
|
|
2
2
|
interface TooltipProps {
|
|
3
3
|
/** The content that shows up when hovered */
|
|
4
4
|
title: ReactNode;
|
|
5
|
-
children:
|
|
5
|
+
children: ReactNode;
|
|
6
6
|
placement?: Placement;
|
|
7
7
|
delay?: number;
|
|
8
8
|
disabled?: boolean;
|
|
9
9
|
}
|
|
10
10
|
export declare function Tooltip(props: TooltipProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
11
11
|
export declare type Placement = "top" | "bottom" | "left" | "right" | "auto";
|
|
12
|
-
export declare function maybeTooltip(props: TooltipProps
|
|
12
|
+
export declare function maybeTooltip(props: Omit<TooltipProps, "children"> & {
|
|
13
|
+
children: ReactElement;
|
|
14
|
+
}): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
13
15
|
export declare function resolveTooltip(disabled?: boolean | ReactNode, tooltip?: ReactNode, readOnly?: boolean | ReactNode): ReactNode | undefined;
|
|
14
16
|
export {};
|
|
@@ -27,13 +27,15 @@ const react_dom_1 = require("react-dom");
|
|
|
27
27
|
const react_popper_1 = require("react-popper");
|
|
28
28
|
const react_stately_1 = require("react-stately");
|
|
29
29
|
const Css_1 = require("../Css");
|
|
30
|
+
const utils_1 = require("../utils");
|
|
30
31
|
function Tooltip(props) {
|
|
31
32
|
const { placement, children, title, disabled, delay = 0 } = props;
|
|
32
33
|
const state = (0, react_stately_1.useTooltipTriggerState)({ delay, isDisabled: disabled });
|
|
33
34
|
const triggerRef = react_1.default.useRef(null);
|
|
34
35
|
const { triggerProps, tooltipProps: _tooltipProps } = (0, react_aria_1.useTooltipTrigger)({ isDisabled: disabled }, state, triggerRef);
|
|
35
36
|
const { tooltipProps } = (0, react_aria_1.useTooltip)(_tooltipProps, state);
|
|
36
|
-
|
|
37
|
+
const tid = (0, utils_1.useTestIds)(props, "tooltip");
|
|
38
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", Object.assign({ ref: triggerRef }, triggerProps, (!state.isOpen && typeof title === "string" ? { title } : {}), tid, { children: children }), void 0), state.isOpen && ((0, jsx_runtime_1.jsx)(Popper, Object.assign({}, (0, react_aria_1.mergeProps)(_tooltipProps, tooltipProps), { triggerRef: triggerRef, content: title, placement: placement }), void 0))] }, void 0));
|
|
37
39
|
}
|
|
38
40
|
exports.Tooltip = Tooltip;
|
|
39
41
|
function Popper({ triggerRef, content, placement = "auto" }) {
|
|
@@ -49,6 +51,7 @@ function Popper({ triggerRef, content, placement = "auto" }) {
|
|
|
49
51
|
return (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsxs)("div", Object.assign({ ref: popperRef, style: styles.popper }, attributes.popper, { css: Css_1.Css.maxw("320px").bgGray900.white.px1.py("4px").br4.xs.z999.$ }, { children: [(0, jsx_runtime_1.jsx)("div", { ref: setArrowRef, style: { ...styles.arrow }, id: "arrow" }, void 0), content] }), void 0), document.body);
|
|
50
52
|
}
|
|
51
53
|
// Helper function to conditionally wrap component with Tooltip if necessary.
|
|
54
|
+
// `maybeTooltip` requires that the `children` prop be a ReactElement, even though <Tooltip /> allows for ReactNode.
|
|
52
55
|
function maybeTooltip(props) {
|
|
53
56
|
return props.title ? (0, jsx_runtime_1.jsx)(Tooltip, Object.assign({}, props), void 0) : props.children;
|
|
54
57
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MutableRefObject } from "react";
|
|
1
|
+
import { MutableRefObject, ReactNode } from "react";
|
|
2
2
|
import { Only } from "../Css";
|
|
3
3
|
import { BeamTextFieldProps, TextFieldXss } from "../interfaces";
|
|
4
4
|
import { Callback } from "../types";
|
|
@@ -8,6 +8,8 @@ export interface TextFieldProps<X> extends BeamTextFieldProps<X> {
|
|
|
8
8
|
clearable?: boolean;
|
|
9
9
|
api?: MutableRefObject<TextFieldApi | undefined>;
|
|
10
10
|
onEnter?: Callback;
|
|
11
|
+
endAdornment?: ReactNode;
|
|
12
|
+
startAdornment?: ReactNode;
|
|
11
13
|
}
|
|
12
14
|
export declare function TextField<X extends Only<TextFieldXss, X>>(props: TextFieldProps<X>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
13
15
|
export declare type TextFieldApi = {
|
|
@@ -56,7 +56,7 @@ function TextFieldBase(props) {
|
|
|
56
56
|
...(!contrast ? Css_1.Css.bgWhite.$ : Css_1.Css.bgGray700.addIn("&::selection", Css_1.Css.bgGray800.$).$),
|
|
57
57
|
},
|
|
58
58
|
hover: Css_1.Css.bgGray100.if(contrast).bgGray600.bGray600.$,
|
|
59
|
-
focus: borderless ? Css_1.Css.bshFocus.$ : Css_1.Css.bLightBlue700.if(contrast).bLightBlue500.$,
|
|
59
|
+
focus: borderless ? Css_1.Css.bshFocus.z1.$ : Css_1.Css.bLightBlue700.if(contrast).bLightBlue500.$,
|
|
60
60
|
disabled: visuallyDisabled
|
|
61
61
|
? Css_1.Css.cursorNotAllowed.gray400.bgGray100.if(contrast).gray500.bgGray700.$
|
|
62
62
|
: Css_1.Css.cursorNotAllowed.$,
|