@activecollab/components 2.0.243 → 2.0.245

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.js CHANGED
@@ -19243,7 +19243,7 @@
19243
19243
  });
19244
19244
  Chip.displayName = "Chip";
19245
19245
 
19246
- var _excluded$C = ["options", "selected", "loading", "loadingText", "onChange", "onInputChange", "placeholder", "handleEmptyAction", "disabled", "size", "invalid", "type", "renderChip", "forceCloseMenu", "renderOption", "limitChips", "hiddenNumberText", "inPortal", "inputWrapperClassName", "scrollWrapper", "onClose", "onClear", "onDeselect", "defaultValue", "open", "onOpen", "triggerMode", "noResultText", "emptyValue", "disableVirtualization", "hideClearButton", "errorMessage"];
19246
+ var _excluded$C = ["options", "selected", "loading", "loadingText", "onChange", "onInputChange", "placeholder", "handleEmptyAction", "disabled", "size", "invalid", "type", "renderChip", "forceCloseMenu", "renderOption", "limitChips", "hiddenNumberText", "inPortal", "inputWrapperClassName", "scrollWrapper", "onClose", "onClear", "onDeselect", "defaultValue", "open", "onOpen", "triggerMode", "noResultText", "emptyValue", "disableVirtualization", "hideClearButton", "errorMessage", "onCancel"];
19247
19247
  var sizeMap = {
19248
19248
  small: 18,
19249
19249
  regular: 24,
@@ -19295,6 +19295,7 @@
19295
19295
  _ref$hideClearButton = _ref.hideClearButton,
19296
19296
  hideClearButton = _ref$hideClearButton === void 0 ? false : _ref$hideClearButton,
19297
19297
  errorMessage = _ref.errorMessage,
19298
+ onCancel = _ref.onCancel,
19298
19299
  prop = _objectWithoutProperties(_ref, _excluded$C);
19299
19300
  var selectedName = React.useMemo(function () {
19300
19301
  var value = "";
@@ -19346,12 +19347,14 @@
19346
19347
  if (e.target && (_comboBoxRef$current = comboBoxRef.current) !== null && _comboBoxRef$current !== void 0 && _comboBoxRef$current.contains(e.target)) {
19347
19348
  return;
19348
19349
  }
19350
+ onCancel === null || onCancel === void 0 || onCancel(selectedName);
19349
19351
  setOpen(false);
19350
19352
  });
19351
19353
  var handleOnKeyDown = React.useCallback(function (e) {
19352
19354
  if (e.key === "Escape" && open) {
19353
19355
  setOpen(false);
19354
19356
  setValue(selectedName);
19357
+ onCancel === null || onCancel === void 0 || onCancel(selectedName);
19355
19358
  e.stopPropagation();
19356
19359
  }
19357
19360
  if (e.key === "Enter" && type === "multiple") {
@@ -19361,7 +19364,7 @@
19361
19364
  setOpen(true);
19362
19365
  onOpen === null || onOpen === void 0 || onOpen();
19363
19366
  }
19364
- }, [focused, onOpen, open, selectedName, type]);
19367
+ }, [focused, onCancel, onOpen, open, selectedName, type]);
19365
19368
  React.useEffect(function () {
19366
19369
  var _childNode$current, _childNode$current2;
19367
19370
  open && (childNode === null || childNode === void 0 || (_childNode$current = childNode.current) === null || _childNode$current === void 0 ? void 0 : _childNode$current.focus());
@@ -19560,13 +19563,13 @@
19560
19563
  var showMenu = React.useMemo(function () {
19561
19564
  var hasOptions = (options === null || options === void 0 ? void 0 : options.length) > 0;
19562
19565
  var valueExists = function valueExists(option) {
19563
- return option.id.toString().includes(value) || option.name.includes(value);
19566
+ return (option.id.toString().includes(value) || option.name.includes(value)) && !(option !== null && option !== void 0 && option.hidden);
19564
19567
  };
19565
19568
  var isValueInOptions = options === null || options === void 0 ? void 0 : options.some(function (option) {
19566
19569
  return isOptionGroup(option) ? option.options.some(valueExists) : valueExists(option);
19567
19570
  });
19568
- return hasOptions && (!!defaultValue || !value) || value && (isValueInOptions || emptyValue || noResultText);
19569
- }, [defaultValue, emptyValue, noResultText, options, value]);
19571
+ return hasOptions && (!!defaultValue || !value) || value && (isValueInOptions || emptyValue && !!handleEmptyAction || noResultText);
19572
+ }, [defaultValue, emptyValue, handleEmptyAction, noResultText, options, value]);
19570
19573
  return /*#__PURE__*/React__default["default"].createElement("div", {
19571
19574
  className: "c-combo-box"
19572
19575
  }, type === "multiple" ? /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(_StyledStyledInputWrapper, {