playbook_ui 13.25.0.pre.alpha.PBNTR272Dropdownkitv42769 → 13.25.0.pre.alpha.PBNTR291Dropdownrailsv22812
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_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
@@ -0,0 +1,77 @@
|
|
1
|
+
const OPTION_SELECTOR = "[data-dropdown-option-label]";
|
2
|
+
export class PbDropdownKeyboard {
|
3
|
+
constructor(dropdown) {
|
4
|
+
this.dropdown = dropdown;
|
5
|
+
this.dropdownElement = dropdown.element;
|
6
|
+
this.options = Array.from(
|
7
|
+
this.dropdownElement.querySelectorAll(OPTION_SELECTOR)
|
8
|
+
);
|
9
|
+
this.focusedOptionIndex = -1;
|
10
|
+
this.init();
|
11
|
+
}
|
12
|
+
|
13
|
+
init() {
|
14
|
+
this.dropdownElement.addEventListener(
|
15
|
+
"keydown",
|
16
|
+
this.handleKeyDown.bind(this)
|
17
|
+
);
|
18
|
+
}
|
19
|
+
|
20
|
+
handleKeyDown(event) {
|
21
|
+
switch (event.key) {
|
22
|
+
case "ArrowDown":
|
23
|
+
event.preventDefault();
|
24
|
+
if (!this.dropdown.target.classList.contains("open")) {
|
25
|
+
this.dropdown.showElement(this.dropdown.target);
|
26
|
+
this.dropdown.updateArrowDisplay(true);
|
27
|
+
}
|
28
|
+
this.moveFocus(1);
|
29
|
+
break;
|
30
|
+
case "ArrowUp":
|
31
|
+
event.preventDefault();
|
32
|
+
this.moveFocus(-1);
|
33
|
+
break;
|
34
|
+
case "Enter":
|
35
|
+
event.preventDefault();
|
36
|
+
if (this.focusedOptionIndex !== -1) {
|
37
|
+
this.selectOption();
|
38
|
+
} else {
|
39
|
+
if (!this.dropdown.target.classList.contains("open")) {
|
40
|
+
this.dropdown.showElement(this.dropdown.target);
|
41
|
+
this.dropdown.updateArrowDisplay(true);
|
42
|
+
}
|
43
|
+
}
|
44
|
+
break;
|
45
|
+
case "Escape":
|
46
|
+
this.dropdown.hideElement(this.dropdown.target);
|
47
|
+
break;
|
48
|
+
case "Tab":
|
49
|
+
this.dropdown.hideElement(this.dropdown.target);
|
50
|
+
this.dropdown.updateArrowDisplay(false);
|
51
|
+
this.resetFocus();
|
52
|
+
break;
|
53
|
+
default:
|
54
|
+
break;
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
moveFocus(direction) {
|
59
|
+
if (this.focusedOptionIndex !== -1) {
|
60
|
+
this.options[this.focusedOptionIndex].classList.remove(
|
61
|
+
"pb_dropdown_option_focused"
|
62
|
+
);
|
63
|
+
}
|
64
|
+
this.focusedOptionIndex =
|
65
|
+
(this.focusedOptionIndex + direction + this.options.length) %
|
66
|
+
this.options.length;
|
67
|
+
this.options[this.focusedOptionIndex].classList.add(
|
68
|
+
"pb_dropdown_option_focused"
|
69
|
+
);
|
70
|
+
}
|
71
|
+
|
72
|
+
selectOption() {
|
73
|
+
const option = this.options[this.focusedOptionIndex];
|
74
|
+
this.dropdown.onOptionSelected(option.dataset.dropdownOptionLabel, option);
|
75
|
+
this.dropdown.hideElement(this.dropdown.target);
|
76
|
+
}
|
77
|
+
}
|
@@ -59,20 +59,22 @@ const DropdownOption = (props: DropdownOptionProps) => {
|
|
59
59
|
const isFocused =
|
60
60
|
focusedOptionIndex >= 0 &&
|
61
61
|
filteredOptions[focusedOptionIndex].label === option.label;
|
62
|
-
const focusedClass = isFocused && "
|
62
|
+
const focusedClass = isFocused && "focused";
|
63
63
|
|
64
64
|
const selectedClass = `${
|
65
65
|
selected.label === option.label
|
66
|
-
? "
|
67
|
-
: "
|
66
|
+
? "selected"
|
67
|
+
: "list"
|
68
68
|
}`;
|
69
69
|
const ariaProps = buildAriaProps(aria);
|
70
70
|
const dataProps = buildDataProps(data);
|
71
71
|
const htmlProps = buildHtmlProps(htmlOptions);
|
72
72
|
const classes = classnames(
|
73
|
-
buildCss(
|
74
|
-
|
75
|
-
|
73
|
+
buildCss(
|
74
|
+
"pb_dropdown_option",
|
75
|
+
selectedClass,
|
76
|
+
focusedClass,
|
77
|
+
),
|
76
78
|
globalProps(props, {padding}),
|
77
79
|
className
|
78
80
|
);
|
@@ -96,7 +98,7 @@ const DropdownOption = (props: DropdownOptionProps) => {
|
|
96
98
|
>
|
97
99
|
<Flex
|
98
100
|
align="center"
|
99
|
-
className="
|
101
|
+
className="dropdown_option_wrapper"
|
100
102
|
justify="between"
|
101
103
|
paddingX="sm"
|
102
104
|
paddingY="xxs"
|
@@ -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
|
+
};
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { Flex, ProgressSimple } from '../..'
|
3
|
+
|
4
|
+
const ProgressSimpleFlex = () => {
|
5
|
+
return (
|
6
|
+
<Flex>
|
7
|
+
<ProgressSimple
|
8
|
+
align="left"
|
9
|
+
flex="1"
|
10
|
+
percent={68}
|
11
|
+
/>
|
12
|
+
</Flex>
|
13
|
+
)
|
14
|
+
}
|
15
|
+
|
16
|
+
export default ProgressSimpleFlex
|
@@ -0,0 +1 @@
|
|
1
|
+
When rendering a Progress Simple through within a Flex container, you must pass `flex="1"` to the kit itself so that it fills the available space
|
@@ -3,6 +3,7 @@ examples:
|
|
3
3
|
rails:
|
4
4
|
- progress_simple_default: Default
|
5
5
|
- progress_simple_value: Setting Values
|
6
|
+
- progress_simple_flex: Within a Flex
|
6
7
|
- progress_simple_width: Progress Bar Width
|
7
8
|
- progress_simple_variants: Variants
|
8
9
|
- progress_simple_muted: Muted
|
@@ -12,6 +13,7 @@ examples:
|
|
12
13
|
react:
|
13
14
|
- progress_simple_default: Default
|
14
15
|
- progress_simple_value: Setting Values
|
16
|
+
- progress_simple_flex: Within a Flex
|
15
17
|
- progress_simple_width: Progress Bar Width
|
16
18
|
- progress_simple_variants: Variants
|
17
19
|
- progress_simple_muted: Muted
|
@@ -2,6 +2,7 @@ export { default as ProgressSimpleAlign } from './_progress_simple_align.jsx'
|
|
2
2
|
export { default as ProgressSimpleDefault } from './_progress_simple_default.jsx'
|
3
3
|
export { default as ProgressSimpleMuted } from './_progress_simple_muted.jsx'
|
4
4
|
export { default as ProgressSimpleValue } from './_progress_simple_value.jsx'
|
5
|
+
export { default as ProgressSimpleFlex } from './_progress_simple_flex.jsx'
|
5
6
|
export { default as ProgressSimpleWidth } from './_progress_simple_width.jsx'
|
6
7
|
export { default as ProgressSimpleVariants } from './_progress_simple_variants.jsx'
|
7
8
|
|
@@ -40,6 +40,23 @@
|
|
40
40
|
border: 6px solid $primary;
|
41
41
|
}
|
42
42
|
}
|
43
|
+
|
44
|
+
&:disabled + .pb_radio_button {
|
45
|
+
cursor: not-allowed;
|
46
|
+
background-color: mix($charcoal, $white, 5%);
|
47
|
+
border-color: $border_light;
|
48
|
+
|
49
|
+
& ~ .pb_body_kit {
|
50
|
+
cursor: not-allowed;
|
51
|
+
color: $text_lt_light;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
&:disabled:checked + .pb_radio_button{
|
56
|
+
cursor: not-allowed;
|
57
|
+
background-color: $white;
|
58
|
+
border: 6px solid $neutral;
|
59
|
+
}
|
43
60
|
}
|
44
61
|
|
45
62
|
&[class*=vertical] {
|
@@ -66,6 +83,24 @@
|
|
66
83
|
border: 6px solid $primary;
|
67
84
|
}
|
68
85
|
}
|
86
|
+
|
87
|
+
&:disabled + .pb_radio_button {
|
88
|
+
cursor: not-allowed;
|
89
|
+
background-color: mix($charcoal, $white, 80%);
|
90
|
+
border: 2px solid $border_dark;
|
91
|
+
|
92
|
+
& ~ .pb_body_kit {
|
93
|
+
cursor: not-allowed;
|
94
|
+
color: $text_dk_light;
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
&:disabled:checked {
|
99
|
+
& ~ .pb_radio_button {
|
100
|
+
background-color: mix($charcoal, $white, 80%);
|
101
|
+
border: 6px solid $border_dark;
|
102
|
+
}
|
103
|
+
}
|
69
104
|
}
|
70
105
|
|
71
106
|
@media (hover:hover) {
|
@@ -14,6 +14,7 @@ type RadioProps = {
|
|
14
14
|
className?: string,
|
15
15
|
dark?: boolean,
|
16
16
|
data?: {[key: string]: string},
|
17
|
+
disabled?: boolean,
|
17
18
|
error?: boolean,
|
18
19
|
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
19
20
|
id?: string,
|
@@ -31,6 +32,7 @@ const Radio = ({
|
|
31
32
|
className,
|
32
33
|
dark = false,
|
33
34
|
data = {},
|
35
|
+
disabled = false,
|
34
36
|
error = false,
|
35
37
|
htmlOptions = {},
|
36
38
|
id,
|
@@ -56,6 +58,7 @@ const Radio = ({
|
|
56
58
|
else
|
57
59
|
return (
|
58
60
|
<input
|
61
|
+
disabled={disabled}
|
59
62
|
id={id}
|
60
63
|
name={name}
|
61
64
|
onChange={onChange}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import React from 'react'
|
2
2
|
import { Flex, Radio } from '../../'
|
3
3
|
|
4
|
-
const RadioAlignment = () => {
|
4
|
+
const RadioAlignment = (props) => {
|
5
5
|
return (
|
6
6
|
<Flex>
|
7
7
|
<Radio
|
@@ -11,6 +11,7 @@ const RadioAlignment = () => {
|
|
11
11
|
name="Group2"
|
12
12
|
tabIndex={0}
|
13
13
|
value="Power"
|
14
|
+
{...props}
|
14
15
|
/>
|
15
16
|
<br />
|
16
17
|
<Radio
|
@@ -20,6 +21,7 @@ const RadioAlignment = () => {
|
|
20
21
|
marginRight="sm"
|
21
22
|
name="Group2"
|
22
23
|
value="Nitro"
|
24
|
+
{...props}
|
23
25
|
/>
|
24
26
|
<br />
|
25
27
|
<Radio
|
@@ -28,6 +30,7 @@ const RadioAlignment = () => {
|
|
28
30
|
label="Google"
|
29
31
|
name="Group2"
|
30
32
|
value="Google"
|
33
|
+
{...props}
|
31
34
|
/>
|
32
35
|
</Flex>
|
33
36
|
)
|
@@ -2,7 +2,7 @@ import React from 'react'
|
|
2
2
|
|
3
3
|
import Radio from '../_radio'
|
4
4
|
|
5
|
-
const RadioDefault = () => {
|
5
|
+
const RadioDefault = (props) => {
|
6
6
|
const ref = React.createRef()
|
7
7
|
|
8
8
|
return (
|
@@ -13,6 +13,7 @@ const RadioDefault = () => {
|
|
13
13
|
ref={ref}
|
14
14
|
tabIndex={0}
|
15
15
|
value="Power"
|
16
|
+
{...props}
|
16
17
|
/>
|
17
18
|
<br />
|
18
19
|
<Radio
|
@@ -20,6 +21,7 @@ const RadioDefault = () => {
|
|
20
21
|
label="Nitro"
|
21
22
|
name="Group2"
|
22
23
|
value="Nitro"
|
24
|
+
{...props}
|
23
25
|
/>
|
24
26
|
<br />
|
25
27
|
<Radio
|
@@ -27,6 +29,7 @@ const RadioDefault = () => {
|
|
27
29
|
label="Google"
|
28
30
|
name="Group2"
|
29
31
|
value="Google"
|
32
|
+
{...props}
|
30
33
|
/>
|
31
34
|
</div>
|
32
35
|
)
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<%= pb_rails("flex", props: {orientation: "column"}) do %>
|
2
|
+
<%= pb_rails("flex/flex_item") do %>
|
3
|
+
<%= pb_rails("radio", props: {
|
4
|
+
text: "Disabled unselected",
|
5
|
+
input_options: {
|
6
|
+
tabindex: 0,
|
7
|
+
disabled: true,
|
8
|
+
},
|
9
|
+
margin_bottom: "xs",
|
10
|
+
name: "DisabledGroup",
|
11
|
+
value: "Disabled unselected",
|
12
|
+
}) %>
|
13
|
+
<% end %>
|
14
|
+
<%= pb_rails("flex/flex_item") do %>
|
15
|
+
<%= pb_rails("radio", props: {
|
16
|
+
text: "Disabled selected",
|
17
|
+
input_options: {
|
18
|
+
tabindex: 0,
|
19
|
+
disabled: true,
|
20
|
+
},
|
21
|
+
checked: true,
|
22
|
+
name: "DisabledGroup",
|
23
|
+
value: "Disabled selected"
|
24
|
+
}) %>
|
25
|
+
<% end %>
|
26
|
+
<% end %>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
|
3
|
+
import Radio from '../_radio'
|
4
|
+
|
5
|
+
const RadioDisabled = (props) => {
|
6
|
+
const ref = React.createRef()
|
7
|
+
|
8
|
+
return (
|
9
|
+
<div style={{ display: "flex", flexDirection: "column" }}>
|
10
|
+
<Radio
|
11
|
+
disabled
|
12
|
+
label="Disabled unselected"
|
13
|
+
marginBottom="xs"
|
14
|
+
name="DisabledGroup"
|
15
|
+
ref={ref}
|
16
|
+
tabIndex={0}
|
17
|
+
value="Disabled unselected"
|
18
|
+
{...props}
|
19
|
+
/>
|
20
|
+
<Radio
|
21
|
+
checked
|
22
|
+
disabled
|
23
|
+
label="Disabled selected"
|
24
|
+
name="DisabledGroup"
|
25
|
+
value="Disabled selected"
|
26
|
+
{...props}
|
27
|
+
/>
|
28
|
+
</div>
|
29
|
+
)
|
30
|
+
}
|
31
|
+
export default RadioDisabled
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import React from 'react'
|
2
2
|
import { Radio } from '../..'
|
3
3
|
|
4
|
-
const RadioError = () => {
|
4
|
+
const RadioError = (props) => {
|
5
5
|
return (
|
6
6
|
<div>
|
7
7
|
<Radio
|
@@ -9,6 +9,7 @@ const RadioError = () => {
|
|
9
9
|
label="Power"
|
10
10
|
name="Group2"
|
11
11
|
value="Power"
|
12
|
+
{...props}
|
12
13
|
/>
|
13
14
|
</div>
|
14
15
|
)
|
@@ -6,12 +6,14 @@ examples:
|
|
6
6
|
- radio_error: With Error
|
7
7
|
- radio_options: With Options
|
8
8
|
- radio_alignment: Alignment
|
9
|
+
- radio_disabled: Disabled
|
9
10
|
|
10
11
|
react:
|
11
12
|
- radio_default: Default
|
12
13
|
- radio_custom: Custom
|
13
14
|
- radio_error: With Error
|
14
15
|
- radio_alignment: Alignment
|
16
|
+
- radio_disabled: Disabled
|
15
17
|
|
16
18
|
swift:
|
17
19
|
- radio_default_swift: Default
|
@@ -2,3 +2,4 @@ export { default as RadioDefault } from './_radio_default.jsx'
|
|
2
2
|
export { default as RadioCustom } from './_radio_custom.jsx'
|
3
3
|
export { default as RadioError } from './_radio_error.jsx'
|
4
4
|
export { default as RadioAlignment } from './_radio_alignment.jsx'
|
5
|
+
export { default as RadioDisabled } from './_radio_disabled.jsx'
|
@@ -11,6 +11,7 @@ module Playbook
|
|
11
11
|
default: false
|
12
12
|
prop :error, type: Playbook::Props::Boolean,
|
13
13
|
default: false
|
14
|
+
prop :disabled, type: Playbook::Props::Boolean, default: false
|
14
15
|
prop :input_options, type: Playbook::Props::HashProp,
|
15
16
|
default: {}
|
16
17
|
prop :name, type: Playbook::Props::String,
|
@@ -32,6 +33,10 @@ module Playbook
|
|
32
33
|
error ? "negative" : nil
|
33
34
|
end
|
34
35
|
|
36
|
+
def input
|
37
|
+
radio_button_tag(name, value, checked, input_options.merge(disabled: disabled))
|
38
|
+
end
|
39
|
+
|
35
40
|
private
|
36
41
|
|
37
42
|
def error_class
|
@@ -69,3 +69,20 @@ test('returns dark + error class name', () => {
|
|
69
69
|
const kit = screen.getByTestId(testId)
|
70
70
|
expect(kit).toHaveClass(`${kitClass} dark error`)
|
71
71
|
})
|
72
|
+
|
73
|
+
test('has disabled attribute', () => {
|
74
|
+
render(
|
75
|
+
<Radio
|
76
|
+
data={{ testid: testId }}
|
77
|
+
disabled
|
78
|
+
label="Power"
|
79
|
+
name="Group2"
|
80
|
+
value="Power"
|
81
|
+
/>
|
82
|
+
)
|
83
|
+
|
84
|
+
const kit = screen.getByTestId(testId)
|
85
|
+
const input = kit.querySelector('input')
|
86
|
+
expect(input).toHaveAttribute('disabled')
|
87
|
+
})
|
88
|
+
|