@thecb/components 6.0.0-beta.16 → 6.0.0-beta.19

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.esm.js CHANGED
@@ -19400,7 +19400,7 @@ var fallbackValues$e = {
19400
19400
  var IconWrapper = styled.div.withConfig({
19401
19401
  displayName: "Dropdown__IconWrapper",
19402
19402
  componentId: "sc-pn6m0h-0"
19403
- })(["position:absolute;display:flex;flex-direction:column;justify-content:center;transition:transform 0.3s ease;", " top:20px;right:12px;"], function (_ref) {
19403
+ })(["position:absolute;display:flex;flex-direction:column;justify-content:center;transition:transform 0.3s ease;", ";top:20px;right:12px;"], function (_ref) {
19404
19404
  var open = _ref.open;
19405
19405
  return open ? "transform: rotate(-180deg)" : "";
19406
19406
  });
@@ -19521,7 +19521,7 @@ var Dropdown = function Dropdown(_ref8) {
19521
19521
  var onKeyDown = function onKeyDown(e) {
19522
19522
  var _optionRefs$current$l, _optionRefs$current;
19523
19523
 
19524
- console.log("current input value", inputValue);
19524
+ console.log("current input value top of keyDown", inputValue);
19525
19525
  var key = e.key,
19526
19526
  keyCode = e.keyCode;
19527
19527
  var focus = document.activeElement;
@@ -19599,10 +19599,24 @@ var Dropdown = function Dropdown(_ref8) {
19599
19599
 
19600
19600
  if (keyCode > 64 && keyCode < 91 || keyCode == 32 || keyCode == 189) {
19601
19601
  e.preventDefault();
19602
+ console.log("current input value inside keydown if", inputValue);
19602
19603
  setInputValue(inputValue + key);
19603
19604
  }
19604
19605
  };
19605
19606
 
19607
+ var handleItemSelection = function handleItemSelection(evt, choice, i) {
19608
+ if (disabledValues.includes(choice.value)) {
19609
+ evt.preventDefault();
19610
+ } else {
19611
+ setSelectedRef(optionRefs.current[i]);
19612
+ onSelect(choice.value);
19613
+
19614
+ if (isOpen) {
19615
+ _onClick();
19616
+ }
19617
+ }
19618
+ };
19619
+
19606
19620
  useEffect$1(function () {
19607
19621
  if (isOpen && selectedRef !== undefined && selectedRef.current !== null) {
19608
19622
  // WAI-ARIA requires the selected option to receive focus
@@ -19672,15 +19686,20 @@ var Dropdown = function Dropdown(_ref8) {
19672
19686
  minWidth: "100%",
19673
19687
  name: autocompleteValue,
19674
19688
  onFocus: function onFocus() {
19689
+ /*
19675
19690
  if (!isOpen) {
19676
- _onClick();
19691
+ onClick();
19677
19692
  }
19693
+ */
19678
19694
  },
19679
19695
  onChange: function onChange(e) {
19680
- console.log("current input value", inputValue);
19696
+ console.log("current input value onChange", inputValue);
19681
19697
  console.log("input change event", e.target);
19682
- console.log("input change event value", e.target.value);
19683
- setInputValue(e.target.value);
19698
+ console.log("input change event value", e.target.value); // support autofill and copy/paste
19699
+
19700
+ if (e.tarvet.value !== inputValue) {
19701
+ setInputValue(e.target.value);
19702
+ }
19684
19703
  },
19685
19704
  padding: "12px",
19686
19705
  placeholder: getSelection(),
@@ -19716,11 +19735,13 @@ var Dropdown = function Dropdown(_ref8) {
19716
19735
  key: choice.value,
19717
19736
  ref: optionRefs.current[i],
19718
19737
  tabIndex: -1,
19719
- onClick: disabledValues.includes(choice.value) ? function (evt) {
19720
- return evt.preventDefault();
19721
- } : function () {
19722
- setSelectedRef(optionRefs.current[i]);
19723
- onSelect(choice.value);
19738
+ onClick: function onClick(e) {
19739
+ return handleItemSelection(e, choice, i);
19740
+ },
19741
+ onKeyDown: function onKeyDown(e) {
19742
+ if (e.keyCode === 13) {
19743
+ handleItemSelection(e, choice, i);
19744
+ }
19724
19745
  },
19725
19746
  selected: choice.value === value,
19726
19747
  "aria-selected": choice.value === value,