@homebound/beam 4.56.3 → 4.57.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
@@ -5879,8 +5879,8 @@ var Icons = {
5879
5879
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("rect", { x: "6", y: "5", width: "10", height: "2" }),
5880
5880
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("rect", { x: "12", y: "10", width: "10", height: "2" })
5881
5881
  ] }),
5882
- cube: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M19.406 4.08601L10.406 0.0860059C10.146 -0.0289941 9.853 -0.0289941 9.593 0.0860059L0.593 4.08601C0.573 4.09501 0.559 4.11001 0.539 4.12101C0.511 4.13501 0.481 4.14401 0.455 4.16101C0.433 4.17601 0.416 4.19501 0.395 4.21101C0.367 4.23201 0.34 4.25501 0.315 4.27901C0.274 4.31801 0.238 4.36001 0.205 4.40501C0.185 4.43301 0.164 4.45801 0.146 4.48601C0.115 4.53901 0.0919999 4.59401 0.0699999 4.65101C0.0609999 4.67801 0.047 4.70301 0.039 4.73001C0.015 4.81701 0 4.90701 0 5.00001V15C0 15.396 0.232 15.753 0.594 15.914L9.594 19.914C9.724 19.972 9.862 20 10 20C10.139 20 10.273 19.961 10.402 19.904L10.406 19.914L19.406 15.914C19.768 15.753 20 15.396 20 15V5.00001C20 4.60401 19.768 4.24701 19.406 4.08601ZM10 2.09501L16.538 5.00001L10 7.90501L8.692 7.32401L3.463 5.00001L10 2.09501ZM2 14.351V6.53901L9 9.65001V17.461L2 14.351ZM11 17.461V9.65001L18 6.53901V14.351L11 17.461Z" }),
5883
5882
  // Figma's 1.75px strokes, scaled 8/7 to Beam's 2px
5883
+ cube: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M13.1016 12.6739V18.4562L18.3962 15.4686V9.6862L13.1016 12.6739ZM6 15.5433L11.1016 18.4485V12.6705L6 9.7654V15.5433ZM6.9933 8.0299L12.1038 10.9406L17.3616 7.973L12.1127 5.0109L6.9933 8.0299ZM20.3962 16.0522C20.3962 16.4129 20.2024 16.7465 19.8883 16.9239L12.5937 21.04C12.2876 21.2128 11.9127 21.2127 11.6071 21.0389L4.5056 16.9942C4.1933 16.8163 4 16.4841 4 16.1248V8.0456C4.0001 7.6917 4.1875 7.3648 4.4922 7.1851L11.5937 2.9953L11.7121 2.9362C11.9954 2.8162 12.3215 2.8328 12.5937 2.9864L19.8883 7.1025C20.2024 7.2798 20.3962 7.6134 20.3962 7.9741V16.0522Z" }),
5884
5884
  cubeDashed: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
5885
5885
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M9.812 7.1132C9.4955 7.1132 9.1873 6.9506 9.0149 6.6583C8.7555 6.2186 8.9017 5.6519 9.3415 5.3925L11.485 4.1282C11.7694 3.9605 12.1216 3.9571 12.409 4.1193L14.5763 5.3425C15.0209 5.5934 15.1779 6.1572 14.927 6.6018C14.6761 7.0464 14.1122 7.2034 13.6678 6.9525L11.9649 5.9915L10.2807 6.9849C10.1333 7.0718 9.9715 7.1132 9.812 7.1132Z" }),
5886
5886
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M7.0861 11.2271C6.9311 11.2271 6.7739 11.188 6.6295 11.1058L4.4669 9.8742C4.1804 9.7111 4.0025 9.4077 4 9.078C3.9975 8.7484 4.1708 8.4423 4.4547 8.2748L6.5983 7.0104C7.038 6.751 7.6047 6.8973 7.8641 7.337C8.1235 7.7767 7.9773 8.3435 7.5376 8.6028L6.7676 9.057L7.5444 9.4993C7.988 9.7519 8.1428 10.3163 7.8902 10.76C7.7198 11.0592 7.4075 11.2271 7.0861 11.2271Z" }),
@@ -19156,6 +19156,89 @@ var import_runtime86 = require("@homebound/truss/runtime");
19156
19156
  // src/inputs/MenuSelectField/MenuSelectField.tsx
