playbook_ui 13.25.0.pre.alpha.barchartfix2766 → 13.25.0
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/pb_advanced_table/advanced_table.html.erb +14 -10
- data/app/pb_kits/playbook/pb_advanced_table/table_body.html.erb +9 -5
- data/app/pb_kits/playbook/pb_advanced_table/table_header.html.erb +6 -2
- data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +6 -2
- data/app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.html.erb +6 -1
- data/app/pb_kits/playbook/pb_background/background.html.erb +11 -2
- data/app/pb_kits/playbook/pb_badge/badge.html.erb +6 -1
- 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 +6 -1
- data/app/pb_kits/playbook/pb_bread_crumbs/bread_crumb_item.html.erb +6 -1
- data/app/pb_kits/playbook/pb_bread_crumbs/bread_crumbs.html.erb +7 -2
- data/app/pb_kits/playbook/pb_button/_button.scss +1 -1
- data/app/pb_kits/playbook/pb_button/button.html.erb +3 -2
- data/app/pb_kits/playbook/pb_button_toolbar/button_toolbar.html.erb +7 -2
- data/app/pb_kits/playbook/pb_caption/caption.html.erb +6 -1
- data/app/pb_kits/playbook/pb_card/card.html.erb +7 -1
- data/app/pb_kits/playbook/pb_card/card_body.html.erb +6 -1
- data/app/pb_kits/playbook/pb_card/card_header.html.erb +6 -1
- data/app/pb_kits/playbook/pb_checkbox/checkbox.html.erb +6 -1
- data/app/pb_kits/playbook/pb_circle_icon_button/circle_icon_button.html.erb +6 -1
- data/app/pb_kits/playbook/pb_collapsible/collapsible.html.erb +6 -1
- data/app/pb_kits/playbook/pb_collapsible/collapsible_content.html.erb +6 -1
- data/app/pb_kits/playbook/pb_collapsible/collapsible_main.html.erb +7 -1
- data/app/pb_kits/playbook/pb_contact/contact.html.erb +6 -1
- data/app/pb_kits/playbook/pb_currency/currency.html.erb +6 -1
- data/app/pb_kits/playbook/pb_currency/docs/example.yml +0 -5
- data/app/pb_kits/playbook/pb_dashboard_value/dashboard_value.html.erb +6 -1
- data/app/pb_kits/playbook/pb_date/date.html.erb +6 -1
- data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +6 -2
- data/app/pb_kits/playbook/pb_date_range_inline/date_range_inline.html.erb +5 -1
- data/app/pb_kits/playbook/pb_date_range_stacked/date_range_stacked.html.erb +5 -1
- data/app/pb_kits/playbook/pb_date_range_stacked/docs/example.yml +0 -4
- data/app/pb_kits/playbook/pb_date_stacked/date_stacked.html.erb +5 -1
- data/app/pb_kits/playbook/pb_date_time/date_time.html.erb +6 -1
- data/app/pb_kits/playbook/pb_date_time_stacked/date_time_stacked.html.erb +7 -1
- data/app/pb_kits/playbook/pb_date_year_stacked/date_year_stacked.html.erb +5 -1
- data/app/pb_kits/playbook/pb_detail/detail.html.erb +6 -1
- data/app/pb_kits/playbook/pb_dialog/_dialog.scss +2 -4
- data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +6 -1
- data/app/pb_kits/playbook/pb_dialog/dialog_body.html.erb +7 -2
- data/app/pb_kits/playbook/pb_dialog/dialog_footer.html.erb +5 -1
- data/app/pb_kits/playbook/pb_dialog/dialog_header.html.erb +6 -2
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +9 -14
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +6 -34
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default.jsx +5 -5
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display.jsx +2 -4
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_options.jsx +5 -5
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx +5 -5
- data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +0 -3
- data/app/pb_kits/playbook/pb_dropdown/docs/index.js +0 -3
- data/app/pb_kits/playbook/pb_dropdown/hooks/useHandleOnKeydown.tsx +6 -11
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownContainer.tsx +0 -5
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownOption.tsx +24 -41
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownTrigger.tsx +47 -91
- data/app/pb_kits/playbook/pb_file_upload/file_upload.html.erb +6 -1
- data/app/pb_kits/playbook/pb_filter/filter.html.erb +5 -1
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.html.erb +6 -1
- data/app/pb_kits/playbook/pb_flex/flex.html.erb +5 -1
- data/app/pb_kits/playbook/pb_flex/flex_item.html.erb +6 -2
- data/app/pb_kits/playbook/pb_form_group/form_group.html.erb +6 -1
- data/app/pb_kits/playbook/pb_form_pill/form_pill.html.erb +1 -1
- data/app/pb_kits/playbook/pb_hashtag/hashtag.html.erb +6 -1
- data/app/pb_kits/playbook/pb_highlight/highlight.html.erb +5 -1
- data/app/pb_kits/playbook/pb_home_address_street/home_address_street.html.erb +5 -1
- data/app/pb_kits/playbook/pb_icon_circle/icon_circle.html.erb +7 -2
- data/app/pb_kits/playbook/pb_icon_stat_value/icon_stat_value.html.erb +6 -1
- data/app/pb_kits/playbook/pb_icon_value/icon_value.html.erb +6 -1
- data/app/pb_kits/playbook/pb_label_pill/label_pill.html.erb +6 -1
- data/app/pb_kits/playbook/pb_label_value/label_value.html.erb +6 -1
- data/app/pb_kits/playbook/pb_layout/body.html.erb +5 -1
- data/app/pb_kits/playbook/pb_layout/footer.html.erb +5 -1
- data/app/pb_kits/playbook/pb_layout/header.html.erb +5 -1
- data/app/pb_kits/playbook/pb_layout/item.html.erb +5 -1
- data/app/pb_kits/playbook/pb_layout/layout.html.erb +5 -1
- data/app/pb_kits/playbook/pb_layout/sidebar.html.erb +5 -1
- data/app/pb_kits/playbook/pb_list/item.html.erb +8 -2
- data/app/pb_kits/playbook/pb_list/list.html.erb +8 -2
- data/app/pb_kits/playbook/pb_loading_inline/loading_inline.html.erb +6 -1
- data/app/pb_kits/playbook/pb_message/message.html.erb +6 -1
- data/app/pb_kits/playbook/pb_message/message_mention.html.erb +6 -1
- data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.html.erb +6 -1
- data/app/pb_kits/playbook/pb_multiple_users/multiple_users.html.erb +6 -1
- data/app/pb_kits/playbook/pb_multiple_users_stacked/multiple_users_stacked.html.erb +6 -1
- data/app/pb_kits/playbook/pb_nav/item.html.erb +14 -3
- data/app/pb_kits/playbook/pb_nav/nav.html.erb +6 -1
- data/app/pb_kits/playbook/pb_online_status/online_status.html.erb +6 -2
- data/app/pb_kits/playbook/pb_pagination/pagination.html.erb +6 -1
- data/app/pb_kits/playbook/pb_passphrase/passphrase.html.erb +1 -1
- data/app/pb_kits/playbook/pb_person/person.html.erb +12 -7
- data/app/pb_kits/playbook/pb_person_contact/person_contact.html.erb +6 -1
- data/app/pb_kits/playbook/pb_pill/pill.html.erb +6 -1
- data/app/pb_kits/playbook/pb_popover/popover.html.erb +6 -1
- data/app/pb_kits/playbook/pb_progress_pills/progress_pills.html.erb +6 -2
- data/app/pb_kits/playbook/pb_progress_simple/progress_simple.html.erb +6 -3
- data/app/pb_kits/playbook/pb_progress_step/progress_step.html.erb +5 -1
- data/app/pb_kits/playbook/pb_progress_step/progress_step_item.html.erb +5 -1
- data/app/pb_kits/playbook/pb_radio/radio.html.erb +8 -2
- data/app/pb_kits/playbook/pb_section_separator/_section_separator.scss +2 -6
- data/app/pb_kits/playbook/pb_section_separator/_section_separator_mixin.scss +1 -11
- data/app/pb_kits/playbook/pb_section_separator/section_separator.html.erb +6 -1
- data/app/pb_kits/playbook/pb_select/select.html.erb +5 -1
- data/app/pb_kits/playbook/pb_selectable_card/selectable_card.html.erb +5 -1
- data/app/pb_kits/playbook/pb_selectable_card_icon/selectable_card_icon.html.erb +4 -1
- data/app/pb_kits/playbook/pb_selectable_icon/selectable_icon.html.erb +5 -1
- data/app/pb_kits/playbook/pb_selectable_list/selectable_list.html.erb +6 -1
- data/app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb +6 -1
- data/app/pb_kits/playbook/pb_source/source.html.erb +5 -1
- data/app/pb_kits/playbook/pb_star_rating/star_rating.html.erb +5 -1
- data/app/pb_kits/playbook/pb_stat_change/stat_change.html.erb +5 -1
- data/app/pb_kits/playbook/pb_stat_value/stat_value.html.erb +5 -1
- data/app/pb_kits/playbook/pb_table/table.html.erb +12 -2
- data/app/pb_kits/playbook/pb_table/table_body.html.erb +16 -6
- data/app/pb_kits/playbook/pb_table/table_cell.html.erb +16 -6
- data/app/pb_kits/playbook/pb_table/table_head.html.erb +16 -6
- data/app/pb_kits/playbook/pb_table/table_header.html.erb +13 -4
- data/app/pb_kits/playbook/pb_table/table_row.html.erb +16 -6
- data/app/pb_kits/playbook/pb_textarea/textarea.html.erb +5 -1
- data/app/pb_kits/playbook/pb_time/time.html.erb +5 -1
- data/app/pb_kits/playbook/pb_time_range_inline/time_range_inline.html.erb +5 -1
- data/app/pb_kits/playbook/pb_time_stacked/time_stacked.html.erb +5 -1
- data/app/pb_kits/playbook/pb_timeline/item.html.erb +7 -3
- data/app/pb_kits/playbook/pb_timeline/timeline.html.erb +5 -1
- data/app/pb_kits/playbook/pb_timestamp/timestamp.html.erb +6 -1
- data/app/pb_kits/playbook/pb_title/title.html.erb +6 -1
- data/app/pb_kits/playbook/pb_title_count/title_count.html.erb +6 -1
- data/app/pb_kits/playbook/pb_title_detail/title_detail.html.erb +5 -1
- data/app/pb_kits/playbook/pb_toggle/toggle.html.erb +6 -1
- data/app/pb_kits/playbook/pb_tooltip/tooltip.html.erb +5 -1
- data/app/pb_kits/playbook/pb_user/user.html.erb +6 -1
- data/app/pb_kits/playbook/pb_user_badge/user_badge.html.erb +6 -1
- data/app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.html.erb +6 -1
- data/dist/playbook-rails.js +4 -4
- data/lib/playbook/kit_base.rb +1 -1
- data/lib/playbook/version.rb +2 -2
- metadata +5 -20
- data/app/pb_kits/playbook/pb_currency/docs/_currency_alignment_swift.md +0 -43
- data/app/pb_kits/playbook/pb_currency/docs/_currency_props_swift.md +0 -12
- data/app/pb_kits/playbook/pb_currency/docs/_currency_size_swift.md +0 -31
- data/app/pb_kits/playbook/pb_date_range_stacked/docs/_date_range_stacked_default_swift.md +0 -14
- data/app/pb_kits/playbook/pb_date_range_stacked/docs/_date_range_stacked_props_swift.md +0 -9
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default.md +0 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete.jsx +0 -87
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete.md +0 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete_and_custom_display.jsx +0 -102
- 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_custom_display.md +0 -3
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_options.md +0 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_padding.jsx +0 -51
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_padding.md +0 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.md +0 -1
@@ -1,6 +1,6 @@
|
|
1
1
|
import React, { useState, useRef, useEffect, ReactElement } from "react";
|
2
2
|
import classnames from "classnames";
|
3
|
-
import { buildAriaProps, buildCss, buildDataProps
|
3
|
+
import { buildAriaProps, buildCss, buildDataProps } from "../utilities/props";
|
4
4
|
import { globalProps } from "../utilities/globalProps";
|
5
5
|
|
6
6
|
import Body from "../pb_body/_body";
|
@@ -22,7 +22,6 @@ type DropdownProps = {
|
|
22
22
|
autocomplete?: boolean;
|
23
23
|
className?: string;
|
24
24
|
data?: { [key: string]: string };
|
25
|
-
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
26
25
|
id?: string;
|
27
26
|
children?: React.ReactChild[] | React.ReactChild | ReactElement[];
|
28
27
|
options: GenericObject;
|
@@ -36,7 +35,6 @@ const Dropdown = (props: DropdownProps) => {
|
|
36
35
|
children,
|
37
36
|
className,
|
38
37
|
data = {},
|
39
|
-
htmlOptions = {},
|
40
38
|
id,
|
41
39
|
options,
|
42
40
|
onSelect,
|
@@ -44,7 +42,6 @@ const Dropdown = (props: DropdownProps) => {
|
|
44
42
|
|
45
43
|
const ariaProps = buildAriaProps(aria);
|
46
44
|
const dataProps = buildDataProps(data);
|
47
|
-
const htmlProps = buildHtmlProps(htmlOptions);
|
48
45
|
const classes = classnames(
|
49
46
|
buildCss("pb_dropdown"),
|
50
47
|
globalProps(props),
|
@@ -54,7 +51,7 @@ const Dropdown = (props: DropdownProps) => {
|
|
54
51
|
const [isDropDownClosed, setIsDropDownClosed, toggleDropdown] = useDropdown();
|
55
52
|
|
56
53
|
const [filterItem, setFilterItem] = useState("");
|
57
|
-
const [selected, setSelected] = useState
|
54
|
+
const [selected, setSelected] = useState({});
|
58
55
|
const [isInputFocused, setIsInputFocused] = useState(false);
|
59
56
|
const [hasTriggerSubcomponent, setHasTriggerSubcomponent] = useState(true);
|
60
57
|
const [hasContainerSubcomponent, setHasContainerSubcomponent] =
|
@@ -74,7 +71,6 @@ const Dropdown = (props: DropdownProps) => {
|
|
74
71
|
const handleClickOutside = (e: MouseEvent) => {
|
75
72
|
if (dropdownRef.current && !dropdownRef.current.contains(e.target)) {
|
76
73
|
setIsDropDownClosed(true);
|
77
|
-
setFocusedOptionIndex(-1)
|
78
74
|
setIsInputFocused(false);
|
79
75
|
}
|
80
76
|
};
|
@@ -89,24 +85,6 @@ const Dropdown = (props: DropdownProps) => {
|
|
89
85
|
setHasContainerSubcomponent(!!container);
|
90
86
|
}, []);
|
91
87
|
|
92
|
-
|
93
|
-
const filteredOptions = options?.filter((option: GenericObject) =>
|
94
|
-
option.label.toLowerCase().includes(filterItem.toLowerCase())
|
95
|
-
);
|
96
|
-
|
97
|
-
useEffect(() => {
|
98
|
-
if (!isDropDownClosed) {
|
99
|
-
let newIndex = 0;
|
100
|
-
if (selected && selected?.label) {
|
101
|
-
const selectedIndex = filteredOptions.findIndex((option: GenericObject) => option.label === selected.label);
|
102
|
-
if (selectedIndex >= 0) {
|
103
|
-
newIndex = selectedIndex;
|
104
|
-
}
|
105
|
-
}
|
106
|
-
setFocusedOptionIndex(newIndex);
|
107
|
-
}
|
108
|
-
}, [isDropDownClosed]);
|
109
|
-
|
110
88
|
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
111
89
|
setFilterItem(e.target.value);
|
112
90
|
setIsDropDownClosed(false);
|
@@ -130,6 +108,10 @@ const Dropdown = (props: DropdownProps) => {
|
|
130
108
|
setFocusedOptionIndex(-1);
|
131
109
|
};
|
132
110
|
|
111
|
+
const filteredOptions = options?.filter((option: GenericObject) =>
|
112
|
+
option.label.toLowerCase().includes(filterItem.toLowerCase())
|
113
|
+
);
|
114
|
+
|
133
115
|
const componentsToRender = prepareSubcomponents({
|
134
116
|
children,
|
135
117
|
hasTriggerSubcomponent,
|
@@ -142,7 +124,6 @@ const Dropdown = (props: DropdownProps) => {
|
|
142
124
|
return (
|
143
125
|
<div {...ariaProps}
|
144
126
|
{...dataProps}
|
145
|
-
{...htmlProps}
|
146
127
|
className={classes}
|
147
128
|
id={id}
|
148
129
|
>
|
@@ -169,15 +150,6 @@ const Dropdown = (props: DropdownProps) => {
|
|
169
150
|
}}
|
170
151
|
>
|
171
152
|
<div className="dropdown_wrapper"
|
172
|
-
onBlur={() => {
|
173
|
-
// Debounce to delay the execution to prevent jumpiness in Focus state
|
174
|
-
setTimeout(() => {
|
175
|
-
if (!dropdownRef.current.contains(document.activeElement)) {
|
176
|
-
setIsInputFocused(false);
|
177
|
-
}
|
178
|
-
}, 0);
|
179
|
-
}}
|
180
|
-
onFocus={() => setIsInputFocused(true)}
|
181
153
|
ref={dropdownRef}
|
182
154
|
>
|
183
155
|
{children ? (
|
@@ -14,11 +14,11 @@ const [selectedOption, setSelectedOption] = useState();
|
|
14
14
|
id: "United-states"
|
15
15
|
},
|
16
16
|
{
|
17
|
-
label: "
|
18
|
-
value: "
|
19
|
-
areaCode: "+
|
20
|
-
icon: "
|
21
|
-
id: "
|
17
|
+
label: "Ukraine",
|
18
|
+
value: "Ukraine",
|
19
|
+
areaCode: "+380",
|
20
|
+
icon: "🇺🇦",
|
21
|
+
id: "ukraine"
|
22
22
|
},
|
23
23
|
{
|
24
24
|
label: "Pakistan",
|
@@ -39,7 +39,7 @@ const DropdownWithCustomDisplay = (props) => {
|
|
39
39
|
}
|
40
40
|
];
|
41
41
|
|
42
|
-
const
|
42
|
+
const customDisplay = () => {
|
43
43
|
return (
|
44
44
|
<>
|
45
45
|
{
|
@@ -62,9 +62,7 @@ const DropdownWithCustomDisplay = (props) => {
|
|
62
62
|
options={options}
|
63
63
|
{...props}
|
64
64
|
>
|
65
|
-
<Dropdown.Trigger customDisplay={
|
66
|
-
placeholder="Select a User"
|
67
|
-
/>
|
65
|
+
<Dropdown.Trigger customDisplay={customDisplay()}/>
|
68
66
|
{options.map((option) => (
|
69
67
|
<Dropdown.Option key={option.id}
|
70
68
|
option={option}
|
@@ -14,11 +14,11 @@ const DropdownWithCustomOptions = (props) => {
|
|
14
14
|
id: "United-states"
|
15
15
|
},
|
16
16
|
{
|
17
|
-
label: "
|
18
|
-
value: "
|
19
|
-
areaCode: "+
|
20
|
-
icon: "
|
21
|
-
id: "
|
17
|
+
label: "Ukraine",
|
18
|
+
value: "Ukraine",
|
19
|
+
areaCode: "+380",
|
20
|
+
icon: "🇺🇦",
|
21
|
+
id: "ukraine"
|
22
22
|
},
|
23
23
|
{
|
24
24
|
label: "Pakistan",
|
@@ -14,11 +14,11 @@ const [selectedOption, setSelectedOption] = useState();
|
|
14
14
|
id: "United-states"
|
15
15
|
},
|
16
16
|
{
|
17
|
-
label: "
|
18
|
-
value: "
|
19
|
-
areaCode: "+
|
20
|
-
icon: "
|
21
|
-
id: "
|
17
|
+
label: "Ukraine",
|
18
|
+
value: "Ukraine",
|
19
|
+
areaCode: "+380",
|
20
|
+
icon: "🇺🇦",
|
21
|
+
id: "ukraine"
|
22
22
|
},
|
23
23
|
{
|
24
24
|
label: "Pakistan",
|
@@ -6,7 +6,4 @@ examples:
|
|
6
6
|
- dropdown_with_custom_options: Custom Options
|
7
7
|
- dropdown_with_custom_display: Custom Display
|
8
8
|
- dropdown_with_custom_trigger: Custom Trigger
|
9
|
-
- dropdown_with_autocomplete: Autocomplete
|
10
|
-
- dropdown_with_autocomplete_and_custom_display: Autocomplete with Custom Display
|
11
|
-
- dropdown_with_custom_padding: Custom Padding for Dropdown Options
|
12
9
|
|
@@ -2,6 +2,3 @@ export { default as DropdownDefault } from './_dropdown_default.jsx'
|
|
2
2
|
export { default as DropdownWithCustomDisplay } from './_dropdown_with_custom_display.jsx'
|
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
|
-
export { default as DropdownWithAutocomplete } from './_dropdown_with_autocomplete.jsx'
|
6
|
-
export { default as DropdownWithAutocompleteAndCustomDisplay } from './_dropdown_with_autocomplete_and_custom_display.jsx'
|
7
|
-
export { default as DropdownWithCustomPadding } from './_dropdown_with_custom_padding.jsx'
|
@@ -12,15 +12,10 @@ const {
|
|
12
12
|
handleOptionClick,
|
13
13
|
setIsDropDownClosed,
|
14
14
|
handleBackspace,
|
15
|
-
selected
|
15
|
+
selected
|
16
16
|
}= useContext(DropdownContext)
|
17
17
|
|
18
18
|
return (e: React.KeyboardEvent) => {
|
19
|
-
|
20
|
-
if (e.key !== "Tab" && autocomplete && selected && selected.label) {
|
21
|
-
handleBackspace();
|
22
|
-
}
|
23
|
-
|
24
19
|
switch (e.key) {
|
25
20
|
case "Backspace":
|
26
21
|
case "Delete":
|
@@ -48,13 +43,13 @@ const {
|
|
48
43
|
e.preventDefault();
|
49
44
|
handleOptionClick(filteredOptions[focusedOptionIndex]);
|
50
45
|
setFocusedOptionIndex(-1)
|
51
|
-
} else if (focusedOptionIndex === -1) {
|
52
|
-
setIsDropDownClosed(false)
|
53
46
|
}
|
54
47
|
break;
|
55
|
-
|
56
|
-
|
57
|
-
|
48
|
+
default:
|
49
|
+
if (selected && selected.label) {
|
50
|
+
e.preventDefault();
|
51
|
+
handleBackspace();
|
52
|
+
}
|
58
53
|
break;
|
59
54
|
}
|
60
55
|
}
|
@@ -4,7 +4,6 @@ import {
|
|
4
4
|
buildAriaProps,
|
5
5
|
buildCss,
|
6
6
|
buildDataProps,
|
7
|
-
buildHtmlProps
|
8
7
|
} from "../../utilities/props";
|
9
8
|
import { globalProps } from "../../utilities/globalProps";
|
10
9
|
|
@@ -20,7 +19,6 @@ type DropdownContainerProps = {
|
|
20
19
|
className?: string;
|
21
20
|
children?: React.ReactChild[] | React.ReactChild;
|
22
21
|
data?: { [key: string]: string };
|
23
|
-
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
24
22
|
id?: string;
|
25
23
|
searchbar?: boolean;
|
26
24
|
};
|
@@ -31,7 +29,6 @@ const DropdownContainer = (props: DropdownContainerProps) => {
|
|
31
29
|
className,
|
32
30
|
children,
|
33
31
|
data = {},
|
34
|
-
htmlOptions = {},
|
35
32
|
id,
|
36
33
|
searchbar = false,
|
37
34
|
} = props;
|
@@ -47,7 +44,6 @@ const DropdownContainer = (props: DropdownContainerProps) => {
|
|
47
44
|
|
48
45
|
const ariaProps = buildAriaProps(aria);
|
49
46
|
const dataProps = buildDataProps(data);
|
50
|
-
const htmlProps = buildHtmlProps(htmlOptions);
|
51
47
|
const classes = classnames(
|
52
48
|
buildCss("pb_dropdown_container"),
|
53
49
|
`${isDropDownClosed ? "close" : "open"}`,
|
@@ -58,7 +54,6 @@ const DropdownContainer = (props: DropdownContainerProps) => {
|
|
58
54
|
return (
|
59
55
|
<div {...ariaProps}
|
60
56
|
{...dataProps}
|
61
|
-
{...htmlProps}
|
62
57
|
className={classes}
|
63
58
|
id={id}
|
64
59
|
onMouseEnter={() => setFocusedOptionIndex(-1)}
|
@@ -4,9 +4,8 @@ import {
|
|
4
4
|
buildAriaProps,
|
5
5
|
buildCss,
|
6
6
|
buildDataProps,
|
7
|
-
buildHtmlProps,
|
8
7
|
} from "../../utilities/props";
|
9
|
-
import { globalProps
|
8
|
+
import { globalProps } from "../../utilities/globalProps";
|
10
9
|
|
11
10
|
import DropdownContext from "../context";
|
12
11
|
|
@@ -20,33 +19,16 @@ type DropdownOptionProps = {
|
|
20
19
|
className?: string;
|
21
20
|
children?: React.ReactChild[] | React.ReactChild;
|
22
21
|
data?: { [key: string]: string };
|
23
|
-
htmlOptions?: { [key: string]: string | number | boolean | (() => void) };
|
24
22
|
id?: string;
|
25
23
|
option?: GenericObject;
|
26
24
|
key?: string;
|
27
|
-
|
28
|
-
} & GlobalProps;
|
25
|
+
};
|
29
26
|
|
30
27
|
const DropdownOption = (props: DropdownOptionProps) => {
|
31
|
-
const {
|
32
|
-
aria = {},
|
33
|
-
className,
|
34
|
-
children,
|
35
|
-
data = {},
|
36
|
-
htmlOptions = {},
|
37
|
-
id,
|
38
|
-
option,
|
39
|
-
key,
|
40
|
-
padding = "xs",
|
41
|
-
} = props;
|
28
|
+
const { aria = {}, className, children, data = {}, id, option, key } = props;
|
42
29
|
|
43
|
-
const {
|
44
|
-
|
45
|
-
selected,
|
46
|
-
filterItem,
|
47
|
-
filteredOptions,
|
48
|
-
focusedOptionIndex,
|
49
|
-
} = useContext(DropdownContext);
|
30
|
+
const { handleOptionClick, selected, filterItem, filteredOptions, focusedOptionIndex } =
|
31
|
+
useContext(DropdownContext);
|
50
32
|
|
51
33
|
const isItemMatchingFilter = (option: GenericObject) =>
|
52
34
|
option?.label.toLowerCase().includes(filterItem.toLowerCase());
|
@@ -54,42 +36,37 @@ const DropdownOption = (props: DropdownOptionProps) => {
|
|
54
36
|
if (!isItemMatchingFilter(option)) {
|
55
37
|
return null;
|
56
38
|
}
|
57
|
-
const isFocused =
|
58
|
-
|
59
|
-
filteredOptions[focusedOptionIndex].label === option.label;
|
60
|
-
const focusedClass = isFocused && "dropdown_option_focused";
|
39
|
+
const isFocused = focusedOptionIndex >= 0 && filteredOptions[focusedOptionIndex].label === option.label
|
40
|
+
const focusedClass = isFocused && "dropdown_option_focused"
|
61
41
|
|
62
42
|
const selectedClass = `${
|
63
43
|
selected.label === option.label
|
64
|
-
|
65
|
-
|
66
|
-
}
|
44
|
+
? "dropdown_option_selected"
|
45
|
+
: "dropdown_option_list"
|
46
|
+
}`
|
67
47
|
const ariaProps = buildAriaProps(aria);
|
68
48
|
const dataProps = buildDataProps(data);
|
69
|
-
const htmlProps = buildHtmlProps(htmlOptions);
|
70
49
|
const classes = classnames(
|
71
50
|
buildCss("pb_dropdown_option"),
|
72
51
|
selectedClass,
|
73
52
|
focusedClass,
|
74
|
-
globalProps(props
|
53
|
+
globalProps(props),
|
75
54
|
className
|
76
55
|
);
|
77
56
|
|
78
57
|
return (
|
79
|
-
<div
|
80
|
-
{...
|
81
|
-
{
|
82
|
-
{
|
83
|
-
className={classes}
|
84
|
-
id={id}
|
58
|
+
<div {...ariaProps}
|
59
|
+
{...dataProps}
|
60
|
+
className={classes}
|
61
|
+
id={id}
|
85
62
|
key={key}
|
86
|
-
onClick= {() => handleOptionClick(option)}
|
87
63
|
>
|
88
64
|
<ListItem
|
89
65
|
cursor="pointer"
|
90
66
|
data-name={option.value}
|
67
|
+
htmlOptions={{ onClick: () => handleOptionClick(option) }}
|
91
68
|
key={option.label}
|
92
|
-
padding="
|
69
|
+
padding="xs"
|
93
70
|
>
|
94
71
|
<Flex
|
95
72
|
align="center"
|
@@ -98,7 +75,13 @@ const DropdownOption = (props: DropdownOptionProps) => {
|
|
98
75
|
paddingX="sm"
|
99
76
|
paddingY="xxs"
|
100
77
|
>
|
101
|
-
{
|
78
|
+
{
|
79
|
+
children ? (
|
80
|
+
children
|
81
|
+
) : (
|
82
|
+
<Body text={option.label}/>
|
83
|
+
)
|
84
|
+
}
|
102
85
|
</Flex>
|
103
86
|
</ListItem>
|
104
87
|
</div>
|
@@ -4,7 +4,6 @@ import {
|
|
4
4
|
buildAriaProps,
|
5
5
|
buildCss,
|
6
6
|
buildDataProps,
|
7
|
-
buildHtmlProps
|
8
7
|
} from "../../utilities/props";
|
9
8
|
import { globalProps } from "../../utilities/globalProps";
|
10
9
|
import { useHandleOnKeyDown } from "../hooks/useHandleOnKeydown";
|
@@ -22,22 +21,11 @@ type DropdownTriggerProps = {
|
|
22
21
|
className?: string;
|
23
22
|
customDisplay?: React.ReactChild[] | React.ReactChild;
|
24
23
|
data?: { [key: string]: string };
|
25
|
-
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
26
24
|
id?: string;
|
27
|
-
placeholder?: string;
|
28
25
|
};
|
29
26
|
|
30
27
|
const DropdownTrigger = (props: DropdownTriggerProps) => {
|
31
|
-
const {
|
32
|
-
aria = {},
|
33
|
-
className,
|
34
|
-
children,
|
35
|
-
customDisplay,
|
36
|
-
data = {},
|
37
|
-
htmlOptions = {},
|
38
|
-
id,
|
39
|
-
placeholder,
|
40
|
-
} = props;
|
28
|
+
const { aria = {}, className, children, customDisplay, data = {}, id } = props;
|
41
29
|
|
42
30
|
const {
|
43
31
|
autocomplete,
|
@@ -49,119 +37,87 @@ const DropdownTrigger = (props: DropdownTriggerProps) => {
|
|
49
37
|
isDropDownClosed,
|
50
38
|
inputRef,
|
51
39
|
isInputFocused,
|
52
|
-
setIsInputFocused
|
40
|
+
setIsInputFocused
|
53
41
|
} = useContext(DropdownContext);
|
54
|
-
|
42
|
+
|
55
43
|
const handleKeyDown = useHandleOnKeyDown();
|
56
44
|
|
57
45
|
const ariaProps = buildAriaProps(aria);
|
58
46
|
const dataProps = buildDataProps(data);
|
59
|
-
const htmlProps = buildHtmlProps(htmlOptions);
|
60
47
|
const classes = classnames(
|
61
48
|
buildCss("pb_dropdown_trigger"),
|
62
49
|
globalProps(props),
|
63
50
|
className
|
64
51
|
);
|
65
52
|
|
66
|
-
const triggerWrapperClasses = `dropdown_trigger_wrapper ${
|
67
|
-
isInputFocused && "dropdown_trigger_wrapper_focus"
|
68
|
-
} ${!autocomplete && "dropdown_trigger_wrapper_select_only"}`;
|
69
|
-
|
70
|
-
const customDisplayPlaceholder = selected.label ? (
|
71
|
-
<b>{selected.label}</b>
|
72
|
-
) : autocomplete ? (
|
73
|
-
""
|
74
|
-
) : placeholder ? (
|
75
|
-
placeholder
|
76
|
-
) : (
|
77
|
-
"Select..."
|
78
|
-
);
|
79
|
-
|
80
|
-
const defaultDisplayPlaceholder = selected.label
|
81
|
-
? selected.label
|
82
|
-
: autocomplete
|
83
|
-
? ""
|
84
|
-
: placeholder
|
85
|
-
? placeholder
|
86
|
-
: "Select...";
|
87
|
-
|
88
53
|
return (
|
89
54
|
<div {...ariaProps}
|
90
55
|
{...dataProps}
|
91
|
-
{...htmlProps}
|
92
56
|
className={classes}
|
93
57
|
id={id}
|
94
58
|
>
|
95
59
|
{children ? (
|
96
60
|
<div
|
97
61
|
onClick={() => toggleDropdown()}
|
98
|
-
onKeyDown= {handleKeyDown}
|
99
62
|
style={{ display: "inline-block" }}
|
100
|
-
tabIndex= {0}
|
101
63
|
>
|
102
64
|
{children}
|
103
65
|
</div>
|
104
66
|
) : (
|
105
67
|
<>
|
106
|
-
<Flex
|
107
|
-
align="center"
|
68
|
+
<Flex align="center"
|
108
69
|
borderRadius="lg"
|
109
|
-
className={
|
110
|
-
cursor=
|
111
|
-
htmlOptions={{
|
112
|
-
onClick: () => handleWrapperClick(),
|
70
|
+
className={`dropdown_trigger_wrapper ${isInputFocused && 'dropdown_trigger_wrapper_focus'}`}
|
71
|
+
cursor="pointer"
|
72
|
+
htmlOptions={{
|
73
|
+
onClick: () => handleWrapperClick(),
|
113
74
|
onKeyDown: handleKeyDown,
|
114
|
-
tabIndex:
|
75
|
+
tabIndex:"0",
|
115
76
|
}}
|
116
77
|
justify="between"
|
117
78
|
paddingX="sm"
|
118
79
|
paddingY="xs"
|
119
80
|
>
|
120
81
|
<FlexItem>
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
82
|
+
<Flex align="center">
|
83
|
+
{customDisplay ? (
|
84
|
+
<Flex align="center">
|
85
|
+
{customDisplay}
|
86
|
+
<Body paddingLeft={`${selected.label ? "xs" : "none"}`}>
|
87
|
+
{selected.label ? <b>{selected.label}</b> : autocomplete ? "" : "Select..." }
|
88
|
+
</Body>
|
89
|
+
</Flex>
|
90
|
+
) : (
|
91
|
+
<Body text={selected.label ? selected.label : autocomplete ? "" : "Select..."} />
|
92
|
+
)
|
93
|
+
}
|
94
|
+
{
|
95
|
+
autocomplete && (
|
96
|
+
<input
|
97
|
+
className="dropdown_input"
|
98
|
+
onChange={handleChange}
|
99
|
+
onClick={() => toggleDropdown()}
|
100
|
+
onFocus={() => setIsInputFocused(true)}
|
101
|
+
onKeyDown={handleKeyDown}
|
102
|
+
placeholder={selected.label ? "" : "Select..."}
|
103
|
+
ref={inputRef}
|
104
|
+
value={filterItem}
|
105
|
+
/>
|
106
|
+
)
|
107
|
+
}
|
108
|
+
|
109
|
+
</Flex>
|
110
|
+
</FlexItem>
|
111
|
+
<FlexItem>
|
112
|
+
<Body display="flex"
|
113
|
+
key={`${isDropDownClosed ? "chevron-down" : 'chevron-up'}`}
|
114
|
+
>
|
115
|
+
<Icon cursor="pointer"
|
116
|
+
icon={`${isDropDownClosed ? "chevron-down" : 'chevron-up'}`}
|
117
|
+
size="sm"
|
118
|
+
/>
|
119
|
+
</Body>
|
151
120
|
</FlexItem>
|
152
|
-
<Body
|
153
|
-
display="flex"
|
154
|
-
htmlOptions={{
|
155
|
-
onClick: (e: Event) => {e.stopPropagation();handleWrapperClick()}
|
156
|
-
}}
|
157
|
-
key={`${isDropDownClosed ? "chevron-down" : "chevron-up"}`}
|
158
|
-
>
|
159
|
-
<Icon
|
160
|
-
cursor="pointer"
|
161
|
-
icon={`${isDropDownClosed ? "chevron-down" : "chevron-up"}`}
|
162
|
-
size="sm"
|
163
|
-
/>
|
164
|
-
</Body>
|
165
121
|
</Flex>
|
166
122
|
</>
|
167
123
|
)}
|
@@ -1,4 +1,9 @@
|
|
1
|
-
<%=
|
1
|
+
<%= content_tag("div",
|
2
|
+
aria: object.aria,
|
3
|
+
class: object.classname,
|
4
|
+
data: object.data,
|
5
|
+
id: object.id,
|
6
|
+
**combined_html_options) do %>
|
2
7
|
<%= pb_rails("form_group", props: {cursor: "pointer", full_width: object.full_width}) do %>
|
3
8
|
<label for="upload-<%= object.id %>" class="pb_button_kit_secondary_inline_enabled"><%= "#{object.label}" %></label>
|
4
9
|
<%= pb_rails("text_input", props: {
|
@@ -1,4 +1,8 @@
|
|
1
|
-
<%=
|
1
|
+
<%= content_tag(:div,
|
2
|
+
id: object.id,
|
3
|
+
data: object.data,
|
4
|
+
class: object.classname,
|
5
|
+
**combined_html_options) do %>
|
2
6
|
<%= object.wrapper do %>
|
3
7
|
<%= pb_rails("flex", props: { orientation: "row", padding_right: "lg", vertical: "center" }) do %>
|
4
8
|
<% if (object.template != "sort_only") %>
|
@@ -1,4 +1,9 @@
|
|
1
|
-
<%=
|
1
|
+
<%= content_tag(:div,
|
2
|
+
aria: object.aria,
|
3
|
+
id: object.id,
|
4
|
+
data: object.data,
|
5
|
+
class: object.classname,
|
6
|
+
**combined_html_options) do %>
|
2
7
|
<%= pb_rails("icon", props: { icon: object.icon_value, classname: "pb_icon", fixed_width: true }) %>
|
3
8
|
|
4
9
|
<% if content %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%=
|
1
|
+
<%= content_tag(:div, id: object.id, data: object.data, class: object.classname + object.size_class, **combined_html_options) 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" }) %>
|