@homebound/beam 2.166.0 → 2.168.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.
|
@@ -274,7 +274,7 @@ export declare type GridColumn<R extends Kinded, S = {}> = {
|
|
|
274
274
|
};
|
|
275
275
|
export declare const nonKindGridColumnKeys: string[];
|
|
276
276
|
/** Allows rendering a specific cell. */
|
|
277
|
-
declare type RenderCellFn<R extends Kinded> = (idx: number, css: Properties, content: ReactNode, row: R, rowStyle: RowStyle<R> | undefined) => ReactNode;
|
|
277
|
+
declare type RenderCellFn<R extends Kinded> = (idx: number, css: Properties, content: ReactNode, row: R, rowStyle: RowStyle<R> | undefined, classNames: string | undefined) => ReactNode;
|
|
278
278
|
/** Defines row-specific styling for each given row `kind` in `R` */
|
|
279
279
|
export declare type GridRowStyles<R extends Kinded> = {
|
|
280
280
|
[P in R["kind"]]?: RowStyle<DiscriminateUnion<R, "kind", P>>;
|
|
@@ -316,6 +316,8 @@ export declare type GridCellContent = {
|
|
|
316
316
|
onClick?: () => {} | string;
|
|
317
317
|
/** Custom css to apply directly to this cell, i.e. cell-specific borders. */
|
|
318
318
|
css?: Properties;
|
|
319
|
+
/** Allows cell to reveal content when the user hovers over a row. Content must be wrapped in an element in order to be hidden. IE <div>{value}</div>*/
|
|
320
|
+
revealOnRowHover?: true;
|
|
319
321
|
};
|
|
320
322
|
declare type MaybeFn<T> = T | (() => T);
|
|
321
323
|
/**
|
|
@@ -490,6 +490,7 @@ function GridRow(props) {
|
|
|
490
490
|
.map((openCardKind) => style.nestedCards.kinds[openCardKind])
|
|
491
491
|
.filter((style) => style)
|
|
492
492
|
: undefined;
|
|
493
|
+
const revealOnRowHoverClass = "revealOnRowHover";
|
|
493
494
|
const rowStyleCellCss = maybeApplyFunction(row, rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.cellCss);
|
|
494
495
|
const rowCss = {
|
|
495
496
|
// 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
|
|
@@ -502,6 +503,10 @@ function GridRow(props) {
|
|
|
502
503
|
// Maybe add the sticky header styles
|
|
503
504
|
...((isHeader || isTotals) && stickyHeader ? Css_1.Css.sticky.topPx(stickyOffset).z2.$ : undefined),
|
|
504
505
|
...(0, nestedCards_1.getNestedCardStyles)(row, openCardStyles, style, isActive),
|
|
506
|
+
...{
|
|
507
|
+
[` > .${revealOnRowHoverClass} > *`]: Css_1.Css.invisible.$,
|
|
508
|
+
[`:hover > .${revealOnRowHoverClass} > *`]: Css_1.Css.visible.$,
|
|
509
|
+
},
|
|
505
510
|
};
|
|
506
511
|
let currentColspan = 1;
|
|
507
512
|
let firstContentColumnStylesApplied = false;
|
|
@@ -523,6 +528,7 @@ function GridRow(props) {
|
|
|
523
528
|
}
|
|
524
529
|
const maybeContent = applyRowFn(column, row, api, level);
|
|
525
530
|
currentColspan = isGridCellContent(maybeContent) ? (_a = maybeContent.colspan) !== null && _a !== void 0 ? _a : 1 : 1;
|
|
531
|
+
const revealOnRowHover = isGridCellContent(maybeContent) ? maybeContent.revealOnRowHover : false;
|
|
526
532
|
const canSortColumn = (sortOn === "client" && column.clientSideSort !== false) ||
|
|
527
533
|
(sortOn === "server" && !!column.serverSideSortKey);
|
|
528
534
|
const alignment = getAlignment(column, maybeContent);
|
|
@@ -598,6 +604,7 @@ function GridRow(props) {
|
|
|
598
604
|
},
|
|
599
605
|
...(column.mw ? Css_1.Css.mw(column.mw).$ : {}),
|
|
600
606
|
};
|
|
607
|
+
const cellClassNames = revealOnRowHover ? revealOnRowHoverClass : undefined;
|
|
601
608
|
const renderFn = ((rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.renderCell) || (rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.rowLink)) && wrapAction
|
|
602
609
|
? rowLinkRenderFn(as)
|
|
603
610
|
: isHeader
|
|
@@ -605,7 +612,7 @@ function GridRow(props) {
|
|
|
605
612
|
: (rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.onClick) && wrapAction
|
|
606
613
|
? rowClickRenderFn(as, api)
|
|
607
614
|
: defaultRenderFn(as);
|
|
608
|
-
return renderFn(columnIndex, cellCss, content, row, rowStyle);
|
|
615
|
+
return renderFn(columnIndex, cellCss, content, row, rowStyle, cellClassNames);
|
|
609
616
|
}) }), void 0));
|
|
610
617
|
return openCardStyles && openCardStyles.length > 0 ? (0, nestedCards_1.wrapCard)(openCardStyles, rowNode) : rowNode;
|
|
611
618
|
}
|
|
@@ -696,12 +703,12 @@ function applyRowFn(column, row, api, level) {
|
|
|
696
703
|
}
|
|
697
704
|
exports.applyRowFn = applyRowFn;
|
|
698
705
|
/** Renders our default cell element, i.e. if no row links and no custom renderCell are used. */
|
|
699
|
-
const defaultRenderFn = (as) => (key, css, content) => {
|
|
706
|
+
const defaultRenderFn = (as) => (key, css, content, row, rowStyle, classNames) => {
|
|
700
707
|
const Cell = as === "table" ? "td" : "div";
|
|
701
|
-
return ((0, jsx_runtime_1.jsx)(Cell, Object.assign({ css: { ...css, ...tableRowStyles(as) } }, { children: content }), key));
|
|
708
|
+
return ((0, jsx_runtime_1.jsx)(Cell, Object.assign({ css: { ...css, ...tableRowStyles(as) }, className: classNames }, { children: content }), key));
|
|
702
709
|
};
|
|
703
710
|
/** Sets up the `GridContext` so that header cells can access the current sort settings. */
|
|
704
|
-
const headerRenderFn = (columns, column, sortState, setSortKey, as) => (key, css, content) => {
|
|
711
|
+
const headerRenderFn = (columns, column, sortState, setSortKey, as) => (key, css, content, row, rowStyle, classNames) => {
|
|
705
712
|
const [currentKey, direction] = sortState || [];
|
|
706
713
|
// If server-side sorting, use the user's key for this column; client-side sorting, use the index.
|
|
707
714
|
const ourSortKey = column.serverSideSortKey || columns.indexOf(column);
|
|
@@ -709,21 +716,21 @@ const headerRenderFn = (columns, column, sortState, setSortKey, as) => (key, css
|
|
|
709
716
|
sorted: ourSortKey === currentKey ? direction : undefined,
|
|
710
717
|
toggleSort: () => setSortKey(ourSortKey),
|
|
711
718
|
};
|
|
712
|
-
const
|
|
713
|
-
return ((0, jsx_runtime_1.jsx)(GridSortContext_1.GridSortContext.Provider, Object.assign({ value: context }, { children: (0, jsx_runtime_1.jsx)(
|
|
719
|
+
const Cell = as === "table" ? "th" : "div";
|
|
720
|
+
return ((0, jsx_runtime_1.jsx)(GridSortContext_1.GridSortContext.Provider, Object.assign({ value: context }, { children: (0, jsx_runtime_1.jsx)(Cell, Object.assign({ css: { ...css, ...tableRowStyles(as, column) }, className: classNames }, { children: content }), void 0) }), key));
|
|
714
721
|
};
|
|
715
722
|
/** Renders a cell element when a row link is in play. */
|
|
716
|
-
const rowLinkRenderFn = (as) => (key, css, content, row, rowStyle) => {
|
|
723
|
+
const rowLinkRenderFn = (as) => (key, css, content, row, rowStyle, classNames) => {
|
|
717
724
|
const to = rowStyle.rowLink(row);
|
|
718
725
|
if (as === "table") {
|
|
719
|
-
return ((0, jsx_runtime_1.jsx)("td", Object.assign({ css: { ...css, ...tableRowStyles(as) } }, { children: (0, jsx_runtime_1.jsx)(react_router_dom_1.Link, Object.assign({ to: to, css: Css_1.Css.noUnderline.color("unset").db.$, className: CssReset_1.navLink }, { children: content }), void 0) }), key));
|
|
726
|
+
return ((0, jsx_runtime_1.jsx)("td", Object.assign({ css: { ...css, ...tableRowStyles(as) }, className: classNames }, { children: (0, jsx_runtime_1.jsx)(react_router_dom_1.Link, Object.assign({ to: to, css: Css_1.Css.noUnderline.color("unset").db.$, className: CssReset_1.navLink }, { children: content }), void 0) }), key));
|
|
720
727
|
}
|
|
721
|
-
return ((0, jsx_runtime_1.jsx)(react_router_dom_1.Link, Object.assign({ to: to, css: { ...Css_1.Css.noUnderline.color("unset").$, ...css }, className: CssReset_1.navLink }, { children: content }), key));
|
|
728
|
+
return ((0, jsx_runtime_1.jsx)(react_router_dom_1.Link, Object.assign({ to: to, css: { ...Css_1.Css.noUnderline.color("unset").$, ...css }, className: `${CssReset_1.navLink} ${classNames}` }, { children: content }), key));
|
|
722
729
|
};
|
|
723
730
|
/** Renders a cell that will fire the RowStyle.onClick. */
|
|
724
|
-
const rowClickRenderFn = (as, api) => (key, css, content, row, rowStyle) => {
|
|
731
|
+
const rowClickRenderFn = (as, api) => (key, css, content, row, rowStyle, classNames) => {
|
|
725
732
|
const Row = as === "table" ? "tr" : "div";
|
|
726
|
-
return ((0, jsx_runtime_1.jsx)(Row, Object.assign({}, { key }, { css: { ...css, ...tableRowStyles(as) }, onClick: () => rowStyle.onClick(row, api) }, { children: content }), void 0));
|
|
733
|
+
return ((0, jsx_runtime_1.jsx)(Row, Object.assign({}, { key }, { css: { ...css, ...tableRowStyles(as) }, className: classNames, onClick: () => rowStyle.onClick(row, api) }, { children: content }), void 0));
|
|
727
734
|
};
|
|
728
735
|
const alignmentToJustify = {
|
|
729
736
|
left: "flex-start",
|
|
@@ -16,6 +16,7 @@ export interface TabsProps<V extends string, X> {
|
|
|
16
16
|
onChange: (value: V) => void;
|
|
17
17
|
contentXss?: X;
|
|
18
18
|
alwaysShowAllTabs?: boolean;
|
|
19
|
+
includeBottomBorder?: boolean;
|
|
19
20
|
}
|
|
20
21
|
export interface RouteTabsProps<V extends string, X> extends Omit<TabsProps<V, X>, "onChange" | "selected" | "tabs"> {
|
|
21
22
|
tabs: RouteTab<V>[];
|
|
@@ -65,26 +66,36 @@ export declare function getTabStyles(): {
|
|
|
65
66
|
} & {
|
|
66
67
|
paddingRight: import("csstype").Property.PaddingRight<0 | (string & {})> | undefined;
|
|
67
68
|
} & {
|
|
68
|
-
|
|
69
|
+
outline: import("csstype").Property.Outline<0 | (string & {})> | undefined;
|
|
70
|
+
} & {
|
|
71
|
+
color: import("csstype").Property.Color | undefined;
|
|
72
|
+
} & {
|
|
73
|
+
width: import("csstype").Property.Width<0 | (string & {})> | undefined;
|
|
74
|
+
} & {
|
|
75
|
+
cursor: import("csstype").Property.Cursor | undefined;
|
|
69
76
|
} & {
|
|
70
77
|
fontWeight: import("csstype").Property.FontWeight | undefined;
|
|
71
78
|
} & {
|
|
72
79
|
fontSize: import("csstype").Property.FontSize<0 | (string & {})> | undefined;
|
|
73
80
|
} & {
|
|
74
81
|
lineHeight: import("csstype").Property.LineHeight<0 | (string & {})> | undefined;
|
|
82
|
+
};
|
|
83
|
+
activeStyles: {
|
|
84
|
+
borderBottomStyle: import("csstype").Property.BorderBottomStyle | undefined;
|
|
75
85
|
} & {
|
|
76
|
-
|
|
86
|
+
borderBottomWidth: import("csstype").Property.BorderBottomWidth<0 | (string & {})> | undefined;
|
|
77
87
|
} & {
|
|
78
|
-
|
|
88
|
+
paddingBottom: import("csstype").Property.PaddingBottom<0 | (string & {})> | undefined;
|
|
79
89
|
} & {
|
|
80
|
-
|
|
90
|
+
borderColor: import("csstype").Property.BorderColor | undefined;
|
|
81
91
|
} & {
|
|
82
|
-
|
|
83
|
-
};
|
|
84
|
-
activeStyles: {
|
|
85
|
-
color: import("csstype").Property.Color | undefined;
|
|
92
|
+
fontWeight: import("csstype").Property.FontWeight | undefined;
|
|
86
93
|
} & {
|
|
87
|
-
|
|
94
|
+
fontSize: import("csstype").Property.FontSize<0 | (string & {})> | undefined;
|
|
95
|
+
} & {
|
|
96
|
+
lineHeight: import("csstype").Property.LineHeight<0 | (string & {})> | undefined;
|
|
97
|
+
} & {
|
|
98
|
+
color: import("csstype").Property.Color | undefined;
|
|
88
99
|
};
|
|
89
100
|
disabledStyles: {
|
|
90
101
|
color: import("csstype").Property.Color | undefined;
|
|
@@ -97,14 +108,24 @@ export declare function getTabStyles(): {
|
|
|
97
108
|
boxShadow: import("csstype").Property.BoxShadow | undefined;
|
|
98
109
|
};
|
|
99
110
|
hoverStyles: {
|
|
100
|
-
|
|
111
|
+
borderBottomStyle: import("csstype").Property.BorderBottomStyle | undefined;
|
|
101
112
|
} & {
|
|
102
|
-
|
|
113
|
+
borderBottomWidth: import("csstype").Property.BorderBottomWidth<0 | (string & {})> | undefined;
|
|
114
|
+
} & {
|
|
115
|
+
paddingBottom: import("csstype").Property.PaddingBottom<0 | (string & {})> | undefined;
|
|
116
|
+
} & {
|
|
117
|
+
borderColor: import("csstype").Property.BorderColor | undefined;
|
|
103
118
|
};
|
|
104
119
|
activeHoverStyles: {
|
|
105
120
|
backgroundColor: import("csstype").Property.BackgroundColor | undefined;
|
|
106
121
|
} & {
|
|
107
|
-
|
|
122
|
+
borderBottomStyle: import("csstype").Property.BorderBottomStyle | undefined;
|
|
123
|
+
} & {
|
|
124
|
+
borderBottomWidth: import("csstype").Property.BorderBottomWidth<0 | (string & {})> | undefined;
|
|
125
|
+
} & {
|
|
126
|
+
paddingBottom: import("csstype").Property.PaddingBottom<0 | (string & {})> | undefined;
|
|
127
|
+
} & {
|
|
128
|
+
borderColor: import("csstype").Property.BorderColor | undefined;
|
|
108
129
|
};
|
|
109
130
|
};
|
|
110
131
|
export declare function getNextTabValue<V extends string>(selected: V, key: "ArrowLeft" | "ArrowRight", tabs: Tab<V>[] | RouteTab<V>[]): V;
|
package/dist/components/Tabs.js
CHANGED
|
@@ -45,7 +45,7 @@ exports.TabContent = TabContent;
|
|
|
45
45
|
/** The top list of tabs. */
|
|
46
46
|
function Tabs(props) {
|
|
47
47
|
const { tabActionsRef, tabActionsDiv } = (0, BeamContext_1.useBeamContext)();
|
|
48
|
-
const { ariaLabel, tabs, ...others } = props;
|
|
48
|
+
const { ariaLabel, tabs, includeBottomBorder, ...others } = props;
|
|
49
49
|
const location = (0, react_router_1.useLocation)();
|
|
50
50
|
const selected = isRouteTabs(props)
|
|
51
51
|
? uniqueTabValue(props.tabs.find((t) => !!(0, react_router_1.matchPath)(location.pathname, { path: t.path, exact: true })) || props.tabs[0])
|
|
@@ -84,7 +84,7 @@ function Tabs(props) {
|
|
|
84
84
|
setActive(selected);
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
-
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.df.aic.$ }, { children: [!hideTabs(props) && ((0, jsx_runtime_1.jsx)("div", Object.assign({ ref: ref, css: Css_1.Css.dif.childGap1.$, "aria-label": ariaLabel, role: "tablist" }, tid, { children: tabs.map((tab) => {
|
|
87
|
+
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.df.aic.$ }, { children: [!hideTabs(props) && ((0, jsx_runtime_1.jsx)("div", Object.assign({ ref: ref, css: { ...Css_1.Css.dif.childGap1.$, ...(includeBottomBorder ? { ...Css_1.Css.bb.bGray200.$ } : {}) }, "aria-label": ariaLabel, role: "tablist" }, tid, { children: tabs.map((tab) => {
|
|
88
88
|
const uniqueValue = uniqueTabValue(tab);
|
|
89
89
|
return ((0, jsx_runtime_1.jsx)(TabImpl, Object.assign({ active: active === uniqueValue, focusProps: focusProps, isFocusVisible: isFocusVisible, onClick: onClick, onKeyUp: onKeyUp, onBlur: onBlur, tab: tab }, tid[(0, defaultTestId_1.defaultTestId)(uniqueValue)]), uniqueValue));
|
|
90
90
|
}) }), void 0)), (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.ml("auto").addIn("&>div", Css_1.Css.df.aic.childGap1.$).$, ref: tabActionsRef }, void 0)] }), void 0));
|
|
@@ -122,13 +122,20 @@ function TabImpl(props) {
|
|
|
122
122
|
return isDisabled ? ((0, jsx_runtime_1.jsx)("div", Object.assign({}, tabProps, { children: tabLabel }), void 0)) : isRouteTab(tab) ? ((0, jsx_runtime_1.jsx)(react_router_dom_1.Link, Object.assign({}, { ...tabProps, ...interactiveProps }, { className: "navLink", to: tab.href }, { children: tabLabel }), void 0)) : ((0, jsx_runtime_1.jsx)("button", Object.assign({}, { ...tabProps, ...interactiveProps }, { children: tabLabel }), void 0));
|
|
123
123
|
}
|
|
124
124
|
function getTabStyles() {
|
|
125
|
+
const borderBottomWidthPx = 4;
|
|
126
|
+
const verticalPaddingPx = 6;
|
|
127
|
+
// Decrease the bottom padding by the same amount of the new border width to prevent text layout shift
|
|
128
|
+
const borderBottomStyles = Css_1.Css.bb
|
|
129
|
+
.add("borderBottomWidth", `${borderBottomWidthPx}px`)
|
|
130
|
+
.pbPx(verticalPaddingPx - borderBottomWidthPx).$;
|
|
125
131
|
return {
|
|
126
|
-
baseStyles: Css_1.Css.df.aic.hPx(32).pyPx(
|
|
127
|
-
|
|
132
|
+
baseStyles: Css_1.Css.df.aic.hPx(32).pyPx(verticalPaddingPx).px1.outline0.gray700.add("width", "fit-content")
|
|
133
|
+
.cursorPointer.sm.$,
|
|
134
|
+
activeStyles: Css_1.Css.add(borderBottomStyles).bLightBlue700.smEm.gray900.$,
|
|
128
135
|
disabledStyles: Css_1.Css.gray400.cursorNotAllowed.$,
|
|
129
136
|
focusRingStyles: Css_1.Css.bgLightBlue50.bshFocus.$,
|
|
130
|
-
hoverStyles: Css_1.Css.
|
|
131
|
-
activeHoverStyles: Css_1.Css.
|
|
137
|
+
hoverStyles: Css_1.Css.add(borderBottomStyles).bGray400.$,
|
|
138
|
+
activeHoverStyles: Css_1.Css.bgLightBlue50.add(borderBottomStyles).bLightBlue700.$,
|
|
132
139
|
};
|
|
133
140
|
}
|
|
134
141
|
exports.getTabStyles = getTabStyles;
|
|
@@ -13,7 +13,7 @@ function ToggleChipGroup(props) {
|
|
|
13
13
|
const state = (0, react_stately_1.useCheckboxGroupState)({ ...props, value: values });
|
|
14
14
|
const { groupProps, labelProps } = (0, react_aria_1.useCheckboxGroup)(props, state);
|
|
15
15
|
const tid = (0, useTestIds_1.useTestIds)(props, "toggleChip");
|
|
16
|
-
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({}, groupProps, { css: Css_1.Css.relative.$ }, { children: [(0, jsx_runtime_1.jsx)(Label_1.Label, Object.assign({ label: label }, labelProps, { hidden: hideLabel }), void 0), (0, jsx_runtime_1.jsx)("div", { children: options.map((o) => ((0, jsx_runtime_1.jsx)(ToggleChip, Object.assign({ value: o.value, groupState: state, selected: state.value.includes(o.value), label: o.label }, tid[o.value]), o.value))) }, void 0)] }), void 0));
|
|
16
|
+
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({}, groupProps, { css: Css_1.Css.relative.$ }, { children: [(0, jsx_runtime_1.jsx)(Label_1.Label, Object.assign({ label: label }, labelProps, { hidden: hideLabel }), void 0), (0, jsx_runtime_1.jsx)("div", Object.assign({ css: Css_1.Css.df.gap1.add("flexWrap", "wrap").$ }, { children: options.map((o) => ((0, jsx_runtime_1.jsx)(ToggleChip, Object.assign({ value: o.value, groupState: state, selected: state.value.includes(o.value), label: o.label }, tid[o.value]), o.value))) }), void 0)] }), void 0));
|
|
17
17
|
}
|
|
18
18
|
exports.ToggleChipGroup = ToggleChipGroup;
|
|
19
19
|
function ToggleChip(props) {
|
|
@@ -22,7 +22,7 @@ function ToggleChip(props) {
|
|
|
22
22
|
const { inputProps } = (0, react_aria_1.useCheckboxGroupItem)({ value, "aria-label": label }, groupState, ref);
|
|
23
23
|
const { isFocusVisible, focusProps } = (0, react_aria_1.useFocusRing)();
|
|
24
24
|
return ((0, jsx_runtime_1.jsxs)("label", Object.assign({ css: {
|
|
25
|
-
...Css_1.Css.relative.dib.br16.sm.px1.cursorPointer.pyPx(4).
|
|
25
|
+
...Css_1.Css.relative.dib.br16.sm.px1.cursorPointer.pyPx(4).bgGray200.$,
|
|
26
26
|
...(isSelected
|
|
27
27
|
? {
|
|
28
28
|
...Css_1.Css.white.bgLightBlue700.$,
|