@homebound/beam 2.187.0 → 2.187.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.
Files changed (49) hide show
  1. package/dist/components/SuperDrawer/ConfirmCloseModal.js +1 -1
  2. package/dist/components/SuperDrawer/SuperDrawer.js +4 -10
  3. package/dist/components/Table/GridTable.d.ts +11 -218
  4. package/dist/components/Table/GridTable.js +15 -426
  5. package/dist/components/Table/GridTableApi.d.ts +3 -2
  6. package/dist/components/Table/GridTableApi.js +2 -2
  7. package/dist/components/Table/TableStyles.d.ts +86 -0
  8. package/dist/components/Table/{styles.js → TableStyles.js} +55 -34
  9. package/dist/components/Table/{CollapseToggle.d.ts → components/CollapseToggle.d.ts} +1 -1
  10. package/dist/components/Table/{CollapseToggle.js → components/CollapseToggle.js} +4 -4
  11. package/dist/components/Table/{EditColumnsButton.d.ts → components/EditColumnsButton.d.ts} +2 -2
  12. package/dist/components/Table/{EditColumnsButton.js → components/EditColumnsButton.js} +5 -5
  13. package/dist/components/Table/components/Row.d.ts +71 -0
  14. package/dist/components/Table/components/Row.js +177 -0
  15. package/dist/components/Table/{SelectToggle.d.ts → components/SelectToggle.d.ts} +0 -0
  16. package/dist/components/Table/{SelectToggle.js → components/SelectToggle.js} +5 -5
  17. package/dist/components/Table/{SortHeader.d.ts → components/SortHeader.d.ts} +1 -1
  18. package/dist/components/Table/{SortHeader.js → components/SortHeader.js} +5 -5
  19. package/dist/components/Table/components/cell.d.ts +41 -0
  20. package/dist/components/Table/components/cell.js +46 -0
  21. package/dist/components/Table/{useColumns.d.ts → hooks/useColumns.d.ts} +1 -1
  22. package/dist/components/Table/{useColumns.js → hooks/useColumns.js} +1 -1
  23. package/dist/components/Table/{columnSizes.d.ts → hooks/useSetupColumnSizes.d.ts} +2 -1
  24. package/dist/components/Table/{columnSizes.js → hooks/useSetupColumnSizes.js} +3 -3
  25. package/dist/components/Table/{useSortState.d.ts → hooks/useSortState.d.ts} +2 -1
  26. package/dist/components/Table/{useSortState.js → hooks/useSortState.js} +6 -6
  27. package/dist/components/Table/index.d.ts +30 -14
  28. package/dist/components/Table/index.js +38 -24
  29. package/dist/components/Table/types.d.ts +83 -0
  30. package/dist/components/Table/types.js +16 -0
  31. package/dist/components/Table/{GridRowLookup.d.ts → utils/GridRowLookup.d.ts} +2 -1
  32. package/dist/components/Table/{GridRowLookup.js → utils/GridRowLookup.js} +2 -2
  33. package/dist/components/Table/{GridSortContext.d.ts → utils/GridSortContext.d.ts} +0 -0
  34. package/dist/components/Table/{GridSortContext.js → utils/GridSortContext.js} +0 -0
  35. package/dist/components/Table/{RowState.d.ts → utils/RowState.d.ts} +1 -1
  36. package/dist/components/Table/{RowState.js → utils/RowState.js} +0 -0
  37. package/dist/components/Table/{columns.d.ts → utils/columns.d.ts} +6 -1
  38. package/dist/components/Table/utils/columns.js +149 -0
  39. package/dist/components/Table/{simpleHelpers.d.ts → utils/simpleHelpers.d.ts} +1 -1
  40. package/dist/components/Table/{simpleHelpers.js → utils/simpleHelpers.js} +0 -0
  41. package/dist/components/Table/{sortRows.d.ts → utils/sortRows.d.ts} +4 -2
  42. package/dist/components/Table/{sortRows.js → utils/sortRows.js} +3 -3
  43. package/dist/components/Table/utils/utils.d.ts +23 -0
  44. package/dist/components/Table/utils/utils.js +148 -0
  45. package/dist/components/Table/{visitor.d.ts → utils/visitor.d.ts} +1 -1
  46. package/dist/components/Table/{visitor.js → utils/visitor.js} +0 -0
  47. package/package.json +1 -1
  48. package/dist/components/Table/columns.js +0 -84
  49. package/dist/components/Table/styles.d.ts +0 -15
