sadais-piui 1.2.4-beta2 → 1.2.4-beta5
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.
- package/CHANGELOG.md +512 -512
- package/LICENSE +20 -20
- package/README.md +166 -166
- package/components/pi-action-sheet/index.vue +247 -247
- package/components/pi-badge/index.vue +136 -136
- package/components/pi-bottom-bar/index.vue +139 -139
- package/components/pi-button/index.vue +492 -492
- package/components/pi-calendar/index.vue +178 -178
- package/components/pi-calendar-panel/index.vue +436 -432
- package/components/pi-canvas/index.vue +400 -400
- package/components/pi-card/index.vue +127 -127
- package/components/pi-checkbox/index.vue +345 -345
- package/components/pi-checkbox-group/index.vue +215 -215
- package/components/pi-circle-progress/index.vue +224 -224
- package/components/pi-code-input/index.vue +262 -262
- package/components/pi-count-down/index.vue +245 -245
- package/components/pi-count-up/index.vue +209 -209
- package/components/pi-date-picker/index.vue +366 -366
- package/components/pi-divider/index.vue +109 -109
- package/components/pi-dropdown/components/dropdown-tab.vue +62 -62
- package/components/pi-dropdown/index.vue +316 -316
- package/components/pi-dropdown-item/index.vue +233 -233
- package/components/pi-form/index.vue +237 -237
- package/components/pi-form-item/index.vue +534 -534
- package/components/pi-gap/index.vue +72 -72
- package/components/pi-grid/index.vue +92 -92
- package/components/pi-grid-item/index.vue +220 -220
- package/components/pi-icon/index.vue +147 -147
- package/components/pi-img/index.vue +267 -267
- package/components/pi-img-cropper/canvas.js +112 -112
- package/components/pi-img-cropper/index.vue +357 -357
- package/components/pi-img-cropper/touch.js +163 -163
- package/components/pi-img-cropper/vector.js +34 -34
- package/components/pi-input/index.vue +299 -299
- package/components/pi-line/index.vue +78 -78
- package/components/pi-line-progress/index.vue +198 -198
- package/components/pi-list/index.vue +115 -115
- package/components/pi-list-item/index.vue +331 -331
- package/components/pi-loading/index.vue +188 -188
- package/components/pi-marquee/index.vue +281 -281
- package/components/pi-marquee-item/index.vue +47 -47
- package/components/pi-mask/index.vue +198 -198
- package/components/pi-modal/index.vue +303 -303
- package/components/pi-navbar/index.vue +421 -421
- package/components/pi-notify/index.vue +239 -239
- package/components/pi-number-keyboard/index.vue +189 -189
- package/components/pi-opentype-button/index.vue +501 -501
- package/components/pi-pagination/index.vue +277 -277
- package/components/pi-picker/index.vue +317 -317
- package/components/pi-popup/index.vue +353 -353
- package/components/pi-popup-select/index.vue +291 -291
- package/components/pi-radio/index.vue +387 -387
- package/components/pi-radio-group/index.vue +262 -262
- package/components/pi-rate/index.vue +212 -212
- package/components/pi-regions-select/index.vue +318 -318
- package/components/pi-search/index.vue +351 -351
- package/components/pi-section/index.vue +218 -218
- package/components/pi-select/index.vue +391 -391
- package/components/pi-skeleton/index.vue +280 -280
- package/components/pi-status-bar/index.vue +56 -56
- package/components/pi-stepper/index.vue +394 -394
- package/components/pi-steps/index.vue +299 -299
- package/components/pi-swiper/index.vue +344 -344
- package/components/pi-switch/index.vue +227 -227
- package/components/pi-tabs/index.vue +398 -398
- package/components/pi-upload-img/index.vue +508 -506
- package/components/pi-waterfall/index.vue +130 -130
- package/components/pi-webview/index.vue +82 -82
- package/config/actionSheet.js +25 -25
- package/config/badge.js +9 -9
- package/config/bottomBar.js +11 -11
- package/config/button.js +29 -29
- package/config/calendar.js +19 -19
- package/config/calendarPanel.js +24 -24
- package/config/card.js +8 -8
- package/config/checkbox.js +14 -14
- package/config/checkboxGroup.js +14 -14
- package/config/circleProgress.js +13 -13
- package/config/codeInput.js +12 -12
- package/config/countDown.js +12 -12
- package/config/countUp.js +13 -13
- package/config/datePicker.js +22 -22
- package/config/divider.js +10 -10
- package/config/dropdown.js +21 -21
- package/config/dropdownItem.js +26 -26
- package/config/form.js +27 -27
- package/config/formItem.js +25 -25
- package/config/gap.js +8 -8
- package/config/grid.js +9 -9
- package/config/gridItem.js +12 -12
- package/config/icon.js +11 -11
- package/config/img.js +21 -21
- package/config/imgCropper.js +26 -26
- package/config/index.js +28 -28
- package/config/input.js +25 -25
- package/config/line.js +8 -8
- package/config/lineProgress.js +14 -14
- package/config/list.js +12 -12
- package/config/listItem.js +25 -25
- package/config/loading.js +10 -10
- package/config/marquee.js +8 -8
- package/config/mask.js +12 -12
- package/config/modal.js +36 -36
- package/config/navbar.js +32 -32
- package/config/notify.js +13 -13
- package/config/numberKeyboard.js +21 -21
- package/config/pagination.js +10 -10
- package/config/picker.js +19 -19
- package/config/popup.js +23 -23
- package/config/popupSelect.js +35 -35
- package/config/radio.js +15 -15
- package/config/radioGroup.js +16 -16
- package/config/rate.js +15 -15
- package/config/regionsData.js +58 -58
- package/config/regionsSelect.js +18 -18
- package/config/search.js +27 -27
- package/config/section.js +23 -23
- package/config/select.js +28 -28
- package/config/skeleton.js +13 -13
- package/config/statusBar.js +5 -5
- package/config/stepper.js +19 -19
- package/config/steps.js +19 -19
- package/config/swiper.js +22 -22
- package/config/switch.js +13 -13
- package/config/tabs.js +23 -23
- package/config/uploadImg.js +63 -63
- package/config/waterfall.js +6 -6
- package/index.js +41 -41
- package/mixin/component-custom.js +24 -24
- package/mixin/emitter.js +45 -45
- package/mixin/props-sync.js +65 -65
- package/mixin/value-sync.js +32 -32
- package/mixin/wx-code.js +30 -30
- package/package.json +25 -25
- package/plugins/async-validator.js +1511 -1511
- package/scss/animation.scss +260 -260
- package/scss/icon/icon.scss +594 -594
- package/scss/index.scss +5 -5
- package/scss/mixin.scss +47 -47
- package/tools/index.js +11 -11
|
@@ -1,387 +1,387 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view
|
|
3
|
-
class="pi-radio-wrap"
|
|
4
|
-
:style="[customStyle]"
|
|
5
|
-
:class="[
|
|
6
|
-
getShape,
|
|
7
|
-
getActiveMode,
|
|
8
|
-
{ disabled: getDisable },
|
|
9
|
-
{ active: val },
|
|
10
|
-
{ stretch: getStretch },
|
|
11
|
-
customClass
|
|
12
|
-
]"
|
|
13
|
-
@tap="handleRadioToggle"
|
|
14
|
-
>
|
|
15
|
-
<view v-if="!['text', 'button'].includes(getShape)" class="radio-icon" :style="[radioStyle]">
|
|
16
|
-
<view v-if="getShape === 'dot'" class="dot" />
|
|
17
|
-
<pi-icon v-else name="blod-check" :size="getIconSize" />
|
|
18
|
-
</view>
|
|
19
|
-
<view
|
|
20
|
-
v-if="$slots.default || $slots.$default"
|
|
21
|
-
class="radio-label"
|
|
22
|
-
:class="[getShape]"
|
|
23
|
-
:style="[textStyle]"
|
|
24
|
-
>
|
|
25
|
-
<slot />
|
|
26
|
-
</view>
|
|
27
|
-
</view>
|
|
28
|
-
</template>
|
|
29
|
-
|
|
30
|
-
<script>
|
|
31
|
-
import { childInit } from '../../mixin/props-sync'
|
|
32
|
-
import { getConfig } from '../../config'
|
|
33
|
-
|
|
34
|
-
const TAG = 'PiRadio'
|
|
35
|
-
const { radio } = getConfig()
|
|
36
|
-
const extendRadioGroup = childInit('PiRadioGroup')
|
|
37
|
-
|
|
38
|
-
// Radio组件
|
|
39
|
-
export default {
|
|
40
|
-
name: 'PiRadio',
|
|
41
|
-
// 混入自定义样式customStyle和customClass
|
|
42
|
-
mixins: [extendRadioGroup],
|
|
43
|
-
options: {
|
|
44
|
-
styleIsolation: 'shared'
|
|
45
|
-
},
|
|
46
|
-
props: {
|
|
47
|
-
// 自定义样式,对象形式
|
|
48
|
-
customStyle: {
|
|
49
|
-
type: Object,
|
|
50
|
-
default() {
|
|
51
|
-
// {}
|
|
52
|
-
return radio.customStyle
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
// 自定义样式类,字符串形式
|
|
56
|
-
customClass: {
|
|
57
|
-
type: String,
|
|
58
|
-
// ''
|
|
59
|
-
default() {
|
|
60
|
-
return radio.customClass
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
// radio组件的标示符
|
|
64
|
-
name: {
|
|
65
|
-
type: [String, Number],
|
|
66
|
-
// ''
|
|
67
|
-
default: radio.name
|
|
68
|
-
},
|
|
69
|
-
// 形状
|
|
70
|
-
shape: {
|
|
71
|
-
// 'square', 'round', 'dot', 'text', 'button'
|
|
72
|
-
type: String,
|
|
73
|
-
// 'round'
|
|
74
|
-
default: radio.shape,
|
|
75
|
-
validator: function(value) {
|
|
76
|
-
return ['square', 'round', 'dot', 'text', 'button'].includes(value)
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
// 当shape为square的时候,设置圆角,值为数字时,单位默认rpx
|
|
80
|
-
borderRadius: {
|
|
81
|
-
type: [String, Number],
|
|
82
|
-
// 8
|
|
83
|
-
default: radio.borderRadius
|
|
84
|
-
},
|
|
85
|
-
// 边框大小,传数字时,单位默认rpx
|
|
86
|
-
border: {
|
|
87
|
-
type: [String, Number],
|
|
88
|
-
// 4
|
|
89
|
-
default: radio.border
|
|
90
|
-
},
|
|
91
|
-
// 是否禁用复选框
|
|
92
|
-
disabled: {
|
|
93
|
-
type: Boolean,
|
|
94
|
-
// false
|
|
95
|
-
default: radio.disabled
|
|
96
|
-
},
|
|
97
|
-
// 是否只读模式
|
|
98
|
-
readonly: {
|
|
99
|
-
type: Boolean,
|
|
100
|
-
// false
|
|
101
|
-
default: radio.readonly
|
|
102
|
-
},
|
|
103
|
-
// radio大小,数字时,单位默认rpx
|
|
104
|
-
size: {
|
|
105
|
-
type: [String, Number],
|
|
106
|
-
// 40
|
|
107
|
-
default: radio.size
|
|
108
|
-
},
|
|
109
|
-
// radio icon 大小,数字时,单位默认rpx
|
|
110
|
-
iconSize: {
|
|
111
|
-
type: [String, Number],
|
|
112
|
-
// 24
|
|
113
|
-
default: radio.iconSize
|
|
114
|
-
},
|
|
115
|
-
// 选中时图标的颜色
|
|
116
|
-
activeColor: {
|
|
117
|
-
type: String,
|
|
118
|
-
// ''
|
|
119
|
-
default: radio.activeColor
|
|
120
|
-
},
|
|
121
|
-
// 激活模式
|
|
122
|
-
activeMode: {
|
|
123
|
-
// `'line'-线框模式` `line-circle - 线环模式(无中间打钩和圆点)` `'fill'-实底模式`
|
|
124
|
-
type: String,
|
|
125
|
-
// 'line'
|
|
126
|
-
default: radio.activeMode,
|
|
127
|
-
validator: function(value) {
|
|
128
|
-
return ['line', 'line-circle', 'fill', 'fill-circle'].includes(value)
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
// 能否取消选中状态
|
|
132
|
-
canCancel: {
|
|
133
|
-
type: Boolean,
|
|
134
|
-
// false
|
|
135
|
-
default: radio.canCancel
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
data() {
|
|
139
|
-
return {}
|
|
140
|
-
},
|
|
141
|
-
computed: {
|
|
142
|
-
val() {
|
|
143
|
-
const radioGroupValue = this.inheritProps.val
|
|
144
|
-
return radioGroupValue === this.name
|
|
145
|
-
},
|
|
146
|
-
getShape() {
|
|
147
|
-
return this.inheritProps.shape || this.shape
|
|
148
|
-
},
|
|
149
|
-
getStretch() {
|
|
150
|
-
return this.inheritProps.stretch
|
|
151
|
-
},
|
|
152
|
-
getBorderRadius() {
|
|
153
|
-
return this._parent && this._parent.borderRadius
|
|
154
|
-
? this.$pi.common.addUnit(this._parent.borderRadius)
|
|
155
|
-
: this.$pi.common.addUnit(this.borderRadius)
|
|
156
|
-
},
|
|
157
|
-
getBorder() {
|
|
158
|
-
return this.inheritProps.border
|
|
159
|
-
? this.$pi.common.addUnit(this.inheritProps.border)
|
|
160
|
-
: this.$pi.common.addUnit(this.border)
|
|
161
|
-
},
|
|
162
|
-
getDisable() {
|
|
163
|
-
return this.inheritProps.disabled || this.disabled
|
|
164
|
-
},
|
|
165
|
-
getActiveMode() {
|
|
166
|
-
return this.inheritProps.activeMode || this.activeMode
|
|
167
|
-
},
|
|
168
|
-
getActiveColor() {
|
|
169
|
-
return this.inheritProps.activeColor || this.activeColor
|
|
170
|
-
},
|
|
171
|
-
getSize() {
|
|
172
|
-
return this.inheritProps.size
|
|
173
|
-
? this.$pi.common.addUnit(this.inheritProps.size)
|
|
174
|
-
: this.$pi.common.addUnit(this.size)
|
|
175
|
-
},
|
|
176
|
-
getIconSize() {
|
|
177
|
-
return this.inheritProps.iconSize
|
|
178
|
-
? this.$pi.common.addUnit(this.inheritProps.iconSize)
|
|
179
|
-
: this.$pi.common.addUnit(this.iconSize)
|
|
180
|
-
},
|
|
181
|
-
getCanCancel() {
|
|
182
|
-
return this.inheritProps.canCancel !== null ? this.inheritProps.canCancel : this.canCancel
|
|
183
|
-
},
|
|
184
|
-
radioStyle() {
|
|
185
|
-
const style = {
|
|
186
|
-
width: this.getSize,
|
|
187
|
-
height: this.getSize,
|
|
188
|
-
borderRadius: this.getBorderRadius,
|
|
189
|
-
borderWidth: this.getBorder
|
|
190
|
-
}
|
|
191
|
-
if (['round', 'dot'].includes(this.getShape)) {
|
|
192
|
-
style.borderRadius = '50%'
|
|
193
|
-
}
|
|
194
|
-
if (this.getActiveColor && this.val) {
|
|
195
|
-
style.borderColor = this.getActiveColor
|
|
196
|
-
if (this.getActiveMode === 'line') {
|
|
197
|
-
style.color = this.getActiveColor
|
|
198
|
-
} else {
|
|
199
|
-
style.backgroundColor = this.getActiveColor
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
return style
|
|
203
|
-
},
|
|
204
|
-
textStyle() {
|
|
205
|
-
const style = {
|
|
206
|
-
borderRadius: this.getBorderRadius,
|
|
207
|
-
borderWidth: this.getBorder
|
|
208
|
-
}
|
|
209
|
-
if (this.getActiveColor && this.val) {
|
|
210
|
-
style.borderColor = this.getActiveColor
|
|
211
|
-
if (['text', 'button'].includes(this.getShape) && this.getActiveMode === 'fill') {
|
|
212
|
-
style.backgroundColor = this.getActiveColor
|
|
213
|
-
} else {
|
|
214
|
-
style.color = this.getActiveColor
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
if (this.getShape === 'button' && this.getActiveMode === 'fill') {
|
|
218
|
-
if (!this.val) {
|
|
219
|
-
style.color = this.getActiveColor
|
|
220
|
-
}
|
|
221
|
-
style.borderColor = this.getActiveColor
|
|
222
|
-
}
|
|
223
|
-
if (this.getActiveColor && this.getShape === 'button' && this.val) {
|
|
224
|
-
style.boxShadow = `-${this.getBorder} 0 0 0 ${this.getActiveColor}`
|
|
225
|
-
}
|
|
226
|
-
return style
|
|
227
|
-
}
|
|
228
|
-
},
|
|
229
|
-
methods: {
|
|
230
|
-
handleRadioToggle() {
|
|
231
|
-
if (this.getDisable) return
|
|
232
|
-
if (this.readonly) return
|
|
233
|
-
this._parent && this._parent.emitChange(this.name)
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
</script>
|
|
238
|
-
|
|
239
|
-
<style lang="scss" scoped>
|
|
240
|
-
$disable-color: #c8c9cc;
|
|
241
|
-
$unactive-color: #cccccc;
|
|
242
|
-
|
|
243
|
-
.pi-radio-wrap {
|
|
244
|
-
display: inline-flex;
|
|
245
|
-
align-items: center;
|
|
246
|
-
.radio-icon {
|
|
247
|
-
position: relative;
|
|
248
|
-
display: inline-flex;
|
|
249
|
-
align-items: center;
|
|
250
|
-
justify-content: center;
|
|
251
|
-
overflow: hidden;
|
|
252
|
-
color: $unactive-color;
|
|
253
|
-
border: 4rpx solid $disable-color;
|
|
254
|
-
transition: all $pi-animation-duration $pi-animation-timing-function;
|
|
255
|
-
.dot {
|
|
256
|
-
display: inline-flex;
|
|
257
|
-
width: 50%;
|
|
258
|
-
height: 50%;
|
|
259
|
-
border-radius: 50%;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
::v-deep pi-icon {
|
|
263
|
-
display: inline-flex;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
&.line-circle,
|
|
267
|
-
&.fill-circle {
|
|
268
|
-
.radio-icon {
|
|
269
|
-
color: transparent;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
.radio-label {
|
|
273
|
-
flex: 1;
|
|
274
|
-
margin-left: 16rpx;
|
|
275
|
-
line-height: 1.5;
|
|
276
|
-
word-wrap: break-word;
|
|
277
|
-
transition: $pi-animation-duration $pi-animation-timing-function;
|
|
278
|
-
transition-property: border, color, background-color;
|
|
279
|
-
&.text {
|
|
280
|
-
padding: 12rpx 24rpx;
|
|
281
|
-
margin-left: 0;
|
|
282
|
-
color: $unactive-color;
|
|
283
|
-
border-color: transparent;
|
|
284
|
-
border-style: solid;
|
|
285
|
-
}
|
|
286
|
-
&.button {
|
|
287
|
-
padding: 24rpx;
|
|
288
|
-
margin-left: 0;
|
|
289
|
-
line-height: 1;
|
|
290
|
-
color: $unactive-color;
|
|
291
|
-
border-color: transparent;
|
|
292
|
-
border-style: solid;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
&.stretch {
|
|
296
|
-
.radio-label {
|
|
297
|
-
display: flex;
|
|
298
|
-
align-items: center;
|
|
299
|
-
justify-content: center;
|
|
300
|
-
height: 84rpx;
|
|
301
|
-
padding: 0;
|
|
302
|
-
text-align: center;
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
&.disabled {
|
|
306
|
-
cursor: not-allowed;
|
|
307
|
-
.radio-icon {
|
|
308
|
-
opacity: $pi-disabled-opacity;
|
|
309
|
-
}
|
|
310
|
-
.radio-label {
|
|
311
|
-
color: $unactive-color;
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
&.line {
|
|
315
|
-
.radio-label.text {
|
|
316
|
-
border-color: $unactive-color;
|
|
317
|
-
}
|
|
318
|
-
.radio-label.button {
|
|
319
|
-
border-color: $unactive-color;
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
&.fill {
|
|
323
|
-
.radio-icon {
|
|
324
|
-
color: #ffffff;
|
|
325
|
-
background-color: $unactive-color;
|
|
326
|
-
border-color: $unactive-color;
|
|
327
|
-
.dot {
|
|
328
|
-
background-color: #ffffff;
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
.radio-label.text {
|
|
332
|
-
color: #ffffff;
|
|
333
|
-
background: $unactive-color;
|
|
334
|
-
}
|
|
335
|
-
.radio-label.button {
|
|
336
|
-
color: $pi-primary-color;
|
|
337
|
-
border-color: $pi-primary-color;
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
&.active {
|
|
341
|
-
.radio-label {
|
|
342
|
-
color: $pi-primary-color;
|
|
343
|
-
&.button {
|
|
344
|
-
box-shadow: -4rpx 0 0 0 $pi-primary-color;
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
&.line,
|
|
348
|
-
&.line-circle {
|
|
349
|
-
.radio-icon {
|
|
350
|
-
color: $pi-primary-color;
|
|
351
|
-
background-color: #ffffff;
|
|
352
|
-
border-color: $pi-primary-color;
|
|
353
|
-
.dot {
|
|
354
|
-
background-color: $pi-primary-color;
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
.radio-label.text {
|
|
358
|
-
color: $pi-primary-color;
|
|
359
|
-
border-color: $pi-primary-color;
|
|
360
|
-
}
|
|
361
|
-
.radio-label.button {
|
|
362
|
-
color: $pi-primary-color;
|
|
363
|
-
border-color: $pi-primary-color;
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
&.fill,
|
|
367
|
-
&.fill-circle {
|
|
368
|
-
.radio-icon {
|
|
369
|
-
color: #ffffff;
|
|
370
|
-
background: $pi-primary-color;
|
|
371
|
-
border-color: $pi-primary-color;
|
|
372
|
-
.dot {
|
|
373
|
-
background-color: #ffffff;
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
.radio-label.text {
|
|
377
|
-
color: #ffffff;
|
|
378
|
-
background: $pi-primary-color;
|
|
379
|
-
}
|
|
380
|
-
.radio-label.button {
|
|
381
|
-
color: #ffffff;
|
|
382
|
-
background: $pi-primary-color;
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
class="pi-radio-wrap"
|
|
4
|
+
:style="[customStyle]"
|
|
5
|
+
:class="[
|
|
6
|
+
getShape,
|
|
7
|
+
getActiveMode,
|
|
8
|
+
{ disabled: getDisable },
|
|
9
|
+
{ active: val },
|
|
10
|
+
{ stretch: getStretch },
|
|
11
|
+
customClass
|
|
12
|
+
]"
|
|
13
|
+
@tap="handleRadioToggle"
|
|
14
|
+
>
|
|
15
|
+
<view v-if="!['text', 'button'].includes(getShape)" class="radio-icon" :style="[radioStyle]">
|
|
16
|
+
<view v-if="getShape === 'dot'" class="dot" />
|
|
17
|
+
<pi-icon v-else name="blod-check" :size="getIconSize" />
|
|
18
|
+
</view>
|
|
19
|
+
<view
|
|
20
|
+
v-if="$slots.default || $slots.$default"
|
|
21
|
+
class="radio-label"
|
|
22
|
+
:class="[getShape]"
|
|
23
|
+
:style="[textStyle]"
|
|
24
|
+
>
|
|
25
|
+
<slot />
|
|
26
|
+
</view>
|
|
27
|
+
</view>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<script>
|
|
31
|
+
import { childInit } from '../../mixin/props-sync'
|
|
32
|
+
import { getConfig } from '../../config'
|
|
33
|
+
|
|
34
|
+
const TAG = 'PiRadio'
|
|
35
|
+
const { radio } = getConfig()
|
|
36
|
+
const extendRadioGroup = childInit('PiRadioGroup')
|
|
37
|
+
|
|
38
|
+
// Radio组件
|
|
39
|
+
export default {
|
|
40
|
+
name: 'PiRadio',
|
|
41
|
+
// 混入自定义样式customStyle和customClass
|
|
42
|
+
mixins: [extendRadioGroup],
|
|
43
|
+
options: {
|
|
44
|
+
styleIsolation: 'shared'
|
|
45
|
+
},
|
|
46
|
+
props: {
|
|
47
|
+
// 自定义样式,对象形式
|
|
48
|
+
customStyle: {
|
|
49
|
+
type: Object,
|
|
50
|
+
default() {
|
|
51
|
+
// {}
|
|
52
|
+
return radio.customStyle
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
// 自定义样式类,字符串形式
|
|
56
|
+
customClass: {
|
|
57
|
+
type: String,
|
|
58
|
+
// ''
|
|
59
|
+
default() {
|
|
60
|
+
return radio.customClass
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
// radio组件的标示符
|
|
64
|
+
name: {
|
|
65
|
+
type: [String, Number],
|
|
66
|
+
// ''
|
|
67
|
+
default: radio.name
|
|
68
|
+
},
|
|
69
|
+
// 形状
|
|
70
|
+
shape: {
|
|
71
|
+
// 'square', 'round', 'dot', 'text', 'button'
|
|
72
|
+
type: String,
|
|
73
|
+
// 'round'
|
|
74
|
+
default: radio.shape,
|
|
75
|
+
validator: function(value) {
|
|
76
|
+
return ['square', 'round', 'dot', 'text', 'button'].includes(value)
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
// 当shape为square的时候,设置圆角,值为数字时,单位默认rpx
|
|
80
|
+
borderRadius: {
|
|
81
|
+
type: [String, Number],
|
|
82
|
+
// 8
|
|
83
|
+
default: radio.borderRadius
|
|
84
|
+
},
|
|
85
|
+
// 边框大小,传数字时,单位默认rpx
|
|
86
|
+
border: {
|
|
87
|
+
type: [String, Number],
|
|
88
|
+
// 4
|
|
89
|
+
default: radio.border
|
|
90
|
+
},
|
|
91
|
+
// 是否禁用复选框
|
|
92
|
+
disabled: {
|
|
93
|
+
type: Boolean,
|
|
94
|
+
// false
|
|
95
|
+
default: radio.disabled
|
|
96
|
+
},
|
|
97
|
+
// 是否只读模式
|
|
98
|
+
readonly: {
|
|
99
|
+
type: Boolean,
|
|
100
|
+
// false
|
|
101
|
+
default: radio.readonly
|
|
102
|
+
},
|
|
103
|
+
// radio大小,数字时,单位默认rpx
|
|
104
|
+
size: {
|
|
105
|
+
type: [String, Number],
|
|
106
|
+
// 40
|
|
107
|
+
default: radio.size
|
|
108
|
+
},
|
|
109
|
+
// radio icon 大小,数字时,单位默认rpx
|
|
110
|
+
iconSize: {
|
|
111
|
+
type: [String, Number],
|
|
112
|
+
// 24
|
|
113
|
+
default: radio.iconSize
|
|
114
|
+
},
|
|
115
|
+
// 选中时图标的颜色
|
|
116
|
+
activeColor: {
|
|
117
|
+
type: String,
|
|
118
|
+
// ''
|
|
119
|
+
default: radio.activeColor
|
|
120
|
+
},
|
|
121
|
+
// 激活模式
|
|
122
|
+
activeMode: {
|
|
123
|
+
// `'line'-线框模式` `line-circle - 线环模式(无中间打钩和圆点)` `'fill'-实底模式`
|
|
124
|
+
type: String,
|
|
125
|
+
// 'line'
|
|
126
|
+
default: radio.activeMode,
|
|
127
|
+
validator: function(value) {
|
|
128
|
+
return ['line', 'line-circle', 'fill', 'fill-circle'].includes(value)
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
// 能否取消选中状态
|
|
132
|
+
canCancel: {
|
|
133
|
+
type: Boolean,
|
|
134
|
+
// false
|
|
135
|
+
default: radio.canCancel
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
data() {
|
|
139
|
+
return {}
|
|
140
|
+
},
|
|
141
|
+
computed: {
|
|
142
|
+
val() {
|
|
143
|
+
const radioGroupValue = this.inheritProps.val
|
|
144
|
+
return radioGroupValue === this.name
|
|
145
|
+
},
|
|
146
|
+
getShape() {
|
|
147
|
+
return this.inheritProps.shape || this.shape
|
|
148
|
+
},
|
|
149
|
+
getStretch() {
|
|
150
|
+
return this.inheritProps.stretch
|
|
151
|
+
},
|
|
152
|
+
getBorderRadius() {
|
|
153
|
+
return this._parent && this._parent.borderRadius
|
|
154
|
+
? this.$pi.common.addUnit(this._parent.borderRadius)
|
|
155
|
+
: this.$pi.common.addUnit(this.borderRadius)
|
|
156
|
+
},
|
|
157
|
+
getBorder() {
|
|
158
|
+
return this.inheritProps.border
|
|
159
|
+
? this.$pi.common.addUnit(this.inheritProps.border)
|
|
160
|
+
: this.$pi.common.addUnit(this.border)
|
|
161
|
+
},
|
|
162
|
+
getDisable() {
|
|
163
|
+
return this.inheritProps.disabled || this.disabled
|
|
164
|
+
},
|
|
165
|
+
getActiveMode() {
|
|
166
|
+
return this.inheritProps.activeMode || this.activeMode
|
|
167
|
+
},
|
|
168
|
+
getActiveColor() {
|
|
169
|
+
return this.inheritProps.activeColor || this.activeColor
|
|
170
|
+
},
|
|
171
|
+
getSize() {
|
|
172
|
+
return this.inheritProps.size
|
|
173
|
+
? this.$pi.common.addUnit(this.inheritProps.size)
|
|
174
|
+
: this.$pi.common.addUnit(this.size)
|
|
175
|
+
},
|
|
176
|
+
getIconSize() {
|
|
177
|
+
return this.inheritProps.iconSize
|
|
178
|
+
? this.$pi.common.addUnit(this.inheritProps.iconSize)
|
|
179
|
+
: this.$pi.common.addUnit(this.iconSize)
|
|
180
|
+
},
|
|
181
|
+
getCanCancel() {
|
|
182
|
+
return this.inheritProps.canCancel !== null ? this.inheritProps.canCancel : this.canCancel
|
|
183
|
+
},
|
|
184
|
+
radioStyle() {
|
|
185
|
+
const style = {
|
|
186
|
+
width: this.getSize,
|
|
187
|
+
height: this.getSize,
|
|
188
|
+
borderRadius: this.getBorderRadius,
|
|
189
|
+
borderWidth: this.getBorder
|
|
190
|
+
}
|
|
191
|
+
if (['round', 'dot'].includes(this.getShape)) {
|
|
192
|
+
style.borderRadius = '50%'
|
|
193
|
+
}
|
|
194
|
+
if (this.getActiveColor && this.val) {
|
|
195
|
+
style.borderColor = this.getActiveColor
|
|
196
|
+
if (this.getActiveMode === 'line') {
|
|
197
|
+
style.color = this.getActiveColor
|
|
198
|
+
} else {
|
|
199
|
+
style.backgroundColor = this.getActiveColor
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return style
|
|
203
|
+
},
|
|
204
|
+
textStyle() {
|
|
205
|
+
const style = {
|
|
206
|
+
borderRadius: this.getBorderRadius,
|
|
207
|
+
borderWidth: this.getBorder
|
|
208
|
+
}
|
|
209
|
+
if (this.getActiveColor && this.val) {
|
|
210
|
+
style.borderColor = this.getActiveColor
|
|
211
|
+
if (['text', 'button'].includes(this.getShape) && this.getActiveMode === 'fill') {
|
|
212
|
+
style.backgroundColor = this.getActiveColor
|
|
213
|
+
} else {
|
|
214
|
+
style.color = this.getActiveColor
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (this.getShape === 'button' && this.getActiveMode === 'fill') {
|
|
218
|
+
if (!this.val) {
|
|
219
|
+
style.color = this.getActiveColor
|
|
220
|
+
}
|
|
221
|
+
style.borderColor = this.getActiveColor
|
|
222
|
+
}
|
|
223
|
+
if (this.getActiveColor && this.getShape === 'button' && this.val) {
|
|
224
|
+
style.boxShadow = `-${this.getBorder} 0 0 0 ${this.getActiveColor}`
|
|
225
|
+
}
|
|
226
|
+
return style
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
methods: {
|
|
230
|
+
handleRadioToggle() {
|
|
231
|
+
if (this.getDisable) return
|
|
232
|
+
if (this.readonly) return
|
|
233
|
+
this._parent && this._parent.emitChange(this.name)
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
</script>
|
|
238
|
+
|
|
239
|
+
<style lang="scss" scoped>
|
|
240
|
+
$disable-color: #c8c9cc;
|
|
241
|
+
$unactive-color: #cccccc;
|
|
242
|
+
|
|
243
|
+
.pi-radio-wrap {
|
|
244
|
+
display: inline-flex;
|
|
245
|
+
align-items: center;
|
|
246
|
+
.radio-icon {
|
|
247
|
+
position: relative;
|
|
248
|
+
display: inline-flex;
|
|
249
|
+
align-items: center;
|
|
250
|
+
justify-content: center;
|
|
251
|
+
overflow: hidden;
|
|
252
|
+
color: $unactive-color;
|
|
253
|
+
border: 4rpx solid $disable-color;
|
|
254
|
+
transition: all $pi-animation-duration $pi-animation-timing-function;
|
|
255
|
+
.dot {
|
|
256
|
+
display: inline-flex;
|
|
257
|
+
width: 50%;
|
|
258
|
+
height: 50%;
|
|
259
|
+
border-radius: 50%;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
::v-deep pi-icon {
|
|
263
|
+
display: inline-flex;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
&.line-circle,
|
|
267
|
+
&.fill-circle {
|
|
268
|
+
.radio-icon {
|
|
269
|
+
color: transparent;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
.radio-label {
|
|
273
|
+
flex: 1;
|
|
274
|
+
margin-left: 16rpx;
|
|
275
|
+
line-height: 1.5;
|
|
276
|
+
word-wrap: break-word;
|
|
277
|
+
transition: $pi-animation-duration $pi-animation-timing-function;
|
|
278
|
+
transition-property: border, color, background-color;
|
|
279
|
+
&.text {
|
|
280
|
+
padding: 12rpx 24rpx;
|
|
281
|
+
margin-left: 0;
|
|
282
|
+
color: $unactive-color;
|
|
283
|
+
border-color: transparent;
|
|
284
|
+
border-style: solid;
|
|
285
|
+
}
|
|
286
|
+
&.button {
|
|
287
|
+
padding: 24rpx;
|
|
288
|
+
margin-left: 0;
|
|
289
|
+
line-height: 1;
|
|
290
|
+
color: $unactive-color;
|
|
291
|
+
border-color: transparent;
|
|
292
|
+
border-style: solid;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
&.stretch {
|
|
296
|
+
.radio-label {
|
|
297
|
+
display: flex;
|
|
298
|
+
align-items: center;
|
|
299
|
+
justify-content: center;
|
|
300
|
+
height: 84rpx;
|
|
301
|
+
padding: 0;
|
|
302
|
+
text-align: center;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
&.disabled {
|
|
306
|
+
cursor: not-allowed;
|
|
307
|
+
.radio-icon {
|
|
308
|
+
opacity: $pi-disabled-opacity;
|
|
309
|
+
}
|
|
310
|
+
.radio-label {
|
|
311
|
+
color: $unactive-color;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
&.line {
|
|
315
|
+
.radio-label.text {
|
|
316
|
+
border-color: $unactive-color;
|
|
317
|
+
}
|
|
318
|
+
.radio-label.button {
|
|
319
|
+
border-color: $unactive-color;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
&.fill {
|
|
323
|
+
.radio-icon {
|
|
324
|
+
color: #ffffff;
|
|
325
|
+
background-color: $unactive-color;
|
|
326
|
+
border-color: $unactive-color;
|
|
327
|
+
.dot {
|
|
328
|
+
background-color: #ffffff;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
.radio-label.text {
|
|
332
|
+
color: #ffffff;
|
|
333
|
+
background: $unactive-color;
|
|
334
|
+
}
|
|
335
|
+
.radio-label.button {
|
|
336
|
+
color: $pi-primary-color;
|
|
337
|
+
border-color: $pi-primary-color;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
&.active {
|
|
341
|
+
.radio-label {
|
|
342
|
+
color: $pi-primary-color;
|
|
343
|
+
&.button {
|
|
344
|
+
box-shadow: -4rpx 0 0 0 $pi-primary-color;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
&.line,
|
|
348
|
+
&.line-circle {
|
|
349
|
+
.radio-icon {
|
|
350
|
+
color: $pi-primary-color;
|
|
351
|
+
background-color: #ffffff;
|
|
352
|
+
border-color: $pi-primary-color;
|
|
353
|
+
.dot {
|
|
354
|
+
background-color: $pi-primary-color;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
.radio-label.text {
|
|
358
|
+
color: $pi-primary-color;
|
|
359
|
+
border-color: $pi-primary-color;
|
|
360
|
+
}
|
|
361
|
+
.radio-label.button {
|
|
362
|
+
color: $pi-primary-color;
|
|
363
|
+
border-color: $pi-primary-color;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
&.fill,
|
|
367
|
+
&.fill-circle {
|
|
368
|
+
.radio-icon {
|
|
369
|
+
color: #ffffff;
|
|
370
|
+
background: $pi-primary-color;
|
|
371
|
+
border-color: $pi-primary-color;
|
|
372
|
+
.dot {
|
|
373
|
+
background-color: #ffffff;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
.radio-label.text {
|
|
377
|
+
color: #ffffff;
|
|
378
|
+
background: $pi-primary-color;
|
|
379
|
+
}
|
|
380
|
+
.radio-label.button {
|
|
381
|
+
color: #ffffff;
|
|
382
|
+
background: $pi-primary-color;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
</style>
|