@thecb/components 6.0.0-beta.17 → 6.0.0-beta.18
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 +27 -11
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +27 -11
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/dropdown/Dropdown.js +24 -12
package/dist/index.cjs.js
CHANGED
|
@@ -19612,6 +19612,19 @@ var Dropdown = function Dropdown(_ref8) {
|
|
|
19612
19612
|
}
|
|
19613
19613
|
};
|
|
19614
19614
|
|
|
19615
|
+
var handleItemSelection = function handleItemSelection(evt, choice, i) {
|
|
19616
|
+
disabledValues.includes(choice.value) ? function (evt) {
|
|
19617
|
+
return evt.preventDefault();
|
|
19618
|
+
} : function () {
|
|
19619
|
+
setSelectedRef(optionRefs.current[i]);
|
|
19620
|
+
onSelect(choice.value);
|
|
19621
|
+
|
|
19622
|
+
if (isOpen) {
|
|
19623
|
+
_onClick();
|
|
19624
|
+
}
|
|
19625
|
+
};
|
|
19626
|
+
};
|
|
19627
|
+
|
|
19615
19628
|
React.useEffect(function () {
|
|
19616
19629
|
if (isOpen && selectedRef !== undefined && selectedRef.current !== null) {
|
|
19617
19630
|
// WAI-ARIA requires the selected option to receive focus
|
|
@@ -19681,15 +19694,20 @@ var Dropdown = function Dropdown(_ref8) {
|
|
|
19681
19694
|
minWidth: "100%",
|
|
19682
19695
|
name: autocompleteValue,
|
|
19683
19696
|
onFocus: function onFocus() {
|
|
19697
|
+
/*
|
|
19684
19698
|
if (!isOpen) {
|
|
19685
|
-
|
|
19699
|
+
onClick();
|
|
19686
19700
|
}
|
|
19701
|
+
*/
|
|
19687
19702
|
},
|
|
19688
19703
|
onChange: function onChange(e) {
|
|
19689
19704
|
console.log("current input value onChange", inputValue);
|
|
19690
19705
|
console.log("input change event", e.target);
|
|
19691
|
-
console.log("input change event value", e.target.value);
|
|
19692
|
-
|
|
19706
|
+
console.log("input change event value", e.target.value); // support autofill and copy/paste
|
|
19707
|
+
|
|
19708
|
+
if (e.tarvet.value !== inputValue) {
|
|
19709
|
+
setInputValue(e.target.value);
|
|
19710
|
+
}
|
|
19693
19711
|
},
|
|
19694
19712
|
padding: "12px",
|
|
19695
19713
|
placeholder: getSelection(),
|
|
@@ -19725,14 +19743,12 @@ var Dropdown = function Dropdown(_ref8) {
|
|
|
19725
19743
|
key: choice.value,
|
|
19726
19744
|
ref: optionRefs.current[i],
|
|
19727
19745
|
tabIndex: -1,
|
|
19728
|
-
onClick:
|
|
19729
|
-
return
|
|
19730
|
-
}
|
|
19731
|
-
|
|
19732
|
-
|
|
19733
|
-
|
|
19734
|
-
if (isOpen) {
|
|
19735
|
-
_onClick();
|
|
19746
|
+
onClick: function onClick(e) {
|
|
19747
|
+
return handleItemSelection(e, choice, i);
|
|
19748
|
+
},
|
|
19749
|
+
onKeyDown: function onKeyDown(e) {
|
|
19750
|
+
if (e.keyCode === 13) {
|
|
19751
|
+
handleItemSelection(e, choice, i);
|
|
19736
19752
|
}
|
|
19737
19753
|
},
|
|
19738
19754
|
selected: choice.value === value,
|