@@ -15,7 +15,7 @@ function ConfirmCloseModal(props) {
15
15
  // after a close and could/will cause other close attempts to fail.
16
16
  modalState.current = undefined;
17
17
  }
18
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(components_1.ModalHeader, { children: "Confirm" }, void 0), (0, jsx_runtime_1.jsx)(components_1.ModalBody, { children: (0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.tc.wPx(400).$ }, { children: [(0, jsx_runtime_1.jsx)("p", Object.assign({ css: Css_1.Css.lgSb.gray900.mb2.$ }, { children: "Are you sure you want to cancel?" }), void 0), (0, jsx_runtime_1.jsx)("p", Object.assign({ css: Css_1.Css.base.gray700.$ }, { children: "Any data you've entered so far will be lost." }), void 0)] }), void 0) }, void 0), (0, jsx_runtime_1.jsx)(components_1.ModalFooter, Object.assign({ xss: Css_1.Css.jcc.$ }, { children: (0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.df.fdc.gap1.aic.$ }, { children: [(0, jsx_runtime_1.jsx)(components_1.Button, { label: continueText, onClick: closeModal }, void 0), (0, jsx_runtime_1.jsx)(components_1.Button, { variant: "tertiary", label: discardText, onClick: () => {
18
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(components_1.ModalBody, { children: (0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.tc.wPx(400).$ }, { children: [(0, jsx_runtime_1.jsx)("p", Object.assign({ css: Css_1.Css.lgSb.gray900.mb1.$ }, { children: "Are you sure you want to cancel?" }), void 0), (0, jsx_runtime_1.jsx)("p", Object.assign({ css: Css_1.Css.base.gray700.$ }, { children: "Any changes you've made so far will be lost." }), void 0)] }), void 0) }, void 0), (0, jsx_runtime_1.jsx)(components_1.ModalFooter, Object.assign({ xss: Css_1.Css.jcc.$ }, { children: (0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.df.fdc.gap1.aic.$ }, { children: [(0, jsx_runtime_1.jsx)(components_1.Button, { label: continueText, onClick: closeModal }, void 0), (0, jsx_runtime_1.jsx)(components_1.Button, { variant: "tertiary", label: discardText, onClick: () => {
19
19
  // The order of these calls doesn't really matter; close this modal and tell the call to do their close
20
20
  onClose();
21
21
  closeModal();
@@ -37,14 +37,12 @@ function SuperDrawer() {
37
37
  var _a, _b;
38
38
  const { drawerContentStack: contentStack, modalState, modalBodyDiv, modalFooterDiv, modalHeaderDiv, } = (0, BeamContext_1.useBeamContext)();
39
39
  const { closeDrawer } = (0, components_1.useSuperDrawer)();
40
- const drawerHeaderRef = (0, react_3.useRef)(null);
41
40
  const modalBodyRef = (0, react_3.useRef)(null);
42
41
  const modalFooterRef = (0, react_3.useRef)(null);
43
42
  const testId = (0, utils_1.useTestIds)({}, "superDrawer");
44
43
  // Steal the modal body/footer portals from Modal, if we're open
45
44
  (0, react_3.useEffect)(() => {
46
- if (modalBodyRef.current && modalFooterRef.current && drawerHeaderRef.current && modalState.current) {
47
- drawerHeaderRef.current.appendChild(modalHeaderDiv);
45
+ if (modalBodyRef.current && modalFooterRef.current && modalState.current) {
48
46
  modalBodyRef.current.appendChild(modalBodyDiv);
49
47
  modalFooterRef.current.appendChild(modalFooterDiv);
50
48
  }
@@ -80,9 +78,7 @@ function SuperDrawer() {
80
78
  // Custom transitions settings for the translateX animation
81
79
  transition: { ease: "linear", duration: 0.2, delay: 0.2 }, exit: { transition: { ease: "linear", duration: 0.2 }, x: width },
82
80
  // Preventing clicks from triggering parent onClick
83
- onClick: (e) => e.stopPropagation() }, { children: (0, jsx_runtime_1.jsxs)(form_state_1.AutoSaveStatusProvider, { children: [(0, jsx_runtime_1.jsxs)("header", Object.assign({ css: Css_1.Css.df.p3.bb.bGray200.df.aic.jcsb.gap2.$ }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.df.aic.$ }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ css: Css_1.Css.xl2Sb.gray900.mr2.$ }, testId.title, { ref: drawerHeaderRef }, { children: !modalState.current && (title || null) }), void 0), !modalState.current && (titleLeftContent || null)] }), void 0), !modalState.current && (
84
- // Forcing height to 32px to match title height
85
- (0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.df.gap3.aic.hPx(32).fs0.$ }, { children: [titleRightContent || null, !hideControls && ((0, jsx_runtime_1.jsx)(components_1.ButtonGroup, Object.assign({ buttons: [
81
+ onClick: (e) => e.stopPropagation() }, { children: (0, jsx_runtime_1.jsxs)(form_state_1.AutoSaveStatusProvider, { children: [(0, jsx_runtime_1.jsxs)("header", Object.assign({ css: Css_1.Css.df.p3.bb.bGray200.df.aic.jcsb.gap2.if(!!modalState.current).bn.$ }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.df.aic.$ }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ css: Css_1.Css.xl2Sb.gray900.mr2.$ }, testId.title, { children: title !== null && title !== void 0 ? title : null }), void 0), titleLeftContent !== null && titleLeftContent !== void 0 ? titleLeftContent : null] }), void 0), (0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.df.gap3.aic.hPx(32).fs0.$ }, { children: [titleRightContent || null, !hideControls && ((0, jsx_runtime_1.jsx)(components_1.ButtonGroup, Object.assign({ buttons: [
86
82
  {
87
83
  icon: "chevronLeft",
88
84
  onClick: () => onPrevClick && onPrevClick(),
@@ -93,10 +89,8 @@ function SuperDrawer() {
93
89
  onClick: () => onNextClick && onNextClick(),
94
90
  disabled: !onNextClick || isDetail,
95
91
  },
96
- ] }, testId.headerActions), void 0)), (0, jsx_runtime_1.jsx)(components_1.IconButton, Object.assign({ icon: "x", onClick: closeDrawer }, testId.close), void 0)] }), void 0))] }), void 0), content, modalState.current && (
92
+ ] }, testId.headerActions), void 0)), (0, jsx_runtime_1.jsx)(components_1.IconButton, Object.assign({ icon: "x", onClick: closeDrawer }, testId.close), void 0)] }), void 0)] }), void 0), content, modalState.current && (
97
93
  // Forcing some design constraints on the modal component
98
- (0, jsx_runtime_1.jsxs)("div", Object.assign({ css:
99
- // topPX(81) is the offset from the header
100
- Css_1.Css.fg1.topPx(81).left0.right0.bottom0.absolute.bgWhite.df.aic.jcc.fg1.fdc.z5.$ }, { children: [modalState.current.content, (0, jsx_runtime_1.jsx)("div", { ref: modalBodyRef }, void 0), (0, jsx_runtime_1.jsx)("div", { ref: modalFooterRef }, void 0)] }), void 0))] }, void 0) }), "superDrawerContainer"))] }, void 0)) }, void 0), document.body);
94
+ (0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.fg1.top0.left0.right0.bottom0.absolute.bgWhite.df.aic.jcc.fg1.fdc.z5.$ }, { children: [modalState.current.content, (0, jsx_runtime_1.jsx)("div", { ref: modalBodyRef }, void 0), (0, jsx_runtime_1.jsx)("div", { ref: modalFooterRef }, void 0)] }), void 0))] }, void 0) }), "superDrawerContainer"))] }, void 0)) }, void 0), document.body);
101
95
  }
