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

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,14 +19400,14 @@ var fallbackValues$e = {
19400
19400
  var IconWrapper = styled.div.withConfig({
19401
19401
  displayName: "Dropdown__IconWrapper",
19402
19402
  componentId: "sc-pn6m0h-0"
19403
- })(["display:flex;flex-direction:column;justify-content:center;transition:transform 0.3s ease;", ""], 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
  });
19407
19407
  var DropdownContentWrapper = styled.div.withConfig({
19408
19408
  displayName: "Dropdown__DropdownContentWrapper",
19409
19409
  componentId: "sc-pn6m0h-1"
19410
- })(["transform-origin:0 0;border:1px solid ", ";border-radius:2px;background-color:", ";padding:8px 0 8px;position:absolute;width:", ";min-width:100%;max-height:", ";overflow-y:scroll;z-index:1;box-sizing:border-box;&:focus{outline:none;}"], GREY_CHATEAU, WHITE, function (_ref2) {
19410
+ })(["transform-origin:0 0;border:1px solid ", ";border-radius:2px;background-color:", ";padding:8px 0 8px;position:absolute;width:", ";min-width:100%;max-height:", ";overflow-y:scroll;z-index:1;box-sizing:border-box;&:focus{outline:none;}ul{padding-left:0;}"], GREY_CHATEAU, WHITE, function (_ref2) {
19411
19411
  var widthFitOptions = _ref2.widthFitOptions;
19412
19412
  return widthFitOptions ? "fit-content" : "100%";
19413
19413
  }, function (_ref3) {
@@ -19446,7 +19446,7 @@ var Dropdown = function Dropdown(_ref8) {
19446
19446
  _ref8$disabledValues = _ref8.disabledValues,
19447
19447
  disabledValues = _ref8$disabledValues === void 0 ? [] : _ref8$disabledValues,
19448
19448
  _ref8$onClick = _ref8.onClick,
19449
- onClick = _ref8$onClick === void 0 ? noop : _ref8$onClick,
19449
+ _onClick = _ref8$onClick === void 0 ? noop : _ref8$onClick,
19450
19450
  themeValues = _ref8.themeValues,
19451
19451
  maxHeight = _ref8.maxHeight,
19452
19452
  _ref8$widthFitOptions = _ref8.widthFitOptions,
@@ -19521,23 +19521,23 @@ 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("key down event is", e.target);
19525
- console.log("key down event value is", e.target.value);
19524
+ console.log("current input value", inputValue);
19526
19525
  var key = e.key,
19527
19526
  keyCode = e.keyCode;
19528
19527
  var focus = document.activeElement;
19529
19528
  console.log("dropdown value is", value);
19530
- console.log("focus is", focus);
19531
- console.log("option refs are", optionRefs.current);
19532
19529
  var optionEl = optionRefs.current.find(function (ref) {
19533
19530
  return ref.current === focus;
19534
19531
  });
19535
- console.log("option el is", optionEl);
19536
19532
 
19537
19533
  switch (key) {
19538
19534
  case "ArrowDown":
19539
19535
  e.preventDefault();
19540
19536
 
19537
+ if (!isOpen) {
19538
+ _onClick();
19539
+ }
19540
+
19541
19541
  if (optionEl) {
19542
19542
  if (optionEl.current.nextElementSibling) {
19543
19543
  optionEl.current.nextElementSibling.focus();
@@ -19546,7 +19546,7 @@ var Dropdown = function Dropdown(_ref8) {
19546
19546
  break;
19547
19547
  }
19548
19548
  } else {
19549
- onClick();
19549
+ _onClick();
19550
19550
  }
19551
19551
 
19552
19552
  break;
@@ -19562,7 +19562,7 @@ var Dropdown = function Dropdown(_ref8) {
19562
19562
  break;
19563
19563
  }
19564
19564
  } else {
19565
- onClick();
19565
+ _onClick();
19566
19566
  }
19567
19567
 
19568
19568
  break;
@@ -19591,19 +19591,19 @@ var Dropdown = function Dropdown(_ref8) {
19591
19591
 
19592
19592
  case "Escape":
19593
19593
  if (isOpen) {
19594
- onClick();
19594
+ _onClick();
19595
19595
  }
19596
19596
 
19597
19597
  break;
19598
19598
  }
19599
+
19600
+ if (keyCode > 64 && keyCode < 91 || keyCode == 32 || keyCode == 189) {
19601
+ e.preventDefault();
19602
+ setInputValue(inputValue + key);
19603
+ }
19599
19604
  };
19600
19605
 
19601
19606
  useEffect$1(function () {
19602
- console.log("option refs in isopen useffect", optionRefs);
19603
- console.log("option ref current in isopen useffect", optionRefs.current[0].current);
19604
- console.log("selected refs in isopen useffect", selectedRef);
19605
- console.log("value in isopen useffect", value);
19606
-
19607
19607
  if (isOpen && selectedRef !== undefined && selectedRef.current !== null) {
19608
19608
  // WAI-ARIA requires the selected option to receive focus
19609
19609
  selectedRef.current.focus();
@@ -19629,8 +19629,6 @@ var Dropdown = function Dropdown(_ref8) {
19629
19629
  }, [inputValue]);
19630
19630
  useEffect$1(function () {
19631
19631
  if (!isOpen && filteredOptions[0] && !disabledValues.includes(filteredOptions[0].value) && filteredOptions[0].text != placeholder) {
19632
- console.log("filtered options are", filteredOptions);
19633
- console.log("option refs are", optionRefs);
19634
19632
  onSelect(filteredOptions[0].value);
19635
19633
  }
19636
19634
 
@@ -19642,12 +19640,16 @@ var Dropdown = function Dropdown(_ref8) {
19642
19640
  }, [filteredOptions]);
19643
19641
  return /*#__PURE__*/React.createElement(Box, {
19644
19642
  padding: "0",
19643
+ background: isOpen ? themeValues.hoverColor : WHITE,
19645
19644
  extraStyles: "position: relative;",
19646
19645
  minWidth: "100%",
19646
+ onClick: function onClick() {
19647
+ if (!isOpen) {
19648
+ _onClick();
19649
+ }
19650
+ },
19651
+ onKeyDown: onKeyDown,
19647
19652
  width: "100%"
19648
- }, /*#__PURE__*/React.createElement(Stack, {
19649
- direction: "row",
19650
- bottomItem: 2
19651
19653
  }, /*#__PURE__*/React.createElement(Box, {
19652
19654
  as: "input",
19653
19655
  "aria-multiline": "false",
@@ -19666,12 +19668,16 @@ var Dropdown = function Dropdown(_ref8) {
19666
19668
  extraStyles: disabled && "color: #6e727e;\n background-color: #f7f7f7;\n pointer-events: none;",
19667
19669
  hoverStyles: "background-color: ".concat(themeValues.hoverColor, ";"),
19668
19670
  isOpen: isOpen,
19669
- minWidth: "85%",
19671
+ minHeight: "48px",
19672
+ minWidth: "100%",
19670
19673
  name: autocompleteValue,
19671
- onKeyDown: onKeyDown,
19672
- onClick: onClick,
19673
- onFocus: onClick,
19674
+ onFocus: function onFocus() {
19675
+ if (!isOpen) {
19676
+ _onClick();
19677
+ }
19678
+ },
19674
19679
  onChange: function onChange(e) {
19680
+ console.log("current input value", inputValue);
19675
19681
  console.log("input change event", e.target);
19676
19682
  console.log("input change event value", e.target.value);
19677
19683
  setInputValue(e.target.value);
@@ -19682,13 +19688,14 @@ var Dropdown = function Dropdown(_ref8) {
19682
19688
  themeValues: themeValues,
19683
19689
  title: hasTitles ? getSelection() : null,
19684
19690
  type: "text",
19685
- tabIndex: -1,
19691
+ tabIndex: 0,
19686
19692
  value: inputValue,
19687
- width: "85%",
19693
+ width: "100%",
19688
19694
  dataQa: placeholder
19689
19695
  }), /*#__PURE__*/React.createElement(IconWrapper, {
19690
- open: isOpen
19691
- }, /*#__PURE__*/React.createElement(DropdownIcon, null))), /*#__PURE__*/React.createElement(Fragment, null, isOpen ? /*#__PURE__*/React.createElement(DropdownContentWrapper, {
19696
+ open: isOpen,
19697
+ onClick: _onClick
19698
+ }, /*#__PURE__*/React.createElement(DropdownIcon, null)), /*#__PURE__*/React.createElement(Fragment, null, isOpen ? /*#__PURE__*/React.createElement(DropdownContentWrapper, {
19692
19699
  maxHeight: maxHeight,
19693
19700
  open: isOpen,
19694
19701
  ref: dropdownRef,