19157
19157
  var import_react86 = require("react");
19158
19158
 
19159
+ // src/inputs/Value.ts
19160
+ var VALUE_PREFIX = "__VALUE--";
19161
+ function keyToValue(key) {
19162
+ if (typeof key === "number") {
19163
+ return key;
19164
+ } else if (typeof key === "string") {
19165
+ if (key === `${VALUE_PREFIX}null` || key === "__VALUE:null") {
19166
+ return null;
19167
+ } else if (key === `${VALUE_PREFIX}undefined` || key === "__VALUE:undefined") {
19168
+ return void 0;
19169
+ } else if (key.startsWith(`${VALUE_PREFIX}boolean--`) || key.startsWith("__VALUE:boolean:")) {
19170
+ const parts = key.includes("--boolean--") ? key.split("--") : key.split(":");
19171
+ return parts[parts.length - 1] === "true";
19172
+ } else if (key.startsWith(`${VALUE_PREFIX}number--`) || key.startsWith("__VALUE:number:")) {
19173
+ const parts = key.includes("--number--") ? key.split("--") : key.split(":");
19174
+ return Number(parts[parts.length - 1]);
19175
+ } else {
19176
+ return key;
19177
+ }
19178
+ } else {
19179
+ throw new Error(`Unsupported key ${key}`);
19180
+ }
19181
+ }
19182
+ function valueToKey(value) {
19183
+ if (typeof value === "string") {
19184
+ return value;
19185
+ } else if (typeof value === "number") {
19186
+ return `${VALUE_PREFIX}number--${value}`;
19187
+ } else if (typeof value === "boolean") {
19188
+ return `${VALUE_PREFIX}boolean--${value}`;
19189
+ } else if (value === null) {
19190
+ return `${VALUE_PREFIX}null`;
19191
+ } else if (value === void 0) {
19192
+ return `${VALUE_PREFIX}undefined`;
19193
+ } else {
19194
+ throw new Error(`Unsupported value ${value}`);
19195
+ }
19196
+ }
19197
+
19198
+ // src/inputs/internal/selectFieldHelpers.ts
19199
+ function initializeOptions(optionsOrLoad, getOptionValue, getOptionLabel, unsetLabel, autoSort) {
19200
+ const result = [];
19201
+ if (unsetLabel) {
19202
+ result.push(unsetOption);
19203
+ }
19204
+ const userOptions = [];
19205
+ if (Array.isArray(optionsOrLoad)) {
19206
+ userOptions.push(...optionsOrLoad);
19207
+ } else {
19208
+ const { options, current: current2 } = optionsOrLoad;
19209
+ if (options) {
19210
+ userOptions.push(...options);
19211
+ }
19212
+ if (current2) {
19213
+ const toCheck = Array.isArray(current2) ? current2 : [current2];
19214
+ toCheck.forEach((current3) => {
19215
+ const value = getOptionValue(current3);
19216
+ const found = options && options.find((o) => getOptionValue(o) === value);
19217
+ if (!found) {
19218
+ userOptions.push(current3);
19219
+ }
19220
+ });
19221
+ }
19222
+ }
19223
+ result.push(...autoSort ? sortOptions(userOptions, getOptionLabel) : userOptions);
19224
+ return result;
19225
+ }
19226
+ var unsetOption = {};
19227
+ function disabledOptionToKeyedTuple(disabledOption) {
19228
+ if (typeof disabledOption === "object" && disabledOption !== null) {
19229
+ return [valueToKey(disabledOption.value), disabledOption.reason];
19230
+ } else {
19231
+ return [valueToKey(disabledOption), void 0];
19232
+ }
19233
+ }
19234
+ function sortOptions(options, getOptionLabel) {
19235
+ return [...options].sort((a, b) => {
19236
+ const labelA = getOptionLabel(a).toLowerCase();
19237
+ const labelB = getOptionLabel(b).toLowerCase();
19238
+ return labelA.localeCompare(labelB);
19239
+ });
19240
+ }
19241
+
19159
19242
  // src/inputs/MenuSelectField/internal/AnchoredOverlay.tsx
