labsense-ui-kit 1.3.63 → 1.3.64

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
@@ -8727,7 +8727,7 @@ var LabelText$1 = styled__default.div(_templateObject5$5 || (_templateObject5$5
8727
8727
  return $disabled ? theme.vms.text.medium : $color || theme.vms.text.medium;
8728
8728
  });
8729
8729
  var NoOptions = styled__default(Span)(_templateObject6$5 || (_templateObject6$5 = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n height: 100%;\n padding: 12px;\n font-size: 14px;\n font-weight: 400;\n"])));
8730
- var DropdownMenu$1 = styled__default.div(_templateObject7$3 || (_templateObject7$3 = _taggedTemplateLiteralLoose(["\n height: auto;\n max-height: 170px;\n border: ", ";\n border-radius: ", ";\n min-width: 100%;\n width: ", ";\n background: ", ";\n box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);\n overflow: hidden;\n position: absolute;\n z-index: 2;\n ", "\n ", "\n\n ", "\n"])), function (_ref24) {
8730
+ var DropdownMenu$1 = styled__default.div(_templateObject7$3 || (_templateObject7$3 = _taggedTemplateLiteralLoose(["\n height: auto;\n max-height: 170px;\n border: ", ";\n border-radius: ", ";\n min-width: 100%;\n width: ", ";\n background: ", ";\n box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);\n overflow: hidden;\n position: absolute;\n z-index: 2;\n outline: none;\n ", "\n ", "\n\n ", "\n"])), function (_ref24) {
8731
8731
  var theme = _ref24.theme;
8732
8732
  return "1px solid " + theme.vms.border.light;
8733
8733
  }, function (_ref25) {
@@ -8850,6 +8850,8 @@ var SelectOption = function SelectOption(_ref37) {
8850
8850
  highlightedIndex = _useState4[0],
8851
8851
  setHighlightedIndex = _useState4[1];
8852
8852
  var optionsWrapperRef = React.useRef(null);
8853
+ var dropdownMenuRef = React.useRef(null);
8854
+ var showSearchBox = searchBox && (options.length > 5 || allowCustomValue);
8853
8855
  React.useEffect(function () {
8854
8856
  if (loading) {
8855
8857
  setIsOpen(false);
@@ -8857,7 +8859,15 @@ var SelectOption = function SelectOption(_ref37) {
8857
8859
  setHighlightedIndex(-1);
8858
8860
  }
8859
8861
  }, [loading]);
8860
- var showSearchBox = searchBox && (options.length > 5 || allowCustomValue);
8862
+ React.useEffect(function () {
8863
+ if (isOpen) {
8864
+ if (showSearchBox && searchInputRef.current) {
8865
+ searchInputRef.current.focus();
8866
+ } else if (dropdownMenuRef.current) {
8867
+ dropdownMenuRef.current.focus();
8868
+ }
8869
+ }
8870
+ }, [isOpen, showSearchBox]);
8861
8871
  var toggleDropdown = function toggleDropdown() {
8862
8872
  var refToUse = (positionRef === null || positionRef === void 0 ? void 0 : positionRef.current) || dropdownRef.current;
8863
8873
  if (refToUse) {
@@ -8963,13 +8973,14 @@ var SelectOption = function SelectOption(_ref37) {
8963
8973
  case 'ArrowDown':
8964
8974
  e.preventDefault();
8965
8975
  setHighlightedIndex(function (prev) {
8966
- return prev < totalOptions - 1 ? prev + 1 : prev;
8976
+ var newIndex = prev < totalOptions - 1 ? prev + 1 : prev;
8977
+ return prev === -1 ? 0 : newIndex;
8967
8978
  });
8968
8979
  break;
8969
8980
  case 'ArrowUp':
8970
8981
  e.preventDefault();
8971
8982
  setHighlightedIndex(function (prev) {
8972
- return prev > 0 ? prev - 1 : -1;
8983
+ return prev > 0 ? prev - 1 : 0;
8973
8984
  });
8974
8985
  break;
8975
8986
  case 'Enter':
@@ -9043,6 +9054,9 @@ var SelectOption = function SelectOption(_ref37) {
9043
9054
  size: 7,
9044
9055
  color: color || themeColors.vms.text.medium
9045
9056
  })), isOpen && React__default.createElement(DropdownMenu$1, {
9057
+ ref: dropdownMenuRef,
9058
+ tabIndex: -1,
9059
+ onKeyDown: !showSearchBox ? handleKeyDown : undefined,
9046
9060
  "$width": width,
9047
9061
  "$menuBackground": menuBackground,
9048
9062
  "$optionsBorderRadius": optionsBorderRadius,