@vtj/materials 0.10.1-alpha.5 → 0.10.1-alpha.7
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/dist/assets/antdv/index.umd.js +2 -2
- package/dist/assets/charts/index.umd.js +2 -2
- package/dist/assets/element/index.umd.js +2 -2
- package/dist/assets/ui/index.umd.js +2 -2
- package/dist/assets/uni-h5/index.umd.js +2 -2
- package/dist/assets/uni-ui/index.umd.js +3 -3
- package/dist/assets/vant/index.umd.js +2 -2
- package/dist/deps/@vtj/charts/index.umd.js +2 -2
- package/dist/deps/@vtj/icons/index.umd.js +2 -2
- package/dist/deps/@vtj/ui/index.umd.js +2 -2
- package/dist/deps/@vtj/utils/index.umd.js +2 -2
- package/dist/deps/uni-h5/style.css +1 -1
- package/dist/deps/uni-ui/index.umd.js +1 -1
- package/dist/deps/uni-ui/style.css +1 -1
- package/package.json +5 -5
- package/src/uni-h5/style.scss +0 -1
- package/src/uni-ui/components/badge.ts +5 -1
- package/src/uni-ui/components/breadcrumb.ts +76 -0
- package/src/uni-ui/components/calendar.ts +63 -0
- package/src/uni-ui/components/card.ts +113 -0
- package/src/uni-ui/components/collapse.ts +118 -0
- package/src/uni-ui/components/combox.ts +51 -0
- package/src/uni-ui/components/countdown.ts +92 -0
- package/src/uni-ui/components/dataCheckbox.ts +104 -0
- package/src/uni-ui/components/dataPicker.ts +146 -0
- package/src/uni-ui/components/dataSelect.ts +68 -0
- package/src/uni-ui/components/dateformat.ts +42 -0
- package/src/uni-ui/components/datetimePicker.ts +103 -0
- package/src/uni-ui/components/drawer.ts +38 -0
- package/src/uni-ui/components/easyinput.ts +159 -0
- package/src/uni-ui/components/fab.ts +89 -0
- package/src/uni-ui/components/fav.ts +65 -0
- package/src/uni-ui/components/filePicker.ts +127 -0
- package/src/uni-ui/components/forms.ts +209 -0
- package/src/uni-ui/components/goodsNav.ts +31 -0
- package/src/uni-ui/components/grid.ts +104 -0
- package/src/uni-ui/components/group.ts +50 -0
- package/src/uni-ui/components/icons.ts +47 -0
- package/src/uni-ui/components/index.ts +89 -1
- package/src/uni-ui/components/indexedList.ts +51 -0
- package/src/uni-ui/components/link.ts +60 -0
- package/src/uni-ui/components/list.ts +259 -0
- package/src/uni-ui/components/loadMore.ts +61 -0
- package/src/uni-ui/components/navbar.ts +121 -0
- package/src/uni-ui/components/noticeBar.ts +83 -0
- package/src/uni-ui/components/numberbox.ts +49 -0
- package/src/uni-ui/components/pagination.ts +59 -0
- package/src/uni-ui/components/popup.ts +206 -0
- package/src/uni-ui/components/rate.ts +89 -0
- package/src/uni-ui/components/row.ts +126 -0
- package/src/uni-ui/components/searchBar.ts +84 -0
- package/src/uni-ui/components/section.ts +68 -0
- package/src/uni-ui/components/segmentedControl.ts +48 -0
- package/src/uni-ui/components/steps.ts +55 -0
- package/src/uni-ui/components/swipeAction.ts +133 -0
- package/src/uni-ui/components/swiperDot.ts +114 -0
- package/src/uni-ui/components/table.ts +132 -0
- package/src/uni-ui/components/tag.ts +56 -0
- package/src/uni-ui/components/title.ts +49 -0
- package/src/uni-ui/components/tooltip.ts +32 -0
- package/src/uni-ui/components/transition.ts +49 -0
- package/src/uni-ui/index.ts +30 -13
- package/src/uni-ui/lib/uni-col/uni-col.vue +324 -0
- package/src/uni-ui/lib/uni-data-select/uni-data-select.vue +590 -0
- package/src/uni-ui/lib/uni-easyinput/common.js +54 -0
- package/src/uni-ui/lib/uni-easyinput/uni-easyinput.vue +790 -0
- package/src/uni-ui/lib/uni-forms-item/uni-forms-item.vue +630 -0
- package/src/uni-ui/lib/uni-goods-nav/i18n/en.json +6 -0
- package/src/uni-ui/lib/uni-goods-nav/i18n/index.js +8 -0
- package/src/uni-ui/lib/uni-goods-nav/i18n/zh-Hans.json +6 -0
- package/src/uni-ui/lib/uni-goods-nav/i18n/zh-Hant.json +6 -0
- package/src/uni-ui/lib/uni-goods-nav/uni-goods-nav.vue +231 -0
- package/src/uni-ui/lib/uni-icons/uni-icons.uvue +91 -0
- package/src/uni-ui/lib/uni-icons/uni-icons.vue +114 -0
- package/src/uni-ui/lib/uni-icons/uniicons.css +664 -0
- package/src/uni-ui/lib/uni-icons/uniicons.ttf +0 -0
- package/src/uni-ui/lib/uni-icons/uniicons_file.ts +664 -0
- package/src/uni-ui/lib/uni-icons/uniicons_file_vue.js +649 -0
- package/src/uni-ui/lib/uni-indexed-list/uni-indexed-list-item.vue +144 -0
- package/src/uni-ui/lib/uni-indexed-list/uni-indexed-list.vue +404 -0
- package/src/uni-ui/lib/uni-list/uni-list.vue +123 -0
- package/src/uni-ui/lib/uni-list/uni-refresh.vue +65 -0
- package/src/uni-ui/lib/uni-list/uni-refresh.wxs +87 -0
- package/src/uni-ui/lib/uni-popup-dialog/keypress.js +45 -0
- package/src/uni-ui/lib/uni-popup-dialog/uni-popup-dialog.vue +324 -0
- package/src/uni-ui/lib/uni-rate/uni-rate.vue +361 -0
- package/src/uni-ui/lib/uni-table/uni-table.vue +496 -0
- package/src/uni-ui/lib/uni-td/uni-td.vue +99 -0
- package/src/uni-ui/lib/uni-th/uni-th.vue +310 -283
- package/src/uni-ui/lib/uni-tr/uni-tr.vue +194 -170
- package/src/version.ts +2 -2
- package/dist/deps/@vtj/uni/index.umd.js +0 -7
@@ -0,0 +1,361 @@
|
|
1
|
+
<template>
|
2
|
+
<view>
|
3
|
+
<view ref="uni-rate" class="uni-rate">
|
4
|
+
<view class="uni-rate__icon" :class="{'uni-cursor-not-allowed': disabled}"
|
5
|
+
:style="{ 'margin-right': marginNumber + 'px' }" v-for="(star, index) in stars" :key="index"
|
6
|
+
@touchstart.stop="touchstart" @touchmove.stop="touchmove" @mousedown.stop="mousedown"
|
7
|
+
@mousemove.stop="mousemove" @mouseleave="mouseleave">
|
8
|
+
<uni-icons :color="color" :size="size" :type="isFill ? 'star-filled' : 'star'" />
|
9
|
+
<!-- #ifdef APP-NVUE -->
|
10
|
+
<view :style="{ width: star.activeWitch.replace('%','')*size/100+'px'}" class="uni-rate__icon-on">
|
11
|
+
<uni-icons style="text-align: left;" :color="disabled?'#ccc':activeColor" :size="size"
|
12
|
+
type="star-filled" />
|
13
|
+
</view>
|
14
|
+
<!-- #endif -->
|
15
|
+
<!-- #ifndef APP-NVUE -->
|
16
|
+
<view :style="{ width: star.activeWitch}" class="uni-rate__icon-on">
|
17
|
+
<uni-icons :color="disabled?disabledColor:activeColor" :size="size" type="star-filled" />
|
18
|
+
</view>
|
19
|
+
<!-- #endif -->
|
20
|
+
</view>
|
21
|
+
</view>
|
22
|
+
</view>
|
23
|
+
</template>
|
24
|
+
|
25
|
+
<script>
|
26
|
+
// #ifdef APP-NVUE
|
27
|
+
const dom = uni.requireNativePlugin('dom');
|
28
|
+
// #endif
|
29
|
+
/**
|
30
|
+
* Rate 评分
|
31
|
+
* @description 评分组件
|
32
|
+
* @tutorial https://ext.dcloud.net.cn/plugin?id=33
|
33
|
+
* @property {Boolean} isFill = [true|false] 星星的类型,是否为实心类型, 默认为实心
|
34
|
+
* @property {String} color 未选中状态的星星颜色,默认为 "#ececec"
|
35
|
+
* @property {String} activeColor 选中状态的星星颜色,默认为 "#ffca3e"
|
36
|
+
* @property {String} disabledColor 禁用状态的星星颜色,默认为 "#c0c0c0"
|
37
|
+
* @property {Number} size 星星的大小
|
38
|
+
* @property {Number} value/v-model 当前评分
|
39
|
+
* @property {Number} max 最大评分评分数量,目前一分一颗星
|
40
|
+
* @property {Number} margin 星星的间距,单位 px
|
41
|
+
* @property {Boolean} disabled = [true|false] 是否为禁用状态,默认为 false
|
42
|
+
* @property {Boolean} readonly = [true|false] 是否为只读状态,默认为 false
|
43
|
+
* @property {Boolean} allowHalf = [true|false] 是否实现半星,默认为 false
|
44
|
+
* @property {Boolean} touchable = [true|false] 是否支持滑动手势,默认为 true
|
45
|
+
* @event {Function} change uniRate 的 value 改变时触发事件,e={value:Number}
|
46
|
+
*/
|
47
|
+
|
48
|
+
export default {
|
49
|
+
name: "UniRate",
|
50
|
+
props: {
|
51
|
+
isFill: {
|
52
|
+
// 星星的类型,是否镂空
|
53
|
+
type: [Boolean, String],
|
54
|
+
default: true
|
55
|
+
},
|
56
|
+
color: {
|
57
|
+
// 星星未选中的颜色
|
58
|
+
type: String,
|
59
|
+
default: "#ececec"
|
60
|
+
},
|
61
|
+
activeColor: {
|
62
|
+
// 星星选中状态颜色
|
63
|
+
type: String,
|
64
|
+
default: "#ffca3e"
|
65
|
+
},
|
66
|
+
disabledColor: {
|
67
|
+
// 星星禁用状态颜色
|
68
|
+
type: String,
|
69
|
+
default: "#c0c0c0"
|
70
|
+
},
|
71
|
+
size: {
|
72
|
+
// 星星的大小
|
73
|
+
type: [Number, String],
|
74
|
+
default: 24
|
75
|
+
},
|
76
|
+
value: {
|
77
|
+
// 当前评分
|
78
|
+
type: [Number, String],
|
79
|
+
default: 0
|
80
|
+
},
|
81
|
+
modelValue: {
|
82
|
+
// 当前评分
|
83
|
+
type: [Number, String],
|
84
|
+
default: 0
|
85
|
+
},
|
86
|
+
max: {
|
87
|
+
// 最大评分
|
88
|
+
type: [Number, String],
|
89
|
+
default: 5
|
90
|
+
},
|
91
|
+
margin: {
|
92
|
+
// 星星的间距
|
93
|
+
type: [Number, String],
|
94
|
+
default: 0
|
95
|
+
},
|
96
|
+
disabled: {
|
97
|
+
// 是否可点击
|
98
|
+
type: [Boolean, String],
|
99
|
+
default: false
|
100
|
+
},
|
101
|
+
readonly: {
|
102
|
+
// 是否只读
|
103
|
+
type: [Boolean, String],
|
104
|
+
default: false
|
105
|
+
},
|
106
|
+
allowHalf: {
|
107
|
+
// 是否显示半星
|
108
|
+
type: [Boolean, String],
|
109
|
+
default: false
|
110
|
+
},
|
111
|
+
touchable: {
|
112
|
+
// 是否支持滑动手势
|
113
|
+
type: [Boolean, String],
|
114
|
+
default: true
|
115
|
+
}
|
116
|
+
},
|
117
|
+
data() {
|
118
|
+
return {
|
119
|
+
valueSync: "",
|
120
|
+
userMouseFristMove: true,
|
121
|
+
userRated: false,
|
122
|
+
userLastRate: 1
|
123
|
+
};
|
124
|
+
},
|
125
|
+
watch: {
|
126
|
+
value(newVal) {
|
127
|
+
this.valueSync = Number(newVal);
|
128
|
+
},
|
129
|
+
modelValue(newVal) {
|
130
|
+
this.valueSync = Number(newVal);
|
131
|
+
},
|
132
|
+
},
|
133
|
+
computed: {
|
134
|
+
stars() {
|
135
|
+
const value = this.valueSync ? this.valueSync : 0;
|
136
|
+
const starList = [];
|
137
|
+
const floorValue = Math.floor(value);
|
138
|
+
const ceilValue = Math.ceil(value);
|
139
|
+
for (let i = 0; i < this.max; i++) {
|
140
|
+
if (floorValue > i) {
|
141
|
+
starList.push({
|
142
|
+
activeWitch: "100%"
|
143
|
+
});
|
144
|
+
} else if (ceilValue - 1 === i) {
|
145
|
+
starList.push({
|
146
|
+
activeWitch: (value - floorValue) * 100 + "%"
|
147
|
+
});
|
148
|
+
} else {
|
149
|
+
starList.push({
|
150
|
+
activeWitch: "0"
|
151
|
+
});
|
152
|
+
}
|
153
|
+
}
|
154
|
+
return starList;
|
155
|
+
},
|
156
|
+
|
157
|
+
marginNumber() {
|
158
|
+
return Number(this.margin)
|
159
|
+
}
|
160
|
+
},
|
161
|
+
created() {
|
162
|
+
this.valueSync = Number(this.value || this.modelValue);
|
163
|
+
this._rateBoxLeft = 0
|
164
|
+
this._oldValue = null
|
165
|
+
},
|
166
|
+
mounted() {
|
167
|
+
setTimeout(() => {
|
168
|
+
this._getSize()
|
169
|
+
}, 100)
|
170
|
+
// #ifdef H5
|
171
|
+
this.PC = this.IsPC()
|
172
|
+
// #endif
|
173
|
+
},
|
174
|
+
methods: {
|
175
|
+
touchstart(e) {
|
176
|
+
// #ifdef H5
|
177
|
+
if (this.IsPC()) return
|
178
|
+
// #endif
|
179
|
+
if (this.readonly || this.disabled) return
|
180
|
+
const {
|
181
|
+
clientX,
|
182
|
+
screenX
|
183
|
+
} = e.changedTouches[0]
|
184
|
+
// TODO 做一下兼容,只有 Nvue 下才有 screenX,其他平台式 clientX
|
185
|
+
this._getRateCount(clientX || screenX)
|
186
|
+
},
|
187
|
+
touchmove(e) {
|
188
|
+
// #ifdef H5
|
189
|
+
if (this.IsPC()) return
|
190
|
+
// #endif
|
191
|
+
if (this.readonly || this.disabled || !this.touchable) return
|
192
|
+
const {
|
193
|
+
clientX,
|
194
|
+
screenX
|
195
|
+
} = e.changedTouches[0]
|
196
|
+
this._getRateCount(clientX || screenX)
|
197
|
+
},
|
198
|
+
|
199
|
+
/**
|
200
|
+
* 兼容 PC @tian
|
201
|
+
*/
|
202
|
+
|
203
|
+
mousedown(e) {
|
204
|
+
// #ifdef H5
|
205
|
+
if (!this.IsPC()) return
|
206
|
+
if (this.readonly || this.disabled) return
|
207
|
+
const {
|
208
|
+
clientX,
|
209
|
+
} = e
|
210
|
+
this.userLastRate = this.valueSync
|
211
|
+
this._getRateCount(clientX)
|
212
|
+
this.userRated = true
|
213
|
+
// #endif
|
214
|
+
},
|
215
|
+
mousemove(e) {
|
216
|
+
// #ifdef H5
|
217
|
+
if (!this.IsPC()) return
|
218
|
+
if (this.userRated) return
|
219
|
+
if (this.userMouseFristMove) {
|
220
|
+
console.log('---mousemove----', this.valueSync);
|
221
|
+
this.userLastRate = this.valueSync
|
222
|
+
this.userMouseFristMove = false
|
223
|
+
}
|
224
|
+
if (this.readonly || this.disabled || !this.touchable) return
|
225
|
+
const {
|
226
|
+
clientX,
|
227
|
+
} = e
|
228
|
+
this._getRateCount(clientX)
|
229
|
+
// #endif
|
230
|
+
},
|
231
|
+
mouseleave(e) {
|
232
|
+
// #ifdef H5
|
233
|
+
if (!this.IsPC()) return
|
234
|
+
if (this.readonly || this.disabled || !this.touchable) return
|
235
|
+
if (this.userRated) {
|
236
|
+
this.userRated = false
|
237
|
+
return
|
238
|
+
}
|
239
|
+
this.valueSync = this.userLastRate
|
240
|
+
// #endif
|
241
|
+
},
|
242
|
+
// #ifdef H5
|
243
|
+
IsPC() {
|
244
|
+
var userAgentInfo = navigator.userAgent;
|
245
|
+
var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];
|
246
|
+
var flag = true;
|
247
|
+
for (let v = 0; v < Agents.length - 1; v++) {
|
248
|
+
if (userAgentInfo.indexOf(Agents[v]) > 0) {
|
249
|
+
flag = false;
|
250
|
+
break;
|
251
|
+
}
|
252
|
+
}
|
253
|
+
return flag;
|
254
|
+
},
|
255
|
+
// #endif
|
256
|
+
|
257
|
+
/**
|
258
|
+
* 获取星星个数
|
259
|
+
*/
|
260
|
+
_getRateCount(clientX) {
|
261
|
+
this._getSize()
|
262
|
+
const size = Number(this.size)
|
263
|
+
if (isNaN(size)) {
|
264
|
+
return new Error('size 属性只能设置为数字')
|
265
|
+
}
|
266
|
+
const rateMoveRange = clientX - this._rateBoxLeft
|
267
|
+
let index = parseInt(rateMoveRange / (size + this.marginNumber))
|
268
|
+
index = index < 0 ? 0 : index;
|
269
|
+
index = index > this.max ? this.max : index;
|
270
|
+
const range = parseInt(rateMoveRange - (size + this.marginNumber) * index);
|
271
|
+
let value = 0;
|
272
|
+
if (this._oldValue === index && !this.PC) return;
|
273
|
+
this._oldValue = index;
|
274
|
+
if (this.allowHalf) {
|
275
|
+
if (range > (size / 2)) {
|
276
|
+
value = index + 1
|
277
|
+
} else {
|
278
|
+
value = index + 0.5
|
279
|
+
}
|
280
|
+
} else {
|
281
|
+
value = index + 1
|
282
|
+
}
|
283
|
+
|
284
|
+
value = Math.max(0.5, Math.min(value, this.max))
|
285
|
+
this.valueSync = value
|
286
|
+
this._onChange()
|
287
|
+
},
|
288
|
+
|
289
|
+
/**
|
290
|
+
* 触发动态修改
|
291
|
+
*/
|
292
|
+
_onChange() {
|
293
|
+
|
294
|
+
this.$emit("input", this.valueSync);
|
295
|
+
this.$emit("update:modelValue", this.valueSync);
|
296
|
+
this.$emit("change", {
|
297
|
+
value: this.valueSync
|
298
|
+
});
|
299
|
+
},
|
300
|
+
/**
|
301
|
+
* 获取星星距离屏幕左侧距离
|
302
|
+
*/
|
303
|
+
_getSize() {
|
304
|
+
// #ifndef APP-NVUE
|
305
|
+
uni.createSelectorQuery()
|
306
|
+
.in(this)
|
307
|
+
.select('.uni-rate')
|
308
|
+
.boundingClientRect()
|
309
|
+
.exec(ret => {
|
310
|
+
if (ret) {
|
311
|
+
this._rateBoxLeft = ret[0].left
|
312
|
+
}
|
313
|
+
})
|
314
|
+
// #endif
|
315
|
+
// #ifdef APP-NVUE
|
316
|
+
dom.getComponentRect(this.$refs['uni-rate'], (ret) => {
|
317
|
+
const size = ret.size
|
318
|
+
if (size) {
|
319
|
+
this._rateBoxLeft = size.left
|
320
|
+
}
|
321
|
+
})
|
322
|
+
// #endif
|
323
|
+
}
|
324
|
+
}
|
325
|
+
};
|
326
|
+
</script>
|
327
|
+
|
328
|
+
<style lang="scss">
|
329
|
+
.uni-rate {
|
330
|
+
/* #ifndef APP-NVUE */
|
331
|
+
display: flex;
|
332
|
+
/* #endif */
|
333
|
+
line-height: 1;
|
334
|
+
font-size: 0;
|
335
|
+
flex-direction: row;
|
336
|
+
/* #ifdef H5 */
|
337
|
+
cursor: pointer;
|
338
|
+
/* #endif */
|
339
|
+
}
|
340
|
+
|
341
|
+
.uni-rate__icon {
|
342
|
+
position: relative;
|
343
|
+
line-height: 1;
|
344
|
+
font-size: 0;
|
345
|
+
}
|
346
|
+
|
347
|
+
.uni-rate__icon-on {
|
348
|
+
overflow: hidden;
|
349
|
+
position: absolute;
|
350
|
+
top: 0;
|
351
|
+
left: 0;
|
352
|
+
line-height: 1;
|
353
|
+
text-align: left;
|
354
|
+
}
|
355
|
+
|
356
|
+
.uni-cursor-not-allowed {
|
357
|
+
/* #ifdef H5 */
|
358
|
+
cursor: not-allowed !important;
|
359
|
+
/* #endif */
|
360
|
+
}
|
361
|
+
</style>
|