playbook_ui 14.20.0.pre.rc.2 → 14.21.0.pre.alpha.PLAY2140upgraderailsdependency8110
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/Components/CustomCell.tsx +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/Components/RegularTableView.tsx +116 -49
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableActionBar.tsx +61 -35
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +37 -23
- data/app/pb_kits/playbook/pb_advanced_table/Context/AdvancedTableContext.tsx +58 -2
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableActions.ts +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +16 -4
- data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx +7 -3
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +48 -19
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +13 -3
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +16 -8
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb +16 -1
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +61 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta.md +6 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility_with_state.jsx +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility_with_state.md +3 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_no_subrows.html.erb +33 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_no_subrows.jsx +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pinned_rows.jsx +57 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pinned_rows_react.md +5 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_scrollbar_none.html.erb +33 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_scrollbar_none.jsx +53 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_actions_rails.html.erb +137 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_actions_rails.md +3 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_header_rails.html.erb +40 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_header_rails.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +8 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +3 -1
- data/app/pb_kits/playbook/pb_advanced_table/index.js +157 -12
- data/app/pb_kits/playbook/pb_advanced_table/table_action_bar.html.erb +23 -0
- data/app/pb_kits/playbook/pb_advanced_table/table_action_bar.rb +19 -0
- data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +4 -0
- data/app/pb_kits/playbook/pb_checkbox/checkbox.html.erb +4 -11
- data/app/pb_kits/playbook/pb_checkbox/checkbox.rb +10 -6
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_indeterminate.html.erb +2 -48
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_indeterminate_rails.md +1 -0
- data/app/pb_kits/playbook/pb_checkbox/index.js +56 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_quick_pick_date_display.html.erb +13 -0
- data/app/pb_kits/playbook/pb_draggable/context/index.tsx +17 -58
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +1 -1
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +86 -19
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_close_on_select.jsx +42 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_close_on_select.md +1 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default_rails.html.erb +31 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default_rails.md +5 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_multi_select.jsx +56 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_multi_select.md +3 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_multi_select_display.jsx +58 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_multi_select_display.md +3 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_multi_select_display_rails.html.erb +20 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_multi_select_display_rails.md +1 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_multi_select_rails.html.erb +19 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_multi_select_rails.md +3 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_multi_select_with_autocomplete.html.erb +20 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_multi_select_with_autocomplete.jsx +57 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_multi_select_with_autocomplete.md +1 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_multi_select_with_custom_options.html.erb +50 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_multi_select_with_custom_options.jsx +105 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_multi_select_with_default.html.erb +22 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_multi_select_with_default.jsx +67 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +13 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/index.js +6 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown.html.erb +3 -3
- data/app/pb_kits/playbook/pb_dropdown/dropdown.rb +16 -2
- data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +108 -2
- data/app/pb_kits/playbook/pb_dropdown/dropdown_trigger.html.erb +34 -13
- data/app/pb_kits/playbook/pb_dropdown/dropdown_trigger.rb +3 -1
- data/app/pb_kits/playbook/pb_dropdown/hooks/useHandleOnKeydown.tsx +0 -6
- data/app/pb_kits/playbook/pb_dropdown/index.js +357 -40
- data/app/pb_kits/playbook/pb_dropdown/keyboard_accessibility.js +39 -12
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownOption.tsx +26 -18
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownTrigger.tsx +96 -19
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/MultiSelectTriggerDisplay.tsx +58 -0
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with.html.erb +1 -0
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +1 -0
- data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +4 -0
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_exclude_countries.html.erb +4 -0
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_exclude_countries.jsx +15 -0
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_exclude_countries.md +1 -0
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_only_countries.jsx +1 -1
- data/app/pb_kits/playbook/pb_phone_number_input/docs/example.yml +4 -3
- data/app/pb_kits/playbook/pb_phone_number_input/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_phone_number_input/phone_number_input.rb +3 -0
- data/app/pb_kits/playbook/pb_popover/index.ts +9 -4
- data/app/pb_kits/playbook/pb_select/docs/_select_custom_select_subheaders.html.erb +12 -0
- data/app/pb_kits/playbook/pb_select/docs/_select_custom_select_subheaders.jsx +31 -0
- data/app/pb_kits/playbook/pb_select/docs/_select_custom_select_subheaders.md +1 -0
- data/app/pb_kits/playbook/pb_select/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_select/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_selectable_rows.html.erb +3 -51
- data/app/pb_kits/playbook/pb_table/styles/_mobile_collapse.scss +1 -1
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +73 -3
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_preserve_input.jsx +23 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_preserve_input.md +1 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/index.js +1 -0
- data/dist/chunks/_typeahead-CoOpeYom.js +22 -0
- data/dist/chunks/_weekday_stacked-B_jpa2Rz.js +45 -0
- data/dist/chunks/lib-D7Va7yqa.js +29 -0
- data/dist/chunks/{pb_form_validation-WWvUXPKD.js → pb_form_validation-DSkdRDMf.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +1 -1
- data/dist/playbook-doc.js +2 -2
- 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/kit_base.rb +3 -3
- data/lib/playbook/version.rb +2 -2
- metadata +48 -7
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default.html.erb +0 -10
- data/dist/chunks/_typeahead-B9-s4j4U.js +0 -22
- data/dist/chunks/_weekday_stacked-CvzpmXD5.js +0 -45
- data/dist/chunks/lib-B20MXZcW.js +0 -29
@@ -0,0 +1,19 @@
|
|
1
|
+
<%
|
2
|
+
options = [
|
3
|
+
{ label: 'United States', value: 'United States', id: 'us' },
|
4
|
+
{ label: 'Canada', value: 'Canada', id: 'ca' },
|
5
|
+
{ label: 'Pakistan', value: 'Pakistan', id: 'pk' },
|
6
|
+
{ label: 'India', value: 'India', id: 'in' },
|
7
|
+
{ label: 'United Kingdom', value: 'United Kingdom', id: 'uk' },
|
8
|
+
{ label: 'Australia', value: 'Australia', id: 'au' },
|
9
|
+
{ label: 'New Zealand', value: 'New Zealand', id: 'nz' },
|
10
|
+
{ label: 'Germany', value: 'Germany', id: 'de' },
|
11
|
+
{ label: 'France', value: 'France', id: 'fr' },
|
12
|
+
{ label: 'Italy', value: 'Italy', id: 'it' },
|
13
|
+
]
|
14
|
+
%>
|
15
|
+
|
16
|
+
<%= pb_rails("dropdown", props: {
|
17
|
+
options: options,
|
18
|
+
multi_select: true,
|
19
|
+
}) %>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<%
|
2
|
+
options = [
|
3
|
+
{ label: 'United States', value: 'United States', id: 'us' },
|
4
|
+
{ label: 'Canada', value: 'Canada', id: 'ca' },
|
5
|
+
{ label: 'Pakistan', value: 'Pakistan', id: 'pk' },
|
6
|
+
{ label: 'India', value: 'India', id: 'in' },
|
7
|
+
{ label: 'United Kingdom', value: 'United Kingdom', id: 'uk' },
|
8
|
+
{ label: 'Australia', value: 'Australia', id: 'au' },
|
9
|
+
{ label: 'New Zealand', value: 'New Zealand', id: 'nz' },
|
10
|
+
{ label: 'Germany', value: 'Germany', id: 'de' },
|
11
|
+
{ label: 'France', value: 'France', id: 'fr' },
|
12
|
+
{ label: 'Italy', value: 'Italy', id: 'it' },
|
13
|
+
]
|
14
|
+
%>
|
15
|
+
|
16
|
+
<%= pb_rails("dropdown", props: {
|
17
|
+
autocomplete: true,
|
18
|
+
options: options,
|
19
|
+
multi_select: true,
|
20
|
+
}) %>
|
@@ -0,0 +1,57 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import Dropdown from '../../pb_dropdown/_dropdown'
|
3
|
+
|
4
|
+
const DropdownMultiSelectWithAutocomplete = (props) => {
|
5
|
+
|
6
|
+
const options = [
|
7
|
+
{
|
8
|
+
label: "United States",
|
9
|
+
value: "United States",
|
10
|
+
},
|
11
|
+
{
|
12
|
+
label: "United Kingdom",
|
13
|
+
value: "United Kingdom",
|
14
|
+
},
|
15
|
+
{
|
16
|
+
label: "Canada",
|
17
|
+
value: "Canada",
|
18
|
+
},
|
19
|
+
{
|
20
|
+
label: "Pakistan",
|
21
|
+
value: "Pakistan",
|
22
|
+
},
|
23
|
+
{
|
24
|
+
label: "India",
|
25
|
+
value: "India",
|
26
|
+
},
|
27
|
+
{
|
28
|
+
label: "Australia",
|
29
|
+
value: "Australia",
|
30
|
+
},
|
31
|
+
{
|
32
|
+
label: "New Zealand",
|
33
|
+
value: "New Zealand",
|
34
|
+
},
|
35
|
+
{
|
36
|
+
label: "Italy",
|
37
|
+
value: "Italy",
|
38
|
+
},
|
39
|
+
{
|
40
|
+
label: "Spain",
|
41
|
+
value: "Spain",
|
42
|
+
}
|
43
|
+
];
|
44
|
+
|
45
|
+
return (
|
46
|
+
<div>
|
47
|
+
<Dropdown
|
48
|
+
autocomplete
|
49
|
+
multiSelect
|
50
|
+
options={options}
|
51
|
+
{...props}
|
52
|
+
/>
|
53
|
+
</div>
|
54
|
+
)
|
55
|
+
}
|
56
|
+
|
57
|
+
export default DropdownMultiSelectWithAutocomplete
|
@@ -0,0 +1 @@
|
|
1
|
+
`multiSelect` can also be used with the `autocomplete` functionality.
|
data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_multi_select_with_custom_options.html.erb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
<%
|
2
|
+
options = [
|
3
|
+
{
|
4
|
+
label: "United States",
|
5
|
+
value: "United States",
|
6
|
+
areaCode: "+1",
|
7
|
+
icon: "🇺🇸",
|
8
|
+
id: "us"
|
9
|
+
},
|
10
|
+
{
|
11
|
+
label: "Canada",
|
12
|
+
value: "Canada",
|
13
|
+
areaCode: "+1",
|
14
|
+
icon: "🇨🇦",
|
15
|
+
id: "ca"
|
16
|
+
},
|
17
|
+
{
|
18
|
+
label: "Pakistan",
|
19
|
+
value: "Pakistan",
|
20
|
+
areaCode: "+92",
|
21
|
+
icon: "🇵🇰",
|
22
|
+
id: "pk"
|
23
|
+
}
|
24
|
+
]
|
25
|
+
|
26
|
+
%>
|
27
|
+
|
28
|
+
<%= pb_rails("dropdown", props: { options: options, multi_select: true }) do %>
|
29
|
+
<%= pb_rails("dropdown/dropdown_trigger", props:{ multi_select: true }) %>
|
30
|
+
<%= pb_rails("dropdown/dropdown_container") do %>
|
31
|
+
<% options.each do |option| %>
|
32
|
+
<%= pb_rails("dropdown/dropdown_option", props: {option: option}) do %>
|
33
|
+
<%= pb_rails("flex", props: {
|
34
|
+
align: "center",
|
35
|
+
justify: "between",
|
36
|
+
}) do %>
|
37
|
+
<%= pb_rails("flex/flex_item") do %>
|
38
|
+
<%= pb_rails("flex") do %>
|
39
|
+
<%= pb_rails("icon", props: {icon: option[:icon]}) %>
|
40
|
+
<%= pb_rails("body", props: {text: option[:label], padding_left:"xs"}) %>
|
41
|
+
<% end %>
|
42
|
+
<% end %>
|
43
|
+
<%= pb_rails("flex/flex_item") do %>
|
44
|
+
<%= pb_rails("body", props: {color:"light", text: option[:areaCode]}) %>
|
45
|
+
<% end %>
|
46
|
+
<% end %>
|
47
|
+
<% end %>
|
48
|
+
<% end %>
|
49
|
+
<% end %>
|
50
|
+
<% end %>
|
@@ -0,0 +1,105 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import Dropdown from '../../pb_dropdown/_dropdown'
|
3
|
+
import Body from '../../pb_body/_body'
|
4
|
+
import Flex from '../../pb_flex/_flex'
|
5
|
+
import FlexItem from '../../pb_flex/_flex_item'
|
6
|
+
import Icon from '../../pb_icon/_icon'
|
7
|
+
|
8
|
+
const DropdownMultiSelectWithCustomOptions = (props) => {
|
9
|
+
|
10
|
+
const options = [
|
11
|
+
{
|
12
|
+
label: "United States",
|
13
|
+
value: "United States",
|
14
|
+
areaCode: "+1",
|
15
|
+
icon: "🇺🇸",
|
16
|
+
id: "United-states"
|
17
|
+
},
|
18
|
+
{
|
19
|
+
label: "Canada",
|
20
|
+
value: "Canada",
|
21
|
+
areaCode: "+1",
|
22
|
+
icon: "🇨🇦",
|
23
|
+
id: "canada"
|
24
|
+
},
|
25
|
+
{
|
26
|
+
label: "Pakistan",
|
27
|
+
value: "Pakistan",
|
28
|
+
areaCode: "+92",
|
29
|
+
icon: "🇵🇰",
|
30
|
+
id: "pakistan"
|
31
|
+
},
|
32
|
+
{
|
33
|
+
label: "India",
|
34
|
+
value: "India",
|
35
|
+
areaCode: "+91",
|
36
|
+
icon: "🇮🇳",
|
37
|
+
id: "india"
|
38
|
+
},
|
39
|
+
{
|
40
|
+
label: "Australia",
|
41
|
+
value: "Australia",
|
42
|
+
areaCode: "+61",
|
43
|
+
icon: "🇦🇺",
|
44
|
+
id: "australia"
|
45
|
+
},
|
46
|
+
{
|
47
|
+
label: "New Zealand",
|
48
|
+
value: "New Zealand",
|
49
|
+
areaCode: "+64",
|
50
|
+
icon: "🇳🇿",
|
51
|
+
id: "new-zealand"
|
52
|
+
},
|
53
|
+
{
|
54
|
+
label: "Italy",
|
55
|
+
value: "Italy",
|
56
|
+
areaCode: "+39",
|
57
|
+
icon: "🇮🇹",
|
58
|
+
id: "italy"
|
59
|
+
},
|
60
|
+
{
|
61
|
+
label: "Spain",
|
62
|
+
value: "Spain",
|
63
|
+
areaCode: "+34",
|
64
|
+
icon: "🇪🇸",
|
65
|
+
id: "spain"
|
66
|
+
}
|
67
|
+
];
|
68
|
+
|
69
|
+
return (
|
70
|
+
<div>
|
71
|
+
<Dropdown
|
72
|
+
multiSelect
|
73
|
+
options={options}
|
74
|
+
{...props}
|
75
|
+
>
|
76
|
+
{options.map((option) => (
|
77
|
+
<Dropdown.Option key={option.id}
|
78
|
+
option={option}
|
79
|
+
>
|
80
|
+
<Flex
|
81
|
+
align="center"
|
82
|
+
justify="between"
|
83
|
+
>
|
84
|
+
<FlexItem>
|
85
|
+
<Flex>
|
86
|
+
<Icon icon={option.icon}
|
87
|
+
paddingRight="xs"
|
88
|
+
/>
|
89
|
+
<Body text={option.label} />
|
90
|
+
</Flex>
|
91
|
+
</FlexItem>
|
92
|
+
<FlexItem>
|
93
|
+
<Body color="light"
|
94
|
+
text={option.areaCode}
|
95
|
+
/>
|
96
|
+
</FlexItem>
|
97
|
+
</Flex>
|
98
|
+
</Dropdown.Option>
|
99
|
+
))}
|
100
|
+
</Dropdown>
|
101
|
+
</div>
|
102
|
+
)
|
103
|
+
}
|
104
|
+
|
105
|
+
export default DropdownMultiSelectWithCustomOptions
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<%
|
2
|
+
options = [
|
3
|
+
{ label: 'United States', value: 'United States', id: 'us' },
|
4
|
+
{ label: 'Canada', value: 'Canada', id: 'ca' },
|
5
|
+
{ label: 'Pakistan', value: 'Pakistan', id: 'pk' },
|
6
|
+
{ label: 'India', value: 'India', id: 'in' },
|
7
|
+
{ label: 'United Kingdom', value: 'United Kingdom', id: 'uk' },
|
8
|
+
{ label: 'Australia', value: 'Australia', id: 'au' },
|
9
|
+
{ label: 'New Zealand', value: 'New Zealand', id: 'nz' },
|
10
|
+
{ label: 'Germany', value: 'Germany', id: 'de' },
|
11
|
+
{ label: 'France', value: 'France', id: 'fr' },
|
12
|
+
{ label: 'Italy', value: 'Italy', id: 'it' },
|
13
|
+
]
|
14
|
+
%>
|
15
|
+
|
16
|
+
<%
|
17
|
+
default_value = [
|
18
|
+
{ label: 'United States', value: 'United States', id: 'us' },
|
19
|
+
{ label: 'Canada', value: 'Canada', id: 'ca' },
|
20
|
+
]
|
21
|
+
%>
|
22
|
+
<%= pb_rails("dropdown", props: {options: options, multi_select: true, default_value: default_value}) %>
|
@@ -0,0 +1,67 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import Dropdown from "../../pb_dropdown/_dropdown";
|
3
|
+
|
4
|
+
const DropdownMultiSelectWithDefault = (props) => {
|
5
|
+
const options = [
|
6
|
+
{
|
7
|
+
label: "United States",
|
8
|
+
value: "United States",
|
9
|
+
},
|
10
|
+
{
|
11
|
+
label: "United Kingdom",
|
12
|
+
value: "United Kingdom",
|
13
|
+
},
|
14
|
+
{
|
15
|
+
label: "Canada",
|
16
|
+
value: "Canada",
|
17
|
+
},
|
18
|
+
{
|
19
|
+
label: "Pakistan",
|
20
|
+
value: "Pakistan",
|
21
|
+
},
|
22
|
+
{
|
23
|
+
label: "India",
|
24
|
+
value: "India",
|
25
|
+
},
|
26
|
+
{
|
27
|
+
label: "Australia",
|
28
|
+
value: "Australia",
|
29
|
+
},
|
30
|
+
{
|
31
|
+
label: "New Zealand",
|
32
|
+
value: "New Zealand",
|
33
|
+
},
|
34
|
+
{
|
35
|
+
label: "Italy",
|
36
|
+
value: "Italy",
|
37
|
+
},
|
38
|
+
{
|
39
|
+
label: "Spain",
|
40
|
+
value: "Spain",
|
41
|
+
},
|
42
|
+
];
|
43
|
+
|
44
|
+
const defaultSelectedOptions = [
|
45
|
+
{
|
46
|
+
label: "United States",
|
47
|
+
value: "United States",
|
48
|
+
},
|
49
|
+
{
|
50
|
+
label: "Italy",
|
51
|
+
value: "Italy",
|
52
|
+
},
|
53
|
+
];
|
54
|
+
|
55
|
+
return (
|
56
|
+
<div>
|
57
|
+
<Dropdown
|
58
|
+
defaultValue={defaultSelectedOptions}
|
59
|
+
multiSelect
|
60
|
+
options={options}
|
61
|
+
{...props}
|
62
|
+
/>
|
63
|
+
</div>
|
64
|
+
);
|
65
|
+
};
|
66
|
+
|
67
|
+
export default DropdownMultiSelectWithDefault;
|
@@ -1,37 +1,49 @@
|
|
1
1
|
examples:
|
2
2
|
rails:
|
3
|
-
-
|
3
|
+
- dropdown_default_rails: Default
|
4
4
|
- dropdown_with_autocomplete: Autocomplete
|
5
|
+
- dropdown_multi_select_rails: Multi Select
|
6
|
+
- dropdown_multi_select_with_autocomplete: Multi Select with Autocomplete
|
7
|
+
- dropdown_multi_select_display_rails: Multi Select with Form Pill Props
|
5
8
|
- dropdown_subtle_variant: Subtle Variant
|
6
9
|
- dropdown_subcomponent_structure_rails: Subcomponent Structure
|
7
10
|
- dropdown_with_autocomplete_with_subcomponents: Autocomplete with Subcomponent Structure
|
8
11
|
- dropdown_with_label: With Label
|
9
12
|
- dropdown_with_custom_options_rails: Custom Options
|
13
|
+
- dropdown_multi_select_with_custom_options: Multi Select with Custom Options
|
10
14
|
- dropdown_with_custom_display_rails: Custom Display
|
11
15
|
- dropdown_with_custom_trigger_rails: Custom Trigger
|
12
16
|
- dropdown_with_search_rails: Custom Trigger Dropdown with Search
|
13
17
|
- dropdown_with_custom_padding: Custom Option Padding
|
14
18
|
- dropdown_error: Dropdown with Error
|
15
19
|
- dropdown_default_value: Default Value
|
20
|
+
- dropdown_multi_select_with_default: Multi Select Default Value
|
16
21
|
- dropdown_blank_selection: Blank Selection
|
17
22
|
- dropdown_separators_hidden: Separators Hidden
|
18
23
|
|
19
24
|
react:
|
20
25
|
- dropdown_default: Default
|
21
26
|
- dropdown_with_autocomplete: Autocomplete
|
27
|
+
- dropdown_multi_select: Multi Select
|
28
|
+
- dropdown_multi_select_with_autocomplete: Multi Select with Autocomplete
|
29
|
+
- dropdown_multi_select_display: Multi Select with Form Pill Props
|
22
30
|
- dropdown_subtle_variant: Subtle Variant
|
23
31
|
- dropdown_subcomponent_structure: Subcomponent Structure
|
24
32
|
- dropdown_with_autocomplete_with_subcomponents: Autocomplete with Subcomponent Structure
|
25
33
|
- dropdown_with_label: With Label
|
26
34
|
- dropdown_with_custom_options: Custom Options
|
35
|
+
- dropdown_multi_select_with_custom_options: Multi Select with Custom Options
|
27
36
|
- dropdown_with_custom_display: Custom Display
|
28
37
|
- dropdown_with_custom_trigger: Custom Trigger
|
29
38
|
- dropdown_with_search: Custom Trigger Dropdown with Search
|
30
39
|
- dropdown_with_custom_padding: Custom Option Padding
|
31
40
|
- dropdown_error: Dropdown with Error
|
32
41
|
- dropdown_default_value: Default Value
|
42
|
+
- dropdown_multi_select_with_default: Multi Select Default Value
|
33
43
|
- dropdown_blank_selection: Blank Selection
|
34
44
|
- dropdown_clear_selection: Clear Selection
|
35
45
|
- dropdown_separators_hidden: Separators Hidden
|
36
46
|
- dropdown_with_external_control: useDropdown Hook
|
47
|
+
- dropdown_close_on_select: Close On Selection
|
48
|
+
|
37
49
|
|
@@ -15,3 +15,9 @@ export { default as DropdownClearSelection } from './_dropdown_clear_selection.j
|
|
15
15
|
export { default as DropdownSubtleVariant } from './_dropdown_subtle_variant.jsx'
|
16
16
|
export { default as DropdownSeparatorsHidden } from './_dropdown_separators_hidden.jsx'
|
17
17
|
export {default as DropdownWithSearch} from './_dropdown_with_search.jsx'
|
18
|
+
export { default as DropdownMultiSelect } from './_dropdown_multi_select.jsx'
|
19
|
+
export { default as DropdownMultiSelectDisplay } from './_dropdown_multi_select_display.jsx'
|
20
|
+
export { default as DropdownMultiSelectWithAutocomplete } from './_dropdown_multi_select_with_autocomplete.jsx'
|
21
|
+
export { default as DropdownMultiSelectWithDefault } from './_dropdown_multi_select_with_default.jsx'
|
22
|
+
export { default as DropdownMultiSelectWithCustomOptions } from './_dropdown_multi_select_with_custom_options.jsx'
|
23
|
+
export { default as DropdownCloseOnSelect } from './_dropdown_close_on_select.jsx'
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<input
|
7
7
|
data-default-value="<%= input_default_value %>"
|
8
8
|
id="dropdown-selected-option"
|
9
|
-
name="<%= object.name %>"
|
9
|
+
name="<%= object.name %><%= '[]' if object.multi_select %>"
|
10
10
|
style="display: none"
|
11
11
|
<%= object.required ? "required" : ""%>
|
12
12
|
/>
|
@@ -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", props:{autocomplete: object.autocomplete}) %>
|
18
|
-
<%= pb_rails("dropdown/dropdown_container", props: {searchbar: object.searchbar}) do %>
|
17
|
+
<%= pb_rails("dropdown/dropdown_trigger", props:{ autocomplete: object.autocomplete, multi_select:object.multi_select }) %>
|
18
|
+
<%= pb_rails("dropdown/dropdown_container", props: { searchbar: object.searchbar }) 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}) %>
|
@@ -22,9 +22,17 @@ module Playbook
|
|
22
22
|
default: false
|
23
23
|
prop :searchbar, type: Playbook::Props::Boolean,
|
24
24
|
default: false
|
25
|
+
prop :multi_select, type: Playbook::Props::Boolean,
|
26
|
+
default: false
|
27
|
+
prop :form_pill_props, type: Playbook::Props::HashProp,
|
28
|
+
default: {}
|
25
29
|
|
26
30
|
def data
|
27
|
-
Hash(prop(:data)).merge(
|
31
|
+
Hash(prop(:data)).merge(
|
32
|
+
pb_dropdown: true,
|
33
|
+
pb_dropdown_multi_select: multi_select,
|
34
|
+
form_pill_props: form_pill_props.to_json
|
35
|
+
)
|
28
36
|
end
|
29
37
|
|
30
38
|
def classname
|
@@ -38,7 +46,13 @@ module Playbook
|
|
38
46
|
end
|
39
47
|
|
40
48
|
def input_default_value
|
41
|
-
|
49
|
+
return "" unless default_value.present?
|
50
|
+
|
51
|
+
if multi_select
|
52
|
+
default_value.map { |v| v.transform_keys(&:to_s)["id"] }.join(",")
|
53
|
+
else
|
54
|
+
default_value.transform_keys(&:to_s)["id"]
|
55
|
+
end
|
42
56
|
end
|
43
57
|
|
44
58
|
def separators_class
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import React from "react"
|
2
|
-
import { render, screen } from "../utilities/test-utils"
|
2
|
+
import { render, screen, fireEvent } from "../utilities/test-utils"
|
3
3
|
|
4
4
|
import { Dropdown, Icon, IconCircle } from 'playbook-ui'
|
5
5
|
|
@@ -263,4 +263,110 @@ test("searchbar prop to render TextInput in container", () => {
|
|
263
263
|
const kit = screen.getByTestId(testId)
|
264
264
|
const searchbar = kit.querySelector('.pb_text_input_kit')
|
265
265
|
expect(searchbar).toBeInTheDocument()
|
266
|
-
})
|
266
|
+
})
|
267
|
+
|
268
|
+
test("MultiSelect prop to allow multiple selections + add correct Form Pills", () => {
|
269
|
+
render(
|
270
|
+
<Dropdown
|
271
|
+
data={{ testid: testId }}
|
272
|
+
multiSelect
|
273
|
+
options={options}
|
274
|
+
/>
|
275
|
+
);
|
276
|
+
|
277
|
+
const kit = screen.getByTestId(testId);
|
278
|
+
const option = Array.from(kit.querySelectorAll(".pb_dropdown_option_list"));
|
279
|
+
fireEvent.click(option[0]); // Select first option
|
280
|
+
fireEvent.click(option[1]); // Select second option
|
281
|
+
const formPills = kit.querySelectorAll(".pb_form_pill_kit_primary");
|
282
|
+
expect(formPills.length).toBe(2);
|
283
|
+
expect(formPills[0]).toHaveTextContent("United States");
|
284
|
+
expect(formPills[1]).toHaveTextContent("Canada");
|
285
|
+
});
|
286
|
+
|
287
|
+
test("hides each selected option from the dropdown", () => {
|
288
|
+
|
289
|
+
render(
|
290
|
+
<Dropdown
|
291
|
+
data={{ testid: testId }}
|
292
|
+
multiSelect
|
293
|
+
options={options}
|
294
|
+
/>
|
295
|
+
);
|
296
|
+
|
297
|
+
const kit = screen.getByTestId(testId);
|
298
|
+
const option = Array.from(kit.querySelectorAll(".pb_dropdown_option_list"));
|
299
|
+
const firstOpt = options[0].label
|
300
|
+
fireEvent.click(option[0]);
|
301
|
+
const option2 = Array.from(kit.querySelectorAll(".pb_dropdown_option_list"));
|
302
|
+
expect(option2[0]).not.toHaveTextContent(firstOpt)
|
303
|
+
})
|
304
|
+
|
305
|
+
test("renders form pills inside trigger", () => {
|
306
|
+
render(
|
307
|
+
<Dropdown
|
308
|
+
data={{ testid: testId }}
|
309
|
+
multiSelect
|
310
|
+
options={options}
|
311
|
+
/>
|
312
|
+
);
|
313
|
+
|
314
|
+
const kit = screen.getByTestId(testId)
|
315
|
+
const option = kit.querySelector('.pb_dropdown_option_list')
|
316
|
+
fireEvent.click(option)
|
317
|
+
const formPill = kit.querySelector(".pb_form_pill_kit_primary")
|
318
|
+
expect(formPill).toBeInTheDocument()
|
319
|
+
})
|
320
|
+
|
321
|
+
test("multiSelect and autocomplete to work together", () => {
|
322
|
+
render (
|
323
|
+
<Dropdown
|
324
|
+
autocomplete
|
325
|
+
data={{ testid: testId }}
|
326
|
+
multiSelect
|
327
|
+
options={options}
|
328
|
+
/>
|
329
|
+
)
|
330
|
+
|
331
|
+
const kit = screen.getByTestId(testId)
|
332
|
+
const input = kit.querySelector('.dropdown_input')
|
333
|
+
expect(input).toBeInTheDocument()
|
334
|
+
const option = kit.querySelector('.pb_dropdown_option_list')
|
335
|
+
fireEvent.click(option)
|
336
|
+
const formPill = kit.querySelector(".pb_form_pill_kit_primary")
|
337
|
+
expect(formPill).toBeInTheDocument()
|
338
|
+
})
|
339
|
+
|
340
|
+
test("renders form pills with size and color", () => {
|
341
|
+
render(
|
342
|
+
<Dropdown
|
343
|
+
data={{ testid: testId }}
|
344
|
+
formPillProps={{ size: "small", color: "neutral" }}
|
345
|
+
multiSelect
|
346
|
+
options={options}
|
347
|
+
/>
|
348
|
+
);
|
349
|
+
|
350
|
+
const kit = screen.getByTestId(testId)
|
351
|
+
const option = kit.querySelector('.pb_dropdown_option_list')
|
352
|
+
fireEvent.click(option)
|
353
|
+
const formPill = kit.querySelector(".pb_form_pill_kit_neutral")
|
354
|
+
expect(formPill).toBeInTheDocument()
|
355
|
+
expect(formPill).toHaveClass("small")
|
356
|
+
})
|
357
|
+
|
358
|
+
test("defaultValue works with multiSelect", () => {
|
359
|
+
render(
|
360
|
+
<Dropdown
|
361
|
+
data={{ testid: testId }}
|
362
|
+
defaultValue={[options[0], options[2]]}
|
363
|
+
multiSelect
|
364
|
+
options={options}
|
365
|
+
/>
|
366
|
+
)
|
367
|
+
const kit = screen.getByTestId(testId)
|
368
|
+
expect(kit.querySelectorAll(".pb_form_pill_kit_primary")).toHaveLength(2)
|
369
|
+
const option2 = Array.from(kit.querySelectorAll(".pb_dropdown_option_list"));
|
370
|
+
const firstOpt = options[0].label
|
371
|
+
expect(option2[0]).not.toHaveTextContent(firstOpt)
|
372
|
+
})
|
@@ -14,7 +14,7 @@
|
|
14
14
|
padding_y:"xs",
|
15
15
|
html_options: {tabindex:"0"}
|
16
16
|
}) do %>
|
17
|
-
<%= pb_rails("flex/flex_item") do %>
|
17
|
+
<%= pb_rails("flex/flex_item", props: { fixed_size: object.multi_select ? "85%" : "" }) do %>
|
18
18
|
<%= pb_rails("flex", props: {align: "center"}) do %>
|
19
19
|
<% if object.custom_display.present? %>
|
20
20
|
<%= pb_rails("flex", props: {align: "center"}) do %>
|
@@ -24,23 +24,44 @@
|
|
24
24
|
<%= pb_rails("body", props: {text: object.default_display_placeholder, id: "dropdown_trigger_display"}) %>
|
25
25
|
<% end %>
|
26
26
|
<% else %>
|
27
|
-
<% if object.
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
27
|
+
<% if object.multi_select %>
|
28
|
+
<%= pb_rails("flex", props: { align: "center", wrap: true }) do %>
|
29
|
+
<%= pb_rails("flex", props: { id:"dropdown_pills_wrapper", wrap: true }) do %>
|
30
|
+
<% end %>
|
31
|
+
<% if object.autocomplete %>
|
32
|
+
<input
|
33
|
+
data-dropdown-autocomplete
|
34
|
+
class="dropdown_input"
|
35
|
+
type="text"
|
36
|
+
placeholder="<%= object.placeholder || 'Select…' %>"
|
37
|
+
autocomplete="off"
|
38
|
+
/>
|
39
|
+
<% else %>
|
40
|
+
<%= pb_rails("body", props: {text: object.default_display_placeholder, id: "dropdown_trigger_display_multi_select"}) %>
|
41
|
+
<% end %>
|
42
|
+
<% end %>
|
35
43
|
<% else %>
|
36
|
-
|
44
|
+
<% if object.autocomplete %>
|
45
|
+
<input
|
46
|
+
data-dropdown-autocomplete
|
47
|
+
class="dropdown_input"
|
48
|
+
type="text"
|
49
|
+
placeholder="<%= object.placeholder || 'Select…' %>"
|
50
|
+
autocomplete="off"
|
51
|
+
/>
|
52
|
+
<% else %>
|
53
|
+
<%= pb_rails("body", props: {text: object.default_display_placeholder, id: "dropdown_trigger_display"}) %>
|
54
|
+
<% end %>
|
37
55
|
<% end %>
|
38
56
|
<% end %>
|
39
57
|
<% end %>
|
40
58
|
<% end %>
|
41
|
-
<%= pb_rails("
|
42
|
-
<%= pb_rails("
|
43
|
-
|
59
|
+
<%= pb_rails("flex/flex_item") do %>
|
60
|
+
<%= pb_rails("body", props: {display: "flex", align_items:"center" }) do %>
|
61
|
+
<%= pb_rails("icon", props: {icon: "times", cursor: "pointer", size:"sm", id: "dropdown_clear_icon", padding_right:"xs" }) %>
|
62
|
+
<%= pb_rails("icon", props: {icon: "chevron-down", cursor: "pointer", size:"sm", id: "dropdown_open_icon"}) %>
|
63
|
+
<%= pb_rails("icon", props: {icon: "chevron-up", cursor: "pointer", size:"sm", id: "dropdown_close_icon"}) %>
|
64
|
+
<% end %>
|
44
65
|
<% end %>
|
45
66
|
<% end %>
|
46
67
|
<% end %>
|
@@ -11,6 +11,8 @@ module Playbook
|
|
11
11
|
prop :custom_display
|
12
12
|
prop :autocomplete, type: Playbook::Props::Boolean,
|
13
13
|
default: false
|
14
|
+
prop :multi_select, type: Playbook::Props::Boolean,
|
15
|
+
default: false
|
14
16
|
|
15
17
|
def data
|
16
18
|
Hash(prop(:data)).merge(dropdown_trigger: true, dropdown_placeholder: default_display_placeholder)
|
@@ -25,7 +27,7 @@ module Playbook
|
|
25
27
|
end
|
26
28
|
|
27
29
|
def trigger_wrapper_classes
|
28
|
-
generate_classname("dropdown_trigger_wrapper", ("select_only" unless autocomplete))
|
30
|
+
generate_classname("dropdown_trigger_wrapper", ("select_only" unless autocomplete || multi_select))
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|