@thecb/components 6.0.0-beta.1 → 6.0.0-beta.12
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 +144 -80
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +144 -80
- 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 +162 -125
- package/src/components/atoms/form-select/FormSelect.js +4 -2
- package/src/components/atoms/layouts/Box.js +1 -1
- package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.js +1 -0
package/dist/index.cjs.js
CHANGED
|
@@ -6380,7 +6380,7 @@ var Box = function Box(_ref) {
|
|
|
6380
6380
|
onFocus: onFocus,
|
|
6381
6381
|
onBlur: onBlur,
|
|
6382
6382
|
onTouchEnd: onTouchEnd
|
|
6383
|
-
}, rest), safeChildren(children, /*#__PURE__*/React__default.createElement(React.Fragment, null)));
|
|
6383
|
+
}, rest), children && safeChildren(children, /*#__PURE__*/React__default.createElement(React.Fragment, null)));
|
|
6384
6384
|
};
|
|
6385
6385
|
|
|
6386
6386
|
var CenterWrapper = styled__default.div.withConfig({
|
|
@@ -19422,7 +19422,7 @@ var DropdownContentWrapper = styled__default.div.withConfig({
|
|
|
19422
19422
|
var maxHeight = _ref3.maxHeight;
|
|
19423
19423
|
return maxHeight || "400px";
|
|
19424
19424
|
});
|
|
19425
|
-
var DropdownItemWrapper = styled__default.
|
|
19425
|
+
var DropdownItemWrapper = styled__default.li.withConfig({
|
|
19426
19426
|
displayName: "Dropdown__DropdownItemWrapper",
|
|
19427
19427
|
componentId: "sc-pn6m0h-2"
|
|
19428
19428
|
})(["background-color:", ";text-align:start;border-width:0px;border-color:transparent;box-shadow:none;padding:1rem;box-sizing:border-box;width:100%;cursor:", ";&:hover{background-color:", ";}&:focus{background-color:", ";outline:none;}"], function (_ref4) {
|
|
@@ -19443,32 +19443,30 @@ var DropdownItemWrapper = styled__default.div.withConfig({
|
|
|
19443
19443
|
themeValues = _ref7.themeValues;
|
|
19444
19444
|
return selected ? themeValues.selectedColor : disabled ? WHITE : themeValues.hoverColor;
|
|
19445
19445
|
});
|
|
19446
|
-
var SearchInput = styled__default.input.withConfig({
|
|
19447
|
-
displayName: "Dropdown__SearchInput",
|
|
19448
|
-
componentId: "sc-pn6m0h-3"
|
|
19449
|
-
})(["border:none;background-color:", ";font-size:16px;height:24px;"], function (_ref8) {
|
|
19450
|
-
var themeValues = _ref8.themeValues;
|
|
19451
|
-
return themeValues.hoverColor && themeValues.hoverColor;
|
|
19452
|
-
});
|
|
19453
19446
|
|
|
19454
|
-
var Dropdown = function Dropdown(
|
|
19455
|
-
var placeholder =
|
|
19456
|
-
options =
|
|
19457
|
-
value =
|
|
19458
|
-
isOpen =
|
|
19459
|
-
isError =
|
|
19460
|
-
onSelect =
|
|
19461
|
-
|
|
19462
|
-
disabledValues =
|
|
19463
|
-
|
|
19464
|
-
onClick =
|
|
19465
|
-
themeValues =
|
|
19466
|
-
maxHeight =
|
|
19467
|
-
|
|
19468
|
-
widthFitOptions =
|
|
19469
|
-
disabled =
|
|
19470
|
-
|
|
19471
|
-
hasTitles =
|
|
19447
|
+
var Dropdown = function Dropdown(_ref8) {
|
|
19448
|
+
var placeholder = _ref8.placeholder,
|
|
19449
|
+
options = _ref8.options,
|
|
19450
|
+
value = _ref8.value,
|
|
19451
|
+
isOpen = _ref8.isOpen,
|
|
19452
|
+
isError = _ref8.isError,
|
|
19453
|
+
onSelect = _ref8.onSelect,
|
|
19454
|
+
_ref8$disabledValues = _ref8.disabledValues,
|
|
19455
|
+
disabledValues = _ref8$disabledValues === void 0 ? [] : _ref8$disabledValues,
|
|
19456
|
+
_ref8$onClick = _ref8.onClick,
|
|
19457
|
+
onClick = _ref8$onClick === void 0 ? noop : _ref8$onClick,
|
|
19458
|
+
themeValues = _ref8.themeValues,
|
|
19459
|
+
maxHeight = _ref8.maxHeight,
|
|
19460
|
+
_ref8$widthFitOptions = _ref8.widthFitOptions,
|
|
19461
|
+
widthFitOptions = _ref8$widthFitOptions === void 0 ? false : _ref8$widthFitOptions,
|
|
19462
|
+
disabled = _ref8.disabled,
|
|
19463
|
+
_ref8$hasTitles = _ref8.hasTitles,
|
|
19464
|
+
hasTitles = _ref8$hasTitles === void 0 ? false : _ref8$hasTitles,
|
|
19465
|
+
_ref8$autoEraseTypeAh = _ref8.autoEraseTypeAhead,
|
|
19466
|
+
autoEraseTypeAhead = _ref8$autoEraseTypeAh === void 0 ? true : _ref8$autoEraseTypeAh,
|
|
19467
|
+
ariaLabelledby = _ref8.ariaLabelledby,
|
|
19468
|
+
_ref8$autocompleteVal = _ref8.autocompleteValue,
|
|
19469
|
+
autocompleteValue = _ref8$autocompleteVal === void 0 ? "" : _ref8$autocompleteVal;
|
|
19472
19470
|
|
|
19473
19471
|
var _useState = React.useState(""),
|
|
19474
19472
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -19490,6 +19488,16 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19490
19488
|
optionsChanged = _useState8[0],
|
|
19491
19489
|
setOptionsChanged = _useState8[1];
|
|
19492
19490
|
|
|
19491
|
+
var _useState9 = React.useState(undefined),
|
|
19492
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
19493
|
+
selectedRef = _useState10[0],
|
|
19494
|
+
setSelectedRef = _useState10[1];
|
|
19495
|
+
|
|
19496
|
+
var _useState11 = React.useState(undefined),
|
|
19497
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
19498
|
+
focusedRef = _useState12[0],
|
|
19499
|
+
setFocusedRef = _useState12[1];
|
|
19500
|
+
|
|
19493
19501
|
if (optionsState !== options) {
|
|
19494
19502
|
setOptionsState(options);
|
|
19495
19503
|
setOptionsChanged(true);
|
|
@@ -19500,10 +19508,10 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19500
19508
|
setOptionsChanged(false);
|
|
19501
19509
|
}
|
|
19502
19510
|
|
|
19503
|
-
var
|
|
19504
|
-
|
|
19505
|
-
timer =
|
|
19506
|
-
setTimer =
|
|
19511
|
+
var _useState13 = React.useState(null),
|
|
19512
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
19513
|
+
timer = _useState14[0],
|
|
19514
|
+
setTimer = _useState14[1];
|
|
19507
19515
|
|
|
19508
19516
|
var optionRefs = React.useRef(_toConsumableArray(Array(options.length)).map(function () {
|
|
19509
19517
|
return /*#__PURE__*/React.createRef();
|
|
@@ -19519,6 +19527,10 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19519
19527
|
};
|
|
19520
19528
|
|
|
19521
19529
|
var onKeyDown = function onKeyDown(e) {
|
|
19530
|
+
var _optionRefs$current$l, _optionRefs$current;
|
|
19531
|
+
|
|
19532
|
+
console.log("key down event is", e.target);
|
|
19533
|
+
console.log("key down event value is", e.target.value);
|
|
19522
19534
|
var key = e.key,
|
|
19523
19535
|
keyCode = e.keyCode;
|
|
19524
19536
|
var focus = document.activeElement;
|
|
@@ -19574,16 +19586,37 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19574
19586
|
e.preventDefault();
|
|
19575
19587
|
setInputValue(inputValue.slice(0, -1));
|
|
19576
19588
|
break;
|
|
19577
|
-
}
|
|
19578
19589
|
|
|
19579
|
-
|
|
19580
|
-
|
|
19581
|
-
|
|
19590
|
+
case "Home":
|
|
19591
|
+
e.preventDefault();
|
|
19592
|
+
optionRefs.current[0].current.focus();
|
|
19593
|
+
break;
|
|
19594
|
+
|
|
19595
|
+
case "End":
|
|
19596
|
+
e.preventDefault();
|
|
19597
|
+
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();
|
|
19598
|
+
break;
|
|
19599
|
+
|
|
19600
|
+
case "Escape":
|
|
19601
|
+
if (isOpen) {
|
|
19602
|
+
onClick();
|
|
19603
|
+
}
|
|
19604
|
+
|
|
19605
|
+
break;
|
|
19582
19606
|
}
|
|
19583
19607
|
};
|
|
19584
19608
|
|
|
19585
19609
|
React.useEffect(function () {
|
|
19586
|
-
|
|
19610
|
+
console.log("option refs in isopen useffect", optionRefs);
|
|
19611
|
+
console.log("option ref current in isopen useffect", optionRefs.current[0].current);
|
|
19612
|
+
console.log("selected refs in isopen useffect", selectedRef);
|
|
19613
|
+
console.log("value in isopen useffect", value);
|
|
19614
|
+
|
|
19615
|
+
if (isOpen && selectedRef !== undefined && selectedRef.current !== null) {
|
|
19616
|
+
// WAI-ARIA requires the selected option to receive focus
|
|
19617
|
+
selectedRef.current.focus();
|
|
19618
|
+
} else if (isOpen && optionRefs.current[0].current) {
|
|
19619
|
+
// If no selected option, first option receives focus
|
|
19587
19620
|
optionRefs.current[0].current.focus();
|
|
19588
19621
|
}
|
|
19589
19622
|
|
|
@@ -19591,16 +19624,21 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19591
19624
|
setInputValue("");
|
|
19592
19625
|
}, [isOpen]);
|
|
19593
19626
|
React.useEffect(function () {
|
|
19594
|
-
|
|
19595
|
-
|
|
19596
|
-
|
|
19597
|
-
|
|
19627
|
+
if (autoEraseTypeAhead) {
|
|
19628
|
+
clearTimeout(timer);
|
|
19629
|
+
setTimer(setTimeout(function () {
|
|
19630
|
+
return setInputValue("");
|
|
19631
|
+
}, 3000));
|
|
19632
|
+
}
|
|
19633
|
+
|
|
19598
19634
|
setFilteredOptions(options.filter(function (option) {
|
|
19599
19635
|
return option.value.toLowerCase().startsWith(inputValue.toLowerCase()) || option.text.toLowerCase().startsWith(inputValue.toLowerCase());
|
|
19600
19636
|
}));
|
|
19601
19637
|
}, [inputValue]);
|
|
19602
19638
|
React.useEffect(function () {
|
|
19603
19639
|
if (!isOpen && filteredOptions[0] && !disabledValues.includes(filteredOptions[0].value) && filteredOptions[0].text != placeholder) {
|
|
19640
|
+
console.log("filtered options are", filteredOptions);
|
|
19641
|
+
console.log("option refs are", optionRefs);
|
|
19604
19642
|
onSelect(filteredOptions[0].value);
|
|
19605
19643
|
}
|
|
19606
19644
|
|
|
@@ -19610,70 +19648,92 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19610
19648
|
dropdownRef.current.focus();
|
|
19611
19649
|
}
|
|
19612
19650
|
}, [filteredOptions]);
|
|
19613
|
-
return /*#__PURE__*/React__default.createElement(
|
|
19614
|
-
|
|
19615
|
-
|
|
19616
|
-
|
|
19617
|
-
width: "100%",
|
|
19618
|
-
hoverStyles: "background-color: ".concat(themeValues.hoverColor, ";"),
|
|
19619
|
-
"aria-expanded": isOpen,
|
|
19620
|
-
extraStyles: disabled && "color: #6e727e;\n background-color: #f7f7f7;\n pointer-events: none;",
|
|
19621
|
-
title: hasTitles ? getSelection() : null
|
|
19651
|
+
return /*#__PURE__*/React__default.createElement(React.Fragment, null, /*#__PURE__*/React__default.createElement(Stack, {
|
|
19652
|
+
direction: "row",
|
|
19653
|
+
bottomItem: 2,
|
|
19654
|
+
extraStyles: "position: relative;"
|
|
19622
19655
|
}, /*#__PURE__*/React__default.createElement(Box, {
|
|
19623
|
-
as: "
|
|
19656
|
+
as: "input",
|
|
19657
|
+
"aria-multiline": "false",
|
|
19658
|
+
"aria-autocomplete": "list",
|
|
19659
|
+
"aria-controls": "".concat(ariaLabelledby, "_listbox"),
|
|
19660
|
+
"aria-activedescendant": "focused_option",
|
|
19661
|
+
"aria-owns": "".concat(ariaLabelledby, "_listbox"),
|
|
19662
|
+
"aria-haspopup": "listbox",
|
|
19663
|
+
"aria-labelledby": ariaLabelledby,
|
|
19664
|
+
"aria-expanded": isOpen,
|
|
19665
|
+
autocomplete: autocompleteValue,
|
|
19624
19666
|
background: isOpen ? themeValues.hoverColor : WHITE,
|
|
19625
|
-
|
|
19626
|
-
padding: "12px",
|
|
19627
|
-
hoverStyles: "background-color: ".concat(themeValues.hoverColor, ";"),
|
|
19667
|
+
borderRadius: "2px",
|
|
19628
19668
|
borderSize: "1px",
|
|
19629
19669
|
borderColor: isError ? ERROR_COLOR : isOpen ? themeValues.selectedColor : GREY_CHATEAU,
|
|
19630
|
-
|
|
19631
|
-
|
|
19632
|
-
|
|
19633
|
-
|
|
19634
|
-
|
|
19635
|
-
|
|
19636
|
-
|
|
19637
|
-
|
|
19638
|
-
|
|
19670
|
+
extraStyles: disabled && "color: #6e727e;\n background-color: #f7f7f7;\n pointer-events: none;",
|
|
19671
|
+
hoverStyles: "background-color: ".concat(themeValues.hoverColor, ";"),
|
|
19672
|
+
isOpen: isOpen,
|
|
19673
|
+
name: autocompleteValue,
|
|
19674
|
+
onKeyDown: onKeyDown,
|
|
19675
|
+
onClick: onClick,
|
|
19676
|
+
onFocus: onClick,
|
|
19677
|
+
onChange: function onChange(e) {
|
|
19678
|
+
console.log("input change event", e.target);
|
|
19679
|
+
console.log("input change event value", e.target.value);
|
|
19680
|
+
setInputValue(e.target.value);
|
|
19681
|
+
},
|
|
19682
|
+
padding: "12px",
|
|
19683
|
+
placeholder: getSelection(),
|
|
19684
|
+
role: "combobox",
|
|
19685
|
+
themeValues: themeValues,
|
|
19686
|
+
title: hasTitles ? getSelection() : null,
|
|
19687
|
+
type: "text",
|
|
19688
|
+
tabIndex: -1,
|
|
19639
19689
|
value: inputValue,
|
|
19640
|
-
|
|
19641
|
-
|
|
19642
|
-
})
|
|
19643
|
-
variant: "p",
|
|
19644
|
-
extraStyles: disabled && "color: #6e727e;\n background-color: #f7f7f7;\n pointer-events: none;"
|
|
19645
|
-
}, getSelection()), /*#__PURE__*/React__default.createElement(IconWrapper, {
|
|
19690
|
+
width: "100%",
|
|
19691
|
+
dataQa: placeholder
|
|
19692
|
+
}), /*#__PURE__*/React__default.createElement(IconWrapper, {
|
|
19646
19693
|
open: isOpen
|
|
19647
|
-
}, /*#__PURE__*/React__default.createElement(DropdownIcon, null)))
|
|
19694
|
+
}, /*#__PURE__*/React__default.createElement(DropdownIcon, null))), /*#__PURE__*/React__default.createElement(React.Fragment, null, isOpen ? /*#__PURE__*/React__default.createElement(DropdownContentWrapper, {
|
|
19648
19695
|
maxHeight: maxHeight,
|
|
19649
19696
|
open: isOpen,
|
|
19650
19697
|
ref: dropdownRef,
|
|
19651
19698
|
widthFitOptions: widthFitOptions,
|
|
19652
|
-
tabIndex: 0
|
|
19699
|
+
tabIndex: 0,
|
|
19700
|
+
role: "listbox",
|
|
19701
|
+
id: "".concat(ariaLabelledby, "_listbox")
|
|
19653
19702
|
}, /*#__PURE__*/React__default.createElement(Stack, {
|
|
19654
|
-
childGap: "0"
|
|
19703
|
+
childGap: "0",
|
|
19704
|
+
as: "ul"
|
|
19655
19705
|
}, filteredOptions.map(function (choice, i) {
|
|
19706
|
+
if (choice.value === value && selectedRef !== optionRefs.current[i]) {
|
|
19707
|
+
setSelectedRef(optionRefs.current[i]);
|
|
19708
|
+
}
|
|
19709
|
+
|
|
19656
19710
|
return /*#__PURE__*/React__default.createElement(DropdownItemWrapper, {
|
|
19711
|
+
id: focusedRef === optionRefs.current[i] ? "focused_option" : choice.value,
|
|
19657
19712
|
key: choice.value,
|
|
19658
19713
|
ref: optionRefs.current[i],
|
|
19659
|
-
as: "button",
|
|
19660
19714
|
tabIndex: -1,
|
|
19661
19715
|
onClick: disabledValues.includes(choice.value) ? function (evt) {
|
|
19662
19716
|
return evt.preventDefault();
|
|
19663
19717
|
} : function () {
|
|
19664
|
-
|
|
19718
|
+
setSelectedRef(optionRefs.current[i]);
|
|
19719
|
+
onSelect(choice.value);
|
|
19665
19720
|
},
|
|
19666
19721
|
selected: choice.value === value,
|
|
19722
|
+
"aria-selected": choice.value === value,
|
|
19667
19723
|
disabled: disabledValues.includes(choice.value),
|
|
19668
19724
|
"data-qa": choice.text,
|
|
19669
19725
|
themeValues: themeValues,
|
|
19670
|
-
title: hasTitles ? choice.text : null
|
|
19726
|
+
title: hasTitles ? choice.text : null,
|
|
19727
|
+
role: "option",
|
|
19728
|
+
onFocus: function onFocus() {
|
|
19729
|
+
return setFocusedRef(optionRefs.current[i]);
|
|
19730
|
+
}
|
|
19671
19731
|
}, /*#__PURE__*/React__default.createElement(Text$1, {
|
|
19672
19732
|
variant: "p",
|
|
19673
19733
|
color: choice.value === value ? WHITE : disabledValues.includes(choice.value) ? STORM_GREY : MINESHAFT_GREY,
|
|
19674
19734
|
extraStyles: "padding-left: 16px; \n cursor: ".concat(disabledValues.includes(choice.value) ? "default" : "pointer", "; \n white-space: nowrap; \n overflow: hidden; \n text-overflow: ellipsis;")
|
|
19675
19735
|
}, choice.text));
|
|
19676
|
-
}))) : /*#__PURE__*/React__default.createElement(React.Fragment, null));
|
|
19736
|
+
}))) : /*#__PURE__*/React__default.createElement(React.Fragment, null)));
|
|
19677
19737
|
};
|
|
19678
19738
|
|
|
19679
19739
|
var Dropdown$1 = themeComponent(Dropdown, "Dropdown", fallbackValues$e);
|
|
@@ -19774,7 +19834,8 @@ var FormSelect = function FormSelect(_ref) {
|
|
|
19774
19834
|
disabled = _ref.disabled,
|
|
19775
19835
|
themeValues = _ref.themeValues,
|
|
19776
19836
|
_ref$hasTitles = _ref.hasTitles,
|
|
19777
|
-
hasTitles = _ref$hasTitles === void 0 ? false : _ref$hasTitles
|
|
19837
|
+
hasTitles = _ref$hasTitles === void 0 ? false : _ref$hasTitles,
|
|
19838
|
+
autocompleteValue = _ref.autocompleteValue;
|
|
19778
19839
|
|
|
19779
19840
|
var _useState = React.useState(false),
|
|
19780
19841
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -19812,7 +19873,7 @@ var FormSelect = function FormSelect(_ref) {
|
|
|
19812
19873
|
extraStyles: "word-break: break-word;\n font-family: Public Sans;\n &::first-letter {\n text-transform: uppercase;\n }",
|
|
19813
19874
|
id: labelTextWhenNoError.replace(/\s+/g, "-")
|
|
19814
19875
|
}, labelTextWhenNoError))), /*#__PURE__*/React__default.createElement(Dropdown$1, {
|
|
19815
|
-
|
|
19876
|
+
ariaLabelledby: labelTextWhenNoError.replace(/\s+/g, "-"),
|
|
19816
19877
|
maxHeight: dropdownMaxHeight,
|
|
19817
19878
|
hasTitles: hasTitles,
|
|
19818
19879
|
placeholder: options[0] ? options[0].text : "",
|
|
@@ -19829,7 +19890,8 @@ var FormSelect = function FormSelect(_ref) {
|
|
|
19829
19890
|
onClick: function onClick() {
|
|
19830
19891
|
return setOpen(!open);
|
|
19831
19892
|
},
|
|
19832
|
-
disabled: disabled
|
|
19893
|
+
disabled: disabled,
|
|
19894
|
+
autocompleteValue: autocompleteValue
|
|
19833
19895
|
}), /*#__PURE__*/React__default.createElement(Stack, {
|
|
19834
19896
|
direction: "row",
|
|
19835
19897
|
justify: "space-between"
|
|
@@ -20602,7 +20664,8 @@ var CountryDropdown = function CountryDropdown(_ref) {
|
|
|
20602
20664
|
labelTextWhenNoError: labelTextWhenNoError,
|
|
20603
20665
|
errorMessages: errorMessages,
|
|
20604
20666
|
showErrors: showErrors,
|
|
20605
|
-
onChange: onChange
|
|
20667
|
+
onChange: onChange,
|
|
20668
|
+
autocompleteValue: "country-name"
|
|
20606
20669
|
});
|
|
20607
20670
|
};
|
|
20608
20671
|
|
|
@@ -33018,7 +33081,8 @@ var FormStateDropdown = function FormStateDropdown(_ref) {
|
|
|
33018
33081
|
fieldActions: fieldActions,
|
|
33019
33082
|
labelTextWhenNoError: labelTextWhenNoError,
|
|
33020
33083
|
errorMessages: errorMessages,
|
|
33021
|
-
showErrors: showErrors
|
|
33084
|
+
showErrors: showErrors,
|
|
33085
|
+
autocompleteValue: "address-level1"
|
|
33022
33086
|
});
|
|
33023
33087
|
};
|
|
33024
33088
|
|