@thecb/components 6.0.0-beta.15 → 6.0.0-beta.18

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.cjs.js CHANGED
@@ -19408,7 +19408,7 @@ var fallbackValues$e = {
19408
19408
  var IconWrapper = styled__default.div.withConfig({
19409
19409
  displayName: "Dropdown__IconWrapper",
19410
19410
  componentId: "sc-pn6m0h-0"
19411
- })(["display:flex;flex-direction:column;justify-content:center;transition:transform 0.3s ease;", " position:absolute;top:20px;right:12px;"], function (_ref) {
19411
+ })(["position:absolute;display:flex;flex-direction:column;justify-content:center;transition:transform 0.3s ease;", ";top:20px;right:12px;"], function (_ref) {
19412
19412
  var open = _ref.open;
19413
19413
  return open ? "transform: rotate(-180deg)" : "";
19414
19414
  });
@@ -19529,7 +19529,7 @@ var Dropdown = function Dropdown(_ref8) {
19529
19529
  var onKeyDown = function onKeyDown(e) {
19530
19530
  var _optionRefs$current$l, _optionRefs$current;
19531
19531
 
19532
- console.log("current input value", inputValue);
19532
+ console.log("current input value top of keyDown", inputValue);
19533
19533
  var key = e.key,
19534
19534
  keyCode = e.keyCode;
19535
19535
  var focus = document.activeElement;
@@ -19542,6 +19542,10 @@ var Dropdown = function Dropdown(_ref8) {
19542
19542
  case "ArrowDown":
19543
19543
  e.preventDefault();
19544
19544
 
19545
+ if (!isOpen) {
19546
+ _onClick();
19547
+ }
19548
+
19545
19549
  if (optionEl) {
19546
19550
  if (optionEl.current.nextElementSibling) {
19547
19551
  optionEl.current.nextElementSibling.focus();
@@ -19600,6 +19604,25 @@ var Dropdown = function Dropdown(_ref8) {
19600
19604
 
19601
19605
  break;
19602
19606
  }
19607
+
19608
+ if (keyCode > 64 && keyCode < 91 || keyCode == 32 || keyCode == 189) {
19609
+ e.preventDefault();
19610
+ console.log("current input value inside keydown if", inputValue);
19611
+ setInputValue(inputValue + key);
19612
+ }
19613
+ };
19614
+
19615
+ var handleItemSelection = function handleItemSelection(evt, choice, i) {
19616
+ disabledValues.includes(choice.value) ? function (evt) {
19617
+ return evt.preventDefault();
19618
+ } : function () {
19619
+ setSelectedRef(optionRefs.current[i]);
19620
+ onSelect(choice.value);
19621
+
19622
+ if (isOpen) {
19623
+ _onClick();
19624
+ }
19625
+ };
19603
19626
  };
19604
19627
 
19605
19628
  React.useEffect(function () {
@@ -19643,13 +19666,12 @@ var Dropdown = function Dropdown(_ref8) {
19643
19666
  extraStyles: "position: relative;",
19644
19667
  minWidth: "100%",
19645
19668
  onClick: function onClick() {
19646
- _onClick();
19669
+ if (!isOpen) {
19670
+ _onClick();
19671
+ }
19647
19672
  },
19648
19673
  onKeyDown: onKeyDown,
19649
19674
  width: "100%"
19650
- }, /*#__PURE__*/React__default.createElement(Stack, {
19651
- direction: "row",
19652
- bottomItem: 2
19653
19675
  }, /*#__PURE__*/React__default.createElement(Box, {
19654
19676
  as: "input",
19655
19677
  "aria-multiline": "false",
@@ -19665,7 +19687,6 @@ var Dropdown = function Dropdown(_ref8) {
19665
19687
  borderRadius: "2px",
19666
19688
  borderSize: "1px",
19667
19689
  borderColor: isError ? ERROR_COLOR : isOpen ? themeValues.selectedColor : GREY_CHATEAU,
19668
- borderWidthOverride: "1px 0px 1px 1px",
19669
19690
  extraStyles: disabled && "color: #6e727e;\n background-color: #f7f7f7;\n pointer-events: none;",
19670
19691
  hoverStyles: "background-color: ".concat(themeValues.hoverColor, ";"),
19671
19692
  isOpen: isOpen,
@@ -19673,15 +19694,20 @@ var Dropdown = function Dropdown(_ref8) {
19673
19694
  minWidth: "100%",
19674
19695
  name: autocompleteValue,
19675
19696
  onFocus: function onFocus() {
19697
+ /*
19676
19698
  if (!isOpen) {
19677
- _onClick();
19699
+ onClick();
19678
19700
  }
19701
+ */
19679
19702
  },
19680
19703
  onChange: function onChange(e) {
19681
- console.log("current input value", inputValue);
19704
+ console.log("current input value onChange", inputValue);
19682
19705
  console.log("input change event", e.target);
19683
- console.log("input change event value", e.target.value);
19684
- setInputValue(e.target.value);
19706
+ console.log("input change event value", e.target.value); // support autofill and copy/paste
19707
+
19708
+ if (e.tarvet.value !== inputValue) {
19709
+ setInputValue(e.target.value);
19710
+ }
19685
19711
  },
19686
19712
  padding: "12px",
19687
19713
  placeholder: getSelection(),
@@ -19694,8 +19720,9 @@ var Dropdown = function Dropdown(_ref8) {
19694
19720
  width: "100%",
19695
19721
  dataQa: placeholder
19696
19722
  }), /*#__PURE__*/React__default.createElement(IconWrapper, {
19697
- open: isOpen
19698
- }, /*#__PURE__*/React__default.createElement(DropdownIcon, null))), /*#__PURE__*/React__default.createElement(React.Fragment, null, isOpen ? /*#__PURE__*/React__default.createElement(DropdownContentWrapper, {
19723
+ open: isOpen,
19724
+ onClick: _onClick
19725
+ }, /*#__PURE__*/React__default.createElement(DropdownIcon, null)), /*#__PURE__*/React__default.createElement(React.Fragment, null, isOpen ? /*#__PURE__*/React__default.createElement(DropdownContentWrapper, {
19699
19726
  maxHeight: maxHeight,
19700
19727
  open: isOpen,
19701
19728
  ref: dropdownRef,
@@ -19716,11 +19743,13 @@ var Dropdown = function Dropdown(_ref8) {
19716
19743
  key: choice.value,
19717
19744
  ref: optionRefs.current[i],
19718
19745
  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);
19746
+ onClick: function onClick(e) {
19747
+ return handleItemSelection(e, choice, i);
19748
+ },
19749
+ onKeyDown: function onKeyDown(e) {
19750
+ if (e.keyCode === 13) {
19751
+ handleItemSelection(e, choice, i);
19752
+ }
19724
19753
  },
19725
19754
  selected: choice.value === value,
19726
19755
  "aria-selected": choice.value === value,