@homebound/beam 2.212.3 → 2.214.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/BeamContext.d.ts +2 -0
- package/dist/components/BeamContext.js +3 -0
- package/dist/components/ButtonGroup.js +1 -1
- package/dist/components/Snackbar/SnackbarNotice.d.ts +1 -1
- package/dist/components/Snackbar/SnackbarNotice.js +7 -5
- package/dist/components/SuperDrawer/SuperDrawer.js +9 -18
- package/dist/components/SuperDrawer/components/SuperDrawerHeader.d.ts +13 -0
- package/dist/components/SuperDrawer/components/SuperDrawerHeader.js +27 -0
- package/dist/components/SuperDrawer/index.d.ts +1 -0
- package/dist/components/SuperDrawer/index.js +1 -0
- package/dist/components/SuperDrawer/useSuperDrawer.d.ts +0 -10
- package/dist/components/Table/GridTable.js +23 -72
- package/dist/components/Table/components/Row.d.ts +0 -2
- package/dist/components/Table/components/Row.js +1 -5
- package/package.json +1 -1
|
@@ -19,6 +19,8 @@ export interface BeamContextState {
|
|
|
19
19
|
drawerCanCloseChecks: MutableRefObject<CanCloseCheck[]>;
|
|
20
20
|
/** Checks when closing SuperDrawer Details, a double array to keep per-detail lists. */
|
|
21
21
|
drawerCanCloseDetailsChecks: MutableRefObject<CanCloseCheck[][]>;
|
|
22
|
+
/** The div for SuperDrawerHeader to portal into. */
|
|
23
|
+
sdHeaderDiv: HTMLDivElement;
|
|
22
24
|
}
|
|
23
25
|
/** This is only exported internally, for useModal and useSuperDrawer, it's not a public API. */
|
|
24
26
|
export declare const BeamContext: import("react").Context<BeamContextState>;
|
|
@@ -20,6 +20,7 @@ exports.BeamContext = (0, react_1.createContext)({
|
|
|
20
20
|
drawerContentStack: new index_1.EmptyRef(),
|
|
21
21
|
drawerCanCloseChecks: new index_1.EmptyRef(),
|
|
22
22
|
drawerCanCloseDetailsChecks: new index_1.EmptyRef(),
|
|
23
|
+
sdHeaderDiv: undefined,
|
|
23
24
|
});
|
|
24
25
|
function BeamProvider({ children, ...presentationProps }) {
|
|
25
26
|
// We want the identity of these to be stable, b/c they end up being used as dependencies
|
|
@@ -40,6 +41,7 @@ function BeamProvider({ children, ...presentationProps }) {
|
|
|
40
41
|
const drawerContentStackRef = (0, react_1.useRef)([]);
|
|
41
42
|
const drawerCanCloseChecks = (0, react_1.useRef)([]);
|
|
42
43
|
const drawerCanCloseDetailsChecks = (0, react_1.useRef)([]);
|
|
44
|
+
const sdHeaderDiv = (0, react_1.useMemo)(() => document.createElement("div"), []);
|
|
43
45
|
// We essentially expose the refs, but with our own getters/setters so that we can
|
|
44
46
|
// have the setters call `tick` to re-render this Provider
|
|
45
47
|
const context = (0, react_1.useMemo)(() => {
|
|
@@ -54,6 +56,7 @@ function BeamProvider({ children, ...presentationProps }) {
|
|
|
54
56
|
modalFooterDiv,
|
|
55
57
|
drawerCanCloseChecks,
|
|
56
58
|
drawerCanCloseDetailsChecks,
|
|
59
|
+
sdHeaderDiv,
|
|
57
60
|
};
|
|
58
61
|
}, [modalBodyDiv, modalFooterDiv]);
|
|
59
62
|
return ((0, jsx_runtime_1.jsx)(exports.BeamContext.Provider, Object.assign({ value: { ...context } }, { children: (0, jsx_runtime_1.jsx)(PresentationContext_1.PresentationProvider, Object.assign({}, presentationProps, { children: (0, jsx_runtime_1.jsx)(form_state_1.AutoSaveStatusProvider, { children: (0, jsx_runtime_1.jsxs)(SnackbarContext_1.SnackbarProvider, { children: [(0, jsx_runtime_1.jsxs)(react_aria_1.OverlayProvider, { children: [children, modalRef.current && (0, jsx_runtime_1.jsx)(Modal_1.Modal, Object.assign({}, modalRef.current), void 0)] }, void 0), (0, jsx_runtime_1.jsx)(SuperDrawer_1.SuperDrawer, {}, void 0)] }, void 0) }, void 0) }), void 0) }), void 0));
|
|
@@ -11,7 +11,7 @@ const defaultTestId_1 = require("../utils/defaultTestId");
|
|
|
11
11
|
function ButtonGroup(props) {
|
|
12
12
|
const { buttons, disabled = false, size = "sm" } = props;
|
|
13
13
|
const tid = (0, utils_1.useTestIds)(props, "buttonGroup");
|
|
14
|
-
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ css:
|
|
14
|
+
return ((0, jsx_runtime_1.jsx)("div", Object.assign({}, tid, { css: sizeStyles[size] }, { children: buttons.map(({ disabled: buttonDisabled, ...buttonProps }, i) => (
|
|
15
15
|
// Disable the button if the ButtonGroup is disabled or if the current button is disabled.
|
|
16
16
|
(0, jsx_runtime_1.jsx)(GroupButton, Object.assign({}, buttonProps, { disabled: disabled || buttonDisabled, size: size }, tid), i))) }), void 0));
|
|
17
17
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
import { ButtonProps } from "../Button";
|
|
3
|
-
export declare type SnackbarNoticeTypes = "error" | "warning" | "success" | "info";
|
|
3
|
+
export declare type SnackbarNoticeTypes = "error" | "warning" | "success" | "info" | "alert";
|
|
4
4
|
export interface SnackbarNoticeProps {
|
|
5
5
|
/** Adds action button to the right of the notice */
|
|
6
6
|
action?: Pick<ButtonProps, "label" | "onClick" | "variant">;
|
|
@@ -12,12 +12,14 @@ function SnackbarNotice(props) {
|
|
|
12
12
|
const tid = (0, utils_1.useTestIds)(props, "snackbar");
|
|
13
13
|
// Only allow the "close" button to be hidden if not a `persistent` notice. Otherwise we could get in a state where the user cannot remove the notice from the screen.
|
|
14
14
|
const reallyHideClose = hideCloseButton && !persistent;
|
|
15
|
-
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.white.bgGray800.br4.base.df.aic.maxwPx(420).$ }, tid, { role: "alert" }, { children: [icon && ((0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.fs0.plPx(12).$ }, { children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, Object.assign({
|
|
15
|
+
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.white.bgGray800.br4.base.df.aic.maxwPx(420).$ }, tid, { role: "alert" }, { children: [icon && ((0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.fs0.plPx(12).$ }, { children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, Object.assign({}, typeToIcon[icon], tid.icon), void 0) }), void 0)), (0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.lineClamp3.pr2.myPx(12).plPx(icon ? 8 : 16).$ }, (typeof message === "string" ? { title: message } : undefined), tid.message, { children: message }), void 0), (action || !reallyHideClose) && ((0, jsx_runtime_1.jsxs)("span", Object.assign({ css: Css_1.Css.fs0.df.aic.$ }, { children: [action && ((0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.ttu.sm.prPx(!reallyHideClose && action.variant !== "text" ? 4 : 8).$ }, { children: (0, jsx_runtime_1.jsx)(Button_1.Button, Object.assign({ contrast: true }, action, tid.action), void 0) }), void 0)), !reallyHideClose && ((0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.pr1.add("lineHeight", 0).$ }, { children: (0, jsx_runtime_1.jsx)(IconButton_1.IconButton, Object.assign({ icon: "x", contrast: true, onClick: onClose }, tid.close), void 0) }), void 0))] }), void 0))] }), void 0));
|
|
16
16
|
}
|
|
17
17
|
exports.SnackbarNotice = SnackbarNotice;
|
|
18
18
|
const typeToIcon = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
// Can change to a Tupple with IconKey and color?
|
|
20
|
+
error: { icon: "xCircle", color: Css_1.Palette.Red300 },
|
|
21
|
+
warning: { icon: "error", color: Css_1.Palette.Yellow300 },
|
|
22
|
+
success: { icon: "checkCircle", color: Css_1.Palette.Green300 },
|
|
23
|
+
info: { icon: "infoCircle", color: Css_1.Palette.LightBlue200 },
|
|
24
|
+
alert: { icon: "errorCircle", color: Css_1.Palette.White },
|
|
23
25
|
};
|
|
@@ -35,10 +35,9 @@ const utils_2 = require("./utils");
|
|
|
35
35
|
*/
|
|
36
36
|
function SuperDrawer() {
|
|
37
37
|
var _a, _b;
|
|
38
|
-
const { drawerContentStack: contentStack } = (0, BeamContext_1.useBeamContext)();
|
|
38
|
+
const { drawerContentStack: contentStack, sdHeaderDiv } = (0, BeamContext_1.useBeamContext)();
|
|
39
39
|
const { closeDrawer } = (0, components_1.useSuperDrawer)();
|
|
40
|
-
const
|
|
41
|
-
const modalFooterRef = (0, react_3.useRef)(null);
|
|
40
|
+
const headerRef = (0, react_3.useRef)(null);
|
|
42
41
|
const testId = (0, utils_1.useTestIds)({}, "superDrawer");
|
|
43
42
|
// Get the latest element on the stack
|
|
44
43
|
// We use undefined, nullish operators and empty object here to allow AnimatePresence
|
|
@@ -47,10 +46,13 @@ function SuperDrawer() {
|
|
|
47
46
|
const { content } = currentContent !== null && currentContent !== void 0 ? currentContent : {};
|
|
48
47
|
// Also get the first / non-detail element on the stack
|
|
49
48
|
const firstContent = (_b = contentStack.current[0]) === null || _b === void 0 ? void 0 : _b.opts;
|
|
50
|
-
const { onPrevClick, onNextClick, titleRightContent, titleLeftContent, hideControls } = firstContent !== null && firstContent !== void 0 ? firstContent : {};
|
|
51
|
-
const isDetail = currentContent !== firstContent;
|
|
52
|
-
const title = content === undefined ? "" : currentContent.title || firstContent.title;
|
|
53
49
|
const { width = utils_2.SuperDrawerWidth.Normal } = firstContent !== null && firstContent !== void 0 ? firstContent : {};
|
|
50
|
+
(0, react_3.useEffect)(() => {
|
|
51
|
+
var _a;
|
|
52
|
+
if (((_a = headerRef.current) === null || _a === void 0 ? void 0 : _a.childNodes.length) === 0 && content) {
|
|
53
|
+
headerRef.current.appendChild(sdHeaderDiv);
|
|
54
|
+
}
|
|
55
|
+
}, [headerRef, content]);
|
|
54
56
|
return (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)(framer_motion_1.AnimatePresence, { children: content && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_2.Global, { styles: { body: Css_1.Css.overflowHidden.$ } }, void 0), (0, react_1.createElement)(framer_motion_1.motion.div, { ...testId,
|
|
55
57
|
// Key is required for framer-motion animations
|
|
56
58
|
key: "superDrawer",
|
|
@@ -70,17 +72,6 @@ function SuperDrawer() {
|
|
|
70
72
|
// Custom transitions settings for the translateX animation
|
|
71
73
|
transition: { ease: "linear", duration: 0.2, delay: 0.2 }, exit: { transition: { ease: "linear", duration: 0.2 }, x: width },
|
|
72
74
|
// Preventing clicks from triggering parent onClick
|
|
73
|
-
onClick: (e) => e.stopPropagation() }, { children: (0, jsx_runtime_1.jsxs)(form_state_1.AutoSaveStatusProvider, { children: [(0, jsx_runtime_1.jsxs)("header", Object.assign({ css: Css_1.Css.
|
|
74
|
-
{
|
|
75
|
-
icon: "chevronLeft",
|
|
76
|
-
onClick: () => onPrevClick && onPrevClick(),
|
|
77
|
-
disabled: !onPrevClick || isDetail,
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
icon: "chevronRight",
|
|
81
|
-
onClick: () => onNextClick && onNextClick(),
|
|
82
|
-
disabled: !onNextClick || isDetail,
|
|
83
|
-
},
|
|
84
|
-
] }, testId.headerActions), void 0)), (0, jsx_runtime_1.jsx)(components_1.IconButton, Object.assign({ icon: "x", onClick: closeDrawer }, testId.close), void 0)] }), void 0)] }), void 0), content] }, void 0) }), "superDrawerContainer"))] }, void 0)) }, void 0), document.body);
|
|
75
|
+
onClick: (e) => e.stopPropagation() }, { children: (0, jsx_runtime_1.jsxs)(form_state_1.AutoSaveStatusProvider, { children: [(0, jsx_runtime_1.jsxs)("header", Object.assign({ css: Css_1.Css.p3.bb.bGray200.df.aic.jcsb.gap3.$ }, { children: [(0, jsx_runtime_1.jsx)("div", { ref: headerRef, css: Css_1.Css.gray900.fg1.addIn("h1", Css_1.Css.xl2Sb.$).$ }, void 0), (0, jsx_runtime_1.jsx)(components_1.IconButton, Object.assign({ icon: "x", onClick: closeDrawer }, testId.close), void 0)] }), void 0), content] }, void 0) }), "superDrawerContainer"))] }, void 0)) }, void 0), document.body);
|
|
85
76
|
}
|
|
86
77
|
exports.SuperDrawer = SuperDrawer;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
interface SuperDrawerHeaderProps {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
hideControls?: boolean;
|
|
5
|
+
}
|
|
6
|
+
interface SuperDrawerHeaderStructuredProps {
|
|
7
|
+
title: string;
|
|
8
|
+
left?: ReactNode;
|
|
9
|
+
right?: ReactNode;
|
|
10
|
+
hideControls?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare function SuperDrawerHeader(props: SuperDrawerHeaderProps | SuperDrawerHeaderStructuredProps): JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SuperDrawerHeader = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
|
+
const react_dom_1 = require("react-dom");
|
|
6
|
+
const BeamContext_1 = require("../../BeamContext");
|
|
7
|
+
const ButtonGroup_1 = require("../../ButtonGroup");
|
|
8
|
+
const Css_1 = require("../../../Css");
|
|
9
|
+
const utils_1 = require("../../../utils");
|
|
10
|
+
function SuperDrawerHeader(props) {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
const { hideControls } = props;
|
|
13
|
+
const { sdHeaderDiv, drawerContentStack: contentStack } = (0, BeamContext_1.useBeamContext)();
|
|
14
|
+
const firstContent = (_a = contentStack.current[0]) === null || _a === void 0 ? void 0 : _a.opts;
|
|
15
|
+
const { onPrevClick, onNextClick } = firstContent !== null && firstContent !== void 0 ? firstContent : {};
|
|
16
|
+
const currentContent = (_b = contentStack.current[contentStack.current.length - 1]) === null || _b === void 0 ? void 0 : _b.opts;
|
|
17
|
+
const isDetail = currentContent !== firstContent;
|
|
18
|
+
const tid = (0, utils_1.useTestIds)({}, "superDrawerHeader");
|
|
19
|
+
return (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.df.aic.jcsb.gap3.$ }, tid, { children: [isStructuredProps(props) ? ((0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.df.jcsb.aic.gap2.fg1.$ }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.fg1.df.aic.gap2.$ }, { children: [(0, jsx_runtime_1.jsx)("h1", { children: props.title }, void 0), props.left] }), void 0), props.right && (0, jsx_runtime_1.jsx)("div", Object.assign({ css: Css_1.Css.fs0.$ }, { children: props.right }), void 0)] }), void 0)) : ((0, jsx_runtime_1.jsx)("div", Object.assign({ css: Css_1.Css.fg1.$ }, { children: props.children }), void 0)), !hideControls && ((0, jsx_runtime_1.jsx)("div", Object.assign({ css: Css_1.Css.fs0.if(isDetail).invisible.$ }, { children: (0, jsx_runtime_1.jsx)(ButtonGroup_1.ButtonGroup, Object.assign({ buttons: [
|
|
20
|
+
{ icon: "chevronLeft", onClick: () => onPrevClick && onPrevClick(), disabled: !onPrevClick },
|
|
21
|
+
{ icon: "chevronRight", onClick: () => onNextClick && onNextClick(), disabled: !onNextClick },
|
|
22
|
+
] }, tid.actions), void 0) }), void 0))] }), void 0), sdHeaderDiv);
|
|
23
|
+
}
|
|
24
|
+
exports.SuperDrawerHeader = SuperDrawerHeader;
|
|
25
|
+
function isStructuredProps(props) {
|
|
26
|
+
return typeof props === "object" && "title" in props;
|
|
27
|
+
}
|
|
@@ -11,6 +11,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
// These are our public APIs
|
|
14
|
+
__exportStar(require("./components/SuperDrawerHeader"), exports);
|
|
14
15
|
__exportStar(require("./ConfirmCloseModal"), exports);
|
|
15
16
|
__exportStar(require("./SuperDrawerContent"), exports);
|
|
16
17
|
__exportStar(require("./useSuperDrawer"), exports);
|
|
@@ -2,18 +2,10 @@ import { ReactNode } from "react";
|
|
|
2
2
|
import { CanCloseCheck } from "../../types";
|
|
3
3
|
import { SuperDrawerWidth } from "./utils";
|
|
4
4
|
export interface OpenInDrawerOpts {
|
|
5
|
-
/** Title of the SuperDrawer */
|
|
6
|
-
title: string;
|
|
7
|
-
/** Optional content to place left of the prev/next buttons, i.e. a "Manage" link. */
|
|
8
|
-
titleRightContent?: ReactNode;
|
|
9
|
-
/** Optional content to place right of the title, i.e. a status badge. */
|
|
10
|
-
titleLeftContent?: ReactNode;
|
|
11
5
|
/** Invokes left, disabled if undefined. */
|
|
12
6
|
onPrevClick?: () => void;
|
|
13
7
|
/** Invokes right, disabled if undefined. */
|
|
14
8
|
onNextClick?: () => void;
|
|
15
|
-
/** Hides the pagination controls for `onNextClick` and `onPrevClick` */
|
|
16
|
-
hideControls?: true;
|
|
17
9
|
/** Adds a callback that is called _after_ close has definitely happened. */
|
|
18
10
|
onClose?: () => void;
|
|
19
11
|
content: ReactNode;
|
|
@@ -21,8 +13,6 @@ export interface OpenInDrawerOpts {
|
|
|
21
13
|
width?: SuperDrawerWidth;
|
|
22
14
|
}
|
|
23
15
|
export interface OpenDetailOpts {
|
|
24
|
-
/** Title of the SuperDrawer for this detail page (replaces the original title). */
|
|
25
|
-
title?: string;
|
|
26
16
|
content: ReactNode;
|
|
27
17
|
}
|
|
28
18
|
export declare type ContentStack = {
|
|
@@ -133,26 +133,12 @@ function GridTable(props) {
|
|
|
133
133
|
// Flatten + component-ize the sorted rows.
|
|
134
134
|
let [headerRows, visibleDataRows, totalsRows, expandableHeaderRows, filteredRowIds] = (0, react_1.useMemo)(() => {
|
|
135
135
|
function makeRowComponent(row, level) {
|
|
136
|
-
// We may have multiple rows that need to be sticky, if that is the case, then we need properly define the stickyOffset for each row.
|
|
137
|
-
// *TOTALS* will always be on top, so that can remain 0.
|
|
138
|
-
// *EXPANDABLE_HEADER Header* may need to include the height of the totals row in the offset
|
|
139
|
-
// *HEADER* may need to include both TOTALS and EXPANDABLE_HEADER in its offset.
|
|
140
|
-
// TODO: Create a single "table header" container that can hold multiple rows and use a single `position: sticky`. And we can get rid of this nonsense.
|
|
141
|
-
const maybeTotalsRowHeight = hasTotalsRow ? TableStyles_1.totalsRowHeight : 0;
|
|
142
|
-
const maybeExpandableRowsHeight = hasExpandableHeader ? TableStyles_1.expandableHeaderRowHeight : 0;
|
|
143
|
-
const rowStickyOffset = row.kind === utils_1.HEADER
|
|
144
|
-
? maybeTotalsRowHeight + maybeExpandableRowsHeight
|
|
145
|
-
: row.kind === utils_1.EXPANDABLE_HEADER
|
|
146
|
-
? maybeTotalsRowHeight
|
|
147
|
-
: 0;
|
|
148
136
|
return ((0, jsx_runtime_1.jsx)(Row_1.Row, Object.assign({}, {
|
|
149
137
|
as,
|
|
150
138
|
columns,
|
|
151
139
|
row,
|
|
152
140
|
style,
|
|
153
141
|
rowStyles,
|
|
154
|
-
stickyHeader,
|
|
155
|
-
stickyOffset: rowStickyOffset + stickyOffset,
|
|
156
142
|
columnSizes,
|
|
157
143
|
level,
|
|
158
144
|
getCount,
|
|
@@ -203,21 +189,9 @@ function GridTable(props) {
|
|
|
203
189
|
const filteredRows = filterRows(api, columns, maybeSorted, filter);
|
|
204
190
|
visitRows(filteredRows, 0, true);
|
|
205
191
|
return [headerRows, visibleDataRows, totalsRows, expandableHeaderRows, filteredRowIds];
|
|
206
|
-
}, [
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
filter,
|
|
210
|
-
maybeSorted,
|
|
211
|
-
columns,
|
|
212
|
-
style,
|
|
213
|
-
rowStyles,
|
|
214
|
-
sortOn,
|
|
215
|
-
stickyHeader,
|
|
216
|
-
stickyOffset,
|
|
217
|
-
columnSizes,
|
|
218
|
-
collapsedIds,
|
|
219
|
-
getCount,
|
|
220
|
-
]);
|
|
192
|
+
}, [as, api, filter, maybeSorted, columns, style, rowStyles, sortOn, columnSizes, collapsedIds, getCount]);
|
|
193
|
+
// Once our header rows are created we can organize them in expected order.
|
|
194
|
+
const tableHeadRows = totalsRows.concat(expandableHeaderRows).concat(headerRows);
|
|
221
195
|
let tooManyClientSideRows = false;
|
|
222
196
|
if (filterMaxRows && visibleDataRows.length > filterMaxRows) {
|
|
223
197
|
tooManyClientSideRows = true;
|
|
@@ -252,7 +226,7 @@ function GridTable(props) {
|
|
|
252
226
|
// behave semantically the same as `as=div` did for its tests.
|
|
253
227
|
const _as = as === "virtual" && runningInJest ? "div" : as;
|
|
254
228
|
const rowStateContext = (0, react_1.useMemo)(() => ({ tableState: tableState }), [tableState]);
|
|
255
|
-
return ((0, jsx_runtime_1.jsx)(TableState_1.TableStateContext.Provider, Object.assign({ value: rowStateContext }, { children: (0, jsx_runtime_1.jsxs)(PresentationContext_1.PresentationProvider, Object.assign({ fieldProps: fieldProps, wrap: (_c = style === null || style === void 0 ? void 0 : style.presentationSettings) === null || _c === void 0 ? void 0 : _c.wrap }, { children: [(0, jsx_runtime_1.jsx)("div", { ref: resizeRef, css: Css_1.Css.w100.if(as === "virtual").w("calc(100% - 20px)").$ }, void 0), renders[_as](style, id, columns,
|
|
229
|
+
return ((0, jsx_runtime_1.jsx)(TableState_1.TableStateContext.Provider, Object.assign({ value: rowStateContext }, { children: (0, jsx_runtime_1.jsxs)(PresentationContext_1.PresentationProvider, Object.assign({ fieldProps: fieldProps, wrap: (_c = style === null || style === void 0 ? void 0 : style.presentationSettings) === null || _c === void 0 ? void 0 : _c.wrap }, { children: [(0, jsx_runtime_1.jsx)("div", { ref: resizeRef, css: Css_1.Css.w100.if(as === "virtual").w("calc(100% - 20px)").$ }, void 0), renders[_as](style, id, columns, visibleDataRows, firstRowMessage, stickyHeader, xss, virtuosoRef, tableHeadRows, stickyOffset)] }), void 0) }), void 0));
|
|
256
230
|
}
|
|
257
231
|
exports.GridTable = GridTable;
|
|
258
232
|
// Determine which HTML element to use to build the GridTable
|
|
@@ -262,42 +236,38 @@ const renders = {
|
|
|
262
236
|
virtual: renderVirtual,
|
|
263
237
|
};
|
|
264
238
|
/** Renders table using divs with flexbox rows, which is the default render */
|
|
265
|
-
function renderDiv(style, id, columns,
|
|
239
|
+
function renderDiv(style, id, columns, visibleDataRows, firstRowMessage, stickyHeader, xss, _virtuosoRef, tableHeadRows, stickyOffset) {
|
|
266
240
|
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ css: {
|
|
267
241
|
// Use `fit-content` to ensure the width of the table takes up the full width of its content.
|
|
268
242
|
// Otherwise, the table's width would be that of its container, which may not be as wide as the table itself.
|
|
269
243
|
// In cases where we have sticky columns on a very wide table, then the container which the columns "stick" to (which is the table),
|
|
270
244
|
// needs to be as wide as the table's content, or else we lose the "stickiness" once scrolling past width of the table's container.
|
|
271
245
|
...Css_1.Css.mw("fit-content").$,
|
|
272
|
-
/*
|
|
273
|
-
Using (n + 3) here to target all rows that are after the first non-header row. Since n starts at 0, we can use
|
|
274
|
-
the + operator as an offset.
|
|
275
|
-
Inspired by: https://stackoverflow.com/a/25005740/2551333
|
|
276
|
-
*/
|
|
277
|
-
...(style.betweenRowsCss
|
|
278
|
-
? Css_1.Css.addIn(`& > div:nth-of-type(n+${headerRows.length + totalsRows.length + 2}) > *`, style.betweenRowsCss).$
|
|
279
|
-
: {}),
|
|
280
|
-
...(style.firstNonHeaderRowCss ? Css_1.Css.addIn(`& > div:nth-of-type(2) > *`, style.firstNonHeaderRowCss).$ : {}),
|
|
281
|
-
...(style.lastRowCss && Css_1.Css.addIn("& > div:last-of-type", style.lastRowCss).$),
|
|
282
|
-
...(style.firstRowCss && Css_1.Css.addIn("& > div:first-of-type", style.firstRowCss).$),
|
|
283
246
|
...style.rootCss,
|
|
284
247
|
...(style.minWidthPx ? Css_1.Css.mwPx(style.minWidthPx).$ : {}),
|
|
285
248
|
...xss,
|
|
286
|
-
}, "data-testid": id }, { children: [
|
|
249
|
+
}, "data-testid": id }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ css: {
|
|
250
|
+
...(style.firstRowCss && Css_1.Css.addIn("& > div:first-of-type", style.firstRowCss).$),
|
|
251
|
+
...Css_1.Css.if(stickyHeader).sticky.topPx(stickyOffset).z(utils_1.zIndices.stickyHeader).$,
|
|
252
|
+
} }, { children: tableHeadRows.map(([, node]) => node) }), void 0), (0, jsx_runtime_1.jsxs)("div", Object.assign({ css: {
|
|
253
|
+
...(style.betweenRowsCss ? Css_1.Css.addIn(`& > div > *`, style.betweenRowsCss).$ : {}),
|
|
254
|
+
...(style.firstNonHeaderRowCss ? Css_1.Css.addIn(`& > div:first-of-type > *`, style.firstNonHeaderRowCss).$ : {}),
|
|
255
|
+
...(style.lastRowCss && Css_1.Css.addIn("& > div:last-of-type", style.lastRowCss).$),
|
|
256
|
+
} }, { children: [firstRowMessage && ((0, jsx_runtime_1.jsx)("div", Object.assign({ css: { ...style.firstRowMessageCss }, "data-gridrow": true }, { children: firstRowMessage }), void 0)), visibleDataRows.map(([, node]) => node)] }), void 0)] }), void 0));
|
|
287
257
|
}
|
|
288
258
|
/** Renders as a table, primarily/solely for good print support. */
|
|
289
|
-
function renderTable(style, id, columns,
|
|
259
|
+
function renderTable(style, id, columns, visibleDataRows, firstRowMessage, stickyHeader, xss, _virtuosoRef, tableHeadRows, stickyOffset) {
|
|
290
260
|
return ((0, jsx_runtime_1.jsxs)("table", Object.assign({ css: {
|
|
291
261
|
...Css_1.Css.w100.add("borderCollapse", "separate").add("borderSpacing", "0").$,
|
|
292
262
|
...Css_1.Css.addIn("& > tbody > tr > * ", style.betweenRowsCss || {})
|
|
293
263
|
// removes border between header and second row
|
|
294
264
|
.addIn("& > tbody > tr:first-of-type > *", style.firstNonHeaderRowCss || {}).$,
|
|
295
265
|
...Css_1.Css.addIn("& > tbody > tr:last-of-type", style.lastRowCss).$,
|
|
296
|
-
...Css_1.Css.addIn("& >
|
|
266
|
+
...Css_1.Css.addIn("& > thead > tr:first-of-type", style.firstRowCss).$,
|
|
297
267
|
...style.rootCss,
|
|
298
268
|
...(style.minWidthPx ? Css_1.Css.mwPx(style.minWidthPx).$ : {}),
|
|
299
269
|
...xss,
|
|
300
|
-
}, "data-testid": id }, { children: [(0, jsx_runtime_1.jsx)("thead", {
|
|
270
|
+
}, "data-testid": id }, { children: [(0, jsx_runtime_1.jsx)("thead", Object.assign({ css: Css_1.Css.if(stickyHeader).sticky.topPx(stickyOffset).z(utils_1.zIndices.stickyHeader).$ }, { children: tableHeadRows.map(([, node]) => node) }), void 0), (0, jsx_runtime_1.jsxs)("tbody", { children: [firstRowMessage && ((0, jsx_runtime_1.jsx)("tr", { children: (0, jsx_runtime_1.jsx)("td", Object.assign({ colSpan: columns.length, css: { ...style.firstRowMessageCss } }, { children: firstRowMessage }), void 0) }, void 0)), visibleDataRows.map(([, node]) => node)] }, void 0)] }), void 0));
|
|
301
271
|
}
|
|
302
272
|
/**
|
|
303
273
|
* Uses react-virtuoso to render rows virtually.
|
|
@@ -319,7 +289,7 @@ function renderTable(style, id, columns, headerRows, totalsRows, expandableHeade
|
|
|
319
289
|
* [2]: https://github.com/tannerlinsley/react-virtual/issues/85
|
|
320
290
|
* [3]: https://github.com/tannerlinsley/react-virtual/issues/108
|
|
321
291
|
*/
|
|
322
|
-
function renderVirtual(style, id, columns,
|
|
292
|
+
function renderVirtual(style, id, columns, visibleDataRows, firstRowMessage, stickyHeader, xss, virtuosoRef, tableHeadRows, _stickyOffset) {
|
|
323
293
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
324
294
|
const { footerStyle, listStyle } = (0, react_1.useMemo)(() => {
|
|
325
295
|
var _a;
|
|
@@ -333,28 +303,13 @@ function renderVirtual(style, id, columns, headerRows, totalsRows, expandableHea
|
|
|
333
303
|
Footer: () => (0, jsx_runtime_1.jsx)("div", { css: footerStyle }, void 0),
|
|
334
304
|
},
|
|
335
305
|
// Pin/sticky both the header row(s) + firstRowMessage to the top
|
|
336
|
-
topItemCount: (stickyHeader ?
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
// Determine if we need to render a totals row
|
|
341
|
-
if (index < totalsRows.length) {
|
|
342
|
-
return totalsRows[index][1];
|
|
306
|
+
topItemCount: (stickyHeader ? tableHeadRows.length : 0) + (firstRowMessage ? 1 : 0), itemContent: (index) => {
|
|
307
|
+
// Since we have 2 arrays of rows: `tableHeadRows`, and `filteredRow` we must determine which one to render.
|
|
308
|
+
if (index < tableHeadRows.length) {
|
|
309
|
+
return tableHeadRows[index][1];
|
|
343
310
|
}
|
|
344
311
|
// Reset index
|
|
345
|
-
index -=
|
|
346
|
-
// Determine if we need to render an expandableHeaderRows row
|
|
347
|
-
if (index < expandableHeaderRows.length) {
|
|
348
|
-
return expandableHeaderRows[index][1];
|
|
349
|
-
}
|
|
350
|
-
// Reset index
|
|
351
|
-
index -= expandableHeaderRows.length;
|
|
352
|
-
// Determine if we need to render a header row
|
|
353
|
-
if (index < headerRows.length) {
|
|
354
|
-
return headerRows[index][1];
|
|
355
|
-
}
|
|
356
|
-
// Reset index
|
|
357
|
-
index -= headerRows.length;
|
|
312
|
+
index -= tableHeadRows.length;
|
|
358
313
|
// Show firstRowMessage as the first `filteredRow`
|
|
359
314
|
if (firstRowMessage) {
|
|
360
315
|
if (index === 0) {
|
|
@@ -366,11 +321,7 @@ function renderVirtual(style, id, columns, headerRows, totalsRows, expandableHea
|
|
|
366
321
|
}
|
|
367
322
|
// Lastly render `filteredRow`
|
|
368
323
|
return visibleDataRows[index][1];
|
|
369
|
-
}, totalCount:
|
|
370
|
-
totalsRows.length +
|
|
371
|
-
expandableHeaderRows.length +
|
|
372
|
-
(firstRowMessage ? 1 : 0) +
|
|
373
|
-
visibleDataRows.length }, void 0));
|
|
324
|
+
}, totalCount: tableHeadRows.length + (firstRowMessage ? 1 : 0) + visibleDataRows.length }, void 0));
|
|
374
325
|
}
|
|
375
326
|
/**
|
|
376
327
|
* A table might render two of these components to represent two virtual lists.
|
|
@@ -33,7 +33,7 @@ const shallowEqual_1 = require("../../../utils/shallowEqual");
|
|
|
33
33
|
// We extract Row to its own mini-component primarily so we can React.memo'ize it.
|
|
34
34
|
function RowImpl(props) {
|
|
35
35
|
var _a;
|
|
36
|
-
const { as, columns, row, style, rowStyles,
|
|
36
|
+
const { as, columns, row, style, rowStyles, sortOn, columnSizes, level, getCount, api, cellHighlight, omitRowHover, hasExpandableHeader, ...others } = props;
|
|
37
37
|
const { tableState } = (0, react_1.useContext)(TableState_1.TableStateContext);
|
|
38
38
|
const rowId = `${row.kind}_${row.id}`;
|
|
39
39
|
const isActive = (0, hooks_1.useComputed)(() => tableState.activeRowId === rowId, [rowId, tableState]);
|
|
@@ -57,10 +57,6 @@ function RowImpl(props) {
|
|
|
57
57
|
// Apply `cursorPointer` to the row if it has a link or `onClick` value.
|
|
58
58
|
...(((rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.rowLink) || (rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.onClick)) && { "&:hover": Css_1.Css.cursorPointer.$ }),
|
|
59
59
|
...(0, utils_1.maybeApplyFunction)(row, rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.rowCss),
|
|
60
|
-
// Maybe add the sticky header styles
|
|
61
|
-
...(utils_1.reservedRowKinds.includes(row.kind) && stickyHeader
|
|
62
|
-
? Css_1.Css.sticky.topPx(stickyOffset).z(utils_1.zIndices.stickyHeader).$
|
|
63
|
-
: undefined),
|
|
64
60
|
...{
|
|
65
61
|
[` > .${revealOnRowHoverClass} > *`]: Css_1.Css.invisible.$,
|
|
66
62
|
[`:hover > .${revealOnRowHoverClass} > *`]: Css_1.Css.visible.$,
|