@homebound/beam 3.23.1 → 3.24.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.
package/dist/Css.json CHANGED
@@ -262,6 +262,9 @@
262
262
  "fl": {"kind":"static","defs":{"float":"left"}},
263
263
  "fr": {"kind":"static","defs":{"float":"right"}},
264
264
  "float": {"kind":"variable","props":["float"],"incremented":false},
265
+ "fsyi": {"kind":"static","defs":{"fontStyle":"italic"}},
266
+ "fsynm": {"kind":"static","defs":{"fontStyle":"normal"}},
267
+ "fsy": {"kind":"variable","props":["fontStyle"],"incremented":false},
265
268
  "fwn": {"kind":"static","defs":{"fontWeight":"normal"}},
266
269
  "fwb": {"kind":"static","defs":{"fontWeight":"bold"}},
267
270
  "fw1": {"kind":"static","defs":{"fontWeight":100}},
package/dist/index.cjs CHANGED
@@ -1507,6 +1507,19 @@ var CssBuilder = class _CssBuilder {
1507
1507
  float(value) {
1508
1508
  return this.add("float", value);
1509
1509
  }
1510
+ // fontStyle
1511
+ /** Sets `fontStyle: "italic"`. */
1512
+ get fsyi() {
1513
+ return this.add("fontStyle", "italic");
1514
+ }
1515
+ /** Sets `fontStyle: "normal"`. */
1516
+ get fsynm() {
1517
+ return this.add("fontStyle", "normal");
1518
+ }
1519
+ /** Sets `fontStyle: value`. */
1520
+ fsy(value) {
1521
+ return this.add("fontStyle", value);
1522
+ }
1510
1523
  // fontWeight
1511
1524
  /** Sets `fontWeight: "normal"`. */
1512
1525
  get fwn() {
@@ -12886,29 +12899,36 @@ function ComboBoxBase(props) {
12886
12899
  } = props;
12887
12900
  const labelStyle = otherProps.labelStyle ?? fieldProps?.labelStyle ?? "above";
12888
12901
  const getOptionLabel = (0, import_react49.useCallback)(
12889
- (o) => unsetLabel && o === unsetOption ? unsetLabel : onAddNew && o === addNewOption ? addNewOption.name : propOptionLabel(o),
12902
+ (o) => unsetLabel && o === unsetOption ? unsetLabel : onAddNew && isAddNewOption(o) ? o.name : propOptionLabel(o),
12890
12903
  // propOptionLabel is basically always a lambda, so don't dep on it
12891
12904
  // eslint-disable-next-line react-hooks/exhaustive-deps
12892
- [unsetLabel]
12905
+ [unsetLabel, onAddNew]
12893
12906
  );
12894
12907
  const getOptionValue = (0, import_react49.useCallback)(
12895
- (o) => unsetLabel && o === unsetOption ? void 0 : onAddNew && o === addNewOption ? addNewOption.id : propOptionValue(o),
12908
+ (o) => unsetLabel && o === unsetOption ? void 0 : onAddNew && isAddNewOption(o) ? o.id : propOptionValue(o),
12896
12909
  // propOptionValue is basically always a lambda, so don't dep on it
12897
12910
  // eslint-disable-next-line react-hooks/exhaustive-deps
12898
- [unsetLabel]
12911
+ [unsetLabel, onAddNew]
12899
12912
  );
12900
12913
  const getOptionMenuLabel = (0, import_react49.useCallback)(
12901
- (o) => propOptionMenuLabel ? propOptionMenuLabel(o, Boolean(unsetLabel) && o === unsetOption, Boolean(onAddNew) && o === addNewOption) : getOptionLabel(o),
12914
+ (o) => {
12915
+ const isAddNew = Boolean(onAddNew) && isAddNewOption(o);
12916
+ if (propOptionMenuLabel) {
12917
+ return propOptionMenuLabel(o, Boolean(unsetLabel) && o === unsetOption, isAddNew);
12918
+ }
12919
+ const label = getOptionLabel(o);
12920
+ return isAddNew ? /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "fsyi", children: label }) : label;
12921
+ },
12902
12922
  // propOptionMenuLabel is basically always a lambda, so don't dep on it
12903
12923
  // eslint-disable-next-line react-hooks/exhaustive-deps
12904
- [unsetLabel, getOptionLabel]
12924
+ [unsetLabel, getOptionLabel, onAddNew]
12905
12925
  );
12906
12926
  const options = (0, import_react49.useMemo)(
12907
- () => initializeOptions(propOptions, getOptionValue, getOptionLabel, unsetLabel, !!onAddNew, autoSort),
12927
+ () => initializeOptions(propOptions, getOptionValue, getOptionLabel, unsetLabel, autoSort),
12908
12928
  // If the caller is using { current, load, options }, memoize on only `current` and `options` values.
12909
12929
  // ...and don't bother on memoizing on getOptionValue b/c it's basically always a lambda
12910
12930
  // eslint-disable-next-line react-hooks/exhaustive-deps
12911
- Array.isArray(propOptions) ? [propOptions, unsetLabel, onAddNew, autoSort] : [propOptions.current, propOptions.options, unsetLabel, onAddNew, autoSort]
12931
+ Array.isArray(propOptions) ? [propOptions, unsetLabel, autoSort] : [propOptions.current, propOptions.options, unsetLabel, autoSort]
12912
12932
  );
12913
12933
  const values = (0, import_react49.useMemo)(() => propValues ?? [], [propValues]);
12914
12934
  const inputStylePalette = (0, import_react49.useMemo)(() => propsInputStylePalette, [propsInputStylePalette]);