19160
19243
  var import_react80 = require("react");
19161
19244
  var import_react_aria31 = require("react-aria");
@@ -20155,89 +20238,6 @@ var import_react85 = require("react");
20155
20238
  var import_react_aria37 = require("react-aria");
20156
20239
  var import_react_stately7 = require("react-stately");
20157
20240
 
20158
- // src/inputs/Value.ts
20159
- var VALUE_PREFIX = "__VALUE--";
20160
- function keyToValue(key) {
20161
- if (typeof key === "number") {
20162
- return key;
20163
- } else if (typeof key === "string") {
20164
- if (key === `${VALUE_PREFIX}null` || key === "__VALUE:null") {
20165
- return null;
20166
- } else if (key === `${VALUE_PREFIX}undefined` || key === "__VALUE:undefined") {
20167
- return void 0;
20168
- } else if (key.startsWith(`${VALUE_PREFIX}boolean--`) || key.startsWith("__VALUE:boolean:")) {
20169
- const parts = key.includes("--boolean--") ? key.split("--") : key.split(":");
20170
- return parts[parts.length - 1] === "true";
20171
- } else if (key.startsWith(`${VALUE_PREFIX}number--`) || key.startsWith("__VALUE:number:")) {
20172
- const parts = key.includes("--number--") ? key.split("--") : key.split(":");
20173
- return Number(parts[parts.length - 1]);
20174
- } else {
20175
- return key;
20176
- }
20177
- } else {
20178
- throw new Error(`Unsupported key ${key}`);
20179
- }
20180
- }
20181
- function valueToKey(value) {
20182
- if (typeof value === "string") {
20183
- return value;
20184
- } else if (typeof value === "number") {
20185
- return `${VALUE_PREFIX}number--${value}`;
20186
- } else if (typeof value === "boolean") {
20187
- return `${VALUE_PREFIX}boolean--${value}`;
20188
- } else if (value === null) {
20189
- return `${VALUE_PREFIX}null`;
20190
- } else if (value === void 0) {
20191
- return `${VALUE_PREFIX}undefined`;
20192
- } else {
20193
- throw new Error(`Unsupported value ${value}`);
20194
- }
20195
- }
20196
-
20197
- // src/inputs/internal/selectFieldHelpers.ts
20198
- function initializeOptions(optionsOrLoad, getOptionValue, getOptionLabel, unsetLabel, autoSort) {
20199
- const result = [];
20200
- if (unsetLabel) {
20201
- result.push(unsetOption);
20202
- }
20203
- const userOptions = [];
20204
- if (Array.isArray(optionsOrLoad)) {
20205
- userOptions.push(...optionsOrLoad);
20206
- } else {
20207
- const { options, current: current2 } = optionsOrLoad;
20208
- if (options) {
20209
- userOptions.push(...options);
20210
- }
20211
- if (current2) {
20212
- const toCheck = Array.isArray(current2) ? current2 : [current2];
20213
- toCheck.forEach((current3) => {
20214
- const value = getOptionValue(current3);
20215
- const found = options && options.find((o) => getOptionValue(o) === value);
20216
- if (!found) {
20217
- userOptions.push(current3);
20218
- }
20219
- });
20220
- }
20221
- }
20222
- result.push(...autoSort ? sortOptions(userOptions, getOptionLabel) : userOptions);
20223
- return result;
20224
- }
20225
- var unsetOption = {};
20226
- function disabledOptionToKeyedTuple(disabledOption) {
20227
- if (typeof disabledOption === "object" && disabledOption !== null) {
20228
- return [valueToKey(disabledOption.value), disabledOption.reason];
20229
- } else {
20230
- return [valueToKey(disabledOption), void 0];
20231
- }
20232
- }
20233
- function sortOptions(options, getOptionLabel) {
20234
- return [...options].sort((a, b) => {
20235
- const labelA = getOptionLabel(a).toLowerCase();
20236
- const labelB = getOptionLabel(b).toLowerCase();
20237
- return labelA.localeCompare(labelB);
20238
- });
20239
- }
20240
-
20241
20241
  // src/inputs/MenuSelectField/internal/menuTree.ts
