playbook_ui 14.2.1.pre.alpha.bugfixforactionrc3663 → 14.2.1.pre.alpha.pbntr373enablekitsforradio3665
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_radio/_radio.tsx +100 -50
- data/app/pb_kits/playbook/pb_radio/docs/_radio_children.jsx +56 -0
- data/app/pb_kits/playbook/pb_radio/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_radio/docs/index.js +1 -0
- data/dist/chunks/_typeahead-DfM3dkuk.js +22 -0
- data/dist/chunks/{_weekday_stacked-Cykj5kLZ.js → _weekday_stacked-ByICVcdC.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +1 -1
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +4 -3
- data/dist/chunks/_typeahead-Cq7RLPBA.js +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa5747ca042dba51edc844b07e00549101cae2c3829c5c96c3aa9f73aea7491e
|
4
|
+
data.tar.gz: 18bf10c5deb6626ad335955cceac2e6d5474efc880fb75e6958ed670e5e620d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfecc78791b9be7bea37131e83dc9711af181361113412768e32d4a050db5dc960201dec5cada82968ae55afe5b1105301fdc563931bf9658a52894ab87cb989
|
7
|
+
data.tar.gz: 10f25895d117d306052e76a930177996a074b34aa04cb810edcf62a20ab1eae9534879f4d8c78a51286b18bd20434094ff6e9b5fcfb6dc3fa983630529e2e7c0
|
@@ -1,28 +1,27 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
import React, { forwardRef } from 'react'
|
1
|
+
import React, { forwardRef, isValidElement, useRef } from 'react'
|
4
2
|
import Body from '../pb_body/_body'
|
3
|
+
import Flex from '../pb_flex/_flex'
|
5
4
|
import classnames from 'classnames'
|
6
5
|
import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../utilities/props'
|
7
6
|
import { globalProps, GlobalProps } from '../utilities/globalProps'
|
8
7
|
|
9
8
|
type RadioProps = {
|
10
|
-
aria?: {[key: string]: string},
|
9
|
+
aria?: { [key: string]: string },
|
11
10
|
alignment?: string,
|
12
11
|
checked?: boolean,
|
13
12
|
children?: React.ReactChild[] | React.ReactChild,
|
14
13
|
className?: string,
|
15
14
|
dark?: boolean,
|
16
|
-
data?: {[key: string]: string},
|
15
|
+
data?: { [key: string]: string },
|
17
16
|
disabled?: boolean,
|
18
17
|
error?: boolean,
|
19
|
-
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
18
|
+
htmlOptions?: { [key: string]: string | number | boolean | (() => void) },
|
20
19
|
id?: string,
|
21
20
|
label: string,
|
22
21
|
name?: string,
|
23
22
|
value?: string,
|
24
23
|
text?: string,
|
25
|
-
onChange: (event: React.FormEvent<HTMLInputElement> | null)=>void,
|
24
|
+
onChange: (event: React.FormEvent<HTMLInputElement> | null) => void,
|
26
25
|
} & GlobalProps
|
27
26
|
|
28
27
|
const Radio = ({
|
@@ -31,9 +30,9 @@ const Radio = ({
|
|
31
30
|
children,
|
32
31
|
className,
|
33
32
|
dark = false,
|
34
|
-
data = {},
|
35
33
|
disabled = false,
|
36
34
|
error = false,
|
35
|
+
data = {},
|
37
36
|
htmlOptions = {},
|
38
37
|
id,
|
39
38
|
label,
|
@@ -42,52 +41,103 @@ const Radio = ({
|
|
42
41
|
value = 'radio_text',
|
43
42
|
onChange = () => { void 0 },
|
44
43
|
...props
|
45
|
-
}: RadioProps, ref: any) => {
|
46
|
-
const
|
47
|
-
|
48
|
-
const
|
44
|
+
}: RadioProps, ref: any ) => {
|
45
|
+
const radioRef = useRef(null);
|
46
|
+
|
47
|
+
const ariaProps = buildAriaProps(aria);
|
48
|
+
const dataProps = buildDataProps(data);
|
49
|
+
const htmlProps = buildHtmlProps(htmlOptions);
|
49
50
|
const classes = classnames(
|
50
|
-
buildCss('pb_radio_kit', alignment
|
51
|
-
dark ? 'dark'
|
51
|
+
buildCss('pb_radio_kit', alignment),
|
52
|
+
dark ? 'dark' : null,
|
53
|
+
error ? 'error' : null,
|
52
54
|
globalProps(props),
|
53
|
-
className
|
55
|
+
className
|
56
|
+
);
|
57
|
+
|
58
|
+
const classesCustom = classnames(
|
59
|
+
dark ? 'dark' : null,
|
60
|
+
error ? 'error' : null,
|
61
|
+
globalProps(props),
|
62
|
+
className
|
63
|
+
);
|
64
|
+
|
65
|
+
const isCustomChild = children && isValidElement(children) && children.type !== 'input';
|
54
66
|
|
55
67
|
const displayRadio = (props: RadioProps & any) => {
|
56
|
-
if (children)
|
57
|
-
return
|
58
|
-
else
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
68
|
+
if (isValidElement(children) && children.type === 'input') {
|
69
|
+
return children;
|
70
|
+
} else if (isCustomChild || !children) {
|
71
|
+
return (
|
72
|
+
<input
|
73
|
+
disabled={disabled}
|
74
|
+
id={id}
|
75
|
+
name={name}
|
76
|
+
onChange={onChange}
|
77
|
+
ref={radioRef}
|
78
|
+
text={text}
|
79
|
+
type="radio"
|
80
|
+
value={value}
|
81
|
+
{...props}
|
82
|
+
/>
|
83
|
+
);
|
84
|
+
}
|
85
|
+
};
|
86
|
+
|
87
|
+
const handleContainerClick = (event: React.MouseEvent<HTMLDivElement, MouseEvent> | undefined) => {
|
88
|
+
if (event) {
|
89
|
+
const target = event.target as HTMLElement;
|
90
|
+
if (
|
91
|
+
target.id === 'pb-radio-children-wrapper' ||
|
92
|
+
target.closest('#pb-radio-children-wrapper')
|
93
|
+
) {
|
94
|
+
radioRef.current?.click();
|
95
|
+
}
|
96
|
+
}
|
97
|
+
};
|
72
98
|
|
73
99
|
return (
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
}
|
100
|
+
isCustomChild ? (
|
101
|
+
<Flex
|
102
|
+
{...ariaProps}
|
103
|
+
{...dataProps}
|
104
|
+
{...htmlProps}
|
105
|
+
align='center'
|
106
|
+
className={classesCustom}
|
107
|
+
cursor='pointer'
|
108
|
+
htmlFor={id}
|
109
|
+
htmlOptions={{
|
110
|
+
onClick: ((event: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
|
111
|
+
handleContainerClick(event);
|
112
|
+
}) as unknown as () => void
|
113
|
+
}}
|
114
|
+
id="radio-container"
|
115
|
+
>
|
116
|
+
<label className={buildCss('pb_radio_kit', alignment)}>
|
117
|
+
<>{displayRadio(props)}</>
|
118
|
+
<span className="pb_radio_button" />
|
119
|
+
</label>
|
120
|
+
<div id="pb-radio-children-wrapper"> {children} </div>
|
121
|
+
</Flex>
|
122
|
+
) : (
|
123
|
+
<label
|
124
|
+
{...ariaProps}
|
125
|
+
{...dataProps}
|
126
|
+
{...htmlProps}
|
127
|
+
className={classes}
|
128
|
+
htmlFor={id}
|
129
|
+
>
|
130
|
+
<>{displayRadio(props)}</>
|
131
|
+
<span className="pb_radio_button" />
|
132
|
+
<Body
|
133
|
+
dark={dark}
|
134
|
+
status={error ? 'negative' : null}
|
135
|
+
text={label}
|
136
|
+
variant={null}
|
137
|
+
/>
|
138
|
+
</label>
|
139
|
+
)
|
140
|
+
);
|
141
|
+
};
|
92
142
|
|
93
|
-
export default forwardRef(Radio)
|
143
|
+
export default forwardRef(Radio);
|
@@ -0,0 +1,56 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import Radio from '../_radio'
|
3
|
+
import Select from '../../pb_select/_select'
|
4
|
+
import Typeahead from '../../pb_typeahead/_typeahead'
|
5
|
+
import Title from '../../pb_title/_title'
|
6
|
+
|
7
|
+
const RadioChildren = (props) => {
|
8
|
+
|
9
|
+
|
10
|
+
const options = [
|
11
|
+
{ label: 'Orange', value: 'Orange' },
|
12
|
+
{ label: 'Red', value: 'Red' },
|
13
|
+
{ label: 'Green', value: 'Green' },
|
14
|
+
{ label: 'Blue', value: 'Blue' },
|
15
|
+
]
|
16
|
+
|
17
|
+
return (
|
18
|
+
<div>
|
19
|
+
<Radio
|
20
|
+
label="Select"
|
21
|
+
name="Group1"
|
22
|
+
tabIndex={0}
|
23
|
+
value="Select"
|
24
|
+
{...props}
|
25
|
+
>
|
26
|
+
<Select
|
27
|
+
minWidth="xs"
|
28
|
+
options={options}
|
29
|
+
/>
|
30
|
+
</Radio>
|
31
|
+
<Radio
|
32
|
+
label="Typeahead"
|
33
|
+
name="Group1"
|
34
|
+
tabIndex={0}
|
35
|
+
value="Typeahead"
|
36
|
+
{...props}
|
37
|
+
>
|
38
|
+
<Typeahead
|
39
|
+
minWidth="xs"
|
40
|
+
options={options}
|
41
|
+
/>
|
42
|
+
</Radio>
|
43
|
+
<br />
|
44
|
+
<Radio
|
45
|
+
defaultChecked={false}
|
46
|
+
label="Typography"
|
47
|
+
name="Group1"
|
48
|
+
value="Typography"
|
49
|
+
{...props}
|
50
|
+
>
|
51
|
+
<Title text="Custom Typography" />
|
52
|
+
</Radio>
|
53
|
+
</div>
|
54
|
+
)
|
55
|
+
}
|
56
|
+
export default RadioChildren
|
@@ -3,3 +3,4 @@ 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
5
|
export { default as RadioDisabled } from './_radio_disabled.jsx'
|
6
|
+
export { default as RadioChildren } from './_radio_children.jsx'
|