102
96
  exports.SuperDrawer = SuperDrawer;
@@ -1,65 +1,12 @@
1
- import { MutableRefObject, ReactElement, ReactNode } from "react";
2
- import { PresentationContextProps, PresentationFieldProps } from "../PresentationContext";
3
- import { GridRowLookup } from "./GridRowLookup";
1
+ import { MutableRefObject } from "react";
4
2
  import { GridTableApi } from "./GridTableApi";
5
- import { GridStyleDef } from "./styles";
6
- import { Margin, Only, Palette, Properties, Typography, Xss } from "../../Css";
7
- export declare type Kinded = {
8
- kind: string;
9
- };
10
- export declare type GridTableXss = Xss<Margin>;
11
- export declare const ASC: "ASC";
12
- export declare const DESC: "DESC";
13
- export declare type Direction = "ASC" | "DESC";
14
- export declare const emptyCell: GridCellContent;
3
+ import { GridStyle, GridStyleDef, RowStyles } from "./TableStyles";
4
+ import { Direction, GridColumn, GridTableXss, Kinded, ParentChildrenTuple, RenderAs } from "./types";
5
+ import { GridRowLookup } from "./utils/GridRowLookup";
6
+ import { Only } from "../../Css";
7
+ import { GridDataRow } from "./components/Row";
15
8
  /** Tells GridTable we're running in Jest, which forces as=virtual to be as=div, to work in jsdom. */
