@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 +24 -9
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +24 -9
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/dropdown/Dropdown.js +44 -34
package/dist/index.esm.js
CHANGED
|
@@ -19460,7 +19460,9 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19460
19460
|
widthFitOptions = _ref9$widthFitOptions === void 0 ? false : _ref9$widthFitOptions,
|
|
19461
19461
|
disabled = _ref9.disabled,
|
|
19462
19462
|
_ref9$hasTitles = _ref9.hasTitles,
|
|
19463
|
-
hasTitles = _ref9$hasTitles === void 0 ? false : _ref9$hasTitles
|
|
19463
|
+
hasTitles = _ref9$hasTitles === void 0 ? false : _ref9$hasTitles,
|
|
19464
|
+
_ref9$autoEraseTypeAh = _ref9.autoEraseTypeAhead,
|
|
19465
|
+
autoEraseTypeAhead = _ref9$autoEraseTypeAh === void 0 ? true : _ref9$autoEraseTypeAh;
|
|
19464
19466
|
|
|
19465
19467
|
var _useState = useState(""),
|
|
19466
19468
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -19482,6 +19484,11 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19482
19484
|
optionsChanged = _useState8[0],
|
|
19483
19485
|
setOptionsChanged = _useState8[1];
|
|
19484
19486
|
|
|
19487
|
+
var _useState9 = useState(undefined),
|
|
19488
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
19489
|
+
selectedRef = _useState10[0],
|
|
19490
|
+
setSelectedRef = _useState10[1];
|
|
19491
|
+
|
|
19485
19492
|
if (optionsState !== options) {
|
|
19486
19493
|
setOptionsState(options);
|
|
19487
19494
|
setOptionsChanged(true);
|
|
@@ -19492,10 +19499,10 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19492
19499
|
setOptionsChanged(false);
|
|
19493
19500
|
}
|
|
19494
19501
|
|
|
19495
|
-
var
|
|
19496
|
-
|
|
19497
|
-
timer =
|
|
19498
|
-
setTimer =
|
|
19502
|
+
var _useState11 = useState(null),
|
|
19503
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
19504
|
+
timer = _useState12[0],
|
|
19505
|
+
setTimer = _useState12[1];
|
|
19499
19506
|
|
|
19500
19507
|
var optionRefs = useRef(_toConsumableArray(Array(options.length)).map(function () {
|
|
19501
19508
|
return /*#__PURE__*/createRef();
|
|
@@ -19578,6 +19585,7 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19578
19585
|
|
|
19579
19586
|
useEffect$1(function () {
|
|
19580
19587
|
console.log("option refs in isopen useffect", optionRefs.current[0].current);
|
|
19588
|
+
console.log("selected refs in isopen useffect", selectedRef);
|
|
19581
19589
|
console.log("value in isopen useffect", value);
|
|
19582
19590
|
|
|
19583
19591
|
if (isOpen && optionRefs.current[0].current) {
|
|
@@ -19588,10 +19596,13 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19588
19596
|
setInputValue("");
|
|
19589
19597
|
}, [isOpen]);
|
|
19590
19598
|
useEffect$1(function () {
|
|
19591
|
-
|
|
19592
|
-
|
|
19593
|
-
|
|
19594
|
-
|
|
19599
|
+
if (autoEraseTypeAhead) {
|
|
19600
|
+
clearTimeout(timer);
|
|
19601
|
+
setTimer(setTimeout(function () {
|
|
19602
|
+
return setInputValue("");
|
|
19603
|
+
}, 2000));
|
|
19604
|
+
}
|
|
19605
|
+
|
|
19595
19606
|
setFilteredOptions(options.filter(function (option) {
|
|
19596
19607
|
return option.value.toLowerCase().startsWith(inputValue.toLowerCase()) || option.text.toLowerCase().startsWith(inputValue.toLowerCase());
|
|
19597
19608
|
}));
|
|
@@ -19650,6 +19661,10 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19650
19661
|
}, /*#__PURE__*/React.createElement(Stack, {
|
|
19651
19662
|
childGap: "0"
|
|
19652
19663
|
}, filteredOptions.map(function (choice, i) {
|
|
19664
|
+
if (selectedRef === undefined && choice.value === value) {
|
|
19665
|
+
setSelectedRef(optionRefs.current[i]);
|
|
19666
|
+
}
|
|
19667
|
+
|
|
19653
19668
|
return /*#__PURE__*/React.createElement(DropdownItemWrapper, {
|
|
19654
19669
|
key: choice.value,
|
|
19655
19670
|
ref: optionRefs.current[i],
|