playbook_ui 14.1.0.pre.alpha.PBNTR462starratingdefaultvalue3582 → 14.1.0.pre.alpha.pbntr373enablekitsforradio3593
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.scss +11 -11
- data/app/pb_kits/playbook/pb_radio/_radio.tsx +100 -50
- data/app/pb_kits/playbook/pb_radio/docs/_radio_children.jsx +51 -0
- data/app/pb_kits/playbook/pb_radio/docs/_radio_default.jsx +1 -1
- 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/app/pb_kits/playbook/pb_star_rating/index.js +0 -10
- data/app/pb_kits/playbook/pb_star_rating/star_rating.rb +1 -3
- data/dist/chunks/_typeahead-CTLaD81v.js +22 -0
- data/dist/chunks/{_weekday_stacked-Cykj5kLZ.js → _weekday_stacked-U-4S3-tB.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 +5 -4
- 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: 3196a7c6aa5e0024e25c8581fe5f40df03e4e21cc9c56c49d0a1ca632526705a
|
4
|
+
data.tar.gz: f7c8bb1d07368d634a75ba43c233bfb38a56806f41b5233736cece0f9a7f94e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88b1dc8797609b61c77cac834ce35550d8a42ab675575b683b266d0b543c763d1f04effee8183793c331e6e4a7d96c53eb7b9b103e1a14d96cd0c4f337767f1b
|
7
|
+
data.tar.gz: 1ea4a1fdd91607e9c6c7af6029f637a48f8b770366ce33e87eb83be9f9672898c09fcac287c1c3478f226efd7c1c3a951c03c8769ee15da4b6560cd5af70e8ed
|
@@ -8,17 +8,17 @@
|
|
8
8
|
display: inline-flex;
|
9
9
|
cursor: pointer;
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
11
|
+
.pb_radio_button{
|
12
|
+
width: 22px;
|
13
|
+
min-width: 22px;
|
14
|
+
height: 22px;
|
15
|
+
box-sizing: border-box;
|
16
|
+
border-radius: 1000px;
|
17
|
+
border: 2px solid $border_light;
|
18
|
+
margin-right: $space_xs;
|
19
|
+
transition: background $transition_default ease, box-shadow $transition_default ease, border-color $transition_default ease;
|
20
|
+
}
|
21
|
+
|
22
22
|
@media (hover:hover) {
|
23
23
|
&:hover .pb_radio_button {
|
24
24
|
background-color: $bg_light;
|
@@ -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
|
46
|
-
const
|
47
|
-
|
48
|
-
const
|
44
|
+
}: RadioProps ) => {
|
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 (children)
|
58
|
-
else
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
68
|
+
if (isValidElement(children) && children.type === 'input') {
|
69
|
+
return React.cloneElement(children, { ...props, ref: radioRef });
|
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 === 'children-wrapper' ||
|
92
|
+
target.closest('#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="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,51 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import Radio from '../_radio'
|
3
|
+
import Typeahead from '../../pb_typeahead/_typeahead'
|
4
|
+
import Dropdown from '../../pb_dropdown/_dropdown'
|
5
|
+
import Title from '../../pb_title/_title'
|
6
|
+
|
7
|
+
const RadioChildren = (props) => {
|
8
|
+
|
9
|
+
|
10
|
+
const options = [
|
11
|
+
{ label: 'Orange', value: '#FFA500' },
|
12
|
+
{ label: 'Red', value: '#FF0000' },
|
13
|
+
{ label: 'Green', value: '#00FF00' },
|
14
|
+
{ label: 'Blue', value: '#0000FF' },
|
15
|
+
]
|
16
|
+
|
17
|
+
return (
|
18
|
+
<div>
|
19
|
+
<Radio
|
20
|
+
label="Power"
|
21
|
+
name="Group2"
|
22
|
+
tabIndex={0}
|
23
|
+
value="Power"
|
24
|
+
{...props}
|
25
|
+
>
|
26
|
+
<Dropdown options={options}/>
|
27
|
+
</Radio>
|
28
|
+
<br />
|
29
|
+
<Radio
|
30
|
+
defaultChecked={false}
|
31
|
+
label="Nitro"
|
32
|
+
name="Group2"
|
33
|
+
value="Nitro"
|
34
|
+
{...props}
|
35
|
+
>
|
36
|
+
<Typeahead options={options} />
|
37
|
+
</Radio>
|
38
|
+
<br />
|
39
|
+
<Radio
|
40
|
+
defaultChecked={false}
|
41
|
+
label="Google"
|
42
|
+
name="Group2"
|
43
|
+
value="Google"
|
44
|
+
{...props}
|
45
|
+
>
|
46
|
+
<Title text="Custom Typography" />
|
47
|
+
</Radio>
|
48
|
+
</div>
|
49
|
+
)
|
50
|
+
}
|
51
|
+
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'
|
@@ -12,7 +12,6 @@ export default class PbStarRating extends PbEnhancedElement {
|
|
12
12
|
connect() {
|
13
13
|
this.addEventListeners()
|
14
14
|
this.handleFormReset()
|
15
|
-
this.setDefaultValue()
|
16
15
|
}
|
17
16
|
|
18
17
|
addEventListeners() {
|
@@ -154,13 +153,4 @@ export default class PbStarRating extends PbEnhancedElement {
|
|
154
153
|
}
|
155
154
|
}
|
156
155
|
}
|
157
|
-
|
158
|
-
setDefaultValue() {
|
159
|
-
const hiddenInput = this.element.querySelector(STAR_RATING_INPUT_DATA_SELECTOR)
|
160
|
-
const defaultValue = hiddenInput.value
|
161
|
-
|
162
|
-
if (defaultValue) {
|
163
|
-
this.updateStarColors(defaultValue)
|
164
|
-
}
|
165
|
-
}
|
166
156
|
}
|
@@ -34,7 +34,6 @@ module Playbook
|
|
34
34
|
default: false
|
35
35
|
prop :input_options, type: Playbook::Props::HashProp,
|
36
36
|
default: {}
|
37
|
-
prop :default_value
|
38
37
|
|
39
38
|
def one_decimal_rating
|
40
39
|
rating.to_f.round(1)
|
@@ -121,8 +120,7 @@ module Playbook
|
|
121
120
|
data: { "pb-star-rating-input": true },
|
122
121
|
name: name,
|
123
122
|
required: required,
|
124
|
-
style: "display: none"
|
125
|
-
value: default_value || ""
|
123
|
+
style: "display: none"
|
126
124
|
)
|
127
125
|
end
|
128
126
|
end
|