16
9
  export declare function setRunningInJest(): void;
17
- /** Completely static look & feel, i.e. nothing that is based on row kinds/content. */
18
- export interface GridStyle {
19
- /** Applied to the base div element. */
20
- rootCss?: Properties;
21
- /** Applied with the owl operator between rows for rendering border lines. */
22
- betweenRowsCss?: Properties;
23
- /** Applied to the first non-header row, i.e. if you want to cancel out `betweenRowsCss`. */
24
- firstNonHeaderRowCss?: Properties;
25
- /** Applied to all cell divs (via a selector off the base div). */
26
- cellCss?: Properties;
27
- /**
28
- * Applied to the header row divs.
29
- *
30
- * NOTE `as=virtual`: When using a virtual table with the goal of adding space
31
- * between the header and the first row use `firstNonHeaderRowCss` with a
32
- * margin-top instead. Using `headerCellCss` will not work since the header
33
- * rows are wrapper with Chrome rows.
34
- */
35
- headerCellCss?: Properties;
36
- /** Applied to 'kind: "totals"' cells */
37
- totalsCellCss?: Properties;
38
- /** Applied to the first cell of all rows, i.e. for table-wide padding or left-side borders. */
39
- firstCellCss?: Properties;
40
- /** Applied to the last cell of all rows, i.e. for table-wide padding or right-side borders. */
41
- lastCellCss?: Properties;
42
- /** Applied to a cell div when `indent: 1` is used. */
43
- indentOneCss?: Properties;
44
- /** Applied to a cell div when `indent: 2` is used. */
45
- indentTwoCss?: Properties;
46
- /** Applied if there is a fallback/overflow message showing. */
47
- firstRowMessageCss?: Properties;
48
- /** Applied on hover if a row has a rowLink/onClick set. */
49
- rowHoverColor?: Palette;
50
- /** Default content to put into an empty cell */
51
- emptyCell?: ReactNode;
52
- presentationSettings?: Pick<PresentationFieldProps, "borderless" | "typeScale"> & Pick<PresentationContextProps, "wrap">;
53
- /** Minimum table width in pixels. Used when calculating columns sizes */
54
- minWidthPx?: number;
55
- /** Css to apply at each level of a parent/child nested table. */
56
- levels?: Record<number, {
57
- cellCss?: Properties;
58
- firstContentColumn?: Properties;
59
- }>;
60
- /** Allows for customization of the background color used to denote an "active" row */
61
- activeBgColor?: Palette;
62
- }
63
10
  export interface GridTableDefaults {
64
11
  style: GridStyle | GridStyleDef;
65
12
  stickyHeader: boolean;
@@ -68,9 +15,6 @@ export interface GridTableDefaults {
68
15
  export declare function setDefaultStyle(style: GridStyle): void;
69
16
  /** Configures the default/app-wide GridTable settings. */
70
17
  export declare function setGridTableDefaults(opts: Partial<GridTableDefaults>): void;
71
- declare type RenderAs = "div" | "table" | "virtual";
72
- /** The GridDataRow is optional b/c the nested card chrome rows only have ReactElements. */
73
- export declare type RowTuple<R extends Kinded> = [GridDataRow<R> | undefined, ReactElement];
74
18
  /**
75
19
  * The sort settings for the current table; whether it's client-side or server-side.
76
20
  *
@@ -117,7 +61,7 @@ export interface GridTableProps<R extends Kinded, S, X> {
117
61
  /** The rows of data (including any header/footer rows), to be rendered by the column definitions. */
118
62
  rows: GridDataRow<R>[];
119
63
  /** Optional row-kind-level styling / behavior like onClick/rowLinks. */
120
- rowStyles?: GridRowStyles<R>;
64
+ rowStyles?: RowStyles<R>;
121
65
  /** Allow looking up prev/next of a row i.e. for SuperDrawer navigation. */
122
66
  rowLookup?: MutableRefObject<GridRowLookup<R> | undefined>;
123
67
  /** Whether the header row should be sticky. */
@@ -179,161 +123,10 @@ export interface GridTableProps<R extends Kinded, S, X> {
179
123
  */
180
124
  export declare function GridTable<R extends Kinded, S = {}, X extends Only<GridTableXss, X> = {}>(props: GridTableProps<R, S, X>): import("@emotion/react/jsx-runtime").JSX.Element;
181
125
  /**
182
- * Calculates column widths using a flexible `calc()` definition that allows for consistent column alignment without the use of `<table />`, CSS Grid, etc layouts.
183
- * Enforces only fixed-sized units (% and px)
184
- */
185
- export declare function calcColumnSizes(columns: GridColumn<any>[], tableWidth: number | undefined, tableMinWidthPx?: number): string[];
186
- /**
187
- * Given an ADT of type T, performs a look up and returns the type of kind K.
188
- *
189
- * See https://stackoverflow.com/a/50125960/355031
190
- */
191
- export declare type DiscriminateUnion<T, K extends keyof T, V extends T[K]> = T extends Record<K, V> ? T : never;
192
- /** A specific kind of row, including the GridDataRow props. */
193
- declare type GridRowKind<R extends Kinded, P extends R["kind"]> = DiscriminateUnion<R, "kind", P> & {
194
- id: string;
195
- children: GridDataRow<R>[];
196
- selectable?: false;
197
- };
198
- /**
199
- * Defines how a single column will render each given row `kind` in `R`.
200
- *
201
- * The `S` generic is either:
202
- *
203
- * - For server-side sorting, it's the sortKey to pass back to the server to
204
- * request "sort by this column".
205
- *
206
- * - For client-side sorting, it's type `number`, to represent the current
207
- * column being sorted, in which case we use the GridCellContent.value.
208
- */
209
- export declare type GridColumn<R extends Kinded, S = {}> = {
210
- [K in R["kind"]]: string | GridCellContent | (DiscriminateUnion<R, "kind", K> extends {
211
- data: infer D;
212
- } ? (data: D, opts: {
213
- row: GridRowKind<R, K>;
214
- api: GridTableApi<R>;
215
- level: number;
216
- }) => ReactNode | GridCellContent : (data: undefined, opts: {
217
- row: GridRowKind<R, K>;
218
- api: GridTableApi<R>;
219
- level: number;
220
- }) => ReactNode | GridCellContent);
221
- } & {
222
- /**
223
- * The column's width.
224
- * - Only px, percentage, or fr units are supported, due to each GridRow acting as an independent table. This ensures consistent alignment between rows.
225
- * - Numbers are treated as `fr` units
226
- * - The default value is `1fr`
227
- */
228
- w?: number | string;
229
- /** The minimum width the column can shrink to */
230
- mw?: string;
231
- /** The column's default alignment for each cell. */
232
- align?: GridCellAlignment;
233
- /** Whether the column can be sorted (if client-side sorting). Defaults to true if sorting client-side. */
234
- clientSideSort?: boolean;
235
- /** This column's sort by value (if server-side sorting). */
236
- serverSideSortKey?: S;
237
- /** Allows the column to stay in place when the user scrolls horizontally */
238
- sticky?: "left" | "right";
239
- /** Prevent column from supporting RowStyle.onClick/rowLink in order to avoid nested interactivity. Defaults to true */
240
- wrapAction?: false;
241
- /** Used as a signal to defer adding the 'indent' styling */
242
- isAction?: true;
243
- /** Column name that will be used to generate an unique identifier for every row cell */
244
- name?: string;
245
- /** Flag that will allow to know which columns are hide-able */
246
- canHide?: boolean;
247
- /** Flag that will allow to know which hide-able columns are visible on initial load */
248
- initVisible?: boolean;
249
- };
250
- export declare const nonKindGridColumnKeys: string[];
251
- /** Allows rendering a specific cell. */
252
- declare type RenderCellFn<R extends Kinded> = (idx: number, css: Properties, content: ReactNode, row: R, rowStyle: RowStyle<R> | undefined, classNames: string | undefined, onClick: (() => void) | undefined) => ReactNode;
253
- /** Defines row-specific styling for each given row `kind` in `R` */
254
- export declare type GridRowStyles<R extends Kinded> = {
255
- [P in R["kind"]]?: RowStyle<DiscriminateUnion<R, "kind", P>>;
256
- };
257
- export interface RowStyle<R extends Kinded> {
258
- /** Applies this css to the wrapper row, i.e. for row-level hovers. */
259
- rowCss?: Properties | ((row: R) => Properties);
260
- /** Applies this css to each cell in the row. */
261
- cellCss?: Properties | ((row: R) => Properties);
262
- /** Renders the cell element, i.e. a link to get whole-row links. */
263
- renderCell?: RenderCellFn<R>;
264
- /** Whether the row should be indented (via a style applied to the 1st cell). */
265
- indent?: 1 | 2;
266
- /** Whether the row should be a link. */
267
- rowLink?: (row: R) => string;
268
- /** Fired when the row is clicked, similar to rowLink but for actions that aren't 'go to this link'. */
269
- onClick?: (row: GridDataRow<R>, api: GridTableApi<R>) => void;
270
- }
271
- export declare type GridCellAlignment = "left" | "right" | "center";
272
- /**
273
- * Allows a cell to be more than just a RectNode, i.e. declare its alignment or
274
- * primitive value for filtering and sorting.
275
- */
276
- export declare type GridCellContent = {
277
- /** The JSX content of the cell. Virtual tables that client-side sort should use a function to avoid perf overhead. */
278
- content: ReactNode | (() => ReactNode);
279
- alignment?: GridCellAlignment;
280
- /** Allow value to be a function in case it's a dynamic value i.e. reading from an inline-edited proxy. */
281
- value?: MaybeFn<number | string | Date | boolean | null | undefined>;
282
- /** The value to use specifically for sorting (i.e. if `value` is used for filtering); defaults to `value`. */
283
- sortValue?: MaybeFn<number | string | Date | boolean | null | undefined>;
284
- /** Whether to indent the cell. */
285
- indent?: 1 | 2;
286
- colspan?: number;
287
- typeScale?: Typography;
288
- /** Allows the cell to stay in place when the user scrolls horizontally, i.e. frozen columns. */
289
- sticky?: "left" | "right";
290
- /** If provided, content of the cell will be wrapped within a <button /> or <a /> tag depending on if the value is a function or a string. */
291
- onClick?: () => {} | string;
292
- /** Custom css to apply directly to this cell, i.e. cell-specific borders. */
293
- css?: Properties;
294
- /** Allows cell to reveal content when the user hovers over a row. Content must be wrapped in an element in order to be hidden. IE <div>{value}</div>*/
295
- revealOnRowHover?: true;
296
- };
297
- declare type MaybeFn<T> = T | (() => T);
298
- /**
299
- * The data for any row in the table, marked by `kind` so that each column knows how to render it.
126
+ * Filters rows given a client-side text `filter.
300
127
  *
301
- * Each `kind` should contain very little presentation logic, i.e. mostly just off-the-wire data from
302
- * a GraphQL query.
128
+ * Ensures parent rows remain in the list if any children match the filter.
303
129
  *
304
- * The presentation concerns instead mainly live in each GridColumn definition, which will format/render
305
- * each kind's data for that specific row+column (i.e. cell) combination.
130
+ * We return a copy of `[Parent, [Child]]` tuples so that we don't modify the `GridDataRow.children`.
306
131
  */
307
- export declare type GridDataRow<R extends Kinded> = {
308
- kind: R["kind"];
309
- /** Combined with the `kind` to determine a table wide React key. */
310
- id: string;
311
- /** A list of parent/grand-parent ids for collapsing parent/child rows. */
312
- children?: GridDataRow<R>[];
313
- /** * Whether to pin this sort to the first/last of its parent's children.
314
- *
315
- * By default, pinned rows are always shown/not filtered out, however providing
316
- * the pin `filter: true` property will allow pinned rows to be hidden
317
- * while filtering.*/
318
- pin?: "first" | "last" | Pin;
319
- data: unknown;
320
- /** Whether to have the row collapsed (children not visible) on initial load. This will be ignore in subsequent re-renders of the table */
321
- initCollapsed?: boolean;
322
- /** Whether to have the row selected on initial load. This will be ignore in subsequent re-renders of the table */
323
- initSelected?: boolean;
324
- /** Whether row can be selected */
325
- selectable?: false;
326
- } & IfAny<R, {}, DiscriminateUnion<R, "kind", R["kind"]>>;
327
- /**
328
- * Used to indicate where to pin the DataRow and if whether it should be filtered or always visible, setting `filter` to `true` will hide this row
329
- * if it doesn't match the provided filtering search term
330
- */
331
- export declare type Pin = {
332
- at: "first" | "last";
333
- filter?: boolean;
334
- };
335
- declare type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N;
336
- /** Return the content for a given column def applied to a given row. */
337
- export declare function applyRowFn<R extends Kinded>(column: GridColumn<R>, row: GridDataRow<R>, api: GridTableApi<R>, level: number): ReactNode | GridCellContent;
338
- export declare function matchesFilter(maybeContent: ReactNode | GridCellContent, filter: string): boolean;
339
- export {};
132
+ export declare function filterRows<R extends Kinded>(api: GridTableApi<R>, columns: GridColumn<R>[], rows: GridDataRow<R>[], filter: string | undefined): ParentChildrenTuple<R>[];