@homebound/beam 2.92.0 → 2.93.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.
|
@@ -152,7 +152,13 @@ export interface GridTableProps<R extends Kinded, S, X> {
|
|
|
152
152
|
*/
|
|
153
153
|
persistCollapse?: string;
|
|
154
154
|
xss?: X;
|
|
155
|
+
/** Experimental API allowing one to scroll to a table index. Primarily intended for stories at the moment */
|
|
156
|
+
api?: MutableRefObject<GridTableApi | undefined>;
|
|
155
157
|
}
|
|
158
|
+
/** NOTE: This API is experimental and primarily intended for story and testing purposes */
|
|
159
|
+
export declare type GridTableApi = {
|
|
160
|
+
scrollToIndex: (index: number) => void;
|
|
161
|
+
};
|
|
156
162
|
/**
|
|
157
163
|
* Renders data in our table layout.
|
|
158
164
|
*
|
|
@@ -82,10 +82,15 @@ exports.setGridTableDefaults = setGridTableDefaults;
|
|
|
82
82
|
*/
|
|
83
83
|
function GridTable(props) {
|
|
84
84
|
var _a;
|
|
85
|
-
const { id = "grid-table", 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, } = props;
|
|
85
|
+
const { id = "grid-table", 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;
|
|
86
86
|
const [collapsedIds, toggleCollapsedId] = useToggleIds(rows, persistCollapse);
|
|
87
87
|
// We only use this in as=virtual mode, but keep this here for rowLookup to use
|
|
88
88
|
const virtuosoRef = (0, react_1.useRef)(null);
|
|
89
|
+
if (api) {
|
|
90
|
+
api.current = {
|
|
91
|
+
scrollToIndex: (index) => virtuosoRef.current && virtuosoRef.current.scrollToIndex(index),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
89
94
|
const [sortState, setSortKey] = (0, useSortState_1.useSortState)(columns, sorting);
|
|
90
95
|
// Disclaimer that technically even though this is a useMemo, sortRows is mutating `rows` directly
|
|
91
96
|
const maybeSorted = (0, react_1.useMemo)(() => {
|
|
@@ -258,7 +263,12 @@ function renderTable(style, id, columns, headerRows, filteredRows, firstRowMessa
|
|
|
258
263
|
* [3]: https://github.com/tannerlinsley/react-virtual/issues/108
|
|
259
264
|
*/
|
|
260
265
|
function renderVirtual(style, id, columns, headerRows, filteredRows, firstRowMessage, stickyHeader, firstLastColumnWidth, xss, virtuosoRef) {
|
|
261
|
-
|
|
266
|
+
var _a;
|
|
267
|
+
const { paddingBottom } = (_a = style.rootCss) !== null && _a !== void 0 ? _a : {};
|
|
268
|
+
return ((0, jsx_runtime_1.jsx)(react_virtuoso_1.Virtuoso, { ref: virtuosoRef, components: {
|
|
269
|
+
List: VirtualRoot(style, columns, id, firstLastColumnWidth, xss),
|
|
270
|
+
Footer: () => (0, jsx_runtime_1.jsx)("div", { css: { paddingBottom } }, void 0),
|
|
271
|
+
},
|
|
262
272
|
// Pin/sticky both the header row(s) + firstRowMessage to the top
|
|
263
273
|
topItemCount: (stickyHeader ? headerRows.length : 0) + (firstRowMessage ? 1 : 0), itemSize: (el) => {
|
|
264
274
|
const maybeContentsDiv = el.firstElementChild;
|