@homebound/beam 2.209.0 → 2.209.1
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.
|
@@ -104,6 +104,11 @@ export interface GridTableProps<R extends Kinded, X> {
|
|
|
104
104
|
* Expected format is `${row.kind}_${row.id}_${column.id}`.
|
|
105
105
|
*/
|
|
106
106
|
activeCellId?: string;
|
|
107
|
+
/**
|
|
108
|
+
* Defines the session storage key for which columns are visible. If not provided, a default storage key will be used based on column order and/or `GridColumn.id`
|
|
109
|
+
* This is beneficial when looking at the same table, but of a different subject (i.e. Project A's PreCon Schedule vs Project A's Construction schedule)
|
|
110
|
+
*/
|
|
111
|
+
visibleColumnsStorageKey?: string;
|
|
107
112
|
}
|
|
108
113
|
/**
|
|
109
114
|
* Renders data in our table layout.
|
|
@@ -79,7 +79,7 @@ exports.setGridTableDefaults = setGridTableDefaults;
|
|
|
79
79
|
*/
|
|
80
80
|
function GridTable(props) {
|
|
81
81
|
var _a, _b, _c;
|
|
82
|
-
const { id = "gridTable", as = "div", columns: _columns, rows, style: maybeStyle = defaults.style, rowStyles, stickyHeader = defaults.stickyHeader, stickyOffset = 0, xss, filter, filterMaxRows, fallbackMessage = "No rows found.", infoMessage, setRowCount, persistCollapse, resizeTarget, activeRowId, activeCellId, } = props;
|
|
82
|
+
const { id = "gridTable", as = "div", columns: _columns, rows, style: maybeStyle = defaults.style, rowStyles, stickyHeader = defaults.stickyHeader, stickyOffset = 0, xss, filter, filterMaxRows, fallbackMessage = "No rows found.", infoMessage, setRowCount, persistCollapse, resizeTarget, activeRowId, activeCellId, visibleColumnsStorageKey, } = props;
|
|
83
83
|
const columnsWithIds = (0, react_1.useMemo)(() => (0, columns_1.assignDefaultColumnIds)(_columns), [_columns]);
|
|
84
84
|
// We only use this in as=virtual mode, but keep this here for rowLookup to use
|
|
85
85
|
const virtuosoRef = (0, react_1.useRef)(null);
|
|
@@ -96,7 +96,7 @@ function GridTable(props) {
|
|
|
96
96
|
const style = (0, TableStyles_1.resolveStyles)(maybeStyle);
|
|
97
97
|
const { tableState } = api;
|
|
98
98
|
tableState.setRows(rows);
|
|
99
|
-
tableState.setColumns(columnsWithIds);
|
|
99
|
+
tableState.setColumns(columnsWithIds, visibleColumnsStorageKey);
|
|
100
100
|
const columns = (0, hooks_1.useComputed)(() => tableState.columns
|
|
101
101
|
.filter((c) => tableState.visibleColumnIds.includes(c.id))
|
|
102
102
|
.flatMap((c) => c.expandColumns && tableState.expandedColumnIds.includes(c.id) ? [c, ...c.expandColumns] : [c]), [tableState]);
|
|
@@ -34,7 +34,7 @@ export declare class TableState {
|
|
|
34
34
|
columns: GridColumnWithId<any>[];
|
|
35
35
|
private expandedColumns;
|
|
36
36
|
visibleColumns: ObservableSet<string>;
|
|
37
|
-
private
|
|
37
|
+
private visibleColumnsStorageKey;
|
|
38
38
|
/**
|
|
39
39
|
* Creates the `RowState` for a given `GridTable`.
|
|
40
40
|
*/
|
|
@@ -45,7 +45,7 @@ export declare class TableState {
|
|
|
45
45
|
setSortKey(clickedColumnId: string): void;
|
|
46
46
|
get sortState(): SortState | undefined;
|
|
47
47
|
setRows(rows: GridDataRow<any>[]): void;
|
|
48
|
-
setColumns(columns: GridColumnWithId<any>[]): void;
|
|
48
|
+
setColumns(columns: GridColumnWithId<any>[], visibleColumnsStorageKey: string | undefined): void;
|
|
49
49
|
setVisibleColumns(ids: string[]): void;
|
|
50
50
|
get visibleColumnIds(): string[];
|
|
51
51
|
get expandedColumnIds(): string[];
|
|
@@ -48,7 +48,7 @@ class TableState {
|
|
|
48
48
|
this.expandedColumns = new mobx_1.ObservableSet();
|
|
49
49
|
// An observable set of column ids to keep track of which columns are visible
|
|
50
50
|
this.visibleColumns = new mobx_1.ObservableSet();
|
|
51
|
-
this.
|
|
51
|
+
this.visibleColumnsStorageKey = "";
|
|
52
52
|
// Make ourselves an observable so that mobx will do caching of .collapseIds so
|
|
53
53
|
// that it'll be a stable identity for GridTable to useMemo against.
|
|
54
54
|
(0, mobx_1.makeAutoObservable)(this, {
|
|
@@ -176,17 +176,17 @@ class TableState {
|
|
|
176
176
|
// Finally replace our existing list of rows
|
|
177
177
|
this.rows = rows;
|
|
178
178
|
}
|
|
179
|
-
setColumns(columns) {
|
|
179
|
+
setColumns(columns, visibleColumnsStorageKey) {
|
|
180
180
|
if (columns !== this.columns) {
|
|
181
181
|
this.columns = columns;
|
|
182
|
-
this.
|
|
183
|
-
this.visibleColumns.replace(readOrSetLocalVisibleColumnState(columns, this.
|
|
182
|
+
this.visibleColumnsStorageKey = visibleColumnsStorageKey !== null && visibleColumnsStorageKey !== void 0 ? visibleColumnsStorageKey : (0, change_case_1.camelCase)(columns.map((c) => c.id).join());
|
|
183
|
+
this.visibleColumns.replace(readOrSetLocalVisibleColumnState(columns, this.visibleColumnsStorageKey));
|
|
184
184
|
const expandedColumnIds = columns.filter((c) => c.initExpanded).map((c) => c.id);
|
|
185
185
|
this.expandedColumns.replace(expandedColumnIds);
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
188
|
setVisibleColumns(ids) {
|
|
189
|
-
sessionStorage.setItem(this.
|
|
189
|
+
sessionStorage.setItem(this.visibleColumnsStorageKey, JSON.stringify(ids));
|
|
190
190
|
this.visibleColumns.replace(ids);
|
|
191
191
|
}
|
|
192
192
|
get visibleColumnIds() {
|