playbook_ui 14.18.1.pre.rc.0 → 14.19.0.pre.alpha.PLAY21297675
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/_playbook.scss +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/Components/RegularTableView.tsx +11 -1
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableActionBar.tsx +148 -15
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +20 -3
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +23 -13
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/VisibilityTree.ts +47 -0
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +313 -21
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +12 -3
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb +6 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta.md +0 -6
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_border_color.jsx +80 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_border_color.md +3 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_border_color_rails.html.erb +58 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_border_color_rails.md +3 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility.jsx +57 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility.md +4 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility_custom.jsx +62 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility_custom.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility_multi.jsx +82 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility_multi.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility_with_state.jsx +65 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility_with_state.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_no_subrows_rails.md +5 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/{_advanced_table_selectable_rows_no_subrows.jsx → _advanced_table_selectable_rows_no_subrows_react.jsx} +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_rails.md +3 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +10 -5
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +7 -2
- data/app/pb_kits/playbook/pb_advanced_table/flat_advanced_table.js +106 -0
- data/app/pb_kits/playbook/pb_advanced_table/index.js +228 -11
- data/app/pb_kits/playbook/pb_advanced_table/scss_partials/advanced_table_sticky_mixin.scss +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +9 -1
- data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +0 -3
- data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +1 -2
- data/app/pb_kits/playbook/pb_avatar/_avatar.scss +4 -0
- data/app/pb_kits/playbook/pb_avatar/_avatar.tsx +3 -0
- data/app/pb_kits/playbook/pb_avatar/avatar.html.erb +3 -3
- data/app/pb_kits/playbook/pb_avatar/avatar.rb +2 -0
- data/app/pb_kits/playbook/pb_avatar/avatar.test.js +18 -0
- data/app/pb_kits/playbook/pb_avatar/docs/_avatar_grayscale.html.erb +5 -0
- data/app/pb_kits/playbook/pb_avatar/docs/_avatar_grayscale.jsx +16 -0
- data/app/pb_kits/playbook/pb_avatar/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_avatar/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_card/card.html.erb +1 -1
- data/app/pb_kits/playbook/pb_card/card.rb +12 -0
- 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 +22 -1
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones_line.html.erb +55 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones_line_rails.md +5 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones_rails.md +5 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_event_listeners.jsx +59 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_event_listeners_react.md +1 -0
- data/app/pb_kits/playbook/pb_draggable/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_draggable/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_draggable/draggable_container.rb +11 -1
- data/app/pb_kits/playbook/pb_draggable/draggable_item.rb +11 -1
- data/app/pb_kits/playbook/pb_draggable/index.js +4 -2
- data/app/pb_kits/playbook/pb_draggable/subcomponents/DraggableItem.tsx +33 -5
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +5 -0
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +5 -16
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_error.html.erb +5 -2
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete.html.erb +28 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete.jsx +17 -64
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete_with_subcomponents.html.erb +58 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/{_dropdown_with_autocomplete_and_custom_display.jsx → _dropdown_with_autocomplete_with_subcomponents.jsx} +11 -25
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete_with_subcomponents.md +1 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_external_control.md +1 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_search.jsx +61 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_search.md +2 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_search_rails.html.erb +52 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_search_rails.md +2 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +7 -4
- 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 +4 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +45 -1
- data/app/pb_kits/playbook/pb_dropdown/dropdown_container.html.erb +10 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown_container.rb +3 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown_trigger.html.erb +12 -2
- data/app/pb_kits/playbook/pb_dropdown/dropdown_trigger.rb +3 -1
- data/app/pb_kits/playbook/pb_dropdown/index.js +57 -0
- data/app/pb_kits/playbook/pb_dropdown/keyboard_accessibility.js +26 -0
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownContainer.tsx +3 -4
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownTrigger.tsx +4 -4
- data/app/pb_kits/playbook/pb_empty_state/_empty_state.scss +8 -1
- data/app/pb_kits/playbook/pb_empty_state/docs/_empty_state_alignment.html.erb +27 -0
- data/app/pb_kits/playbook/pb_empty_state/docs/_empty_state_default.html.erb +7 -0
- data/app/pb_kits/playbook/pb_empty_state/docs/_empty_state_orientation.html.erb +12 -0
- data/app/pb_kits/playbook/pb_empty_state/docs/_empty_state_size.html.erb +23 -0
- data/app/pb_kits/playbook/pb_empty_state/docs/example.yml +5 -1
- data/app/pb_kits/playbook/pb_empty_state/empty_state.html.erb +19 -0
- data/app/pb_kits/playbook/pb_empty_state/empty_state.rb +123 -0
- data/app/pb_kits/playbook/pb_message/_message.tsx +3 -0
- data/app/pb_kits/playbook/pb_message/docs/_message_grayscale.html.erb +9 -0
- data/app/pb_kits/playbook/pb_message/docs/_message_grayscale.jsx +21 -0
- data/app/pb_kits/playbook/pb_message/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_message/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_message/message.html.erb +2 -1
- data/app/pb_kits/playbook/pb_message/message.rb +1 -0
- data/app/pb_kits/playbook/pb_overlay/_overlay.scss +2 -1
- 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 +5 -4
- data/app/pb_kits/playbook/pb_section_separator/_section_separator.tsx +2 -2
- data/app/pb_kits/playbook/pb_select/_select.scss +10 -0
- 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 +5 -1
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.html.erb +8 -1
- data/app/pb_kits/playbook/pb_user/_user.tsx +3 -0
- data/app/pb_kits/playbook/pb_user/docs/_user_grayscale.html.erb +6 -0
- data/app/pb_kits/playbook/pb_user/docs/_user_grayscale.jsx +16 -0
- data/app/pb_kits/playbook/pb_user/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_user/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_user/user.html.erb +2 -1
- data/app/pb_kits/playbook/pb_user/user.rb +1 -0
- data/dist/chunks/{_typeahead-D8CsVBZO.js → _typeahead-BPSIWtFT.js} +3 -3
- data/dist/chunks/_weekday_stacked-BeuPAmxG.js +45 -0
- data/dist/chunks/{lib-BmTAc7Nc.js → lib-B20MXZcW.js} +2 -2
- data/dist/chunks/{pb_form_validation-BWjy4bFn.js → pb_form_validation-WWvUXPKD.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +6 -14
- 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/version.rb +2 -2
- metadata +52 -21
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete_and_custom_display.md +0 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx +0 -79
- data/app/pb_kits/playbook/pb_gantt_chart/_gantt_chart.scss +0 -3
- data/app/pb_kits/playbook/pb_gantt_chart/_gantt_chart.tsx +0 -72
- data/app/pb_kits/playbook/pb_gantt_chart/docs/_gantt_chart_default.jsx +0 -53
- data/app/pb_kits/playbook/pb_gantt_chart/docs/example.yml +0 -7
- data/app/pb_kits/playbook/pb_gantt_chart/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_gantt_chart/gantt_chart.test.jsx +0 -19
- data/dist/chunks/_weekday_stacked-CHQsoCdP.js +0 -45
- /data/app/pb_kits/playbook/pb_advanced_table/docs/{_advanced_table_selectable_rows_react.md → _advanced_table_selectable_rows.md} +0 -0
- /data/app/pb_kits/playbook/pb_advanced_table/docs/{_advanced_table_selectable_rows_no_subrows.html.erb → _advanced_table_selectable_rows_no_subrows_rails.html.erb} +0 -0
- /data/app/pb_kits/playbook/pb_advanced_table/docs/{_advanced_table_selectable_rows.html.erb → _advanced_table_selectable_rows_rails.html.erb} +0 -0
- /data/app/pb_kits/playbook/pb_draggable/docs/{_draggable_drop_zones_line.md → _draggable_drop_zones_line_react.md} +0 -0
- /data/app/pb_kits/playbook/pb_draggable/docs/{_draggable_event_listeners.md → _draggable_event_listeners_rails.md} +0 -0
@@ -0,0 +1,52 @@
|
|
1
|
+
<%
|
2
|
+
options = [
|
3
|
+
{
|
4
|
+
label: "United States",
|
5
|
+
value: "United States",
|
6
|
+
areaCode: "+1",
|
7
|
+
icon: "🇺🇸",
|
8
|
+
id: "us"
|
9
|
+
},
|
10
|
+
{
|
11
|
+
label: "United Kingdom",
|
12
|
+
value: "United Kingdom",
|
13
|
+
areaCode: "+44",
|
14
|
+
icon: "🇬🇧",
|
15
|
+
id: "gb"
|
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}) do %>
|
29
|
+
<%= pb_rails("dropdown/dropdown_trigger") do %>
|
30
|
+
<%= pb_rails("icon_circle", props: {icon:"flag", cursor: "pointer", variant:"royal"}) %>
|
31
|
+
<% end %>
|
32
|
+
<%= pb_rails("dropdown/dropdown_container", props:{max_width:"xs", searchbar: true}) do %>
|
33
|
+
<% options.each do |option| %>
|
34
|
+
<%= pb_rails("dropdown/dropdown_option", props: {option: option}) do %>
|
35
|
+
<%= pb_rails("flex", props: {
|
36
|
+
align: "center",
|
37
|
+
justify: "between",
|
38
|
+
}) do %>
|
39
|
+
<%= pb_rails("flex/flex_item") do %>
|
40
|
+
<%= pb_rails("flex") do %>
|
41
|
+
<%= pb_rails("icon", props: {icon: option[:icon]}) %>
|
42
|
+
<%= pb_rails("body", props: {text: option[:label], padding_left:"xs"}) %>
|
43
|
+
<% end %>
|
44
|
+
<% end %>
|
45
|
+
<%= pb_rails("flex/flex_item") do %>
|
46
|
+
<%= pb_rails("body", props: {color:"light", text: option[:areaCode]}) %>
|
47
|
+
<% end %>
|
48
|
+
<% end %>
|
49
|
+
<% end %>
|
50
|
+
<% end %>
|
51
|
+
<% end %>
|
52
|
+
<% end %>
|
@@ -1,12 +1,15 @@
|
|
1
1
|
examples:
|
2
2
|
rails:
|
3
3
|
- dropdown_default: Default
|
4
|
+
- dropdown_with_autocomplete: Autocomplete
|
4
5
|
- dropdown_subtle_variant: Subtle Variant
|
5
6
|
- dropdown_subcomponent_structure_rails: Subcomponent Structure
|
7
|
+
- dropdown_with_autocomplete_with_subcomponents: Autocomplete with Subcomponent Structure
|
6
8
|
- dropdown_with_label: With Label
|
7
9
|
- dropdown_with_custom_options_rails: Custom Options
|
8
10
|
- dropdown_with_custom_display_rails: Custom Display
|
9
11
|
- dropdown_with_custom_trigger_rails: Custom Trigger
|
12
|
+
- dropdown_with_search_rails: Custom Trigger Dropdown with Search
|
10
13
|
- dropdown_with_custom_padding: Custom Option Padding
|
11
14
|
- dropdown_error: Dropdown with Error
|
12
15
|
- dropdown_default_value: Default Value
|
@@ -15,20 +18,20 @@ examples:
|
|
15
18
|
|
16
19
|
react:
|
17
20
|
- dropdown_default: Default
|
21
|
+
- dropdown_with_autocomplete: Autocomplete
|
18
22
|
- dropdown_subtle_variant: Subtle Variant
|
19
23
|
- dropdown_subcomponent_structure: Subcomponent Structure
|
24
|
+
- dropdown_with_autocomplete_with_subcomponents: Autocomplete with Subcomponent Structure
|
20
25
|
- dropdown_with_label: With Label
|
21
26
|
- dropdown_with_custom_options: Custom Options
|
22
27
|
- dropdown_with_custom_display: Custom Display
|
23
28
|
- dropdown_with_custom_trigger: Custom Trigger
|
29
|
+
- dropdown_with_search: Custom Trigger Dropdown with Search
|
24
30
|
- dropdown_with_custom_padding: Custom Option Padding
|
25
31
|
- dropdown_error: Dropdown with Error
|
26
32
|
- dropdown_default_value: Default Value
|
27
33
|
- dropdown_blank_selection: Blank Selection
|
28
34
|
- dropdown_clear_selection: Clear Selection
|
29
35
|
- dropdown_separators_hidden: Separators Hidden
|
30
|
-
|
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
|
36
|
+
- dropdown_with_external_control: useDropdown Hook
|
34
37
|
|
@@ -3,11 +3,10 @@ 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 DropdownWithAutocompleteWithSubcomponents } from './_dropdown_with_autocomplete_with_subcomponents.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'
|
11
10
|
export { default as DropdownSubcomponentStructure } from './_dropdown_subcomponent_structure.jsx'
|
12
11
|
export { default as DropdownError } from './_dropdown_error.jsx'
|
13
12
|
export { default as DropdownDefaultValue } from './_dropdown_default_value.jsx'
|
@@ -15,3 +14,4 @@ export { default as DropdownBlankSelection } from './_dropdown_blank_selection.j
|
|
15
14
|
export { default as DropdownClearSelection } from './_dropdown_clear_selection.jsx'
|
16
15
|
export { default as DropdownSubtleVariant } from './_dropdown_subtle_variant.jsx'
|
17
16
|
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") do %>
|
17
|
+
<%= pb_rails("dropdown/dropdown_trigger", props:{autocomplete: object.autocomplete}) %>
|
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}) %>
|
@@ -18,6 +18,10 @@ 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
|
21
25
|
|
22
26
|
def data
|
23
27
|
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 } from 'playbook-ui'
|
4
|
+
import { Dropdown, Icon, IconCircle } from 'playbook-ui'
|
5
5
|
|
6
6
|
|
7
7
|
const testId = 'dropdown'
|
@@ -219,4 +219,48 @@ 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()
|
222
266
|
})
|
@@ -1,4 +1,14 @@
|
|
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 %>
|
2
12
|
<%= pb_rails("list", props: {ordered: false, borderless: false}) do %>
|
3
13
|
<% if content.present? %>
|
4
14
|
<%= content.presence %>
|
@@ -8,7 +8,7 @@
|
|
8
8
|
align: "center",
|
9
9
|
border_radius:"lg",
|
10
10
|
classname: object.trigger_wrapper_classes,
|
11
|
-
cursor: "pointer",
|
11
|
+
cursor: object.autocomplete ? "text" : "pointer",
|
12
12
|
justify: "between",
|
13
13
|
padding_x:"sm",
|
14
14
|
padding_y:"xs",
|
@@ -24,7 +24,17 @@
|
|
24
24
|
<%= pb_rails("body", props: {text: object.default_display_placeholder, id: "dropdown_trigger_display"}) %>
|
25
25
|
<% end %>
|
26
26
|
<% else %>
|
27
|
-
|
27
|
+
<% if object.autocomplete %>
|
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 %>
|
28
38
|
<% end %>
|
29
39
|
<% end %>
|
30
40
|
<% end %>
|
@@ -9,6 +9,8 @@ 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
|
12
14
|
|
13
15
|
def data
|
14
16
|
Hash(prop(:data)).merge(dropdown_trigger: true, dropdown_placeholder: default_display_placeholder)
|
@@ -23,7 +25,7 @@ module Playbook
|
|
23
25
|
end
|
24
26
|
|
25
27
|
def trigger_wrapper_classes
|
26
|
-
generate_classname("dropdown_trigger_wrapper", "select_only")
|
28
|
+
generate_classname("dropdown_trigger_wrapper", ("select_only" unless autocomplete))
|
27
29
|
end
|
28
30
|
end
|
29
31
|
end
|
@@ -11,6 +11,8 @@ const CUSTOM_DISPLAY_SELECTOR = "[data-dropdown-custom-trigger]";
|
|
11
11
|
const DROPDOWN_TRIGGER_DISPLAY = "#dropdown_trigger_display";
|
12
12
|
const DROPDOWN_PLACEHOLDER = "[data-dropdown-placeholder]";
|
13
13
|
const DROPDOWN_INPUT = "#dropdown-selected-option";
|
14
|
+
const SEARCH_INPUT_SELECTOR = "[data-dropdown-autocomplete]";
|
15
|
+
const SEARCH_BAR_SELECTOR = "[data-dropdown-search]";
|
14
16
|
|
15
17
|
export default class PbDropdown extends PbEnhancedElement {
|
16
18
|
static get selector() {
|
@@ -25,9 +27,11 @@ export default class PbDropdown extends PbEnhancedElement {
|
|
25
27
|
this.keyboardHandler = new PbDropdownKeyboard(this);
|
26
28
|
this.setDefaultValue();
|
27
29
|
this.bindEventListeners();
|
30
|
+
this.bindSearchInput();
|
28
31
|
this.updateArrowDisplay(false);
|
29
32
|
this.handleFormValidation();
|
30
33
|
this.handleFormReset();
|
34
|
+
this.bindSearchBar();
|
31
35
|
}
|
32
36
|
|
33
37
|
bindEventListeners() {
|
@@ -45,6 +49,53 @@ export default class PbDropdown extends PbEnhancedElement {
|
|
45
49
|
);
|
46
50
|
}
|
47
51
|
|
52
|
+
bindSearchBar() {
|
53
|
+
this.searchBar = this.element.querySelector(SEARCH_BAR_SELECTOR);
|
54
|
+
if (!this.searchBar) return;
|
55
|
+
|
56
|
+
this.searchBar.addEventListener("input", (e) =>
|
57
|
+
this.handleSearch(e.target.value)
|
58
|
+
);
|
59
|
+
}
|
60
|
+
|
61
|
+
bindSearchInput() {
|
62
|
+
this.searchInput = this.element.querySelector(SEARCH_INPUT_SELECTOR);
|
63
|
+
if (!this.searchInput) return;
|
64
|
+
|
65
|
+
// Focus the input when anyone clicks the wrapper
|
66
|
+
this.element
|
67
|
+
.querySelector(TRIGGER_SELECTOR)
|
68
|
+
?.addEventListener("click", () => this.searchInput.focus());
|
69
|
+
|
70
|
+
// Live filter
|
71
|
+
this.searchInput.addEventListener("input", (e) =>
|
72
|
+
this.handleSearch(e.target.value)
|
73
|
+
);
|
74
|
+
}
|
75
|
+
|
76
|
+
handleSearch(term = "") {
|
77
|
+
const lcTerm = term.toLowerCase();
|
78
|
+
this.element.querySelectorAll(OPTION_SELECTOR).forEach((opt) => {
|
79
|
+
const label = JSON.parse(opt.dataset.dropdownOptionLabel).label
|
80
|
+
.toString()
|
81
|
+
.toLowerCase();
|
82
|
+
|
83
|
+
// hide or show option
|
84
|
+
const match = label.includes(lcTerm);
|
85
|
+
opt.style.display = match ? "" : "none";
|
86
|
+
});
|
87
|
+
|
88
|
+
if (this.target.classList.contains("open")) {
|
89
|
+
const el = this.target;
|
90
|
+
el.style.height = "auto";
|
91
|
+
requestAnimationFrame(() => {
|
92
|
+
const newHeight = el.scrollHeight + "px";
|
93
|
+
el.offsetHeight; // force reflow
|
94
|
+
el.style.height = newHeight;
|
95
|
+
});
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
48
99
|
handleOptionClick(event) {
|
49
100
|
const option = event.target.closest(OPTION_SELECTOR);
|
50
101
|
const hiddenInput = this.element.querySelector(DROPDOWN_INPUT);
|
@@ -59,6 +110,7 @@ export default class PbDropdown extends PbEnhancedElement {
|
|
59
110
|
}
|
60
111
|
|
61
112
|
handleDocumentClick(event) {
|
113
|
+
if (event.target.closest(SEARCH_BAR_SELECTOR)) return;
|
62
114
|
if (this.isClickOutside(event) && this.target.classList.contains("open")) {
|
63
115
|
this.hideElement(this.target);
|
64
116
|
this.updateArrowDisplay(false);
|
@@ -99,6 +151,11 @@ export default class PbDropdown extends PbEnhancedElement {
|
|
99
151
|
}
|
100
152
|
}
|
101
153
|
|
154
|
+
const autocompleteInput = this.element.querySelector(SEARCH_INPUT_SELECTOR);
|
155
|
+
if (autocompleteInput){
|
156
|
+
autocompleteInput.value = JSON.parse(value).label;
|
157
|
+
}
|
158
|
+
|
102
159
|
const customTrigger = this.element.querySelector(CUSTOM_DISPLAY_SELECTOR);
|
103
160
|
if (customTrigger) {
|
104
161
|
if (this.target.classList.contains("open")) {
|
@@ -1,4 +1,6 @@
|
|
1
1
|
const OPTION_SELECTOR = "[data-dropdown-option-label]";
|
2
|
+
const SEARCH_INPUT_SELECTOR = "[data-dropdown-autocomplete]";
|
3
|
+
|
2
4
|
export class PbDropdownKeyboard {
|
3
5
|
constructor(dropdown) {
|
4
6
|
this.dropdown = dropdown;
|
@@ -7,6 +9,9 @@ export class PbDropdownKeyboard {
|
|
7
9
|
this.dropdownElement.querySelectorAll(OPTION_SELECTOR)
|
8
10
|
);
|
9
11
|
this.focusedOptionIndex = -1;
|
12
|
+
this.searchInput = this.dropdownElement.querySelector(
|
13
|
+
SEARCH_INPUT_SELECTOR
|
14
|
+
);
|
10
15
|
this.init();
|
11
16
|
}
|
12
17
|
|
@@ -15,6 +20,18 @@ export class PbDropdownKeyboard {
|
|
15
20
|
"keydown",
|
16
21
|
this.handleKeyDown.bind(this)
|
17
22
|
);
|
23
|
+
if (this.searchInput) {
|
24
|
+
this.searchInput.addEventListener("input", () =>
|
25
|
+
this.openDropdownIfClosed()
|
26
|
+
);
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
openDropdownIfClosed() {
|
31
|
+
if (!this.dropdown.target.classList.contains("open")) {
|
32
|
+
this.dropdown.showElement(this.dropdown.target);
|
33
|
+
this.dropdown.updateArrowDisplay(true);
|
34
|
+
}
|
18
35
|
}
|
19
36
|
|
20
37
|
handleKeyDown(event) {
|
@@ -50,6 +67,15 @@ export class PbDropdownKeyboard {
|
|
50
67
|
this.dropdown.updateArrowDisplay(false);
|
51
68
|
this.resetFocus();
|
52
69
|
break;
|
70
|
+
case "Backspace":
|
71
|
+
if (this.searchInput) {
|
72
|
+
setTimeout(() => {
|
73
|
+
if (this.searchInput.value.trim() === "") {
|
74
|
+
this.dropdown.resetDropdownValue();
|
75
|
+
}
|
76
|
+
}, 0);
|
77
|
+
}
|
78
|
+
break;
|
53
79
|
default:
|
54
80
|
break;
|
55
81
|
}
|
@@ -6,7 +6,7 @@ import {
|
|
6
6
|
buildDataProps,
|
7
7
|
buildHtmlProps
|
8
8
|
} from "../../utilities/props";
|
9
|
-
import { globalProps } from "../../utilities/globalProps";
|
9
|
+
import { globalProps, GlobalProps } from "../../utilities/globalProps";
|
10
10
|
|
11
11
|
import DropdownContext from "../context";
|
12
12
|
|
@@ -24,7 +24,7 @@ type DropdownContainerProps = {
|
|
24
24
|
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
25
25
|
id?: string;
|
26
26
|
searchbar?: boolean;
|
27
|
-
};
|
27
|
+
} & GlobalProps;
|
28
28
|
|
29
29
|
const DropdownContainer = (props: DropdownContainerProps) => {
|
30
30
|
const {
|
@@ -46,7 +46,6 @@ const DropdownContainer = (props: DropdownContainerProps) => {
|
|
46
46
|
inputRef,
|
47
47
|
isDropDownClosed,
|
48
48
|
setFocusedOptionIndex,
|
49
|
-
triggerRef
|
50
49
|
} = useContext(DropdownContext);
|
51
50
|
|
52
51
|
const ariaProps = buildAriaProps(aria);
|
@@ -67,7 +66,7 @@ const DropdownContainer = (props: DropdownContainerProps) => {
|
|
67
66
|
id={id}
|
68
67
|
onMouseEnter={() => setFocusedOptionIndex(-1)}
|
69
68
|
ref={dropdownContainerRef}
|
70
|
-
style={
|
69
|
+
style={{ position: "absolute"}}
|
71
70
|
>
|
72
71
|
{searchbar && (
|
73
72
|
<TextInput dark={dark}
|
@@ -53,7 +53,6 @@ const DropdownTrigger = (props: DropdownTriggerProps) => {
|
|
53
53
|
selected,
|
54
54
|
setIsInputFocused,
|
55
55
|
toggleDropdown,
|
56
|
-
triggerRef,
|
57
56
|
} = useContext(DropdownContext);
|
58
57
|
|
59
58
|
const handleKeyDown = useHandleOnKeyDown();
|
@@ -99,7 +98,6 @@ const DropdownTrigger = (props: DropdownTriggerProps) => {
|
|
99
98
|
id={id}
|
100
99
|
>
|
101
100
|
{
|
102
|
-
!triggerRef && (
|
103
101
|
children ? (
|
104
102
|
<div
|
105
103
|
onClick={() => toggleDropdown()}
|
@@ -147,7 +145,10 @@ const DropdownTrigger = (props: DropdownTriggerProps) => {
|
|
147
145
|
<input
|
148
146
|
className="dropdown_input"
|
149
147
|
onChange={handleChange}
|
150
|
-
onClick={() =>
|
148
|
+
onClick={(e) => {
|
149
|
+
e.stopPropagation();// keep the wrapper’s handler from firing
|
150
|
+
toggleDropdown();
|
151
|
+
}}
|
151
152
|
onFocus={() => setIsInputFocused(true)}
|
152
153
|
onKeyDown={handleKeyDown}
|
153
154
|
placeholder={
|
@@ -181,7 +182,6 @@ const DropdownTrigger = (props: DropdownTriggerProps) => {
|
|
181
182
|
</Flex>
|
182
183
|
</>
|
183
184
|
)
|
184
|
-
)
|
185
185
|
}
|
186
186
|
</div>
|
187
187
|
);
|
@@ -1,4 +1,5 @@
|
|
1
1
|
.pb_empty_state_kit {
|
2
|
+
max-width: 100%;
|
2
3
|
|
3
4
|
.sm-state-vertical {
|
4
5
|
width: 150px;
|
@@ -35,4 +36,10 @@
|
|
35
36
|
}
|
36
37
|
}
|
37
38
|
|
38
|
-
|
39
|
+
&.dark {
|
40
|
+
[class*="pb_title_kit"],
|
41
|
+
[class*="pb_body_kit"],
|
42
|
+
[class*="pb_detail_kit"],
|
43
|
+
[class*="pb_button_kit_link"]:hover { color: $white; }
|
44
|
+
}
|
45
|
+
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<%= pb_rails("flex", props: {align: "center", spacing: "evenly", wrap: true}) do %>
|
2
|
+
<%= pb_rails("empty_state", props: {
|
3
|
+
description: "Body text goes into detail with possible steps for user to take",
|
4
|
+
header: "Title Explains",
|
5
|
+
image: "default",
|
6
|
+
primary_button: "Next Action",
|
7
|
+
primary_button_url: "#primary_button_url",
|
8
|
+
alignment: "left",
|
9
|
+
}) %>
|
10
|
+
|
11
|
+
<%= pb_rails("empty_state", props: {
|
12
|
+
description: "Body text goes into detail with possible steps for user to take",
|
13
|
+
header: "Title Explains",
|
14
|
+
image: "default",
|
15
|
+
primary_button: "Next Action",
|
16
|
+
primary_button_url: "#primary_button_url",
|
17
|
+
}) %>
|
18
|
+
|
19
|
+
<%= pb_rails("empty_state", props: {
|
20
|
+
description: "Body text goes into detail with possible steps for user to take",
|
21
|
+
header: "Title Explains",
|
22
|
+
image: "default",
|
23
|
+
primary_button: "Next Action",
|
24
|
+
primary_button_url: "#primary_button_url",
|
25
|
+
alignment: "right",
|
26
|
+
}) %>
|
27
|
+
<% end %>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<%= pb_rails("flex", props: {align: "center", justify: "center", wrap: true}) do %>
|
2
|
+
<%= pb_rails("empty_state", props: {
|
3
|
+
description: "Body text goes into detail with possible steps for user to take",
|
4
|
+
header: "Title Explains",
|
5
|
+
image: "default",
|
6
|
+
orientation:"horizontal",
|
7
|
+
alignment: "left",
|
8
|
+
size: "lg",
|
9
|
+
primary_button: "Next Action",
|
10
|
+
primary_button_url: "#primary_button_url",
|
11
|
+
}) %>
|
12
|
+
<% end %>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<%= pb_rails("flex", props: {align: "center", spacing: "evenly", wrap: true}) do %>
|
2
|
+
<%= pb_rails("empty_state", props: {
|
3
|
+
description: "Body text goes into detail with possible steps for user to take",
|
4
|
+
header: "Title Explains",
|
5
|
+
image: "default",
|
6
|
+
primary_button: "Next Action",
|
7
|
+
primary_button_url: "#primary_button_url",
|
8
|
+
link_button: "Alt Action",
|
9
|
+
link_button_url: "#link_button_url",
|
10
|
+
size: "sm",
|
11
|
+
}) %>
|
12
|
+
|
13
|
+
<%= pb_rails("empty_state", props: {
|
14
|
+
description: "Body text goes into detail with possible steps for user to take",
|
15
|
+
header: "Title Explains",
|
16
|
+
image: "default",
|
17
|
+
primary_button: "Next Action",
|
18
|
+
primary_button_url: "#primary_button_url",
|
19
|
+
link_button: "Alt Action",
|
20
|
+
link_button_url: "#link_button_url",
|
21
|
+
size: "lg",
|
22
|
+
}) %>
|
23
|
+
<% end %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<%= pb_content_tag do %>
|
2
|
+
<%= pb_rails("flex", props: { align: flex_align, orientation: config[:flex_direction], padding_left: padding_size, padding_right: padding_size, vertical: "center", classname: config[:scss_class], max_width: "100%" }) do %>
|
3
|
+
<%= pb_rails("image", props: { url: image == "default" ? default_image_data_uri : image, alt: "Empty State Image", html_options: { width: config[:image_width], height: "auto", alignment: "start" } }) %>
|
4
|
+
<%= pb_rails("flex/flex_item") do %>
|
5
|
+
<%= pb_rails("title", props: { text: object.header, size: config[:title_size], padding_bottom: config[:title_padding], text_align: alignment }) %>
|
6
|
+
<% if size == "sm" %>
|
7
|
+
<%= pb_rails("detail", props: { text: object.description, padding_bottom: config[:description_pad], text_align: alignment }) %>
|
8
|
+
<% else %>
|
9
|
+
<%= pb_rails("body", props: { text: object.description, padding_bottom: config[:description_pad], text_align: alignment }) %>
|
10
|
+
<% end %>
|
11
|
+
<% if primary_button.present? %>
|
12
|
+
<%= pb_rails("button", props: { text: primary_button, variant: "primary", width: "100%", size: config[:button_size], link: primary_button_url, margin_bottom: config[:button_margin] }) %>
|
13
|
+
<% end %>
|
14
|
+
<% if link_button.present? %>
|
15
|
+
<%= pb_rails("button", props: { text: link_button, variant: "link", size: config[:button_size], link: link_button_url, width: "100%" }) %>
|
16
|
+
<% end %>
|
17
|
+
<% end %>
|
18
|
+
<% end %>
|
19
|
+
<% end %>
|