lbp-form-radio.js
2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import './styles/radio.scss'
import commonProps from './common/props.js'
import editorConfigForProps from './common/editor-config-for-configurable-props.js'
export default {
name: 'lbp-form-radio',
props: {
...commonProps,
value: {
type: [String, Number],
default: '标题演示'
},
aliasName: {
type: String,
default: '标题演示'
},
checked: {
type: Boolean,
default: false
},
onFocus: {
type: Function,
default: () => {}
},
onClick: {
type: Function,
default: () => {}
},
onBlur: {
type: Function,
default: () => {}
}
},
editorConfig: {
propsConfig: {
...editorConfigForProps
}
},
methods: {
handleChange (e) {
if (this.disabled) return
this.$emit('change', e.target.value)
}
},
render () {
const {
color,
textAlign,
backgroundColor,
fontSize,
lineHeight,
borderColor,
borderRadius,
borderWidth,
aliasName,
id,
type,
// readOnly, // ?
disabled,
// tabIndex, // ?
checked,
// autoFocus,
value,
vertical
} = this
const style = {
color,
textAlign,
backgroundColor,
fontSize: fontSize,
lineHeight: lineHeight + 'em',
borderColor,
borderRadius: borderRadius + 'px',
borderWidth: borderWidth + 'px',
textDecoration: 'none',
display: vertical ? 'block' : 'inline-block'
}
const checkedClass = checked && 'is-checked'
return (
<label role="radio" tabindex="0" class="lbp-radio" style={style} aria-checked="true">
<span class={'lbp-radio__input' + checkedClass}>
<span class="lbp-radio__inner"></span>
<input
class="lbp-radio__original"
name={aliasName}
id={id}
type={type}
ref="input"
value={value}
disabled={disabled}
checked={!!checked}
onChange={this.handleChange}
// readOnly={readOnly}
// tabIndex={tabIndex}
// className={`${prefixCls}-input`}
// onClick={this.onClick}
// onFocus={this.onFocus}
// onBlur={this.onBlur}
// onInput={this.onInput}
// autoFocus={autoFocus}
// data-type="lbp-form-input"
// {...globalProps}
/>
<span class="lbp-radio__label"><slot>{value}</slot></span>
</span>
</label>
)
}
}