@thecb/components 6.0.0-beta.15 → 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 +47 -18
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +47 -18
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/dropdown/Dropdown.js +90 -68
package/dist/index.esm.js
CHANGED
|
@@ -19400,7 +19400,7 @@ var fallbackValues$e = {
|
|
|
19400
19400
|
var IconWrapper = styled.div.withConfig({
|
|
19401
19401
|
displayName: "Dropdown__IconWrapper",
|
|
19402
19402
|
componentId: "sc-pn6m0h-0"
|
|
19403
|
-
})(["display:flex;flex-direction:column;justify-content:center;transition:transform 0.3s ease;", "
|
|
19403
|
+
})(["position:absolute;display:flex;flex-direction:column;justify-content:center;transition:transform 0.3s ease;", ";top:20px;right:12px;"], function (_ref) {
|
|
19404
19404
|
var open = _ref.open;
|
|
19405
19405
|
return open ? "transform: rotate(-180deg)" : "";
|
|
19406
19406
|
});
|
|
@@ -19521,7 +19521,7 @@ var Dropdown = function Dropdown(_ref8) {
|
|
|
19521
19521
|
var onKeyDown = function onKeyDown(e) {
|
|
19522
19522
|
var _optionRefs$current$l, _optionRefs$current;
|
|
19523
19523
|
|
|
19524
|
-
console.log("current input value", inputValue);
|
|
19524
|
+
console.log("current input value top of keyDown", inputValue);
|
|
19525
19525
|
var key = e.key,
|
|
19526
19526
|
keyCode = e.keyCode;
|
|
19527
19527
|
var focus = document.activeElement;
|
|
@@ -19534,6 +19534,10 @@ var Dropdown = function Dropdown(_ref8) {
|
|
|
19534
19534
|
case "ArrowDown":
|
|
19535
19535
|
e.preventDefault();
|
|
19536
19536
|
|
|
19537
|
+
if (!isOpen) {
|
|
19538
|
+
_onClick();
|
|
19539
|
+
}
|
|
19540
|
+
|
|
19537
19541
|
if (optionEl) {
|
|
19538
19542
|
if (optionEl.current.nextElementSibling) {
|
|
19539
19543
|
optionEl.current.nextElementSibling.focus();
|
|
@@ -19592,6 +19596,25 @@ var Dropdown = function Dropdown(_ref8) {
|
|
|
19592
19596
|
|
|
19593
19597
|
break;
|
|
19594
19598
|
}
|
|
19599
|
+
|
|
19600
|
+
if (keyCode > 64 && keyCode < 91 || keyCode == 32 || keyCode == 189) {
|
|
19601
|
+
e.preventDefault();
|
|
19602
|
+
console.log("current input value inside keydown if", inputValue);
|
|
19603
|
+
setInputValue(inputValue + key);
|
|
19604
|
+
}
|
|
19605
|
+
};
|
|
19606
|
+
|
|
19607
|
+
var handleItemSelection = function handleItemSelection(evt, choice, i) {
|
|
19608
|
+
disabledValues.includes(choice.value) ? function (evt) {
|
|
19609
|
+
return evt.preventDefault();
|
|
19610
|
+
} : function () {
|
|
19611
|
+
setSelectedRef(optionRefs.current[i]);
|
|
19612
|
+
onSelect(choice.value);
|
|
19613
|
+
|
|
19614
|
+
if (isOpen) {
|
|
19615
|
+
_onClick();
|
|
19616
|
+
}
|
|
19617
|
+
};
|
|
19595
19618
|
};
|
|
19596
19619
|
|
|
19597
19620
|
useEffect$1(function () {
|
|
@@ -19635,13 +19658,12 @@ var Dropdown = function Dropdown(_ref8) {
|
|
|
19635
19658
|
extraStyles: "position: relative;",
|
|
19636
19659
|
minWidth: "100%",
|
|
19637
19660
|
onClick: function onClick() {
|
|
19638
|
-
|
|
19661
|
+
if (!isOpen) {
|
|
19662
|
+
_onClick();
|
|
19663
|
+
}
|
|
19639
19664
|
},
|
|
19640
19665
|
onKeyDown: onKeyDown,
|
|
19641
19666
|
width: "100%"
|
|
19642
|
-
}, /*#__PURE__*/React.createElement(Stack, {
|
|
19643
|
-
direction: "row",
|
|
19644
|
-
bottomItem: 2
|
|
19645
19667
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
19646
19668
|
as: "input",
|
|
19647
19669
|
"aria-multiline": "false",
|
|
@@ -19657,7 +19679,6 @@ var Dropdown = function Dropdown(_ref8) {
|
|
|
19657
19679
|
borderRadius: "2px",
|
|
19658
19680
|
borderSize: "1px",
|
|
19659
19681
|
borderColor: isError ? ERROR_COLOR : isOpen ? themeValues.selectedColor : GREY_CHATEAU,
|
|
19660
|
-
borderWidthOverride: "1px 0px 1px 1px",
|
|
19661
19682
|
extraStyles: disabled && "color: #6e727e;\n background-color: #f7f7f7;\n pointer-events: none;",
|
|
19662
19683
|
hoverStyles: "background-color: ".concat(themeValues.hoverColor, ";"),
|
|
19663
19684
|
isOpen: isOpen,
|
|
@@ -19665,15 +19686,20 @@ var Dropdown = function Dropdown(_ref8) {
|
|
|
19665
19686
|
minWidth: "100%",
|
|
19666
19687
|
name: autocompleteValue,
|
|
19667
19688
|
onFocus: function onFocus() {
|
|
19689
|
+
/*
|
|
19668
19690
|
if (!isOpen) {
|
|
19669
|
-
|
|
19691
|
+
onClick();
|
|
19670
19692
|
}
|
|
19693
|
+
*/
|
|
19671
19694
|
},
|
|
19672
19695
|
onChange: function onChange(e) {
|
|
19673
|
-
console.log("current input value", inputValue);
|
|
19696
|
+
console.log("current input value onChange", inputValue);
|
|
19674
19697
|
console.log("input change event", e.target);
|
|
19675
|
-
console.log("input change event value", e.target.value);
|
|
19676
|
-
|
|
19698
|
+
console.log("input change event value", e.target.value); // support autofill and copy/paste
|
|
19699
|
+
|
|
19700
|
+
if (e.tarvet.value !== inputValue) {
|
|
19701
|
+
setInputValue(e.target.value);
|
|
19702
|
+
}
|
|
19677
19703
|
},
|
|
19678
19704
|
padding: "12px",
|
|
19679
19705
|
placeholder: getSelection(),
|
|
@@ -19686,8 +19712,9 @@ var Dropdown = function Dropdown(_ref8) {
|
|
|
19686
19712
|
width: "100%",
|
|
19687
19713
|
dataQa: placeholder
|
|
19688
19714
|
}), /*#__PURE__*/React.createElement(IconWrapper, {
|
|
19689
|
-
open: isOpen
|
|
19690
|
-
|
|
19715
|
+
open: isOpen,
|
|
19716
|
+
onClick: _onClick
|
|
19717
|
+
}, /*#__PURE__*/React.createElement(DropdownIcon, null)), /*#__PURE__*/React.createElement(Fragment, null, isOpen ? /*#__PURE__*/React.createElement(DropdownContentWrapper, {
|
|
19691
19718
|
maxHeight: maxHeight,
|
|
19692
19719
|
open: isOpen,
|
|
19693
19720
|
ref: dropdownRef,
|
|
@@ -19708,11 +19735,13 @@ var Dropdown = function Dropdown(_ref8) {
|
|
|
19708
19735
|
key: choice.value,
|
|
19709
19736
|
ref: optionRefs.current[i],
|
|
19710
19737
|
tabIndex: -1,
|
|
19711
|
-
onClick:
|
|
19712
|
-
return
|
|
19713
|
-
}
|
|
19714
|
-
|
|
19715
|
-
|
|
19738
|
+
onClick: function onClick(e) {
|
|
19739
|
+
return handleItemSelection(e, choice, i);
|
|
19740
|
+
},
|
|
19741
|
+
onKeyDown: function onKeyDown(e) {
|
|
19742
|
+
if (e.keyCode === 13) {
|
|
19743
|
+
handleItemSelection(e, choice, i);
|
|
19744
|
+
}
|
|
19716
19745
|
},
|
|
19717
19746
|
selected: choice.value === value,
|
|
19718
19747
|
"aria-selected": choice.value === value,
|