playbook_ui 13.25.0 → 13.26.0.pre.alpha.jasoncypretpatch12820
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/index.js +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +14 -0
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +10 -14
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta.html.erb +33 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta.md +24 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.md +5 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/index.js +78 -0
- data/app/pb_kits/playbook/pb_advanced_table/table_body.html.erb +5 -9
- data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +4 -2
- data/app/pb_kits/playbook/pb_advanced_table/table_header.html.erb +2 -6
- data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +5 -8
- data/app/pb_kits/playbook/pb_avatar/Utilities/GetPlacementPropsHelper.tsx +44 -0
- data/app/pb_kits/playbook/pb_avatar/_avatar.tsx +86 -21
- data/app/pb_kits/playbook/pb_avatar/avatar.html.erb +26 -3
- data/app/pb_kits/playbook/pb_avatar/avatar.rb +41 -0
- data/app/pb_kits/playbook/pb_avatar/docs/_avatar_badge_component_overlay.html.erb +71 -0
- data/app/pb_kits/playbook/pb_avatar/docs/_avatar_badge_component_overlay.jsx +77 -0
- data/app/pb_kits/playbook/pb_avatar/docs/_avatar_circle_icon_component_overlay.html.erb +71 -0
- data/app/pb_kits/playbook/pb_avatar/docs/_avatar_circle_icon_component_overlay.jsx +77 -0
- data/app/pb_kits/playbook/pb_avatar/docs/_avatar_default.jsx +20 -0
- data/app/pb_kits/playbook/pb_avatar/docs/example.yml +4 -0
- data/app/pb_kits/playbook/pb_avatar/docs/index.js +2 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.html.erb +1 -6
- data/app/pb_kits/playbook/pb_background/background.html.erb +2 -11
- data/app/pb_kits/playbook/pb_badge/badge.html.erb +1 -6
- data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.tsx +1 -1
- data/app/pb_kits/playbook/pb_body/_body.tsx +1 -1
- data/app/pb_kits/playbook/pb_body/body.html.erb +1 -6
- data/app/pb_kits/playbook/pb_bread_crumbs/bread_crumb_item.html.erb +1 -6
- data/app/pb_kits/playbook/pb_bread_crumbs/bread_crumbs.html.erb +2 -7
- data/app/pb_kits/playbook/pb_button/_button.scss +1 -1
- data/app/pb_kits/playbook/pb_button/_button_mixins.scss +1 -0
- data/app/pb_kits/playbook/pb_button/button.html.erb +2 -3
- data/app/pb_kits/playbook/pb_button_toolbar/button_toolbar.html.erb +2 -7
- data/app/pb_kits/playbook/pb_caption/caption.html.erb +1 -6
- data/app/pb_kits/playbook/pb_card/card.html.erb +1 -7
- data/app/pb_kits/playbook/pb_card/card_body.html.erb +1 -6
- data/app/pb_kits/playbook/pb_card/card_header.html.erb +1 -6
- data/app/pb_kits/playbook/pb_checkbox/_checkbox.scss +49 -0
- data/app/pb_kits/playbook/pb_checkbox/_checkbox.tsx +3 -0
- data/app/pb_kits/playbook/pb_checkbox/checkbox.html.erb +1 -6
- data/app/pb_kits/playbook/pb_checkbox/checkbox.rb +2 -1
- data/app/pb_kits/playbook/pb_checkbox/checkbox.test.js +14 -0
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_disabled.html.erb +23 -0
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_disabled.jsx +29 -0
- data/app/pb_kits/playbook/pb_checkbox/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_checkbox/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_circle_icon_button/circle_icon_button.html.erb +1 -6
- data/app/pb_kits/playbook/pb_collapsible/collapsible.html.erb +1 -6
- data/app/pb_kits/playbook/pb_collapsible/collapsible_content.html.erb +1 -6
- data/app/pb_kits/playbook/pb_collapsible/collapsible_main.html.erb +1 -7
- data/app/pb_kits/playbook/pb_contact/contact.html.erb +1 -6
- data/app/pb_kits/playbook/pb_currency/currency.html.erb +1 -6
- data/app/pb_kits/playbook/pb_currency/docs/_currency_alignment_swift.md +43 -0
- data/app/pb_kits/playbook/pb_currency/docs/_currency_props_swift.md +12 -0
- data/app/pb_kits/playbook/pb_currency/docs/_currency_size_swift.md +31 -0
- data/app/pb_kits/playbook/pb_currency/docs/example.yml +5 -0
- data/app/pb_kits/playbook/pb_dashboard_value/dashboard_value.html.erb +1 -6
- data/app/pb_kits/playbook/pb_date/date.html.erb +1 -6
- data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +2 -6
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.md +3 -1
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_close.md +3 -1
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_quick_pick_range_limit.md +1 -1
- data/app/pb_kits/playbook/pb_date_range_inline/date_range_inline.html.erb +1 -5
- data/app/pb_kits/playbook/pb_date_range_stacked/date_range_stacked.html.erb +1 -5
- data/app/pb_kits/playbook/pb_date_range_stacked/docs/_date_range_stacked_default_swift.md +14 -0
- data/app/pb_kits/playbook/pb_date_range_stacked/docs/_date_range_stacked_props_swift.md +9 -0
- data/app/pb_kits/playbook/pb_date_range_stacked/docs/example.yml +4 -0
- data/app/pb_kits/playbook/pb_date_stacked/date_stacked.html.erb +1 -5
- data/app/pb_kits/playbook/pb_date_time/date_time.html.erb +1 -6
- data/app/pb_kits/playbook/pb_date_time_stacked/date_time_stacked.html.erb +1 -7
- data/app/pb_kits/playbook/pb_date_year_stacked/date_year_stacked.html.erb +1 -5
- data/app/pb_kits/playbook/pb_detail/detail.html.erb +1 -6
- data/app/pb_kits/playbook/pb_dialog/_dialog.scss +4 -2
- data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +1 -6
- data/app/pb_kits/playbook/pb_dialog/dialog_body.html.erb +2 -7
- data/app/pb_kits/playbook/pb_dialog/dialog_footer.html.erb +1 -5
- data/app/pb_kits/playbook/pb_dialog/dialog_header.html.erb +2 -6
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +101 -35
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +93 -26
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default.html.erb +10 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default.jsx +4 -22
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default.md +1 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_subcomponent_structure.html.erb +17 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_subcomponent_structure.jsx +42 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_subcomponent_structure.md +7 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete.jsx +84 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete.md +1 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete_and_custom_display.jsx +101 -0
- 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_custom_display.html.erb +60 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display.jsx +6 -4
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display.md +5 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_options.html.erb +45 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_options.jsx +6 -9
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_options.md +1 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_padding.html.erb +17 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_padding.jsx +48 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_padding.md +1 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.html.erb +47 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx +5 -5
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.md +1 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_external_control.jsx +59 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx +72 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_label.html.erb +10 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_label.jsx +39 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_label.md +1 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +16 -2
- data/app/pb_kits/playbook/pb_dropdown/docs/index.js +7 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown.html.erb +20 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown.rb +19 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +200 -10
- data/app/pb_kits/playbook/pb_dropdown/dropdown_container.html.erb +15 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown_container.rb +19 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown_option.html.erb +22 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown_option.rb +22 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown_trigger.html.erb +38 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown_trigger.rb +30 -0
- data/app/pb_kits/playbook/pb_dropdown/hooks/useDropdown.tsx +2 -2
- data/app/pb_kits/playbook/pb_dropdown/hooks/useHandleOnKeydown.tsx +14 -9
- data/app/pb_kits/playbook/pb_dropdown/index.js +152 -0
- data/app/pb_kits/playbook/pb_dropdown/keyboard_accessibility.js +77 -0
- data/app/pb_kits/playbook/pb_dropdown/scss_partials/_dropdown_animation.scss +18 -0
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownContainer.tsx +22 -8
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownOption.tsx +56 -29
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownTrigger.tsx +130 -68
- data/app/pb_kits/playbook/pb_dropdown/utilities/clickOutsideHelper.tsx +41 -0
- data/app/pb_kits/playbook/pb_dropdown/utilities/index.ts +2 -0
- data/app/pb_kits/playbook/pb_dropdown/utilities/subComponentHelper.tsx +9 -7
- data/app/pb_kits/playbook/pb_file_upload/file_upload.html.erb +1 -6
- data/app/pb_kits/playbook/pb_filter/filter.html.erb +1 -5
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.html.erb +1 -6
- data/app/pb_kits/playbook/pb_flex/flex.html.erb +1 -5
- data/app/pb_kits/playbook/pb_flex/flex_item.html.erb +2 -6
- data/app/pb_kits/playbook/pb_form_group/form_group.html.erb +1 -6
- data/app/pb_kits/playbook/pb_form_pill/form_pill.html.erb +1 -1
- data/app/pb_kits/playbook/pb_hashtag/hashtag.html.erb +1 -6
- data/app/pb_kits/playbook/pb_highlight/highlight.html.erb +1 -5
- data/app/pb_kits/playbook/pb_home_address_street/home_address_street.html.erb +1 -5
- data/app/pb_kits/playbook/pb_icon_circle/icon_circle.html.erb +2 -7
- data/app/pb_kits/playbook/pb_icon_stat_value/icon_stat_value.html.erb +1 -6
- data/app/pb_kits/playbook/pb_icon_value/icon_value.html.erb +1 -6
- data/app/pb_kits/playbook/pb_label_pill/label_pill.html.erb +1 -6
- data/app/pb_kits/playbook/pb_label_value/label_value.html.erb +1 -6
- data/app/pb_kits/playbook/pb_layout/body.html.erb +1 -5
- data/app/pb_kits/playbook/pb_layout/footer.html.erb +1 -5
- data/app/pb_kits/playbook/pb_layout/header.html.erb +1 -5
- data/app/pb_kits/playbook/pb_layout/item.html.erb +1 -5
- data/app/pb_kits/playbook/pb_layout/layout.html.erb +1 -5
- data/app/pb_kits/playbook/pb_layout/sidebar.html.erb +1 -5
- data/app/pb_kits/playbook/pb_list/item.html.erb +2 -8
- data/app/pb_kits/playbook/pb_list/list.html.erb +2 -8
- data/app/pb_kits/playbook/pb_loading_inline/_loading_inline.tsx +3 -1
- data/app/pb_kits/playbook/pb_loading_inline/docs/_loading_inline_custom.html.erb +13 -0
- data/app/pb_kits/playbook/pb_loading_inline/docs/_loading_inline_custom.jsx +26 -0
- data/app/pb_kits/playbook/pb_loading_inline/docs/{_loading_inline_light.html.erb → _loading_inline_default.html.erb} +2 -2
- data/app/pb_kits/playbook/pb_loading_inline/docs/{_loading_inline_light.jsx → _loading_inline_default.jsx} +2 -2
- data/app/pb_kits/playbook/pb_loading_inline/docs/example.yml +4 -2
- data/app/pb_kits/playbook/pb_loading_inline/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_loading_inline/loading_inline.html.erb +2 -7
- data/app/pb_kits/playbook/pb_loading_inline/loading_inline.rb +1 -0
- data/app/pb_kits/playbook/pb_loading_inline/loading_inline.test.js +14 -0
- data/app/pb_kits/playbook/pb_message/message.html.erb +1 -6
- data/app/pb_kits/playbook/pb_message/message_mention.html.erb +1 -6
- data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.html.erb +1 -6
- data/app/pb_kits/playbook/pb_multiple_users/multiple_users.html.erb +1 -6
- data/app/pb_kits/playbook/pb_multiple_users_stacked/multiple_users_stacked.html.erb +1 -6
- data/app/pb_kits/playbook/pb_nav/item.html.erb +3 -14
- data/app/pb_kits/playbook/pb_nav/nav.html.erb +1 -6
- data/app/pb_kits/playbook/pb_online_status/online_status.html.erb +2 -6
- data/app/pb_kits/playbook/pb_pagination/pagination.html.erb +1 -6
- data/app/pb_kits/playbook/pb_passphrase/passphrase.html.erb +1 -1
- data/app/pb_kits/playbook/pb_person/person.html.erb +7 -12
- data/app/pb_kits/playbook/pb_person_contact/person_contact.html.erb +1 -6
- data/app/pb_kits/playbook/pb_pill/pill.html.erb +1 -6
- data/app/pb_kits/playbook/pb_popover/popover.html.erb +1 -6
- data/app/pb_kits/playbook/pb_progress_pills/progress_pills.html.erb +2 -6
- data/app/pb_kits/playbook/pb_progress_simple/docs/_progress_simple_flex.html.erb +3 -0
- data/app/pb_kits/playbook/pb_progress_simple/docs/_progress_simple_flex.jsx +16 -0
- data/app/pb_kits/playbook/pb_progress_simple/docs/_progress_simple_flex.md +1 -0
- data/app/pb_kits/playbook/pb_progress_simple/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_progress_simple/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_progress_simple/progress_simple.html.erb +3 -6
- data/app/pb_kits/playbook/pb_progress_simple/progress_simple.rb +1 -1
- data/app/pb_kits/playbook/pb_progress_step/progress_step.html.erb +1 -5
- data/app/pb_kits/playbook/pb_progress_step/progress_step_item.html.erb +1 -5
- data/app/pb_kits/playbook/pb_radio/_radio.scss +35 -0
- data/app/pb_kits/playbook/pb_radio/_radio.tsx +3 -0
- data/app/pb_kits/playbook/pb_radio/docs/_radio_alignment.jsx +4 -1
- data/app/pb_kits/playbook/pb_radio/docs/_radio_default.jsx +4 -1
- data/app/pb_kits/playbook/pb_radio/docs/_radio_disabled.html.erb +26 -0
- data/app/pb_kits/playbook/pb_radio/docs/_radio_disabled.jsx +31 -0
- data/app/pb_kits/playbook/pb_radio/docs/_radio_error.jsx +2 -1
- data/app/pb_kits/playbook/pb_radio/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_radio/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_radio/radio.html.erb +2 -8
- data/app/pb_kits/playbook/pb_radio/radio.rb +5 -0
- data/app/pb_kits/playbook/pb_radio/radio.test.js +17 -0
- data/app/pb_kits/playbook/pb_section_separator/_section_separator.scss +6 -2
- data/app/pb_kits/playbook/pb_section_separator/_section_separator_mixin.scss +11 -1
- data/app/pb_kits/playbook/pb_section_separator/section_separator.html.erb +1 -6
- data/app/pb_kits/playbook/pb_select/select.html.erb +1 -5
- data/app/pb_kits/playbook/pb_selectable_card/selectable_card.html.erb +1 -5
- data/app/pb_kits/playbook/pb_selectable_card_icon/selectable_card_icon.html.erb +1 -4
- data/app/pb_kits/playbook/pb_selectable_icon/selectable_icon.html.erb +1 -5
- data/app/pb_kits/playbook/pb_selectable_list/selectable_list.html.erb +1 -6
- data/app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb +1 -6
- data/app/pb_kits/playbook/pb_source/source.html.erb +1 -5
- data/app/pb_kits/playbook/pb_star_rating/star_rating.html.erb +1 -5
- data/app/pb_kits/playbook/pb_stat_change/stat_change.html.erb +1 -5
- data/app/pb_kits/playbook/pb_stat_value/stat_value.html.erb +1 -5
- data/app/pb_kits/playbook/pb_table/table.html.erb +2 -12
- data/app/pb_kits/playbook/pb_table/table_body.html.erb +6 -16
- data/app/pb_kits/playbook/pb_table/table_cell.html.erb +6 -16
- data/app/pb_kits/playbook/pb_table/table_head.html.erb +6 -16
- data/app/pb_kits/playbook/pb_table/table_header.html.erb +4 -13
- data/app/pb_kits/playbook/pb_table/table_row.html.erb +6 -16
- data/app/pb_kits/playbook/pb_textarea/textarea.html.erb +1 -5
- data/app/pb_kits/playbook/pb_time/time.html.erb +1 -5
- data/app/pb_kits/playbook/pb_time_range_inline/time_range_inline.html.erb +1 -5
- data/app/pb_kits/playbook/pb_time_stacked/time_stacked.html.erb +1 -5
- data/app/pb_kits/playbook/pb_timeline/item.html.erb +3 -7
- data/app/pb_kits/playbook/pb_timeline/timeline.html.erb +1 -5
- data/app/pb_kits/playbook/pb_timestamp/timestamp.html.erb +1 -6
- data/app/pb_kits/playbook/pb_title/title.html.erb +1 -6
- data/app/pb_kits/playbook/pb_title_count/title_count.html.erb +1 -6
- data/app/pb_kits/playbook/pb_title_detail/title_detail.html.erb +1 -5
- data/app/pb_kits/playbook/pb_toggle/toggle.html.erb +1 -6
- data/app/pb_kits/playbook/pb_tooltip/_tooltip.tsx +1 -1
- data/app/pb_kits/playbook/pb_tooltip/tooltip.html.erb +1 -5
- data/app/pb_kits/playbook/pb_user/user.html.erb +1 -6
- data/app/pb_kits/playbook/pb_user_badge/user_badge.html.erb +1 -6
- data/app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.html.erb +1 -6
- data/app/pb_kits/playbook/playbook-rails.js +6 -0
- data/dist/menu.yml +1 -1
- data/dist/playbook-rails.js +6 -6
- data/lib/playbook/kit_base.rb +1 -1
- data/lib/playbook/version.rb +2 -2
- metadata +65 -8
- data/app/pb_kits/playbook/pb_advanced_table/docs/_description.md +0 -1
@@ -4,6 +4,7 @@ import {
|
|
4
4
|
buildAriaProps,
|
5
5
|
buildCss,
|
6
6
|
buildDataProps,
|
7
|
+
buildHtmlProps
|
7
8
|
} from "../../utilities/props";
|
8
9
|
import { globalProps } from "../../utilities/globalProps";
|
9
10
|
|
@@ -16,9 +17,11 @@ import Body from "../../pb_body/_body";
|
|
16
17
|
|
17
18
|
type DropdownContainerProps = {
|
18
19
|
aria?: { [key: string]: string };
|
19
|
-
className?: string;
|
20
20
|
children?: React.ReactChild[] | React.ReactChild;
|
21
|
+
className?: string;
|
22
|
+
dark?: boolean;
|
21
23
|
data?: { [key: string]: string };
|
24
|
+
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
22
25
|
id?: string;
|
23
26
|
searchbar?: boolean;
|
24
27
|
};
|
@@ -26,24 +29,29 @@ type DropdownContainerProps = {
|
|
26
29
|
const DropdownContainer = (props: DropdownContainerProps) => {
|
27
30
|
const {
|
28
31
|
aria = {},
|
29
|
-
className,
|
30
32
|
children,
|
33
|
+
className,
|
34
|
+
dark = false,
|
31
35
|
data = {},
|
36
|
+
htmlOptions = {},
|
32
37
|
id,
|
33
38
|
searchbar = false,
|
34
39
|
} = props;
|
35
40
|
|
36
41
|
const {
|
37
|
-
|
38
|
-
handleChange,
|
39
|
-
filterItem,
|
42
|
+
dropdownContainerRef,
|
40
43
|
filteredOptions,
|
44
|
+
filterItem,
|
45
|
+
handleChange,
|
41
46
|
inputRef,
|
47
|
+
isDropDownClosed,
|
42
48
|
setFocusedOptionIndex,
|
49
|
+
triggerRef
|
43
50
|
} = useContext(DropdownContext);
|
44
51
|
|
45
52
|
const ariaProps = buildAriaProps(aria);
|
46
53
|
const dataProps = buildDataProps(data);
|
54
|
+
const htmlProps = buildHtmlProps(htmlOptions);
|
47
55
|
const classes = classnames(
|
48
56
|
buildCss("pb_dropdown_container"),
|
49
57
|
`${isDropDownClosed ? "close" : "open"}`,
|
@@ -54,12 +62,16 @@ const DropdownContainer = (props: DropdownContainerProps) => {
|
|
54
62
|
return (
|
55
63
|
<div {...ariaProps}
|
56
64
|
{...dataProps}
|
65
|
+
{...htmlProps}
|
57
66
|
className={classes}
|
58
67
|
id={id}
|
59
68
|
onMouseEnter={() => setFocusedOptionIndex(-1)}
|
69
|
+
ref={dropdownContainerRef}
|
70
|
+
style={triggerRef ? {} : { position: "absolute"}}
|
60
71
|
>
|
61
72
|
{searchbar && (
|
62
|
-
<TextInput
|
73
|
+
<TextInput dark={dark}
|
74
|
+
paddingTop="xs"
|
63
75
|
paddingX="xs"
|
64
76
|
>
|
65
77
|
<input
|
@@ -70,9 +82,10 @@ const DropdownContainer = (props: DropdownContainerProps) => {
|
|
70
82
|
/>
|
71
83
|
</TextInput>
|
72
84
|
)}
|
73
|
-
<List>
|
85
|
+
<List dark={dark}>
|
86
|
+
{
|
74
87
|
filteredOptions?.length === 0 ? (
|
75
|
-
<ListItem
|
88
|
+
<ListItem dark={dark}
|
76
89
|
display="flex"
|
77
90
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
78
91
|
// @ts-ignore
|
@@ -80,6 +93,7 @@ const DropdownContainer = (props: DropdownContainerProps) => {
|
|
80
93
|
padding="xs"
|
81
94
|
>
|
82
95
|
<Body color="light"
|
96
|
+
dark={dark}
|
83
97
|
text="no option"
|
84
98
|
/>
|
85
99
|
</ListItem>
|
@@ -4,8 +4,9 @@ import {
|
|
4
4
|
buildAriaProps,
|
5
5
|
buildCss,
|
6
6
|
buildDataProps,
|
7
|
+
buildHtmlProps,
|
7
8
|
} from "../../utilities/props";
|
8
|
-
import { globalProps } from "../../utilities/globalProps";
|
9
|
+
import { globalProps, GlobalProps } from "../../utilities/globalProps";
|
9
10
|
|
10
11
|
import DropdownContext from "../context";
|
11
12
|
|
@@ -16,19 +17,38 @@ import { GenericObject } from "../../types";
|
|
16
17
|
|
17
18
|
type DropdownOptionProps = {
|
18
19
|
aria?: { [key: string]: string };
|
19
|
-
className?: string;
|
20
20
|
children?: React.ReactChild[] | React.ReactChild;
|
21
|
+
className?: string;
|
22
|
+
dark?: boolean;
|
21
23
|
data?: { [key: string]: string };
|
24
|
+
htmlOptions?: { [key: string]: string | number | boolean | (() => void) };
|
22
25
|
id?: string;
|
23
|
-
option?: GenericObject;
|
24
26
|
key?: string;
|
25
|
-
|
27
|
+
option?: GenericObject;
|
28
|
+
padding?: string;
|
29
|
+
} & GlobalProps;
|
26
30
|
|
27
31
|
const DropdownOption = (props: DropdownOptionProps) => {
|
28
|
-
const {
|
32
|
+
const {
|
33
|
+
aria = {},
|
34
|
+
children,
|
35
|
+
className,
|
36
|
+
dark = false,
|
37
|
+
data = {},
|
38
|
+
htmlOptions = {},
|
39
|
+
id,
|
40
|
+
key,
|
41
|
+
option,
|
42
|
+
padding = "xs",
|
43
|
+
} = props;
|
29
44
|
|
30
|
-
const {
|
31
|
-
|
45
|
+
const {
|
46
|
+
filteredOptions,
|
47
|
+
filterItem,
|
48
|
+
focusedOptionIndex,
|
49
|
+
handleOptionClick,
|
50
|
+
selected,
|
51
|
+
} = useContext(DropdownContext);
|
32
52
|
|
33
53
|
const isItemMatchingFilter = (option: GenericObject) =>
|
34
54
|
option?.label.toLowerCase().includes(filterItem.toLowerCase());
|
@@ -36,51 +56,58 @@ const DropdownOption = (props: DropdownOptionProps) => {
|
|
36
56
|
if (!isItemMatchingFilter(option)) {
|
37
57
|
return null;
|
38
58
|
}
|
39
|
-
const isFocused =
|
40
|
-
|
59
|
+
const isFocused =
|
60
|
+
focusedOptionIndex >= 0 &&
|
61
|
+
filteredOptions[focusedOptionIndex].label === option.label;
|
62
|
+
const focusedClass = isFocused && "focused";
|
41
63
|
|
42
64
|
const selectedClass = `${
|
43
65
|
selected.label === option.label
|
44
|
-
|
45
|
-
|
46
|
-
}
|
66
|
+
? "selected"
|
67
|
+
: "list"
|
68
|
+
}`;
|
47
69
|
const ariaProps = buildAriaProps(aria);
|
48
70
|
const dataProps = buildDataProps(data);
|
71
|
+
const htmlProps = buildHtmlProps(htmlOptions);
|
49
72
|
const classes = classnames(
|
50
|
-
buildCss(
|
51
|
-
|
52
|
-
|
53
|
-
|
73
|
+
buildCss(
|
74
|
+
"pb_dropdown_option",
|
75
|
+
selectedClass,
|
76
|
+
focusedClass,
|
77
|
+
),
|
78
|
+
globalProps(props, {padding}),
|
54
79
|
className
|
55
80
|
);
|
56
81
|
|
57
82
|
return (
|
58
|
-
<div
|
59
|
-
{...
|
60
|
-
|
61
|
-
|
83
|
+
<div
|
84
|
+
{...ariaProps}
|
85
|
+
{...dataProps}
|
86
|
+
{...htmlProps}
|
87
|
+
className={classes}
|
88
|
+
id={id}
|
62
89
|
key={key}
|
90
|
+
onClick= {() => handleOptionClick(option)}
|
63
91
|
>
|
64
92
|
<ListItem
|
65
93
|
cursor="pointer"
|
94
|
+
dark={dark}
|
66
95
|
data-name={option.value}
|
67
|
-
htmlOptions={{ onClick: () => handleOptionClick(option) }}
|
68
96
|
key={option.label}
|
69
|
-
padding="
|
97
|
+
padding="none"
|
70
98
|
>
|
71
99
|
<Flex
|
72
100
|
align="center"
|
73
|
-
className="
|
101
|
+
className="dropdown_option_wrapper"
|
74
102
|
justify="between"
|
75
103
|
paddingX="sm"
|
76
104
|
paddingY="xxs"
|
77
105
|
>
|
78
|
-
{
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
)
|
106
|
+
{children ?
|
107
|
+
children :
|
108
|
+
<Body dark={dark}
|
109
|
+
text={option.label}
|
110
|
+
/>
|
84
111
|
}
|
85
112
|
</Flex>
|
86
113
|
</ListItem>
|
@@ -4,6 +4,7 @@ import {
|
|
4
4
|
buildAriaProps,
|
5
5
|
buildCss,
|
6
6
|
buildDataProps,
|
7
|
+
buildHtmlProps
|
7
8
|
} from "../../utilities/props";
|
8
9
|
import { globalProps } from "../../utilities/globalProps";
|
9
10
|
import { useHandleOnKeyDown } from "../hooks/useHandleOnKeydown";
|
@@ -20,107 +21,168 @@ type DropdownTriggerProps = {
|
|
20
21
|
children?: React.ReactChild[] | React.ReactChild;
|
21
22
|
className?: string;
|
22
23
|
customDisplay?: React.ReactChild[] | React.ReactChild;
|
24
|
+
dark?: boolean;
|
23
25
|
data?: { [key: string]: string };
|
26
|
+
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
24
27
|
id?: string;
|
28
|
+
placeholder?: string;
|
25
29
|
};
|
26
30
|
|
27
31
|
const DropdownTrigger = (props: DropdownTriggerProps) => {
|
28
|
-
const {
|
32
|
+
const {
|
33
|
+
aria = {},
|
34
|
+
children,
|
35
|
+
className,
|
36
|
+
customDisplay,
|
37
|
+
dark = false,
|
38
|
+
data = {},
|
39
|
+
htmlOptions = {},
|
40
|
+
id,
|
41
|
+
placeholder,
|
42
|
+
} = props;
|
29
43
|
|
30
44
|
const {
|
31
45
|
autocomplete,
|
32
|
-
handleWrapperClick,
|
33
|
-
selected,
|
34
46
|
filterItem,
|
35
47
|
handleChange,
|
36
|
-
|
37
|
-
isDropDownClosed,
|
48
|
+
handleWrapperClick,
|
38
49
|
inputRef,
|
50
|
+
inputWrapperRef,
|
51
|
+
isDropDownClosed,
|
39
52
|
isInputFocused,
|
40
|
-
|
53
|
+
selected,
|
54
|
+
setIsInputFocused,
|
55
|
+
toggleDropdown,
|
56
|
+
triggerRef,
|
41
57
|
} = useContext(DropdownContext);
|
42
|
-
|
58
|
+
|
43
59
|
const handleKeyDown = useHandleOnKeyDown();
|
44
60
|
|
45
61
|
const ariaProps = buildAriaProps(aria);
|
46
62
|
const dataProps = buildDataProps(data);
|
63
|
+
const htmlProps = buildHtmlProps(htmlOptions);
|
47
64
|
const classes = classnames(
|
48
65
|
buildCss("pb_dropdown_trigger"),
|
49
66
|
globalProps(props),
|
50
67
|
className
|
51
68
|
);
|
52
69
|
|
70
|
+
const triggerWrapperClasses = buildCss(
|
71
|
+
"dropdown_trigger_wrapper",
|
72
|
+
isInputFocused && "focus",
|
73
|
+
!autocomplete && "select_only"
|
74
|
+
);
|
75
|
+
|
76
|
+
const customDisplayPlaceholder = selected.label ? (
|
77
|
+
<b>{selected.label}</b>
|
78
|
+
) : autocomplete ? (
|
79
|
+
""
|
80
|
+
) : placeholder ? (
|
81
|
+
placeholder
|
82
|
+
) : (
|
83
|
+
"Select..."
|
84
|
+
);
|
85
|
+
|
86
|
+
const defaultDisplayPlaceholder = selected.label
|
87
|
+
? selected.label
|
88
|
+
: autocomplete
|
89
|
+
? ""
|
90
|
+
: placeholder
|
91
|
+
? placeholder
|
92
|
+
: "Select...";
|
93
|
+
|
53
94
|
return (
|
54
95
|
<div {...ariaProps}
|
55
96
|
{...dataProps}
|
97
|
+
{...htmlProps}
|
56
98
|
className={classes}
|
57
99
|
id={id}
|
58
100
|
>
|
59
|
-
{
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
101
|
+
{
|
102
|
+
!triggerRef && (
|
103
|
+
children ? (
|
104
|
+
<div
|
105
|
+
onClick={() => toggleDropdown()}
|
106
|
+
onKeyDown= {handleKeyDown}
|
107
|
+
ref={inputWrapperRef}
|
108
|
+
style={{ display: "inline-block" }}
|
109
|
+
tabIndex= {0}
|
110
|
+
>
|
111
|
+
{children}
|
112
|
+
</div>
|
113
|
+
) : (
|
114
|
+
<>
|
115
|
+
<Flex
|
116
|
+
align="center"
|
117
|
+
borderRadius="lg"
|
118
|
+
className={triggerWrapperClasses}
|
119
|
+
cursor={`${autocomplete ? "text" : "pointer"}`}
|
120
|
+
htmlOptions={{
|
121
|
+
onClick: () => handleWrapperClick(),
|
122
|
+
onKeyDown: handleKeyDown,
|
123
|
+
tabIndex: "0",
|
124
|
+
ref:inputWrapperRef
|
125
|
+
}}
|
126
|
+
justify="between"
|
127
|
+
paddingX="sm"
|
128
|
+
paddingY="xs"
|
129
|
+
>
|
130
|
+
<FlexItem>
|
131
|
+
<Flex align="center">
|
83
132
|
{customDisplay ? (
|
84
133
|
<Flex align="center">
|
85
|
-
|
86
|
-
|
87
|
-
{
|
88
|
-
|
134
|
+
{customDisplay}
|
135
|
+
<Body dark={dark}
|
136
|
+
paddingLeft={`${selected.label ? "xs" : "none"}`}
|
137
|
+
>
|
138
|
+
{customDisplayPlaceholder}
|
139
|
+
</Body>
|
89
140
|
</Flex>
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
>
|
115
|
-
|
116
|
-
|
117
|
-
|
141
|
+
) : (
|
142
|
+
<Body dark={dark}
|
143
|
+
text={defaultDisplayPlaceholder}
|
144
|
+
/>
|
145
|
+
)}
|
146
|
+
{autocomplete && (
|
147
|
+
<input
|
148
|
+
className="dropdown_input"
|
149
|
+
onChange={handleChange}
|
150
|
+
onClick={() => toggleDropdown()}
|
151
|
+
onFocus={() => setIsInputFocused(true)}
|
152
|
+
onKeyDown={handleKeyDown}
|
153
|
+
placeholder={
|
154
|
+
selected.label
|
155
|
+
? ""
|
156
|
+
: placeholder
|
157
|
+
? placeholder
|
158
|
+
: "Select..."
|
159
|
+
}
|
160
|
+
ref={inputRef}
|
161
|
+
value={filterItem}
|
162
|
+
/>
|
163
|
+
)}
|
164
|
+
</Flex>
|
165
|
+
</FlexItem>
|
166
|
+
<Body
|
167
|
+
dark={dark}
|
168
|
+
display="flex"
|
169
|
+
htmlOptions={{
|
170
|
+
onClick: (e: Event) => {e.stopPropagation();handleWrapperClick()}
|
171
|
+
}}
|
172
|
+
key={`${isDropDownClosed ? "chevron-down" : "chevron-up"}`}
|
173
|
+
>
|
174
|
+
<Icon
|
175
|
+
cursor="pointer"
|
176
|
+
dark={dark}
|
177
|
+
icon={`${isDropDownClosed ? "chevron-down" : "chevron-up"}`}
|
178
|
+
size="sm"
|
118
179
|
/>
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
180
|
+
</Body>
|
181
|
+
</Flex>
|
182
|
+
</>
|
183
|
+
)
|
184
|
+
)
|
185
|
+
}
|
124
186
|
</div>
|
125
187
|
);
|
126
188
|
};
|
@@ -0,0 +1,41 @@
|
|
1
|
+
type HandleClickOutsideType = {
|
2
|
+
inputWrapperRef?: React.RefObject<HTMLDivElement>;
|
3
|
+
dropdownContainerRef?: React.RefObject<HTMLDivElement>;
|
4
|
+
setIsDropDownClosed?: (value: boolean) => void;
|
5
|
+
setFocusedOptionIndex?: (value: number) => void;
|
6
|
+
setIsInputFocused?: (value: boolean) => void;
|
7
|
+
};
|
8
|
+
|
9
|
+
export const handleClickOutside =
|
10
|
+
({
|
11
|
+
inputWrapperRef,
|
12
|
+
dropdownContainerRef,
|
13
|
+
setIsDropDownClosed,
|
14
|
+
setFocusedOptionIndex,
|
15
|
+
setIsInputFocused,
|
16
|
+
}: HandleClickOutsideType) =>
|
17
|
+
(e: MouseEvent) => {
|
18
|
+
let targetElement = e.target as HTMLElement;
|
19
|
+
let shouldClose = true;
|
20
|
+
|
21
|
+
//Only needed for when useDropdown hook used with external trigger
|
22
|
+
while (targetElement && shouldClose) {
|
23
|
+
if (
|
24
|
+
targetElement.getAttribute("data-dropdown") === "pb-dropdown-trigger"
|
25
|
+
) {
|
26
|
+
shouldClose = false;
|
27
|
+
}
|
28
|
+
targetElement = targetElement.parentElement as HTMLElement;
|
29
|
+
}
|
30
|
+
if (
|
31
|
+
inputWrapperRef.current &&
|
32
|
+
!inputWrapperRef.current.contains((e.target as HTMLElement)) &&
|
33
|
+
dropdownContainerRef.current &&
|
34
|
+
!dropdownContainerRef.current.contains((e.target as HTMLElement)) &&
|
35
|
+
shouldClose
|
36
|
+
) {
|
37
|
+
setIsDropDownClosed(true);
|
38
|
+
setFocusedOptionIndex(-1);
|
39
|
+
setIsInputFocused(false);
|
40
|
+
}
|
41
|
+
};
|
@@ -4,11 +4,12 @@ import DropdownContainer from "../subcomponents/DropdownContainer";
|
|
4
4
|
|
5
5
|
type PrepareComponentsProps = {
|
6
6
|
children: React.ReactChild[] | React.ReactChild;
|
7
|
-
hasTriggerSubcomponent: boolean;
|
8
|
-
hasContainerSubcomponent: boolean;
|
9
|
-
trigger: React.ReactChild;
|
10
7
|
container: React.ReactChild;
|
8
|
+
dark?: boolean;
|
9
|
+
hasContainerSubcomponent: boolean;
|
10
|
+
hasTriggerSubcomponent: boolean;
|
11
11
|
otherChildren: React.ReactChild[];
|
12
|
+
trigger: React.ReactChild;
|
12
13
|
};
|
13
14
|
|
14
15
|
export const separateChildComponents = (children: React.ReactChild[] | React.ReactChild | ReactElement[]) => {
|
@@ -36,19 +37,20 @@ export const prepareSubcomponents = ({
|
|
36
37
|
trigger,
|
37
38
|
container,
|
38
39
|
otherChildren,
|
40
|
+
dark
|
39
41
|
}: PrepareComponentsProps) => {
|
40
42
|
const componentsToRender = [];
|
41
43
|
|
42
44
|
if (!hasTriggerSubcomponent && !hasContainerSubcomponent) {
|
43
|
-
componentsToRender.push(<DropdownTrigger />);
|
44
|
-
componentsToRender.push(<DropdownContainer>{children}</DropdownContainer>);
|
45
|
+
componentsToRender.push(<DropdownTrigger dark={dark}/>);
|
46
|
+
componentsToRender.push(<DropdownContainer dark={dark}>{children}</DropdownContainer>);
|
45
47
|
} else if (!hasTriggerSubcomponent && hasContainerSubcomponent) {
|
46
|
-
componentsToRender.push(<DropdownTrigger />);
|
48
|
+
componentsToRender.push(<DropdownTrigger dark={dark}/>);
|
47
49
|
componentsToRender.push(children);
|
48
50
|
} else if (hasTriggerSubcomponent && !hasContainerSubcomponent) {
|
49
51
|
componentsToRender.push(trigger);
|
50
52
|
componentsToRender.push(
|
51
|
-
<DropdownContainer>{otherChildren}</DropdownContainer>
|
53
|
+
<DropdownContainer dark={dark}>{otherChildren}</DropdownContainer>
|
52
54
|
);
|
53
55
|
} else {
|
54
56
|
componentsToRender.push(trigger);
|
@@ -1,9 +1,4 @@
|
|
1
|
-
<%=
|
2
|
-
aria: object.aria,
|
3
|
-
class: object.classname,
|
4
|
-
data: object.data,
|
5
|
-
id: object.id,
|
6
|
-
**combined_html_options) do %>
|
1
|
+
<%= pb_content_tag do %>
|
7
2
|
<%= pb_rails("form_group", props: {cursor: "pointer", full_width: object.full_width}) do %>
|
8
3
|
<label for="upload-<%= object.id %>" class="pb_button_kit_secondary_inline_enabled"><%= "#{object.label}" %></label>
|
9
4
|
<%= pb_rails("text_input", props: {
|
@@ -1,8 +1,4 @@
|
|
1
|
-
<%=
|
2
|
-
id: object.id,
|
3
|
-
data: object.data,
|
4
|
-
class: object.classname,
|
5
|
-
**combined_html_options) do %>
|
1
|
+
<%= pb_content_tag do %>
|
6
2
|
<%= object.wrapper do %>
|
7
3
|
<%= pb_rails("flex", props: { orientation: "row", padding_right: "lg", vertical: "center" }) do %>
|
8
4
|
<% if (object.template != "sort_only") %>
|
@@ -1,9 +1,4 @@
|
|
1
|
-
<%=
|
2
|
-
aria: object.aria,
|
3
|
-
id: object.id,
|
4
|
-
data: object.data,
|
5
|
-
class: object.classname,
|
6
|
-
**combined_html_options) do %>
|
1
|
+
<%= pb_content_tag do %>
|
7
2
|
<%= pb_rails("icon", props: { icon: object.icon_value, classname: "pb_icon", fixed_width: true }) %>
|
8
3
|
|
9
4
|
<% if content %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%=
|
1
|
+
<%= pb_content_tag(:div, class: object.classname + object.size_class) do %>
|
2
2
|
<% if object.name.present? %>
|
3
3
|
<%= pb_rails("avatar", props: { name: object.name, image_url: object.avatar_url, size: "xs" }) %>
|
4
4
|
<%= pb_rails("title", props: { text: object.name, size: 4, classname: "pb_form_pill_text" }) %>
|
@@ -1,9 +1,4 @@
|
|
1
|
-
<%=
|
2
|
-
aria: object.aria,
|
3
|
-
class: object.classname,
|
4
|
-
data: object.data,
|
5
|
-
id: object.id,
|
6
|
-
**combined_html_options) do %>
|
1
|
+
<%= pb_content_tag(:span) do %>
|
7
2
|
<%= link_to object.url, target: object.link_option do %>
|
8
3
|
<%= pb_rails("badge", props: { dark: object.dark, variant: "primary", text: object.hashtag_text }) %>
|
9
4
|
<% end %>
|
@@ -1,8 +1,4 @@
|
|
1
|
-
<%=
|
2
|
-
id: object.id,
|
3
|
-
data: object.data,
|
4
|
-
class: object.classname,
|
5
|
-
**combined_html_options) do %>
|
1
|
+
<%= pb_content_tag do %>
|
6
2
|
<%= pb_rails("home_address_street/#{emphasis}_emphasis", props: object.send("#{emphasis}_emphasis_props")) %>
|
7
3
|
<% end %>
|
8
4
|
|