@homebound/beam 2.95.0 → 2.95.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.
@@ -7,9 +7,14 @@ const components_1 = require("..");
7
7
  function CollapseToggle(props) {
8
8
  const { row } = props;
9
9
  const { isCollapsed, toggleCollapsed } = (0, react_1.useContext)(components_1.GridCollapseContext);
10
- const toggleOnClick = (0, react_1.useCallback)(() => toggleCollapsed(row.id), [row.id, toggleCollapsed]);
11
- const iconKey = isCollapsed(row.id) ? "chevronRight" : "chevronDown";
12
- const headerIconKey = isCollapsed(row.id) ? "chevronsRight" : "chevronsDown";
10
+ const [, setTick] = (0, react_1.useState)(0);
11
+ const currentlyCollapsed = isCollapsed(row.id);
12
+ const toggleOnClick = (0, react_1.useCallback)(() => {
13
+ toggleCollapsed(row.id);
14
+ setTick(Date.now());
15
+ }, [row.id, currentlyCollapsed, toggleCollapsed]);
16
+ const iconKey = currentlyCollapsed ? "chevronRight" : "chevronDown";
17
+ const headerIconKey = currentlyCollapsed ? "chevronsRight" : "chevronsDown";
13
18
  const isHeader = row.kind === "header";
14
19
  if (!isHeader && (!props.row.children || props.row.children.length === 0)) {
15
20
  return null;
@@ -302,13 +302,17 @@ export declare type GridDataRow<R extends Kinded> = {
302
302
  /** Return the content for a given column def applied to a given row. */
303
303
  export declare function applyRowFn<R extends Kinded>(column: GridColumn<R>, row: GridDataRow<R>): ReactNode | GridCellContent;
304
304
  /**
305
- * Provides each row access to its `collapsed` current state and toggle.
305
+ * Provides each row access to a method to check if it is collapsed and toggle it's collapsed state.
306
306
  *
307
307
  * Calling `toggleCollapse` will keep the row itself showing, but will hide any
308
308
  * children rows (specifically those that have this row's `id` in their `parentIds`
309
309
  * prop).
310
+ *
311
+ * headerCollapsed is used to trigger rows at the root level to rerender their chevron when all are
312
+ * collapsed/expanded.
310
313
  */
311
314
  declare type GridCollapseContextProps = {
315
+ headerCollapsed: boolean;
312
316
  isCollapsed: (id: string) => boolean;
313
317
  toggleCollapsed(id: string): void;
314
318
  };
@@ -257,9 +257,9 @@ function renderTable(style, id, columns, headerRows, filteredRows, firstRowMessa
257
257
  */
258
258
  function renderVirtual(style, id, columns, headerRows, filteredRows, firstRowMessage, stickyHeader, firstLastColumnWidth, xss, virtuosoRef) {
259
259
  var _a;
260
- const { paddingBottom } = (_a = style.rootCss) !== null && _a !== void 0 ? _a : {};
260
+ const { paddingBottom, ...otherRootStyles } = (_a = style.rootCss) !== null && _a !== void 0 ? _a : {};
261
261
  return ((0, jsx_runtime_1.jsx)(react_virtuoso_1.Virtuoso, { ref: virtuosoRef, components: {
262
- List: VirtualRoot(style, columns, id, firstLastColumnWidth, xss),
262
+ List: VirtualRoot({ ...style, rootCss: otherRootStyles }, columns, id, firstLastColumnWidth, xss),
263
263
  Footer: () => (0, jsx_runtime_1.jsx)("div", { css: { paddingBottom } }, void 0),
264
264
  },
265
265
  // Pin/sticky both the header row(s) + firstRowMessage to the top
@@ -544,6 +544,7 @@ const defaultRenderFn = (as) => (key, css, content) => {
544
544
  return ((0, jsx_runtime_1.jsx)(Row, Object.assign({ css: { ...css, ...tableRowStyles(as) } }, { children: content }), key));
545
545
  };
546
546
  exports.GridCollapseContext = react_1.default.createContext({
547
+ headerCollapsed: false,
547
548
  isCollapsed: (id) => false,
548
549
  toggleCollapsed: (id) => { },
549
550
  });
@@ -687,7 +688,7 @@ function useToggleIds(rows, persistCollapse) {
687
688
  // Trigger a re-render
688
689
  setTick(collapsedIds.join(","));
689
690
  };
690
- return { isCollapsed, toggleCollapsed: toggleAll };
691
+ return { headerCollapsed: isCollapsed("header"), isCollapsed, toggleCollapsed: toggleAll };
691
692
  },
692
693
  // eslint-disable-next-line react-hooks/exhaustive-deps
693
694
  [rows]);
@@ -709,10 +710,10 @@ function useToggleIds(rows, persistCollapse) {
709
710
  // Trigger a re-render
710
711
  setTick(collapsedIds.join(","));
711
712
  };
712
- return { isCollapsed, toggleCollapsed: toggleRow };
713
+ return { headerCollapsed: isCollapsed("header"), isCollapsed, toggleCollapsed: toggleRow };
713
714
  },
714
715
  // eslint-disable-next-line react-hooks/exhaustive-deps
715
- []);
716
+ [collapseAllContext.isCollapsed("header")]);
716
717
  // Return a copy of the list, b/c we want external useMemos that do explicitly use the
717
718
  // entire list as a dep to re-render whenever the list is changed (which they need to
718
719
  // see as new list identity).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.95.0",
3
+ "version": "2.95.1",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",