@thecb/components 10.12.1 → 10.12.2-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 +252 -124
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.esm.js +251 -125
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/checkbox/Checkbox.js +22 -9
- package/src/components/atoms/checkbox/Checkbox.stories.js +17 -13
- package/src/components/atoms/checkbox/Checkbox.theme.js +6 -2
- package/src/components/atoms/icons/CheckboxCheckmarkIcon.js +45 -0
- package/src/components/atoms/icons/PaymentStatusIcon.d.ts +1 -0
- package/src/components/atoms/icons/PaymentStatusIcon.js +28 -0
- package/src/components/atoms/icons/PersonIcon.d.ts +1 -0
- package/src/components/atoms/icons/PersonIcon.js +28 -0
- package/src/components/atoms/icons/icons.stories.js +5 -1
- package/src/components/atoms/icons/index.js +5 -1
- package/src/components/molecules/multiple-select-filter/MultipleSelectFilter.js +33 -25
- package/src/components/molecules/multiple-select-filter/MultipleSelectFilter.stories.js +2 -4
- package/src/components/molecules/multiple-select-filter/MultipleSelectFilter.styled.js +15 -7
- package/src/components/molecules/multiple-select-filter/MultipleSelectFilter.theme.js +7 -3
- package/src/components/molecules/multiple-select-filter/__private__/ActionLinkButton.js +16 -13
- package/src/components/molecules/multiple-select-filter/__private__/FilterButton.js +24 -14
- package/src/components/molecules/multiple-select-filter/__private__/FilterDropdown.js +22 -18
- package/src/components/molecules/multiple-select-filter/__private__/FilterableList.js +43 -41
- package/src/components/molecules/multiple-select-filter/__private__/FilterableListItem.js +52 -41
- package/src/components/molecules/multiple-select-filter/__private__/SearchBox.js +10 -7
- package/src/components/molecules/multiple-select-filter/index.d.ts +2 -2
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
import React, { forwardRef } from "react";
|
|
2
2
|
import { FilterDropdownContainer } from "../MultipleSelectFilter.styled";
|
|
3
3
|
|
|
4
|
-
const FilterDropdown = forwardRef(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
4
|
+
const FilterDropdown = forwardRef(
|
|
5
|
+
({ id, ariaOwns, ariaControls, opened, extraStyles, children }, ref) => {
|
|
6
|
+
return (
|
|
7
|
+
<>
|
|
8
|
+
{opened && (
|
|
9
|
+
<FilterDropdownContainer
|
|
10
|
+
ref={ref}
|
|
11
|
+
id={id}
|
|
12
|
+
role="combobox"
|
|
13
|
+
aria-expanded={opened}
|
|
14
|
+
aria-haspopup="listbox"
|
|
15
|
+
aria-owns={ariaOwns}
|
|
16
|
+
aria-controls={ariaControls}
|
|
17
|
+
extraStyles={extraStyles}
|
|
18
|
+
>
|
|
19
|
+
{children}
|
|
20
|
+
</FilterDropdownContainer>
|
|
21
|
+
)}
|
|
22
|
+
</>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
);
|
|
22
26
|
|
|
23
27
|
export default FilterDropdown;
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
isChecked,
|
|
10
10
|
isMaxSelectionReached
|
|
11
11
|
} from "./util";
|
|
12
|
-
import { GHOST_GREY } from "../../../../constants/colors";
|
|
13
12
|
|
|
14
13
|
const FilterableList = ({
|
|
15
14
|
id,
|
|
@@ -68,23 +67,20 @@ const FilterableList = ({
|
|
|
68
67
|
return (
|
|
69
68
|
<Box
|
|
70
69
|
id={id}
|
|
71
|
-
role="listbox"
|
|
72
70
|
padding="0"
|
|
71
|
+
role="listbox"
|
|
72
|
+
aria-label="Filter options container"
|
|
73
|
+
onKeyDown={handleKeyDown}
|
|
73
74
|
extraStyles={`
|
|
74
75
|
overflow-y: auto;
|
|
75
76
|
max-height: 250px;
|
|
76
77
|
display: flex;
|
|
77
78
|
flex-flow: column;
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
padding-bottom: 0.5rem;
|
|
80
|
+
`}
|
|
80
81
|
>
|
|
81
82
|
{sortedAppliedOptions?.length > 0 && (
|
|
82
|
-
|
|
83
|
-
padding="0"
|
|
84
|
-
extraStyles={
|
|
85
|
-
sortedOptions.length > 0 && `border-bottom: 1px solid ${GHOST_GREY}`
|
|
86
|
-
}
|
|
87
|
-
>
|
|
83
|
+
<>
|
|
88
84
|
{sortedAppliedOptions.map((option, index) => {
|
|
89
85
|
const checked = isChecked(option, selectedOptions);
|
|
90
86
|
const tabIndex =
|
|
@@ -102,41 +98,47 @@ const FilterableList = ({
|
|
|
102
98
|
tabIndex={tabIndex}
|
|
103
99
|
name={name}
|
|
104
100
|
themeValues={themeValues}
|
|
101
|
+
showDivider={
|
|
102
|
+
sortedOptions.length > 0 &&
|
|
103
|
+
index === sortedAppliedOptions.length - 1
|
|
104
|
+
}
|
|
105
105
|
></FilterableListItem>
|
|
106
106
|
);
|
|
107
107
|
})}
|
|
108
|
-
|
|
108
|
+
</>
|
|
109
109
|
)}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
110
|
+
<>
|
|
111
|
+
{sortedOptions.map((option, index) => {
|
|
112
|
+
const checked = isChecked(option, selectedOptions);
|
|
113
|
+
const isDisabled =
|
|
114
|
+
isMaxSelectionReached(maxSelections, selectedOptions) && !checked;
|
|
115
|
+
const indexOffset = sortedAppliedOptions?.length
|
|
116
|
+
? sortedAppliedOptions?.length
|
|
117
|
+
: 0;
|
|
118
|
+
const currentIndex = index === 0 ? indexOffset : index + indexOffset;
|
|
119
|
+
const tabIndex =
|
|
120
|
+
currentIndex === focusedIndex ||
|
|
121
|
+
(indexOffset === 0 &&
|
|
122
|
+
currentIndex === indexOffset &&
|
|
123
|
+
focusedIndex === -1)
|
|
124
|
+
? "0"
|
|
125
|
+
: "-1";
|
|
126
|
+
return (
|
|
127
|
+
<FilterableListItem
|
|
128
|
+
key={currentIndex}
|
|
129
|
+
ref={el => (itemRefs.current[currentIndex] = el)}
|
|
130
|
+
index={currentIndex}
|
|
131
|
+
option={option}
|
|
132
|
+
checked={checked}
|
|
133
|
+
selectOption={isDisabled ? noop : handleSelectOption}
|
|
134
|
+
disabled={isDisabled}
|
|
135
|
+
tabIndex={tabIndex}
|
|
136
|
+
name={name}
|
|
137
|
+
themeValues={themeValues}
|
|
138
|
+
></FilterableListItem>
|
|
139
|
+
);
|
|
140
|
+
})}
|
|
141
|
+
</>
|
|
140
142
|
</Box>
|
|
141
143
|
);
|
|
142
144
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { forwardRef } from "react";
|
|
2
2
|
import Checkbox from "../../../atoms/checkbox";
|
|
3
|
-
import {
|
|
3
|
+
import { GHOST_GREY } from "../../../../constants/colors";
|
|
4
|
+
import CheckboxCheckmarkIcon from "../../../atoms/icons/CheckboxCheckmarkIcon";
|
|
4
5
|
|
|
5
6
|
const FilterableListItem = forwardRef(
|
|
6
7
|
(
|
|
@@ -12,54 +13,64 @@ const FilterableListItem = forwardRef(
|
|
|
12
13
|
disabled,
|
|
13
14
|
tabIndex,
|
|
14
15
|
name,
|
|
16
|
+
showDivider,
|
|
17
|
+
extraStyles,
|
|
15
18
|
themeValues
|
|
16
19
|
},
|
|
17
20
|
ref
|
|
18
21
|
) => {
|
|
22
|
+
const dividerStyles = `
|
|
23
|
+
::after {
|
|
24
|
+
content: '';
|
|
25
|
+
position: absolute;
|
|
26
|
+
width: 100%;
|
|
27
|
+
display: block;
|
|
28
|
+
height: 1px;
|
|
29
|
+
background-color: ${GHOST_GREY};
|
|
30
|
+
bottom: -0.5rem;
|
|
31
|
+
left: 0;
|
|
32
|
+
}`;
|
|
19
33
|
return (
|
|
20
|
-
<
|
|
21
|
-
padding="0"
|
|
34
|
+
<Checkbox
|
|
22
35
|
key={index}
|
|
36
|
+
ref={ref}
|
|
37
|
+
title={option.name}
|
|
38
|
+
name={option.name}
|
|
39
|
+
role="option"
|
|
40
|
+
aria-selected={checked}
|
|
41
|
+
tabIndex={tabIndex}
|
|
42
|
+
dataQa={`${name}-option-${index}`}
|
|
43
|
+
checked={checked}
|
|
44
|
+
onChange={() => selectOption(option)}
|
|
45
|
+
textExtraStyles={`font-size: 0.875rem; margin: 0;`}
|
|
46
|
+
disabled={disabled}
|
|
23
47
|
extraStyles={`
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
title={option.name}
|
|
34
|
-
name={option.name}
|
|
35
|
-
checked={checked}
|
|
36
|
-
onChange={() => selectOption(option)}
|
|
37
|
-
textExtraStyles={`font-size: 0.875rem; margin: 0;`}
|
|
38
|
-
disabled={disabled}
|
|
39
|
-
extraStyles={`
|
|
40
|
-
padding: 0.075rem 0.325rem;
|
|
41
|
-
margin: 0;
|
|
42
|
-
:hover,
|
|
43
|
-
:active,
|
|
44
|
-
:focus {
|
|
45
|
-
background-color: ${themeValues.primaryColor};
|
|
46
|
-
}
|
|
48
|
+
padding: 0.375rem 0.625rem;
|
|
49
|
+
margin: 0;
|
|
50
|
+
:hover,
|
|
51
|
+
:active,
|
|
52
|
+
:focus {
|
|
53
|
+
background-color: ${themeValues.primaryColor};
|
|
54
|
+
}
|
|
55
|
+
${showDivider && dividerStyles}
|
|
56
|
+
${extraStyles}
|
|
47
57
|
`}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
checkboxMargin={showDivider ? "0 0 1rem" : "0"}
|
|
59
|
+
hasIconOverride={true}
|
|
60
|
+
icon={CheckboxCheckmarkIcon}
|
|
61
|
+
checkboxExtraStyles={`
|
|
62
|
+
display: flex;
|
|
63
|
+
justify-content: center;
|
|
64
|
+
align-items: center;
|
|
65
|
+
height: 20px;
|
|
66
|
+
width: 20px;
|
|
67
|
+
${
|
|
68
|
+
checked && !disabled
|
|
69
|
+
? `background: ` + themeValues.secondaryColor + `;`
|
|
70
|
+
: ""
|
|
71
|
+
}
|
|
72
|
+
`}
|
|
73
|
+
/>
|
|
63
74
|
);
|
|
64
75
|
}
|
|
65
76
|
);
|
|
@@ -22,13 +22,16 @@ const SearchBox = ({
|
|
|
22
22
|
placeholder={placeholder}
|
|
23
23
|
disabled={disabled}
|
|
24
24
|
extraStyles={`
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
height: 2.875rem;
|
|
26
|
+
border: 0;
|
|
27
|
+
border-radius: 0;
|
|
28
|
+
padding: 0.45rem;
|
|
29
|
+
font-size: 0.875rem;
|
|
30
|
+
border-bottom: 1px solid ${GHOST_GREY};
|
|
31
|
+
:focus {
|
|
32
|
+
outline-offset: -3px;
|
|
33
|
+
}
|
|
34
|
+
`}
|
|
32
35
|
/>
|
|
33
36
|
)}
|
|
34
37
|
</Box>
|
|
@@ -10,7 +10,9 @@ export interface MultipleSelectFilterProps {
|
|
|
10
10
|
actions: FieldActions;
|
|
11
11
|
autocompleteValue?: boolean;
|
|
12
12
|
btnContentOverride?: JSX.Element;
|
|
13
|
+
btnExtraStyles?: string;
|
|
13
14
|
disabled: boolean;
|
|
15
|
+
dropdownExtraStyles?: string;
|
|
14
16
|
extraStyles?: string;
|
|
15
17
|
fields: {
|
|
16
18
|
searchTerm: Field;
|
|
@@ -24,8 +26,6 @@ export interface MultipleSelectFilterProps {
|
|
|
24
26
|
options: SearchableSelectOption[];
|
|
25
27
|
placeholder?: string;
|
|
26
28
|
searchable?: boolean;
|
|
27
|
-
selectedOptions: SearchableSelectOption[];
|
|
28
|
-
setSelectedOptions: (options: SearchableSelectOption[]) => void;
|
|
29
29
|
themeValues?: any[];
|
|
30
30
|
truncateBtnTextWidth?: string;
|
|
31
31
|
}
|