@thecb/components 6.0.0-beta.3 → 6.0.0-beta.4
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.esm.js
CHANGED
|
@@ -19462,7 +19462,8 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19462
19462
|
_ref9$hasTitles = _ref9.hasTitles,
|
|
19463
19463
|
hasTitles = _ref9$hasTitles === void 0 ? false : _ref9$hasTitles,
|
|
19464
19464
|
_ref9$autoEraseTypeAh = _ref9.autoEraseTypeAhead,
|
|
19465
|
-
autoEraseTypeAhead = _ref9$autoEraseTypeAh === void 0 ? true : _ref9$autoEraseTypeAh
|
|
19465
|
+
autoEraseTypeAhead = _ref9$autoEraseTypeAh === void 0 ? true : _ref9$autoEraseTypeAh,
|
|
19466
|
+
ariaLabelledby = _ref9.ariaLabelledby;
|
|
19466
19467
|
|
|
19467
19468
|
var _useState = useState(""),
|
|
19468
19469
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -19518,6 +19519,8 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19518
19519
|
};
|
|
19519
19520
|
|
|
19520
19521
|
var onKeyDown = function onKeyDown(e) {
|
|
19522
|
+
var _optionRefs$current$l, _optionRefs$current;
|
|
19523
|
+
|
|
19521
19524
|
var key = e.key,
|
|
19522
19525
|
keyCode = e.keyCode;
|
|
19523
19526
|
var focus = document.activeElement;
|
|
@@ -19571,10 +19574,18 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19571
19574
|
|
|
19572
19575
|
case "Backspace" :
|
|
19573
19576
|
e.preventDefault();
|
|
19574
|
-
console.log("input value is", inputValue);
|
|
19575
|
-
console.log("new input value will be", inputValue.slice(0, -1));
|
|
19576
19577
|
setInputValue(inputValue.slice(0, -1));
|
|
19577
19578
|
break;
|
|
19579
|
+
|
|
19580
|
+
case "Home":
|
|
19581
|
+
e.preventDefault();
|
|
19582
|
+
optionRefs.current[0].current.focus();
|
|
19583
|
+
break;
|
|
19584
|
+
|
|
19585
|
+
case "End":
|
|
19586
|
+
e.preventDefault();
|
|
19587
|
+
optionRefs.current[(_optionRefs$current$l = optionRefs === null || optionRefs === void 0 ? void 0 : (_optionRefs$current = optionRefs.current) === null || _optionRefs$current === void 0 ? void 0 : _optionRefs$current.length) !== null && _optionRefs$current$l !== void 0 ? _optionRefs$current$l : 0 - 1].current.focus();
|
|
19588
|
+
break;
|
|
19578
19589
|
}
|
|
19579
19590
|
|
|
19580
19591
|
if (keyCode > 64 && keyCode < 91 || keyCode == 32 || keyCode == 189) {
|
|
@@ -19588,7 +19599,11 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19588
19599
|
console.log("selected refs in isopen useffect", selectedRef);
|
|
19589
19600
|
console.log("value in isopen useffect", value);
|
|
19590
19601
|
|
|
19591
|
-
if (isOpen &&
|
|
19602
|
+
if (isOpen && selectedRef !== undefined) {
|
|
19603
|
+
// WAI-ARIA requires the selected option to receive focus
|
|
19604
|
+
selectedRef.current.focus();
|
|
19605
|
+
} else if (isOpen && optionRefs.current[0].current) {
|
|
19606
|
+
// If no selected option, first option receives focus
|
|
19592
19607
|
optionRefs.current[0].current.focus();
|
|
19593
19608
|
}
|
|
19594
19609
|
|
|
@@ -19625,6 +19640,10 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19625
19640
|
width: "100%",
|
|
19626
19641
|
hoverStyles: "background-color: ".concat(themeValues.hoverColor, ";"),
|
|
19627
19642
|
"aria-expanded": isOpen,
|
|
19643
|
+
role: "combobox",
|
|
19644
|
+
"aria-owns": "".concat(ariaLabelledby, "_listbox"),
|
|
19645
|
+
"aria-haspopup": "listbox",
|
|
19646
|
+
"aria-labelledby": ariaLabelledby,
|
|
19628
19647
|
extraStyles: disabled && "color: #6e727e;\n background-color: #f7f7f7;\n pointer-events: none;",
|
|
19629
19648
|
title: hasTitles ? getSelection() : null
|
|
19630
19649
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
@@ -19636,28 +19655,34 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19636
19655
|
borderSize: "1px",
|
|
19637
19656
|
borderColor: isError ? ERROR_COLOR : isOpen ? themeValues.selectedColor : GREY_CHATEAU,
|
|
19638
19657
|
borderRadius: "2px",
|
|
19639
|
-
tabIndex: 0,
|
|
19640
19658
|
dataQa: placeholder,
|
|
19641
19659
|
extraStyles: "height: 48px;\n ".concat(disabled && "color: #6e727e;\n background-color: #f7f7f7;\n pointer-events: none;", "\n ")
|
|
19642
19660
|
}, /*#__PURE__*/React.createElement(Stack, {
|
|
19643
19661
|
direction: "row",
|
|
19644
19662
|
bottomItem: 2
|
|
19645
|
-
},
|
|
19646
|
-
"aria-label":
|
|
19663
|
+
}, /*#__PURE__*/React.createElement(SearchInput, {
|
|
19664
|
+
"aria-label": getSelection(),
|
|
19665
|
+
placeholder: getSelection(),
|
|
19647
19666
|
value: inputValue,
|
|
19648
19667
|
onChange: noop,
|
|
19649
|
-
themeValues: themeValues
|
|
19650
|
-
|
|
19651
|
-
|
|
19652
|
-
|
|
19653
|
-
|
|
19668
|
+
themeValues: themeValues,
|
|
19669
|
+
role: "searchbox",
|
|
19670
|
+
type: "text",
|
|
19671
|
+
"aria-multiline": "false",
|
|
19672
|
+
"aria-autocomplete": "list",
|
|
19673
|
+
"aria-controls": "".concat(ariaLabelledby, "_listbox"),
|
|
19674
|
+
"aria-activedescendant": "selected_option",
|
|
19675
|
+
tabIndex: 0
|
|
19676
|
+
}), /*#__PURE__*/React.createElement(IconWrapper, {
|
|
19654
19677
|
open: isOpen
|
|
19655
19678
|
}, /*#__PURE__*/React.createElement(DropdownIcon, null)))), isOpen ? /*#__PURE__*/React.createElement(DropdownContentWrapper, {
|
|
19656
19679
|
maxHeight: maxHeight,
|
|
19657
19680
|
open: isOpen,
|
|
19658
19681
|
ref: dropdownRef,
|
|
19659
19682
|
widthFitOptions: widthFitOptions,
|
|
19660
|
-
tabIndex: 0
|
|
19683
|
+
tabIndex: 0,
|
|
19684
|
+
role: "listbox",
|
|
19685
|
+
id: "".concat(ariaLabelledby, "_listbox")
|
|
19661
19686
|
}, /*#__PURE__*/React.createElement(Stack, {
|
|
19662
19687
|
childGap: "0"
|
|
19663
19688
|
}, filteredOptions.map(function (choice, i) {
|
|
@@ -19666,6 +19691,7 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19666
19691
|
}
|
|
19667
19692
|
|
|
19668
19693
|
return /*#__PURE__*/React.createElement(DropdownItemWrapper, {
|
|
19694
|
+
id: choice.value === value ? "selected_option" : choice.value,
|
|
19669
19695
|
key: choice.value,
|
|
19670
19696
|
ref: optionRefs.current[i],
|
|
19671
19697
|
as: "button",
|
|
@@ -19676,10 +19702,12 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19676
19702
|
return onSelect(choice.value);
|
|
19677
19703
|
},
|
|
19678
19704
|
selected: choice.value === value,
|
|
19705
|
+
"aria-selected": choice.value === value,
|
|
19679
19706
|
disabled: disabledValues.includes(choice.value),
|
|
19680
19707
|
"data-qa": choice.text,
|
|
19681
19708
|
themeValues: themeValues,
|
|
19682
|
-
title: hasTitles ? choice.text : null
|
|
19709
|
+
title: hasTitles ? choice.text : null,
|
|
19710
|
+
role: "option"
|
|
19683
19711
|
}, /*#__PURE__*/React.createElement(Text$1, {
|
|
19684
19712
|
variant: "p",
|
|
19685
19713
|
color: choice.value === value ? WHITE : disabledValues.includes(choice.value) ? STORM_GREY : MINESHAFT_GREY,
|
|
@@ -19824,7 +19852,7 @@ var FormSelect = function FormSelect(_ref) {
|
|
|
19824
19852
|
extraStyles: "word-break: break-word;\n font-family: Public Sans;\n &::first-letter {\n text-transform: uppercase;\n }",
|
|
19825
19853
|
id: labelTextWhenNoError.replace(/\s+/g, "-")
|
|
19826
19854
|
}, labelTextWhenNoError))), /*#__PURE__*/React.createElement(Dropdown$1, {
|
|
19827
|
-
|
|
19855
|
+
ariaLabelledby: labelTextWhenNoError.replace(/\s+/g, "-"),
|
|
19828
19856
|
maxHeight: dropdownMaxHeight,
|
|
19829
19857
|
hasTitles: hasTitles,
|
|
19830
19858
|
placeholder: options[0] ? options[0].text : "",
|