@homebound/beam 2.212.3 → 2.213.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.
@@ -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({ icon: 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));
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
- error: "xCircle",
20
- warning: "error",
21
- success: "checkCircle",
22
- info: "infoCircle",
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
  };
@@ -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
- as,
208
- api,
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, headerRows, totalsRows, expandableHeaderRows, visibleDataRows, firstRowMessage, stickyHeader, xss, virtuosoRef)] }), void 0) }), void 0));
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, headerRows, totalsRows, expandableHeaderRows, visibleDataRows, firstRowMessage, _stickyHeader, xss, _virtuosoRef) {
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: [totalsRows.map(([, node]) => node), expandableHeaderRows.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)), visibleDataRows.map(([, node]) => node)] }), void 0));
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, headerRows, totalsRows, expandableHeaderRows, visibleDataRows, firstRowMessage, _stickyHeader, xss, _virtuosoRef) {
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("& > tbody > tr:first-of-type", style.firstRowCss).$,
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", { children: [...totalsRows, ...expandableHeaderRows, ...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)), visibleDataRows.map(([, node]) => node)] }, void 0)] }), void 0));
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, headerRows, totalsRows, expandableHeaderRows, visibleDataRows, firstRowMessage, stickyHeader, xss, virtuosoRef) {
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 ? headerRows.length + totalsRows.length + expandableHeaderRows.length : 0) +
337
- (firstRowMessage ? 1 : 0), itemContent: (index) => {
338
- // Since we have 4 arrays of rows: `headerRows`, `totalsRows`, `expandableHeaderRows`, and `filteredRow` we
339
- // must determine which one to render.
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 -= totalsRows.length;
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: headerRows.length +
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.
@@ -9,8 +9,6 @@ interface RowProps<R extends Kinded> {
9
9
  row: GridDataRow<R>;
10
10
  style: GridStyle;
11
11
  rowStyles: RowStyles<R> | undefined;
12
- stickyHeader: boolean;
13
- stickyOffset: number;
14
12
  sortOn: SortOn;
15
13
  columnSizes: string[];
16
14
  level: number;
@@ -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, stickyHeader, stickyOffset, sortOn, columnSizes, level, getCount, api, cellHighlight, omitRowHover, hasExpandableHeader, ...others } = props;
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.$,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.212.3",
3
+ "version": "2.213.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",