playbook_ui 14.18.0.pre.alpha.play2149overlaykitdynamicbug7619 → 14.18.0.pre.alpha.revert4567revert4553PLAY2056ATcolbordercolors7469
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/pb_advanced_table/docs/_advanced_table_beta.md +6 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/{_advanced_table_selectable_rows_no_subrows_react.jsx → _advanced_table_selectable_rows_no_subrows.jsx} +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_no_subrows_rails.md +1 -5
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_rails.md +2 -3
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +5 -4
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/index.js +11 -228
- data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +1 -9
- data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +3 -0
- data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +2 -1
- data/app/pb_kits/playbook/pb_card/card.html.erb +1 -1
- data/app/pb_kits/playbook/pb_card/card.rb +0 -12
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_error.html.erb +2 -2
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones.html.erb +1 -22
- data/app/pb_kits/playbook/pb_draggable/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_draggable/docs/index.js +1 -2
- data/app/pb_kits/playbook/pb_draggable/draggable_container.rb +1 -11
- data/app/pb_kits/playbook/pb_draggable/draggable_item.rb +1 -11
- data/app/pb_kits/playbook/pb_draggable/index.js +2 -4
- data/app/pb_kits/playbook/pb_draggable/subcomponents/DraggableItem.tsx +5 -33
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +0 -5
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +16 -5
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_error.html.erb +2 -5
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete.jsx +64 -17
- data/app/pb_kits/playbook/pb_dropdown/docs/{_dropdown_with_autocomplete_with_subcomponents.jsx → _dropdown_with_autocomplete_and_custom_display.jsx} +25 -11
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete_and_custom_display.md +1 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx +79 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +4 -7
- data/app/pb_kits/playbook/pb_dropdown/docs/index.js +2 -2
- data/app/pb_kits/playbook/pb_dropdown/dropdown.html.erb +2 -2
- data/app/pb_kits/playbook/pb_dropdown/dropdown.rb +0 -4
- data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +1 -45
- data/app/pb_kits/playbook/pb_dropdown/dropdown_container.html.erb +0 -10
- data/app/pb_kits/playbook/pb_dropdown/dropdown_container.rb +0 -3
- data/app/pb_kits/playbook/pb_dropdown/dropdown_trigger.html.erb +2 -12
- data/app/pb_kits/playbook/pb_dropdown/dropdown_trigger.rb +1 -3
- data/app/pb_kits/playbook/pb_dropdown/index.js +0 -57
- data/app/pb_kits/playbook/pb_dropdown/keyboard_accessibility.js +0 -26
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownContainer.tsx +2 -1
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownTrigger.tsx +4 -4
- data/app/pb_kits/playbook/pb_form_group/_error_state_mixin.scss +18 -22
- data/app/pb_kits/playbook/pb_overlay/_overlay.scss +1 -2
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional.jsx +1 -1
- data/app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_token.tsx +4 -5
- data/app/pb_kits/playbook/pb_select/_select.scss +0 -10
- data/app/pb_kits/playbook/pb_select/docs/_select_error.html.erb +1 -1
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_custom_click.jsx +7 -7
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_row.tsx +5 -5
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_error.html.erb +1 -1
- data/app/pb_kits/playbook/pb_textarea/docs/_textarea_error.html.erb +1 -5
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.html.erb +1 -8
- data/dist/chunks/{_typeahead-Bc1SPP0-.js → _typeahead-D8CsVBZO.js} +2 -2
- data/dist/chunks/_weekday_stacked-D3oLTSkH.js +45 -0
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +1 -1
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +13 -25
- data/app/pb_kits/playbook/pb_advanced_table/flat_advanced_table.js +0 -106
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones_line.html.erb +0 -55
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones_line_rails.md +0 -5
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones_rails.md +0 -5
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_event_listeners.jsx +0 -59
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_event_listeners_react.md +0 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete.html.erb +0 -28
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete_with_subcomponents.html.erb +0 -58
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete_with_subcomponents.md +0 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_external_control.md +0 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_search.jsx +0 -61
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_search.md +0 -2
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_search_rails.html.erb +0 -52
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_search_rails.md +0 -2
- data/dist/chunks/_weekday_stacked-DDrCiip0.js +0 -45
- /data/app/pb_kits/playbook/pb_advanced_table/docs/{_advanced_table_selectable_rows_rails.html.erb → _advanced_table_selectable_rows.html.erb} +0 -0
- /data/app/pb_kits/playbook/pb_advanced_table/docs/{_advanced_table_selectable_rows_no_subrows_rails.html.erb → _advanced_table_selectable_rows_no_subrows.html.erb} +0 -0
- /data/app/pb_kits/playbook/pb_advanced_table/docs/{_advanced_table_selectable_rows.md → _advanced_table_selectable_rows_react.md} +0 -0
- /data/app/pb_kits/playbook/pb_draggable/docs/{_draggable_drop_zones_line_react.md → _draggable_drop_zones_line.md} +0 -0
- /data/app/pb_kits/playbook/pb_draggable/docs/{_draggable_event_listeners_rails.md → _draggable_event_listeners.md} +0 -0
@@ -8,7 +8,6 @@ import {
|
|
8
8
|
} from "../../utilities/props";
|
9
9
|
import { globalProps } from "../../utilities/globalProps";
|
10
10
|
import { DraggableContext } from "../context";
|
11
|
-
import { noop } from '../../utilities/object'
|
12
11
|
|
13
12
|
type DraggableItemProps = {
|
14
13
|
aria?: { [key: string]: string };
|
@@ -18,13 +17,6 @@ type DraggableItemProps = {
|
|
18
17
|
data?: { [key: string]: string };
|
19
18
|
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
20
19
|
id?: string;
|
21
|
-
onDrag?: () => void,
|
22
|
-
onDragEnd?: () => void,
|
23
|
-
onDragEnter?: () => void,
|
24
|
-
onDragLeave?: () => void,
|
25
|
-
onDragOver?: () => void,
|
26
|
-
onDragStart?: () => void,
|
27
|
-
onDrop?: () => void,
|
28
20
|
dragId?: string;
|
29
21
|
tag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'span' | 'div' | 'tr' | 'th' | 'td' | 'thead' | 'col' | 'tbody',
|
30
22
|
};
|
@@ -39,14 +31,7 @@ const DraggableItem = (props: DraggableItemProps) => {
|
|
39
31
|
htmlOptions = {},
|
40
32
|
id,
|
41
33
|
dragId,
|
42
|
-
tag="div"
|
43
|
-
onDrag = noop,
|
44
|
-
onDragEnd = noop,
|
45
|
-
onDragEnter = noop,
|
46
|
-
onDragLeave = noop,
|
47
|
-
onDragOver = noop,
|
48
|
-
onDragStart = noop,
|
49
|
-
onDrop = noop,
|
34
|
+
tag="div"
|
50
35
|
} = props;
|
51
36
|
|
52
37
|
const {
|
@@ -76,7 +61,7 @@ const DraggableItem = (props: DraggableItemProps) => {
|
|
76
61
|
);
|
77
62
|
|
78
63
|
// Enhanced drag start handler that preserves dimensions
|
79
|
-
const
|
64
|
+
const onDragStart = (e: React.DragEvent) => {
|
80
65
|
if (dropZone !== 'ghost' && itemRef.current) {
|
81
66
|
// Create a clone for the drag image
|
82
67
|
const clone = itemRef.current.cloneNode(true) as HTMLElement;
|
@@ -111,9 +96,6 @@ const DraggableItem = (props: DraggableItemProps) => {
|
|
111
96
|
|
112
97
|
// Call the original handler
|
113
98
|
handleDragStart(dragId, container);
|
114
|
-
|
115
|
-
// Custom event handler
|
116
|
-
onDragStart()
|
117
99
|
};
|
118
100
|
|
119
101
|
return (
|
@@ -125,19 +107,9 @@ const DraggableItem = (props: DraggableItemProps) => {
|
|
125
107
|
draggable
|
126
108
|
id={id}
|
127
109
|
key={dragId}
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
onDragEnd()
|
132
|
-
}}
|
133
|
-
onDragEnter={() => {
|
134
|
-
handleDragEnter(dragId, container)
|
135
|
-
onDragEnter()
|
136
|
-
}}
|
137
|
-
onDragLeave={onDragLeave}
|
138
|
-
onDragOver={onDragOver}
|
139
|
-
onDragStart={handleDragStartWithCustom}
|
140
|
-
onDrop={onDrop}
|
110
|
+
onDragEnd={() => handleDragEnd()}
|
111
|
+
onDragEnter={() => handleDragEnter(dragId, container)}
|
112
|
+
onDragStart={onDragStart}
|
141
113
|
ref={itemRef}
|
142
114
|
>
|
143
115
|
{children}
|
@@ -41,11 +41,6 @@
|
|
41
41
|
outline: unset;
|
42
42
|
transition: box-shadow 0.15s ease-in-out;
|
43
43
|
}
|
44
|
-
&:focus-within {
|
45
|
-
box-shadow: 0px 0px 0 1px $primary !important;
|
46
|
-
outline: unset;
|
47
|
-
transition: box-shadow 0.15s ease-in-out;
|
48
|
-
}
|
49
44
|
|
50
45
|
&[class*="_select_only"] {
|
51
46
|
box-shadow: inset 0 -11px 20px rgba($primary, 0.05);
|
@@ -36,6 +36,7 @@ type DropdownProps = {
|
|
36
36
|
onSelect?: (arg: GenericObject) => null;
|
37
37
|
options: GenericObject;
|
38
38
|
separators?: boolean;
|
39
|
+
triggerRef?: any;
|
39
40
|
variant?: "default" | "subtle";
|
40
41
|
};
|
41
42
|
|
@@ -64,6 +65,7 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
64
65
|
onSelect,
|
65
66
|
options,
|
66
67
|
separators = true,
|
68
|
+
triggerRef,
|
67
69
|
variant = "default",
|
68
70
|
} = props;
|
69
71
|
|
@@ -89,7 +91,7 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
89
91
|
const [focusedOptionIndex, setFocusedOptionIndex] = useState(-1);
|
90
92
|
|
91
93
|
const dropdownRef = useRef(null);
|
92
|
-
const inputRef = useRef
|
94
|
+
const inputRef = useRef(null);
|
93
95
|
const inputWrapperRef = useRef(null);
|
94
96
|
const dropdownContainerRef = useRef(null);
|
95
97
|
|
@@ -97,7 +99,15 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
97
99
|
separateChildComponents(children);
|
98
100
|
|
99
101
|
useEffect(() => {
|
100
|
-
|
102
|
+
// Set the parent element of the trigger to relative to allow for absolute positioning of the dropdown
|
103
|
+
//Only needed for when useDropdown hook used with external trigger
|
104
|
+
if (triggerRef?.current) {
|
105
|
+
const parentElement = triggerRef.current.parentNode;
|
106
|
+
if (parentElement) {
|
107
|
+
parentElement.style.position = 'relative';
|
108
|
+
}
|
109
|
+
}
|
110
|
+
// Handle clicks outside the dropdown
|
101
111
|
const handleClick = handleClickOutside({
|
102
112
|
inputWrapperRef,
|
103
113
|
dropdownContainerRef,
|
@@ -157,7 +167,7 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
157
167
|
};
|
158
168
|
|
159
169
|
const handleWrapperClick = () => {
|
160
|
-
autocomplete && inputRef
|
170
|
+
autocomplete && inputRef.current.focus();
|
161
171
|
toggleDropdown();
|
162
172
|
};
|
163
173
|
|
@@ -192,7 +202,7 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
192
202
|
{...htmlProps}
|
193
203
|
className={classes}
|
194
204
|
id={id}
|
195
|
-
style={{position: "relative"}}
|
205
|
+
style={triggerRef ? { position: "absolute" } : { position: "relative" }}
|
196
206
|
>
|
197
207
|
<DropdownContext.Provider
|
198
208
|
value={{
|
@@ -215,7 +225,8 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
215
225
|
setIsDropDownClosed,
|
216
226
|
setIsInputFocused,
|
217
227
|
setSelected,
|
218
|
-
toggleDropdown
|
228
|
+
toggleDropdown,
|
229
|
+
triggerRef
|
219
230
|
}}
|
220
231
|
>
|
221
232
|
{label &&
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%
|
1
|
+
<%
|
2
2
|
options = [
|
3
3
|
{ label: 'United States', value: 'United States', id: 'us' },
|
4
4
|
{ label: 'Canada', value: 'Canada', id: 'ca' },
|
@@ -6,7 +6,4 @@
|
|
6
6
|
]
|
7
7
|
%>
|
8
8
|
|
9
|
-
<%= pb_rails("dropdown", props: {
|
10
|
-
error: raw(pb_rails("icon", props: { icon: "warning" }) + " Please make a valid selection"),
|
11
|
-
options: options
|
12
|
-
}) %>
|
9
|
+
<%= pb_rails("dropdown", props: { error: "Please make a valid selection", options: options }) %>
|
@@ -1,39 +1,86 @@
|
|
1
1
|
import React from 'react'
|
2
2
|
|
3
3
|
import Dropdown from '../../pb_dropdown/_dropdown'
|
4
|
+
import Badge from '../../pb_badge/_badge'
|
5
|
+
import FlexItem from '../../pb_flex/_flex_item'
|
6
|
+
import User from '../../pb_user/_user'
|
4
7
|
|
5
8
|
const DropdownWithAutocomplete = (props) => {
|
6
9
|
|
7
10
|
const options = [
|
8
11
|
{
|
9
|
-
label: "
|
10
|
-
value: "
|
11
|
-
|
12
|
-
|
13
|
-
id: "
|
12
|
+
label: "Jasper Furniss",
|
13
|
+
value: "Jasper Furniss",
|
14
|
+
territory: "PHL",
|
15
|
+
title: "Lead UX Engineer",
|
16
|
+
id: "jasper-furniss",
|
17
|
+
status: "Offline"
|
14
18
|
},
|
15
19
|
{
|
16
|
-
label: "
|
17
|
-
value: "
|
18
|
-
|
19
|
-
|
20
|
-
id: "
|
20
|
+
label: "Ramon Ruiz",
|
21
|
+
value: "Ramon Ruiz",
|
22
|
+
territory: "PHL",
|
23
|
+
title: "Senior UX Designer",
|
24
|
+
id: "ramon-ruiz",
|
25
|
+
status: "Away"
|
21
26
|
},
|
22
27
|
{
|
23
|
-
label: "
|
24
|
-
value: "
|
25
|
-
|
26
|
-
|
27
|
-
id: "
|
28
|
+
label: "Carlos Lima",
|
29
|
+
value: "Carlos Lima",
|
30
|
+
territory: "PHL",
|
31
|
+
title: "Nitro Developer",
|
32
|
+
id: "carlos-lima",
|
33
|
+
status: "Online"
|
34
|
+
},
|
35
|
+
{
|
36
|
+
label: "Courtney Long",
|
37
|
+
value: "Courtney Long",
|
38
|
+
territory: "PHL",
|
39
|
+
title: "Lead UX Designer",
|
40
|
+
id: "courtney-long",
|
41
|
+
status: "Online"
|
28
42
|
}
|
29
|
-
]
|
43
|
+
];
|
44
|
+
|
30
45
|
|
31
46
|
return (
|
32
47
|
<div>
|
33
48
|
<Dropdown autocomplete
|
34
49
|
options={options}
|
35
50
|
{...props}
|
36
|
-
|
51
|
+
>
|
52
|
+
{options.map((option) => (
|
53
|
+
<Dropdown.Option key={option.id}
|
54
|
+
option={option}
|
55
|
+
>
|
56
|
+
<>
|
57
|
+
<FlexItem>
|
58
|
+
<User
|
59
|
+
align="left"
|
60
|
+
avatar
|
61
|
+
name={option.label}
|
62
|
+
orientation="horizontal"
|
63
|
+
territory={option.territory}
|
64
|
+
title={option.title}
|
65
|
+
/>
|
66
|
+
</FlexItem>
|
67
|
+
<FlexItem>
|
68
|
+
<Badge
|
69
|
+
rounded
|
70
|
+
text={option.status}
|
71
|
+
variant={`${
|
72
|
+
option.status === "Offline"
|
73
|
+
? "neutral"
|
74
|
+
: option.status === "Online"
|
75
|
+
? "success"
|
76
|
+
: "warning"
|
77
|
+
}`}
|
78
|
+
/>
|
79
|
+
</FlexItem>
|
80
|
+
</>
|
81
|
+
</Dropdown.Option>
|
82
|
+
))}
|
83
|
+
</Dropdown>
|
37
84
|
</div>
|
38
85
|
)
|
39
86
|
}
|
@@ -1,13 +1,15 @@
|
|
1
|
-
import React from 'react'
|
1
|
+
import React, { useState } from 'react'
|
2
2
|
|
3
|
-
import Dropdown from '
|
3
|
+
import Dropdown from '../../pb_dropdown/_dropdown'
|
4
4
|
import Badge from '../../pb_badge/_badge'
|
5
|
-
import Flex from '../../pb_flex/_flex'
|
6
5
|
import FlexItem from '../../pb_flex/_flex_item'
|
6
|
+
import Avatar from '../../pb_avatar/_avatar'
|
7
7
|
import User from '../../pb_user/_user'
|
8
8
|
|
9
9
|
|
10
|
-
const
|
10
|
+
const DropdownWithAutocompleteAndCustomDisplay = (props) => {
|
11
|
+
const [selectedOption, setSelectedOption] = useState();
|
12
|
+
|
11
13
|
const options = [
|
12
14
|
{
|
13
15
|
label: "Jasper Furniss",
|
@@ -43,21 +45,34 @@ const DropdownWithAutocompleteWithSubcomponents = (props) => {
|
|
43
45
|
}
|
44
46
|
];
|
45
47
|
|
48
|
+
const CustomDisplay = () => {
|
49
|
+
return (
|
50
|
+
<>
|
51
|
+
{
|
52
|
+
selectedOption && (
|
53
|
+
<Avatar
|
54
|
+
name={selectedOption.label}
|
55
|
+
size="xs"
|
56
|
+
/>
|
57
|
+
)
|
58
|
+
}
|
59
|
+
</>
|
60
|
+
)
|
61
|
+
};
|
46
62
|
|
47
63
|
return (
|
48
64
|
<div>
|
49
65
|
<Dropdown autocomplete
|
66
|
+
onSelect={(selectedItem) => setSelectedOption(selectedItem)}
|
50
67
|
options={options}
|
51
68
|
{...props}
|
52
69
|
>
|
70
|
+
<Dropdown.Trigger customDisplay={<CustomDisplay/>} />
|
53
71
|
{options.map((option) => (
|
54
72
|
<Dropdown.Option key={option.id}
|
55
73
|
option={option}
|
56
74
|
>
|
57
|
-
|
58
|
-
align="center"
|
59
|
-
justify="between"
|
60
|
-
>
|
75
|
+
<>
|
61
76
|
<FlexItem>
|
62
77
|
<User
|
63
78
|
align="left"
|
@@ -70,7 +85,6 @@ const DropdownWithAutocompleteWithSubcomponents = (props) => {
|
|
70
85
|
</FlexItem>
|
71
86
|
<FlexItem>
|
72
87
|
<Badge
|
73
|
-
dark
|
74
88
|
rounded
|
75
89
|
text={option.status}
|
76
90
|
variant={`${
|
@@ -82,7 +96,7 @@ const DropdownWithAutocompleteWithSubcomponents = (props) => {
|
|
82
96
|
}`}
|
83
97
|
/>
|
84
98
|
</FlexItem>
|
85
|
-
|
99
|
+
</>
|
86
100
|
</Dropdown.Option>
|
87
101
|
))}
|
88
102
|
</Dropdown>
|
@@ -90,4 +104,4 @@ const DropdownWithAutocompleteWithSubcomponents = (props) => {
|
|
90
104
|
)
|
91
105
|
}
|
92
106
|
|
93
|
-
export default
|
107
|
+
export default DropdownWithAutocompleteAndCustomDisplay
|
@@ -0,0 +1 @@
|
|
1
|
+
`autocomplete` prop can also be used in conjunction with the `customDisplay` prop.
|
@@ -0,0 +1,79 @@
|
|
1
|
+
import React, { useRef } from 'react'
|
2
|
+
|
3
|
+
import Dropdown from '../../pb_dropdown/_dropdown'
|
4
|
+
import useDropdown from '../../pb_dropdown/hooks/useDropdown'
|
5
|
+
import CircleIconButton from '../../pb_circle_icon_button/_circle_icon_button'
|
6
|
+
import FlexItem from '../../pb_flex/_flex_item'
|
7
|
+
import Icon from '../../pb_icon/_icon'
|
8
|
+
import Body from '../../pb_body/_body'
|
9
|
+
import Flex from '../../pb_flex/_flex'
|
10
|
+
|
11
|
+
const DropdownWithHook = (props) => {
|
12
|
+
const [isDropDownClosed, setIsDropdownClosed] = useDropdown(true);
|
13
|
+
const buttonRef = useRef(null);
|
14
|
+
|
15
|
+
const options = [
|
16
|
+
{
|
17
|
+
label: "United States",
|
18
|
+
value: "United States",
|
19
|
+
areaCode: "+1",
|
20
|
+
icon: "🇺🇸",
|
21
|
+
id: "United-states"
|
22
|
+
},
|
23
|
+
{
|
24
|
+
label: "Canada",
|
25
|
+
value: "Canada",
|
26
|
+
areaCode: "+1",
|
27
|
+
icon: "🇨🇦",
|
28
|
+
id: "canada"
|
29
|
+
},
|
30
|
+
{
|
31
|
+
label: "Pakistan",
|
32
|
+
value: "Pakistan",
|
33
|
+
areaCode: "+92",
|
34
|
+
icon: "🇵🇰",
|
35
|
+
id: "pakistan"
|
36
|
+
}
|
37
|
+
];
|
38
|
+
|
39
|
+
return (
|
40
|
+
<div>
|
41
|
+
<CircleIconButton
|
42
|
+
htmlOptions={{ref: buttonRef}}
|
43
|
+
icon={"flag"}
|
44
|
+
onClick={() => setIsDropdownClosed(!isDropDownClosed)}
|
45
|
+
variant="secondary"
|
46
|
+
/>
|
47
|
+
<Dropdown
|
48
|
+
isClosed={isDropDownClosed}
|
49
|
+
options={options}
|
50
|
+
triggerRef={buttonRef}
|
51
|
+
{...props}
|
52
|
+
>
|
53
|
+
{options.map((option) => (
|
54
|
+
<Dropdown.Option key={option.id}
|
55
|
+
option={option}
|
56
|
+
>
|
57
|
+
<>
|
58
|
+
<FlexItem>
|
59
|
+
<Flex paddingRight='md'>
|
60
|
+
<Icon icon={option.icon}
|
61
|
+
paddingRight="xs"
|
62
|
+
/>
|
63
|
+
<Body text={option.label} />
|
64
|
+
</Flex>
|
65
|
+
</FlexItem>
|
66
|
+
<FlexItem>
|
67
|
+
<Body color="light"
|
68
|
+
text={option.areaCode}
|
69
|
+
/>
|
70
|
+
</FlexItem>
|
71
|
+
</>
|
72
|
+
</Dropdown.Option>
|
73
|
+
))}
|
74
|
+
</Dropdown>
|
75
|
+
</div>
|
76
|
+
)
|
77
|
+
}
|
78
|
+
|
79
|
+
export default DropdownWithHook
|
@@ -1,15 +1,12 @@
|
|
1
1
|
examples:
|
2
2
|
rails:
|
3
3
|
- dropdown_default: Default
|
4
|
-
- dropdown_with_autocomplete: Autocomplete
|
5
4
|
- dropdown_subtle_variant: Subtle Variant
|
6
5
|
- dropdown_subcomponent_structure_rails: Subcomponent Structure
|
7
|
-
- dropdown_with_autocomplete_with_subcomponents: Autocomplete with Subcomponent Structure
|
8
6
|
- dropdown_with_label: With Label
|
9
7
|
- dropdown_with_custom_options_rails: Custom Options
|
10
8
|
- dropdown_with_custom_display_rails: Custom Display
|
11
9
|
- dropdown_with_custom_trigger_rails: Custom Trigger
|
12
|
-
- dropdown_with_search_rails: Custom Trigger Dropdown with Search
|
13
10
|
- dropdown_with_custom_padding: Custom Option Padding
|
14
11
|
- dropdown_error: Dropdown with Error
|
15
12
|
- dropdown_default_value: Default Value
|
@@ -18,20 +15,20 @@ examples:
|
|
18
15
|
|
19
16
|
react:
|
20
17
|
- dropdown_default: Default
|
21
|
-
- dropdown_with_autocomplete: Autocomplete
|
22
18
|
- dropdown_subtle_variant: Subtle Variant
|
23
19
|
- dropdown_subcomponent_structure: Subcomponent Structure
|
24
|
-
- dropdown_with_autocomplete_with_subcomponents: Autocomplete with Subcomponent Structure
|
25
20
|
- dropdown_with_label: With Label
|
26
21
|
- dropdown_with_custom_options: Custom Options
|
27
22
|
- dropdown_with_custom_display: Custom Display
|
28
23
|
- dropdown_with_custom_trigger: Custom Trigger
|
29
|
-
- dropdown_with_search: Custom Trigger Dropdown with Search
|
30
24
|
- dropdown_with_custom_padding: Custom Option Padding
|
31
25
|
- dropdown_error: Dropdown with Error
|
32
26
|
- dropdown_default_value: Default Value
|
33
27
|
- dropdown_blank_selection: Blank Selection
|
34
28
|
- dropdown_clear_selection: Clear Selection
|
35
29
|
- dropdown_separators_hidden: Separators Hidden
|
36
|
-
-
|
30
|
+
# - dropdown_with_autocomplete: Autocomplete
|
31
|
+
# - dropdown_with_autocomplete_and_custom_display: Autocomplete with Custom Display
|
32
|
+
# - dropdown_with_external_control: useDropdown Hook
|
33
|
+
# - dropdown_with_hook: useDropdown Hook with Any Trigger
|
37
34
|
|
@@ -3,10 +3,11 @@ export { default as DropdownWithCustomDisplay } from './_dropdown_with_custom_di
|
|
3
3
|
export { default as DropdownWithCustomOptions } from './_dropdown_with_custom_options.jsx'
|
4
4
|
export { default as DropdownWithCustomTrigger } from './_dropdown_with_custom_trigger.jsx'
|
5
5
|
export { default as DropdownWithAutocomplete } from './_dropdown_with_autocomplete.jsx'
|
6
|
-
export { default as
|
6
|
+
export { default as DropdownWithAutocompleteAndCustomDisplay } from './_dropdown_with_autocomplete_and_custom_display.jsx'
|
7
7
|
export { default as DropdownWithCustomPadding } from './_dropdown_with_custom_padding.jsx'
|
8
8
|
export { default as DropdownWithLabel } from './_dropdown_with_label.jsx'
|
9
9
|
export { default as DropdownWithExternalControl } from './_dropdown_with_external_control.jsx'
|
10
|
+
export { default as DropdownWithHook } from './_dropdown_with_hook.jsx'
|
10
11
|
export { default as DropdownSubcomponentStructure } from './_dropdown_subcomponent_structure.jsx'
|
11
12
|
export { default as DropdownError } from './_dropdown_error.jsx'
|
12
13
|
export { default as DropdownDefaultValue } from './_dropdown_default_value.jsx'
|
@@ -14,4 +15,3 @@ export { default as DropdownBlankSelection } from './_dropdown_blank_selection.j
|
|
14
15
|
export { default as DropdownClearSelection } from './_dropdown_clear_selection.jsx'
|
15
16
|
export { default as DropdownSubtleVariant } from './_dropdown_subtle_variant.jsx'
|
16
17
|
export { default as DropdownSeparatorsHidden } from './_dropdown_separators_hidden.jsx'
|
17
|
-
export {default as DropdownWithSearch} from './_dropdown_with_search.jsx'
|
@@ -14,8 +14,8 @@
|
|
14
14
|
<%= content.presence %>
|
15
15
|
<%= pb_rails("body", props: { status: "negative", text: object.error }) %>
|
16
16
|
<% else %>
|
17
|
-
<%= pb_rails("dropdown/dropdown_trigger"
|
18
|
-
<%= pb_rails("dropdown/dropdown_container"
|
17
|
+
<%= pb_rails("dropdown/dropdown_trigger") %>
|
18
|
+
<%= pb_rails("dropdown/dropdown_container") do %>
|
19
19
|
<% if options_with_blank.present? %>
|
20
20
|
<% options_with_blank.each do |option| %>
|
21
21
|
<%= pb_rails("dropdown/dropdown_option", props: {option: option}) %>
|
@@ -18,10 +18,6 @@ module Playbook
|
|
18
18
|
default: "default"
|
19
19
|
prop :separators, type: Playbook::Props::Boolean,
|
20
20
|
default: true
|
21
|
-
prop :autocomplete, type: Playbook::Props::Boolean,
|
22
|
-
default: false
|
23
|
-
prop :searchbar, type: Playbook::Props::Boolean,
|
24
|
-
default: false
|
25
21
|
|
26
22
|
def data
|
27
23
|
Hash(prop(:data)).merge(pb_dropdown: true)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import React from "react"
|
2
2
|
import { render, screen } from "../utilities/test-utils"
|
3
3
|
|
4
|
-
import { Dropdown, Icon
|
4
|
+
import { Dropdown, Icon } from 'playbook-ui'
|
5
5
|
|
6
6
|
|
7
7
|
const testId = 'dropdown'
|
@@ -219,48 +219,4 @@ test('show error message', () => {
|
|
219
219
|
|
220
220
|
const kit = screen.getByTestId(testId)
|
221
221
|
expect(kit).toHaveTextContent(errorMessage)
|
222
|
-
})
|
223
|
-
|
224
|
-
test("autocomplete prop to render input", () => {
|
225
|
-
render (
|
226
|
-
<Dropdown
|
227
|
-
autocomplete
|
228
|
-
data={{ testid: testId }}
|
229
|
-
options={options}
|
230
|
-
/>
|
231
|
-
)
|
232
|
-
|
233
|
-
const kit = screen.getByTestId(testId)
|
234
|
-
const input = kit.querySelector('.dropdown_input')
|
235
|
-
expect(input).toBeInTheDocument()
|
236
|
-
})
|
237
|
-
|
238
|
-
test("searchbar prop to render TextInput in container", () => {
|
239
|
-
render (
|
240
|
-
<Dropdown
|
241
|
-
data={{ testid: testId }}
|
242
|
-
options={options}
|
243
|
-
>
|
244
|
-
<Dropdown.Trigger>
|
245
|
-
<IconCircle
|
246
|
-
cursor="pointer"
|
247
|
-
icon="flag"
|
248
|
-
variant="royal"
|
249
|
-
/>
|
250
|
-
</Dropdown.Trigger>
|
251
|
-
<Dropdown.Container maxWidth="xs"
|
252
|
-
searchbar
|
253
|
-
>
|
254
|
-
{options.map((option) => (
|
255
|
-
<Dropdown.Option key={option.id}
|
256
|
-
option={option}
|
257
|
-
/>
|
258
|
-
))}
|
259
|
-
</Dropdown.Container>
|
260
|
-
</Dropdown>
|
261
|
-
)
|
262
|
-
|
263
|
-
const kit = screen.getByTestId(testId)
|
264
|
-
const searchbar = kit.querySelector('.pb_text_input_kit')
|
265
|
-
expect(searchbar).toBeInTheDocument()
|
266
222
|
})
|
@@ -1,14 +1,4 @@
|
|
1
1
|
<%= pb_content_tag do %>
|
2
|
-
<% if object.searchbar %>
|
3
|
-
<%= pb_rails("text_input", props: {padding_top:"xs", padding_x:"xs"}) do %>
|
4
|
-
<input
|
5
|
-
type="text"
|
6
|
-
placeholder="Search…"
|
7
|
-
data-dropdown-search
|
8
|
-
autocomplete="off"
|
9
|
-
/>
|
10
|
-
<% end %>
|
11
|
-
<% end %>
|
12
2
|
<%= pb_rails("list", props: {ordered: false, borderless: false}) do %>
|
13
3
|
<% if content.present? %>
|
14
4
|
<%= content.presence %>
|
@@ -8,7 +8,7 @@
|
|
8
8
|
align: "center",
|
9
9
|
border_radius:"lg",
|
10
10
|
classname: object.trigger_wrapper_classes,
|
11
|
-
cursor:
|
11
|
+
cursor: "pointer",
|
12
12
|
justify: "between",
|
13
13
|
padding_x:"sm",
|
14
14
|
padding_y:"xs",
|
@@ -24,17 +24,7 @@
|
|
24
24
|
<%= pb_rails("body", props: {text: object.default_display_placeholder, id: "dropdown_trigger_display"}) %>
|
25
25
|
<% end %>
|
26
26
|
<% else %>
|
27
|
-
|
28
|
-
<input
|
29
|
-
data-dropdown-autocomplete
|
30
|
-
class="dropdown_input"
|
31
|
-
type="text"
|
32
|
-
placeholder="<%= object.placeholder || 'Select…' %>"
|
33
|
-
autocomplete="off"
|
34
|
-
/>
|
35
|
-
<% else %>
|
36
|
-
<%= pb_rails("body", props: {text: object.default_display_placeholder, id: "dropdown_trigger_display"}) %>
|
37
|
-
<% end %>
|
27
|
+
<%= pb_rails("body", props: {text: object.default_display_placeholder, id: "dropdown_trigger_display"}) %>
|
38
28
|
<% end %>
|
39
29
|
<% end %>
|
40
30
|
<% end %>
|
@@ -9,8 +9,6 @@ module Playbook
|
|
9
9
|
default: ""
|
10
10
|
prop :placeholder, type: Playbook::Props::String
|
11
11
|
prop :custom_display
|
12
|
-
prop :autocomplete, type: Playbook::Props::Boolean,
|
13
|
-
default: false
|
14
12
|
|
15
13
|
def data
|
16
14
|
Hash(prop(:data)).merge(dropdown_trigger: true, dropdown_placeholder: default_display_placeholder)
|
@@ -25,7 +23,7 @@ module Playbook
|
|
25
23
|
end
|
26
24
|
|
27
25
|
def trigger_wrapper_classes
|
28
|
-
generate_classname("dropdown_trigger_wrapper",
|
26
|
+
generate_classname("dropdown_trigger_wrapper", "select_only")
|
29
27
|
end
|
30
28
|
end
|
31
29
|
end
|