@homebound/beam 2.127.0 → 2.128.2
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 +3 -1
- package/dist/components/Table/GridTable.js +35 -17
- package/dist/components/Table/RowState.js +8 -2
- package/dist/components/Table/styles.d.ts +0 -1
- package/dist/components/Table/styles.js +5 -4
- package/dist/hooks/useComputed.js +1 -1
- package/dist/inputs/Switch.js +3 -4
- package/package.json +1 -1
|
@@ -33,6 +33,8 @@ export interface GridStyle {
|
|
|
33
33
|
* rows are wrapper with Chrome rows.
|
|
34
34
|
*/
|
|
35
35
|
headerCellCss?: Properties;
|
|
36
|
+
/** Applied to 'kind: "totals"' cells */
|
|
37
|
+
totalsCellCss?: Properties;
|
|
36
38
|
/** Applied to the first cell of all rows, i.e. for table-wide padding or left-side borders. */
|
|
37
39
|
firstCellCss?: Properties;
|
|
38
40
|
/** Applied to the last cell of all rows, i.e. for table-wide padding or right-side borders. */
|
|
@@ -151,7 +153,7 @@ export interface GridTableProps<R extends Kinded, S, X> {
|
|
|
151
153
|
rowLookup?: MutableRefObject<GridRowLookup<R> | undefined>;
|
|
152
154
|
/** Whether the header row should be sticky. */
|
|
153
155
|
stickyHeader?: boolean;
|
|
154
|
-
stickyOffset?:
|
|
156
|
+
stickyOffset?: number;
|
|
155
157
|
/** Configures sorting via a hash, does not need to be stable. */
|
|
156
158
|
sorting?: GridSortConfig<S>;
|
|
157
159
|
/** Shown in the first row slot, if there are no rows to show, i.e. 'No rows found'. */
|
|
@@ -88,7 +88,7 @@ exports.setGridTableDefaults = setGridTableDefaults;
|
|
|
88
88
|
*/
|
|
89
89
|
function GridTable(props) {
|
|
90
90
|
var _a, _b, _c, _d;
|
|
91
|
-
const { id = "gridTable", as = "div", columns, rows, style: maybeStyle = defaults.style, rowStyles, stickyHeader = defaults.stickyHeader, stickyOffset =
|
|
91
|
+
const { id = "gridTable", as = "div", columns, rows, style: maybeStyle = defaults.style, rowStyles, stickyHeader = defaults.stickyHeader, stickyOffset = 0, xss, filter, filterMaxRows, fallbackMessage = "No rows found.", infoMessage, setRowCount, observeRows, persistCollapse, resizeTarget, activeRowId, } = props;
|
|
92
92
|
// We only use this in as=virtual mode, but keep this here for rowLookup to use
|
|
93
93
|
const virtuosoRef = (0, react_1.useRef)(null);
|
|
94
94
|
const tableRef = (0, react_1.useRef)(null);
|
|
@@ -121,15 +121,18 @@ function GridTable(props) {
|
|
|
121
121
|
}
|
|
122
122
|
return rows;
|
|
123
123
|
}, [columns, rows, sortOn, sortState]);
|
|
124
|
+
let hasTotalsRow = false;
|
|
124
125
|
// Filter rows - ensures parent rows remain in the list if any children match the filter.
|
|
125
126
|
const filterRows = (0, react_1.useCallback)((acc, row) => {
|
|
126
127
|
var _a, _b, _c;
|
|
127
128
|
// Break up "foo bar" into `[foo, bar]` and a row must match both `foo` and `bar`
|
|
128
129
|
const filters = (filter && filter.split(/ +/)) || [];
|
|
129
130
|
const matches = row.kind === "header" ||
|
|
131
|
+
row.kind === "totals" ||
|
|
130
132
|
filters.length === 0 ||
|
|
131
133
|
!!row.pin ||
|
|
132
134
|
filters.every((f) => columns.map((c) => applyRowFn(c, row, api, 0)).some((maybeContent) => matchesFilter(maybeContent, f)));
|
|
135
|
+
hasTotalsRow || (hasTotalsRow = row.kind === "totals");
|
|
133
136
|
// If the row matches, add it in
|
|
134
137
|
if (matches) {
|
|
135
138
|
return acc.concat([[row, (_b = (_a = row.children) === null || _a === void 0 ? void 0 : _a.reduce(filterRows, [])) !== null && _b !== void 0 ? _b : []]]);
|
|
@@ -148,7 +151,7 @@ function GridTable(props) {
|
|
|
148
151
|
return acc;
|
|
149
152
|
}, [filter, collapsedIds, columns]);
|
|
150
153
|
// Flatten + component-ize the sorted rows.
|
|
151
|
-
let [headerRows, filteredRows] = (0, react_1.useMemo)(() => {
|
|
154
|
+
let [headerRows, filteredRows, totalsRows] = (0, react_1.useMemo)(() => {
|
|
152
155
|
function makeRowComponent(row, level) {
|
|
153
156
|
// We only pass sortState to header rows, b/c non-headers rows shouldn't have to re-render on sorting
|
|
154
157
|
// changes, and so by not passing the sortProps, it means the data rows' React.memo will still cache them.
|
|
@@ -161,7 +164,8 @@ function GridTable(props) {
|
|
|
161
164
|
style,
|
|
162
165
|
rowStyles,
|
|
163
166
|
stickyHeader,
|
|
164
|
-
stickyOffset
|
|
167
|
+
// If we have a totals row then add the height of the totals row (52px) to the `stickyOffset` for the "header" kind
|
|
168
|
+
stickyOffset: hasTotalsRow && row.kind === "header" ? 52 + stickyOffset : stickyOffset,
|
|
165
169
|
openCards: nestedCards ? nestedCards.currentOpenCards() : undefined,
|
|
166
170
|
columnSizes,
|
|
167
171
|
level,
|
|
@@ -172,6 +176,7 @@ function GridTable(props) {
|
|
|
172
176
|
}
|
|
173
177
|
// Split out the header rows from the data rows so that we can put an `infoMessage` in between them (if needed).
|
|
174
178
|
const headerRows = [];
|
|
179
|
+
const totalsRows = [];
|
|
175
180
|
const filteredRows = [];
|
|
176
181
|
// Misc state to track our nested card-ification, i.e. interleaved actual rows + chrome rows
|
|
177
182
|
const nestedCards = !!style.nestedCards && new nestedCards_1.NestedCards(columns, filteredRows, style.nestedCards);
|
|
@@ -192,6 +197,10 @@ function GridTable(props) {
|
|
|
192
197
|
headerRows.push([row[0], makeRowComponent(row[0], level)]);
|
|
193
198
|
return;
|
|
194
199
|
}
|
|
200
|
+
if (row[0].kind === "totals") {
|
|
201
|
+
totalsRows.push([row[0], makeRowComponent(row[0], level)]);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
195
204
|
visit(row, level);
|
|
196
205
|
addSpacer && nestedCards && i !== length - 1 && nestedCards.addSpacer();
|
|
197
206
|
});
|
|
@@ -200,7 +209,7 @@ function GridTable(props) {
|
|
|
200
209
|
// If nestedCards is set, we assume the top-level kind is a card, and so should add spacers between them
|
|
201
210
|
visitRows(maybeSorted.reduce(filterRows, []), !!nestedCards, 0);
|
|
202
211
|
nestedCards && nestedCards.done();
|
|
203
|
-
return [headerRows, filteredRows];
|
|
212
|
+
return [headerRows, filteredRows, totalsRows];
|
|
204
213
|
}, [
|
|
205
214
|
as,
|
|
206
215
|
maybeSorted,
|
|
@@ -252,7 +261,7 @@ function GridTable(props) {
|
|
|
252
261
|
// behave semantically the same as `as=div` did for its tests.
|
|
253
262
|
const _as = as === "virtual" && runningInJest ? "div" : as;
|
|
254
263
|
const rowStateContext = (0, react_1.useMemo)(() => ({ rowState }), [rowState]);
|
|
255
|
-
return ((0, jsx_runtime_1.jsx)(RowState_1.RowStateContext.Provider, Object.assign({ value: rowStateContext }, { children: (0, jsx_runtime_1.jsx)(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: renders[_as](style, id, columns, headerRows, filteredRows, firstRowMessage, stickyHeader, (_d = style.nestedCards) === null || _d === void 0 ? void 0 : _d.firstLastColumnWidth, xss, virtuosoRef, tableRef) }), void 0) }), void 0));
|
|
264
|
+
return ((0, jsx_runtime_1.jsx)(RowState_1.RowStateContext.Provider, Object.assign({ value: rowStateContext }, { children: (0, jsx_runtime_1.jsx)(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: renders[_as](style, id, columns, headerRows, totalsRows, filteredRows, firstRowMessage, stickyHeader, (_d = style.nestedCards) === null || _d === void 0 ? void 0 : _d.firstLastColumnWidth, xss, virtuosoRef, tableRef) }), void 0) }), void 0));
|
|
256
265
|
}
|
|
257
266
|
exports.GridTable = GridTable;
|
|
258
267
|
// Determine which HTML element to use to build the GridTable
|
|
@@ -262,7 +271,7 @@ const renders = {
|
|
|
262
271
|
virtual: renderVirtual,
|
|
263
272
|
};
|
|
264
273
|
/** Renders table using divs with flexbox rows, which is the default render */
|
|
265
|
-
function renderDiv(style, id, columns, headerRows, filteredRows, firstRowMessage, _stickyHeader, firstLastColumnWidth, xss, _virtuosoRef, tableRef) {
|
|
274
|
+
function renderDiv(style, id, columns, headerRows, totalsRows, filteredRows, firstRowMessage, _stickyHeader, firstLastColumnWidth, xss, _virtuosoRef, tableRef) {
|
|
266
275
|
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ ref: tableRef, css: {
|
|
267
276
|
/*
|
|
268
277
|
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,10 +283,10 @@ function renderDiv(style, id, columns, headerRows, filteredRows, firstRowMessage
|
|
|
274
283
|
...style.rootCss,
|
|
275
284
|
...(style.minWidthPx ? Css_1.Css.mwPx(style.minWidthPx).$ : {}),
|
|
276
285
|
...xss,
|
|
277
|
-
}, "data-testid": id }, { children: [headerRows.map(([, node]) => node), firstRowMessage && ((0, jsx_runtime_1.jsx)("div", Object.assign({ css: { ...style.firstRowMessageCss }, "data-gridrow": true }, { children: firstRowMessage }), void 0)), filteredRows.map(([, node]) => node)] }), void 0));
|
|
286
|
+
}, "data-testid": id }, { children: [totalsRows.map(([, node]) => node), headerRows.map(([, node]) => node), firstRowMessage && ((0, jsx_runtime_1.jsx)("div", Object.assign({ css: { ...style.firstRowMessageCss }, "data-gridrow": true }, { children: firstRowMessage }), void 0)), filteredRows.map(([, node]) => node)] }), void 0));
|
|
278
287
|
}
|
|
279
288
|
/** Renders as a table, primarily/solely for good print support. */
|
|
280
|
-
function renderTable(style, id, columns, headerRows, filteredRows, firstRowMessage, _stickyHeader, _firstLastColumnWidth, xss, _virtuosoRef, tableRef) {
|
|
289
|
+
function renderTable(style, id, columns, headerRows, totalsRows, filteredRows, firstRowMessage, _stickyHeader, _firstLastColumnWidth, xss, _virtuosoRef, tableRef) {
|
|
281
290
|
return ((0, jsx_runtime_1.jsxs)("table", Object.assign({ ref: tableRef, css: {
|
|
282
291
|
...Css_1.Css.w100.add("borderCollapse", "collapse").$,
|
|
283
292
|
...Css_1.Css.addIn("& > tbody > tr ", style.betweenRowsCss || {})
|
|
@@ -286,7 +295,7 @@ function renderTable(style, id, columns, headerRows, filteredRows, firstRowMessa
|
|
|
286
295
|
...style.rootCss,
|
|
287
296
|
...(style.minWidthPx ? Css_1.Css.mwPx(style.minWidthPx).$ : {}),
|
|
288
297
|
...xss,
|
|
289
|
-
}, "data-testid": id }, { children: [(0, jsx_runtime_1.jsx)("thead", { children: headerRows.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)), filteredRows.map(([, node]) => node)] }, void 0)] }), void 0));
|
|
298
|
+
}, "data-testid": id }, { children: [(0, jsx_runtime_1.jsx)("thead", { children: [...totalsRows, ...headerRows].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)), filteredRows.map(([, node]) => node)] }, void 0)] }), void 0));
|
|
290
299
|
}
|
|
291
300
|
/**
|
|
292
301
|
* Uses react-virtuoso to render rows virtually.
|
|
@@ -308,7 +317,7 @@ function renderTable(style, id, columns, headerRows, filteredRows, firstRowMessa
|
|
|
308
317
|
* [2]: https://github.com/tannerlinsley/react-virtual/issues/85
|
|
309
318
|
* [3]: https://github.com/tannerlinsley/react-virtual/issues/108
|
|
310
319
|
*/
|
|
311
|
-
function renderVirtual(style, id, columns, headerRows, filteredRows, firstRowMessage, stickyHeader, firstLastColumnWidth, xss, virtuosoRef, tableRef) {
|
|
320
|
+
function renderVirtual(style, id, columns, headerRows, totalsRows, filteredRows, firstRowMessage, stickyHeader, firstLastColumnWidth, xss, virtuosoRef, tableRef) {
|
|
312
321
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
313
322
|
const { footerStyle, listStyle } = (0, react_1.useMemo)(() => {
|
|
314
323
|
var _a;
|
|
@@ -327,9 +336,15 @@ function renderVirtual(style, id, columns, headerRows, filteredRows, firstRowMes
|
|
|
327
336
|
Footer: () => (0, jsx_runtime_1.jsx)("div", { css: footerStyle }, void 0),
|
|
328
337
|
},
|
|
329
338
|
// Pin/sticky both the header row(s) + firstRowMessage to the top
|
|
330
|
-
topItemCount: (stickyHeader ? headerRows.length : 0) + (firstRowMessage ? 1 : 0), itemContent: (index) => {
|
|
331
|
-
// Since we have
|
|
339
|
+
topItemCount: (stickyHeader ? headerRows.length + totalsRows.length : 0) + (firstRowMessage ? 1 : 0), itemContent: (index) => {
|
|
340
|
+
// Since we have three arrays of rows: `headerRows`, `totalsRows`, and `filteredRow` we
|
|
332
341
|
// must determine which one to render.
|
|
342
|
+
// Determine if we need to render a totals row
|
|
343
|
+
if (index < totalsRows.length) {
|
|
344
|
+
return totalsRows[index][1];
|
|
345
|
+
}
|
|
346
|
+
// Reset index
|
|
347
|
+
index -= totalsRows.length;
|
|
333
348
|
// Determine if we need to render a header row
|
|
334
349
|
if (index < headerRows.length) {
|
|
335
350
|
return headerRows[index][1];
|
|
@@ -347,7 +362,7 @@ function renderVirtual(style, id, columns, headerRows, filteredRows, firstRowMes
|
|
|
347
362
|
}
|
|
348
363
|
// Lastly render `filteredRow`
|
|
349
364
|
return filteredRows[index][1];
|
|
350
|
-
}, totalCount: (headerRows.length || 0) + (firstRowMessage ? 1 : 0) + (filteredRows.length || 0) }, void 0));
|
|
365
|
+
}, totalCount: (headerRows.length || 0) + (totalsRows.length || 0) + (firstRowMessage ? 1 : 0) + (filteredRows.length || 0) }, void 0));
|
|
351
366
|
}
|
|
352
367
|
/**
|
|
353
368
|
* A table might render two of these components to represent two virtual lists.
|
|
@@ -473,8 +488,9 @@ function GridRow(props) {
|
|
|
473
488
|
const { as, columns, row, style, rowStyles, stickyHeader, stickyOffset, sortOn, sortState, setSortKey, openCards, columnSizes, level, getCount, api, ...others } = props;
|
|
474
489
|
const { rowState } = (0, react_1.useContext)(RowState_1.RowStateContext);
|
|
475
490
|
const isActive = (0, hooks_1.useComputed)(() => rowState.activeRowId === `${row.kind}_${row.id}`, [row, rowState]);
|
|
476
|
-
// We treat the "header" kind as special for "good defaults" styling
|
|
491
|
+
// We treat the "header" and "totals" kind as special for "good defaults" styling
|
|
477
492
|
const isHeader = row.kind === "header";
|
|
493
|
+
const isTotals = row.kind === "totals";
|
|
478
494
|
const rowStyle = rowStyles === null || rowStyles === void 0 ? void 0 : rowStyles[row.kind];
|
|
479
495
|
const Row = as === "table" ? "tr" : "div";
|
|
480
496
|
const openCardStyles = typeof openCards === "string"
|
|
@@ -493,7 +509,7 @@ function GridRow(props) {
|
|
|
493
509
|
}),
|
|
494
510
|
...maybeApplyFunction(row, rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.rowCss),
|
|
495
511
|
// Maybe add the sticky header styles
|
|
496
|
-
...(isHeader && stickyHeader ? Css_1.Css.sticky.
|
|
512
|
+
...((isHeader || isTotals) && stickyHeader ? Css_1.Css.sticky.topPx(stickyOffset).z2.$ : undefined),
|
|
497
513
|
...(0, nestedCards_1.getNestedCardStyles)(row, openCardStyles, style, isActive),
|
|
498
514
|
};
|
|
499
515
|
let currentColspan = 1;
|
|
@@ -567,8 +583,10 @@ function GridRow(props) {
|
|
|
567
583
|
...getIndentationCss(style, rowStyle, columnIndex, maybeContent),
|
|
568
584
|
// Then apply any header-specific override
|
|
569
585
|
...(isHeader && style.headerCellCss),
|
|
586
|
+
// Then apply any totals-specific override
|
|
587
|
+
...(isTotals && style.totalsCellCss),
|
|
570
588
|
// Or level-specific styling
|
|
571
|
-
...(!isHeader && !!style.levels && ((_d = style.levels[level]) === null || _d === void 0 ? void 0 : _d.cellCss)),
|
|
589
|
+
...(!isHeader && !isTotals && !!style.levels && ((_d = style.levels[level]) === null || _d === void 0 ? void 0 : _d.cellCss)),
|
|
572
590
|
// Level specific styling for the first content column
|
|
573
591
|
...(applyFirstContentColumnStyles && !!style.levels && ((_e = style.levels[level]) === null || _e === void 0 ? void 0 : _e.firstContentColumn)),
|
|
574
592
|
// The specific cell's css (if any from GridCellContent)
|
|
@@ -770,7 +788,7 @@ function tableRowStyles(as, column) {
|
|
|
770
788
|
: {};
|
|
771
789
|
}
|
|
772
790
|
function resolveStyles(style) {
|
|
773
|
-
const defKeys = ["inlineEditing", "grouped", "
|
|
791
|
+
const defKeys = ["inlineEditing", "grouped", "rowHeight"];
|
|
774
792
|
const keys = (0, utils_1.safeKeys)(style);
|
|
775
793
|
if (keys.length === 0 || keys.some((k) => defKeys.includes(k))) {
|
|
776
794
|
return (0, styles_1.getTableStyles)(style);
|
|
@@ -38,7 +38,13 @@ class RowState {
|
|
|
38
38
|
this.activeRowId = undefined;
|
|
39
39
|
// Make ourselves an observable so that mobx will do caching of .collapseIds so
|
|
40
40
|
// that it'll be a stable identity for GridTable to useMemo against.
|
|
41
|
-
(0, mobx_1.makeAutoObservable)(this,
|
|
41
|
+
(0, mobx_1.makeAutoObservable)(this,
|
|
42
|
+
// We only shallow observe rows so that:
|
|
43
|
+
// a) we don't deeply/needlessly proxy-ize a large Apollo fragment cache, but
|
|
44
|
+
// b) if rows changes, we re-run computeds like getSelectedRows that may need to see the
|
|
45
|
+
// updated _contents_ of a given row, even if our other selected/visible row states don't change.
|
|
46
|
+
// (as any b/c rows is private, so the mapped type doesn't see it)
|
|
47
|
+
{ rows: mobx_1.observable.shallow });
|
|
42
48
|
// Whenever our `visibleRows` change (i.e. via filtering) then we need to re-derive header and parent rows' selected state.
|
|
43
49
|
(0, mobx_1.reaction)(() => [...this.visibleRows.values()].sort(), () => {
|
|
44
50
|
const map = new Map();
|
|
@@ -85,7 +91,7 @@ class RowState {
|
|
|
85
91
|
// Just mash the header + all rows + children as selected
|
|
86
92
|
const map = new Map();
|
|
87
93
|
map.set("header", "checked");
|
|
88
|
-
(0, visitor_1.visit)(this.rows, (row) => this.visibleRows.has(row.id) && map.set(row.id, "checked"));
|
|
94
|
+
(0, visitor_1.visit)(this.rows, (row) => this.visibleRows.has(row.id) && row.kind !== "totals" && map.set(row.id, "checked"));
|
|
89
95
|
this.selectedRows.replace(map);
|
|
90
96
|
}
|
|
91
97
|
else {
|
|
@@ -5,6 +5,7 @@ const Css_1 = require("../../Css");
|
|
|
5
5
|
/** Our original table look & feel/style. */
|
|
6
6
|
exports.defaultStyle = {
|
|
7
7
|
rootCss: Css_1.Css.gray700.$,
|
|
8
|
+
totalsCellCss: Css_1.Css.bgWhite.$,
|
|
8
9
|
betweenRowsCss: Css_1.Css.bt.bGray400.$,
|
|
9
10
|
firstNonHeaderRowCss: Css_1.Css.add({ borderTopStyle: "none" }).$,
|
|
10
11
|
cellCss: Css_1.Css.py2.px3.$,
|
|
@@ -42,8 +43,8 @@ exports.cardStyle = {
|
|
|
42
43
|
function memoizedTableStyles() {
|
|
43
44
|
const cache = {};
|
|
44
45
|
return (props) => {
|
|
45
|
-
const { inlineEditing = false, grouped = false, rowHeight = "flexible"
|
|
46
|
-
const key = `${inlineEditing}|${grouped}|${rowHeight}
|
|
46
|
+
const { inlineEditing = false, grouped = false, rowHeight = "flexible" } = props || {};
|
|
47
|
+
const key = `${inlineEditing}|${grouped}|${rowHeight}`;
|
|
47
48
|
if (!cache[key]) {
|
|
48
49
|
const groupedLevels = {
|
|
49
50
|
0: {
|
|
@@ -57,13 +58,13 @@ function memoizedTableStyles() {
|
|
|
57
58
|
emptyCell: "-",
|
|
58
59
|
firstRowMessageCss: Css_1.Css.tc.py3.$,
|
|
59
60
|
headerCellCss: Css_1.Css.gray700.xsEm.bgGray200.aic.nowrap.pxPx(12).hPx(40).$,
|
|
61
|
+
totalsCellCss: Css_1.Css.bgWhite.gray700.smEm.hPx(52).pt0.pbPx(12).boxShadow("none").$,
|
|
60
62
|
cellCss: {
|
|
61
63
|
...Css_1.Css.gray900.xs.bgWhite.aic.pxPx(12).boxShadow(`inset 0 -1px 0 ${Css_1.Palette.Gray200}`).$,
|
|
62
64
|
...(rowHeight === "flexible" ? Css_1.Css.py2.$ : Css_1.Css.nowrap.hPx(inlineEditing ? 48 : 36).$),
|
|
63
|
-
...(totals ? Css_1.Css.gray700.smEm.hPx(40).mb1.bgWhite.boxShadow("none").$ : {}),
|
|
64
65
|
},
|
|
65
66
|
presentationSettings: { borderless: true, typeScale: "xs", wrap: rowHeight === "flexible" },
|
|
66
|
-
levels:
|
|
67
|
+
levels: grouped ? groupedLevels : defaultLevels,
|
|
67
68
|
};
|
|
68
69
|
}
|
|
69
70
|
return cache[key];
|
|
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.useComputed = void 0;
|
|
7
|
+
const fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
|
|
7
8
|
const mobx_1 = require("mobx");
|
|
8
9
|
const react_1 = require("react");
|
|
9
|
-
const fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
|
|
10
10
|
/** Evaluates a computed function `fn` to a regular value and triggers a re-render whenever it changes. */
|
|
11
11
|
function useComputed(fn, deps) {
|
|
12
12
|
// We always return the useRef value, and use this just to trigger re-renders
|
package/dist/inputs/Switch.js
CHANGED
|
@@ -29,7 +29,7 @@ function Switch(props) {
|
|
|
29
29
|
...(labelStyle === "filter" && Css_1.Css.jcsb.aic.w("auto").sm.$),
|
|
30
30
|
...(isDisabled && Css_1.Css.cursorNotAllowed.gray400.$),
|
|
31
31
|
}, "aria-label": label }, { children: [!hideLabel && labelStyle === "form" && (0, jsx_runtime_1.jsx)(Label_1.Label, { label: label }, void 0), !hideLabel && labelStyle === "filter" && (0, jsx_runtime_1.jsx)("span", { children: label }, void 0), (0, jsx_runtime_1.jsx)("div", Object.assign({ "aria-hidden": "true", css: {
|
|
32
|
-
...Css_1.Css.wPx(
|
|
32
|
+
...Css_1.Css.wPx(40).hPx(toggleHeight(compact)).bgGray200.br12.relative.transition.$,
|
|
33
33
|
...(isHovered && exports.switchHoverStyles),
|
|
34
34
|
...(isKeyboardFocus && exports.switchFocusStyles),
|
|
35
35
|
...(isDisabled && Css_1.Css.bgGray300.$),
|
|
@@ -49,8 +49,7 @@ exports.Switch = Switch;
|
|
|
49
49
|
/** Styles */
|
|
50
50
|
// Element sizes
|
|
51
51
|
const toggleHeight = (isCompact) => (isCompact ? 16 : 24);
|
|
52
|
-
const
|
|
53
|
-
const circleDiameter = (isCompact) => (isCompact ? 14 : 20);
|
|
52
|
+
const circleDiameter = (isCompact) => (isCompact ? 12 : 20);
|
|
54
53
|
// Switcher/Toggle element styles
|
|
55
54
|
exports.switchHoverStyles = Css_1.Css.bgGray400.$;
|
|
56
55
|
exports.switchFocusStyles = Css_1.Css.bshFocus.$;
|
|
@@ -60,7 +59,7 @@ const switchCircleDefaultStyles = (isCompact) => ({
|
|
|
60
59
|
...Css_1.Css.wPx(circleDiameter(isCompact))
|
|
61
60
|
.hPx(circleDiameter(isCompact))
|
|
62
61
|
.br100.bgWhite.bshBasic.absolute.leftPx(2)
|
|
63
|
-
.topPx(
|
|
62
|
+
.topPx(2).transition.df.aic.jcc.$,
|
|
64
63
|
svg: Css_1.Css.hPx(toggleHeight(isCompact) / 2).wPx(toggleHeight(isCompact) / 2).$,
|
|
65
64
|
});
|
|
66
65
|
/**
|