playbook_ui 13.24.0.pre.alpha.PBNTR261NewKitDropdown2681 β 13.24.0.pre.alpha.PLAY998backgroundkitremoveemptyinlinline2666
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/_playbook.scss +0 -2
- data/app/pb_kits/playbook/index.js +0 -1
- data/app/pb_kits/playbook/pb_background/_background.tsx +7 -5
- data/app/pb_kits/playbook/pb_list/_list_item.tsx +2 -2
- data/app/pb_kits/playbook/playbook-doc.js +0 -2
- data/dist/menu.yml +1 -5
- data/dist/playbook-rails.js +5 -5
- data/lib/playbook/version.rb +1 -1
- metadata +2 -17
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +0 -92
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +0 -152
- data/app/pb_kits/playbook/pb_dropdown/context/index.tsx +0 -5
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default.jsx +0 -53
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display.jsx +0 -104
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_options.jsx +0 -69
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx +0 -78
- data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +0 -9
- data/app/pb_kits/playbook/pb_dropdown/docs/index.js +0 -4
- data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +0 -17
- data/app/pb_kits/playbook/pb_dropdown/hooks/useDropdown.tsx +0 -17
- data/app/pb_kits/playbook/pb_dropdown/hooks/useHandleOnKeydown.tsx +0 -53
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownContainer.tsx +0 -95
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownOption.tsx +0 -91
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownTrigger.tsx +0 -118
data/lib/playbook/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: playbook_ui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 13.24.0.pre.alpha.
|
4
|
+
version: 13.24.0.pre.alpha.PLAY998backgroundkitremoveemptyinlinline2666
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Power UX
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-04-
|
12
|
+
date: 2024-04-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionpack
|
@@ -1027,21 +1027,6 @@ files:
|
|
1027
1027
|
- app/pb_kits/playbook/pb_distribution_bar/docs/index.js
|
1028
1028
|
- app/pb_kits/playbook/pb_docs/kit_example.html.erb
|
1029
1029
|
- app/pb_kits/playbook/pb_docs/kit_example.rb
|
1030
|
-
- app/pb_kits/playbook/pb_dropdown/_dropdown.scss
|
1031
|
-
- app/pb_kits/playbook/pb_dropdown/_dropdown.tsx
|
1032
|
-
- app/pb_kits/playbook/pb_dropdown/context/index.tsx
|
1033
|
-
- app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default.jsx
|
1034
|
-
- app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display.jsx
|
1035
|
-
- app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_options.jsx
|
1036
|
-
- app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx
|
1037
|
-
- app/pb_kits/playbook/pb_dropdown/docs/example.yml
|
1038
|
-
- app/pb_kits/playbook/pb_dropdown/docs/index.js
|
1039
|
-
- app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx
|
1040
|
-
- app/pb_kits/playbook/pb_dropdown/hooks/useDropdown.tsx
|
1041
|
-
- app/pb_kits/playbook/pb_dropdown/hooks/useHandleOnKeydown.tsx
|
1042
|
-
- app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownContainer.tsx
|
1043
|
-
- app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownOption.tsx
|
1044
|
-
- app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownTrigger.tsx
|
1045
1030
|
- app/pb_kits/playbook/pb_enhanced_element/element_observer.ts
|
1046
1031
|
- app/pb_kits/playbook/pb_enhanced_element/index.ts
|
1047
1032
|
- app/pb_kits/playbook/pb_file_upload/_file_upload.scss
|
@@ -1,92 +0,0 @@
|
|
1
|
-
@import "../tokens/colors";
|
2
|
-
@import "../tokens/spacing";
|
3
|
-
@import "../tokens/typography";
|
4
|
-
@import "../tokens/border_radius";
|
5
|
-
@import "../tokens/shadows";
|
6
|
-
@import "../tokens/positioning";
|
7
|
-
@import "../pb_body/body_mixins";
|
8
|
-
|
9
|
-
.pb_dropdown {
|
10
|
-
.dropdown_wrapper {
|
11
|
-
position: relative;
|
12
|
-
.dropdown_trigger_wrapper {
|
13
|
-
@include pb_body;
|
14
|
-
border: 1px solid $border_light;
|
15
|
-
background-color: $white;
|
16
|
-
&:hover {
|
17
|
-
background-color: rgba($focus_input_light, $opacity_5);
|
18
|
-
input {
|
19
|
-
background-color: rgba($focus_input_light, $opacity_5);
|
20
|
-
}
|
21
|
-
}
|
22
|
-
|
23
|
-
.dropdown_input {
|
24
|
-
@include pb_body;
|
25
|
-
border: unset;
|
26
|
-
border-radius: $border_rad_heavier;
|
27
|
-
padding: 0;
|
28
|
-
|
29
|
-
&:focus-visible {
|
30
|
-
outline: none;
|
31
|
-
}
|
32
|
-
}
|
33
|
-
&:focus {
|
34
|
-
box-shadow: 0px 0px 0 1px $primary;
|
35
|
-
outline: unset;
|
36
|
-
transition: box-shadow .15s ease-in-out;
|
37
|
-
}
|
38
|
-
}
|
39
|
-
|
40
|
-
.dropdown_trigger_wrapper_focus {
|
41
|
-
box-shadow: 0px 0px 0 1px $primary;
|
42
|
-
transition: box-shadow .10s ease-in-out;
|
43
|
-
}
|
44
|
-
|
45
|
-
.pb_dropdown_container {
|
46
|
-
background-color: $white;
|
47
|
-
overflow:hidden;
|
48
|
-
box-shadow: $shadow_deep;
|
49
|
-
border-radius: $border_rad_heavier;
|
50
|
-
border: 1px solid $border_light;
|
51
|
-
margin-top: $space_xs;
|
52
|
-
position: absolute;
|
53
|
-
z-index: $z_1;
|
54
|
-
width: 100%;
|
55
|
-
transition: opacity .25s ease-in-out;
|
56
|
-
|
57
|
-
.pb_dropdown_option {
|
58
|
-
:hover {
|
59
|
-
background-color: $border_light;
|
60
|
-
}
|
61
|
-
}
|
62
|
-
|
63
|
-
.dropdown_option_focused {
|
64
|
-
background-color: $border_light;
|
65
|
-
}
|
66
|
-
|
67
|
-
.dropdown_option {
|
68
|
-
width: 100%;
|
69
|
-
}
|
70
|
-
|
71
|
-
.dropdown_option_list {
|
72
|
-
border-bottom: 1px solid $border_light;
|
73
|
-
}
|
74
|
-
.dropdown_option_selected {
|
75
|
-
background-color: $primary;
|
76
|
-
[class^="pb_body"], [class^="pb_title_kit"] {
|
77
|
-
color: $white !important;
|
78
|
-
}
|
79
|
-
:hover {
|
80
|
-
background-color: unset;
|
81
|
-
}
|
82
|
-
}
|
83
|
-
}
|
84
|
-
.close {
|
85
|
-
display: none;
|
86
|
-
}
|
87
|
-
|
88
|
-
.open {
|
89
|
-
display: block;
|
90
|
-
}
|
91
|
-
}
|
92
|
-
}
|
@@ -1,152 +0,0 @@
|
|
1
|
-
import React, {useState, useRef, useEffect} from 'react'
|
2
|
-
import classnames from 'classnames'
|
3
|
-
import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
|
4
|
-
import { globalProps } from '../utilities/globalProps'
|
5
|
-
|
6
|
-
import Body from '../pb_body/_body'
|
7
|
-
|
8
|
-
import DropdownContainer from './subcomponents/DropdownContainer'
|
9
|
-
import DropdownOption from './subcomponents/DropdownOption'
|
10
|
-
import DropdownTrigger from './subcomponents/DropdownTrigger'
|
11
|
-
import DropdownContext from './context'
|
12
|
-
import useDropdown from './hooks/useDropdown'
|
13
|
-
import { GenericObject } from '../types'
|
14
|
-
|
15
|
-
type DropdownProps = {
|
16
|
-
aria?: { [key: string]: string },
|
17
|
-
className?: string,
|
18
|
-
data?: { [key: string]: string },
|
19
|
-
id?: string,
|
20
|
-
children?: React.ReactChild[] | React.ReactChild,
|
21
|
-
options?: GenericObject,
|
22
|
-
onSelect?: (arg:GenericObject) => null
|
23
|
-
}
|
24
|
-
|
25
|
-
const Dropdown = (props: DropdownProps) => {
|
26
|
-
const {
|
27
|
-
aria = {},
|
28
|
-
children,
|
29
|
-
className,
|
30
|
-
data = {},
|
31
|
-
id,
|
32
|
-
options,
|
33
|
-
onSelect
|
34
|
-
} = props
|
35
|
-
|
36
|
-
const ariaProps = buildAriaProps(aria)
|
37
|
-
const dataProps = buildDataProps(data)
|
38
|
-
const classes = classnames(buildCss('pb_dropdown'), globalProps(props), className)
|
39
|
-
|
40
|
-
const [ isDropDownClosed, setIsDropDownClosed, toggleDropdown ] = useDropdown()
|
41
|
-
|
42
|
-
const [filterItem, setFilterItem] = useState("");
|
43
|
-
const [selected, setSelected] = useState({});
|
44
|
-
const [isInputFocused, setIsInputFocused] = useState(false);
|
45
|
-
//state for keyboard events
|
46
|
-
const [focusedOptionIndex, setFocusedOptionIndex] = useState(-1);
|
47
|
-
|
48
|
-
const dropdownRef = useRef(null);
|
49
|
-
const inputRef = useRef(null);
|
50
|
-
|
51
|
-
// useEffect to handle clicks outside the dropdown
|
52
|
-
useEffect(() => {
|
53
|
-
const handleClickOutside = (event: any) => {
|
54
|
-
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
55
|
-
setIsDropDownClosed(true);
|
56
|
-
setIsInputFocused(false)
|
57
|
-
}
|
58
|
-
};
|
59
|
-
window.addEventListener("click", handleClickOutside);
|
60
|
-
return () => {
|
61
|
-
window.removeEventListener("click", handleClickOutside);
|
62
|
-
};
|
63
|
-
}, []);
|
64
|
-
|
65
|
-
|
66
|
-
const handleChange = (e: any) => {
|
67
|
-
setFilterItem(e.target.value);
|
68
|
-
setIsDropDownClosed(false);
|
69
|
-
};
|
70
|
-
|
71
|
-
const handleOptionClick = (selectedItem: GenericObject) => {
|
72
|
-
setSelected(selectedItem);
|
73
|
-
setFilterItem("");
|
74
|
-
setIsDropDownClosed(true);
|
75
|
-
onSelect(selectedItem);
|
76
|
-
};
|
77
|
-
|
78
|
-
|
79
|
-
const handleWrapperClick = () => {
|
80
|
-
inputRef.current.focus();
|
81
|
-
toggleDropdown();
|
82
|
-
};
|
83
|
-
|
84
|
-
const handleBackspace = () => {
|
85
|
-
setSelected({})
|
86
|
-
onSelect(null)
|
87
|
-
setFocusedOptionIndex(-1)
|
88
|
-
}
|
89
|
-
|
90
|
-
const filteredOptions = options?.filter((option: GenericObject) =>
|
91
|
-
option.label.toLowerCase().includes(filterItem.toLowerCase())
|
92
|
-
);
|
93
|
-
|
94
|
-
return (
|
95
|
-
<div
|
96
|
-
{...ariaProps}
|
97
|
-
{...dataProps}
|
98
|
-
className={classes}
|
99
|
-
id={id}
|
100
|
-
>
|
101
|
-
<DropdownContext.Provider
|
102
|
-
value={{
|
103
|
-
filteredOptions,
|
104
|
-
filterItem,
|
105
|
-
focusedOptionIndex,
|
106
|
-
handleBackspace,
|
107
|
-
handleChange,
|
108
|
-
handleOptionClick,
|
109
|
-
handleWrapperClick,
|
110
|
-
inputRef,
|
111
|
-
isInputFocused,
|
112
|
-
options,
|
113
|
-
selected,
|
114
|
-
setFocusedOptionIndex,
|
115
|
-
setIsInputFocused,
|
116
|
-
setSelected,
|
117
|
-
isDropDownClosed,
|
118
|
-
setIsDropDownClosed,
|
119
|
-
toggleDropdown
|
120
|
-
|
121
|
-
}}
|
122
|
-
>
|
123
|
-
<div className="dropdown_wrapper"
|
124
|
-
ref={dropdownRef}
|
125
|
-
>
|
126
|
-
{children ? (
|
127
|
-
children
|
128
|
-
) : (
|
129
|
-
<>
|
130
|
-
<DropdownTrigger />
|
131
|
-
<DropdownContainer>
|
132
|
-
{options && options?.map((option: GenericObject) => (
|
133
|
-
<Dropdown.Option key={option.id}
|
134
|
-
option={option}
|
135
|
-
>
|
136
|
-
<Body text={option.label}/>
|
137
|
-
</Dropdown.Option>
|
138
|
-
))}
|
139
|
-
</DropdownContainer>
|
140
|
-
</>
|
141
|
-
)}
|
142
|
-
</div>
|
143
|
-
</DropdownContext.Provider>
|
144
|
-
</div>
|
145
|
-
)
|
146
|
-
}
|
147
|
-
|
148
|
-
Dropdown.Option = DropdownOption;
|
149
|
-
Dropdown.Trigger = DropdownTrigger;
|
150
|
-
Dropdown.Container = DropdownContainer;
|
151
|
-
|
152
|
-
export default Dropdown
|
@@ -1,53 +0,0 @@
|
|
1
|
-
import React, { useState } from 'react'
|
2
|
-
import { Dropdown } from '../../'
|
3
|
-
|
4
|
-
const DropdownDefault = (props) => {
|
5
|
-
// eslint-disable-next-line no-unused-vars
|
6
|
-
const [selectedOption, setSelectedOption] = useState();
|
7
|
-
|
8
|
-
const options = [
|
9
|
-
{
|
10
|
-
label: "United States",
|
11
|
-
value: "United States",
|
12
|
-
areaCode: "+1",
|
13
|
-
icon: "πΊπΈ",
|
14
|
-
id: "United-states"
|
15
|
-
},
|
16
|
-
{
|
17
|
-
label: "Ukraine",
|
18
|
-
value: "Ukraine",
|
19
|
-
areaCode: "+380",
|
20
|
-
icon: "πΊπ¦",
|
21
|
-
id: "ukraine"
|
22
|
-
},
|
23
|
-
{
|
24
|
-
label: "Pakistan",
|
25
|
-
value: "Pakistan",
|
26
|
-
areaCode: "+92",
|
27
|
-
icon: "π΅π°",
|
28
|
-
id: "pakistan"
|
29
|
-
}
|
30
|
-
];
|
31
|
-
|
32
|
-
|
33
|
-
return (
|
34
|
-
<div>
|
35
|
-
<Dropdown
|
36
|
-
onSelect={(selectedItem) => setSelectedOption(selectedItem)}
|
37
|
-
options={options}
|
38
|
-
{...props}
|
39
|
-
>
|
40
|
-
<Dropdown.Trigger/>
|
41
|
-
<Dropdown.Container>
|
42
|
-
{options.map((option) => (
|
43
|
-
<Dropdown.Option key={option.id}
|
44
|
-
option={option}
|
45
|
-
/>
|
46
|
-
))}
|
47
|
-
</Dropdown.Container>
|
48
|
-
</Dropdown>
|
49
|
-
</div>
|
50
|
-
)
|
51
|
-
}
|
52
|
-
|
53
|
-
export default DropdownDefault
|
@@ -1,104 +0,0 @@
|
|
1
|
-
import React, { useState } from 'react'
|
2
|
-
import { Dropdown, User, FlexItem, Badge, Avatar } from '../../'
|
3
|
-
|
4
|
-
const DropdownWithCustomDisplay = (props) => {
|
5
|
-
const [selectedOption, setSelectedOption] = useState();
|
6
|
-
|
7
|
-
const options = [
|
8
|
-
{
|
9
|
-
label: "Jasper Furniss",
|
10
|
-
value: "Jasper Furniss",
|
11
|
-
territory: "PHL",
|
12
|
-
title: "Senior UX Engineer",
|
13
|
-
id: "jasper-furniss",
|
14
|
-
status: "Offline"
|
15
|
-
},
|
16
|
-
{
|
17
|
-
label: "Ramon Ruiz",
|
18
|
-
value: "Ramon Ruiz",
|
19
|
-
territory: "PHL",
|
20
|
-
title: "Senior UX Desinger",
|
21
|
-
id: "ramon-ruiz",
|
22
|
-
status: "Away"
|
23
|
-
},
|
24
|
-
{
|
25
|
-
label: "Jason Cypret",
|
26
|
-
value: "Jason Cypret",
|
27
|
-
territory: "PHL",
|
28
|
-
title: "VP of User Experience",
|
29
|
-
id: "jason-cypret",
|
30
|
-
status: "Online"
|
31
|
-
},
|
32
|
-
{
|
33
|
-
label: "Courtney Long",
|
34
|
-
value: "Courtney Long",
|
35
|
-
territory: "PHL",
|
36
|
-
title: "UX Design Mentor",
|
37
|
-
id: "courtney-long",
|
38
|
-
status: "Online"
|
39
|
-
}
|
40
|
-
];
|
41
|
-
|
42
|
-
const customDisplay = () => {
|
43
|
-
return (
|
44
|
-
<>
|
45
|
-
{
|
46
|
-
selectedOption && (
|
47
|
-
<Avatar
|
48
|
-
name={selectedOption.label}
|
49
|
-
size="sm"
|
50
|
-
/>
|
51
|
-
)
|
52
|
-
}
|
53
|
-
</>
|
54
|
-
)
|
55
|
-
};
|
56
|
-
|
57
|
-
|
58
|
-
return (
|
59
|
-
<div>
|
60
|
-
<Dropdown
|
61
|
-
onSelect={(selectedItem) => setSelectedOption(selectedItem)}
|
62
|
-
options={options}
|
63
|
-
{...props}
|
64
|
-
>
|
65
|
-
<Dropdown.Trigger customDisplay={customDisplay()}/>
|
66
|
-
<Dropdown.Container>
|
67
|
-
{options.map((option) => (
|
68
|
-
<Dropdown.Option key={option.id}
|
69
|
-
option={option}
|
70
|
-
>
|
71
|
-
<>
|
72
|
-
<FlexItem>
|
73
|
-
<User
|
74
|
-
align="left"
|
75
|
-
avatar
|
76
|
-
name={option.label}
|
77
|
-
orientation="horizontal"
|
78
|
-
territory={option.territory}
|
79
|
-
title={option.title}
|
80
|
-
/>
|
81
|
-
</FlexItem>
|
82
|
-
<FlexItem>
|
83
|
-
<Badge
|
84
|
-
rounded
|
85
|
-
text={option.status}
|
86
|
-
variant={`${
|
87
|
-
option.status === "Offline"
|
88
|
-
? "neutral"
|
89
|
-
: option.status === "Online"
|
90
|
-
? "success"
|
91
|
-
: "warning"
|
92
|
-
}`}
|
93
|
-
/>
|
94
|
-
</FlexItem>
|
95
|
-
</>
|
96
|
-
</Dropdown.Option>
|
97
|
-
))}
|
98
|
-
</Dropdown.Container>
|
99
|
-
</Dropdown>
|
100
|
-
</div>
|
101
|
-
)
|
102
|
-
}
|
103
|
-
|
104
|
-
export default DropdownWithCustomDisplay
|
@@ -1,69 +0,0 @@
|
|
1
|
-
import React, { useState } from 'react'
|
2
|
-
import { Dropdown, Icon, Body, FlexItem, Flex } from '../..'
|
3
|
-
|
4
|
-
const DropdownWithCustomOptions = (props) => {
|
5
|
-
// eslint-disable-next-line no-unused-vars
|
6
|
-
const [selectedOption, setSelectedOption] = useState();
|
7
|
-
|
8
|
-
const options = [
|
9
|
-
{
|
10
|
-
label: "United States",
|
11
|
-
value: "United States",
|
12
|
-
areaCode: "+1",
|
13
|
-
icon: "πΊπΈ",
|
14
|
-
id: "United-states"
|
15
|
-
},
|
16
|
-
{
|
17
|
-
label: "Ukraine",
|
18
|
-
value: "Ukraine",
|
19
|
-
areaCode: "+380",
|
20
|
-
icon: "πΊπ¦",
|
21
|
-
id: "ukraine"
|
22
|
-
},
|
23
|
-
{
|
24
|
-
label: "Pakistan",
|
25
|
-
value: "Pakistan",
|
26
|
-
areaCode: "+92",
|
27
|
-
icon: "π΅π°",
|
28
|
-
id: "pakistan"
|
29
|
-
}
|
30
|
-
];
|
31
|
-
|
32
|
-
|
33
|
-
return (
|
34
|
-
<div>
|
35
|
-
<Dropdown
|
36
|
-
onSelect={(selectedItem) => setSelectedOption(selectedItem)}
|
37
|
-
options={options}
|
38
|
-
{...props}
|
39
|
-
>
|
40
|
-
<Dropdown.Trigger/>
|
41
|
-
<Dropdown.Container>
|
42
|
-
{options.map((option) => (
|
43
|
-
<Dropdown.Option key={option.id}
|
44
|
-
option={option}
|
45
|
-
>
|
46
|
-
<>
|
47
|
-
<FlexItem>
|
48
|
-
<Flex>
|
49
|
-
<Icon icon={option.icon}
|
50
|
-
paddingRight="xs"
|
51
|
-
/>
|
52
|
-
<Body text={option.label} />
|
53
|
-
</Flex>
|
54
|
-
</FlexItem>
|
55
|
-
<FlexItem>
|
56
|
-
<Body color="light"
|
57
|
-
text={option.areaCode}
|
58
|
-
/>
|
59
|
-
</FlexItem>
|
60
|
-
</>
|
61
|
-
</Dropdown.Option>
|
62
|
-
))}
|
63
|
-
</Dropdown.Container>
|
64
|
-
</Dropdown>
|
65
|
-
</div>
|
66
|
-
)
|
67
|
-
}
|
68
|
-
|
69
|
-
export default DropdownWithCustomOptions
|
@@ -1,78 +0,0 @@
|
|
1
|
-
import React, { useState } from 'react'
|
2
|
-
import { Dropdown, Icon, Body, FlexItem, Flex, IconCircle } from '../..'
|
3
|
-
|
4
|
-
const DropdownWithCustomTrigger = (props) => {
|
5
|
-
|
6
|
-
const [selectedOption, setSelectedOption] = useState();
|
7
|
-
|
8
|
-
const options = [
|
9
|
-
{
|
10
|
-
label: "United States",
|
11
|
-
value: "United States",
|
12
|
-
areaCode: "+1",
|
13
|
-
icon: "πΊπΈ",
|
14
|
-
id: "United-states"
|
15
|
-
},
|
16
|
-
{
|
17
|
-
label: "Ukraine",
|
18
|
-
value: "Ukraine",
|
19
|
-
areaCode: "+380",
|
20
|
-
icon: "πΊπ¦",
|
21
|
-
id: "ukraine"
|
22
|
-
},
|
23
|
-
{
|
24
|
-
label: "Pakistan",
|
25
|
-
value: "Pakistan",
|
26
|
-
areaCode: "+92",
|
27
|
-
icon: "π΅π°",
|
28
|
-
id: "pakistan"
|
29
|
-
}
|
30
|
-
];
|
31
|
-
|
32
|
-
|
33
|
-
return (
|
34
|
-
<div>
|
35
|
-
<Dropdown
|
36
|
-
onSelect={(selectedItem) => setSelectedOption(selectedItem)}
|
37
|
-
options={options}
|
38
|
-
{...props}
|
39
|
-
>
|
40
|
-
<Dropdown.Trigger>
|
41
|
-
<div key={selectedOption ? selectedOption.icon : "flag"}>
|
42
|
-
<IconCircle
|
43
|
-
cursor="pointer"
|
44
|
-
icon={selectedOption ? selectedOption.icon : "flag"}
|
45
|
-
variant="royal"
|
46
|
-
/>
|
47
|
-
</div>
|
48
|
-
</Dropdown.Trigger>
|
49
|
-
|
50
|
-
<Dropdown.Container>
|
51
|
-
{options.map((option) => (
|
52
|
-
<Dropdown.Option key={option.id}
|
53
|
-
option={option}
|
54
|
-
>
|
55
|
-
<>
|
56
|
-
<FlexItem>
|
57
|
-
<Flex>
|
58
|
-
<Icon icon={option.icon}
|
59
|
-
paddingRight="xs"
|
60
|
-
/>
|
61
|
-
<Body text={option.label} />
|
62
|
-
</Flex>
|
63
|
-
</FlexItem>
|
64
|
-
<FlexItem>
|
65
|
-
<Body color="light"
|
66
|
-
text={option.areaCode}
|
67
|
-
/>
|
68
|
-
</FlexItem>
|
69
|
-
</>
|
70
|
-
</Dropdown.Option>
|
71
|
-
))}
|
72
|
-
</Dropdown.Container>
|
73
|
-
</Dropdown>
|
74
|
-
</div>
|
75
|
-
)
|
76
|
-
}
|
77
|
-
|
78
|
-
export default DropdownWithCustomTrigger
|
@@ -1,4 +0,0 @@
|
|
1
|
-
export { default as DropdownDefault } from './_dropdown_default.jsx'
|
2
|
-
export { default as DropdownWithCustomDisplay } from './_dropdown_with_custom_display.jsx'
|
3
|
-
export { default as DropdownWithCustomOptions } from './_dropdown_with_custom_options.jsx'
|
4
|
-
export { default as DropdownWithCustomTrigger } from './_dropdown_with_custom_trigger.jsx'
|
@@ -1,17 +0,0 @@
|
|
1
|
-
import { renderKit } from '../utilities/test-utils'
|
2
|
-
|
3
|
-
import { Dropdown } from '../'
|
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
|
-
*/
|
9
|
-
|
10
|
-
test('generated scaffold test - update me', () => {
|
11
|
-
const props = {
|
12
|
-
data: { testid: 'default' }
|
13
|
-
}
|
14
|
-
|
15
|
-
const kit = renderKit(Dropdown , props)
|
16
|
-
expect(kit).toBeInTheDocument()
|
17
|
-
})
|
@@ -1,17 +0,0 @@
|
|
1
|
-
import {useState} from 'react';
|
2
|
-
|
3
|
-
|
4
|
-
const useDropdown = (initial=true) => {
|
5
|
-
|
6
|
-
const [isDropDownClosed, setIsDropDownClosed] = useState(initial);
|
7
|
-
|
8
|
-
const toggleDropdown = () => setIsDropDownClosed(!isDropDownClosed);
|
9
|
-
|
10
|
-
return [
|
11
|
-
isDropDownClosed,
|
12
|
-
setIsDropDownClosed as any,
|
13
|
-
toggleDropdown
|
14
|
-
]
|
15
|
-
}
|
16
|
-
|
17
|
-
export default useDropdown
|