@homebound/beam 3.20.1 → 3.21.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.
package/dist/index.cjs CHANGED
@@ -5888,7 +5888,12 @@ var iconButtonOutline = {
5888
5888
  borderRadius: "br8",
5889
5889
  width: "w_48px",
5890
5890
  height: "h_40px",
5891
- borderColor: "bcGray300",
5891
+ backgroundColor: ["bgColor_var", {
5892
+ "--backgroundColor": "var(--b-surface)"
5893
+ }],
5894
+ borderColor: ["bc_var", {
5895
+ "--borderColor": "var(--b-surface-separator)"
5896
+ }],
5892
5897
  borderStyle: "bss",
5893
5898
  borderWidth: "bw1",
5894
5899
  display: "df",
@@ -19325,7 +19330,7 @@ function invertSpacing(value) {
19325
19330
  }
19326
19331
 
19327
19332
  // src/components/Layout/GridTableLayout/GridTableLayout.tsx
19328
- var import_utils117 = require("@react-aria/utils");
19333
+ var import_utils120 = require("@react-aria/utils");
19329
19334
  var import_react103 = __toESM(require("react"), 1);
19330
19335
 
19331
19336
  // src/components/ButtonMenu.tsx
@@ -19444,6 +19449,12 @@ var DateFilter = class extends BaseFilter {
19444
19449
  dehydrate(value) {
19445
19450
  return value ? { op: value.op, value: dehydratePlainDate(value.value) } : void 0;
19446
19451
  }
19452
+ formatSelectedFilterLabel(value) {
19453
+ const { operations, getOperationValue, getOperationLabel } = this.props;
19454
+ const operation = operations.find((o) => getOperationValue(o) === value.op);
19455
+ const opLabel = operation ? getOperationLabel(operation) : String(value.op);
19456
+ return `${opLabel} ${formatDate(value.value, "date")}`;
19457
+ }
19447
19458
  render(value, setValue, tid, inModal, vertical) {
19448
19459
  const { label, operations, getOperationValue, getOperationLabel, defaultValue } = this.props;
19449
19460
  return /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)(import_jsx_runtime129.Fragment, { children: [
@@ -19511,6 +19522,10 @@ var DateRangeFilter = class extends BaseFilter {
19511
19522
  value: value.value ? { from: dehydratePlainDate(value.value.from), to: dehydratePlainDate(value.value.to) } : void 0
19512
19523
  } : void 0;
19513
19524
  }
19525
+ formatSelectedFilterLabel(value) {
19526
+ const formatted = formatDateRange(value.value, "date");
19527
+ return formatted ? formatted : void 0;
19528
+ }
19514
19529
  render(value, setValue, tid, inModal, vertical) {
19515
19530
  const { label, placeholderText, disabledDays, testFieldLabel, defaultValue } = this.props;
19516
19531
  return /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(import_jsx_runtime130.Fragment, { children: [
@@ -19552,12 +19567,34 @@ function hydrateDateRange(value) {
19552
19567
  return { from: hydratedFrom, to: hydratedTo };
19553
19568
  }
19554
19569
 
19570
+ // src/components/Filters/selectedFilterLabelUtils.ts
19571
+ function resolveOptionSelectedFilterLabel(optionsOrLoad, getOptionValue, getOptionLabel, value) {
19572
+ const options = initializeOptions(optionsOrLoad, getOptionValue, getOptionLabel, void 0, false, false);
19573
+ const match = options.find((o) => getOptionValue(o) === value);
19574
+ return match ? getOptionLabel(match) : String(value);
19575
+ }
19576
+ function resolveTreeSelectedFilterLabel(optionsOrLoad, getOptionValue, getOptionLabel, value) {
19577
+ const options = resolveNestedOptions(optionsOrLoad);
19578
+ const match = options.flatMap(flattenOptions).find((o) => getOptionValue(o) === value);
19579
+ return match ? getOptionLabel(match) : String(value);
19580
+ }
19581
+ function resolveNestedOptions(optionsOrLoad) {
19582
+ if (Array.isArray(optionsOrLoad)) {
19583
+ return optionsOrLoad;
19584
+ }
19585
+ return optionsOrLoad.current ?? [];
19586
+ }
19587
+
19555
19588
  // src/components/Filters/MultiFilter.tsx
19556
19589
  var import_jsx_runtime131 = require("react/jsx-runtime");
19557
19590
  function multiFilter(props) {
19558
19591
  return (key) => new MultiFilter(key, props);
19559
19592
  }
19560
19593
  var MultiFilter = class extends BaseFilter {
19594
+ formatSelectedFilterLabel(value) {
19595
+ const { options, getOptionValue, getOptionLabel } = this.props;
19596
+ return resolveOptionSelectedFilterLabel(options, getOptionValue, getOptionLabel, value);
19597
+ }
19561
19598
  render(value, setValue, tid, inModal, vertical) {
19562
19599
  if (inModal && Array.isArray(this.props.options) && this.props.options.length > 0 && this.props.options.length <= 8) {
19563
19600
  const { disabledOptions } = this.props;
@@ -19611,6 +19648,10 @@ function numberRangeFilter(props) {
19611
19648
  return (key) => new NumberRangeFilter(key, props);
19612
19649
  }
19613
19650
  var NumberRangeFilter = class extends BaseFilter {
19651
+ formatSelectedFilterLabel(value) {
19652
+ const parts = [value.min, value.max].filter((n) => n !== void 0);
19653
+ return parts.length > 0 ? parts.join(" \u2013 ") : void 0;
19654
+ }
19614
19655
  render(value, setValue, tid, inModal, vertical) {
19615
19656
  const {
19616
19657
  label,
@@ -19685,6 +19726,10 @@ function singleFilter(props) {
19685
19726
  }
19686
19727
  var allOption = {};
19687
19728
  var SingleFilter = class extends BaseFilter {
19729
+ formatSelectedFilterLabel(value) {
19730
+ const { options, getOptionValue, getOptionLabel } = this.props;
19731
+ return resolveOptionSelectedFilterLabel(options, getOptionValue, getOptionLabel, value);
19732
+ }
19688
19733
  render(value, setValue, tid, inModal, vertical) {
19689
19734
  const {
19690
19735
  label,
@@ -19721,6 +19766,10 @@ function treeFilter(props) {
19721
19766
  return (key) => new TreeFilter(key, props);
19722
19767
  }
19723
19768
  var TreeFilter = class extends BaseFilter {
19769
+ formatSelectedFilterLabel(value) {
19770
+ const { options, getOptionValue, getOptionLabel } = this.props;
19771
+ return resolveTreeSelectedFilterLabel(options, getOptionValue, getOptionLabel, value);
19772
+ }
19724
19773
  render(value, setValue, tid, inModal, vertical) {
19725
19774
  const { defaultValue, nothingSelectedText, filterBy = "root", ...props } = this.props;
19726
19775
  return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
@@ -19748,6 +19797,11 @@ function booleanFilter(props) {
19748
19797
  return (key) => new BooleanFilter(key, props);
19749
19798
  }
19750
19799
  var BooleanFilter = class extends BaseFilter {
19800
+ formatSelectedFilterLabel(value) {
19801
+ const { options = defaultBooleanOptions } = this.props;
19802
+ const match = options.find(([optionValue]) => optionValue === value);
19803
+ return match ? match[1] : String(value);
19804
+ }
19751
19805
  render(value, setValue, tid, inModal, vertical) {
19752
19806
  const { options = defaultBooleanOptions, label, defaultValue, ...props } = this.props;
19753
19807
  return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
@@ -19786,6 +19840,10 @@ function checkboxFilter(props) {
19786
19840
  });
19787
19841
  }
19788
19842
  var CheckboxFilter = class extends BaseFilter {
19843
+ formatSelectedFilterLabel(value) {
19844
+ const { onValue = true } = this.props;
19845
+ return value === onValue ? this.label : void 0;
19846
+ }
19789
19847
  render(value, setValue, tid, inModal, vertical) {
19790
19848
  const { defaultValue, onValue = true, offValue = void 0, ...props } = this.props;
19791
19849
  return /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(
@@ -19940,6 +19998,10 @@ function toggleFilter(props) {
19940
19998
  });
19941
19999
  }
19942
20000
  var ToggleFilter = class extends BaseFilter {
20001
+ formatSelectedFilterLabel(value) {
20002
+ const { onValue = true } = this.props;
20003
+ return value === onValue ? this.label : void 0;
20004
+ }
19943
20005
  render(value, setValue, tid, inModal, vertical) {
19944
20006
  const { defaultValue, onValue = true, offValue = void 0, ...props } = this.props;
19945
20007
  return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
@@ -20034,24 +20096,11 @@ function FilterDropdownMenu(props) {
20034
20096
  opacity: "o0"
20035
20097
  } : {}
20036
20098
  }), children: searchTextField }),
20037
- sm && hasSearch && /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(Button, { label: "", "aria-label": "Search", icon: "search", onClick: () => setSearchIsOpen(!searchIsOpen), active: searchIsOpen, variant: "secondaryBlack", ...testId.searchButton }),
20038
- hasFilters && /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(Button, { label: sm ? "" : "Filter", "aria-label": "Filter", icon: "filter", size: "md", endAdornment: /* @__PURE__ */ (0, import_jsx_runtime141.jsxs)("div", { className: "df aic gap1", children: [
20099
+ sm && hasSearch && /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(IconButton, { variant: "outline", icon: "search", label: "Search", onClick: () => setSearchIsOpen(!searchIsOpen), active: searchIsOpen, ...testId.searchButton }),
20100
+ sm && hasFilters && /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(IconButton, { variant: "outline", icon: "filter", label: "Filter", active: isOpen, onClick: () => setIsOpen(!isOpen), ...testId.button }),
20101
+ !sm && hasFilters && /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(Button, { label: "Filter", icon: "filter", size: "md", endAdornment: /* @__PURE__ */ (0, import_jsx_runtime141.jsxs)("div", { className: "df aic gap1", children: [
20039
20102
  activeFilterCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(CountBadge, { count: activeFilterCount }),
20040
- /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(Icon, { xss: {
20041
- ...sm ? {
20042
- position: "absolute",
20043
- overflow: "oh",
20044
- clip: "cli_inset_50",
20045
- clipPath: "clp_none",
20046
- border: "bd_0",
20047
- height: "h_1px",
20048
- margin: "m_neg1px",
20049
- width: "w_1px",
20050
- padding: "p_0",
20051
- whiteSpace: "wsnw",
20052
- opacity: "o0"
20053
- } : {}
20054
- }, icon: isOpen ? "chevronUp" : "chevronDown" })
20103
+ /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(Icon, { icon: isOpen ? "chevronUp" : "chevronDown" })
20055
20104
  ] }), variant: "secondaryBlack", onClick: () => setIsOpen(!isOpen), active: isOpen, ...testId.button }),
20056
20105
  searchIsOpen && /* @__PURE__ */ (0, import_jsx_runtime141.jsx)("div", { ...(0, import_runtime75.trussProps)({
20057
20106
  width: "w100",
@@ -20084,30 +20133,32 @@ function FilterChips({
20084
20133
  onClear,
20085
20134
  testId
20086
20135
  }) {
20087
- const chips = safeEntries(filterImpls).flatMap(([key]) => {
20088
- const value = filter[key];
20089
- if (!isDefined(value)) return [];
20090
- if (Array.isArray(value)) {
20091
- return value.map((item) => {
20092
- const chipKey = `${String(key)}_${item}`;
20093
- const newArray = value.filter((v) => v !== item);
20094
- return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(ToggleChip, { text: titleCase(String(item)), onClick: () => onChange(updateFilter(filter, key, newArray.length > 0 ? newArray : void 0)), ...testId[`chip_${chipKey}`] }, chipKey);
20095
- });
20096
- }
20097
- return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(ToggleChip, { text: titleCase(String(value)), onClick: () => onChange(updateFilter(filter, key, void 0)), ...testId[`chip_${String(key)}`] }, String(key));
20098
- });
20136
+ const chips = safeEntries(filterImpls).flatMap(([key, f]) => chipsForFilterKey(key, f, filter, onChange, testId));
20099
20137
  if (chips.length === 0) return null;
20100
20138
  return /* @__PURE__ */ (0, import_jsx_runtime141.jsxs)("div", { className: "df gap1 fww aic order_1", children: [
20101
20139
  chips,
20102
20140
  /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(Button, { label: "Clear", variant: "tertiary", onClick: onClear, ...testId.clearBtn })
20103
20141
  ] });
20104
20142
  }
20143
+ function chipsForFilterKey(key, f, filter, onChange, testId) {
20144
+ const value = filter[key];
20145
+ if (!isDefined(value)) return [];
20146
+ if (Array.isArray(value)) {
20147
+ return value.flatMap((item) => {
20148
+ const label2 = f.formatSelectedFilterLabel(item);
20149
+ if (!isDefined(label2)) return [];
20150
+ const chipKey = `${String(key)}_${item}`;
20151
+ const newArray = value.filter((v) => v !== item);
20152
+ return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(ToggleChip, { text: label2, onClick: () => onChange(updateFilter(filter, key, newArray.length > 0 ? newArray : void 0)), ...testId[`chip_${chipKey}`] }, chipKey);
20153
+ });
20154
+ }
20155
+ const label = f.formatSelectedFilterLabel(value);
20156
+ if (!isDefined(label)) return [];
20157
+ return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(ToggleChip, { text: label, onClick: () => onChange(updateFilter(filter, key, void 0)), ...testId[`chip_${String(key)}`] }, String(key));
20158
+ }
20105
20159
  function buildFilterImpls(filterDefs) {
20106
20160
  return Object.fromEntries(safeEntries(filterDefs).map(([key, fn]) => [key, fn(key)]));
20107
20161
  }
20108
- function titleCase(str) {
20109
- return str.split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
20110
- }
20111
20162
  function getActiveFilterCount(filter) {
20112
20163
  return safeKeys(filter).filter((key) => filter[key] !== void 0).length;
20113
20164
  }
@@ -20587,7 +20638,7 @@ function useSetTableActionsHeight(tableWrapperRef, tableActionsRef, enabled) {
20587
20638
  tableWrapper.style.removeProperty(beamTableActionsHeightVar);
20588
20639
  }
20589
20640
  }, [enabled, tableActionsRef, tableWrapperRef]);
20590
- (0, import_utils117.useResizeObserver)({
20641
+ (0, import_utils120.useResizeObserver)({
20591
20642
  ref: tableActionsRef,
20592
20643
  onResize: enabled ? syncHeightVar : noop
20593
20644
  });
@@ -21223,7 +21274,7 @@ var import_react111 = require("react");
21223
21274
  var import_react_aria49 = require("react-aria");
21224
21275
 
21225
21276
  // src/components/Tag.tsx
21226
- var import_utils124 = require("@react-aria/utils");
21277
+ var import_utils127 = require("@react-aria/utils");
21227
21278
  var import_react110 = require("react");
21228
21279
  var import_runtime83 = require("@homebound/truss/runtime");
21229
21280
  var import_jsx_runtime158 = require("react/jsx-runtime");
@@ -21239,7 +21290,7 @@ function Tag(props) {
21239
21290
  const tid = useTestIds(otherProps);
21240
21291
  const [showTooltip, setShowTooltip] = (0, import_react110.useState)(false);
21241
21292
  const ref = (0, import_react110.useRef)(null);
21242
- (0, import_utils124.useResizeObserver)({
21293
+ (0, import_utils127.useResizeObserver)({
21243
21294
  ref,
21244
21295
  onResize: () => {
21245
21296
  if (ref.current) {
@@ -21964,7 +22015,7 @@ function HomeboundLogo(props) {
21964
22015
  }
21965
22016
 
21966
22017
  // src/components/MaxLines.tsx
21967
- var import_utils132 = require("@react-aria/utils");
22018
+ var import_utils135 = require("@react-aria/utils");
21968
22019
  var import_react120 = require("react");
21969
22020
  var import_runtime92 = require("@homebound/truss/runtime");
21970
22021
  var import_jsx_runtime167 = require("react/jsx-runtime");
@@ -21975,7 +22026,7 @@ function MaxLines({
21975
22026
  const elRef = (0, import_react120.useRef)(null);
21976
22027
  const [hasMore, setHasMore] = (0, import_react120.useState)(false);
21977
22028
  const [expanded, setExpanded] = (0, import_react120.useState)(false);
21978
- (0, import_utils132.useLayoutEffect)(() => {
22029
+ (0, import_utils135.useLayoutEffect)(() => {
21979
22030
  if (!elRef.current) return;
21980
22031
  setHasMore(elRef.current.scrollHeight > elRef.current.clientHeight);
21981
22032
  }, []);
@@ -21986,7 +22037,7 @@ function MaxLines({
21986
22037
  if (!elRef.current) return;
21987
22038
  !expanded && setHasMore(elRef.current.scrollHeight > elRef.current.clientHeight);
21988
22039
  }, [expanded]);
21989
- (0, import_utils132.useResizeObserver)({
22040
+ (0, import_utils135.useResizeObserver)({
21990
22041
  ref: elRef,
21991
22042
  onResize
21992
22043
  });
@@ -22010,7 +22061,7 @@ function MaxLines({
22010
22061
  var import_change_case8 = require("change-case");
22011
22062
 
22012
22063
  // src/components/AppNav/AppNavGroup.tsx
22013
- var import_utils134 = require("@react-aria/utils");
22064
+ var import_utils137 = require("@react-aria/utils");
22014
22065
  var import_change_case7 = require("change-case");
22015
22066
  var import_react123 = require("react");
22016
22067
 
@@ -22253,7 +22304,7 @@ function AppNavGroupDisclosure(props) {
22253
22304
  setContentHeight(`${contentEl.scrollHeight}px`);
22254
22305
  }
22255
22306
  }, [expanded, contentEl]);
22256
- (0, import_utils134.useResizeObserver)({
22307
+ (0, import_utils137.useResizeObserver)({
22257
22308
  ref: contentRef,
22258
22309
  onResize
22259
22310
  });
@@ -22866,7 +22917,7 @@ function PageHeader2(props) {
22866
22917
  }
22867
22918
 
22868
22919
  // src/components/ScrollShadows.tsx
22869
- var import_utils142 = require("@react-aria/utils");
22920
+ var import_utils145 = require("@react-aria/utils");
22870
22921
  var import_react126 = require("react");
22871
22922
  var import_runtime100 = require("@homebound/truss/runtime");
22872
22923
  var import_jsx_runtime177 = require("react/jsx-runtime");
@@ -22955,7 +23006,7 @@ function ScrollShadows(props) {
22955
23006
  setShowEndShadow(start + boxSize < end);
22956
23007
  }, [horizontal]);
22957
23008
  const onResize = (0, import_react126.useCallback)(() => scrollRef.current && updateScrollProps(scrollRef.current), [updateScrollProps]);
22958
- (0, import_utils142.useResizeObserver)({
23009
+ (0, import_utils145.useResizeObserver)({
22959
23010
  ref: scrollRef,
22960
23011
  onResize
22961
23012
  });
@@ -23864,7 +23915,7 @@ function useAutoHideOnScroll(spacerRef, enabled, getTopOffset) {
23864
23915
  }
23865
23916
 
23866
23917
  // src/layouts/useMeasuredHeight.ts
23867
- var import_utils149 = require("@react-aria/utils");
23918
+ var import_utils152 = require("@react-aria/utils");
23868
23919
  var import_react134 = require("react");
23869
23920
  function useMeasuredHeight(ref, enabled) {
23870
23921
  const [height, setHeight] = (0, import_react134.useState)(0);
@@ -23873,7 +23924,7 @@ function useMeasuredHeight(ref, enabled) {
23873
23924
  const next = el ? Math.round(el.getBoundingClientRect().height) : 0;
23874
23925
  setHeight((prev) => prev === next ? prev : next);
23875
23926
  }, [ref]);
23876
- (0, import_utils149.useResizeObserver)({ ref, onResize: syncElementHeight });
23927
+ (0, import_utils152.useResizeObserver)({ ref, onResize: syncElementHeight });
23877
23928
  (0, import_react134.useLayoutEffect)(() => {
23878
23929
  syncElementHeight();
23879
23930
  }, [enabled, syncElementHeight]);