labsense-ui-kit 1.3.62 → 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.
@@ -6,6 +6,7 @@ export declare const Options: import("styled-components/dist/types").IStyledComp
6
6
  $optionFontWeight?: string | undefined;
7
7
  $optionBackgroundColor?: string | undefined;
8
8
  $optionSelected?: boolean | undefined;
9
+ $isHighlighted?: boolean | undefined;
9
10
  }>> & string;
10
11
  export declare const DropdownMenu: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
11
12
  $menuBackground?: string | undefined;
package/dist/index.js CHANGED
@@ -7862,15 +7862,24 @@ var DatePicker = function DatePicker(_ref22) {
7862
7862
 
7863
7863
  var _templateObject$a, _templateObject2$7, _templateObject3$4, _templateObject4$3, _templateObject5$3, _templateObject6$3;
7864
7864
  var OptionContainer = styled__default.div(_templateObject$a || (_templateObject$a = _taggedTemplateLiteralLoose([""])));
7865
- var OptionItem = styled__default.div(_templateObject2$7 || (_templateObject2$7 = _taggedTemplateLiteralLoose(["\n border-bottom: ", ";\n"])), function (_ref) {
7865
+ var OptionItem = styled__default.div(_templateObject2$7 || (_templateObject2$7 = _taggedTemplateLiteralLoose(["\n border-bottom: ", ";\n background-color: ", ";\n border-radius: ", ";\n"])), function (_ref) {
7866
7866
  var $optionBorder = _ref.$optionBorder,
7867
7867
  $isborder = _ref.$isborder,
7868
7868
  theme = _ref.theme;
7869
7869
  return $isborder ? $optionBorder || "1px solid " + theme.vms.border.extraLight : '';
7870
- });
7871
- var OptionLabel = styled__default.label(_templateObject3$4 || (_templateObject3$4 = _taggedTemplateLiteralLoose(["\n cursor: pointer;\n display: flex;\n gap: 8px;\n padding: 8px 12px;\n word-break: break-word;\n box-sizing: border-box;\n display: flex;\n align-items: center;\n font-weight: 500;\n font-size: 14px;\n line-height: 14px;\n color: ", ";\n"])), function (_ref2) {
7872
- var $optionColor = _ref2.$optionColor,
7870
+ }, function (_ref2) {
7871
+ var $isHighlighted = _ref2.$isHighlighted,
7873
7872
  theme = _ref2.theme;
7873
+ return $isHighlighted ? theme.vms.hover.primary : 'transparent';
7874
+ }, function (_ref3) {
7875
+ var $isHighlighted = _ref3.$isHighlighted;
7876
+ return $isHighlighted ? '4px' : '0';
7877
+ });
7878
+ var OptionLabel = styled__default.label(_templateObject3$4 || (_templateObject3$4 = _taggedTemplateLiteralLoose(["\n cursor: pointer;\n display: flex;\n gap: 8px;\n padding: 8px 12px;\n word-break: break-word;\n box-sizing: border-box;\n display: flex;\n align-items: center;\n font-weight: 500;\n font-size: 14px;\n line-height: 14px;\n color: ", ";\n"])), function (_ref4) {
7879
+ var $optionColor = _ref4.$optionColor,
7880
+ $isHighlighted = _ref4.$isHighlighted,
7881
+ theme = _ref4.theme;
7882
+ if ($isHighlighted) return theme.vms.text.white;
7874
7883
  switch ($optionColor) {
7875
7884
  case 'dark':
7876
7885
  return theme.vms.text.dark;
@@ -7892,9 +7901,9 @@ var OptionLabel = styled__default.label(_templateObject3$4 || (_templateObject3$
7892
7901
  return $optionColor || theme.vms.text.medium;
7893
7902
  }
7894
7903
  });
7895
- var SearchContainer = styled__default.div(_templateObject4$3 || (_templateObject4$3 = _taggedTemplateLiteralLoose(["\n width: 100%;\n height: auto;\n background: ", ";\n border-bottom: ", ";\n border-radius: ", ";\n padding: 8px 8px;\n display: flex;\n align-items: center;\n gap: 8px;\n"])), function (_ref3) {
7896
- var $background = _ref3.$background,
7897
- theme = _ref3.theme;
7904
+ var SearchContainer = styled__default.div(_templateObject4$3 || (_templateObject4$3 = _taggedTemplateLiteralLoose(["\n width: 100%;\n height: auto;\n background: ", ";\n border-bottom: ", ";\n border-radius: ", ";\n padding: 8px 8px;\n display: flex;\n align-items: center;\n gap: 8px;\n"])), function (_ref5) {
7905
+ var $background = _ref5.$background,
7906
+ theme = _ref5.theme;
7898
7907
  switch ($background) {
7899
7908
  case 'dark':
7900
7909
  return theme.vms.text.dark;
@@ -7915,19 +7924,19 @@ var SearchContainer = styled__default.div(_templateObject4$3 || (_templateObject
7915
7924
  default:
7916
7925
  return $background;
7917
7926
  }
7918
- }, function (_ref4) {
7919
- var $borderBottom = _ref4.$borderBottom;
7927
+ }, function (_ref6) {
7928
+ var $borderBottom = _ref6.$borderBottom;
7920
7929
  return $borderBottom || 'none';
7921
- }, function (_ref5) {
7922
- var $borderRadius = _ref5.$borderRadius;
7930
+ }, function (_ref7) {
7931
+ var $borderRadius = _ref7.$borderRadius;
7923
7932
  return $borderRadius || '8px';
7924
7933
  });
7925
- var SearchBar = styled__default.input(_templateObject5$3 || (_templateObject5$3 = _taggedTemplateLiteralLoose(["\n border: none;\n outline: none;\n width: 100%;\n font-weight: 400;\n font-size: 14px;\n line-height: 14px;\n background: ", ";\n color: ", ";\n &::placeholder {\n color: ", ";\n font-style: italic;\n }\n"])), function (_ref6) {
7926
- var theme = _ref6.theme;
7934
+ var SearchBar = styled__default.input(_templateObject5$3 || (_templateObject5$3 = _taggedTemplateLiteralLoose(["\n border: none;\n outline: none;\n width: 100%;\n font-weight: 400;\n font-size: 14px;\n line-height: 14px;\n background: ", ";\n color: ", ";\n &::placeholder {\n color: ", ";\n font-style: italic;\n }\n"])), function (_ref8) {
7935
+ var theme = _ref8.theme;
7927
7936
  return theme.vms["default"].tertiary;
7928
- }, function (_ref7) {
7929
- var $inputColor = _ref7.$inputColor,
7930
- theme = _ref7.theme;
7937
+ }, function (_ref9) {
7938
+ var $inputColor = _ref9.$inputColor,
7939
+ theme = _ref9.theme;
7931
7940
  switch ($inputColor) {
7932
7941
  case 'dark':
7933
7942
  return theme.vms.text.dark;
@@ -7948,9 +7957,9 @@ var SearchBar = styled__default.input(_templateObject5$3 || (_templateObject5$3
7948
7957
  default:
7949
7958
  return $inputColor;
7950
7959
  }
7951
- }, function (_ref8) {
7952
- var $placeholderColor = _ref8.$placeholderColor,
7953
- theme = _ref8.theme;
7960
+ }, function (_ref10) {
7961
+ var $placeholderColor = _ref10.$placeholderColor,
7962
+ theme = _ref10.theme;
7954
7963
  switch ($placeholderColor) {
7955
7964
  case 'dark':
7956
7965
  return theme.vms.text.dark;
@@ -7973,28 +7982,34 @@ var SearchBar = styled__default.input(_templateObject5$3 || (_templateObject5$3
7973
7982
  }
7974
7983
  });
7975
7984
  var Text = styled__default.span(_templateObject6$3 || (_templateObject6$3 = _taggedTemplateLiteralLoose(["\n word-break: break-word;\n"])));
7976
- var OptionComponent = function OptionComponent(_ref9) {
7977
- var options = _ref9.options,
7978
- selectedOptions = _ref9.selectedOptions,
7979
- onChange = _ref9.onChange,
7980
- _ref9$placeholder = _ref9.placeholder,
7981
- placeholder = _ref9$placeholder === void 0 ? 'Search...' : _ref9$placeholder,
7982
- placeholderColor = _ref9.placeholderColor,
7983
- optionBorder = _ref9.optionBorder,
7984
- optionColor = _ref9.optionColor,
7985
- searchIcon = _ref9.searchIcon,
7986
- searchbarTextColor = _ref9.searchbarTextColor,
7987
- searchBoxBorder = _ref9.searchBoxBorder,
7988
- searchBoxBorderRadius = _ref9.searchBoxBorderRadius,
7989
- searchBoxBackground = _ref9.searchBoxBackground,
7990
- _ref9$searchBox = _ref9.searchBox,
7991
- searchBox = _ref9$searchBox === void 0 ? true : _ref9$searchBox,
7992
- NoOptionsText = _ref9.NoOptionsText;
7985
+ var OptionComponent = function OptionComponent(_ref11) {
7986
+ var options = _ref11.options,
7987
+ selectedOptions = _ref11.selectedOptions,
7988
+ onChange = _ref11.onChange,
7989
+ _ref11$placeholder = _ref11.placeholder,
7990
+ placeholder = _ref11$placeholder === void 0 ? 'Search...' : _ref11$placeholder,
7991
+ placeholderColor = _ref11.placeholderColor,
7992
+ optionBorder = _ref11.optionBorder,
7993
+ optionColor = _ref11.optionColor,
7994
+ searchIcon = _ref11.searchIcon,
7995
+ searchbarTextColor = _ref11.searchbarTextColor,
7996
+ searchBoxBorder = _ref11.searchBoxBorder,
7997
+ searchBoxBorderRadius = _ref11.searchBoxBorderRadius,
7998
+ searchBoxBackground = _ref11.searchBoxBackground,
7999
+ _ref11$searchBox = _ref11.searchBox,
8000
+ searchBox = _ref11$searchBox === void 0 ? true : _ref11$searchBox,
8001
+ NoOptionsText = _ref11.NoOptionsText;
7993
8002
  var _useState = React.useState(''),
7994
8003
  searchQuery = _useState[0],
7995
8004
  setSearchQuery = _useState[1];
8005
+ var _useState2 = React.useState(-1),
8006
+ highlightedIndex = _useState2[0],
8007
+ setHighlightedIndex = _useState2[1];
8008
+ var optionContainerRef = React.useRef(null);
8009
+ var searchInputRef = React.useRef(null);
7996
8010
  var handleSearchChange = function handleSearchChange(e) {
7997
8011
  setSearchQuery(e.target.value.trimStart());
8012
+ setHighlightedIndex(-1);
7998
8013
  };
7999
8014
  var handleOptionToggle = function handleOptionToggle(currentOption) {
8000
8015
  var newOption = selectedOptions.includes(currentOption) ? selectedOptions.filter(function (item) {
@@ -8002,6 +8017,36 @@ var OptionComponent = function OptionComponent(_ref9) {
8002
8017
  }) : [].concat(selectedOptions, [currentOption]);
8003
8018
  onChange === null || onChange === void 0 ? void 0 : onChange(newOption);
8004
8019
  };
8020
+ var handleKeyDown = function handleKeyDown(e) {
8021
+ if (finalOptions.length === 0) return;
8022
+ switch (e.key) {
8023
+ case 'ArrowDown':
8024
+ e.preventDefault();
8025
+ setHighlightedIndex(function (prev) {
8026
+ return prev < finalOptions.length - 1 ? prev + 1 : prev;
8027
+ });
8028
+ break;
8029
+ case 'ArrowUp':
8030
+ e.preventDefault();
8031
+ setHighlightedIndex(function (prev) {
8032
+ return prev > 0 ? prev - 1 : -1;
8033
+ });
8034
+ break;
8035
+ case 'Enter':
8036
+ e.preventDefault();
8037
+ if (highlightedIndex >= 0 && highlightedIndex < finalOptions.length) {
8038
+ var selectedOption = finalOptions[highlightedIndex];
8039
+ handleOptionToggle(selectedOption.value);
8040
+ }
8041
+ break;
8042
+ case 'Escape':
8043
+ setHighlightedIndex(-1);
8044
+ if (searchInputRef.current) {
8045
+ searchInputRef.current.blur();
8046
+ }
8047
+ break;
8048
+ }
8049
+ };
8005
8050
  var filteredOptions = options.filter(function (option) {
8006
8051
  return option.labelText.toLowerCase().includes(searchQuery.toLowerCase());
8007
8052
  });
@@ -8012,6 +8057,17 @@ var OptionComponent = function OptionComponent(_ref9) {
8012
8057
  })) : filteredOptions.sort(function (a, b) {
8013
8058
  return a.labelText.localeCompare(b.labelText);
8014
8059
  });
8060
+ React.useEffect(function () {
8061
+ if (highlightedIndex >= 0 && optionContainerRef.current) {
8062
+ var highlightedElement = optionContainerRef.current.children[highlightedIndex];
8063
+ if (highlightedElement) {
8064
+ highlightedElement.scrollIntoView({
8065
+ block: 'nearest',
8066
+ behavior: 'smooth'
8067
+ });
8068
+ }
8069
+ }
8070
+ }, [highlightedIndex]);
8015
8071
  return React__default.createElement(Container, {
8016
8072
  "$flexDirection": 'column',
8017
8073
  "$gap": '8px',
@@ -8026,20 +8082,26 @@ var OptionComponent = function OptionComponent(_ref9) {
8026
8082
  color: searchIcon === null || searchIcon === void 0 ? void 0 : searchIcon.color,
8027
8083
  weight: (searchIcon === null || searchIcon === void 0 ? void 0 : searchIcon.weight) || '0px'
8028
8084
  }), React__default.createElement(SearchBar, {
8085
+ ref: searchInputRef,
8029
8086
  type: 'text',
8030
8087
  placeholder: placeholder,
8031
8088
  value: searchQuery,
8032
8089
  onChange: handleSearchChange,
8090
+ onKeyDown: handleKeyDown,
8033
8091
  "$inputColor": searchbarTextColor,
8034
8092
  "$placeholderColor": placeholderColor
8035
- })), React__default.createElement(OptionContainer, null, finalOptions.length > 0 ? finalOptions.map(function (option, id) {
8093
+ })), React__default.createElement(OptionContainer, {
8094
+ ref: optionContainerRef
8095
+ }, finalOptions.length > 0 ? finalOptions.map(function (option, id) {
8036
8096
  return React__default.createElement(OptionItem, {
8037
8097
  key: option.value,
8038
8098
  "$optionBorder": optionBorder,
8039
- "$isborder": id !== finalOptions.length - 1
8099
+ "$isborder": id !== finalOptions.length - 1,
8100
+ "$isHighlighted": id === highlightedIndex
8040
8101
  }, React__default.createElement(OptionLabel, {
8041
8102
  htmlFor: option.value,
8042
- "$optionColor": optionColor
8103
+ "$optionColor": optionColor,
8104
+ "$isHighlighted": id === highlightedIndex
8043
8105
  }, React__default.createElement("input", {
8044
8106
  id: option.value,
8045
8107
  type: 'checkbox',
@@ -8334,6 +8396,7 @@ var MultiSelectDropdown = function MultiSelectDropdown(_ref32) {
8334
8396
  isOpen = _useState2[0],
8335
8397
  setIsOpen = _useState2[1];
8336
8398
  var dropdownRef = React.useRef(null);
8399
+ var dropdownButtonRef = React.useRef(null);
8337
8400
  var toggleDropdown = function toggleDropdown() {
8338
8401
  if (disabled) return;
8339
8402
  var refToUse = dropdownRef.current;
@@ -8399,6 +8462,34 @@ var MultiSelectDropdown = function MultiSelectDropdown(_ref32) {
8399
8462
  return v !== SELECT_ALL_VALUE;
8400
8463
  }));
8401
8464
  };
8465
+ var handleKeyDown = function handleKeyDown(e) {
8466
+ if (disabled) return;
8467
+ switch (e.key) {
8468
+ case 'Enter':
8469
+ case ' ':
8470
+ e.preventDefault();
8471
+ toggleDropdown();
8472
+ break;
8473
+ case 'Escape':
8474
+ if (isOpen) {
8475
+ e.preventDefault();
8476
+ setIsOpen(false);
8477
+ }
8478
+ break;
8479
+ case 'ArrowDown':
8480
+ if (!isOpen) {
8481
+ e.preventDefault();
8482
+ toggleDropdown();
8483
+ }
8484
+ break;
8485
+ case 'ArrowUp':
8486
+ if (!isOpen) {
8487
+ e.preventDefault();
8488
+ toggleDropdown();
8489
+ }
8490
+ break;
8491
+ }
8492
+ };
8402
8493
  return React__default.createElement(Container$2, null, title && React__default.createElement(TitleText, {
8403
8494
  "$titleColor": titleColor || themeColors.vms.text.dark,
8404
8495
  "$titleSize": titleSize,
@@ -8410,7 +8501,10 @@ var MultiSelectDropdown = function MultiSelectDropdown(_ref32) {
8410
8501
  "$height": height,
8411
8502
  "$hasTitle": !!title
8412
8503
  }, React__default.createElement(DropdownButton, {
8504
+ ref: dropdownButtonRef,
8413
8505
  onClick: toggleDropdown,
8506
+ onKeyDown: handleKeyDown,
8507
+ tabIndex: disabled ? -1 : 0,
8414
8508
  "$height": height,
8415
8509
  "$width": width,
8416
8510
  "$border": border,
@@ -8581,8 +8675,9 @@ var DropdownButton$1 = styled__default.div(_templateObject3$6 || (_templateObjec
8581
8675
  var Options = styled__default.div(_templateObject4$5 || (_templateObject4$5 = _taggedTemplateLiteralLoose(["\n color: ", ";\n padding: 5px 10px;\n width: 100%;\n font-size: ", ";\n font-weight: ", ";\n background-color: ", ";\n\n \n &:hover {\n background-color: ", ";\n color: ", ";\n cursor: pointer;\n }\n\n"])), function (_ref14) {
8582
8676
  var $optionColor = _ref14.$optionColor,
8583
8677
  $optionSelected = _ref14.$optionSelected,
8678
+ $isHighlighted = _ref14.$isHighlighted,
8584
8679
  theme = _ref14.theme;
8585
- return $optionSelected ? theme.vms.text.white : $optionColor || theme.vms.text.medium;
8680
+ return $optionSelected || $isHighlighted ? theme.vms.text.white : $optionColor || theme.vms.text.medium;
8586
8681
  }, function (_ref15) {
8587
8682
  var $optionFontSize = _ref15.$optionFontSize;
8588
8683
  return $optionFontSize || '14px';
@@ -8592,8 +8687,9 @@ var Options = styled__default.div(_templateObject4$5 || (_templateObject4$5 = _t
8592
8687
  }, function (_ref17) {
8593
8688
  var $optionBackgroundColor = _ref17.$optionBackgroundColor,
8594
8689
  $optionSelected = _ref17.$optionSelected,
8690
+ $isHighlighted = _ref17.$isHighlighted,
8595
8691
  theme = _ref17.theme;
8596
- return $optionSelected ? theme.vms["default"].primary : $optionBackgroundColor || theme.vms["default"].tertiary;
8692
+ return $optionSelected ? theme.vms["default"].primary : $isHighlighted ? theme.vms.hover.primary : $optionBackgroundColor || theme.vms["default"].tertiary;
8597
8693
  }, function (_ref18) {
8598
8694
  var theme = _ref18.theme;
8599
8695
  return theme.vms.hover.primary;
@@ -8631,7 +8727,7 @@ var LabelText$1 = styled__default.div(_templateObject5$5 || (_templateObject5$5
8631
8727
  return $disabled ? theme.vms.text.medium : $color || theme.vms.text.medium;
8632
8728
  });
8633
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"])));
8634
- 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) {
8635
8731
  var theme = _ref24.theme;
8636
8732
  return "1px solid " + theme.vms.border.light;
8637
8733
  }, function (_ref25) {
@@ -8750,13 +8846,28 @@ var SelectOption = function SelectOption(_ref37) {
8750
8846
  var _useState3 = React.useState(''),
8751
8847
  searchTerm = _useState3[0],
8752
8848
  setSearchTerm = _useState3[1];
8849
+ var _useState4 = React.useState(-1),
8850
+ highlightedIndex = _useState4[0],
8851
+ setHighlightedIndex = _useState4[1];
8852
+ var optionsWrapperRef = React.useRef(null);
8853
+ var dropdownMenuRef = React.useRef(null);
8854
+ var showSearchBox = searchBox && (options.length > 5 || allowCustomValue);
8753
8855
  React.useEffect(function () {
8754
8856
  if (loading) {
8755
8857
  setIsOpen(false);
8756
8858
  setSearchTerm('');
8859
+ setHighlightedIndex(-1);
8757
8860
  }
8758
8861
  }, [loading]);
8759
- 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]);
8760
8871
  var toggleDropdown = function toggleDropdown() {
8761
8872
  var refToUse = (positionRef === null || positionRef === void 0 ? void 0 : positionRef.current) || dropdownRef.current;
8762
8873
  if (refToUse) {
@@ -8776,6 +8887,7 @@ var SelectOption = function SelectOption(_ref37) {
8776
8887
  });
8777
8888
  if (!isOpen) {
8778
8889
  setSearchTerm('');
8890
+ setHighlightedIndex(-1);
8779
8891
  }
8780
8892
  };
8781
8893
  var dropdownRef = React.useRef(null);
@@ -8800,6 +8912,7 @@ var SelectOption = function SelectOption(_ref37) {
8800
8912
  }
8801
8913
  setIsOpen(false);
8802
8914
  setSearchTerm('');
8915
+ setHighlightedIndex(-1);
8803
8916
  };
8804
8917
  var filteredOptions = searchTerm ? options.filter(function (option) {
8805
8918
  return option.label.toLowerCase().includes(searchTerm.toLowerCase());
@@ -8824,6 +8937,7 @@ var SelectOption = function SelectOption(_ref37) {
8824
8937
  if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
8825
8938
  setIsOpen(false);
8826
8939
  setSearchTerm('');
8940
+ setHighlightedIndex(-1);
8827
8941
  }
8828
8942
  };
8829
8943
  document.addEventListener('mousedown', handleClickOutside);
@@ -8831,12 +8945,63 @@ var SelectOption = function SelectOption(_ref37) {
8831
8945
  document.removeEventListener('mousedown', handleClickOutside);
8832
8946
  };
8833
8947
  }, []);
8948
+ React.useEffect(function () {
8949
+ if (highlightedIndex >= 0 && optionsWrapperRef.current) {
8950
+ var children = optionsWrapperRef.current.children;
8951
+ var offset = isCustomValue ? 1 : 0;
8952
+ var highlightedElement = children[highlightedIndex + offset];
8953
+ if (highlightedElement) {
8954
+ highlightedElement.scrollIntoView({
8955
+ block: 'nearest',
8956
+ behavior: 'smooth'
8957
+ });
8958
+ }
8959
+ }
8960
+ }, [highlightedIndex, isCustomValue]);
8834
8961
  var selectedOption = options === null || options === void 0 ? void 0 : options.find(function (option) {
8835
8962
  return option.value === value;
8836
8963
  });
8837
8964
  var displayLabel = (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) || (allowCustomValue && value ? value : '');
8838
8965
  var handleSearchChange = function handleSearchChange(e) {
8839
8966
  setSearchTerm(e.target.value);
8967
+ setHighlightedIndex(-1);
8968
+ };
8969
+ var handleKeyDown = function handleKeyDown(e) {
8970
+ var totalOptions = isCustomValue ? filteredOptions.length + 1 : filteredOptions.length;
8971
+ if (totalOptions === 0) return;
8972
+ switch (e.key) {
8973
+ case 'ArrowDown':
8974
+ e.preventDefault();
8975
+ setHighlightedIndex(function (prev) {
8976
+ var newIndex = prev < totalOptions - 1 ? prev + 1 : prev;
8977
+ return prev === -1 ? 0 : newIndex;
8978
+ });
8979
+ break;
8980
+ case 'ArrowUp':
8981
+ e.preventDefault();
8982
+ setHighlightedIndex(function (prev) {
8983
+ return prev > 0 ? prev - 1 : 0;
8984
+ });
8985
+ break;
8986
+ case 'Enter':
8987
+ e.preventDefault();
8988
+ if (highlightedIndex >= 0) {
8989
+ if (isCustomValue && highlightedIndex === 0) {
8990
+ handleCustomValueSelect();
8991
+ } else {
8992
+ var adjustedIndex = isCustomValue ? highlightedIndex - 1 : highlightedIndex;
8993
+ if (adjustedIndex >= 0 && adjustedIndex < filteredOptions.length) {
8994
+ handleOptionClick(filteredOptions[adjustedIndex].value);
8995
+ }
8996
+ }
8997
+ }
8998
+ break;
8999
+ case 'Escape':
9000
+ setIsOpen(false);
9001
+ setSearchTerm('');
9002
+ setHighlightedIndex(-1);
9003
+ break;
9004
+ }
8840
9005
  };
8841
9006
  return React__default.createElement(Container, {
8842
9007
  "$padding": padding,
@@ -8889,6 +9054,9 @@ var SelectOption = function SelectOption(_ref37) {
8889
9054
  size: 7,
8890
9055
  color: color || themeColors.vms.text.medium
8891
9056
  })), isOpen && React__default.createElement(DropdownMenu$1, {
9057
+ ref: dropdownMenuRef,
9058
+ tabIndex: -1,
9059
+ onKeyDown: !showSearchBox ? handleKeyDown : undefined,
8892
9060
  "$width": width,
8893
9061
  "$menuBackground": menuBackground,
8894
9062
  "$optionsBorderRadius": optionsBorderRadius,
@@ -8910,13 +9078,17 @@ var SelectOption = function SelectOption(_ref37) {
8910
9078
  type: 'text',
8911
9079
  value: searchTerm,
8912
9080
  onChange: handleSearchChange,
9081
+ onKeyDown: handleKeyDown,
8913
9082
  placeholder: placeholderText,
8914
9083
  "$inputColor": inputColor,
8915
9084
  "$placeholderColor": placeholderColor
8916
- })), React__default.createElement(OptionsWrapper, null, isCustomValue && React__default.createElement(Options, {
9085
+ })), React__default.createElement(OptionsWrapper, {
9086
+ ref: optionsWrapperRef
9087
+ }, isCustomValue && React__default.createElement(Options, {
8917
9088
  "$optionSelected": false,
9089
+ "$isHighlighted": highlightedIndex === 0,
8918
9090
  onClick: handleCustomValueSelect
8919
- }, "Add \"", normalizedSearch, "\""), filteredOptions.length ? filteredOptions.map(function (option) {
9091
+ }, "Add \"", normalizedSearch, "\""), filteredOptions.length ? filteredOptions.map(function (option, index) {
8920
9092
  return React__default.createElement(Options, {
8921
9093
  key: option.value,
8922
9094
  "$optionColor": optionColor,
@@ -8926,7 +9098,8 @@ var SelectOption = function SelectOption(_ref37) {
8926
9098
  onClick: function onClick() {
8927
9099
  return handleOptionClick(option.value);
8928
9100
  },
8929
- "$optionSelected": option.value === value || allowCustomValue && option.value === displayLabel
9101
+ "$optionSelected": option.value === value || allowCustomValue && option.value === displayLabel,
9102
+ "$isHighlighted": isCustomValue ? index + 1 === highlightedIndex : index === highlightedIndex
8930
9103
  }, option.label);
8931
9104
  }) : !isCustomValue && React__default.createElement(NoOptions, null, NoOptionsText)))));
8932
9105
  };
@@ -9720,12 +9893,14 @@ var OptionContainer$1 = styled__default.div(_templateObject$h || (_templateObjec
9720
9893
  });
9721
9894
  var OptionItem$1 = styled__default.div(_templateObject2$e || (_templateObject2$e = _taggedTemplateLiteralLoose(["\n color: ", ";\n background-color: ", ";\n border-radius: 8px;\n\n &:hover {\n background-color: ", ";\n color: ", ";\n cursor: pointer;\n }\n"])), function (_ref2) {
9722
9895
  var $optionSelected = _ref2.$optionSelected,
9896
+ $isHighlighted = _ref2.$isHighlighted,
9723
9897
  theme = _ref2.theme;
9724
- return $optionSelected ? theme.vms.text.white : theme.vms.text.medium;
9898
+ return $optionSelected || $isHighlighted ? theme.vms.text.white : theme.vms.text.medium;
9725
9899
  }, function (_ref3) {
9726
9900
  var $optionSelected = _ref3.$optionSelected,
9901
+ $isHighlighted = _ref3.$isHighlighted,
9727
9902
  theme = _ref3.theme;
9728
- return $optionSelected ? theme.vms["default"].primary : theme.vms.text.white;
9903
+ return $optionSelected ? theme.vms["default"].primary : $isHighlighted ? theme.vms.hover.primary : theme.vms.text.white;
9729
9904
  }, function (_ref4) {
9730
9905
  var theme = _ref4.theme;
9731
9906
  return theme.vms.hover.primary;
@@ -9851,19 +10026,57 @@ var TextFieldWithDropdown = function TextFieldWithDropdown(_ref16) {
9851
10026
  var _useTranslation = reactI18next.useTranslation(),
9852
10027
  t = _useTranslation.t;
9853
10028
  var searchBoxRef = React.useRef(null);
10029
+ var optionsWrapperRef = React.useRef(null);
9854
10030
  var _useState = React.useState(false),
9855
10031
  isSearchBarEnabled = _useState[0],
9856
10032
  setIsSearchBarEnabled = _useState[1];
10033
+ var _useState2 = React.useState(-1),
10034
+ highlightedIndex = _useState2[0],
10035
+ setHighlightedIndex = _useState2[1];
9857
10036
  var filteredArray = options.filter(function (item) {
9858
10037
  return item.labelText.toLowerCase().includes(internalSearchQuery.toLowerCase().trim());
9859
10038
  });
9860
10039
  var handleSearchChange = function handleSearchChange(e) {
9861
10040
  var value = e.target.value.trimStart();
9862
10041
  setInternalSearchQuery(value);
10042
+ setHighlightedIndex(-1);
10043
+ };
10044
+ var handleKeyDown = function handleKeyDown(e) {
10045
+ if (!isSearchBarEnabled || filteredArray.length === 0) return;
10046
+ switch (e.key) {
10047
+ case 'ArrowDown':
10048
+ e.preventDefault();
10049
+ setHighlightedIndex(function (prev) {
10050
+ return prev < filteredArray.length - 1 ? prev + 1 : prev;
10051
+ });
10052
+ break;
10053
+ case 'ArrowUp':
10054
+ e.preventDefault();
10055
+ setHighlightedIndex(function (prev) {
10056
+ return prev > 0 ? prev - 1 : -1;
10057
+ });
10058
+ break;
10059
+ case 'Enter':
10060
+ e.preventDefault();
10061
+ if (highlightedIndex >= 0 && highlightedIndex < filteredArray.length) {
10062
+ var _selectedOption = filteredArray[highlightedIndex];
10063
+ setInternalSearchQuery(_selectedOption.labelText);
10064
+ setSearchQuery(_selectedOption.labelText);
10065
+ setIsSearchBarEnabled(false);
10066
+ setHighlightedIndex(-1);
10067
+ if (onSelect) onSelect(_selectedOption);
10068
+ }
10069
+ break;
10070
+ case 'Escape':
10071
+ setIsSearchBarEnabled(false);
10072
+ setHighlightedIndex(-1);
10073
+ break;
10074
+ }
9863
10075
  };
9864
10076
  var handleClickOutside = function handleClickOutside(event) {
9865
10077
  if (searchBoxRef.current && !searchBoxRef.current.contains(event.target)) {
9866
10078
  setIsSearchBarEnabled(false);
10079
+ setHighlightedIndex(-1);
9867
10080
  }
9868
10081
  };
9869
10082
  React.useEffect(function () {
@@ -9872,6 +10085,17 @@ var TextFieldWithDropdown = function TextFieldWithDropdown(_ref16) {
9872
10085
  document.removeEventListener('mousedown', handleClickOutside);
9873
10086
  };
9874
10087
  }, []);
10088
+ React.useEffect(function () {
10089
+ if (highlightedIndex >= 0 && optionsWrapperRef.current) {
10090
+ var highlightedElement = optionsWrapperRef.current.children[highlightedIndex];
10091
+ if (highlightedElement) {
10092
+ highlightedElement.scrollIntoView({
10093
+ block: 'nearest',
10094
+ behavior: 'smooth'
10095
+ });
10096
+ }
10097
+ }
10098
+ }, [highlightedIndex]);
9875
10099
  return React__default.createElement(Container, {
9876
10100
  "$flexDirection": 'column',
9877
10101
  "$gap": '8px',
@@ -9898,6 +10122,7 @@ var TextFieldWithDropdown = function TextFieldWithDropdown(_ref16) {
9898
10122
  placeholder: placeholder,
9899
10123
  value: internalSearchQuery,
9900
10124
  onChange: handleSearchChange,
10125
+ onKeyDown: handleKeyDown,
9901
10126
  "$inputColor": searchbarTextColor,
9902
10127
  "$placeholderColor": isSearchBarEnabled ? themeColors.vms.text.light : themeColors.vms.text.medium,
9903
10128
  disabled: !!searchQuery
@@ -9917,16 +10142,20 @@ var TextFieldWithDropdown = function TextFieldWithDropdown(_ref16) {
9917
10142
  "$fontSize": '12px',
9918
10143
  "$fontWeight": '400',
9919
10144
  "$color": themeColors.vms.text.light
9920
- }, t('Showing_results') + " (" + filteredArray.length + " of " + (options === null || options === void 0 ? void 0 : options.length) + ")")), React__default.createElement(OptionsWrapper$1, null, filteredArray.length > 0 ? filteredArray.map(function (option) {
10145
+ }, t('Showing_results') + " (" + filteredArray.length + " of " + (options === null || options === void 0 ? void 0 : options.length) + ")")), React__default.createElement(OptionsWrapper$1, {
10146
+ ref: optionsWrapperRef
10147
+ }, filteredArray.length > 0 ? filteredArray.map(function (option, index) {
9921
10148
  return React__default.createElement(OptionItem$1, {
9922
10149
  key: option.value,
9923
- "$optionSelected": option.value === selectedOption
10150
+ "$optionSelected": option.value === selectedOption,
10151
+ "$isHighlighted": index === highlightedIndex
9924
10152
  }, React__default.createElement(OptionLabel$1, {
9925
10153
  htmlFor: option.value,
9926
10154
  onClick: function onClick() {
9927
10155
  setInternalSearchQuery(option.labelText);
9928
10156
  setSearchQuery(option.labelText);
9929
10157
  setIsSearchBarEnabled(false);
10158
+ setHighlightedIndex(-1);
9930
10159
  if (onSelect) onSelect(option);
9931
10160
  }
9932
10161
  }, option.labelText));