@@ -12930,9 +12950,8 @@ function ComboBoxBase(props) {
12930
12950
  const {
12931
12951
  searchValue
12932
12952
  } = fieldState;
12933
- const filteredOptions = (0, import_react49.useMemo)(() => {
12934
- return !searchValue ? options : options.filter((o) => contains(getOptionLabel(o), searchValue) || o === addNewOption);
12935
- }, [options, searchValue, getOptionLabel, contains]);
12953
+ const addNewOption = (0, import_react49.useMemo)(() => getAddNewOption(searchValue, options, getOptionLabel, onAddNew), [searchValue, options, getOptionLabel, onAddNew]);
12954
+ const filteredOptions = (0, import_react49.useMemo)(() => !searchValue ? options : addNewOption ? [...options.filter((o) => contains(getOptionLabel(o), searchValue)), addNewOption] : options.filter((o) => contains(getOptionLabel(o), searchValue)), [options, searchValue, getOptionLabel, contains, addNewOption]);
12936
12955
  function resetField() {
12937
12956
  setFieldState((prevState) => ({
12938
12957
  ...prevState,
@@ -13023,9 +13042,9 @@ function ComboBoxBase(props) {
13023
13042
  onSelect([], []);
13024
13043
  return;
13025
13044
  }
13026
- const selectedOption = options.find((o) => valueToKey(getOptionValue(o)) === key);
13027
- if (selectedOption === addNewOption && onAddNew) {
13028
- onAddNew(fieldState.inputValue);
13045
+ const selectedOption = filteredOptions.find((o) => valueToKey(getOptionValue(o)) === key);
13046
+ if (onAddNew && isAddNewOption(selectedOption) && fieldState.inputValue) {
13047
+ onAddNew(fieldState.inputValue.trim());
13029
13048
  return;
13030
13049
  }
13031
13050
  onSelect([keyToValue(key)], selectedOption ? [selectedOption] : []);
@@ -13120,7 +13139,7 @@ function ComboBoxBase(props) {
13120
13139
  function getInputValue(selectedOptions, getOptionLabel, multiselect, nothingSelectedText, readOnly) {
13121
13140
  return selectedOptions.length === 1 ? getOptionLabel(selectedOptions[0]) : readOnly && selectedOptions.length > 0 ? selectedOptions.map(getOptionLabel).join(", ") : multiselect && selectedOptions.length === 0 ? nothingSelectedText : "";
13122
13141
  }
13123
- function initializeOptions(optionsOrLoad, getOptionValue, getOptionLabel, unsetLabel, addNew, autoSort) {
13142
+ function initializeOptions(optionsOrLoad, getOptionValue, getOptionLabel, unsetLabel, autoSort) {
13124
13143
  const result = [];
13125
13144
  if (unsetLabel) {
13126
13145
  result.push(unsetOption);
@@ -13148,9 +13167,6 @@ function initializeOptions(optionsOrLoad, getOptionValue, getOptionLabel, unsetL
13148
13167
  }
13149
13168
  }
13150
13169
  result.push(...autoSort ? sortOptions(userOptions, getOptionLabel) : userOptions);
13151
- if (addNew) {
13152
- result.push(addNewOption);
13153
- }
13154
13170
  return result;
13155
13171
  }
13156
13172
  function sortOptions(options, getOptionLabel) {
@@ -13161,10 +13177,25 @@ function sortOptions(options, getOptionLabel) {
13161
13177
  });
13162
13178
  }
13163
13179
  var unsetOption = {};
13164
- var addNewOption = {
13165
- id: "new",
13166
- name: "Add New"
13167
- };
13180
+ var addNewOptionId = "beam_new";
13181
+ function isAddNewOption(o) {
13182
+ return typeof o === "object" && o !== null && "id" in o && o.id === addNewOptionId;
13183
+ }
13184
+ function getAddNewOption(searchValue, options, getOptionLabel, onAddNew) {
13185
+ if (!onAddNew) return void 0;
13186
+ const normalizedSearch = searchValue?.trim().toLowerCase();
13187
+ if (!normalizedSearch) return void 0;
13188
+ const trimmedSearch = searchValue.trim();
13189
+ const matchesExistingOption = options.some((o) => {
13190
+ if (o === unsetOption) return false;
13191
+ return getOptionLabel(o).trim().toLowerCase() === normalizedSearch;
13192
+ });
13193
+ if (matchesExistingOption) return void 0;
13194
+ return {
13195
+ id: addNewOptionId,
13196
+ name: `Add "${trimmedSearch}"`
13197
+ };
13198
+ }
13168
13199
  function disabledOptionToKeyedTuple(disabledOption) {
13169
13200
  if (typeof disabledOption === "object" && disabledOption !== null) {
13170
13201
  return [valueToKey(disabledOption.value), disabledOption.reason];
@@ -19609,7 +19640,7 @@ function hydrateDateRange(value) {
19609
19640
 
19610
19641
  // src/components/Filters/selectedFilterLabelUtils.ts
19611
19642
  function resolveOptionSelectedFilterLabel(optionsOrLoad, getOptionValue, getOptionLabel, value) {
19612
- const options = initializeOptions(optionsOrLoad, getOptionValue, getOptionLabel, void 0, false, false);
19643
+ const options = initializeOptions(optionsOrLoad, getOptionValue, getOptionLabel, void 0, false);
19613
19644
  const match = options.find((o) => getOptionValue(o) === value);
19614
19645
  return match ? getOptionLabel(match) : String(value);
19615
19646
  }