playbook_ui 13.25.0.pre.alpha.PBNTR272Dropdownkitv42769 → 13.25.0.pre.alpha.PBNTR291Dropdownrailsv22812
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_bar_graph/_bar_graph.tsx +1 -1
- 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.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_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_dropdown/_dropdown.scss +41 -58
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +15 -28
- 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 +1 -7
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default.md +1 -1
- 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 +2 -5
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete_and_custom_display.jsx +1 -2
- 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 +1 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display.md +1 -1
- 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.md +1 -1
- 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_trigger.html.erb +47 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_external_control.jsx +1 -4
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx +1 -4
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_label.html.erb +10 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +10 -2
- data/app/pb_kits/playbook/pb_dropdown/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown.html.erb +21 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown.rb +20 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +3 -3
- 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/index.js +154 -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/DropdownOption.tsx +9 -7
- 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_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.rb +1 -1
- 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.rb +5 -0
- data/app/pb_kits/playbook/pb_radio/radio.test.js +17 -0
- data/app/pb_kits/playbook/playbook-rails.js +3 -0
- data/dist/playbook-rails.js +5 -5
- data/lib/playbook/version.rb +1 -1
- metadata +31 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76d5446d59ffafe0e3da366fc35ae5a85ce4965c57204e395724cd9bd4fbd4e2
|
4
|
+
data.tar.gz: b1b7f18e82863f99ff0a7d7d22dd9f0e6b55d78b709f739bf28f6a12a8dc0514
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e64335a9b6dea16cd26759da7db490f4058f962c2f86c2d0ef381fa02be563c684a02774f9797a874bb13694626313277c4089a536c902f8e10f723e5ff07bd0
|
7
|
+
data.tar.gz: a1191a5963dd004a8601ce004476d65d8eaccb94234f4d8289cc46bf21a5a93bd8aa044f80d203904f958bbcc4c1d2c09a861ad3acaa91e7d8375912bb57f2ed
|
@@ -102,7 +102,7 @@ const BarGraph = ({
|
|
102
102
|
max: yAxisMax,
|
103
103
|
opposite: false,
|
104
104
|
title: {
|
105
|
-
text:
|
105
|
+
text: Array.isArray(axisTitle) ? (axisTitle.length > 0 ? axisTitle[0].name : null) : axisTitle,
|
106
106
|
},
|
107
107
|
plotLines: typeof yAxisMin !== 'undefined' && yAxisMin !== null ? [] : [{
|
108
108
|
value: 0,
|
@@ -74,6 +74,31 @@ $transition: $transition_cubic;
|
|
74
74
|
opacity: $opacity_10;
|
75
75
|
}
|
76
76
|
}
|
77
|
+
|
78
|
+
&:disabled ~ .pb_checkbox_checkmark {
|
79
|
+
cursor: not-allowed;
|
80
|
+
background-color: mix($charcoal, $white, 5%);
|
81
|
+
border-color: $border_light;
|
82
|
+
|
83
|
+
& ~ .pb_checkbox_label {
|
84
|
+
cursor: not-allowed;
|
85
|
+
color: $text_lt_light;
|
86
|
+
}
|
87
|
+
& ~ .pb_checkbox_label .pb_body_kit {
|
88
|
+
cursor: not-allowed;
|
89
|
+
color: $text_lt_light;
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
&:disabled:checked ~ .pb_checkbox_checkmark {
|
94
|
+
background-color: $neutral;
|
95
|
+
border-color: $neutral;
|
96
|
+
}
|
97
|
+
|
98
|
+
&:disabled:checked:hover ~ .pb_checkbox_checkmark {
|
99
|
+
background-color: $neutral;
|
100
|
+
border-color: $neutral;
|
101
|
+
}
|
77
102
|
}
|
78
103
|
|
79
104
|
&.dark {
|
@@ -81,6 +106,30 @@ $transition: $transition_cubic;
|
|
81
106
|
&:focus ~ .pb_checkbox_checkmark {
|
82
107
|
box-shadow: 0px 0px 0px 2px $bg_dark_card, 0px 0px 0px 4px $primary;
|
83
108
|
}
|
109
|
+
|
110
|
+
&:disabled ~ .pb_checkbox_checkmark {
|
111
|
+
cursor: not-allowed;
|
112
|
+
background-color: mix($charcoal, $white, 80%);
|
113
|
+
border: 2px solid $border_dark;
|
114
|
+
|
115
|
+
& ~ .pb_checkbox_label {
|
116
|
+
cursor: not-allowed;
|
117
|
+
color: $text_dk_light;
|
118
|
+
}
|
119
|
+
& ~ .pb_checkbox_label .pb_body_kit {
|
120
|
+
cursor: not-allowed;
|
121
|
+
color: $text_dk_light;
|
122
|
+
}
|
123
|
+
}
|
124
|
+
|
125
|
+
&:disabled:checked ~ .pb_checkbox_checkmark {
|
126
|
+
background-color: $border_dark;
|
127
|
+
}
|
128
|
+
|
129
|
+
&:disabled:checked:hover ~ .pb_checkbox_checkmark {
|
130
|
+
background-color: $border_dark;
|
131
|
+
border-color: $border_dark;
|
132
|
+
}
|
84
133
|
}
|
85
134
|
|
86
135
|
@media (hover:hover) {
|
@@ -12,6 +12,7 @@ type CheckboxProps = {
|
|
12
12
|
className?: string,
|
13
13
|
dark?: boolean,
|
14
14
|
data?: {[key: string]: string},
|
15
|
+
disabled?: boolean,
|
15
16
|
error?: boolean,
|
16
17
|
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
17
18
|
id?: string,
|
@@ -31,6 +32,7 @@ const Checkbox = (props: CheckboxProps): React.ReactElement => {
|
|
31
32
|
className,
|
32
33
|
dark = false,
|
33
34
|
data = {},
|
35
|
+
disabled = false,
|
34
36
|
error = false,
|
35
37
|
htmlOptions = {},
|
36
38
|
id,
|
@@ -67,6 +69,7 @@ const Checkbox = (props: CheckboxProps): React.ReactElement => {
|
|
67
69
|
return (
|
68
70
|
<input
|
69
71
|
defaultChecked={checked}
|
72
|
+
disabled={disabled}
|
70
73
|
name={name}
|
71
74
|
onChange={onChange}
|
72
75
|
ref={checkRef}
|
@@ -9,6 +9,7 @@ module Playbook
|
|
9
9
|
prop :text
|
10
10
|
prop :value
|
11
11
|
prop :name
|
12
|
+
prop :disabled, type: Playbook::Props::Boolean, default: false
|
12
13
|
|
13
14
|
prop :input_options, type: Playbook::Props::HashProp,
|
14
15
|
default: {}
|
@@ -26,7 +27,7 @@ module Playbook
|
|
26
27
|
end
|
27
28
|
|
28
29
|
def input
|
29
|
-
check_box_tag(name, value, checked, input_options)
|
30
|
+
check_box_tag(name, value, checked, input_options.merge(disabled: disabled))
|
30
31
|
end
|
31
32
|
|
32
33
|
def checkbox_label_status
|
@@ -92,3 +92,17 @@ test('has checked attribute', () => {
|
|
92
92
|
const kit = screen.getByTestId(testId)
|
93
93
|
expect(kit.getElementsByTagName('input')[0]).toHaveAttribute('checked')
|
94
94
|
})
|
95
|
+
|
96
|
+
test('has disabled attribute', () => {
|
97
|
+
render(
|
98
|
+
<Checkbox
|
99
|
+
data={{ testid: testId }}
|
100
|
+
disabled
|
101
|
+
name="checkbox-name"
|
102
|
+
text="Checkbox"
|
103
|
+
value="check-box value"
|
104
|
+
/>)
|
105
|
+
const kit = screen.getByTestId(testId)
|
106
|
+
const input = kit.querySelector('input')
|
107
|
+
expect(input).toHaveAttribute('disabled')
|
108
|
+
})
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<%= pb_rails("flex", props: {orientation: "column"}) do %>
|
2
|
+
<%= pb_rails("flex/flex_item") do %>
|
3
|
+
<%= pb_rails("checkbox" , props: {
|
4
|
+
input_options: { tabindex: 0 },
|
5
|
+
margin_bottom: "xs",
|
6
|
+
text: "Disabled unchecked",
|
7
|
+
value: "checkbox-value",
|
8
|
+
disabled: true,
|
9
|
+
name: "checkbox-name"
|
10
|
+
}) %>
|
11
|
+
<% end %>
|
12
|
+
<%= pb_rails("flex/flex_item") do %>
|
13
|
+
<%= pb_rails("checkbox" , props: {
|
14
|
+
input_options: { tabindex: 0 },
|
15
|
+
text: "Disabled checked",
|
16
|
+
value: "checkbox-value",
|
17
|
+
disabled: true,
|
18
|
+
checked: true,
|
19
|
+
name: "checkbox-name"
|
20
|
+
}) %>
|
21
|
+
<% end %>
|
22
|
+
<% end %>
|
23
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
|
3
|
+
import Checkbox from '../_checkbox'
|
4
|
+
|
5
|
+
const CheckboxDisabled = (props) => {
|
6
|
+
return (
|
7
|
+
<div style={{ display: "flex", flexDirection: "column" }}>
|
8
|
+
<Checkbox
|
9
|
+
disabled
|
10
|
+
marginBottom="xs"
|
11
|
+
name="default name"
|
12
|
+
tabIndex={0}
|
13
|
+
text="Disabled unchecked"
|
14
|
+
value="default value"
|
15
|
+
{...props}
|
16
|
+
/>
|
17
|
+
<Checkbox
|
18
|
+
checked
|
19
|
+
disabled
|
20
|
+
name="checkbox-name"
|
21
|
+
text="Disabled checked"
|
22
|
+
value="check-box value"
|
23
|
+
{...props}
|
24
|
+
/>
|
25
|
+
</div>
|
26
|
+
)
|
27
|
+
}
|
28
|
+
|
29
|
+
export default CheckboxDisabled
|
@@ -6,6 +6,7 @@ examples:
|
|
6
6
|
- checkbox_error: Default w/ Error
|
7
7
|
- checkbox_options: Checkbox w/ Options
|
8
8
|
- checkbox_indeterminate: Indeterminate Checkbox
|
9
|
+
- checkbox_disabled: Disabled Checkbox
|
9
10
|
|
10
11
|
react:
|
11
12
|
- checkbox_default: Default
|
@@ -13,6 +14,7 @@ examples:
|
|
13
14
|
- checkbox_custom: Custom Checkbox
|
14
15
|
- checkbox_error: Default w/ Error
|
15
16
|
- checkbox_indeterminate: Indeterminate Checkbox
|
17
|
+
- checkbox_disabled: Disabled Checkbox
|
16
18
|
|
17
19
|
swift:
|
18
20
|
- checkbox_default_swift: Default
|
@@ -3,3 +3,4 @@ export { default as CheckboxCustom } from './_checkbox_custom.jsx'
|
|
3
3
|
export { default as CheckboxError } from './_checkbox_error.jsx'
|
4
4
|
export { default as CheckboxChecked } from './_checkbox_checked.jsx'
|
5
5
|
export { default as CheckboxIndeterminate } from './_checkbox_indeterminate.jsx'
|
6
|
+
export { default as CheckboxDisabled } from './_checkbox_disabled.jsx'
|
@@ -1,3 +1,5 @@
|
|
1
1
|
Your change handler function has access to two arguments: `dateStr` and `selectedDates`.
|
2
2
|
|
3
|
-
The first, `dateStr`, is a string of the chosen date. The second, `selectedDates`, is an array of selected date objects. In many use cases `selectedDates` will have only one value but you'll still need to access it from index 0.
|
3
|
+
The first, `dateStr`, is a string of the chosen date. The second, `selectedDates`, is an array of selected date objects. In many use cases `selectedDates` will have only one value but you'll still need to access it from index 0.
|
4
|
+
|
5
|
+
NOTE: On Change does not account for manual input by users, so if your date picker sets `allowInput`, you should use the `onClose` method instead.
|
@@ -1,3 +1,5 @@
|
|
1
1
|
The `onClose` handler function has access to two arguments: `dateStr` and `selectedDates`.
|
2
2
|
|
3
|
-
The first, `dateStr`, is a string of the chosen date. The second, `selectedDates`, is an array of selected date objects. In many use cases `selectedDates` will have only one value but you'll still need to access it from index 0.
|
3
|
+
The first, `dateStr`, is a string of the chosen date. The second, `selectedDates`, is an array of selected date objects. In many use cases `selectedDates` will have only one value but you'll still need to access it from index 0.
|
4
|
+
|
5
|
+
NOTE: `onClose` is the ideal handler function to use when `allowInput` is enabled.
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Because the Quick Pick variant has `allowInput` set to `true` by default, use the `onClose` handler function to access the startDate and endDate values. See the `onClose` example for details.
|
@@ -7,28 +7,11 @@
|
|
7
7
|
@import "../pb_body/body_mixins";
|
8
8
|
@import "../pb_textarea/textarea_mixin";
|
9
9
|
|
10
|
-
@
|
11
|
-
from {
|
12
|
-
opacity: 0;
|
13
|
-
}
|
14
|
-
|
15
|
-
to {
|
16
|
-
opacity: 1;
|
17
|
-
}
|
18
|
-
}
|
19
|
-
@keyframes fadeOut {
|
20
|
-
from {
|
21
|
-
opacity: 1;
|
22
|
-
}
|
23
|
-
|
24
|
-
to {
|
25
|
-
opacity: 0;
|
26
|
-
}
|
27
|
-
}
|
10
|
+
@import "./scss_partials/dropdown_animation";
|
28
11
|
|
29
12
|
.pb_dropdown {
|
30
13
|
.dropdown_wrapper {
|
31
|
-
[class*=dropdown_trigger_wrapper] {
|
14
|
+
[class*="dropdown_trigger_wrapper"] {
|
32
15
|
@include pb_body;
|
33
16
|
border: 1px solid $border_light;
|
34
17
|
background-color: $white;
|
@@ -47,7 +30,6 @@
|
|
47
30
|
.dropdown_input {
|
48
31
|
@include pb_body;
|
49
32
|
border: unset;
|
50
|
-
border-radius: $border_rad_heavier;
|
51
33
|
padding: 0;
|
52
34
|
background-color: $white;
|
53
35
|
&:focus-visible {
|
@@ -55,17 +37,17 @@
|
|
55
37
|
}
|
56
38
|
}
|
57
39
|
&:focus {
|
58
|
-
box-shadow: 0px 0px 0 1px $primary;
|
40
|
+
box-shadow: 0px 0px 0 1px $primary !important;
|
59
41
|
outline: unset;
|
60
42
|
transition: box-shadow 0.15s ease-in-out;
|
61
43
|
}
|
62
|
-
|
63
|
-
&[class*=_select_only] {
|
44
|
+
|
45
|
+
&[class*="_select_only"] {
|
64
46
|
box-shadow: inset 0 -11px 20px rgba($primary, 0.05);
|
65
47
|
}
|
66
48
|
|
67
|
-
&[class*=_focus] {
|
68
|
-
box-shadow: 0px 0px 0 1px $primary;
|
49
|
+
&[class*="_focus"] {
|
50
|
+
box-shadow: 0px 0px 0 1px $primary !important;
|
69
51
|
transition: box-shadow 0.1s ease-in-out;
|
70
52
|
}
|
71
53
|
}
|
@@ -80,34 +62,34 @@
|
|
80
62
|
z-index: $z_1;
|
81
63
|
width: 100%;
|
82
64
|
|
83
|
-
|
65
|
+
[class*="pb_dropdown_option"] {
|
84
66
|
cursor: pointer;
|
85
67
|
&:hover {
|
86
68
|
background-color: $border_light;
|
87
69
|
}
|
88
|
-
}
|
89
|
-
|
90
|
-
.dropdown_option_focused {
|
91
|
-
background-color: $border_light;
|
92
|
-
}
|
93
70
|
|
94
|
-
|
95
|
-
|
96
|
-
|
71
|
+
&[class*="_focused"] {
|
72
|
+
background-color: $border_light;
|
73
|
+
}
|
97
74
|
|
98
|
-
|
99
|
-
|
100
|
-
}
|
101
|
-
.dropdown_option_selected {
|
102
|
-
background-color: $primary;
|
103
|
-
[class^="pb_body"],
|
104
|
-
[class^="pb_title_kit"] {
|
105
|
-
color: $white !important;
|
75
|
+
&[class*="_list"] {
|
76
|
+
border-bottom: 1px solid $border_light;
|
106
77
|
}
|
107
|
-
|
108
|
-
background-color: $primary
|
78
|
+
&[class*="selected"] {
|
79
|
+
background-color: $primary;
|
80
|
+
[class^="pb_body"],
|
81
|
+
[class^="pb_title_kit"] {
|
82
|
+
color: $white !important;
|
83
|
+
}
|
84
|
+
&:hover {
|
85
|
+
background-color: $primary !important;
|
86
|
+
}
|
109
87
|
}
|
110
88
|
}
|
89
|
+
|
90
|
+
.dropdown_option_wrapper {
|
91
|
+
width: 100%;
|
92
|
+
}
|
111
93
|
}
|
112
94
|
.close {
|
113
95
|
display: none;
|
@@ -128,7 +110,7 @@
|
|
128
110
|
|
129
111
|
&.dark {
|
130
112
|
.dropdown_wrapper {
|
131
|
-
[class*=dropdown_trigger_wrapper] {
|
113
|
+
[class*="dropdown_trigger_wrapper"] {
|
132
114
|
@include pb_body_light_dark;
|
133
115
|
background-color: rgba($white, 0.1) !important;
|
134
116
|
background: none;
|
@@ -143,10 +125,9 @@
|
|
143
125
|
[class^="pb_body"] {
|
144
126
|
color: $white;
|
145
127
|
}
|
146
|
-
&[class*=_select_only] {
|
147
|
-
box-shadow: inset 0 -11px 20px rgba($white, 0.05)
|
128
|
+
&[class*="_select_only"] {
|
129
|
+
box-shadow: inset 0 -11px 20px rgba($white, 0.05);
|
148
130
|
}
|
149
|
-
|
150
131
|
.dropdown_input {
|
151
132
|
background-color: unset;
|
152
133
|
color: $white;
|
@@ -157,24 +138,26 @@
|
|
157
138
|
background-color: $bg_dark !important;
|
158
139
|
border-color: rgba($white, 0.15);
|
159
140
|
color: $white;
|
160
|
-
.dropdown_option_list {
|
161
|
-
border-color: rgba($white, 0.15);
|
162
|
-
}
|
163
141
|
[class^="pb_body"],
|
164
142
|
[class^="pb_title_kit"] {
|
165
143
|
color: $white !important;
|
166
144
|
}
|
167
145
|
|
168
|
-
|
146
|
+
[class*="pb_dropdown_option"] {
|
169
147
|
&:hover {
|
170
148
|
background-color: $hover_dark;
|
171
149
|
}
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
150
|
+
|
151
|
+
&[class*="_focused"] {
|
152
|
+
background-color: $hover_dark;
|
153
|
+
}
|
154
|
+
|
155
|
+
&[class*="_list"] {
|
156
|
+
border-color: rgba($white, 0.15);
|
157
|
+
}
|
158
|
+
&[class*="selected"] {
|
159
|
+
background-color: $primary;
|
160
|
+
}
|
178
161
|
}
|
179
162
|
}
|
180
163
|
}
|
@@ -1,27 +1,28 @@
|
|
1
|
-
import React, { useState, useRef, useEffect
|
1
|
+
import React, { useState, useRef, useEffect } from "react";
|
2
2
|
import classnames from "classnames";
|
3
3
|
import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from "../utilities/props";
|
4
4
|
import { globalProps } from "../utilities/globalProps";
|
5
|
+
import { GenericObject } from "../types";
|
5
6
|
|
6
7
|
import Body from "../pb_body/_body";
|
7
8
|
import Caption from "../pb_caption/_caption";
|
8
9
|
|
9
10
|
import DropdownContainer from "./subcomponents/DropdownContainer";
|
11
|
+
import DropdownContext from "./context";
|
10
12
|
import DropdownOption from "./subcomponents/DropdownOption";
|
11
13
|
import DropdownTrigger from "./subcomponents/DropdownTrigger";
|
12
|
-
import DropdownContext from "./context";
|
13
14
|
import useDropdown from "./hooks/useDropdown";
|
14
15
|
|
15
16
|
import {
|
16
17
|
separateChildComponents,
|
17
18
|
prepareSubcomponents,
|
18
|
-
|
19
|
-
|
19
|
+
handleClickOutside,
|
20
|
+
} from "./utilities";
|
20
21
|
|
21
22
|
type DropdownProps = {
|
22
23
|
aria?: { [key: string]: string };
|
23
24
|
autocomplete?: boolean;
|
24
|
-
children?: React.ReactChild[] | React.ReactChild | ReactElement[];
|
25
|
+
children?: React.ReactChild[] | React.ReactChild | React.ReactElement[];
|
25
26
|
className?: string;
|
26
27
|
dark?: boolean;
|
27
28
|
data?: { [key: string]: string };
|
@@ -89,31 +90,17 @@ const Dropdown = (props: DropdownProps) => {
|
|
89
90
|
}
|
90
91
|
}
|
91
92
|
// Handle clicks outside the dropdown
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
shouldClose = false;
|
100
|
-
}
|
101
|
-
targetElement = targetElement.parentElement as HTMLElement;
|
102
|
-
}
|
103
|
-
if (
|
104
|
-
inputWrapperRef.current && !inputWrapperRef.current.contains(e.target) &&
|
105
|
-
(dropdownContainerRef.current && !dropdownContainerRef.current.contains(e.target)) &&
|
106
|
-
shouldClose
|
107
|
-
) {
|
108
|
-
setIsDropDownClosed(true);
|
109
|
-
setFocusedOptionIndex(-1);
|
110
|
-
setIsInputFocused(false);
|
111
|
-
}
|
112
|
-
};
|
93
|
+
const handleClick = handleClickOutside({
|
94
|
+
inputWrapperRef,
|
95
|
+
dropdownContainerRef,
|
96
|
+
setIsDropDownClosed,
|
97
|
+
setFocusedOptionIndex,
|
98
|
+
setIsInputFocused,
|
99
|
+
});
|
113
100
|
|
114
|
-
window.addEventListener("click",
|
101
|
+
window.addEventListener("click", handleClick);
|
115
102
|
return () => {
|
116
|
-
window.removeEventListener("click",
|
103
|
+
window.removeEventListener("click", handleClick);
|
117
104
|
};
|
118
105
|
}, []);
|
119
106
|
|
@@ -1 +1 @@
|
|
1
|
-
`options`
|
1
|
+
The Dropdown kit accepts an `options` array and renders each object from that array as a selectable option within a dropdown container. `options` is a required prop and must be an array of objects. Each object can contain as many key/value pairs as needed but MUST contain 'label' and 'value' as the only required items within each object.
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<%
|
2
|
+
options = [
|
3
|
+
{ label: 'United States', value: 'United States', id: 'us' },
|
4
|
+
{ label: 'Canada', value: 'Canada', id: 'ca' },
|
5
|
+
{ label: 'Pakistan', value: 'Pakistan', id: 'pk' },
|
6
|
+
]
|
7
|
+
|
8
|
+
%>
|
9
|
+
|
10
|
+
<%= pb_rails("dropdown", props: {options: options}) do %>
|
11
|
+
<%= pb_rails("dropdown/dropdown_trigger") %>
|
12
|
+
<%= pb_rails("dropdown/dropdown_container") do %>
|
13
|
+
<% options.each do |option| %>
|
14
|
+
<%= pb_rails("dropdown/dropdown_option", props: {option: option}) %>
|
15
|
+
<% end %>
|
16
|
+
<% end %>
|
17
|
+
<% end %>
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { Dropdown } from '../..'
|
3
|
+
|
4
|
+
const DropdownSubcomponentStructure = (props) => {
|
5
|
+
|
6
|
+
|
7
|
+
const options = [
|
8
|
+
{
|
9
|
+
label: "United States",
|
10
|
+
value: "United States",
|
11
|
+
},
|
12
|
+
{
|
13
|
+
label: "Canada",
|
14
|
+
value: "Canada",
|
15
|
+
},
|
16
|
+
{
|
17
|
+
label: "Pakistan",
|
18
|
+
value: "Pakistan",
|
19
|
+
}
|
20
|
+
];
|
21
|
+
|
22
|
+
|
23
|
+
return (
|
24
|
+
<div>
|
25
|
+
<Dropdown
|
26
|
+
options={options}
|
27
|
+
{...props}
|
28
|
+
>
|
29
|
+
<Dropdown.Trigger/>
|
30
|
+
<Dropdown.Container>
|
31
|
+
{options.map((option) => (
|
32
|
+
<Dropdown.Option key={option.id}
|
33
|
+
option={option}
|
34
|
+
/>
|
35
|
+
))}
|
36
|
+
</Dropdown.Container>
|
37
|
+
</Dropdown>
|
38
|
+
</div>
|
39
|
+
)
|
40
|
+
}
|
41
|
+
|
42
|
+
export default DropdownSubcomponentStructure
|
@@ -0,0 +1,7 @@
|
|
1
|
+
The dropdown comes with the following subcomponents that can be used to achieve various levels of customization:
|
2
|
+
|
3
|
+
`Dropdown. Trigger` / `dropdown/dropdown_trigger`
|
4
|
+
`Dropdown.Container`/ `dropdown/dropdown_container`
|
5
|
+
`Dropdown.Option` / `dropdown/dropdown_option`
|
6
|
+
|
7
|
+
See the code snippet below for a visual on how to use the kit with subcomponents. Each subcomponent allows for GlobalProps in addition to any subcomponent specfic props.
|
@@ -1,9 +1,7 @@
|
|
1
|
-
import React
|
1
|
+
import React from 'react'
|
2
2
|
import { Dropdown, User, Badge, FlexItem } from '../..'
|
3
3
|
|
4
4
|
const DropdownWithAutocomplete = (props) => {
|
5
|
-
// eslint-disable-next-line no-unused-vars
|
6
|
-
const [selectedOption, setSelectedOption] = useState();
|
7
5
|
|
8
6
|
const options = [
|
9
7
|
{
|
@@ -18,7 +16,7 @@ const DropdownWithAutocomplete = (props) => {
|
|
18
16
|
label: "Ramon Ruiz",
|
19
17
|
value: "Ramon Ruiz",
|
20
18
|
territory: "PHL",
|
21
|
-
title: "Senior UX
|
19
|
+
title: "Senior UX Designer",
|
22
20
|
id: "ramon-ruiz",
|
23
21
|
status: "Away"
|
24
22
|
},
|
@@ -44,7 +42,6 @@ const DropdownWithAutocomplete = (props) => {
|
|
44
42
|
return (
|
45
43
|
<div>
|
46
44
|
<Dropdown autocomplete
|
47
|
-
onSelect={(selectedItem) => setSelectedOption(selectedItem)}
|
48
45
|
options={options}
|
49
46
|
{...props}
|
50
47
|
>
|
data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete_and_custom_display.jsx
CHANGED
@@ -2,7 +2,6 @@ import React, { useState } from 'react'
|
|
2
2
|
import { Dropdown, User, Badge, FlexItem, Avatar } from '../..'
|
3
3
|
|
4
4
|
const DropdownWithAutocompleteAndCustomDisplay = (props) => {
|
5
|
-
// eslint-disable-next-line no-unused-vars
|
6
5
|
const [selectedOption, setSelectedOption] = useState();
|
7
6
|
|
8
7
|
const options = [
|
@@ -18,7 +17,7 @@ const DropdownWithAutocompleteAndCustomDisplay = (props) => {
|
|
18
17
|
label: "Ramon Ruiz",
|
19
18
|
value: "Ramon Ruiz",
|
20
19
|
territory: "PHL",
|
21
|
-
title: "Senior UX
|
20
|
+
title: "Senior UX Designer",
|
22
21
|
id: "ramon-ruiz",
|
23
22
|
status: "Away"
|
24
23
|
},
|