@thecb/components 6.0.0-beta.0 → 6.0.0-beta.11
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 -79
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +144 -79
- 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 +163 -125
- 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
|
@@ -19414,7 +19414,7 @@ var DropdownContentWrapper = styled.div.withConfig({
|
|
|
19414
19414
|
var maxHeight = _ref3.maxHeight;
|
|
19415
19415
|
return maxHeight || "400px";
|
|
19416
19416
|
});
|
|
19417
|
-
var DropdownItemWrapper = styled.
|
|
19417
|
+
var DropdownItemWrapper = styled.li.withConfig({
|
|
19418
19418
|
displayName: "Dropdown__DropdownItemWrapper",
|
|
19419
19419
|
componentId: "sc-pn6m0h-2"
|
|
19420
19420
|
})(["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) {
|
|
@@ -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,9 +19519,14 @@ 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);
|
|
19517
19530
|
console.log("focus is", focus);
|
|
19518
19531
|
console.log("option refs are", optionRefs.current);
|
|
19519
19532
|
var optionEl = optionRefs.current.find(function (ref) {
|
|
@@ -19565,16 +19578,37 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19565
19578
|
e.preventDefault();
|
|
19566
19579
|
setInputValue(inputValue.slice(0, -1));
|
|
19567
19580
|
break;
|
|
19568
|
-
}
|
|
19569
19581
|
|
|
19570
|
-
|
|
19571
|
-
|
|
19572
|
-
|
|
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;
|
|
19591
|
+
|
|
19592
|
+
case "Escape":
|
|
19593
|
+
if (isOpen) {
|
|
19594
|
+
onClick();
|
|
19595
|
+
}
|
|
19596
|
+
|
|
19597
|
+
break;
|
|
19573
19598
|
}
|
|
19574
19599
|
};
|
|
19575
19600
|
|
|
19576
19601
|
useEffect$1(function () {
|
|
19577
|
-
|
|
19602
|
+
console.log("option refs in isopen useffect", optionRefs);
|
|
19603
|
+
console.log("option ref current in isopen useffect", optionRefs.current[0].current);
|
|
19604
|
+
console.log("selected refs in isopen useffect", selectedRef);
|
|
19605
|
+
console.log("value in isopen useffect", value);
|
|
19606
|
+
|
|
19607
|
+
if (isOpen && selectedRef !== undefined && selectedRef.current !== null) {
|
|
19608
|
+
// WAI-ARIA requires the selected option to receive focus
|
|
19609
|
+
selectedRef.current.focus();
|
|
19610
|
+
} else if (isOpen && optionRefs.current[0].current) {
|
|
19611
|
+
// If no selected option, first option receives focus
|
|
19578
19612
|
optionRefs.current[0].current.focus();
|
|
19579
19613
|
}
|
|
19580
19614
|
|
|
@@ -19582,16 +19616,21 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19582
19616
|
setInputValue("");
|
|
19583
19617
|
}, [isOpen]);
|
|
19584
19618
|
useEffect$1(function () {
|
|
19585
|
-
|
|
19586
|
-
|
|
19587
|
-
|
|
19588
|
-
|
|
19619
|
+
if (autoEraseTypeAhead) {
|
|
19620
|
+
clearTimeout(timer);
|
|
19621
|
+
setTimer(setTimeout(function () {
|
|
19622
|
+
return setInputValue("");
|
|
19623
|
+
}, 3000));
|
|
19624
|
+
}
|
|
19625
|
+
|
|
19589
19626
|
setFilteredOptions(options.filter(function (option) {
|
|
19590
19627
|
return option.value.toLowerCase().startsWith(inputValue.toLowerCase()) || option.text.toLowerCase().startsWith(inputValue.toLowerCase());
|
|
19591
19628
|
}));
|
|
19592
19629
|
}, [inputValue]);
|
|
19593
19630
|
useEffect$1(function () {
|
|
19594
19631
|
if (!isOpen && filteredOptions[0] && !disabledValues.includes(filteredOptions[0].value) && filteredOptions[0].text != placeholder) {
|
|
19632
|
+
console.log("filtered options are", filteredOptions);
|
|
19633
|
+
console.log("option refs are", optionRefs);
|
|
19595
19634
|
onSelect(filteredOptions[0].value);
|
|
19596
19635
|
}
|
|
19597
19636
|
|
|
@@ -19601,70 +19640,92 @@ var Dropdown = function Dropdown(_ref9) {
|
|
|
19601
19640
|
dropdownRef.current.focus();
|
|
19602
19641
|
}
|
|
19603
19642
|
}, [filteredOptions]);
|
|
19604
|
-
return /*#__PURE__*/React.createElement(
|
|
19605
|
-
|
|
19606
|
-
|
|
19607
|
-
|
|
19608
|
-
width: "100%",
|
|
19609
|
-
hoverStyles: "background-color: ".concat(themeValues.hoverColor, ";"),
|
|
19610
|
-
"aria-expanded": isOpen,
|
|
19611
|
-
extraStyles: disabled && "color: #6e727e;\n background-color: #f7f7f7;\n pointer-events: none;",
|
|
19612
|
-
title: hasTitles ? getSelection() : null
|
|
19643
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Stack, {
|
|
19644
|
+
direction: "row",
|
|
19645
|
+
bottomItem: 2,
|
|
19646
|
+
extraStyles: "position: relative;"
|
|
19613
19647
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
19614
|
-
as: "
|
|
19648
|
+
as: "input",
|
|
19649
|
+
"aria-multiline": "false",
|
|
19650
|
+
"aria-autocomplete": "list",
|
|
19651
|
+
"aria-controls": "".concat(ariaLabelledby, "_listbox"),
|
|
19652
|
+
"aria-activedescendant": "focused_option",
|
|
19653
|
+
"aria-owns": "".concat(ariaLabelledby, "_listbox"),
|
|
19654
|
+
"aria-haspopup": "listbox",
|
|
19655
|
+
"aria-labelledby": ariaLabelledby,
|
|
19656
|
+
"aria-expanded": isOpen,
|
|
19657
|
+
autocomplete: autocompleteValue,
|
|
19615
19658
|
background: isOpen ? themeValues.hoverColor : WHITE,
|
|
19616
|
-
|
|
19617
|
-
padding: "12px",
|
|
19618
|
-
hoverStyles: "background-color: ".concat(themeValues.hoverColor, ";"),
|
|
19659
|
+
borderRadius: "2px",
|
|
19619
19660
|
borderSize: "1px",
|
|
19620
19661
|
borderColor: isError ? ERROR_COLOR : isOpen ? themeValues.selectedColor : GREY_CHATEAU,
|
|
19621
|
-
|
|
19622
|
-
|
|
19623
|
-
|
|
19624
|
-
|
|
19625
|
-
|
|
19626
|
-
|
|
19627
|
-
|
|
19628
|
-
|
|
19629
|
-
|
|
19662
|
+
extraStyles: disabled && "color: #6e727e;\n background-color: #f7f7f7;\n pointer-events: none;",
|
|
19663
|
+
hoverStyles: "background-color: ".concat(themeValues.hoverColor, ";"),
|
|
19664
|
+
isOpen: isOpen,
|
|
19665
|
+
name: autocompleteValue,
|
|
19666
|
+
onKeyDown: onKeyDown,
|
|
19667
|
+
onClick: onClick,
|
|
19668
|
+
onFocus: onClick,
|
|
19669
|
+
onChange: function onChange(e) {
|
|
19670
|
+
console.log("input change event", e.target);
|
|
19671
|
+
console.log("input change event value", e.target.value);
|
|
19672
|
+
setInputValue(e.target.value);
|
|
19673
|
+
},
|
|
19674
|
+
padding: "12px",
|
|
19675
|
+
placeholder: getSelection(),
|
|
19676
|
+
role: "combobox",
|
|
19677
|
+
themeValues: themeValues,
|
|
19678
|
+
title: hasTitles ? getSelection() : null,
|
|
19679
|
+
type: "text",
|
|
19680
|
+
tabIndex: -1,
|
|
19630
19681
|
value: inputValue,
|
|
19631
|
-
|
|
19632
|
-
|
|
19633
|
-
})
|
|
19634
|
-
variant: "p",
|
|
19635
|
-
extraStyles: disabled && "color: #6e727e;\n background-color: #f7f7f7;\n pointer-events: none;"
|
|
19636
|
-
}, getSelection()), /*#__PURE__*/React.createElement(IconWrapper, {
|
|
19682
|
+
width: "100%",
|
|
19683
|
+
dataQa: placeholder
|
|
19684
|
+
}), /*#__PURE__*/React.createElement(IconWrapper, {
|
|
19637
19685
|
open: isOpen
|
|
19638
|
-
}, /*#__PURE__*/React.createElement(DropdownIcon, null)))
|
|
19686
|
+
}, /*#__PURE__*/React.createElement(DropdownIcon, null))), /*#__PURE__*/React.createElement(Fragment, null, isOpen ? /*#__PURE__*/React.createElement(DropdownContentWrapper, {
|
|
19639
19687
|
maxHeight: maxHeight,
|
|
19640
19688
|
open: isOpen,
|
|
19641
19689
|
ref: dropdownRef,
|
|
19642
19690
|
widthFitOptions: widthFitOptions,
|
|
19643
|
-
tabIndex: 0
|
|
19691
|
+
tabIndex: 0,
|
|
19692
|
+
role: "listbox",
|
|
19693
|
+
id: "".concat(ariaLabelledby, "_listbox")
|
|
19644
19694
|
}, /*#__PURE__*/React.createElement(Stack, {
|
|
19645
|
-
childGap: "0"
|
|
19695
|
+
childGap: "0",
|
|
19696
|
+
as: "ul"
|
|
19646
19697
|
}, filteredOptions.map(function (choice, i) {
|
|
19698
|
+
if (choice.value === value && selectedRef !== optionRefs.current[i]) {
|
|
19699
|
+
setSelectedRef(optionRefs.current[i]);
|
|
19700
|
+
}
|
|
19701
|
+
|
|
19647
19702
|
return /*#__PURE__*/React.createElement(DropdownItemWrapper, {
|
|
19703
|
+
id: focusedRef === optionRefs.current[i] ? "focused_option" : choice.value,
|
|
19648
19704
|
key: choice.value,
|
|
19649
19705
|
ref: optionRefs.current[i],
|
|
19650
|
-
as: "button",
|
|
19651
19706
|
tabIndex: -1,
|
|
19652
19707
|
onClick: disabledValues.includes(choice.value) ? function (evt) {
|
|
19653
19708
|
return evt.preventDefault();
|
|
19654
19709
|
} : function () {
|
|
19655
|
-
|
|
19710
|
+
setSelectedRef(optionRefs.current[i]);
|
|
19711
|
+
onSelect(choice.value);
|
|
19656
19712
|
},
|
|
19657
19713
|
selected: choice.value === value,
|
|
19714
|
+
"aria-selected": choice.value === value,
|
|
19658
19715
|
disabled: disabledValues.includes(choice.value),
|
|
19659
19716
|
"data-qa": choice.text,
|
|
19660
19717
|
themeValues: themeValues,
|
|
19661
|
-
title: hasTitles ? choice.text : null
|
|
19718
|
+
title: hasTitles ? choice.text : null,
|
|
19719
|
+
role: "option",
|
|
19720
|
+
onFocus: function onFocus() {
|
|
19721
|
+
return setFocusedRef(optionRefs.current[i]);
|
|
19722
|
+
}
|
|
19662
19723
|
}, /*#__PURE__*/React.createElement(Text$1, {
|
|
19663
19724
|
variant: "p",
|
|
19664
19725
|
color: choice.value === value ? WHITE : disabledValues.includes(choice.value) ? STORM_GREY : MINESHAFT_GREY,
|
|
19665
19726
|
extraStyles: "padding-left: 16px; \n cursor: ".concat(disabledValues.includes(choice.value) ? "default" : "pointer", "; \n white-space: nowrap; \n overflow: hidden; \n text-overflow: ellipsis;")
|
|
19666
19727
|
}, choice.text));
|
|
19667
|
-
}))) : /*#__PURE__*/React.createElement(Fragment, null));
|
|
19728
|
+
}))) : /*#__PURE__*/React.createElement(Fragment, null)));
|
|
19668
19729
|
};
|
|
19669
19730
|
|
|
19670
19731
|
var Dropdown$1 = themeComponent(Dropdown, "Dropdown", fallbackValues$e);
|
|
@@ -19765,7 +19826,8 @@ var FormSelect = function FormSelect(_ref) {
|
|
|
19765
19826
|
disabled = _ref.disabled,
|
|
19766
19827
|
themeValues = _ref.themeValues,
|
|
19767
19828
|
_ref$hasTitles = _ref.hasTitles,
|
|
19768
|
-
hasTitles = _ref$hasTitles === void 0 ? false : _ref$hasTitles
|
|
19829
|
+
hasTitles = _ref$hasTitles === void 0 ? false : _ref$hasTitles,
|
|
19830
|
+
autocompleteValue = _ref.autocompleteValue;
|
|
19769
19831
|
|
|
19770
19832
|
var _useState = useState(false),
|
|
19771
19833
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -19803,7 +19865,7 @@ var FormSelect = function FormSelect(_ref) {
|
|
|
19803
19865
|
extraStyles: "word-break: break-word;\n font-family: Public Sans;\n &::first-letter {\n text-transform: uppercase;\n }",
|
|
19804
19866
|
id: labelTextWhenNoError.replace(/\s+/g, "-")
|
|
19805
19867
|
}, labelTextWhenNoError))), /*#__PURE__*/React.createElement(Dropdown$1, {
|
|
19806
|
-
|
|
19868
|
+
ariaLabelledby: labelTextWhenNoError.replace(/\s+/g, "-"),
|
|
19807
19869
|
maxHeight: dropdownMaxHeight,
|
|
19808
19870
|
hasTitles: hasTitles,
|
|
19809
19871
|
placeholder: options[0] ? options[0].text : "",
|
|
@@ -19820,7 +19882,8 @@ var FormSelect = function FormSelect(_ref) {
|
|
|
19820
19882
|
onClick: function onClick() {
|
|
19821
19883
|
return setOpen(!open);
|
|
19822
19884
|
},
|
|
19823
|
-
disabled: disabled
|
|
19885
|
+
disabled: disabled,
|
|
19886
|
+
autocompleteValue: autocompleteValue
|
|
19824
19887
|
}), /*#__PURE__*/React.createElement(Stack, {
|
|
19825
19888
|
direction: "row",
|
|
19826
19889
|
justify: "space-between"
|
|
@@ -20593,7 +20656,8 @@ var CountryDropdown = function CountryDropdown(_ref) {
|
|
|
20593
20656
|
labelTextWhenNoError: labelTextWhenNoError,
|
|
20594
20657
|
errorMessages: errorMessages,
|
|
20595
20658
|
showErrors: showErrors,
|
|
20596
|
-
onChange: onChange
|
|
20659
|
+
onChange: onChange,
|
|
20660
|
+
autocompleteValue: "country-name"
|
|
20597
20661
|
});
|
|
20598
20662
|
};
|
|
20599
20663
|
|
|
@@ -33009,7 +33073,8 @@ var FormStateDropdown = function FormStateDropdown(_ref) {
|
|
|
33009
33073
|
fieldActions: fieldActions,
|
|
33010
33074
|
labelTextWhenNoError: labelTextWhenNoError,
|
|
33011
33075
|
errorMessages: errorMessages,
|
|
33012
|
-
showErrors: showErrors
|
|
33076
|
+
showErrors: showErrors,
|
|
33077
|
+
autocompleteValue: "address-level1"
|
|
33013
33078
|
});
|
|
33014
33079
|
};
|
|
33015
33080
|
|