@thecb/components 6.0.0-beta.0 → 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 +30 -9
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +30 -9
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/dropdown/Dropdown.js +52 -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();
|
|
@@ -19514,6 +19521,7 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19514
19521
|
var key = e.key,
|
|
19515
19522
|
keyCode = e.keyCode;
|
|
19516
19523
|
var focus = document.activeElement;
|
|
19524
|
+
console.log("dropdown value is", value);
|
|
19517
19525
|
console.log("focus is", focus);
|
|
19518
19526
|
console.log("option refs are", optionRefs.current);
|
|
19519
19527
|
var optionEl = optionRefs.current.find(function (ref) {
|
|
@@ -19563,6 +19571,8 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19563
19571
|
|
|
19564
19572
|
case "Backspace" :
|
|
19565
19573
|
e.preventDefault();
|
|
19574
|
+
console.log("input value is", inputValue);
|
|
19575
|
+
console.log("new input value will be", inputValue.slice(0, -1));
|
|
19566
19576
|
setInputValue(inputValue.slice(0, -1));
|
|
19567
19577
|
break;
|
|
19568
19578
|
}
|
|
@@ -19574,6 +19584,10 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19574
19584
|
};
|
|
19575
19585
|
|
|
19576
19586
|
useEffect$1(function () {
|
|
19587
|
+
console.log("option refs in isopen useffect", optionRefs.current[0].current);
|
|
19588
|
+
console.log("selected refs in isopen useffect", selectedRef);
|
|
19589
|
+
console.log("value in isopen useffect", value);
|
|
19590
|
+
|
|
19577
19591
|
if (isOpen && optionRefs.current[0].current) {
|
|
19578
19592
|
optionRefs.current[0].current.focus();
|
|
19579
19593
|
}
|
|
@@ -19582,10 +19596,13 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19582
19596
|
setInputValue("");
|
|
19583
19597
|
}, [isOpen]);
|
|
19584
19598
|
useEffect$1(function () {
|
|
19585
|
-
|
|
19586
|
-
|
|
19587
|
-
|
|
19588
|
-
|
|
19599
|
+
if (autoEraseTypeAhead) {
|
|
19600
|
+
clearTimeout(timer);
|
|
19601
|
+
setTimer(setTimeout(function () {
|
|
19602
|
+
return setInputValue("");
|
|
19603
|
+
}, 2000));
|
|
19604
|
+
}
|
|
19605
|
+
|
|
19589
19606
|
setFilteredOptions(options.filter(function (option) {
|
|
19590
19607
|
return option.value.toLowerCase().startsWith(inputValue.toLowerCase()) || option.text.toLowerCase().startsWith(inputValue.toLowerCase());
|
|
19591
19608
|
}));
|
|
@@ -19644,6 +19661,10 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19644
19661
|
}, /*#__PURE__*/React.createElement(Stack, {
|
|
19645
19662
|
childGap: "0"
|
|
19646
19663
|
}, filteredOptions.map(function (choice, i) {
|
|
19664
|
+
if (selectedRef === undefined && choice.value === value) {
|
|
19665
|
+
setSelectedRef(optionRefs.current[i]);
|
|
19666
|
+
}
|
|
19667
|
+
|
|
19647
19668
|
return /*#__PURE__*/React.createElement(DropdownItemWrapper, {
|
|
19648
19669
|
key: choice.value,
|
|
19649
19670
|
ref: optionRefs.current[i],
|