@thecb/components 6.0.0-beta.20 → 6.0.0-beta.23
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 +23 -13
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +23 -13
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/dropdown/Dropdown.js +14 -10
package/dist/index.cjs.js
CHANGED
|
@@ -20746,6 +20746,11 @@ var Dropdown = function Dropdown(_ref8) {
|
|
|
20746
20746
|
focusedRef = _useState12[0],
|
|
20747
20747
|
setFocusedRef = _useState12[1];
|
|
20748
20748
|
|
|
20749
|
+
var _useState13 = React.useState(false),
|
|
20750
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
20751
|
+
inputChangedByAutofill = _useState14[0],
|
|
20752
|
+
setInputChangedByAutofill = _useState14[1];
|
|
20753
|
+
|
|
20749
20754
|
if (optionsState !== options) {
|
|
20750
20755
|
setOptionsState(options);
|
|
20751
20756
|
setOptionsChanged(true);
|
|
@@ -20756,10 +20761,10 @@ var Dropdown = function Dropdown(_ref8) {
|
|
|
20756
20761
|
setOptionsChanged(false);
|
|
20757
20762
|
}
|
|
20758
20763
|
|
|
20759
|
-
var
|
|
20760
|
-
|
|
20761
|
-
timer =
|
|
20762
|
-
setTimer =
|
|
20764
|
+
var _useState15 = React.useState(null),
|
|
20765
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
20766
|
+
timer = _useState16[0],
|
|
20767
|
+
setTimer = _useState16[1];
|
|
20763
20768
|
|
|
20764
20769
|
var optionRefs = React.useRef(_toConsumableArray(Array(options.length)).map(function () {
|
|
20765
20770
|
return /*#__PURE__*/React.createRef();
|
|
@@ -20897,8 +20902,19 @@ var Dropdown = function Dropdown(_ref8) {
|
|
|
20897
20902
|
}));
|
|
20898
20903
|
}, [inputValue]);
|
|
20899
20904
|
React.useEffect(function () {
|
|
20900
|
-
if (
|
|
20905
|
+
if (
|
|
20906
|
+
/*
|
|
20907
|
+
Either user has typed a value into input that matches a non-disabled option
|
|
20908
|
+
or
|
|
20909
|
+
user has autofilled or pasted into input a string matching a valid option
|
|
20910
|
+
*/
|
|
20911
|
+
(!isOpen || inputChangedByAutofill) && filteredOptions[0] && !disabledValues.includes(filteredOptions[0].value) && filteredOptions[0].text != placeholder) {
|
|
20912
|
+
setInputChangedByAutofill(false);
|
|
20901
20913
|
onSelect(filteredOptions[0].value);
|
|
20914
|
+
|
|
20915
|
+
if (isOpen) {
|
|
20916
|
+
_onClick();
|
|
20917
|
+
}
|
|
20902
20918
|
}
|
|
20903
20919
|
|
|
20904
20920
|
if (optionRefs.current[0].current) {
|
|
@@ -20940,20 +20956,14 @@ var Dropdown = function Dropdown(_ref8) {
|
|
|
20940
20956
|
minHeight: "48px",
|
|
20941
20957
|
minWidth: "100%",
|
|
20942
20958
|
name: autocompleteValue,
|
|
20943
|
-
onFocus: function onFocus() {
|
|
20944
|
-
/*
|
|
20945
|
-
if (!isOpen) {
|
|
20946
|
-
onClick();
|
|
20947
|
-
}
|
|
20948
|
-
*/
|
|
20949
|
-
},
|
|
20950
20959
|
onChange: function onChange(e) {
|
|
20951
20960
|
console.log("current input value onChange", inputValue);
|
|
20952
20961
|
console.log("input change event", e.target);
|
|
20953
20962
|
console.log("input change event value", e.target.value); // support autofill and copy/paste
|
|
20954
20963
|
|
|
20955
|
-
if (e.
|
|
20964
|
+
if (e.target.value !== inputValue) {
|
|
20956
20965
|
setInputValue(e.target.value);
|
|
20966
|
+
setInputChangedByAutofill(true);
|
|
20957
20967
|
}
|
|
20958
20968
|
},
|
|
20959
20969
|
padding: "12px",
|