@thecb/components 9.1.0-beta.7 → 9.1.0
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 +38 -29
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.esm.js +38 -29
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/.DS_Store +0 -0
- package/src/components/atoms/.DS_Store +0 -0
- package/src/components/atoms/alert/Alert.js +7 -3
- package/src/components/atoms/dropdown/Dropdown.js +5 -5
- package/src/components/atoms/form-layouts/FormInput.js +1 -1
- package/src/components/atoms/form-layouts/index.d.ts +1 -1
- package/src/components/atoms/form-select/FormSelect.js +4 -2
- package/src/components/atoms/form-select/FormSelect.stories.js +8 -4
- package/src/components/atoms/form-select/index.d.ts +2 -1
- package/src/components/atoms/icons/icons.stories.js +0 -2
- package/src/components/atoms/layouts/Box.d.ts +1 -0
- package/src/components/atoms/layouts/Box.js +2 -0
- package/src/components/atoms/line-item/LineItem.js +6 -12
- package/src/components/atoms/searchable-select/SearchableSelect.js +2 -0
- package/src/components/atoms/searchable-select/SearchableSelect.stories.js +61 -0
- package/src/components/atoms/searchable-select/index.d.ts +1 -0
- package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.js +2 -3
- package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.stories.js +1 -0
- package/src/components/molecules/.DS_Store +0 -0
- package/src/components/molecules/address-form/AddressForm.js +1 -2
- package/src/components/molecules/phone-form/PhoneForm.js +1 -1
- /package/src/components/atoms/icons/{ExternalLinkIcon.js → ExternalLinkicon.js} +0 -0
package/package.json
CHANGED
package/src/.DS_Store
ADDED
|
Binary file
|
|
Binary file
|
|
@@ -24,7 +24,10 @@ const Alert = ({
|
|
|
24
24
|
enableSmallText = false,
|
|
25
25
|
innerContentPadding = "1rem",
|
|
26
26
|
iconPadding = "0 0 0 1rem",
|
|
27
|
-
contentFullHeight = false
|
|
27
|
+
contentFullHeight = false,
|
|
28
|
+
ariaRole = null,
|
|
29
|
+
ariaAtomic = true,
|
|
30
|
+
ariaLive = "polite"
|
|
28
31
|
}) => {
|
|
29
32
|
const Icon = AlertIcons[variant];
|
|
30
33
|
let contentPadding = maxContentWidth
|
|
@@ -92,8 +95,9 @@ const Alert = ({
|
|
|
92
95
|
borderSize={noBorder ? "0px" : "1px"}
|
|
93
96
|
boxShadow={enableBoxShadow ? generateShadows()?.inset?.base : ""}
|
|
94
97
|
extraStyles={extraStyles}
|
|
95
|
-
|
|
96
|
-
aria-atomic
|
|
98
|
+
aria-live={ariaLive}
|
|
99
|
+
{...(ariaAtomic !== null ? { "aria-atomic": ariaAtomic } : {})}
|
|
100
|
+
{...(ariaRole !== null ? { role: ariaRole } : {})}
|
|
97
101
|
>
|
|
98
102
|
{maxContentWidth ? (
|
|
99
103
|
<Center maxWidth={maxContentWidth}>{content}</Center>
|
|
@@ -103,7 +103,7 @@ const Dropdown = ({
|
|
|
103
103
|
autoEraseTypeAhead = true,
|
|
104
104
|
ariaLabelledby,
|
|
105
105
|
ariaDescribedby,
|
|
106
|
-
autocompleteValue
|
|
106
|
+
autocompleteValue, // browser autofill value, like country-name
|
|
107
107
|
smoothScroll = true,
|
|
108
108
|
ariaInvalid = false
|
|
109
109
|
}) => {
|
|
@@ -394,14 +394,14 @@ const Dropdown = ({
|
|
|
394
394
|
? STORM_GREY
|
|
395
395
|
: MINESHAFT_GREY
|
|
396
396
|
}
|
|
397
|
-
extraStyles={`padding-left: 16px;
|
|
397
|
+
extraStyles={`padding-left: 16px;
|
|
398
398
|
cursor: ${
|
|
399
399
|
disabledValues.includes(choice.value)
|
|
400
400
|
? "default"
|
|
401
401
|
: "pointer"
|
|
402
|
-
};
|
|
403
|
-
white-space: nowrap;
|
|
404
|
-
overflow: hidden;
|
|
402
|
+
};
|
|
403
|
+
white-space: nowrap;
|
|
404
|
+
overflow: hidden;
|
|
405
405
|
text-overflow: ellipsis;`}
|
|
406
406
|
>
|
|
407
407
|
{choice.text}
|
|
@@ -21,9 +21,10 @@ const FormSelect = ({
|
|
|
21
21
|
disabled,
|
|
22
22
|
themeValues,
|
|
23
23
|
hasTitles = false,
|
|
24
|
-
autocompleteValue
|
|
24
|
+
autocompleteValue, // browser autofill value, like country-name
|
|
25
25
|
smoothScroll = true, // whether the browser should animate scroll to selected item on first open
|
|
26
|
-
dataQa = null
|
|
26
|
+
dataQa = null,
|
|
27
|
+
widthFitOptions = false
|
|
27
28
|
}) => {
|
|
28
29
|
const [open, setOpen] = useState(false);
|
|
29
30
|
const dropdownRef = useRef(null);
|
|
@@ -73,6 +74,7 @@ const FormSelect = ({
|
|
|
73
74
|
"error message"
|
|
74
75
|
)}
|
|
75
76
|
maxHeight={dropdownMaxHeight}
|
|
77
|
+
widthFitOptions={widthFitOptions}
|
|
76
78
|
hasTitles={hasTitles}
|
|
77
79
|
placeholder={options[0] ? options[0].text : ""}
|
|
78
80
|
options={options}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { connect } from "react-redux";
|
|
3
|
+
import { text } from "@storybook/addon-knobs";
|
|
3
4
|
import { createFormState, required } from "redux-freeform";
|
|
4
5
|
|
|
5
6
|
import FormSelect from "./FormSelect";
|
|
@@ -30,17 +31,20 @@ const story = page({
|
|
|
30
31
|
height: "500px"
|
|
31
32
|
});
|
|
32
33
|
|
|
33
|
-
const FormWrapper =
|
|
34
|
+
const FormWrapper = props => (
|
|
34
35
|
<FormSelect
|
|
36
|
+
autocompleteValue={props.autocompleteValue}
|
|
35
37
|
labelTextWhenNoError="Form Select"
|
|
36
38
|
errorMessages={errorMessages}
|
|
37
39
|
options={options}
|
|
38
|
-
field={fields.thing}
|
|
39
|
-
fieldActions={actions.fields.thing}
|
|
40
|
+
field={props.fields.thing}
|
|
41
|
+
fieldActions={props.actions.fields.thing}
|
|
40
42
|
disabledValues={["disabled"]}
|
|
41
43
|
/>
|
|
42
44
|
);
|
|
43
45
|
|
|
44
46
|
export default story;
|
|
45
47
|
const ConnectedForm = connect(mapStateToProps, mapDispatchToProps)(FormWrapper);
|
|
46
|
-
export const formSelect = () =>
|
|
48
|
+
export const formSelect = () => (
|
|
49
|
+
<ConnectedForm autocompleteValue={text("autocompleteValue", null, "props")} />
|
|
50
|
+
);
|
|
@@ -20,9 +20,10 @@ export interface FormSelectProps {
|
|
|
20
20
|
disabledValues?: string[];
|
|
21
21
|
themeValues?: object;
|
|
22
22
|
hasTitles?: boolean;
|
|
23
|
-
autocompleteValue?: string
|
|
23
|
+
autocompleteValue?: string;
|
|
24
24
|
smoothScroll?: boolean;
|
|
25
25
|
dataQa?: string | null;
|
|
26
|
+
widthFitOptions?: boolean;
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
export const FormSelect: React.FC<Expand<FormSelectProps> &
|
|
@@ -20,7 +20,6 @@ import {
|
|
|
20
20
|
CheckmarkIcon,
|
|
21
21
|
BankIcon,
|
|
22
22
|
GenericCard,
|
|
23
|
-
PaymentIcon,
|
|
24
23
|
AutopayOnIcon,
|
|
25
24
|
SearchIcon,
|
|
26
25
|
AchReturnIcon,
|
|
@@ -66,7 +65,6 @@ export const routingNumberImage = () => <RoutingNumberImage />;
|
|
|
66
65
|
export const checkmarkIcon = () => <CheckmarkIcon />;
|
|
67
66
|
export const bankIcon = () => <BankIcon />;
|
|
68
67
|
export const genericCard = () => <GenericCard />;
|
|
69
|
-
export const paymentIcon = () => <PaymentIcon />;
|
|
70
68
|
export const autopayOnIcon = () => <AutopayOnIcon />;
|
|
71
69
|
export const searchIcon = () => <SearchIcon />;
|
|
72
70
|
export const achReturnIcon = () => <AchReturnIcon />;
|
|
@@ -13,6 +13,7 @@ import { safeChildren, screenReaderOnlyStyle } from "../../../util/general";
|
|
|
13
13
|
const Box = forwardRef(
|
|
14
14
|
(
|
|
15
15
|
{
|
|
16
|
+
autocompleteValue,
|
|
16
17
|
padding = "16px",
|
|
17
18
|
borderSize = "0px",
|
|
18
19
|
borderColor = "transparent",
|
|
@@ -50,6 +51,7 @@ const Box = forwardRef(
|
|
|
50
51
|
ref
|
|
51
52
|
) => (
|
|
52
53
|
<BoxWrapper
|
|
54
|
+
autoComplete={autocompleteValue}
|
|
53
55
|
padding={padding}
|
|
54
56
|
borderSize={borderSize}
|
|
55
57
|
borderColor={borderColor}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Cluster, Stack } from "../layouts";
|
|
3
3
|
import Paragraph from "../paragraph";
|
|
4
|
-
import Text from "../text";
|
|
5
4
|
import { themeComponent } from "../../../util/themeUtils";
|
|
6
5
|
import { fallbackValues } from "./LineItem.theme";
|
|
7
|
-
import {
|
|
6
|
+
import { STORM_GREY } from "../../../constants/colors";
|
|
8
7
|
|
|
9
8
|
const LineItem = ({
|
|
10
9
|
description,
|
|
@@ -29,15 +28,8 @@ const LineItem = ({
|
|
|
29
28
|
attr => visibleFields.includes(attr.key) && attr.key !== "description"
|
|
30
29
|
)
|
|
31
30
|
?.map(attr => (
|
|
32
|
-
<Paragraph
|
|
33
|
-
|
|
34
|
-
weight="400"
|
|
35
|
-
key={attr.key}
|
|
36
|
-
>
|
|
37
|
-
<Text weight={FONT_WEIGHT_SEMIBOLD}>{`${formatAttrKeys(
|
|
38
|
-
attr.key
|
|
39
|
-
)}:`}</Text>
|
|
40
|
-
<Text>{` ${attr.value}`}</Text>
|
|
31
|
+
<Paragraph variant="pS" weight="400" key={attr.key} color={STORM_GREY}>
|
|
32
|
+
{`${formatAttrKeys(attr.key)}: ${attr.value}`}
|
|
41
33
|
</Paragraph>
|
|
42
34
|
));
|
|
43
35
|
|
|
@@ -53,7 +45,9 @@ const LineItem = ({
|
|
|
53
45
|
<Paragraph variant={themeValues.paragraphVariant} weight="400">
|
|
54
46
|
{subDescription}
|
|
55
47
|
</Paragraph>
|
|
56
|
-
{visibleCustomAttrs &&
|
|
48
|
+
{visibleCustomAttrs && (
|
|
49
|
+
<Stack childGap="0.25rem">{visibleCustomAttrs}</Stack>
|
|
50
|
+
)}
|
|
57
51
|
</Stack>
|
|
58
52
|
{!!displayQuantity && (
|
|
59
53
|
<Paragraph
|
|
@@ -8,6 +8,7 @@ import Checkbox from "../checkbox";
|
|
|
8
8
|
const SELECT_ALL = "Select All";
|
|
9
9
|
|
|
10
10
|
const SearchableSelect = ({
|
|
11
|
+
autocompleteValue,
|
|
11
12
|
items,
|
|
12
13
|
selectedItems,
|
|
13
14
|
allSelected,
|
|
@@ -47,6 +48,7 @@ const SearchableSelect = ({
|
|
|
47
48
|
}
|
|
48
49
|
>
|
|
49
50
|
<FormInput
|
|
51
|
+
autocompleteValue={autocompleteValue}
|
|
50
52
|
errorMessages={{}}
|
|
51
53
|
field={fields.searchTerm}
|
|
52
54
|
fieldActions={actions.fields.searchTerm}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { connect } from "react-redux";
|
|
3
|
+
import { text } from "@storybook/addon-knobs";
|
|
4
|
+
import { createFormState } from "redux-freeform";
|
|
5
|
+
|
|
6
|
+
import SearchableSelect from "./SearchableSelect";
|
|
7
|
+
import page from "../../../../.storybook/page";
|
|
8
|
+
|
|
9
|
+
const { mapStateToProps, mapDispatchToProps, reducer } = createFormState({
|
|
10
|
+
searchTerm: {
|
|
11
|
+
validators: []
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const items = [
|
|
16
|
+
{ name: "Foo", value: "foo-value" },
|
|
17
|
+
{ name: "Bar", value: "bar-value" },
|
|
18
|
+
{ name: "Baz", value: "baz-value" }
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
const FormWrapper = props => {
|
|
22
|
+
const [selectedItems, setSelectedItems] = useState(props.selectedItems || []);
|
|
23
|
+
const selectValues = items => items.map(item => item.value);
|
|
24
|
+
|
|
25
|
+
const selectItem = selectedItem => {
|
|
26
|
+
if (selectValues(selectedItems).includes(selectedItem.value)) {
|
|
27
|
+
const fewerItems = selectedItems.filter(
|
|
28
|
+
item => item.value !== selectedItem.value
|
|
29
|
+
);
|
|
30
|
+
setSelectedItems(fewerItems);
|
|
31
|
+
} else {
|
|
32
|
+
const moreItems = selectedItems.concat(selectedItem);
|
|
33
|
+
setSelectedItems(moreItems);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<SearchableSelect
|
|
39
|
+
autocompleteValue={props.autocompleteValue}
|
|
40
|
+
items={items}
|
|
41
|
+
fields={props.fields}
|
|
42
|
+
actions={props.actions}
|
|
43
|
+
selectedItems={selectedItems}
|
|
44
|
+
selectItem={selectItem}
|
|
45
|
+
/>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const story = page({
|
|
50
|
+
title: "Components|Atoms/SearchableSelect",
|
|
51
|
+
Component: SearchableSelect,
|
|
52
|
+
reducer,
|
|
53
|
+
mapStateToProps,
|
|
54
|
+
mapDispatchToProps
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export default story;
|
|
58
|
+
const ConnectedForm = connect(mapStateToProps, mapDispatchToProps)(FormWrapper);
|
|
59
|
+
export const searchableSelect = () => (
|
|
60
|
+
<ConnectedForm autocompleteValue={text("autocompleteValue", null, "props")} />
|
|
61
|
+
);
|
|
@@ -9,8 +9,7 @@ const FormStateDropdown = ({
|
|
|
9
9
|
field,
|
|
10
10
|
fieldActions,
|
|
11
11
|
showErrors,
|
|
12
|
-
countryCode
|
|
13
|
-
autocompleteValue = null
|
|
12
|
+
countryCode
|
|
14
13
|
}) => {
|
|
15
14
|
const placeholder =
|
|
16
15
|
countryCode === "US" ? placeHolderOptionUS : placeHolderOption;
|
|
@@ -23,7 +22,7 @@ const FormStateDropdown = ({
|
|
|
23
22
|
labelTextWhenNoError={labelTextWhenNoError}
|
|
24
23
|
errorMessages={errorMessages}
|
|
25
24
|
showErrors={showErrors}
|
|
26
|
-
autocompleteValue=
|
|
25
|
+
autocompleteValue="address-level1"
|
|
27
26
|
/>
|
|
28
27
|
);
|
|
29
28
|
};
|
|
Binary file
|
|
@@ -98,7 +98,7 @@ const AddressForm = ({
|
|
|
98
98
|
fieldActions={actions.fields.city}
|
|
99
99
|
showErrors={showErrors}
|
|
100
100
|
onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
|
|
101
|
-
autocompleteValue="
|
|
101
|
+
autocompleteValue="address-level2"
|
|
102
102
|
dataQa="City"
|
|
103
103
|
/>
|
|
104
104
|
<StateProvinceDropdown
|
|
@@ -109,7 +109,6 @@ const AddressForm = ({
|
|
|
109
109
|
fieldActions={actions.fields.stateProvince}
|
|
110
110
|
showErrors={showErrors}
|
|
111
111
|
onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
|
|
112
|
-
autocompleteValue="administrative-area"
|
|
113
112
|
dataQa="State or Province"
|
|
114
113
|
/>
|
|
115
114
|
<FormInput
|
|
@@ -40,7 +40,7 @@ const PhoneForm = ({
|
|
|
40
40
|
showErrors={showErrors}
|
|
41
41
|
formatter={createFormat(phoneFormats, formatDelimiter)}
|
|
42
42
|
onKeyUp={e => e.key === "Enter" && handleSubmit(e)}
|
|
43
|
-
autocompleteValue="tel"
|
|
43
|
+
autocompleteValue="tel-national"
|
|
44
44
|
dataQa="Phone number"
|
|
45
45
|
isNum={true}
|
|
46
46
|
/>
|
|
File without changes
|