@homebound/beam 2.79.2 → 2.80.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/Icon.d.ts +1 -0
- package/dist/components/Icon.js +1 -0
- package/dist/components/Table/GridTable.d.ts +8 -13
- package/dist/components/Table/GridTable.js +28 -64
- package/dist/components/Table/index.d.ts +2 -1
- package/dist/components/Table/index.js +5 -4
- package/dist/components/Table/nestedCards.d.ts +1 -2
- package/dist/components/Table/nestedCards.js +4 -11
- package/dist/components/Table/styles.d.ts +7 -0
- package/dist/components/Table/styles.js +42 -0
- package/package.json +4 -2
|
@@ -22,6 +22,7 @@ export declare function Icon(props: IconProps): import("@emotion/react/jsx-runti
|
|
|
22
22
|
* 3. Remove all fill attributes as these will be controlled by the wrapping component
|
|
23
23
|
*/
|
|
24
24
|
export declare const Icons: {
|
|
25
|
+
drag: import("@emotion/react/jsx-runtime").JSX.Element;
|
|
25
26
|
x: import("@emotion/react/jsx-runtime").JSX.Element;
|
|
26
27
|
loader: import("@emotion/react/jsx-runtime").JSX.Element;
|
|
27
28
|
linkExternal: import("@emotion/react/jsx-runtime").JSX.Element;
|
package/dist/components/Icon.js
CHANGED
|
@@ -20,6 +20,7 @@ exports.Icon = Icon;
|
|
|
20
20
|
*/
|
|
21
21
|
exports.Icons = {
|
|
22
22
|
// Actions
|
|
23
|
+
drag: ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("path", { d: "M8 8C7.44772 8 7 7.55228 7 7L7 5C7 4.44772 7.44772 4 8 4L10 4C10.5523 4 11 4.44772 11 5L11 7C11 7.55228 10.5523 8 10 8L8 8Z" }, void 0), (0, jsx_runtime_1.jsx)("path", { d: "M8 14C7.44772 14 7 13.5523 7 13L7 11C7 10.4477 7.44772 10 8 10L10 10C10.5523 10 11 10.4477 11 11L11 13C11 13.5523 10.5523 14 10 14L8 14Z" }, void 0), (0, jsx_runtime_1.jsx)("path", { d: "M8 20C7.44772 20 7 19.5523 7 19L7 17C7 16.4477 7.44772 16 8 16L10 16C10.5523 16 11 16.4477 11 17L11 19C11 19.5523 10.5523 20 10 20L8 20Z" }, void 0), (0, jsx_runtime_1.jsx)("path", { d: "M14 8C13.4477 8 13 7.55228 13 7L13 5C13 4.44772 13.4477 4 14 4L16 4C16.5523 4 17 4.44772 17 5L17 7C17 7.55228 16.5523 8 16 8L14 8Z" }, void 0), (0, jsx_runtime_1.jsx)("path", { d: "M14 14C13.4477 14 13 13.5523 13 13L13 11C13 10.4477 13.4477 10 14 10L16 10C16.5523 10 17 10.4477 17 11L17 13C17 13.5523 16.5523 14 16 14L14 14Z" }, void 0), (0, jsx_runtime_1.jsx)("path", { d: "M14 20C13.4477 20 13 19.5523 13 19L13 17C13 16.4477 13.4477 16 14 16L16 16C16.5523 16 17 16.4477 17 17L17 19C17 19.5523 16.5523 20 16 20L14 20Z" }, void 0)] }, void 0)),
|
|
23
24
|
x: ((0, jsx_runtime_1.jsx)("path", { d: "M16.192 6.34399L11.949 10.586L7.70697 6.34399L6.29297 7.75799L10.535 12L6.29297 16.242L7.70697 17.656L11.949 13.414L16.192 17.656L17.606 16.242L13.364 12L17.606 7.75799L16.192 6.34399Z" }, void 0)),
|
|
24
25
|
loader: ((0, jsx_runtime_1.jsx)("path", { d: "M12 22C17.421 22 22 17.421 22 12H20C20 16.337 16.337 20 12 20C7.663 20 4 16.337 4 12C4 7.664 7.663 4 12 4V2C6.579 2 2 6.58 2 12C2 17.421 6.579 22 12 22Z" }, void 0)),
|
|
25
26
|
linkExternal: ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("path", { d: "M13 3L16.293 6.293L9.29297 13.293L10.707 14.707L17.707 7.707L21 11V3H13Z" }, void 0), (0, jsx_runtime_1.jsx)("path", { d: "M19 19H5V5H12L10 3H5C3.897 3 3 3.897 3 5V19C3 20.103 3.897 21 5 21H19C20.103 21 21 20.103 21 19V14L19 12V19Z" }, void 0)] }, void 0)),
|
|
@@ -41,8 +41,10 @@ export interface GridStyle {
|
|
|
41
41
|
emptyCell?: ReactNode;
|
|
42
42
|
}
|
|
43
43
|
export interface NestedCardsStyle {
|
|
44
|
-
/**
|
|
45
|
-
|
|
44
|
+
/** Space between each card. */
|
|
45
|
+
spacerPx: number;
|
|
46
|
+
/** Width of the first and last "hidden" columns used to align nested columns. */
|
|
47
|
+
firstLastColumnWidth?: number;
|
|
46
48
|
/**
|
|
47
49
|
* Per-kind styling for nested cards (see `cardStyle` if you only need a flat list of cards).
|
|
48
50
|
*
|
|
@@ -66,24 +68,17 @@ export interface NestedCardStyle {
|
|
|
66
68
|
brPx: number;
|
|
67
69
|
/** The left/right padding of the card. */
|
|
68
70
|
pxPx: number;
|
|
69
|
-
/** The y spacing between each row within this card. */
|
|
70
|
-
spacerPx: number;
|
|
71
71
|
}
|
|
72
72
|
export interface GridTableDefaults {
|
|
73
73
|
style: GridStyle;
|
|
74
74
|
stickyHeader: boolean;
|
|
75
75
|
}
|
|
76
|
-
/** Our original table look & feel/style. */
|
|
77
|
-
export declare const defaultStyle: GridStyle;
|
|
78
|
-
/** Tightens up the padding of rows, great for rows that have form elements in them. */
|
|
79
|
-
export declare const condensedStyle: GridStyle;
|
|
80
|
-
/** Renders each row as a card. */
|
|
81
|
-
export declare const cardStyle: GridStyle;
|
|
82
76
|
/** Configures the default/app-wide GridStyle. */
|
|
83
77
|
export declare function setDefaultStyle(style: GridStyle): void;
|
|
84
78
|
/** Configures the default/app-wide GridTable settings. */
|
|
85
79
|
export declare function setGridTableDefaults(opts: Partial<GridTableDefaults>): void;
|
|
86
80
|
declare type RenderAs = "div" | "table" | "virtual";
|
|
81
|
+
/** The GridDataRow is optional b/c the nested card chrome rows only have ReactElements. */
|
|
87
82
|
export declare type RowTuple<R extends Kinded> = [GridDataRow<R> | undefined, ReactElement];
|
|
88
83
|
/**
|
|
89
84
|
* The sort settings for the current table; whether it's client-side or server-side.
|
|
@@ -170,7 +165,7 @@ export interface GridTableProps<R extends Kinded, S, X> {
|
|
|
170
165
|
* - Columns are mostly rendering logic
|
|
171
166
|
* - I.e. each column defines it's behavior for each given row `kind`
|
|
172
167
|
*
|
|
173
|
-
* In a kind of cute way, headers are not modeled specially, i.e. they are just another
|
|
168
|
+
* In a "kind" of cute way, headers are not modeled specially, i.e. they are just another
|
|
174
169
|
* row `kind` along with the data rows. (Admittedly, out of pragmatism, we do apply some
|
|
175
170
|
* special styling to the row that uses `kind: "header"`.)
|
|
176
171
|
*/
|
|
@@ -186,8 +181,8 @@ export declare function GridTable<R extends Kinded, S = {}, X extends Only<GridT
|
|
|
186
181
|
*
|
|
187
182
|
* When we're as=virtual, we change our default + enforce only fixed-sized units (% and px)
|
|
188
183
|
*/
|
|
189
|
-
export declare function calcVirtualGridColumns(columns: GridColumn<any>[],
|
|
190
|
-
export declare function calcDivGridColumns(columns: GridColumn<any>[],
|
|
184
|
+
export declare function calcVirtualGridColumns(columns: GridColumn<any>[], firstLastColumnWidth: number | undefined): string;
|
|
185
|
+
export declare function calcDivGridColumns(columns: GridColumn<any>[], firstLastCardWidth: number | undefined): string;
|
|
191
186
|
/**
|
|
192
187
|
* Given an ADT of type T, performs a look up and returns the type of kind K.
|
|
193
188
|
*
|
|
@@ -22,7 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.matchesFilter = exports.GridCollapseContext = exports.applyRowFn = exports.calcDivGridColumns = exports.calcVirtualGridColumns = exports.GridTable = exports.setGridTableDefaults = exports.setDefaultStyle = exports.
|
|
25
|
+
exports.matchesFilter = exports.GridCollapseContext = exports.applyRowFn = exports.calcDivGridColumns = exports.calcVirtualGridColumns = exports.GridTable = exports.setGridTableDefaults = exports.setDefaultStyle = exports.setRunningInJest = exports.emptyCell = exports.DESC = exports.ASC = void 0;
|
|
26
26
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
27
27
|
const memoize_one_1 = __importDefault(require("memoize-one"));
|
|
28
28
|
const mobx_react_1 = require("mobx-react");
|
|
@@ -38,6 +38,7 @@ const sortRows_1 = require("./sortRows");
|
|
|
38
38
|
const useSortState_1 = require("./useSortState");
|
|
39
39
|
const Css_1 = require("../../Css");
|
|
40
40
|
const tinycolor2_1 = __importDefault(require("tinycolor2"));
|
|
41
|
+
const _1 = require(".");
|
|
41
42
|
exports.ASC = "ASC";
|
|
42
43
|
exports.DESC = "DESC";
|
|
43
44
|
const emptyCell = () => (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}, void 0);
|
|
@@ -48,46 +49,8 @@ function setRunningInJest() {
|
|
|
48
49
|
runningInJest = true;
|
|
49
50
|
}
|
|
50
51
|
exports.setRunningInJest = setRunningInJest;
|
|
51
|
-
/** Our original table look & feel/style. */
|
|
52
|
-
exports.defaultStyle = {
|
|
53
|
-
rootCss: Css_1.Css.gray700.$,
|
|
54
|
-
betweenRowsCss: Css_1.Css.bt.bGray400.$,
|
|
55
|
-
firstNonHeaderRowCss: Css_1.Css.add({ borderTopStyle: "none" }).$,
|
|
56
|
-
cellCss: Css_1.Css.py2.px3.$,
|
|
57
|
-
firstCellCss: Css_1.Css.pl1.$,
|
|
58
|
-
lastCellCss: Css_1.Css.$,
|
|
59
|
-
indentOneCss: Css_1.Css.pl4.$,
|
|
60
|
-
indentTwoCss: Css_1.Css.pl7.$,
|
|
61
|
-
// Use h100 so that all cells are the same height when scrolled; set bgWhite for when we're laid over other rows.
|
|
62
|
-
headerCellCss: Css_1.Css.asfe.nowrap.py1.bgGray100.h100.aife.$,
|
|
63
|
-
firstRowMessageCss: Css_1.Css.px1.py2.$,
|
|
64
|
-
rowHoverColor: Css_1.Palette.Gray200,
|
|
65
|
-
};
|
|
66
|
-
/** Tightens up the padding of rows, great for rows that have form elements in them. */
|
|
67
|
-
exports.condensedStyle = {
|
|
68
|
-
...exports.defaultStyle,
|
|
69
|
-
headerCellCss: Css_1.Css.bgGray100.tinyEm.$,
|
|
70
|
-
cellCss: Css_1.Css.aic.sm.py1.px2.$,
|
|
71
|
-
rootCss: Css_1.Css.dg.gray700.xs.$,
|
|
72
|
-
};
|
|
73
|
-
/** Renders each row as a card. */
|
|
74
|
-
exports.cardStyle = {
|
|
75
|
-
...exports.defaultStyle,
|
|
76
|
-
firstNonHeaderRowCss: Css_1.Css.mt2.$,
|
|
77
|
-
cellCss: Css_1.Css.p2.my1.bt.bb.bGray400.$,
|
|
78
|
-
firstCellCss: Css_1.Css.bl.add({ borderTopLeftRadius: "4px", borderBottomLeftRadius: "4px" }).$,
|
|
79
|
-
lastCellCss: Css_1.Css.br.add({ borderTopRightRadius: "4px", borderBottomRightRadius: "4px" }).$,
|
|
80
|
-
// Undo the card look & feel for the header
|
|
81
|
-
headerCellCss: {
|
|
82
|
-
...exports.defaultStyle.headerCellCss,
|
|
83
|
-
...Css_1.Css.add({
|
|
84
|
-
border: "none",
|
|
85
|
-
borderRadius: "unset",
|
|
86
|
-
}).p1.m0.xsEm.gray700.$,
|
|
87
|
-
},
|
|
88
|
-
};
|
|
89
52
|
let defaults = {
|
|
90
|
-
style:
|
|
53
|
+
style: _1.defaultStyle,
|
|
91
54
|
stickyHeader: false,
|
|
92
55
|
};
|
|
93
56
|
/** Configures the default/app-wide GridStyle. */
|
|
@@ -112,11 +75,12 @@ exports.setGridTableDefaults = setGridTableDefaults;
|
|
|
112
75
|
* - Columns are mostly rendering logic
|
|
113
76
|
* - I.e. each column defines it's behavior for each given row `kind`
|
|
114
77
|
*
|
|
115
|
-
* In a kind of cute way, headers are not modeled specially, i.e. they are just another
|
|
78
|
+
* In a "kind" of cute way, headers are not modeled specially, i.e. they are just another
|
|
116
79
|
* row `kind` along with the data rows. (Admittedly, out of pragmatism, we do apply some
|
|
117
80
|
* special styling to the row that uses `kind: "header"`.)
|
|
118
81
|
*/
|
|
119
82
|
function GridTable(props) {
|
|
83
|
+
var _a;
|
|
120
84
|
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;
|
|
121
85
|
const [collapsedIds, toggleCollapsedId] = useToggleIds(rows, persistCollapse);
|
|
122
86
|
// We only use this in as=virtual mode, but keep this here for rowLookup to use
|
|
@@ -132,7 +96,7 @@ function GridTable(props) {
|
|
|
132
96
|
return rows;
|
|
133
97
|
}, [columns, rows, sorting, sortState]);
|
|
134
98
|
// Filter + flatten + component-ize the sorted rows.
|
|
135
|
-
let [headerRows, filteredRows
|
|
99
|
+
let [headerRows, filteredRows] = (0, react_1.useMemo)(() => {
|
|
136
100
|
// Break up "foo bar" into `[foo, bar]` and a row must match both `foo` and `bar`
|
|
137
101
|
const filters = (filter && filter.split(/ +/)) || [];
|
|
138
102
|
function makeRowComponent(row) {
|
|
@@ -163,25 +127,23 @@ function GridTable(props) {
|
|
|
163
127
|
// Split out the header rows from the data rows so that we can put an `infoMessage` in between them (if needed).
|
|
164
128
|
const headerRows = [];
|
|
165
129
|
const filteredRows = [];
|
|
166
|
-
// If we're doing nested cards, we will add extra first/last columns, and need to know how wide to make them
|
|
167
|
-
let maxCardPadding = undefined;
|
|
168
130
|
// Misc state to track our nested card-ification, i.e. interleaved actual rows + chrome rows
|
|
169
131
|
const nestedCards = !!style.nestedCards && new nestedCards_1.NestedCards(columns, filteredRows, style);
|
|
170
132
|
// Depth-first to filter
|
|
171
133
|
function visit(row) {
|
|
134
|
+
var _a;
|
|
172
135
|
const matches = filters.length === 0 ||
|
|
136
|
+
row.pin ||
|
|
173
137
|
filters.every((filter) => columns.map((c) => applyRowFn(c, row)).some((maybeContent) => matchesFilter(maybeContent, filter)));
|
|
174
138
|
// Even if we don't pass the filter, one of our children might, so we continue on after this check
|
|
175
139
|
let isCard = false;
|
|
176
140
|
if (matches) {
|
|
177
141
|
isCard = nestedCards && nestedCards.maybeOpenCard(row);
|
|
178
|
-
if (isCard && nestedCards) {
|
|
179
|
-
maxCardPadding = nestedCards.maxCardPadding(maxCardPadding);
|
|
180
|
-
}
|
|
181
142
|
filteredRows.push([row, makeRowComponent(row)]);
|
|
182
143
|
}
|
|
183
144
|
const isCollapsed = collapsedIds.includes(row.id);
|
|
184
|
-
if (!isCollapsed && row.children) {
|
|
145
|
+
if (!isCollapsed && !!((_a = row.children) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
146
|
+
nestedCards && matches && nestedCards.addSpacer();
|
|
185
147
|
visitRows(row.children, isCard);
|
|
186
148
|
}
|
|
187
149
|
isCard && nestedCards && nestedCards.closeCard();
|
|
@@ -190,17 +152,19 @@ function GridTable(props) {
|
|
|
190
152
|
const length = rows.length;
|
|
191
153
|
rows.forEach((row, i) => {
|
|
192
154
|
if (row.kind === "header") {
|
|
155
|
+
nestedCards && nestedCards.maybeOpenCard(row);
|
|
193
156
|
headerRows.push([row, makeRowComponent(row)]);
|
|
157
|
+
nestedCards && nestedCards.closeCard();
|
|
194
158
|
return;
|
|
195
159
|
}
|
|
196
160
|
visit(row);
|
|
197
|
-
addSpacer && nestedCards && i !== length - 1 && nestedCards.
|
|
161
|
+
addSpacer && nestedCards && i !== length - 1 && nestedCards.addSpacer();
|
|
198
162
|
});
|
|
199
163
|
}
|
|
200
164
|
// If nestedCards is set, we assume the top-level kind is a card, and so should add spacers between them
|
|
201
165
|
visitRows(maybeSorted, !!nestedCards);
|
|
202
166
|
nestedCards && nestedCards.done();
|
|
203
|
-
return [headerRows, filteredRows
|
|
167
|
+
return [headerRows, filteredRows];
|
|
204
168
|
}, [
|
|
205
169
|
as,
|
|
206
170
|
maybeSorted,
|
|
@@ -238,7 +202,7 @@ function GridTable(props) {
|
|
|
238
202
|
// just trust the GridTable impl that, at runtime, `as=virtual` will (other than being virtualized)
|
|
239
203
|
// behave semantically the same as `as=div` did for its tests.
|
|
240
204
|
const _as = as === "virtual" && runningInJest ? "div" : as;
|
|
241
|
-
return renders[_as](style, id, columns, headerRows, filteredRows, firstRowMessage, stickyHeader,
|
|
205
|
+
return renders[_as](style, id, columns, headerRows, filteredRows, firstRowMessage, stickyHeader, (_a = style.nestedCards) === null || _a === void 0 ? void 0 : _a.firstLastColumnWidth, xss, virtuosoRef);
|
|
242
206
|
}
|
|
243
207
|
exports.GridTable = GridTable;
|
|
244
208
|
// Determine which HTML element to use to build the GridTable
|
|
@@ -248,9 +212,9 @@ const renders = {
|
|
|
248
212
|
virtual: renderVirtual,
|
|
249
213
|
};
|
|
250
214
|
/** Renders as a CSS Grid, which is the default / most well-supported rendered. */
|
|
251
|
-
function renderCssGrid(style, id, columns, headerRows, filteredRows, firstRowMessage, stickyHeader,
|
|
215
|
+
function renderCssGrid(style, id, columns, headerRows, filteredRows, firstRowMessage, stickyHeader, firstLastCardWidth, xss, virtuosoRef) {
|
|
252
216
|
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ css: {
|
|
253
|
-
...Css_1.Css.dg.gtc(calcDivGridColumns(columns,
|
|
217
|
+
...Css_1.Css.dg.gtc(calcDivGridColumns(columns, firstLastCardWidth)).$,
|
|
254
218
|
...Css_1.Css
|
|
255
219
|
// Apply the between-row styling with `div + div > *` so that we don't have to have conditional
|
|
256
220
|
// `if !lastRow add border` CSS applied via JS that would mean the row can't be React.memo'd.
|
|
@@ -263,7 +227,7 @@ function renderCssGrid(style, id, columns, headerRows, filteredRows, firstRowMes
|
|
|
263
227
|
}, "data-testid": id }, { children: [headerRows.map(([, node]) => node), firstRowMessage && ((0, jsx_runtime_1.jsx)("div", Object.assign({ css: Css_1.Css.add("gridColumn", `${columns.length} span`).$ }, { children: (0, jsx_runtime_1.jsx)("div", Object.assign({ css: { ...style.firstRowMessageCss } }, { children: firstRowMessage }), void 0) }), void 0)), filteredRows.map(([, node]) => node)] }), void 0));
|
|
264
228
|
}
|
|
265
229
|
/** Renders as a table, primarily/solely for good print support. */
|
|
266
|
-
function renderTable(style, id, columns, headerRows, filteredRows, firstRowMessage,
|
|
230
|
+
function renderTable(style, id, columns, headerRows, filteredRows, firstRowMessage, _stickyHeader, _firstLastColumnWidth, xss, _virtuosoRef) {
|
|
267
231
|
return ((0, jsx_runtime_1.jsxs)("table", Object.assign({ css: {
|
|
268
232
|
...Css_1.Css.w100.add("borderCollapse", "collapse").$,
|
|
269
233
|
...Css_1.Css.addIn("& > tbody > tr ", style.betweenRowsCss || {})
|
|
@@ -293,8 +257,8 @@ function renderTable(style, id, columns, headerRows, filteredRows, firstRowMessa
|
|
|
293
257
|
* [2]: https://github.com/tannerlinsley/react-virtual/issues/85
|
|
294
258
|
* [3]: https://github.com/tannerlinsley/react-virtual/issues/108
|
|
295
259
|
*/
|
|
296
|
-
function renderVirtual(style, id, columns, headerRows, filteredRows, firstRowMessage, stickyHeader,
|
|
297
|
-
return ((0, jsx_runtime_1.jsx)(react_virtuoso_1.Virtuoso, { ref: virtuosoRef, components: { List: VirtualRoot(style, columns, id,
|
|
260
|
+
function renderVirtual(style, id, columns, headerRows, filteredRows, firstRowMessage, stickyHeader, firstLastColumnWidth, xss, virtuosoRef) {
|
|
261
|
+
return ((0, jsx_runtime_1.jsx)(react_virtuoso_1.Virtuoso, { ref: virtuosoRef, components: { List: VirtualRoot(style, columns, id, firstLastColumnWidth, xss) },
|
|
298
262
|
// Pin/sticky both the header row(s) + firstRowMessage to the top
|
|
299
263
|
topItemCount: (stickyHeader ? headerRows.length : 0) + (firstRowMessage ? 1 : 0),
|
|
300
264
|
// Both the `Item` and `itemContent` use `display: contents`, so their height is 0,
|
|
@@ -323,11 +287,11 @@ function renderVirtual(style, id, columns, headerRows, filteredRows, firstRowMes
|
|
|
323
287
|
* identity, even though technically we have a different "component" per the given set of props
|
|
324
288
|
* (solely to capture as params that we can't pass through react-virtuoso's API as props).
|
|
325
289
|
*/
|
|
326
|
-
const VirtualRoot = (0, memoize_one_1.default)((gs, columns, id,
|
|
290
|
+
const VirtualRoot = (0, memoize_one_1.default)((gs, columns, id, firstLastColumnWidth, xss) => {
|
|
327
291
|
return react_1.default.forwardRef(({ style, children }, ref) => {
|
|
328
292
|
// This re-renders each time we have new children in the view port
|
|
329
293
|
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ ref: ref, style: style, css: {
|
|
330
|
-
...Css_1.Css.dg.gtc(calcVirtualGridColumns(columns,
|
|
294
|
+
...Css_1.Css.dg.gtc(calcVirtualGridColumns(columns, firstLastColumnWidth)).$,
|
|
331
295
|
// Add an extra `> div` due to Item + itemContent both having divs
|
|
332
296
|
...Css_1.Css.addIn("& > div + div > div > *", gs.betweenRowsCss || {}).$,
|
|
333
297
|
// Add `display:contents` to Item to flatten it like we do GridRow
|
|
@@ -348,7 +312,7 @@ const VirtualRoot = (0, memoize_one_1.default)((gs, columns, id, maxCardPadding,
|
|
|
348
312
|
*
|
|
349
313
|
* When we're as=virtual, we change our default + enforce only fixed-sized units (% and px)
|
|
350
314
|
*/
|
|
351
|
-
function calcVirtualGridColumns(columns,
|
|
315
|
+
function calcVirtualGridColumns(columns, firstLastColumnWidth) {
|
|
352
316
|
// For both default columns (1fr) as well as `w: 4fr` columns, we translate the width into an expression that looks like:
|
|
353
317
|
// calc((100% - allOtherPercent - allOtherPx) * ((myFr / totalFr))`
|
|
354
318
|
//
|
|
@@ -400,10 +364,10 @@ function calcVirtualGridColumns(columns, maxCardPadding) {
|
|
|
400
364
|
return fr(w);
|
|
401
365
|
}
|
|
402
366
|
});
|
|
403
|
-
return maybeAddCardColumns(sizes,
|
|
367
|
+
return maybeAddCardColumns(sizes, firstLastColumnWidth);
|
|
404
368
|
}
|
|
405
369
|
exports.calcVirtualGridColumns = calcVirtualGridColumns;
|
|
406
|
-
function calcDivGridColumns(columns,
|
|
370
|
+
function calcDivGridColumns(columns, firstLastCardWidth) {
|
|
407
371
|
const sizes = columns.map(({ w }) => {
|
|
408
372
|
if (typeof w === "undefined") {
|
|
409
373
|
// Hrm, I waffle between 'auto' or '1fr' being the better default here...
|
|
@@ -418,12 +382,12 @@ function calcDivGridColumns(columns, maxCardPadding) {
|
|
|
418
382
|
return `${w}fr`;
|
|
419
383
|
}
|
|
420
384
|
});
|
|
421
|
-
return maybeAddCardColumns(sizes,
|
|
385
|
+
return maybeAddCardColumns(sizes, firstLastCardWidth);
|
|
422
386
|
}
|
|
423
387
|
exports.calcDivGridColumns = calcDivGridColumns;
|
|
424
388
|
// If we're doing nested cards, we add extra 1st/last cells...
|
|
425
|
-
function maybeAddCardColumns(sizes,
|
|
426
|
-
return (!
|
|
389
|
+
function maybeAddCardColumns(sizes, firstLastCardWidth) {
|
|
390
|
+
return (!firstLastCardWidth ? sizes : [`${firstLastCardWidth}px`, ...sizes, `${firstLastCardWidth}px`]).join(" ");
|
|
427
391
|
}
|
|
428
392
|
function getIndentationCss(style, rowStyle, columnIndex, maybeContent) {
|
|
429
393
|
// Look for cell-specific indent or row-specific indent (row-specific is only one the first column)
|
|
@@ -2,8 +2,9 @@ export * from "./CollapseToggle";
|
|
|
2
2
|
export * from "./columns";
|
|
3
3
|
export type { GridRowLookup } from "./GridRowLookup";
|
|
4
4
|
export { GridSortContext } from "./GridSortContext";
|
|
5
|
-
export { ASC,
|
|
5
|
+
export { ASC, DESC, GridTable, setDefaultStyle, setGridTableDefaults } from "./GridTable";
|
|
6
6
|
export type { Direction, GridCellAlignment, GridCellContent, GridCollapseContext, GridColumn, GridDataRow, GridRowStyles, GridSortConfig, GridStyle, GridTableDefaults, GridTableProps, GridTableXss, Kinded, RowStyle, setRunningInJest, } from "./GridTable";
|
|
7
7
|
export { simpleDataRows, simpleHeader, simpleRows } from "./simpleHelpers";
|
|
8
8
|
export type { SimpleHeaderAndDataOf, SimpleHeaderAndDataWith } from "./simpleHelpers";
|
|
9
9
|
export { SortHeader } from "./SortHeader";
|
|
10
|
+
export { cardStyle, condensedStyle, defaultStyle } from "./styles";
|
|
@@ -10,16 +10,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.
|
|
13
|
+
exports.defaultStyle = exports.condensedStyle = exports.cardStyle = exports.SortHeader = exports.simpleRows = exports.simpleHeader = exports.simpleDataRows = exports.setGridTableDefaults = exports.setDefaultStyle = exports.GridTable = exports.DESC = exports.ASC = exports.GridSortContext = void 0;
|
|
14
14
|
__exportStar(require("./CollapseToggle"), exports);
|
|
15
15
|
__exportStar(require("./columns"), exports);
|
|
16
16
|
var GridSortContext_1 = require("./GridSortContext");
|
|
17
17
|
Object.defineProperty(exports, "GridSortContext", { enumerable: true, get: function () { return GridSortContext_1.GridSortContext; } });
|
|
18
18
|
var GridTable_1 = require("./GridTable");
|
|
19
19
|
Object.defineProperty(exports, "ASC", { enumerable: true, get: function () { return GridTable_1.ASC; } });
|
|
20
|
-
Object.defineProperty(exports, "cardStyle", { enumerable: true, get: function () { return GridTable_1.cardStyle; } });
|
|
21
|
-
Object.defineProperty(exports, "condensedStyle", { enumerable: true, get: function () { return GridTable_1.condensedStyle; } });
|
|
22
|
-
Object.defineProperty(exports, "defaultStyle", { enumerable: true, get: function () { return GridTable_1.defaultStyle; } });
|
|
23
20
|
Object.defineProperty(exports, "DESC", { enumerable: true, get: function () { return GridTable_1.DESC; } });
|
|
24
21
|
Object.defineProperty(exports, "GridTable", { enumerable: true, get: function () { return GridTable_1.GridTable; } });
|
|
25
22
|
Object.defineProperty(exports, "setDefaultStyle", { enumerable: true, get: function () { return GridTable_1.setDefaultStyle; } });
|
|
@@ -30,3 +27,7 @@ Object.defineProperty(exports, "simpleHeader", { enumerable: true, get: function
|
|
|
30
27
|
Object.defineProperty(exports, "simpleRows", { enumerable: true, get: function () { return simpleHelpers_1.simpleRows; } });
|
|
31
28
|
var SortHeader_1 = require("./SortHeader");
|
|
32
29
|
Object.defineProperty(exports, "SortHeader", { enumerable: true, get: function () { return SortHeader_1.SortHeader; } });
|
|
30
|
+
var styles_1 = require("./styles");
|
|
31
|
+
Object.defineProperty(exports, "cardStyle", { enumerable: true, get: function () { return styles_1.cardStyle; } });
|
|
32
|
+
Object.defineProperty(exports, "condensedStyle", { enumerable: true, get: function () { return styles_1.condensedStyle; } });
|
|
33
|
+
Object.defineProperty(exports, "defaultStyle", { enumerable: true, get: function () { return styles_1.defaultStyle; } });
|
|
@@ -22,9 +22,8 @@ export declare class NestedCards {
|
|
|
22
22
|
constructor(columns: GridColumn<any>[], filteredRows: RowTuple<any>[], style: GridStyle);
|
|
23
23
|
maybeOpenCard(row: GridDataRow<any>): boolean;
|
|
24
24
|
closeCard(): void;
|
|
25
|
-
|
|
25
|
+
addSpacer(): void;
|
|
26
26
|
done(): void;
|
|
27
|
-
maxCardPadding(current: number | undefined): number;
|
|
28
27
|
/** Return a stable copy of the cards, so it won't change as we keep going. */
|
|
29
28
|
currentOpenCards(): NestedCardStyle[];
|
|
30
29
|
}
|
|
@@ -25,10 +25,10 @@ class NestedCards {
|
|
|
25
25
|
this.openCards = [];
|
|
26
26
|
// A buffer of the open/close/spacer rows we need between each content row.
|
|
27
27
|
this.chromeBuffer = [];
|
|
28
|
-
this.styles = style.nestedCards
|
|
28
|
+
this.styles = style.nestedCards;
|
|
29
29
|
}
|
|
30
30
|
maybeOpenCard(row) {
|
|
31
|
-
const card = this.styles[row.kind];
|
|
31
|
+
const card = this.styles.kinds[row.kind];
|
|
32
32
|
// If this kind doesn't have a card defined, don't put it on the card stack
|
|
33
33
|
if (card) {
|
|
34
34
|
this.openCards.push(card);
|
|
@@ -42,19 +42,12 @@ class NestedCards {
|
|
|
42
42
|
this.chromeBuffer.push(makeOpenOrCloseCard(this.openCards, "close"));
|
|
43
43
|
this.openCards.pop();
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
// If we're between two top-level cards, there is no open card, so fallback on topLevelSpacerPx
|
|
48
|
-
const height = (openCard === null || openCard === void 0 ? void 0 : openCard.spacerPx) || this.style.nestedCards.topLevelSpacerPx;
|
|
49
|
-
this.chromeBuffer.push(makeSpacer(height, this.openCards));
|
|
45
|
+
addSpacer() {
|
|
46
|
+
this.chromeBuffer.push(makeSpacer(this.styles.spacerPx, this.openCards));
|
|
50
47
|
}
|
|
51
48
|
done() {
|
|
52
49
|
maybeCreateChromeRow(this.columns, this.filteredRows, this.chromeBuffer);
|
|
53
50
|
}
|
|
54
|
-
maxCardPadding(current) {
|
|
55
|
-
const padding = this.openCards.map((c) => c.pxPx + (!!c.bColor ? 1 : 0)).reduce((a, b) => a + b, 0);
|
|
56
|
-
return Math.max(padding, current || 0);
|
|
57
|
-
}
|
|
58
51
|
/** Return a stable copy of the cards, so it won't change as we keep going. */
|
|
59
52
|
currentOpenCards() {
|
|
60
53
|
return [...this.openCards];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { GridStyle } from ".";
|
|
2
|
+
/** Our original table look & feel/style. */
|
|
3
|
+
export declare const defaultStyle: GridStyle;
|
|
4
|
+
/** Tightens up the padding of rows, great for rows that have form elements in them. */
|
|
5
|
+
export declare const condensedStyle: GridStyle;
|
|
6
|
+
/** Renders each row as a card. */
|
|
7
|
+
export declare const cardStyle: GridStyle;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cardStyle = exports.condensedStyle = exports.defaultStyle = void 0;
|
|
4
|
+
const src_1 = require("../..");
|
|
5
|
+
/** Our original table look & feel/style. */
|
|
6
|
+
exports.defaultStyle = {
|
|
7
|
+
rootCss: src_1.Css.gray700.$,
|
|
8
|
+
betweenRowsCss: src_1.Css.bt.bGray400.$,
|
|
9
|
+
firstNonHeaderRowCss: src_1.Css.add({ borderTopStyle: "none" }).$,
|
|
10
|
+
cellCss: src_1.Css.py2.px3.$,
|
|
11
|
+
firstCellCss: src_1.Css.pl1.$,
|
|
12
|
+
lastCellCss: src_1.Css.$,
|
|
13
|
+
indentOneCss: src_1.Css.pl4.$,
|
|
14
|
+
indentTwoCss: src_1.Css.pl7.$,
|
|
15
|
+
// Use h100 so that all cells are the same height when scrolled; set bgWhite for when we're laid over other rows.
|
|
16
|
+
headerCellCss: src_1.Css.asfe.nowrap.py1.bgGray100.h100.aife.$,
|
|
17
|
+
firstRowMessageCss: src_1.Css.px1.py2.$,
|
|
18
|
+
rowHoverColor: src_1.Palette.Gray200,
|
|
19
|
+
};
|
|
20
|
+
/** Tightens up the padding of rows, great for rows that have form elements in them. */
|
|
21
|
+
exports.condensedStyle = {
|
|
22
|
+
...exports.defaultStyle,
|
|
23
|
+
headerCellCss: src_1.Css.bgGray100.tinyEm.$,
|
|
24
|
+
cellCss: src_1.Css.aic.sm.py1.px2.$,
|
|
25
|
+
rootCss: src_1.Css.dg.gray700.xs.$,
|
|
26
|
+
};
|
|
27
|
+
/** Renders each row as a card. */
|
|
28
|
+
exports.cardStyle = {
|
|
29
|
+
...exports.defaultStyle,
|
|
30
|
+
firstNonHeaderRowCss: src_1.Css.mt2.$,
|
|
31
|
+
cellCss: src_1.Css.p2.my1.bt.bb.bGray400.$,
|
|
32
|
+
firstCellCss: src_1.Css.bl.add({ borderTopLeftRadius: "4px", borderBottomLeftRadius: "4px" }).$,
|
|
33
|
+
lastCellCss: src_1.Css.br.add({ borderTopRightRadius: "4px", borderBottomRightRadius: "4px" }).$,
|
|
34
|
+
// Undo the card look & feel for the header
|
|
35
|
+
headerCellCss: {
|
|
36
|
+
...exports.defaultStyle.headerCellCss,
|
|
37
|
+
...src_1.Css.add({
|
|
38
|
+
border: "none",
|
|
39
|
+
borderRadius: "unset",
|
|
40
|
+
}).p1.m0.xsEm.gray700.$,
|
|
41
|
+
},
|
|
42
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@homebound/beam",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.80.0",
|
|
4
4
|
"author": "Homebound",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -89,10 +89,12 @@
|
|
|
89
89
|
"@types/dompurify": "^2.2.3",
|
|
90
90
|
"@types/jest": "^26.0.20",
|
|
91
91
|
"@types/react": "^17.0.5",
|
|
92
|
+
"@types/react-beautiful-dnd": "^13.1.2",
|
|
92
93
|
"@types/react-dom": "^16.9.11",
|
|
93
94
|
"@types/react-router-dom": "^5.1.7",
|
|
94
95
|
"@typescript-eslint/eslint-plugin": "^4.17.0",
|
|
95
96
|
"@typescript-eslint/parser": "^4.17.0",
|
|
97
|
+
"array-move": "^4.0.0",
|
|
96
98
|
"babel-eslint": "^10.1.0",
|
|
97
99
|
"babel-loader": "^8.2.2",
|
|
98
100
|
"chromatic": "^5.9.2",
|
|
@@ -114,9 +116,9 @@
|
|
|
114
116
|
"prettier": "^2.2.1",
|
|
115
117
|
"prettier-plugin-organize-imports": "^1.1.1",
|
|
116
118
|
"react": "^16.14.0",
|
|
119
|
+
"react-beautiful-dnd": "^13.1.0",
|
|
117
120
|
"react-dom": "^16.14.0",
|
|
118
121
|
"semantic-release": "^17.4.0",
|
|
119
|
-
"tinycolor2": "^1.4.1",
|
|
120
122
|
"ts-jest": "^26.5.3",
|
|
121
123
|
"ts-node": "^9.1.1",
|
|
122
124
|
"tslib": "^2.1.0",
|