@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.cjs.js CHANGED
@@ -19408,14 +19408,14 @@ 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;", ""], 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
  });
19415
19415
  var DropdownContentWrapper = styled__default.div.withConfig({
19416
19416
  displayName: "Dropdown__DropdownContentWrapper",
19417
19417
  componentId: "sc-pn6m0h-1"
19418
- })(["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) {
19418
+ })(["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) {
19419
19419
  var widthFitOptions = _ref2.widthFitOptions;
19420
19420
  return widthFitOptions ? "fit-content" : "100%";
19421
19421
  }, function (_ref3) {
@@ -19454,7 +19454,7 @@ var Dropdown = function Dropdown(_ref8) {
19454
19454
  _ref8$disabledValues = _ref8.disabledValues,
19455
19455
  disabledValues = _ref8$disabledValues === void 0 ? [] : _ref8$disabledValues,
19456
19456
  _ref8$onClick = _ref8.onClick,
19457
- onClick = _ref8$onClick === void 0 ? noop : _ref8$onClick,
19457
+ _onClick = _ref8$onClick === void 0 ? noop : _ref8$onClick,
19458
19458
  themeValues = _ref8.themeValues,
19459
19459
  maxHeight = _ref8.maxHeight,
19460
19460
  _ref8$widthFitOptions = _ref8.widthFitOptions,
@@ -19529,23 +19529,23 @@ 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("key down event is", e.target);
19533
- console.log("key down event value is", e.target.value);
19532
+ console.log("current input value", inputValue);
19534
19533
  var key = e.key,
19535
19534
  keyCode = e.keyCode;
19536
19535
  var focus = document.activeElement;
19537
19536
  console.log("dropdown value is", value);
19538
- console.log("focus is", focus);
19539
- console.log("option refs are", optionRefs.current);
19540
19537
  var optionEl = optionRefs.current.find(function (ref) {
19541
19538
  return ref.current === focus;
19542
19539
  });
19543
- console.log("option el is", optionEl);
19544
19540
 
19545
19541
  switch (key) {
19546
19542
  case "ArrowDown":
19547
19543
  e.preventDefault();
19548
19544
 
19545
+ if (!isOpen) {
19546
+ _onClick();
19547
+ }
19548
+
19549
19549
  if (optionEl) {
19550
19550
  if (optionEl.current.nextElementSibling) {
19551
19551
  optionEl.current.nextElementSibling.focus();
@@ -19554,7 +19554,7 @@ var Dropdown = function Dropdown(_ref8) {
19554
19554
  break;
19555
19555
  }
19556
19556
  } else {
19557
- onClick();
19557
+ _onClick();
19558
19558
  }
19559
19559
 
19560
19560
  break;
@@ -19570,7 +19570,7 @@ var Dropdown = function Dropdown(_ref8) {
19570
19570
  break;
19571
19571
  }
19572
19572
  } else {
19573
- onClick();
19573
+ _onClick();
19574
19574
  }
19575
19575
 
19576
19576
  break;
@@ -19599,19 +19599,19 @@ var Dropdown = function Dropdown(_ref8) {
19599
19599
 
19600
19600
  case "Escape":
19601
19601
  if (isOpen) {
19602
- onClick();
19602
+ _onClick();
19603
19603
  }
19604
19604
 
19605
19605
  break;
19606
19606
  }
19607
+
19608
+ if (keyCode > 64 && keyCode < 91 || keyCode == 32 || keyCode == 189) {
19609
+ e.preventDefault();
19610
+ setInputValue(inputValue + key);
19611
+ }
19607
19612
  };
19608
19613
 
19609
19614
  React.useEffect(function () {
19610
- console.log("option refs in isopen useffect", optionRefs);
19611
- console.log("option ref current in isopen useffect", optionRefs.current[0].current);
19612
- console.log("selected refs in isopen useffect", selectedRef);
19613
- console.log("value in isopen useffect", value);
19614
-
19615
19615
  if (isOpen && selectedRef !== undefined && selectedRef.current !== null) {
19616
19616
  // WAI-ARIA requires the selected option to receive focus
19617
19617
  selectedRef.current.focus();
@@ -19637,8 +19637,6 @@ var Dropdown = function Dropdown(_ref8) {
19637
19637
  }, [inputValue]);
19638
19638
  React.useEffect(function () {
19639
19639
  if (!isOpen && filteredOptions[0] && !disabledValues.includes(filteredOptions[0].value) && filteredOptions[0].text != placeholder) {
19640
- console.log("filtered options are", filteredOptions);
19641
- console.log("option refs are", optionRefs);
19642
19640
  onSelect(filteredOptions[0].value);
19643
19641
  }
19644
19642
 
@@ -19650,12 +19648,16 @@ var Dropdown = function Dropdown(_ref8) {
19650
19648
  }, [filteredOptions]);
19651
19649
  return /*#__PURE__*/React__default.createElement(Box, {
19652
19650
  padding: "0",
19651
+ background: isOpen ? themeValues.hoverColor : WHITE,
19653
19652
  extraStyles: "position: relative;",
19654
19653
  minWidth: "100%",
19654
+ onClick: function onClick() {
19655
+ if (!isOpen) {
19656
+ _onClick();
19657
+ }
19658
+ },
19659
+ onKeyDown: onKeyDown,
19655
19660
  width: "100%"
19656
- }, /*#__PURE__*/React__default.createElement(Stack, {
19657
- direction: "row",
19658
- bottomItem: 2
19659
19661
  }, /*#__PURE__*/React__default.createElement(Box, {
19660
19662
  as: "input",
19661
19663
  "aria-multiline": "false",
@@ -19674,12 +19676,16 @@ var Dropdown = function Dropdown(_ref8) {
19674
19676
  extraStyles: disabled && "color: #6e727e;\n background-color: #f7f7f7;\n pointer-events: none;",
19675
19677
  hoverStyles: "background-color: ".concat(themeValues.hoverColor, ";"),
19676
19678
  isOpen: isOpen,
19677
- minWidth: "85%",
19679
+ minHeight: "48px",
19680
+ minWidth: "100%",
19678
19681
  name: autocompleteValue,
19679
- onKeyDown: onKeyDown,
19680
- onClick: onClick,
19681
- onFocus: onClick,
19682
+ onFocus: function onFocus() {
19683
+ if (!isOpen) {
19684
+ _onClick();
19685
+ }
19686
+ },
19682
19687
  onChange: function onChange(e) {
19688
+ console.log("current input value", inputValue);
19683
19689
  console.log("input change event", e.target);
19684
19690
  console.log("input change event value", e.target.value);
19685
19691
  setInputValue(e.target.value);
@@ -19690,13 +19696,14 @@ var Dropdown = function Dropdown(_ref8) {
19690
19696
  themeValues: themeValues,
19691
19697
  title: hasTitles ? getSelection() : null,
19692
19698
  type: "text",
19693
- tabIndex: -1,
19699
+ tabIndex: 0,
19694
19700
  value: inputValue,
19695
- width: "85%",
19701
+ width: "100%",
19696
19702
  dataQa: placeholder
19697
19703
  }), /*#__PURE__*/React__default.createElement(IconWrapper, {
19698
- open: isOpen
19699
- }, /*#__PURE__*/React__default.createElement(DropdownIcon, null))), /*#__PURE__*/React__default.createElement(React.Fragment, null, isOpen ? /*#__PURE__*/React__default.createElement(DropdownContentWrapper, {
19704
+ open: isOpen,
19705
+ onClick: _onClick
19706
+ }, /*#__PURE__*/React__default.createElement(DropdownIcon, null)), /*#__PURE__*/React__default.createElement(React.Fragment, null, isOpen ? /*#__PURE__*/React__default.createElement(DropdownContentWrapper, {
19700
19707
  maxHeight: maxHeight,
19701
19708
  open: isOpen,
19702
19709
  ref: dropdownRef,