playbook_ui 13.25.0.pre.alpha.PBNTR272Dropdownkitv42769 β 13.25.0.pre.alpha.PLAY1249fixTooltipswrappingformelementscausingmisalignment2783
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.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/index.js +0 -1
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +12 -90
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +11 -63
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default.jsx +13 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default.md +0 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display.jsx +1 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display.md +1 -3
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_options.jsx +4 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_padding.jsx +4 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +2 -5
- data/app/pb_kits/playbook/pb_dropdown/docs/index.js +1 -4
- data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +10 -200
- data/app/pb_kits/playbook/pb_dropdown/hooks/useDropdown.tsx +2 -2
- data/app/pb_kits/playbook/pb_dropdown/hooks/useHandleOnKeydown.tsx +4 -4
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownContainer.tsx +8 -17
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownOption.tsx +8 -16
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownTrigger.tsx +78 -96
- data/app/pb_kits/playbook/pb_dropdown/utilities/subComponentHelper.tsx +7 -9
- data/app/pb_kits/playbook/pb_tooltip/_tooltip.tsx +0 -1
- data/dist/playbook-rails.js +4 -4
- data/lib/playbook/version.rb +1 -1
- metadata +2 -6
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_external_control.jsx +0 -62
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx +0 -75
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_label.jsx +0 -39
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_label.md +0 -1
@@ -1,207 +1,17 @@
|
|
1
|
-
import
|
2
|
-
import { render, screen } from "../utilities/test-utils"
|
1
|
+
import { renderKit } from '../utilities/test-utils'
|
3
2
|
|
4
|
-
import { Dropdown
|
3
|
+
import { Dropdown } from '../'
|
5
4
|
|
5
|
+
/* See these resources for more testing info:
|
6
|
+
- https://github.com/testing-library/jest-dom#usage for useage and examples
|
7
|
+
- https://jestjs.io/docs/en/using-matchers
|
8
|
+
*/
|
6
9
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
{
|
11
|
-
label: "United States",
|
12
|
-
value: "United States",
|
13
|
-
areaCode: "+1",
|
14
|
-
icon: "πΊπΈ",
|
15
|
-
id: "United-states"
|
16
|
-
},
|
17
|
-
{
|
18
|
-
label: "Canada",
|
19
|
-
value: "Canada",
|
20
|
-
areaCode: "+1",
|
21
|
-
icon: "π¨π¦",
|
22
|
-
id: "canada"
|
23
|
-
},
|
24
|
-
{
|
25
|
-
label: "Pakistan",
|
26
|
-
value: "Pakistan",
|
27
|
-
areaCode: "+92",
|
28
|
-
icon: "π΅π°",
|
29
|
-
id: "pakistan"
|
10
|
+
test('generated scaffold test - update me', () => {
|
11
|
+
const props = {
|
12
|
+
data: { testid: 'default' }
|
30
13
|
}
|
31
|
-
];
|
32
|
-
|
33
|
-
const DefaultDropdownKit = () => {
|
34
|
-
return (
|
35
|
-
<Dropdown
|
36
|
-
data={{ testid: testId }}
|
37
|
-
options={options}
|
38
|
-
>
|
39
|
-
{options.map((option) => (
|
40
|
-
<Dropdown.Option key={option.id}
|
41
|
-
option={option}
|
42
|
-
/>
|
43
|
-
))}
|
44
|
-
</Dropdown>
|
45
|
-
)
|
46
|
-
}
|
47
14
|
|
48
|
-
|
49
|
-
render(<DefaultDropdownKit/>)
|
50
|
-
|
51
|
-
const kit = screen.getByTestId(testId)
|
15
|
+
const kit = renderKit(Dropdown , props)
|
52
16
|
expect(kit).toBeInTheDocument()
|
53
|
-
expect(kit).toHaveClass('pb_dropdown')
|
54
|
-
})
|
55
|
-
|
56
|
-
test('generated default Trigger and Container when none passed in', () => {
|
57
|
-
render(<DefaultDropdownKit/>)
|
58
|
-
|
59
|
-
const kit = screen.getByTestId(testId)
|
60
|
-
|
61
|
-
const trigger = kit.querySelector('.pb_dropdown_trigger')
|
62
|
-
expect(trigger).toBeInTheDocument()
|
63
|
-
|
64
|
-
const container = kit.querySelector('.pb_dropdown_container')
|
65
|
-
expect(container).toBeInTheDocument()
|
66
|
-
|
67
|
-
const defaultTrigger = kit.querySelector('.dropdown_trigger_wrapper_select_only')
|
68
|
-
expect(defaultTrigger).toBeInTheDocument()
|
69
|
-
})
|
70
|
-
|
71
|
-
test('generated Options', () => {
|
72
|
-
render(<DefaultDropdownKit/>)
|
73
|
-
|
74
|
-
const kit = screen.getByTestId(testId)
|
75
|
-
const option = kit.querySelector('.pb_dropdown_option')
|
76
|
-
expect(option).toBeInTheDocument()
|
77
|
-
})
|
78
|
-
|
79
|
-
test('generated customDisplay for trigger', () => {
|
80
|
-
render (
|
81
|
-
<Dropdown
|
82
|
-
data={{ testid: testId }}
|
83
|
-
options={options}
|
84
|
-
>
|
85
|
-
<Dropdown.Trigger
|
86
|
-
customDisplay={<Icon icon="flag" />}
|
87
|
-
/>
|
88
|
-
{options.map((option) => (
|
89
|
-
<Dropdown.Option key={option.id}
|
90
|
-
option={option}
|
91
|
-
/>
|
92
|
-
))}
|
93
|
-
</Dropdown>
|
94
|
-
)
|
95
|
-
|
96
|
-
const kit = screen.getByTestId(testId)
|
97
|
-
const trigger = kit.querySelector('.pb_dropdown_trigger')
|
98
|
-
const customDisplay = trigger.querySelector('.fa-flag.pb_icon_kit.fa-fw')
|
99
|
-
expect(customDisplay).toBeInTheDocument()
|
100
17
|
})
|
101
|
-
|
102
|
-
test('generated placeholder prop', () => {
|
103
|
-
render (
|
104
|
-
<Dropdown
|
105
|
-
data={{ testid: testId }}
|
106
|
-
options={options}
|
107
|
-
>
|
108
|
-
<Dropdown.Trigger
|
109
|
-
placeholder="Select a country"
|
110
|
-
/>
|
111
|
-
{options.map((option) => (
|
112
|
-
<Dropdown.Option key={option.id}
|
113
|
-
option={option}
|
114
|
-
/>
|
115
|
-
))}
|
116
|
-
</Dropdown>
|
117
|
-
)
|
118
|
-
|
119
|
-
const kit = screen.getByTestId(testId)
|
120
|
-
const trigger = kit.querySelector('.pb_dropdown_trigger')
|
121
|
-
expect(trigger).toHaveTextContent('Select a country')
|
122
|
-
|
123
|
-
})
|
124
|
-
|
125
|
-
test('generated label prop', () => {
|
126
|
-
render (
|
127
|
-
<Dropdown
|
128
|
-
data={{ testid: testId }}
|
129
|
-
label="Countries"
|
130
|
-
options={options}
|
131
|
-
>
|
132
|
-
{options.map((option) => (
|
133
|
-
<Dropdown.Option key={option.id}
|
134
|
-
option={option}
|
135
|
-
/>
|
136
|
-
))}
|
137
|
-
</Dropdown>
|
138
|
-
)
|
139
|
-
|
140
|
-
const kit = screen.getByTestId(testId)
|
141
|
-
const label = kit.querySelector('.pb_caption_kit_md')
|
142
|
-
expect(label).toHaveTextContent('Countries')
|
143
|
-
})
|
144
|
-
|
145
|
-
test('generated custom option', () => {
|
146
|
-
render (
|
147
|
-
<Dropdown
|
148
|
-
data={{ testid: testId }}
|
149
|
-
options={options}
|
150
|
-
>
|
151
|
-
{options.map((option) => (
|
152
|
-
<Dropdown.Option key={option.id}
|
153
|
-
option={option}
|
154
|
-
>
|
155
|
-
<Icon icon={option.icon} />
|
156
|
-
</Dropdown.Option>
|
157
|
-
))}
|
158
|
-
</Dropdown>
|
159
|
-
)
|
160
|
-
|
161
|
-
const kit = screen.getByTestId(testId)
|
162
|
-
const customOption = kit.querySelector('.pb_icon_kit_emoji')
|
163
|
-
expect(customOption).toBeInTheDocument()
|
164
|
-
})
|
165
|
-
|
166
|
-
test('generated custom Trigger', () => {
|
167
|
-
render (
|
168
|
-
<Dropdown
|
169
|
-
data={{ testid: testId }}
|
170
|
-
options={options}
|
171
|
-
>
|
172
|
-
<Dropdown.Trigger>
|
173
|
-
<Icon icon="home" />
|
174
|
-
</Dropdown.Trigger>
|
175
|
-
{options.map((option) => (
|
176
|
-
<Dropdown.Option key={option.id}
|
177
|
-
option={option}
|
178
|
-
/>
|
179
|
-
))}
|
180
|
-
</Dropdown>
|
181
|
-
)
|
182
|
-
|
183
|
-
const kit = screen.getByTestId(testId)
|
184
|
-
const trigger = kit.querySelector('.pb_dropdown_trigger')
|
185
|
-
const customTrigger = trigger.querySelector('.fa-home.pb_icon_kit.fa-fw')
|
186
|
-
expect(customTrigger).toBeInTheDocument()
|
187
|
-
})
|
188
|
-
|
189
|
-
test('selected option on click', () => {
|
190
|
-
render (
|
191
|
-
<Dropdown
|
192
|
-
data={{ testid: testId }}
|
193
|
-
options={options}
|
194
|
-
>
|
195
|
-
{options.map((option) => (
|
196
|
-
<Dropdown.Option key={option.id}
|
197
|
-
option={option}
|
198
|
-
/>
|
199
|
-
))}
|
200
|
-
</Dropdown>
|
201
|
-
)
|
202
|
-
|
203
|
-
const kit = screen.getByTestId(testId)
|
204
|
-
const option = kit.querySelector('.pb_dropdown_option')
|
205
|
-
option.click()
|
206
|
-
expect(option).toHaveClass('pb_dropdown_option dropdown_option_selected p_xs')
|
207
|
-
})
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import {useState} from 'react';
|
2
2
|
|
3
3
|
|
4
|
-
const useDropdown = (initial=
|
4
|
+
const useDropdown = (initial=true) => {
|
5
5
|
|
6
6
|
const [isDropDownClosed, setIsDropDownClosed] = useState(initial);
|
7
7
|
|
8
|
-
const toggleDropdown = () => setIsDropDownClosed(
|
8
|
+
const toggleDropdown = () => setIsDropDownClosed(!isDropDownClosed);
|
9
9
|
|
10
10
|
return [
|
11
11
|
isDropDownClosed,
|
@@ -6,13 +6,13 @@ export const useHandleOnKeyDown = () => {
|
|
6
6
|
|
7
7
|
const {
|
8
8
|
autocomplete,
|
9
|
-
filteredOptions,
|
10
9
|
focusedOptionIndex,
|
11
|
-
|
12
|
-
handleOptionClick,
|
13
|
-
selected,
|
10
|
+
filteredOptions,
|
14
11
|
setFocusedOptionIndex,
|
12
|
+
handleOptionClick,
|
15
13
|
setIsDropDownClosed,
|
14
|
+
handleBackspace,
|
15
|
+
selected,
|
16
16
|
}= useContext(DropdownContext)
|
17
17
|
|
18
18
|
return (e: React.KeyboardEvent) => {
|
@@ -17,9 +17,8 @@ import Body from "../../pb_body/_body";
|
|
17
17
|
|
18
18
|
type DropdownContainerProps = {
|
19
19
|
aria?: { [key: string]: string };
|
20
|
-
children?: React.ReactChild[] | React.ReactChild;
|
21
20
|
className?: string;
|
22
|
-
|
21
|
+
children?: React.ReactChild[] | React.ReactChild;
|
23
22
|
data?: { [key: string]: string };
|
24
23
|
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
25
24
|
id?: string;
|
@@ -29,9 +28,8 @@ type DropdownContainerProps = {
|
|
29
28
|
const DropdownContainer = (props: DropdownContainerProps) => {
|
30
29
|
const {
|
31
30
|
aria = {},
|
32
|
-
children,
|
33
31
|
className,
|
34
|
-
|
32
|
+
children,
|
35
33
|
data = {},
|
36
34
|
htmlOptions = {},
|
37
35
|
id,
|
@@ -39,14 +37,12 @@ const DropdownContainer = (props: DropdownContainerProps) => {
|
|
39
37
|
} = props;
|
40
38
|
|
41
39
|
const {
|
42
|
-
|
43
|
-
filteredOptions,
|
44
|
-
filterItem,
|
40
|
+
isDropDownClosed,
|
45
41
|
handleChange,
|
42
|
+
filterItem,
|
43
|
+
filteredOptions,
|
46
44
|
inputRef,
|
47
|
-
isDropDownClosed,
|
48
45
|
setFocusedOptionIndex,
|
49
|
-
triggerRef
|
50
46
|
} = useContext(DropdownContext);
|
51
47
|
|
52
48
|
const ariaProps = buildAriaProps(aria);
|
@@ -66,12 +62,9 @@ const DropdownContainer = (props: DropdownContainerProps) => {
|
|
66
62
|
className={classes}
|
67
63
|
id={id}
|
68
64
|
onMouseEnter={() => setFocusedOptionIndex(-1)}
|
69
|
-
ref={dropdownContainerRef}
|
70
|
-
style={triggerRef ? {} : { position: "absolute"}}
|
71
65
|
>
|
72
66
|
{searchbar && (
|
73
|
-
<TextInput
|
74
|
-
paddingTop="xs"
|
67
|
+
<TextInput paddingTop="xs"
|
75
68
|
paddingX="xs"
|
76
69
|
>
|
77
70
|
<input
|
@@ -82,10 +75,9 @@ const DropdownContainer = (props: DropdownContainerProps) => {
|
|
82
75
|
/>
|
83
76
|
</TextInput>
|
84
77
|
)}
|
85
|
-
<List
|
86
|
-
{
|
78
|
+
<List>{
|
87
79
|
filteredOptions?.length === 0 ? (
|
88
|
-
<ListItem
|
80
|
+
<ListItem
|
89
81
|
display="flex"
|
90
82
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
91
83
|
// @ts-ignore
|
@@ -93,7 +85,6 @@ const DropdownContainer = (props: DropdownContainerProps) => {
|
|
93
85
|
padding="xs"
|
94
86
|
>
|
95
87
|
<Body color="light"
|
96
|
-
dark={dark}
|
97
88
|
text="no option"
|
98
89
|
/>
|
99
90
|
</ListItem>
|
@@ -17,37 +17,35 @@ import { GenericObject } from "../../types";
|
|
17
17
|
|
18
18
|
type DropdownOptionProps = {
|
19
19
|
aria?: { [key: string]: string };
|
20
|
-
children?: React.ReactChild[] | React.ReactChild;
|
21
20
|
className?: string;
|
22
|
-
|
21
|
+
children?: React.ReactChild[] | React.ReactChild;
|
23
22
|
data?: { [key: string]: string };
|
24
23
|
htmlOptions?: { [key: string]: string | number | boolean | (() => void) };
|
25
24
|
id?: string;
|
26
|
-
key?: string;
|
27
25
|
option?: GenericObject;
|
26
|
+
key?: string;
|
28
27
|
padding?: string;
|
29
28
|
} & GlobalProps;
|
30
29
|
|
31
30
|
const DropdownOption = (props: DropdownOptionProps) => {
|
32
31
|
const {
|
33
32
|
aria = {},
|
34
|
-
children,
|
35
33
|
className,
|
36
|
-
|
34
|
+
children,
|
37
35
|
data = {},
|
38
36
|
htmlOptions = {},
|
39
37
|
id,
|
40
|
-
key,
|
41
38
|
option,
|
39
|
+
key,
|
42
40
|
padding = "xs",
|
43
41
|
} = props;
|
44
42
|
|
45
43
|
const {
|
46
|
-
filteredOptions,
|
47
|
-
filterItem,
|
48
|
-
focusedOptionIndex,
|
49
44
|
handleOptionClick,
|
50
45
|
selected,
|
46
|
+
filterItem,
|
47
|
+
filteredOptions,
|
48
|
+
focusedOptionIndex,
|
51
49
|
} = useContext(DropdownContext);
|
52
50
|
|
53
51
|
const isItemMatchingFilter = (option: GenericObject) =>
|
@@ -89,7 +87,6 @@ const DropdownOption = (props: DropdownOptionProps) => {
|
|
89
87
|
>
|
90
88
|
<ListItem
|
91
89
|
cursor="pointer"
|
92
|
-
dark={dark}
|
93
90
|
data-name={option.value}
|
94
91
|
key={option.label}
|
95
92
|
padding="none"
|
@@ -101,12 +98,7 @@ const DropdownOption = (props: DropdownOptionProps) => {
|
|
101
98
|
paddingX="sm"
|
102
99
|
paddingY="xxs"
|
103
100
|
>
|
104
|
-
{children ?
|
105
|
-
children :
|
106
|
-
<Body dark={dark}
|
107
|
-
text={option.label}
|
108
|
-
/>
|
109
|
-
}
|
101
|
+
{children ? children : <Body text={option.label} />}
|
110
102
|
</Flex>
|
111
103
|
</ListItem>
|
112
104
|
</div>
|
@@ -21,7 +21,6 @@ type DropdownTriggerProps = {
|
|
21
21
|
children?: React.ReactChild[] | React.ReactChild;
|
22
22
|
className?: string;
|
23
23
|
customDisplay?: React.ReactChild[] | React.ReactChild;
|
24
|
-
dark?: boolean;
|
25
24
|
data?: { [key: string]: string };
|
26
25
|
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
27
26
|
id?: string;
|
@@ -31,10 +30,9 @@ type DropdownTriggerProps = {
|
|
31
30
|
const DropdownTrigger = (props: DropdownTriggerProps) => {
|
32
31
|
const {
|
33
32
|
aria = {},
|
34
|
-
children,
|
35
33
|
className,
|
34
|
+
children,
|
36
35
|
customDisplay,
|
37
|
-
dark = false,
|
38
36
|
data = {},
|
39
37
|
htmlOptions = {},
|
40
38
|
id,
|
@@ -43,17 +41,15 @@ const DropdownTrigger = (props: DropdownTriggerProps) => {
|
|
43
41
|
|
44
42
|
const {
|
45
43
|
autocomplete,
|
44
|
+
handleWrapperClick,
|
45
|
+
selected,
|
46
46
|
filterItem,
|
47
47
|
handleChange,
|
48
|
-
|
49
|
-
inputRef,
|
50
|
-
inputWrapperRef,
|
48
|
+
toggleDropdown,
|
51
49
|
isDropDownClosed,
|
50
|
+
inputRef,
|
52
51
|
isInputFocused,
|
53
|
-
selected,
|
54
52
|
setIsInputFocused,
|
55
|
-
toggleDropdown,
|
56
|
-
triggerRef,
|
57
53
|
} = useContext(DropdownContext);
|
58
54
|
|
59
55
|
const handleKeyDown = useHandleOnKeyDown();
|
@@ -67,11 +63,9 @@ const DropdownTrigger = (props: DropdownTriggerProps) => {
|
|
67
63
|
className
|
68
64
|
);
|
69
65
|
|
70
|
-
const triggerWrapperClasses =
|
71
|
-
"
|
72
|
-
|
73
|
-
!autocomplete && "select_only"
|
74
|
-
);
|
66
|
+
const triggerWrapperClasses = `dropdown_trigger_wrapper ${
|
67
|
+
isInputFocused && "dropdown_trigger_wrapper_focus"
|
68
|
+
} ${!autocomplete && "dropdown_trigger_wrapper_select_only"}`;
|
75
69
|
|
76
70
|
const customDisplayPlaceholder = selected.label ? (
|
77
71
|
<b>{selected.label}</b>
|
@@ -98,91 +92,79 @@ const DropdownTrigger = (props: DropdownTriggerProps) => {
|
|
98
92
|
className={classes}
|
99
93
|
id={id}
|
100
94
|
>
|
101
|
-
{
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
>
|
130
|
-
<FlexItem>
|
95
|
+
{children ? (
|
96
|
+
<div
|
97
|
+
onClick={() => toggleDropdown()}
|
98
|
+
onKeyDown= {handleKeyDown}
|
99
|
+
style={{ display: "inline-block" }}
|
100
|
+
tabIndex= {0}
|
101
|
+
>
|
102
|
+
{children}
|
103
|
+
</div>
|
104
|
+
) : (
|
105
|
+
<>
|
106
|
+
<Flex
|
107
|
+
align="center"
|
108
|
+
borderRadius="lg"
|
109
|
+
className={triggerWrapperClasses}
|
110
|
+
cursor={`${autocomplete ? "text" : "pointer"}`}
|
111
|
+
htmlOptions={{
|
112
|
+
onClick: () => handleWrapperClick(),
|
113
|
+
onKeyDown: handleKeyDown,
|
114
|
+
tabIndex: "0",
|
115
|
+
}}
|
116
|
+
justify="between"
|
117
|
+
paddingX="sm"
|
118
|
+
paddingY="xs"
|
119
|
+
>
|
120
|
+
<FlexItem>
|
121
|
+
<Flex align="center">
|
122
|
+
{customDisplay ? (
|
131
123
|
<Flex align="center">
|
132
|
-
{customDisplay
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
paddingLeft={`${selected.label ? "xs" : "none"}`}
|
137
|
-
>
|
138
|
-
{customDisplayPlaceholder}
|
139
|
-
</Body>
|
140
|
-
</Flex>
|
141
|
-
) : (
|
142
|
-
<Body dark={dark}
|
143
|
-
text={defaultDisplayPlaceholder}
|
144
|
-
/>
|
145
|
-
)}
|
146
|
-
{autocomplete && (
|
147
|
-
<input
|
148
|
-
className="dropdown_input"
|
149
|
-
onChange={handleChange}
|
150
|
-
onClick={() => toggleDropdown()}
|
151
|
-
onFocus={() => setIsInputFocused(true)}
|
152
|
-
onKeyDown={handleKeyDown}
|
153
|
-
placeholder={
|
154
|
-
selected.label
|
155
|
-
? ""
|
156
|
-
: placeholder
|
157
|
-
? placeholder
|
158
|
-
: "Select..."
|
159
|
-
}
|
160
|
-
ref={inputRef}
|
161
|
-
value={filterItem}
|
162
|
-
/>
|
163
|
-
)}
|
124
|
+
{customDisplay}
|
125
|
+
<Body paddingLeft={`${selected.label ? "xs" : "none"}`}>
|
126
|
+
{customDisplayPlaceholder}
|
127
|
+
</Body>
|
164
128
|
</Flex>
|
165
|
-
|
166
|
-
<Body
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
}
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
129
|
+
) : (
|
130
|
+
<Body text={defaultDisplayPlaceholder} />
|
131
|
+
)}
|
132
|
+
{autocomplete && (
|
133
|
+
<input
|
134
|
+
className="dropdown_input"
|
135
|
+
onChange={handleChange}
|
136
|
+
onClick={() => toggleDropdown()}
|
137
|
+
onFocus={() => setIsInputFocused(true)}
|
138
|
+
onKeyDown={handleKeyDown}
|
139
|
+
placeholder={
|
140
|
+
selected.label
|
141
|
+
? ""
|
142
|
+
: placeholder
|
143
|
+
? placeholder
|
144
|
+
: "Select..."
|
145
|
+
}
|
146
|
+
ref={inputRef}
|
147
|
+
value={filterItem}
|
148
|
+
/>
|
149
|
+
)}
|
181
150
|
</Flex>
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
151
|
+
</FlexItem>
|
152
|
+
<Body
|
153
|
+
display="flex"
|
154
|
+
htmlOptions={{
|
155
|
+
onClick: (e: Event) => {e.stopPropagation();handleWrapperClick()}
|
156
|
+
}}
|
157
|
+
key={`${isDropDownClosed ? "chevron-down" : "chevron-up"}`}
|
158
|
+
>
|
159
|
+
<Icon
|
160
|
+
cursor="pointer"
|
161
|
+
icon={`${isDropDownClosed ? "chevron-down" : "chevron-up"}`}
|
162
|
+
size="sm"
|
163
|
+
/>
|
164
|
+
</Body>
|
165
|
+
</Flex>
|
166
|
+
</>
|
167
|
+
)}
|
186
168
|
</div>
|
187
169
|
);
|
188
170
|
};
|
@@ -4,12 +4,11 @@ import DropdownContainer from "../subcomponents/DropdownContainer";
|
|
4
4
|
|
5
5
|
type PrepareComponentsProps = {
|
6
6
|
children: React.ReactChild[] | React.ReactChild;
|
7
|
-
container: React.ReactChild;
|
8
|
-
dark?: boolean;
|
9
|
-
hasContainerSubcomponent: boolean;
|
10
7
|
hasTriggerSubcomponent: boolean;
|
11
|
-
|
8
|
+
hasContainerSubcomponent: boolean;
|
12
9
|
trigger: React.ReactChild;
|
10
|
+
container: React.ReactChild;
|
11
|
+
otherChildren: React.ReactChild[];
|
13
12
|
};
|
14
13
|
|
15
14
|
export const separateChildComponents = (children: React.ReactChild[] | React.ReactChild | ReactElement[]) => {
|
@@ -37,20 +36,19 @@ export const prepareSubcomponents = ({
|
|
37
36
|
trigger,
|
38
37
|
container,
|
39
38
|
otherChildren,
|
40
|
-
dark
|
41
39
|
}: PrepareComponentsProps) => {
|
42
40
|
const componentsToRender = [];
|
43
41
|
|
44
42
|
if (!hasTriggerSubcomponent && !hasContainerSubcomponent) {
|
45
|
-
componentsToRender.push(<DropdownTrigger
|
46
|
-
componentsToRender.push(<DropdownContainer
|
43
|
+
componentsToRender.push(<DropdownTrigger />);
|
44
|
+
componentsToRender.push(<DropdownContainer>{children}</DropdownContainer>);
|
47
45
|
} else if (!hasTriggerSubcomponent && hasContainerSubcomponent) {
|
48
|
-
componentsToRender.push(<DropdownTrigger
|
46
|
+
componentsToRender.push(<DropdownTrigger />);
|
49
47
|
componentsToRender.push(children);
|
50
48
|
} else if (hasTriggerSubcomponent && !hasContainerSubcomponent) {
|
51
49
|
componentsToRender.push(trigger);
|
52
50
|
componentsToRender.push(
|
53
|
-
<DropdownContainer
|
51
|
+
<DropdownContainer>{otherChildren}</DropdownContainer>
|
54
52
|
);
|
55
53
|
} else {
|
56
54
|
componentsToRender.push(trigger);
|