@thecb/components 5.11.4 → 6.0.0-beta.10
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 +138 -78
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +138 -78
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/country-dropdown/CountryDropdown.js +1 -0
- package/src/components/atoms/dropdown/Dropdown.js +158 -123
- package/src/components/atoms/form-select/FormSelect.js +4 -2
- package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.js +1 -0
package/dist/index.esm.js
CHANGED
|
@@ -19435,32 +19435,30 @@ var DropdownItemWrapper = styled.div.withConfig({
|
|
|
19435
19435
|
themeValues = _ref7.themeValues;
|
|
19436
19436
|
return selected ? themeValues.selectedColor : disabled ? WHITE : themeValues.hoverColor;
|
|
19437
19437
|
});
|
|
19438
|
-
var SearchInput = styled.input.withConfig({
|
|
19439
|
-
displayName: "Dropdown__SearchInput",
|
|
19440
|
-
componentId: "sc-pn6m0h-3"
|
|
19441
|
-
})(["border:none;background-color:", ";font-size:16px;height:24px;"], function (_ref8) {
|
|
19442
|
-
var themeValues = _ref8.themeValues;
|
|
19443
|
-
return themeValues.hoverColor && themeValues.hoverColor;
|
|
19444
|
-
});
|
|
19445
19438
|
|
|
19446
|
-
var Dropdown = function Dropdown(
|
|
19447
|
-
var placeholder =
|
|
19448
|
-
options =
|
|
19449
|
-
value =
|
|
19450
|
-
isOpen =
|
|
19451
|
-
isError =
|
|
19452
|
-
onSelect =
|
|
19453
|
-
|
|
19454
|
-
disabledValues =
|
|
19455
|
-
|
|
19456
|
-
onClick =
|
|
19457
|
-
themeValues =
|
|
19458
|
-
maxHeight =
|
|
19459
|
-
|
|
19460
|
-
widthFitOptions =
|
|
19461
|
-
disabled =
|
|
19462
|
-
|
|
19463
|
-
hasTitles =
|
|
19439
|
+
var Dropdown = function Dropdown(_ref8) {
|
|
19440
|
+
var placeholder = _ref8.placeholder,
|
|
19441
|
+
options = _ref8.options,
|
|
19442
|
+
value = _ref8.value,
|
|
19443
|
+
isOpen = _ref8.isOpen,
|
|
19444
|
+
isError = _ref8.isError,
|
|
19445
|
+
onSelect = _ref8.onSelect,
|
|
19446
|
+
_ref8$disabledValues = _ref8.disabledValues,
|
|
19447
|
+
disabledValues = _ref8$disabledValues === void 0 ? [] : _ref8$disabledValues,
|
|
19448
|
+
_ref8$onClick = _ref8.onClick,
|
|
19449
|
+
onClick = _ref8$onClick === void 0 ? noop : _ref8$onClick,
|
|
19450
|
+
themeValues = _ref8.themeValues,
|
|
19451
|
+
maxHeight = _ref8.maxHeight,
|
|
19452
|
+
_ref8$widthFitOptions = _ref8.widthFitOptions,
|
|
19453
|
+
widthFitOptions = _ref8$widthFitOptions === void 0 ? false : _ref8$widthFitOptions,
|
|
19454
|
+
disabled = _ref8.disabled,
|
|
19455
|
+
_ref8$hasTitles = _ref8.hasTitles,
|
|
19456
|
+
hasTitles = _ref8$hasTitles === void 0 ? false : _ref8$hasTitles,
|
|
19457
|
+
_ref8$autoEraseTypeAh = _ref8.autoEraseTypeAhead,
|
|
19458
|
+
autoEraseTypeAhead = _ref8$autoEraseTypeAh === void 0 ? true : _ref8$autoEraseTypeAh,
|
|
19459
|
+
ariaLabelledby = _ref8.ariaLabelledby,
|
|
19460
|
+
_ref8$autocompleteVal = _ref8.autocompleteValue,
|
|
19461
|
+
autocompleteValue = _ref8$autocompleteVal === void 0 ? "" : _ref8$autocompleteVal;
|
|
19464
19462
|
|
|
19465
19463
|
var _useState = useState(""),
|
|
19466
19464
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -19482,6 +19480,16 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19482
19480
|
optionsChanged = _useState8[0],
|
|
19483
19481
|
setOptionsChanged = _useState8[1];
|
|
19484
19482
|
|
|
19483
|
+
var _useState9 = useState(undefined),
|
|
19484
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
19485
|
+
selectedRef = _useState10[0],
|
|
19486
|
+
setSelectedRef = _useState10[1];
|
|
19487
|
+
|
|
19488
|
+
var _useState11 = useState(undefined),
|
|
19489
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
19490
|
+
focusedRef = _useState12[0],
|
|
19491
|
+
setFocusedRef = _useState12[1];
|
|
19492
|
+
|
|
19485
19493
|
if (optionsState !== options) {
|
|
19486
19494
|
setOptionsState(options);
|
|
19487
19495
|
setOptionsChanged(true);
|
|
@@ -19492,10 +19500,10 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19492
19500
|
setOptionsChanged(false);
|
|
19493
19501
|
}
|
|
19494
19502
|
|
|
19495
|
-
var
|
|
19496
|
-
|
|
19497
|
-
timer =
|
|
19498
|
-
setTimer =
|
|
19503
|
+
var _useState13 = useState(null),
|
|
19504
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
19505
|
+
timer = _useState14[0],
|
|
19506
|
+
setTimer = _useState14[1];
|
|
19499
19507
|
|
|
19500
19508
|
var optionRefs = useRef(_toConsumableArray(Array(options.length)).map(function () {
|
|
19501
19509
|
return /*#__PURE__*/createRef();
|
|
@@ -19511,12 +19519,20 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19511
19519
|
};
|
|
19512
19520
|
|
|
19513
19521
|
var onKeyDown = function onKeyDown(e) {
|
|
19522
|
+
var _optionRefs$current$l, _optionRefs$current;
|
|
19523
|
+
|
|
19524
|
+
console.log("key down event is", e.target);
|
|
19525
|
+
console.log("key down event value is", e.target.value);
|
|
19514
19526
|
var key = e.key,
|
|
19515
19527
|
keyCode = e.keyCode;
|
|
19516
19528
|
var focus = document.activeElement;
|
|
19529
|
+
console.log("dropdown value is", value);
|
|
19530
|
+
console.log("focus is", focus);
|
|
19531
|
+
console.log("option refs are", optionRefs.current);
|
|
19517
19532
|
var optionEl = optionRefs.current.find(function (ref) {
|
|
19518
19533
|
return ref.current === focus;
|
|
19519
19534
|
});
|
|
19535
|
+
console.log("option el is", optionEl);
|
|
19520
19536
|
|
|
19521
19537
|
switch (key) {
|
|
19522
19538
|
case "ArrowDown":
|
|
@@ -19562,16 +19578,30 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19562
19578
|
e.preventDefault();
|
|
19563
19579
|
setInputValue(inputValue.slice(0, -1));
|
|
19564
19580
|
break;
|
|
19565
|
-
}
|
|
19566
19581
|
|
|
19567
|
-
|
|
19568
|
-
|
|
19569
|
-
|
|
19582
|
+
case "Home":
|
|
19583
|
+
e.preventDefault();
|
|
19584
|
+
optionRefs.current[0].current.focus();
|
|
19585
|
+
break;
|
|
19586
|
+
|
|
19587
|
+
case "End":
|
|
19588
|
+
e.preventDefault();
|
|
19589
|
+
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();
|
|
19590
|
+
break;
|
|
19570
19591
|
}
|
|
19571
19592
|
};
|
|
19572
19593
|
|
|
19573
19594
|
useEffect$1(function () {
|
|
19574
|
-
|
|
19595
|
+
console.log("option refs in isopen useffect", optionRefs);
|
|
19596
|
+
console.log("option ref current in isopen useffect", optionRefs.current[0].current);
|
|
19597
|
+
console.log("selected refs in isopen useffect", selectedRef);
|
|
19598
|
+
console.log("value in isopen useffect", value);
|
|
19599
|
+
|
|
19600
|
+
if (isOpen && selectedRef !== undefined && selectedRef.current !== null) {
|
|
19601
|
+
// WAI-ARIA requires the selected option to receive focus
|
|
19602
|
+
selectedRef.current.focus();
|
|
19603
|
+
} else if (isOpen && optionRefs.current[0].current) {
|
|
19604
|
+
// If no selected option, first option receives focus
|
|
19575
19605
|
optionRefs.current[0].current.focus();
|
|
19576
19606
|
}
|
|
19577
19607
|
|
|
@@ -19579,16 +19609,21 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19579
19609
|
setInputValue("");
|
|
19580
19610
|
}, [isOpen]);
|
|
19581
19611
|
useEffect$1(function () {
|
|
19582
|
-
|
|
19583
|
-
|
|
19584
|
-
|
|
19585
|
-
|
|
19612
|
+
if (autoEraseTypeAhead) {
|
|
19613
|
+
clearTimeout(timer);
|
|
19614
|
+
setTimer(setTimeout(function () {
|
|
19615
|
+
return setInputValue("");
|
|
19616
|
+
}, 3000));
|
|
19617
|
+
}
|
|
19618
|
+
|
|
19586
19619
|
setFilteredOptions(options.filter(function (option) {
|
|
19587
19620
|
return option.value.toLowerCase().startsWith(inputValue.toLowerCase()) || option.text.toLowerCase().startsWith(inputValue.toLowerCase());
|
|
19588
19621
|
}));
|
|
19589
19622
|
}, [inputValue]);
|
|
19590
19623
|
useEffect$1(function () {
|
|
19591
19624
|
if (!isOpen && filteredOptions[0] && !disabledValues.includes(filteredOptions[0].value) && filteredOptions[0].text != placeholder) {
|
|
19625
|
+
console.log("filtered options are", filteredOptions);
|
|
19626
|
+
console.log("option refs are", optionRefs);
|
|
19592
19627
|
onSelect(filteredOptions[0].value);
|
|
19593
19628
|
}
|
|
19594
19629
|
|
|
@@ -19598,70 +19633,91 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19598
19633
|
dropdownRef.current.focus();
|
|
19599
19634
|
}
|
|
19600
19635
|
}, [filteredOptions]);
|
|
19601
|
-
return /*#__PURE__*/React.createElement(
|
|
19602
|
-
|
|
19603
|
-
|
|
19604
|
-
|
|
19605
|
-
width: "100%",
|
|
19606
|
-
hoverStyles: "background-color: ".concat(themeValues.hoverColor, ";"),
|
|
19607
|
-
"aria-expanded": isOpen,
|
|
19608
|
-
extraStyles: disabled && "color: #6e727e;\n background-color: #f7f7f7;\n pointer-events: none;",
|
|
19609
|
-
title: hasTitles ? getSelection() : null
|
|
19636
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Stack, {
|
|
19637
|
+
direction: "row",
|
|
19638
|
+
bottomItem: 2,
|
|
19639
|
+
extraStyles: "position: relative;"
|
|
19610
19640
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
19611
|
-
as: "
|
|
19641
|
+
as: "input",
|
|
19642
|
+
"aria-multiline": "false",
|
|
19643
|
+
"aria-autocomplete": "list",
|
|
19644
|
+
"aria-controls": "".concat(ariaLabelledby, "_listbox"),
|
|
19645
|
+
"aria-activedescendant": "focused_option",
|
|
19646
|
+
"aria-owns": "".concat(ariaLabelledby, "_listbox"),
|
|
19647
|
+
"aria-haspopup": "listbox",
|
|
19648
|
+
"aria-labelledby": ariaLabelledby,
|
|
19649
|
+
"aria-expanded": isOpen,
|
|
19650
|
+
autocomplete: autocompleteValue,
|
|
19612
19651
|
background: isOpen ? themeValues.hoverColor : WHITE,
|
|
19613
|
-
|
|
19614
|
-
padding: "12px",
|
|
19615
|
-
hoverStyles: "background-color: ".concat(themeValues.hoverColor, ";"),
|
|
19652
|
+
borderRadius: "2px",
|
|
19616
19653
|
borderSize: "1px",
|
|
19617
19654
|
borderColor: isError ? ERROR_COLOR : isOpen ? themeValues.selectedColor : GREY_CHATEAU,
|
|
19618
|
-
|
|
19619
|
-
|
|
19620
|
-
|
|
19621
|
-
|
|
19622
|
-
|
|
19623
|
-
|
|
19624
|
-
|
|
19625
|
-
|
|
19626
|
-
|
|
19655
|
+
extraStyles: disabled && "color: #6e727e;\n background-color: #f7f7f7;\n pointer-events: none;",
|
|
19656
|
+
hoverStyles: "background-color: ".concat(themeValues.hoverColor, ";"),
|
|
19657
|
+
isOpen: isOpen,
|
|
19658
|
+
name: autocompleteValue,
|
|
19659
|
+
onKeyDown: onKeyDown,
|
|
19660
|
+
onClick: onClick,
|
|
19661
|
+
onFocus: onClick,
|
|
19662
|
+
onChange: function onChange(e) {
|
|
19663
|
+
console.log("input change event", e.target);
|
|
19664
|
+
console.log("input change event value", e.target.value);
|
|
19665
|
+
setInputValue(e.target.value);
|
|
19666
|
+
},
|
|
19667
|
+
padding: "12px",
|
|
19668
|
+
placeholder: getSelection(),
|
|
19669
|
+
role: "combobox",
|
|
19670
|
+
themeValues: themeValues,
|
|
19671
|
+
title: hasTitles ? getSelection() : null,
|
|
19672
|
+
type: "text",
|
|
19673
|
+
tabIndex: -1,
|
|
19627
19674
|
value: inputValue,
|
|
19628
|
-
|
|
19629
|
-
|
|
19630
|
-
}
|
|
19631
|
-
variant: "p",
|
|
19632
|
-
extraStyles: disabled && "color: #6e727e;\n background-color: #f7f7f7;\n pointer-events: none;"
|
|
19633
|
-
}, getSelection()), /*#__PURE__*/React.createElement(IconWrapper, {
|
|
19634
|
-
open: isOpen
|
|
19635
|
-
}, /*#__PURE__*/React.createElement(DropdownIcon, null)))), isOpen ? /*#__PURE__*/React.createElement(DropdownContentWrapper, {
|
|
19675
|
+
width: "100%",
|
|
19676
|
+
dataQa: placeholder
|
|
19677
|
+
}, isOpen ? /*#__PURE__*/React.createElement(DropdownContentWrapper, {
|
|
19636
19678
|
maxHeight: maxHeight,
|
|
19637
19679
|
open: isOpen,
|
|
19638
19680
|
ref: dropdownRef,
|
|
19639
19681
|
widthFitOptions: widthFitOptions,
|
|
19640
|
-
tabIndex: 0
|
|
19682
|
+
tabIndex: 0,
|
|
19683
|
+
role: "listbox",
|
|
19684
|
+
id: "".concat(ariaLabelledby, "_listbox")
|
|
19641
19685
|
}, /*#__PURE__*/React.createElement(Stack, {
|
|
19642
19686
|
childGap: "0"
|
|
19643
19687
|
}, filteredOptions.map(function (choice, i) {
|
|
19688
|
+
if (choice.value === value && selectedRef !== optionRefs.current[i]) {
|
|
19689
|
+
setSelectedRef(optionRefs.current[i]);
|
|
19690
|
+
}
|
|
19691
|
+
|
|
19644
19692
|
return /*#__PURE__*/React.createElement(DropdownItemWrapper, {
|
|
19693
|
+
id: focusedRef === optionRefs.current[i] ? "focused_option" : choice.value,
|
|
19645
19694
|
key: choice.value,
|
|
19646
19695
|
ref: optionRefs.current[i],
|
|
19647
|
-
as: "button",
|
|
19648
19696
|
tabIndex: -1,
|
|
19649
19697
|
onClick: disabledValues.includes(choice.value) ? function (evt) {
|
|
19650
19698
|
return evt.preventDefault();
|
|
19651
19699
|
} : function () {
|
|
19652
|
-
|
|
19700
|
+
setSelectedRef(optionRefs.current[i]);
|
|
19701
|
+
onSelect(choice.value);
|
|
19653
19702
|
},
|
|
19654
19703
|
selected: choice.value === value,
|
|
19704
|
+
"aria-selected": choice.value === value,
|
|
19655
19705
|
disabled: disabledValues.includes(choice.value),
|
|
19656
19706
|
"data-qa": choice.text,
|
|
19657
19707
|
themeValues: themeValues,
|
|
19658
|
-
title: hasTitles ? choice.text : null
|
|
19708
|
+
title: hasTitles ? choice.text : null,
|
|
19709
|
+
role: "option",
|
|
19710
|
+
onFocus: function onFocus() {
|
|
19711
|
+
return setFocusedRef(optionRefs.current[i]);
|
|
19712
|
+
}
|
|
19659
19713
|
}, /*#__PURE__*/React.createElement(Text$1, {
|
|
19660
19714
|
variant: "p",
|
|
19661
19715
|
color: choice.value === value ? WHITE : disabledValues.includes(choice.value) ? STORM_GREY : MINESHAFT_GREY,
|
|
19662
19716
|
extraStyles: "padding-left: 16px; \n cursor: ".concat(disabledValues.includes(choice.value) ? "default" : "pointer", "; \n white-space: nowrap; \n overflow: hidden; \n text-overflow: ellipsis;")
|
|
19663
19717
|
}, choice.text));
|
|
19664
|
-
}))) : /*#__PURE__*/React.createElement(Fragment, null))
|
|
19718
|
+
}))) : /*#__PURE__*/React.createElement(Fragment, null)), /*#__PURE__*/React.createElement(IconWrapper, {
|
|
19719
|
+
open: isOpen
|
|
19720
|
+
}, /*#__PURE__*/React.createElement(DropdownIcon, null))));
|
|
19665
19721
|
};
|
|
19666
19722
|
|
|
19667
19723
|
var Dropdown$1 = themeComponent(Dropdown, "Dropdown", fallbackValues$e);
|
|
@@ -19762,7 +19818,8 @@ var FormSelect = function FormSelect(_ref) {
|
|
|
19762
19818
|
disabled = _ref.disabled,
|
|
19763
19819
|
themeValues = _ref.themeValues,
|
|
19764
19820
|
_ref$hasTitles = _ref.hasTitles,
|
|
19765
|
-
hasTitles = _ref$hasTitles === void 0 ? false : _ref$hasTitles
|
|
19821
|
+
hasTitles = _ref$hasTitles === void 0 ? false : _ref$hasTitles,
|
|
19822
|
+
autocompleteValue = _ref.autocompleteValue;
|
|
19766
19823
|
|
|
19767
19824
|
var _useState = useState(false),
|
|
19768
19825
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -19800,7 +19857,7 @@ var FormSelect = function FormSelect(_ref) {
|
|
|
19800
19857
|
extraStyles: "word-break: break-word;\n font-family: Public Sans;\n &::first-letter {\n text-transform: uppercase;\n }",
|
|
19801
19858
|
id: labelTextWhenNoError.replace(/\s+/g, "-")
|
|
19802
19859
|
}, labelTextWhenNoError))), /*#__PURE__*/React.createElement(Dropdown$1, {
|
|
19803
|
-
|
|
19860
|
+
ariaLabelledby: labelTextWhenNoError.replace(/\s+/g, "-"),
|
|
19804
19861
|
maxHeight: dropdownMaxHeight,
|
|
19805
19862
|
hasTitles: hasTitles,
|
|
19806
19863
|
placeholder: options[0] ? options[0].text : "",
|
|
@@ -19817,7 +19874,8 @@ var FormSelect = function FormSelect(_ref) {
|
|
|
19817
19874
|
onClick: function onClick() {
|
|
19818
19875
|
return setOpen(!open);
|
|
19819
19876
|
},
|
|
19820
|
-
disabled: disabled
|
|
19877
|
+
disabled: disabled,
|
|
19878
|
+
autocompleteValue: autocompleteValue
|
|
19821
19879
|
}), /*#__PURE__*/React.createElement(Stack, {
|
|
19822
19880
|
direction: "row",
|
|
19823
19881
|
justify: "space-between"
|
|
@@ -20590,7 +20648,8 @@ var CountryDropdown = function CountryDropdown(_ref) {
|
|
|
20590
20648
|
labelTextWhenNoError: labelTextWhenNoError,
|
|
20591
20649
|
errorMessages: errorMessages,
|
|
20592
20650
|
showErrors: showErrors,
|
|
20593
|
-
onChange: onChange
|
|
20651
|
+
onChange: onChange,
|
|
20652
|
+
autocompleteValue: "country-name"
|
|
20594
20653
|
});
|
|
20595
20654
|
};
|
|
20596
20655
|
|
|
@@ -33006,7 +33065,8 @@ var FormStateDropdown = function FormStateDropdown(_ref) {
|
|
|
33006
33065
|
fieldActions: fieldActions,
|
|
33007
33066
|
labelTextWhenNoError: labelTextWhenNoError,
|
|
33008
33067
|
errorMessages: errorMessages,
|
|
33009
|
-
showErrors: showErrors
|
|
33068
|
+
showErrors: showErrors,
|
|
33069
|
+
autocompleteValue: "address-level1"
|
|
33010
33070
|
});
|
|
33011
33071
|
};
|
|
33012
33072
|
|