@thecb/components 9.0.6 → 9.0.7-beta.1
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 +15 -20
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.esm.js +15 -20
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/dropdown/Dropdown.js +5 -5
- package/src/components/atoms/form-layouts/FormInput.js +1 -1
- package/src/components/atoms/form-select/FormSelect.js +2 -4
- package/src/components/atoms/form-select/FormSelect.stories.js +8 -4
- package/src/components/atoms/form-select/index.d.ts +0 -1
- package/src/components/atoms/icons/icons.stories.js +0 -2
- package/src/components/atoms/layouts/Box.js +2 -0
- 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/state-province-dropdown/StateProvinceDropdown.js +2 -3
- package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.stories.js +1 -0
- package/src/components/molecules/address-form/AddressForm.js +0 -1
- 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
|
@@ -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,10 +21,9 @@ 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
|
|
27
|
-
widthFitOptions = false
|
|
26
|
+
dataQa = null
|
|
28
27
|
}) => {
|
|
29
28
|
const [open, setOpen] = useState(false);
|
|
30
29
|
const dropdownRef = useRef(null);
|
|
@@ -74,7 +73,6 @@ const FormSelect = ({
|
|
|
74
73
|
"error message"
|
|
75
74
|
)}
|
|
76
75
|
maxHeight={dropdownMaxHeight}
|
|
77
|
-
widthFitOptions={widthFitOptions}
|
|
78
76
|
hasTitles={hasTitles}
|
|
79
77
|
placeholder={options[0] ? options[0].text : ""}
|
|
80
78
|
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,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}
|
|
@@ -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
|
};
|
|
@@ -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
|