20242
20242
  function buildMenuTree(roots, getKey, getChildren) {
20243
20243
  const nodes = /* @__PURE__ */ new Map();
@@ -20419,10 +20419,11 @@ var import_jsx_runtime115 = require("react/jsx-runtime");
20419
20419
  function useMenuSelectField(props) {
20420
20420
  const {
20421
20421
  options: optionsProp,
20422
- getOptionValue = defaultOptionValue,
20423
- getOptionLabel = defaultOptionLabel,
20422
+ getOptionValue: propGetOptionValue = defaultOptionValue,
20423
+ getOptionLabel: propGetOptionLabel = defaultOptionLabel,
20424
20424
  getOptionMenuLabel,
20425
20425
  getOptionSearchText,
20426
+ unsetLabel,
20426
20427
  autoSort = true,
20427
20428
  onSearch,
20428
20429
  disabledOptions,
@@ -20465,11 +20466,13 @@ function useMenuSelectField(props) {
20465
20466
  const [search, setSearch] = (0, import_react85.useState)("");
20466
20467
  const [optionsLoading, setOptionsLoading] = (0, import_react85.useState)(false);
20467
20468
  const didRequestOptionsRef = (0, import_react85.useRef)(false);
20469
+ const getOptionLabel = (option) => unsetLabel && option === unsetOption ? unsetLabel : propGetOptionLabel(option);
20470
+ const getOptionValue = (option) => unsetLabel && option === unsetOption ? void 0 : propGetOptionValue(option);
20468
20471
  const options = (0, import_react85.useMemo)(
20469
- () => initializeOptions(optionsProp, getOptionValue, getOptionLabel, void 0, autoSort),
20472
+ () => initializeOptions(optionsProp, getOptionValue, getOptionLabel, unsetLabel, autoSort),
20470
20473
  // getOptionValue and getOptionLabel are typically inline lambdas
20471
20474
  // oxlint-disable-next-line react-hooks/exhaustive-deps
20472
- [optionsProp, autoSort]
20475
+ [optionsProp, autoSort, unsetLabel]
20473
20476
  );
20474
20477
  const { hoverProps, isHovered } = (0, import_react_aria37.useHover)({});
20475
20478
  const { focusProps, isFocusVisible } = (0, import_react_aria37.useFocusRing)();
@@ -20536,10 +20539,12 @@ function useMenuSelectField(props) {
20536
20539
  );
20537
20540
  }, [menuTree, allOptions, search, serverSearch, contains, expandedKeys, searchCollapsedKeys]);
20538
20541
  const filteredOptions = (0, import_react85.useMemo)(
20539
- () => menuTree || !search || serverSearch ? options : options.filter((o) => matchesSearch(o, search, getOptionLabel, getOptionSearchText, contains)),
20542
+ () => menuTree || !search || serverSearch ? options : options.filter(
20543
+ (option) => unsetLabel && option === unsetOption ? contains(getOptionLabel(option), search) : matchesSearch(option, search, getOptionLabel, getOptionSearchText, contains)
20544
+ ),
20540
20545
  // getOptionLabel and getOptionSearchText are typically inline lambdas
20541
20546
  // oxlint-disable-next-line react-hooks/exhaustive-deps
20542
- [menuTree, options, search, serverSearch, contains]
20547
+ [menuTree, options, search, serverSearch, contains, unsetLabel]
20543
20548
  );
20544
20549
  function onSelectionChange(keys) {
20545
20550
  if (keys === "all") return;
@@ -20589,7 +20594,7 @@ function useMenuSelectField(props) {
20589
20594
  }, [treeRows, filteredOptions]);
20590
20595
  const state = (0, import_react_stately7.useListState)({
20591
20596
  items: collectionItems,
20592
- children: (item) => /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(import_react_stately7.Item, { textValue: getOptionLabel(item.option), children: getOptionMenuLabel ? getOptionMenuLabel(item.option) : getOptionLabel(item.option) }, item.key),
20597
+ children: (item) => /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(import_react_stately7.Item, { textValue: getOptionLabel(item.option), children: getOptionMenuLabel ? getOptionMenuLabel(item.option, Boolean(unsetLabel) && item.option === unsetOption) : getOptionLabel(item.option) }, item.key),
20593
20598
  selectionMode: multiple ? "multiple" : "single",
20594
20599
  selectedKeys: selectedRowKeys,
20595
20600
  disabledKeys: disabledRowKeys,
@@ -20980,17 +20985,24 @@ function BaseMenuSelectField(props) {
20980
20985
  // src/inputs/MenuSelectField/MenuSelectField.tsx
20981
20986
  var import_jsx_runtime117 = require("react/jsx-runtime");
20982
20987
  function MenuSelectField(props) {
20983
- const { value, proposedValue, onSelect, ...rest } = props;
20984
- const values = (0, import_react86.useMemo)(() => value === void 0 ? [] : [value], [value]);
20988
+ const { value, proposedValue, onSelect, unsetLabel, ...rest } = props;
20989
+ const values = (0, import_react86.useMemo)(() => {
20990
+ if (value !== void 0) return [value];
20991
+ return unsetLabel ? [void 0] : [];
20992
+ }, [value, unsetLabel]);
20985
20993
  const proposedValues = (0, import_react86.useMemo)(() => proposedValue === void 0 ? void 0 : [proposedValue], [proposedValue]);
20986
20994
  return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
20987
20995
  BaseMenuSelectField,
20988
20996
  {
20989
20997
  ...rest,
20998
+ unsetLabel,
20990
20999
  selectionMode: "single",
20991
21000
  values,
20992
21001
  proposedValues,
20993
- onCommit: (next, opts) => onSelect(next[0], opts[0])
21002
+ onCommit: (next, opts) => {
21003
+ const option = opts[0];
21004
+ onSelect(next[0], option === unsetOption ? void 0 : option);
21005
+ }
20994
21006
  }
20995
21007
  );
20996
21008
  }
@@ -32000,7 +32012,6 @@ var import_jsx_runtime241 = require("react/jsx-runtime");
32000
32012
  function singleFilter(props) {
32001
32013
  return (key) => new SingleFilter(key, props);
32002
32014
  }
32003
- var allOption = {};
32004
32015
  var SingleFilter = class extends BaseFilter {
32005
32016
  formatSelectedFilterLabel(value) {
32006
32017
  const { options } = this.props;
@@ -32008,26 +32019,15 @@ var SingleFilter = class extends BaseFilter {
32008
32019
  return resolveOptionSelectedFilterLabel(options, getOptionValue, getOptionLabel, value);
32009
32020
  }
32010
32021
  render(value, setValue, tid, inModal, vertical) {
32011
- const { label, defaultValue, options: maybeOptions, nothingSelectedText, autoSort, ...props } = this.props;
32012
- const { getOptionValue, getOptionLabel } = optionReaders2(this.props);
32013
- const unsetText = nothingSelectedText ?? "All";
32014
- const isStaticList = Array.isArray(maybeOptions);
32015
- const options = isStaticList ? [
32016
- allOption,
32017
- ...initializeOptions(maybeOptions, getOptionValue, getOptionLabel, void 0, autoSort ?? true)
32018
- ] : maybeOptions;
32022
+ const { label, defaultValue, nothingSelectedText, unsetLabel, ...props } = this.props;
32019
32023
  return /* @__PURE__ */ (0, import_jsx_runtime241.jsx)(
32020
32024
  MenuSelectField,
32021
32025
  {
32022
32026
  ...props,
32023
- autoSort: isStaticList ? false : autoSort,
32024
- options,
32025
- getOptionValue: (option) => option === allOption ? void 0 : getOptionValue(option),
32026
- getOptionLabel: (option) => option === allOption ? unsetText : getOptionLabel(option),
32027
+ unsetLabel: unsetLabel ?? nothingSelectedText ?? "All",
32027
32028
  value,
32028
32029
  label: this.label,
32029
32030
  labelStyle: inModal ? "hidden" : !inModal && !vertical ? "inline" : "above",
32030
- nothingSelectedText: unsetText,
32031
32031
  onSelect: (next) => setValue(next || void 0),
32032
32032
  ...this.testId(tid)
32033
32033
  }