playbook_ui 16.10.0.pre.alpha.play3040dropdownkitdisableoptions17375 → 16.10.0.pre.alpha.play300617388
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_advanced_table/Components/CustomCell.tsx +2 -0
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +0 -114
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +4 -13
- data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +0 -6
- data/app/pb_kits/playbook/pb_dropdown/docs/index.js +0 -3
- data/app/pb_kits/playbook/pb_dropdown/dropdown.html.erb +4 -5
- data/app/pb_kits/playbook/pb_dropdown/dropdown.rb +1 -6
- data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +0 -96
- data/app/pb_kits/playbook/pb_dropdown/dropdown_container.html.erb +0 -1
- data/app/pb_kits/playbook/pb_dropdown/dropdown_container.rb +0 -2
- data/app/pb_kits/playbook/pb_dropdown/dropdown_option.html.erb +2 -2
- data/app/pb_kits/playbook/pb_dropdown/dropdown_option.rb +2 -27
- data/app/pb_kits/playbook/pb_dropdown/dropdown_trigger.html.erb +2 -4
- data/app/pb_kits/playbook/pb_dropdown/dropdown_trigger.rb +0 -2
- data/app/pb_kits/playbook/pb_dropdown/hooks/useHandleOnKeydown.tsx +5 -25
- data/app/pb_kits/playbook/pb_dropdown/index.js +1 -51
- data/app/pb_kits/playbook/pb_dropdown/keyboard_accessibility.js +1 -11
- data/app/pb_kits/playbook/pb_dropdown/kit.schema.json +0 -8
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownOption.tsx +4 -15
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownTrigger.tsx +13 -22
- data/app/pb_kits/playbook/pb_icon/_icon.tsx +0 -2
- data/app/pb_kits/playbook/pb_list/item.html.erb +1 -1
- data/app/pb_kits/playbook/pb_popover/docs/_popover_list.html.erb +2 -2
- data/app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb +1 -1
- data/dist/chunks/{_typeahead-B0yIrn2R.js → _typeahead-CdD0-K3_.js} +1 -1
- data/dist/chunks/vendor.js +3 -3
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +3 -11
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_custom_display_disabled_option.html.erb +0 -93
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_custom_display_disabled_option.jsx +0 -127
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_custom_display_disabled_option.md +0 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_disabled.html.erb +0 -10
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_disabled.jsx +0 -37
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_disabled_option.html.erb +0 -10
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_disabled_option.jsx +0 -37
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_disabled_option.md +0 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 136e0ee2c63bf1f23fd2183429e8c8fc0404605fa1a6d6f6d2d8c882f1ad4e6a
|
|
4
|
+
data.tar.gz: fffab17b4fb9c91b864f815426fb816529a2d594fe397aa06119c97bda692aa1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2cde44dd1cb7d345c54c98dcadb251bc7fa396351de68ccda061d1123f1b15ecee076f36174685650b1d6bdca86ead9a9b354d1ddbf29a38c9eb18bc3157c91d
|
|
7
|
+
data.tar.gz: 88e1236b5b9169ba14f7091837040582512da5ed331f8cb9b4e3e7af58d8915fc4ba1ff8813db91dad95bab4054f31686fed8580f22a2afa5cac3b4ba3e68e06
|
|
@@ -84,11 +84,13 @@ export const CustomCell = ({
|
|
|
84
84
|
>
|
|
85
85
|
{row.getIsExpanded() ? (
|
|
86
86
|
<Icon cursor="pointer"
|
|
87
|
+
htmlOptions={{ style: { width: "16.656px", height: "13.328px" } }}
|
|
87
88
|
icon="circle-play"
|
|
88
89
|
rotation={90}
|
|
89
90
|
/>
|
|
90
91
|
) : (
|
|
91
92
|
<Icon cursor="pointer"
|
|
93
|
+
htmlOptions={{ style: { width: "16.656px", height: "13.328px" } }}
|
|
92
94
|
icon="circle-play"
|
|
93
95
|
/>
|
|
94
96
|
)}
|
|
@@ -10,61 +10,6 @@
|
|
|
10
10
|
@import "./scss_partials/dropdown_animation";
|
|
11
11
|
@import "dropdown_mixin";
|
|
12
12
|
|
|
13
|
-
@mixin dropdown-disabled-typography($color) {
|
|
14
|
-
.pb_body_kit,
|
|
15
|
-
.pb_body_kit_default,
|
|
16
|
-
.pb_body_kit_light,
|
|
17
|
-
.pb_body_kit_lighter,
|
|
18
|
-
.pb_body_kit_link,
|
|
19
|
-
.pb_body_kit_success,
|
|
20
|
-
.pb_body_kit_error,
|
|
21
|
-
.pb_body_kit_neutral,
|
|
22
|
-
.pb_body_kit_positive,
|
|
23
|
-
.pb_body_kit_negative,
|
|
24
|
-
.pb_caption_kit,
|
|
25
|
-
.pb_caption_kit_xs,
|
|
26
|
-
.pb_caption_kit_sm,
|
|
27
|
-
.pb_caption_kit_md,
|
|
28
|
-
.pb_caption_kit_base,
|
|
29
|
-
.pb_caption_kit_lg,
|
|
30
|
-
.pb_caption_kit_xl,
|
|
31
|
-
.pb_title_kit,
|
|
32
|
-
.pb_detail_kit,
|
|
33
|
-
.pb_detail_kit_color_light,
|
|
34
|
-
.pb_detail_kit_color_default,
|
|
35
|
-
.pb_detail_kit_color_lighter,
|
|
36
|
-
.pb_detail_kit_color_link,
|
|
37
|
-
.pb_detail_kit_color_error,
|
|
38
|
-
.pb_detail_kit_color_success,
|
|
39
|
-
.pb_link_kit,
|
|
40
|
-
.pb_link_kit_underline,
|
|
41
|
-
a {
|
|
42
|
-
color: $color !important;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
@each $caption-color, $caption-value in $pb_caption_colors {
|
|
47
|
-
.pb_caption_kit_xs_#{$caption-color},
|
|
48
|
-
.pb_caption_kit_sm_#{$caption-color},
|
|
49
|
-
.pb_caption_kit_md_#{$caption-color},
|
|
50
|
-
.pb_caption_kit_base_#{$caption-color},
|
|
51
|
-
.pb_caption_kit_lg_#{$caption-color},
|
|
52
|
-
.pb_caption_kit_xl_#{$caption-color} {
|
|
53
|
-
color: $color !important;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
@each $link-color, $link-value in $pb_link_colors {
|
|
59
|
-
.pb_link_kit_#{$link-color},
|
|
60
|
-
.pb_link_kit_#{$link-color}_underline,
|
|
61
|
-
.pb_link_kit_#{$link-color}_disabled,
|
|
62
|
-
.pb_link_kit_#{$link-color}_underline_disabled {
|
|
63
|
-
color: $color !important;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
13
|
.pb_dropdown_default,
|
|
69
14
|
.pb_dropdown_subtle,
|
|
70
15
|
.pb_dropdown_quickpick,
|
|
@@ -105,17 +50,6 @@
|
|
|
105
50
|
color: $input_text_default;
|
|
106
51
|
}
|
|
107
52
|
}
|
|
108
|
-
|
|
109
|
-
.dropdown_input:disabled {
|
|
110
|
-
background-color: $input_background_disabled;
|
|
111
|
-
color: $input_text_disabled;
|
|
112
|
-
cursor: default;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
.dropdown_input:disabled::placeholder {
|
|
116
|
-
color: $input_text_disabled;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
53
|
&:focus {
|
|
120
54
|
box-shadow: 0px 0px 0 1px $status_border_primary !important;
|
|
121
55
|
outline: unset;
|
|
@@ -211,20 +145,6 @@
|
|
|
211
145
|
}
|
|
212
146
|
}
|
|
213
147
|
}
|
|
214
|
-
|
|
215
|
-
// Disabled state
|
|
216
|
-
&.disabled {
|
|
217
|
-
cursor: not-allowed;
|
|
218
|
-
// background-color: $input_background_disabled;
|
|
219
|
-
color: $input_text_disabled;
|
|
220
|
-
border-color: $input_border_disabled;
|
|
221
|
-
pointer-events: none;
|
|
222
|
-
@include dropdown-disabled-typography($input_text_disabled);
|
|
223
|
-
&:hover,
|
|
224
|
-
&:focus {
|
|
225
|
-
background-color: $input_background_disabled;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
148
|
}
|
|
229
149
|
|
|
230
150
|
.dropdown_option_wrapper {
|
|
@@ -456,40 +376,6 @@
|
|
|
456
376
|
background-color: $primary;
|
|
457
377
|
border-bottom: rgba($white, 0.15);
|
|
458
378
|
}
|
|
459
|
-
|
|
460
|
-
&.disabled {
|
|
461
|
-
cursor: not-allowed;
|
|
462
|
-
background-color: $input_background_disabled_dark;
|
|
463
|
-
color: $input_text_disabled_dark;
|
|
464
|
-
border-color: $input_border_disabled_dark;
|
|
465
|
-
pointer-events: none;
|
|
466
|
-
@include dropdown-disabled-typography($input_text_disabled_dark);
|
|
467
|
-
&:hover,
|
|
468
|
-
&:focus {
|
|
469
|
-
background-color: $input_background_disabled_dark;
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
&.disabled {
|
|
477
|
-
.dropdown_wrapper {
|
|
478
|
-
.dropdown_trigger_wrapper,
|
|
479
|
-
.dropdown_trigger_wrapper_focus,
|
|
480
|
-
.dropdown_trigger_wrapper_focus_select_only,
|
|
481
|
-
.dropdown_trigger_wrapper_select_only {
|
|
482
|
-
background-color: $input_background_disabled;
|
|
483
|
-
box-shadow: none !important;
|
|
484
|
-
cursor: default !important;
|
|
485
|
-
opacity: 0.5;
|
|
486
|
-
pointer-events: none;
|
|
487
|
-
|
|
488
|
-
input {
|
|
489
|
-
background-color: $input_background_disabled;
|
|
490
|
-
color: $input_text_disabled;
|
|
491
|
-
cursor: default !important;
|
|
492
|
-
}
|
|
493
379
|
}
|
|
494
380
|
}
|
|
495
381
|
}
|
|
@@ -93,7 +93,6 @@ type DropdownProps = {
|
|
|
93
93
|
closeOnClick?: "outside" | "inside" | "any";
|
|
94
94
|
constrainHeight?: boolean;
|
|
95
95
|
customQuickPickDates?: CustomQuickPickDates;
|
|
96
|
-
disabled?: boolean;
|
|
97
96
|
formPillProps?: GenericObject;
|
|
98
97
|
dark?: boolean;
|
|
99
98
|
data?: { [key: string]: string };
|
|
@@ -140,7 +139,6 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
|
140
139
|
dark = false,
|
|
141
140
|
data = {},
|
|
142
141
|
defaultValue = {},
|
|
143
|
-
disabled = false,
|
|
144
142
|
error,
|
|
145
143
|
htmlOptions = {},
|
|
146
144
|
id,
|
|
@@ -166,7 +164,6 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
|
166
164
|
const separatorsClass = separators ? '' : 'separators_hidden'
|
|
167
165
|
const classes = classnames(
|
|
168
166
|
buildCss("pb_dropdown", variant, separatorsClass),
|
|
169
|
-
disabled && "disabled",
|
|
170
167
|
globalProps(props),
|
|
171
168
|
className
|
|
172
169
|
);
|
|
@@ -177,7 +174,7 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
|
177
174
|
: (options || []);
|
|
178
175
|
// ----------------------------------------------------------
|
|
179
176
|
|
|
180
|
-
const [isDropDownClosed, setIsDropDownClosed, toggleDropdown] = useDropdown(
|
|
177
|
+
const [isDropDownClosed, setIsDropDownClosed, toggleDropdown] = useDropdown(isClosed);
|
|
181
178
|
|
|
182
179
|
// Use a suffix for the trigger ID to avoid conflict with the outer div's id
|
|
183
180
|
const sanitizeForId = (str: string) =>
|
|
@@ -231,7 +228,6 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
|
231
228
|
|
|
232
229
|
const handleLabelClick = (e: React.MouseEvent) => {
|
|
233
230
|
e.stopPropagation();
|
|
234
|
-
if (disabled) return;
|
|
235
231
|
if (selectId) {
|
|
236
232
|
const trigger = document.getElementById(selectId);
|
|
237
233
|
if (trigger) trigger.focus();
|
|
@@ -273,8 +269,8 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
|
273
269
|
|
|
274
270
|
// dropdown to toggle with external control
|
|
275
271
|
useEffect(() => {
|
|
276
|
-
setIsDropDownClosed(
|
|
277
|
-
}, [
|
|
272
|
+
setIsDropDownClosed(isClosed)
|
|
273
|
+
}, [isClosed])
|
|
278
274
|
|
|
279
275
|
const blankSelectionOption: GenericObject = blankSelection ? [{ label: blankSelection, value: "" }] : [];
|
|
280
276
|
const optionsWithBlankSelection = blankSelectionOption.concat(dropdownOptions);
|
|
@@ -334,14 +330,12 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
|
334
330
|
|
|
335
331
|
|
|
336
332
|
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
337
|
-
if (disabled) return;
|
|
338
333
|
setFilterItem(e.target.value);
|
|
339
334
|
setIsDropDownClosed(false);
|
|
340
335
|
};
|
|
341
336
|
|
|
342
337
|
|
|
343
338
|
const handleOptionClick = (clickedItem: GenericObject) => {
|
|
344
|
-
if (disabled) return;
|
|
345
339
|
const shouldCloseOnClick = closeOnClick === "any" || closeOnClick === "inside";
|
|
346
340
|
|
|
347
341
|
if (multiSelect) {
|
|
@@ -384,13 +378,11 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
|
384
378
|
};
|
|
385
379
|
|
|
386
380
|
const handleWrapperClick = () => {
|
|
387
|
-
if (disabled) return;
|
|
388
381
|
autocomplete && inputRef?.current?.focus();
|
|
389
382
|
toggleDropdown();
|
|
390
383
|
};
|
|
391
384
|
|
|
392
385
|
const handleBackspace = () => {
|
|
393
|
-
if (disabled) return;
|
|
394
386
|
if (multiSelect) {
|
|
395
387
|
setSelected([]);
|
|
396
388
|
onSelect && onSelect([]);
|
|
@@ -510,7 +502,6 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
|
510
502
|
blankSelection,
|
|
511
503
|
clearable,
|
|
512
504
|
dropdownContainerRef,
|
|
513
|
-
disabled,
|
|
514
505
|
error,
|
|
515
506
|
errorId,
|
|
516
507
|
filterItem,
|
|
@@ -573,7 +564,7 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
|
573
564
|
}
|
|
574
565
|
}, 0);
|
|
575
566
|
}}
|
|
576
|
-
onFocus={() =>
|
|
567
|
+
onFocus={() => setIsInputFocused(true)}
|
|
577
568
|
ref={dropdownRef}
|
|
578
569
|
>
|
|
579
570
|
{children ? (
|
|
@@ -6,14 +6,12 @@ examples:
|
|
|
6
6
|
- dropdown_multi_select_with_autocomplete: Multi Select with Autocomplete
|
|
7
7
|
- dropdown_multi_select_display_rails: Multi Select with Form Pill Props
|
|
8
8
|
- dropdown_subtle_variant: Subtle Variant
|
|
9
|
-
- dropdown_disabled_option: Disabled Option
|
|
10
9
|
- dropdown_subcomponent_structure_rails: Subcomponent Structure
|
|
11
10
|
- dropdown_with_autocomplete_with_subcomponents: Autocomplete with Subcomponent Structure
|
|
12
11
|
- dropdown_with_label: With Label
|
|
13
12
|
- dropdown_with_custom_options_rails: Custom Options
|
|
14
13
|
- dropdown_multi_select_with_custom_options: Multi Select with Custom Options
|
|
15
14
|
- dropdown_with_custom_display_rails: Custom Display
|
|
16
|
-
- dropdown_custom_display_disabled_option: Custom Display Disabled Option
|
|
17
15
|
- dropdown_with_custom_trigger_rails: Custom Trigger
|
|
18
16
|
- dropdown_with_search_rails: Custom Trigger Dropdown with Search
|
|
19
17
|
- dropdown_with_custom_padding: Custom Option Padding
|
|
@@ -35,7 +33,6 @@ examples:
|
|
|
35
33
|
- dropdown_quickpick_with_date_pickers_rails: Quick Pick with Date Pickers
|
|
36
34
|
- dropdown_quickpick_with_date_pickers_default_rails: Quick Pick with Date Pickers (Default Value)
|
|
37
35
|
- dropdown_required_indicator: Required Indicator
|
|
38
|
-
- dropdown_disabled: Disabled Input
|
|
39
36
|
- dropdown_custom_event_type: Custom Event Type
|
|
40
37
|
|
|
41
38
|
react:
|
|
@@ -45,12 +42,10 @@ examples:
|
|
|
45
42
|
- dropdown_multi_select_with_autocomplete: Multi Select with Autocomplete
|
|
46
43
|
- dropdown_multi_select_display: Multi Select with Form Pill Props
|
|
47
44
|
- dropdown_subtle_variant: Subtle Variant
|
|
48
|
-
- dropdown_disabled_option: Disabled Option
|
|
49
45
|
- dropdown_subcomponent_structure: Subcomponent Structure
|
|
50
46
|
- dropdown_with_autocomplete_with_subcomponents: Autocomplete with Subcomponent Structure
|
|
51
47
|
- dropdown_with_label: With Label
|
|
52
48
|
- dropdown_with_custom_options: Custom Options
|
|
53
|
-
- dropdown_custom_display_disabled_option: Custom Display Disabled Option
|
|
54
49
|
- dropdown_multi_select_with_custom_options: Multi Select with Custom Options
|
|
55
50
|
- dropdown_with_custom_display: Custom Display
|
|
56
51
|
- dropdown_with_custom_trigger: Custom Trigger
|
|
@@ -76,4 +71,3 @@ examples:
|
|
|
76
71
|
- dropdown_quickpick_custom: Quick Pick Variant (Custom Quick Pick Dates)
|
|
77
72
|
- dropdown_quickpick_with_date_pickers: Quick Pick Variant with Date Pickers
|
|
78
73
|
- dropdown_required_indicator: Required Indicator
|
|
79
|
-
- dropdown_disabled: Disabled Input
|
|
@@ -33,6 +33,3 @@ export { default as DropdownWithClearable } from './_dropdown_with_clearable.jsx
|
|
|
33
33
|
export { default as DropdownWithConstrainHeight } from './_dropdown_with_constrain_height.jsx'
|
|
34
34
|
export { default as DropdownClosingOptions } from './_dropdown_closing_options.jsx'
|
|
35
35
|
export { default as DropdownRequiredIndicator } from "./_dropdown_required_indicator.jsx";
|
|
36
|
-
export { default as DropdownDisabledOption } from "./_dropdown_disabled_option.jsx";
|
|
37
|
-
export { default as DropdownCustomDisplayDisabledOption } from "./_dropdown_custom_display_disabled_option.jsx";
|
|
38
|
-
export { default as DropdownDisabled } from "./_dropdown_disabled.jsx";
|
|
@@ -18,12 +18,11 @@
|
|
|
18
18
|
data-dropdown-selected-option
|
|
19
19
|
name="<%= object.name %><%= '[]' if object.multi_select %>"
|
|
20
20
|
style="display: none"
|
|
21
|
-
<%= object.disabled ? "disabled" : ""%>
|
|
22
21
|
<%= object.required ? "required" : ""%>
|
|
23
22
|
/>
|
|
24
23
|
<% if object.variant == "quickpick" %>
|
|
25
|
-
<input id="<%= object.start_date_id %>" name="<%= object.start_date_name %>" style="display: none"
|
|
26
|
-
<input id="<%= object.end_date_id %>" name="<%= object.end_date_name %>" style="display: none"
|
|
24
|
+
<input id="<%= object.start_date_id %>" name="<%= object.start_date_name %>" style="display: none">
|
|
25
|
+
<input id="<%= object.end_date_id %>" name="<%= object.end_date_name %>" style="display: none">
|
|
27
26
|
<% end %>
|
|
28
27
|
<% if content.present? %>
|
|
29
28
|
<%= content.presence %>
|
|
@@ -31,8 +30,8 @@
|
|
|
31
30
|
<%= pb_rails("body", props: { status: "negative", text: object.error, id: object.error_id, aria: { atomic: "true", live: "polite" }, html_options: { role: "alert" }, dark: object.dark }) %>
|
|
32
31
|
<% end %>
|
|
33
32
|
<% else %>
|
|
34
|
-
<%= pb_rails("dropdown/dropdown_trigger", props: { autocomplete: object.autocomplete,
|
|
35
|
-
<%= pb_rails("dropdown/dropdown_container", props: { searchbar: object.searchbar, constrain_height: object.constrain_height
|
|
33
|
+
<%= pb_rails("dropdown/dropdown_trigger", props: { autocomplete: object.autocomplete, multi_select: object.multi_select, placeholder: object.placeholder, select_id: object.select_id, label: object.label, error_id: object.error_id, error: object.error }) %>
|
|
34
|
+
<%= pb_rails("dropdown/dropdown_container", props: { searchbar: object.searchbar, constrain_height: object.constrain_height }) do %>
|
|
36
35
|
<% if options_with_blank.present? %>
|
|
37
36
|
<% options_with_blank.each do |option| %>
|
|
38
37
|
<%= pb_rails("dropdown/dropdown_option", props: {option: option}) %>
|
|
@@ -18,8 +18,6 @@ module Playbook
|
|
|
18
18
|
default: ""
|
|
19
19
|
prop :custom_quick_pick_dates, type: Playbook::Props::HashProp,
|
|
20
20
|
default: {}
|
|
21
|
-
prop :disabled, type: Playbook::Props::Boolean,
|
|
22
|
-
default: false
|
|
23
21
|
prop :variant, type: Playbook::Props::Enum,
|
|
24
22
|
values: %w[default subtle quickpick],
|
|
25
23
|
default: "default"
|
|
@@ -64,7 +62,6 @@ module Playbook
|
|
|
64
62
|
Hash(prop(:data)).merge(
|
|
65
63
|
pb_dropdown: true,
|
|
66
64
|
pb_dropdown_multi_select: multi_select,
|
|
67
|
-
pb_dropdown_disabled: disabled,
|
|
68
65
|
pb_dropdown_variant: variant,
|
|
69
66
|
pb_dropdown_clearable: clearable,
|
|
70
67
|
pb_dropdown_close_on_click: close_on_click,
|
|
@@ -78,9 +75,7 @@ module Playbook
|
|
|
78
75
|
end
|
|
79
76
|
|
|
80
77
|
def classname
|
|
81
|
-
|
|
82
|
-
classes << " disabled" if disabled
|
|
83
|
-
classes
|
|
78
|
+
generate_classname("pb_dropdown", variant, separators_class)
|
|
84
79
|
end
|
|
85
80
|
|
|
86
81
|
def select_id
|
|
@@ -238,46 +238,6 @@ test('generated custom option', () => {
|
|
|
238
238
|
expect(customOption).toBeInTheDocument()
|
|
239
239
|
})
|
|
240
240
|
|
|
241
|
-
test('disabled custom option does not select and marks child wrapper disabled', () => {
|
|
242
|
-
const onSelect = jest.fn()
|
|
243
|
-
const disabledOptions = [
|
|
244
|
-
{
|
|
245
|
-
label: 'Enabled',
|
|
246
|
-
value: 'enabled',
|
|
247
|
-
id: 'enabled',
|
|
248
|
-
},
|
|
249
|
-
{
|
|
250
|
-
label: 'Disabled',
|
|
251
|
-
value: 'disabled',
|
|
252
|
-
id: 'disabled',
|
|
253
|
-
disabled: true,
|
|
254
|
-
},
|
|
255
|
-
]
|
|
256
|
-
|
|
257
|
-
render(
|
|
258
|
-
<Dropdown
|
|
259
|
-
data={{ testid: testId }}
|
|
260
|
-
onSelect={onSelect}
|
|
261
|
-
options={disabledOptions}
|
|
262
|
-
>
|
|
263
|
-
{disabledOptions.map((option) => (
|
|
264
|
-
<Dropdown.Option key={option.id}
|
|
265
|
-
option={option}
|
|
266
|
-
>
|
|
267
|
-
<span>{option.label}</span>
|
|
268
|
-
</Dropdown.Option>
|
|
269
|
-
))}
|
|
270
|
-
</Dropdown>
|
|
271
|
-
)
|
|
272
|
-
|
|
273
|
-
const disabledChild = screen.getByText('Disabled')
|
|
274
|
-
fireEvent.click(disabledChild)
|
|
275
|
-
|
|
276
|
-
expect(onSelect).not.toHaveBeenCalled()
|
|
277
|
-
expect(disabledChild.parentElement).toHaveClass('dropdown_option_wrapper', 'disabled')
|
|
278
|
-
expect(disabledChild.closest('[aria-disabled="true"]')).toBeInTheDocument()
|
|
279
|
-
})
|
|
280
|
-
|
|
281
241
|
test('generated custom Trigger', () => {
|
|
282
242
|
render (
|
|
283
243
|
<Dropdown
|
|
@@ -872,60 +832,4 @@ describe("quickpick Last Month range when current month is shorter than the prev
|
|
|
872
832
|
expect(formatDate(startDate)).toBe(formatDate(DateTime.getPreviousMonthStartDate(now)))
|
|
873
833
|
expect(formatDate(endDate)).toBe(formatDate(DateTime.getPreviousMonthEndDate(now)))
|
|
874
834
|
})
|
|
875
|
-
})
|
|
876
|
-
|
|
877
|
-
test('disabled prop prevents dropdown from opening', () => {
|
|
878
|
-
render(
|
|
879
|
-
<Dropdown
|
|
880
|
-
data={{ testid: testId }}
|
|
881
|
-
disabled
|
|
882
|
-
options={options}
|
|
883
|
-
/>
|
|
884
|
-
)
|
|
885
|
-
|
|
886
|
-
const kit = screen.getByTestId(testId)
|
|
887
|
-
expect(kit).toHaveClass('disabled')
|
|
888
|
-
|
|
889
|
-
const trigger = kit.querySelector('.dropdown_trigger_wrapper_select_only')
|
|
890
|
-
const container = kit.querySelector('.pb_dropdown_container')
|
|
891
|
-
|
|
892
|
-
fireEvent.click(trigger)
|
|
893
|
-
|
|
894
|
-
expect(container).toHaveClass('close')
|
|
895
|
-
expect(container).not.toHaveClass('open')
|
|
896
|
-
})
|
|
897
|
-
|
|
898
|
-
test('disabled prop prevents dropdown from opening with keyboard', () => {
|
|
899
|
-
render(
|
|
900
|
-
<Dropdown
|
|
901
|
-
data={{ testid: testId }}
|
|
902
|
-
disabled
|
|
903
|
-
options={options}
|
|
904
|
-
/>
|
|
905
|
-
)
|
|
906
|
-
|
|
907
|
-
const kit = screen.getByTestId(testId)
|
|
908
|
-
const trigger = kit.querySelector('.dropdown_trigger_wrapper_select_only')
|
|
909
|
-
const container = kit.querySelector('.pb_dropdown_container')
|
|
910
|
-
|
|
911
|
-
fireEvent.keyDown(trigger, { key: 'Enter' })
|
|
912
|
-
|
|
913
|
-
expect(container).toHaveClass('close')
|
|
914
|
-
expect(container).not.toHaveClass('open')
|
|
915
|
-
})
|
|
916
|
-
|
|
917
|
-
test('disabled prop disables autocomplete input', () => {
|
|
918
|
-
render(
|
|
919
|
-
<Dropdown
|
|
920
|
-
autocomplete
|
|
921
|
-
data={{ testid: testId }}
|
|
922
|
-
disabled
|
|
923
|
-
options={options}
|
|
924
|
-
/>
|
|
925
|
-
)
|
|
926
|
-
|
|
927
|
-
const kit = screen.getByTestId(testId)
|
|
928
|
-
const input = kit.querySelector('.dropdown_input')
|
|
929
|
-
|
|
930
|
-
expect(input).toBeDisabled()
|
|
931
835
|
})
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
<%= pb_content_tag(:div, id: object.
|
|
1
|
+
<%= pb_content_tag(:div, id: object.option[:id]) do %>
|
|
2
2
|
<%= pb_rails("list/item", props: {
|
|
3
3
|
display: "flex",
|
|
4
4
|
justify_content: "center",
|
|
5
5
|
padding:"none",
|
|
6
6
|
cursor: "pointer"
|
|
7
7
|
}) do %>
|
|
8
|
-
<div class="
|
|
8
|
+
<div class="dropdown_option_wrapper">
|
|
9
9
|
<% if content.present? %>
|
|
10
10
|
<%= content.presence %>
|
|
11
11
|
<% else %>
|
|
@@ -7,36 +7,11 @@ module Playbook
|
|
|
7
7
|
prop :id, type: Playbook::Props::String
|
|
8
8
|
|
|
9
9
|
def data
|
|
10
|
-
Hash(prop(:data)).merge(
|
|
11
|
-
"dropdown_option_disabled": disabled,
|
|
12
|
-
"dropdown_option_label": option
|
|
13
|
-
)
|
|
10
|
+
Hash(prop(:data)).merge("dropdown_option_label": option)
|
|
14
11
|
end
|
|
15
12
|
|
|
16
13
|
def classname
|
|
17
|
-
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def disabled
|
|
21
|
-
option_value(:disabled) == true
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def option_id
|
|
25
|
-
option_value(:id)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def option_wrapper_class
|
|
29
|
-
disabled ? "dropdown_option_wrapper disabled" : "dropdown_option_wrapper"
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
private
|
|
33
|
-
|
|
34
|
-
def disabled_class
|
|
35
|
-
disabled ? " disabled" : ""
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def option_value(key)
|
|
39
|
-
option[key] || option[key.to_s]
|
|
14
|
+
generate_classname("pb_dropdown_option", "list")
|
|
40
15
|
end
|
|
41
16
|
end
|
|
42
17
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<%= pb_content_tag do %>
|
|
2
2
|
<% if content.present? %>
|
|
3
|
-
<div style="display: inline-block" tabindex="
|
|
3
|
+
<div style="display: inline-block" tabindex="0" data-dropdown="pb-dropdown-trigger" data-dropdown-custom-trigger aria-invalid="<%= object.error.present? %>"
|
|
4
4
|
<% if object.label.present? %> aria-label="<%= [object.label, object.default_display_placeholder].join(', ') %>"<% end %>
|
|
5
5
|
<% if object.select_id.present? %> id="<%= object.select_id %>"<% end %>
|
|
6
6
|
<% if object.error_id.present? %> aria-describedby="<%= object.error_id %>"<% end %>
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
justify: "between",
|
|
18
18
|
padding_x:"sm",
|
|
19
19
|
padding_y:"xs",
|
|
20
|
-
html_options: { tabindex:
|
|
20
|
+
html_options: { tabindex: "0", "aria-label": object.label.present? ? [object.label, object.default_display_placeholder].join(", ") : nil, "aria-describedby": object.error_id, "aria-invalid": object.error.present?, "data-dropdown": "pb-dropdown-trigger" }
|
|
21
21
|
}) do %>
|
|
22
22
|
<%= pb_rails("flex/flex_item", props: { fixed_size: object.multi_select ? "85%" : "" }) do %>
|
|
23
23
|
<%= pb_rails("flex", props: {align: "center"}) do %>
|
|
@@ -37,7 +37,6 @@
|
|
|
37
37
|
<input
|
|
38
38
|
data-dropdown-autocomplete
|
|
39
39
|
class="dropdown_input"
|
|
40
|
-
<%= object.disabled ? "disabled" : "" %>
|
|
41
40
|
type="text"
|
|
42
41
|
placeholder="<%= object.placeholder || 'Select…' %>"
|
|
43
42
|
autocomplete="off"
|
|
@@ -51,7 +50,6 @@
|
|
|
51
50
|
<input
|
|
52
51
|
data-dropdown-autocomplete
|
|
53
52
|
class="dropdown_input"
|
|
54
|
-
<%= object.disabled ? "disabled" : "" %>
|
|
55
53
|
type="text"
|
|
56
54
|
placeholder="<%= object.placeholder || 'Select…' %>"
|
|
57
55
|
autocomplete="off"
|
|
@@ -11,8 +11,6 @@ module Playbook
|
|
|
11
11
|
prop :custom_display
|
|
12
12
|
prop :autocomplete, type: Playbook::Props::Boolean,
|
|
13
13
|
default: false
|
|
14
|
-
prop :disabled, type: Playbook::Props::Boolean,
|
|
15
|
-
default: false
|
|
16
14
|
prop :multi_select, type: Playbook::Props::Boolean,
|
|
17
15
|
default: false
|
|
18
16
|
prop :select_id, type: Playbook::Props::String
|
|
@@ -15,28 +15,6 @@ const {
|
|
|
15
15
|
setIsDropDownClosed,
|
|
16
16
|
}= useContext(DropdownContext)
|
|
17
17
|
|
|
18
|
-
// Helper function to find next non-disabled option
|
|
19
|
-
const findNextAvailableIndex = (currentIndex: number, direction: 'forward' | 'backward'): number => {
|
|
20
|
-
let nextIndex = currentIndex;
|
|
21
|
-
let attempts = 0;
|
|
22
|
-
|
|
23
|
-
while (attempts < filteredOptions.length) {
|
|
24
|
-
if (direction === 'forward') {
|
|
25
|
-
nextIndex = (nextIndex + 1) % filteredOptions.length;
|
|
26
|
-
} else {
|
|
27
|
-
nextIndex = (nextIndex - 1 + filteredOptions.length) % filteredOptions.length;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (!filteredOptions[nextIndex]?.disabled) {
|
|
31
|
-
return nextIndex;
|
|
32
|
-
}
|
|
33
|
-
attempts++;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// If all options are disabled, return current index
|
|
37
|
-
return currentIndex;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
18
|
return (e: React.KeyboardEvent) => {
|
|
41
19
|
|
|
42
20
|
if (e.key !== "Tab" && autocomplete && selected && selected.label) {
|
|
@@ -47,18 +25,20 @@ const {
|
|
|
47
25
|
case "ArrowDown": {
|
|
48
26
|
e.preventDefault();
|
|
49
27
|
setIsDropDownClosed(false);
|
|
50
|
-
const nextIndex =
|
|
28
|
+
const nextIndex = (focusedOptionIndex + 1) % filteredOptions.length;
|
|
51
29
|
setFocusedOptionIndex(nextIndex);
|
|
52
30
|
break;
|
|
53
31
|
}
|
|
54
32
|
case "ArrowUp": {
|
|
55
33
|
e.preventDefault();
|
|
56
|
-
const nextIndexUp =
|
|
34
|
+
const nextIndexUp =
|
|
35
|
+
(focusedOptionIndex - 1 + filteredOptions.length) %
|
|
36
|
+
filteredOptions.length;
|
|
57
37
|
setFocusedOptionIndex(nextIndexUp);
|
|
58
38
|
break;
|
|
59
39
|
}
|
|
60
40
|
case "Enter":
|
|
61
|
-
if (focusedOptionIndex !== -1
|
|
41
|
+
if (focusedOptionIndex !== -1) {
|
|
62
42
|
e.preventDefault();
|
|
63
43
|
handleOptionClick(filteredOptions[focusedOptionIndex]);
|
|
64
44
|
setFocusedOptionIndex(-1)
|