@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.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
|
|
19504
|
-
|
|
19505
|
-
timer =
|
|
19506
|
-
setTimer =
|
|
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();
|
|
@@ -19522,6 +19529,7 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19522
19529
|
var key = e.key,
|
|
19523
19530
|
keyCode = e.keyCode;
|
|
19524
19531
|
var focus = document.activeElement;
|
|
19532
|
+
console.log("dropdown value is", value);
|
|
19525
19533
|
console.log("focus is", focus);
|
|
19526
19534
|
console.log("option refs are", optionRefs.current);
|
|
19527
19535
|
var optionEl = optionRefs.current.find(function (ref) {
|
|
@@ -19571,6 +19579,8 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19571
19579
|
|
|
19572
19580
|
case "Backspace" :
|
|
19573
19581
|
e.preventDefault();
|
|
19582
|
+
console.log("input value is", inputValue);
|
|
19583
|
+
console.log("new input value will be", inputValue.slice(0, -1));
|
|
19574
19584
|
setInputValue(inputValue.slice(0, -1));
|
|
19575
19585
|
break;
|
|
19576
19586
|
}
|
|
@@ -19582,6 +19592,10 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19582
19592
|
};
|
|
19583
19593
|
|
|
19584
19594
|
React.useEffect(function () {
|
|
19595
|
+
console.log("option refs in isopen useffect", optionRefs.current[0].current);
|
|
19596
|
+
console.log("selected refs in isopen useffect", selectedRef);
|
|
19597
|
+
console.log("value in isopen useffect", value);
|
|
19598
|
+
|
|
19585
19599
|
if (isOpen && optionRefs.current[0].current) {
|
|
19586
19600
|
optionRefs.current[0].current.focus();
|
|
19587
19601
|
}
|
|
@@ -19590,10 +19604,13 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19590
19604
|
setInputValue("");
|
|
19591
19605
|
}, [isOpen]);
|
|
19592
19606
|
React.useEffect(function () {
|
|
19593
|
-
|
|
19594
|
-
|
|
19595
|
-
|
|
19596
|
-
|
|
19607
|
+
if (autoEraseTypeAhead) {
|
|
19608
|
+
clearTimeout(timer);
|
|
19609
|
+
setTimer(setTimeout(function () {
|
|
19610
|
+
return setInputValue("");
|
|
19611
|
+
}, 2000));
|
|
19612
|
+
}
|
|
19613
|
+
|
|
19597
19614
|
setFilteredOptions(options.filter(function (option) {
|
|
19598
19615
|
return option.value.toLowerCase().startsWith(inputValue.toLowerCase()) || option.text.toLowerCase().startsWith(inputValue.toLowerCase());
|
|
19599
19616
|
}));
|
|
@@ -19652,6 +19669,10 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19652
19669
|
}, /*#__PURE__*/React__default.createElement(Stack, {
|
|
19653
19670
|
childGap: "0"
|
|
19654
19671
|
}, filteredOptions.map(function (choice, i) {
|
|
19672
|
+
if (selectedRef === undefined && choice.value === value) {
|
|
19673
|
+
setSelectedRef(optionRefs.current[i]);
|
|
19674
|
+
}
|
|
19675
|
+
|
|
19655
19676
|
return /*#__PURE__*/React__default.createElement(DropdownItemWrapper, {
|
|
19656
19677
|
key: choice.value,
|
|
19657
19678
|
ref: optionRefs.current[i],
|