@homebound/beam 2.226.0 → 2.227.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.
@@ -20,6 +20,8 @@ interface FilterProps<F, G extends Value = string> {
20
20
  };
21
21
  /** Specifies the layout of the filters. If not supplied it will use the default (horizontal) layout. Using the 'vertical' layout will also remove the "More Filters" button/modal */
22
22
  vertical?: boolean;
23
+ /** Specifies the number of in line filters before more filters modal */
24
+ numberOfInlineFilters?: number;
23
25
  }
24
26
  declare function Filters<F, G extends Value = string>(props: FilterProps<F, G>): import("@emotion/react/jsx-runtime").JSX.Element;
25
27
  declare const _Filters: typeof Filters;
@@ -10,24 +10,23 @@ const Css_1 = require("../../Css");
10
10
  const SelectField_1 = require("../../inputs/SelectField");
11
11
  const utils_1 = require("../../utils");
12
12
  function Filters(props) {
13
- const { filter, onChange, filterDefs, groupBy, vertical = false } = props;
13
+ const { filter, onChange, filterDefs, groupBy, vertical = false, numberOfInlineFilters = groupBy ? 3 : 4 } = props;
14
14
  const testId = (0, utils_1.useTestIds)(props, Filters_1.filterTestIdPrefix);
15
15
  const { openModal } = (0, Modal_1.useModal)();
16
- const numberOfPageFilters = groupBy ? 2 : 3;
17
16
  const [pageFilters, modalFilters] = (0, react_1.useMemo)(() => {
18
17
  // Take the FilterDefs that have a `key => ...` factory and eval it
19
18
  const impls = (0, utils_1.safeEntries)(filterDefs).map(([key, fn]) => [key, fn(key)]);
20
- // If we have more than 4 filters,
21
- if (!vertical && impls.length > numberOfPageFilters + 1) {
22
- // Then return the first three to show on the page, and the remainder for the modal.
19
+ // If we have more than numberOfInlineFilters depending on groupby,
20
+ if (!vertical && impls.length > numberOfInlineFilters) {
21
+ // Then return up to the numberOfInlineFilters, and the remainder in the modal.
23
22
  return [
24
- Object.fromEntries(impls.slice(0, numberOfPageFilters)),
25
- Object.fromEntries(impls.slice(numberOfPageFilters)),
23
+ Object.fromEntries(impls.slice(0, numberOfInlineFilters)),
24
+ Object.fromEntries(impls.slice(numberOfInlineFilters)),
26
25
  ];
27
26
  }
28
27
  // Otherwise, we don't have enough to show the modal, so only use page filter keys
29
28
  return [Object.fromEntries(impls), {}];
30
- }, [numberOfPageFilters, filterDefs]);
29
+ }, [numberOfInlineFilters, filterDefs]);
31
30
  const numModalFilters = (0, utils_1.safeKeys)(modalFilters).filter((fk) => filter[fk] !== undefined).length;
32
31
  const maybeGroupByField = groupBy ? ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(SelectField_1.SelectField, { label: "Group by", compact: !vertical, inlineLabel: !vertical, sizeToContent: !vertical, options: groupBy.options, getOptionValue: (o) => o.id, getOptionLabel: (o) => o.name, value: groupBy.value, onSelect: (g) => g && groupBy.setValue(g) }, void 0) }, void 0)) : null;
33
32
  // Return list of filter components. `onSelect` should update the `filter`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.226.0",
3
+ "version": "2.227.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",