@thecb/components 6.0.0-beta.2 → 6.0.0-beta.3

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
@@ -19468,7 +19468,9 @@ var Dropdown = function Dropdown(_ref9) {
19468
19468
  widthFitOptions = _ref9$widthFitOptions === void 0 ? false : _ref9$widthFitOptions,
19469
19469
  disabled = _ref9.disabled,
19470
19470
  _ref9$hasTitles = _ref9.hasTitles,
19471
- hasTitles = _ref9$hasTitles === void 0 ? false : _ref9$hasTitles;
19471
+ hasTitles = _ref9$hasTitles === void 0 ? false : _ref9$hasTitles,
19472
+ _ref9$autoEraseTypeAh = _ref9.autoEraseTypeAhead,
19473
+ autoEraseTypeAhead = _ref9$autoEraseTypeAh === void 0 ? true : _ref9$autoEraseTypeAh;
19472
19474
 
19473
19475
  var _useState = React.useState(""),
19474
19476
  _useState2 = _slicedToArray(_useState, 2),
@@ -19490,6 +19492,11 @@ var Dropdown = function Dropdown(_ref9) {
19490
19492
  optionsChanged = _useState8[0],
19491
19493
  setOptionsChanged = _useState8[1];
19492
19494
 
19495
+ var _useState9 = React.useState(undefined),
19496
+ _useState10 = _slicedToArray(_useState9, 2),
19497
+ selectedRef = _useState10[0],
19498
+ setSelectedRef = _useState10[1];
19499
+
19493
19500
  if (optionsState !== options) {
19494
19501
  setOptionsState(options);
19495
19502
  setOptionsChanged(true);
@@ -19500,10 +19507,10 @@ var Dropdown = function Dropdown(_ref9) {
19500
19507
  setOptionsChanged(false);
19501
19508
  }
19502
19509
 
19503
- var _useState9 = React.useState(null),
19504
- _useState10 = _slicedToArray(_useState9, 2),
19505
- timer = _useState10[0],
19506
- setTimer = _useState10[1];
19510
+ var _useState11 = React.useState(null),
19511
+ _useState12 = _slicedToArray(_useState11, 2),
19512
+ timer = _useState12[0],
19513
+ setTimer = _useState12[1];
19507
19514
 
19508
19515
  var optionRefs = React.useRef(_toConsumableArray(Array(options.length)).map(function () {
19509
19516
  return /*#__PURE__*/React.createRef();
@@ -19586,6 +19593,7 @@ var Dropdown = function Dropdown(_ref9) {
19586
19593
 
19587
19594
  React.useEffect(function () {
19588
19595
  console.log("option refs in isopen useffect", optionRefs.current[0].current);
19596
+ console.log("selected refs in isopen useffect", selectedRef);
19589
19597
  console.log("value in isopen useffect", value);
19590
19598
 
19591
19599
  if (isOpen && optionRefs.current[0].current) {
@@ -19596,10 +19604,13 @@ var Dropdown = function Dropdown(_ref9) {
19596
19604
  setInputValue("");
19597
19605
  }, [isOpen]);
19598
19606
  React.useEffect(function () {
19599
- clearTimeout(timer);
19600
- setTimer(setTimeout(function () {
19601
- return setInputValue("");
19602
- }, 2000));
19607
+ if (autoEraseTypeAhead) {
19608
+ clearTimeout(timer);
19609
+ setTimer(setTimeout(function () {
19610
+ return setInputValue("");
19611
+ }, 2000));
19612
+ }
19613
+
19603
19614
  setFilteredOptions(options.filter(function (option) {
19604
19615
  return option.value.toLowerCase().startsWith(inputValue.toLowerCase()) || option.text.toLowerCase().startsWith(inputValue.toLowerCase());
19605
19616
  }));
@@ -19658,6 +19669,10 @@ var Dropdown = function Dropdown(_ref9) {
19658
19669
  }, /*#__PURE__*/React__default.createElement(Stack, {
19659
19670
  childGap: "0"
19660
19671
  }, filteredOptions.map(function (choice, i) {
19672
+ if (selectedRef === undefined && choice.value === value) {
19673
+ setSelectedRef(optionRefs.current[i]);
19674
+ }
19675
+
19661
19676
  return /*#__PURE__*/React__default.createElement(DropdownItemWrapper, {
19662
19677
  key: choice.value,
19663
19678
  ref: optionRefs.current[i],