@homebound/beam 2.80.3 → 2.80.7
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 +2 -2
- package/dist/components/Table/GridTable.js +16 -16
- package/dist/components/Table/nestedCards.d.ts +1 -1
- package/dist/components/Table/nestedCards.js +4 -4
- package/dist/components/Tabs.d.ts +14 -3
- package/dist/components/testData.d.ts +2 -2
- package/dist/inputs/CheckboxBase.js +3 -2
- package/dist/utils/rtl.d.ts +3 -3
- package/dist/utils/rtl.js +9 -7
- package/package.json +1 -1
|
@@ -44,7 +44,7 @@ export interface NestedCardsStyle {
|
|
|
44
44
|
/** Space between each card. */
|
|
45
45
|
spacerPx: number;
|
|
46
46
|
/** Width of the first and last "hidden" columns used to align nested columns. */
|
|
47
|
-
firstLastColumnWidth
|
|
47
|
+
firstLastColumnWidth: number;
|
|
48
48
|
/**
|
|
49
49
|
* Per-kind styling for nested cards (see `cardStyle` if you only need a flat list of cards).
|
|
50
50
|
*
|
|
@@ -182,7 +182,7 @@ export declare function GridTable<R extends Kinded, S = {}, X extends Only<GridT
|
|
|
182
182
|
* When we're as=virtual, we change our default + enforce only fixed-sized units (% and px)
|
|
183
183
|
*/
|
|
184
184
|
export declare function calcVirtualGridColumns(columns: GridColumn<any>[], firstLastColumnWidth: number | undefined): string;
|
|
185
|
-
export declare function calcDivGridColumns(columns: GridColumn<any>[],
|
|
185
|
+
export declare function calcDivGridColumns(columns: GridColumn<any>[], firstLastColumnWidth: number | undefined): string;
|
|
186
186
|
/**
|
|
187
187
|
* Given an ADT of type T, performs a look up and returns the type of kind K.
|
|
188
188
|
*
|
|
@@ -213,16 +213,15 @@ const renders = {
|
|
|
213
213
|
virtual: renderVirtual,
|
|
214
214
|
};
|
|
215
215
|
/** Renders as a CSS Grid, which is the default / most well-supported rendered. */
|
|
216
|
-
function renderCssGrid(style, id, columns, headerRows, filteredRows, firstRowMessage, stickyHeader,
|
|
216
|
+
function renderCssGrid(style, id, columns, headerRows, filteredRows, firstRowMessage, stickyHeader, firstLastColumnWidth, xss, virtuosoRef) {
|
|
217
217
|
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ css: {
|
|
218
|
-
...Css_1.Css.dg.gtc(calcDivGridColumns(columns,
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
.addIn("& > div:nth-of-type(2) > *", style.firstNonHeaderRowCss || {}).$,
|
|
218
|
+
...Css_1.Css.dg.gtc(calcDivGridColumns(columns, firstLastColumnWidth)).$,
|
|
219
|
+
// Apply the between-row styling with `div + div > *` so that we don't have to have conditional
|
|
220
|
+
// `if !lastRow add border` CSS applied via JS that would mean the row can't be React.memo'd.
|
|
221
|
+
// The `div + div` is also the "owl operator", i.e. don't apply to the 1st row.
|
|
222
|
+
...(style.betweenRowsCss ? Css_1.Css.addIn("& > div + div > *", style.betweenRowsCss).$ : {}),
|
|
223
|
+
// removes border between header and second row
|
|
224
|
+
...(style.firstNonHeaderRowCss ? Css_1.Css.addIn("& > div:nth-of-type(2) > *", style.firstNonHeaderRowCss).$ : {}),
|
|
226
225
|
...style.rootCss,
|
|
227
226
|
...xss,
|
|
228
227
|
}, "data-testid": id }, { children: [headerRows.map(([, node]) => node), firstRowMessage && ((0, jsx_runtime_1.jsx)("div", Object.assign({ css: Css_1.Css.add("gridColumn", `${columns.length} span`).$ }, { children: (0, jsx_runtime_1.jsx)("div", Object.assign({ css: { ...style.firstRowMessageCss } }, { children: firstRowMessage }), void 0) }), void 0)), filteredRows.map(([, node]) => node)] }), void 0));
|
|
@@ -368,7 +367,7 @@ function calcVirtualGridColumns(columns, firstLastColumnWidth) {
|
|
|
368
367
|
return maybeAddCardColumns(sizes, firstLastColumnWidth);
|
|
369
368
|
}
|
|
370
369
|
exports.calcVirtualGridColumns = calcVirtualGridColumns;
|
|
371
|
-
function calcDivGridColumns(columns,
|
|
370
|
+
function calcDivGridColumns(columns, firstLastColumnWidth) {
|
|
372
371
|
const sizes = columns.map(({ w }) => {
|
|
373
372
|
if (typeof w === "undefined") {
|
|
374
373
|
// Hrm, I waffle between 'auto' or '1fr' being the better default here...
|
|
@@ -383,12 +382,12 @@ function calcDivGridColumns(columns, firstLastCardWidth) {
|
|
|
383
382
|
return `${w}fr`;
|
|
384
383
|
}
|
|
385
384
|
});
|
|
386
|
-
return maybeAddCardColumns(sizes,
|
|
385
|
+
return maybeAddCardColumns(sizes, firstLastColumnWidth);
|
|
387
386
|
}
|
|
388
387
|
exports.calcDivGridColumns = calcDivGridColumns;
|
|
389
388
|
// If we're doing nested cards, we add extra 1st/last cells...
|
|
390
|
-
function maybeAddCardColumns(sizes,
|
|
391
|
-
return (!
|
|
389
|
+
function maybeAddCardColumns(sizes, firstLastColumnWidth) {
|
|
390
|
+
return (!firstLastColumnWidth ? sizes : [`${firstLastColumnWidth}px`, ...sizes, `${firstLastColumnWidth}px`]).join(" ");
|
|
392
391
|
}
|
|
393
392
|
function getIndentationCss(style, rowStyle, columnIndex, maybeContent) {
|
|
394
393
|
// Look for cell-specific indent or row-specific indent (row-specific is only one the first column)
|
|
@@ -425,7 +424,8 @@ function GridRow(props) {
|
|
|
425
424
|
const Row = as === "table" ? "tr" : "div";
|
|
426
425
|
const currentCard = openCards && openCards.length > 0 && openCards[openCards.length - 1];
|
|
427
426
|
let currentColspan = 1;
|
|
428
|
-
const
|
|
427
|
+
const maybeStickyHeaderStyles = isHeader && stickyHeader ? Css_1.Css.sticky.top(stickyOffset).z1.$ : undefined;
|
|
428
|
+
const div = ((0, jsx_runtime_1.jsxs)(Row, Object.assign({ css: rowCss }, others, { children: [openCards && (0, nestedCards_1.maybeAddCardPadding)(openCards, "first", maybeStickyHeaderStyles), columns.map((column, columnIndex) => {
|
|
429
429
|
var _a;
|
|
430
430
|
// Decrement colspan count and skip if greater than 1.
|
|
431
431
|
if (currentColspan > 1) {
|
|
@@ -459,7 +459,7 @@ function GridRow(props) {
|
|
|
459
459
|
...getIndentationCss(style, rowStyle, columnIndex, maybeContent),
|
|
460
460
|
// Then apply any header-specific override
|
|
461
461
|
...(isHeader && style.headerCellCss),
|
|
462
|
-
...
|
|
462
|
+
...maybeStickyHeaderStyles,
|
|
463
463
|
// If we're within a card, use its background color
|
|
464
464
|
...(currentCard && Css_1.Css.bgColor(currentCard.bgColor).$),
|
|
465
465
|
// Add in colspan css if needed
|
|
@@ -475,7 +475,7 @@ function GridRow(props) {
|
|
|
475
475
|
? rowClickRenderFn(as)
|
|
476
476
|
: defaultRenderFn(as);
|
|
477
477
|
return renderFn(columnIndex, cellCss, content, row, rowStyle);
|
|
478
|
-
}), openCards && (0, nestedCards_1.maybeAddCardPadding)(openCards, "final")] }), void 0));
|
|
478
|
+
}), openCards && (0, nestedCards_1.maybeAddCardPadding)(openCards, "final", maybeStickyHeaderStyles)] }), void 0));
|
|
479
479
|
// Because of useToggleIds, this provider should basically never trigger a re-render, which is
|
|
480
480
|
// good because we don't want the context to change and re-render every row just because some
|
|
481
481
|
// other unrelated rows have collapsed/uncollapsed.
|
|
@@ -45,7 +45,7 @@ export declare function makeOpenOrCloseCard(openCards: NestedCardStyle[], kind:
|
|
|
45
45
|
* For the first or last cell of actual content, wrap them in divs that re-create the
|
|
46
46
|
* outer cards' padding + background.
|
|
47
47
|
*/
|
|
48
|
-
export declare function maybeAddCardPadding(openCards: NestedCardStyle[], column: "first" | "final"): any;
|
|
48
|
+
export declare function maybeAddCardPadding(openCards: NestedCardStyle[], column: "first" | "final", styles?: {}): any;
|
|
49
49
|
/**
|
|
50
50
|
* Create a spacer between rows of children.
|
|
51
51
|
*
|
|
@@ -97,8 +97,8 @@ exports.makeOpenOrCloseCard = makeOpenOrCloseCard;
|
|
|
97
97
|
* For the first or last cell of actual content, wrap them in divs that re-create the
|
|
98
98
|
* outer cards' padding + background.
|
|
99
99
|
*/
|
|
100
|
-
function maybeAddCardPadding(openCards, column) {
|
|
101
|
-
let div =
|
|
100
|
+
function maybeAddCardPadding(openCards, column, styles) {
|
|
101
|
+
let div = undefined;
|
|
102
102
|
[...openCards].reverse().forEach((card) => {
|
|
103
103
|
div = ((0, jsx_runtime_1.jsx)("div", Object.assign({ css: {
|
|
104
104
|
...Css_1.Css.h100.bgColor(card.bgColor).if(!!card.bColor).bc(card.bColor).$,
|
|
@@ -106,7 +106,7 @@ function maybeAddCardPadding(openCards, column) {
|
|
|
106
106
|
...(column === "final" && Css_1.Css.prPx(card.pxPx).if(!!card.bColor).br.$),
|
|
107
107
|
} }, { children: div }), void 0));
|
|
108
108
|
});
|
|
109
|
-
return div;
|
|
109
|
+
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ "data-cardpadding": "true" }, (styles ? { css: styles } : {}), { children: div }), void 0));
|
|
110
110
|
}
|
|
111
111
|
exports.maybeAddCardPadding = maybeAddCardPadding;
|
|
112
112
|
/**
|
|
@@ -142,7 +142,7 @@ function maybeCreateChromeRow(columns, filteredRows, chromeBuffer) {
|
|
|
142
142
|
filteredRows.push([
|
|
143
143
|
undefined,
|
|
144
144
|
// We add 2 to account for our dedicated open/close columns
|
|
145
|
-
(0, jsx_runtime_1.jsx)("div", Object.assign({ css: Css_1.Css.gc(`span ${columns.length + 2}`)
|
|
145
|
+
(0, jsx_runtime_1.jsx)("div", Object.assign({ css: Css_1.Css.gc(`span ${columns.length + 2}`).$, "data-chrome": "true" }, { children: chromeBuffer.map((c, i) => ((0, jsx_runtime_1.jsx)(react_1.Fragment, { children: c }, i))) }), void 0),
|
|
146
146
|
]);
|
|
147
147
|
// clear the buffer
|
|
148
148
|
chromeBuffer.splice(0, chromeBuffer.length);
|
|
@@ -7,7 +7,6 @@ export interface Tab<V extends string = string> {
|
|
|
7
7
|
icon?: IconKey;
|
|
8
8
|
endAdornment?: ReactNode;
|
|
9
9
|
disabled?: boolean;
|
|
10
|
-
render: () => ReactNode;
|
|
11
10
|
}
|
|
12
11
|
declare type TabsContentXss = Xss<Margin>;
|
|
13
12
|
export interface TabsProps<V extends string, X> {
|
|
@@ -25,6 +24,18 @@ export interface RouteTab<V extends string = string> extends Omit<Tab<V>, "value
|
|
|
25
24
|
href: V;
|
|
26
25
|
path: string | string[];
|
|
27
26
|
}
|
|
27
|
+
export interface TabWithContent<V extends string = string> extends Omit<Tab<V>, "render"> {
|
|
28
|
+
render: () => ReactNode;
|
|
29
|
+
}
|
|
30
|
+
export interface RouteTabWithContent<V extends string = string> extends Omit<RouteTab<V>, "render"> {
|
|
31
|
+
render: () => ReactNode;
|
|
32
|
+
}
|
|
33
|
+
interface RequiredRenderTabs<V extends string, X> extends Omit<TabsProps<V, X>, "tabs"> {
|
|
34
|
+
tabs: TabWithContent<V>[];
|
|
35
|
+
}
|
|
36
|
+
interface RequiredRenderRouteTabs<V extends string, X> extends Omit<RouteTabsProps<V, X>, "tabs"> {
|
|
37
|
+
tabs: RouteTabWithContent<V>[];
|
|
38
|
+
}
|
|
28
39
|
/**
|
|
29
40
|
* Provides a list of tabs and their content.
|
|
30
41
|
*
|
|
@@ -34,8 +45,8 @@ export interface RouteTab<V extends string = string> extends Omit<Tab<V>, "value
|
|
|
34
45
|
* If you want to tease apart Tabs from their TabContent, you can use the `Tab`
|
|
35
46
|
* and `TabContent` components directly.
|
|
36
47
|
*/
|
|
37
|
-
export declare function TabsWithContent<V extends string, X extends Only<TabsContentXss, X>>(props:
|
|
38
|
-
export declare function TabContent<V extends string>(props: Omit<
|
|
48
|
+
export declare function TabsWithContent<V extends string, X extends Only<TabsContentXss, X>>(props: RequiredRenderTabs<V, X> | RequiredRenderRouteTabs<V, X>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
49
|
+
export declare function TabContent<V extends string>(props: Omit<RequiredRenderTabs<V, {}>, "onChange"> | RequiredRenderRouteTabs<V, {}>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
39
50
|
/** The top list of tabs. */
|
|
40
51
|
export declare function Tabs<V extends string>(props: TabsProps<V, {}> | RouteTabsProps<V, {}>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
41
52
|
export declare function getTabStyles(): {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { TabWithContent } from "./Tabs";
|
|
3
3
|
export declare type TabValue = "tab1" | "tab2" | "tab3" | "tab4";
|
|
4
|
-
export declare const testTabs:
|
|
4
|
+
export declare const testTabs: TabWithContent<TabValue>[];
|
|
5
5
|
export declare function TestTabContent({ content }: {
|
|
6
6
|
content: ReactNode;
|
|
7
7
|
}): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -8,12 +8,13 @@ const HelperText_1 = require("../components/HelperText");
|
|
|
8
8
|
const Css_1 = require("../Css");
|
|
9
9
|
const ErrorMessage_1 = require("./ErrorMessage");
|
|
10
10
|
const utils_1 = require("../utils");
|
|
11
|
+
const defaultTestId_1 = require("../utils/defaultTestId");
|
|
11
12
|
function CheckboxBase(props) {
|
|
12
13
|
const { ariaProps, description, isDisabled = false, isIndeterminate = false, isSelected, inputProps, label, errorMsg, helperText, } = props;
|
|
13
14
|
const ref = (0, react_1.useRef)(null);
|
|
14
15
|
const { isFocusVisible, focusProps } = (0, react_aria_1.useFocusRing)(ariaProps);
|
|
15
16
|
const { hoverProps, isHovered } = (0, react_aria_1.useHover)({ isDisabled });
|
|
16
|
-
const tid = (0, utils_1.useTestIds)(props);
|
|
17
|
+
const tid = (0, utils_1.useTestIds)(props, (0, defaultTestId_1.defaultTestId)(label));
|
|
17
18
|
const markIcon = isIndeterminate ? dashSmall : isSelected ? checkmarkSmall : "";
|
|
18
19
|
return ((0, jsx_runtime_1.jsxs)("label", Object.assign({ css: Css_1.Css.df.cursorPointer.relative
|
|
19
20
|
// Prevents accidental checkbox clicks due to label width being longer
|
|
@@ -22,7 +23,7 @@ function CheckboxBase(props) {
|
|
|
22
23
|
.maxw((0, Css_1.px)(320))
|
|
23
24
|
.if(description !== undefined)
|
|
24
25
|
.maxw((0, Css_1.px)(344))
|
|
25
|
-
.if(isDisabled).cursorNotAllowed.$ }, { children: [(0, jsx_runtime_1.jsx)(react_aria_1.VisuallyHidden, { children: (0, jsx_runtime_1.jsx)("input", Object.assign({ ref: ref }, inputProps, focusProps), void 0) }, void 0), (0, jsx_runtime_1.jsx)("span", Object.assign({}, hoverProps, { css: {
|
|
26
|
+
.if(isDisabled).cursorNotAllowed.$ }, { children: [(0, jsx_runtime_1.jsx)(react_aria_1.VisuallyHidden, { children: (0, jsx_runtime_1.jsx)("input", Object.assign({ ref: ref }, inputProps, focusProps, tid), void 0) }, void 0), (0, jsx_runtime_1.jsx)("span", Object.assign({}, hoverProps, { css: {
|
|
26
27
|
...baseStyles,
|
|
27
28
|
...((isSelected || isIndeterminate) && filledBoxStyles),
|
|
28
29
|
...((isSelected || isIndeterminate) && isHovered && filledBoxHoverStyles),
|
package/dist/utils/rtl.d.ts
CHANGED
|
@@ -13,9 +13,9 @@ interface RenderOpts {
|
|
|
13
13
|
export declare function render(component: ReactElement, withoutBeamProvider: RenderOpts, ...otherWrappers: Wrapper[]): Promise<RenderResult & Record<string, HTMLElement & Function>>;
|
|
14
14
|
export declare function render(component: ReactElement, ...otherWrappers: Wrapper[]): Promise<RenderResult & Record<string, HTMLElement & Function>>;
|
|
15
15
|
export declare function cell(r: RenderResult, row: number, column: number): HTMLElement;
|
|
16
|
-
export declare function cellOf(r: RenderResult,
|
|
16
|
+
export declare function cellOf(r: RenderResult, tableTestId: string, rowNum: number, column: number): HTMLElement;
|
|
17
17
|
export declare function cellAnd(r: RenderResult, row: number, column: number, testId: string): HTMLElement;
|
|
18
|
-
export declare function row(r: RenderResult, row: number): HTMLElement;
|
|
19
|
-
export declare function rowAnd(r: RenderResult,
|
|
18
|
+
export declare function row(r: RenderResult, row: number, tableTestId?: string): HTMLElement;
|
|
19
|
+
export declare function rowAnd(r: RenderResult, rowNum: number, testId: string): HTMLElement;
|
|
20
20
|
/** RTL wrapper for Beam's SuperDrawer/Modal context. */
|
|
21
21
|
export declare const withBeamRTL: Wrapper;
|
package/dist/utils/rtl.js
CHANGED
|
@@ -34,11 +34,12 @@ function render(component, wrapperOrOpts, ...otherWrappers) {
|
|
|
34
34
|
}
|
|
35
35
|
exports.render = render;
|
|
36
36
|
function cell(r, row, column) {
|
|
37
|
-
return r
|
|
37
|
+
return cellOf(r, "grid-table", row, column);
|
|
38
38
|
}
|
|
39
39
|
exports.cell = cell;
|
|
40
|
-
function cellOf(r,
|
|
41
|
-
|
|
40
|
+
function cellOf(r, tableTestId, rowNum, column) {
|
|
41
|
+
const nonPaddingColumns = Array.from(row(r, rowNum, tableTestId).childNodes).filter((node) => !("cardpadding" in node.dataset));
|
|
42
|
+
return nonPaddingColumns[column];
|
|
42
43
|
}
|
|
43
44
|
exports.cellOf = cellOf;
|
|
44
45
|
function cellAnd(r, row, column, testId) {
|
|
@@ -46,12 +47,13 @@ function cellAnd(r, row, column, testId) {
|
|
|
46
47
|
fail(`Element not found ${(0, react_1.prettyDOM)(cell(r, row, column))}`));
|
|
47
48
|
}
|
|
48
49
|
exports.cellAnd = cellAnd;
|
|
49
|
-
function row(r, row) {
|
|
50
|
-
|
|
50
|
+
function row(r, row, tableTestId = "grid-table") {
|
|
51
|
+
const nonChromeRows = Array.from(r.getByTestId(tableTestId).childNodes).filter((node) => !("chrome" in node.dataset));
|
|
52
|
+
return nonChromeRows[row];
|
|
51
53
|
}
|
|
52
54
|
exports.row = row;
|
|
53
|
-
function rowAnd(r,
|
|
54
|
-
const e = r
|
|
55
|
+
function rowAnd(r, rowNum, testId) {
|
|
56
|
+
const e = row(r, rowNum);
|
|
55
57
|
return e.querySelector(`[data-testid="${testId}"]`) || fail(`Element not found ${(0, react_1.prettyDOM)(e)}`);
|
|
56
58
|
}
|
|
57
59
|
exports.rowAnd = rowAnd;
|