@homebound/beam 2.159.0 → 2.161.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.
@@ -40,5 +40,5 @@ function AutoSaveIndicator({ hideOnIdle, doNotReset }) {
40
40
  }
41
41
  exports.AutoSaveIndicator = AutoSaveIndicator;
42
42
  function Indicator({ text, icon, color }) {
43
- return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.df.gap1.aic.gray700.smEm.$ }, { children: [(0, jsx_runtime_1.jsx)(Icon_1.Icon, { icon: icon, color: color }, void 0), text] }), void 0));
43
+ return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ "data-testid": "autoSave", css: Css_1.Css.df.gap1.aic.gray700.smEm.$ }, { children: [(0, jsx_runtime_1.jsx)(Icon_1.Icon, { icon: icon, color: color }, void 0), text] }), void 0));
44
44
  }
@@ -1,5 +1,5 @@
1
1
  import { Margin, Only, Xss } from "../Css";
2
- declare type ChipType = "caution" | "warning" | "success" | "neutral";
2
+ declare type ChipType = "caution" | "warning" | "success" | "light" | "dark" | "neutral";
3
3
  export declare const ChipTypes: Record<ChipType, ChipType>;
4
4
  export interface ChipProps<X> {
5
5
  text: string;
@@ -10,6 +10,8 @@ exports.ChipTypes = {
10
10
  caution: "caution",
11
11
  warning: "warning",
12
12
  success: "success",
13
+ light: "light",
14
+ dark: "dark",
13
15
  neutral: "neutral",
14
16
  };
15
17
  /** Kinda like a chip, but read-only, so no `onClick` or `hover`. */
@@ -29,5 +31,7 @@ const typeStyles = {
29
31
  caution: Css_1.Css.bgYellow200.$,
30
32
  warning: Css_1.Css.bgRed100.$,
31
33
  success: Css_1.Css.bgGreen100.$,
34
+ light: Css_1.Css.bgWhite.$,
35
+ dark: Css_1.Css.bgGray900.white.$,
32
36
  neutral: Css_1.Css.bgGray200.$,
33
37
  };
@@ -333,14 +333,26 @@ export declare type GridDataRow<R extends Kinded> = {
333
333
  id: string;
334
334
  /** A list of parent/grand-parent ids for collapsing parent/child rows. */
335
335
  children?: GridDataRow<R>[];
336
- /** Whether to pin this sort to the first/last of its parent's children. */
337
- pin?: "first" | "last";
336
+ /** * Whether to pin this sort to the first/last of its parent's children.
337
+ *
338
+ * By default, pinned rows are always shown/not filtered out, however providing
339
+ * the pin `filter: true` property will allow pinned rows to be hidden
340
+ * while filtering.*/
341
+ pin?: "first" | "last" | Pin;
338
342
  data: unknown;
339
343
  /** Whether to have the row collapsed (children not visible) on initial load. This will be ignore in subsequent re-renders of the table */
340
344
  initCollapsed?: boolean;
341
345
  /** Whether row can be selected */
342
346
  selectable?: false;
343
347
  } & IfAny<R, {}, DiscriminateUnion<R, "kind", R["kind"]>>;
348
+ /**
349
+ * 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
350
+ * if it doesn't match the provided filtering search term
351
+ */
352
+ export declare type Pin = {
353
+ at: "first" | "last";
354
+ filter?: boolean;
355
+ };
344
356
  declare type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N;
345
357
  /** Return the content for a given column def applied to a given row. */
346
358
  export declare function applyRowFn<R extends Kinded>(column: GridColumn<R>, row: GridDataRow<R>, api: GridTableApi<R>, level: number): ReactNode | GridCellContent;
@@ -822,7 +822,9 @@ function filterRows(api, columns, rows, filter) {
822
822
  }
823
823
  else {
824
824
  const matchedChildren = (_d = (_c = row.children) === null || _c === void 0 ? void 0 : _c.reduce(filterFn, [])) !== null && _d !== void 0 ? _d : [];
825
- if (matchedChildren.length > 0 || row.pin) {
825
+ if (matchedChildren.length > 0 ||
826
+ typeof row.pin === "string" ||
827
+ (row.pin !== undefined && row.pin.filter !== true)) {
826
828
  return acc.concat([[row, matchedChildren]]);
827
829
  }
828
830
  else {
@@ -27,8 +27,10 @@ function sortBatch(columns, batch, sortState, caseSensitive) {
27
27
  // If both rows are pinned, we don't sort within them, because by pinning the page is taking
28
28
  // explicit ownership over the order of the rows (and we also don't support "levels of pins",
29
29
  // i.e. for change events putting "just added" rows `pin: last` and the "add new" row `pin: lastest`).
30
- const ap = a.pin === "first" ? -1 : a.pin === "last" ? 1 : 0;
31
- const bp = b.pin === "first" ? -1 : b.pin === "last" ? 1 : 0;
30
+ const aPin = getPin(a.pin);
31
+ const bPin = getPin(b.pin);
32
+ const ap = aPin === "first" ? -1 : aPin === "last" ? 1 : 0;
33
+ const bp = bPin === "first" ? -1 : bPin === "last" ? 1 : 0;
32
34
  return ap === bp ? 0 : ap < bp ? -1 : 1;
33
35
  }
34
36
  else if (primaryColumn) {
@@ -42,6 +44,9 @@ function sortBatch(columns, batch, sortState, caseSensitive) {
42
44
  return compare(column, a, b, invert, caseSensitive);
43
45
  });
44
46
  }
47
+ function getPin(pin) {
48
+ return typeof pin === "string" ? pin : pin === null || pin === void 0 ? void 0 : pin.at;
49
+ }
45
50
  function compare(column, a, b, invert, caseSensitive) {
46
51
  const v1 = sortValue((0, GridTable_1.applyRowFn)(column, a, {}, 0), caseSensitive);
47
52
  const v2 = sortValue((0, GridTable_1.applyRowFn)(column, b, {}, 0), caseSensitive);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.159.0",
3
+ "version": "2.161.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",