@vtj/materials 0.10.1-alpha.1 → 0.10.1-alpha.2
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/uni/index.umd.js +2 -2
- package/dist/deps/@vtj/utils/index.umd.js +2 -2
- package/dist/deps/mockjs/mock-min.js +10 -0
- 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-ui/components/badge.ts +52 -0
- package/src/uni-ui/index.ts +197 -3
- package/src/uni-ui/lib/uni-datetime-picker/calendar-item.vue +177 -0
- package/src/uni-ui/lib/uni-datetime-picker/calendar.vue +947 -0
- package/src/uni-ui/lib/uni-datetime-picker/i18n/en.json +22 -0
- package/src/uni-ui/lib/uni-datetime-picker/i18n/index.js +8 -0
- package/src/uni-ui/lib/uni-datetime-picker/i18n/zh-Hans.json +22 -0
- package/src/uni-ui/lib/uni-datetime-picker/i18n/zh-Hant.json +22 -0
- package/src/uni-ui/lib/uni-datetime-picker/time-picker.vue +940 -0
- package/src/uni-ui/lib/uni-datetime-picker/uni-datetime-picker.vue +1232 -0
- package/src/uni-ui/lib/uni-datetime-picker/util.js +421 -0
- package/src/uni-ui/lib/uni-forms/uni-forms.vue +416 -0
- package/src/uni-ui/lib/uni-forms/utils.js +293 -0
- package/src/uni-ui/lib/uni-forms/validate.js +486 -0
- package/src/uni-ui/lib/uni-popup/i18n/en.json +7 -0
- package/src/uni-ui/lib/uni-popup/i18n/index.js +8 -0
- package/src/uni-ui/lib/uni-popup/i18n/zh-Hans.json +7 -0
- package/src/uni-ui/lib/uni-popup/i18n/zh-Hant.json +7 -0
- package/src/uni-ui/lib/uni-popup/keypress.js +45 -0
- package/src/uni-ui/lib/uni-popup/popup.js +26 -0
- package/src/uni-ui/lib/uni-popup/uni-popup.uvue +90 -0
- package/src/uni-ui/lib/uni-popup/uni-popup.vue +552 -0
- package/src/uni-ui/lib/uni-swipe-action-item/bindingx.js +302 -0
- package/src/uni-ui/lib/uni-swipe-action-item/isPC.js +12 -0
- package/src/uni-ui/lib/uni-swipe-action-item/mpalipay.js +195 -0
- package/src/uni-ui/lib/uni-swipe-action-item/mpother.js +260 -0
- package/src/uni-ui/lib/uni-swipe-action-item/mpwxs.js +84 -0
- package/src/uni-ui/lib/uni-swipe-action-item/render.js +270 -0
- package/src/uni-ui/lib/uni-swipe-action-item/uni-swipe-action-item.vue +494 -0
- package/src/uni-ui/lib/uni-swipe-action-item/wx.wxs +341 -0
- package/src/uni-ui/lib/uni-th/filter-dropdown.vue +511 -0
- package/src/uni-ui/lib/uni-th/uni-th.vue +295 -0
- package/src/uni-ui/lib/uni-tr/table-checkbox.vue +179 -0
- package/src/uni-ui/lib/uni-tr/uni-tr.vue +184 -0
- package/src/uni-ui/lib/uni.scss +76 -0
- package/src/uni-ui/polyfill.ts +41 -0
- package/src/version.ts +2 -2
@@ -0,0 +1,302 @@
|
|
1
|
+
let bindIngXMixins = {}
|
2
|
+
|
3
|
+
// #ifdef APP-NVUE
|
4
|
+
const BindingX = uni.requireNativePlugin('bindingx');
|
5
|
+
const dom = uni.requireNativePlugin('dom');
|
6
|
+
const animation = uni.requireNativePlugin('animation');
|
7
|
+
|
8
|
+
bindIngXMixins = {
|
9
|
+
data() {
|
10
|
+
return {}
|
11
|
+
},
|
12
|
+
|
13
|
+
watch: {
|
14
|
+
show(newVal) {
|
15
|
+
if (this.autoClose) return
|
16
|
+
if (this.stop) return
|
17
|
+
this.stop = true
|
18
|
+
if (newVal) {
|
19
|
+
this.open(newVal)
|
20
|
+
} else {
|
21
|
+
this.close()
|
22
|
+
}
|
23
|
+
},
|
24
|
+
leftOptions() {
|
25
|
+
this.getSelectorQuery()
|
26
|
+
this.init()
|
27
|
+
},
|
28
|
+
rightOptions(newVal) {
|
29
|
+
this.init()
|
30
|
+
}
|
31
|
+
},
|
32
|
+
created() {
|
33
|
+
this.swipeaction = this.getSwipeAction()
|
34
|
+
if (this.swipeaction && Array.isArray(this.swipeaction.children)) {
|
35
|
+
this.swipeaction.children.push(this)
|
36
|
+
}
|
37
|
+
},
|
38
|
+
mounted() {
|
39
|
+
this.box = this.getEl(this.$refs['selector-box--hock'])
|
40
|
+
this.selector = this.getEl(this.$refs['selector-content--hock']);
|
41
|
+
this.leftButton = this.getEl(this.$refs['selector-left-button--hock']);
|
42
|
+
this.rightButton = this.getEl(this.$refs['selector-right-button--hock']);
|
43
|
+
this.init()
|
44
|
+
},
|
45
|
+
// beforeDestroy() {
|
46
|
+
// this.swipeaction.children.forEach((item, index) => {
|
47
|
+
// if (item === this) {
|
48
|
+
// this.swipeaction.children.splice(index, 1)
|
49
|
+
// }
|
50
|
+
// })
|
51
|
+
// },
|
52
|
+
methods: {
|
53
|
+
init() {
|
54
|
+
this.$nextTick(() => {
|
55
|
+
this.x = 0
|
56
|
+
this.button = {
|
57
|
+
show: false
|
58
|
+
}
|
59
|
+
setTimeout(() => {
|
60
|
+
this.getSelectorQuery()
|
61
|
+
}, 200)
|
62
|
+
})
|
63
|
+
},
|
64
|
+
onClick(index, item, position) {
|
65
|
+
this.$emit('click', {
|
66
|
+
content: item,
|
67
|
+
index,
|
68
|
+
position
|
69
|
+
})
|
70
|
+
},
|
71
|
+
touchstart(e) {
|
72
|
+
// fix by mehaotian 禁止滑动
|
73
|
+
if (this.disabled) return
|
74
|
+
// 每次只触发一次,避免多次监听造成闪烁
|
75
|
+
if (this.stop) return
|
76
|
+
this.stop = true
|
77
|
+
if (this.autoClose && this.swipeaction) {
|
78
|
+
this.swipeaction.closeOther(this)
|
79
|
+
}
|
80
|
+
|
81
|
+
const leftWidth = this.button.left.width
|
82
|
+
const rightWidth = this.button.right.width
|
83
|
+
let expression = this.range(this.x, -rightWidth, leftWidth)
|
84
|
+
let leftExpression = this.range(this.x - leftWidth, -leftWidth, 0)
|
85
|
+
let rightExpression = this.range(this.x + rightWidth, 0, rightWidth)
|
86
|
+
|
87
|
+
this.eventpan = BindingX.bind({
|
88
|
+
anchor: this.box,
|
89
|
+
eventType: 'pan',
|
90
|
+
props: [{
|
91
|
+
element: this.selector,
|
92
|
+
property: 'transform.translateX',
|
93
|
+
expression
|
94
|
+
}, {
|
95
|
+
element: this.leftButton,
|
96
|
+
property: 'transform.translateX',
|
97
|
+
expression: leftExpression
|
98
|
+
}, {
|
99
|
+
element: this.rightButton,
|
100
|
+
property: 'transform.translateX',
|
101
|
+
expression: rightExpression
|
102
|
+
}, ]
|
103
|
+
}, (e) => {
|
104
|
+
// nope
|
105
|
+
if (e.state === 'end') {
|
106
|
+
this.x = e.deltaX + this.x;
|
107
|
+
this.isclick = true
|
108
|
+
this.bindTiming(e.deltaX)
|
109
|
+
}
|
110
|
+
});
|
111
|
+
},
|
112
|
+
touchend(e) {
|
113
|
+
if (this.isopen !== 'none' && !this.isclick) {
|
114
|
+
this.open('none')
|
115
|
+
}
|
116
|
+
},
|
117
|
+
bindTiming(x) {
|
118
|
+
const left = this.x
|
119
|
+
const leftWidth = this.button.left.width
|
120
|
+
const rightWidth = this.button.right.width
|
121
|
+
const threshold = this.threshold
|
122
|
+
if (!this.isopen || this.isopen === 'none') {
|
123
|
+
if (left > threshold) {
|
124
|
+
this.open('left')
|
125
|
+
} else if (left < -threshold) {
|
126
|
+
this.open('right')
|
127
|
+
} else {
|
128
|
+
this.open('none')
|
129
|
+
}
|
130
|
+
} else {
|
131
|
+
if ((x > -leftWidth && x < 0) || x > rightWidth) {
|
132
|
+
if ((x > -threshold && x < 0) || (x - rightWidth > threshold)) {
|
133
|
+
this.open('left')
|
134
|
+
} else {
|
135
|
+
this.open('none')
|
136
|
+
}
|
137
|
+
} else {
|
138
|
+
if ((x < threshold && x > 0) || (x + leftWidth < -threshold)) {
|
139
|
+
this.open('right')
|
140
|
+
} else {
|
141
|
+
this.open('none')
|
142
|
+
}
|
143
|
+
}
|
144
|
+
}
|
145
|
+
},
|
146
|
+
|
147
|
+
/**
|
148
|
+
* 移动范围
|
149
|
+
* @param {Object} num
|
150
|
+
* @param {Object} mix
|
151
|
+
* @param {Object} max
|
152
|
+
*/
|
153
|
+
range(num, mix, max) {
|
154
|
+
return `min(max(x+${num}, ${mix}), ${max})`
|
155
|
+
},
|
156
|
+
|
157
|
+
/**
|
158
|
+
* 开启swipe
|
159
|
+
*/
|
160
|
+
open(type) {
|
161
|
+
this.animation(type)
|
162
|
+
},
|
163
|
+
|
164
|
+
/**
|
165
|
+
* 关闭swipe
|
166
|
+
*/
|
167
|
+
close() {
|
168
|
+
this.animation('none')
|
169
|
+
},
|
170
|
+
|
171
|
+
/**
|
172
|
+
* 开启关闭动画
|
173
|
+
* @param {Object} type
|
174
|
+
*/
|
175
|
+
animation(type) {
|
176
|
+
const time = 300
|
177
|
+
const leftWidth = this.button.left.width
|
178
|
+
const rightWidth = this.button.right.width
|
179
|
+
if (this.eventpan && this.eventpan.token) {
|
180
|
+
BindingX.unbind({
|
181
|
+
token: this.eventpan.token,
|
182
|
+
eventType: 'pan'
|
183
|
+
})
|
184
|
+
}
|
185
|
+
|
186
|
+
switch (type) {
|
187
|
+
case 'left':
|
188
|
+
Promise.all([
|
189
|
+
this.move(this.selector, leftWidth),
|
190
|
+
this.move(this.leftButton, 0),
|
191
|
+
this.move(this.rightButton, rightWidth * 2)
|
192
|
+
]).then(() => {
|
193
|
+
this.setEmit(leftWidth, type)
|
194
|
+
})
|
195
|
+
break
|
196
|
+
case 'right':
|
197
|
+
Promise.all([
|
198
|
+
this.move(this.selector, -rightWidth),
|
199
|
+
this.move(this.leftButton, -leftWidth * 2),
|
200
|
+
this.move(this.rightButton, 0)
|
201
|
+
]).then(() => {
|
202
|
+
this.setEmit(-rightWidth, type)
|
203
|
+
})
|
204
|
+
break
|
205
|
+
default:
|
206
|
+
Promise.all([
|
207
|
+
this.move(this.selector, 0),
|
208
|
+
this.move(this.leftButton, -leftWidth),
|
209
|
+
this.move(this.rightButton, rightWidth)
|
210
|
+
]).then(() => {
|
211
|
+
this.setEmit(0, type)
|
212
|
+
})
|
213
|
+
|
214
|
+
}
|
215
|
+
},
|
216
|
+
setEmit(x, type) {
|
217
|
+
const leftWidth = this.button.left.width
|
218
|
+
const rightWidth = this.button.right.width
|
219
|
+
this.isopen = this.isopen || 'none'
|
220
|
+
this.stop = false
|
221
|
+
this.isclick = false
|
222
|
+
// 只有状态不一致才会返回结果
|
223
|
+
if (this.isopen !== type && this.x !== x) {
|
224
|
+
if (type === 'left' && leftWidth > 0) {
|
225
|
+
this.$emit('change', 'left')
|
226
|
+
}
|
227
|
+
if (type === 'right' && rightWidth > 0) {
|
228
|
+
this.$emit('change', 'right')
|
229
|
+
}
|
230
|
+
if (type === 'none') {
|
231
|
+
this.$emit('change', 'none')
|
232
|
+
}
|
233
|
+
}
|
234
|
+
this.x = x
|
235
|
+
this.isopen = type
|
236
|
+
},
|
237
|
+
move(ref, value) {
|
238
|
+
return new Promise((resolve, reject) => {
|
239
|
+
animation.transition(ref, {
|
240
|
+
styles: {
|
241
|
+
transform: `translateX(${value})`,
|
242
|
+
},
|
243
|
+
duration: 150, //ms
|
244
|
+
timingFunction: 'linear',
|
245
|
+
needLayout: false,
|
246
|
+
delay: 0 //ms
|
247
|
+
}, function(res) {
|
248
|
+
resolve(res)
|
249
|
+
})
|
250
|
+
})
|
251
|
+
|
252
|
+
},
|
253
|
+
|
254
|
+
/**
|
255
|
+
* 获取ref
|
256
|
+
* @param {Object} el
|
257
|
+
*/
|
258
|
+
getEl(el) {
|
259
|
+
return el.ref
|
260
|
+
},
|
261
|
+
/**
|
262
|
+
* 获取节点信息
|
263
|
+
*/
|
264
|
+
getSelectorQuery() {
|
265
|
+
Promise.all([
|
266
|
+
this.getDom('left'),
|
267
|
+
this.getDom('right'),
|
268
|
+
]).then((data) => {
|
269
|
+
let show = 'none'
|
270
|
+
if (this.autoClose) {
|
271
|
+
show = 'none'
|
272
|
+
} else {
|
273
|
+
show = this.show
|
274
|
+
}
|
275
|
+
|
276
|
+
if (show === 'none') {
|
277
|
+
// this.close()
|
278
|
+
} else {
|
279
|
+
this.open(show)
|
280
|
+
}
|
281
|
+
|
282
|
+
})
|
283
|
+
|
284
|
+
},
|
285
|
+
getDom(str) {
|
286
|
+
return new Promise((resolve, reject) => {
|
287
|
+
dom.getComponentRect(this.$refs[`selector-${str}-button--hock`], (data) => {
|
288
|
+
if (data) {
|
289
|
+
this.button[str] = data.size
|
290
|
+
resolve(data)
|
291
|
+
} else {
|
292
|
+
reject()
|
293
|
+
}
|
294
|
+
})
|
295
|
+
})
|
296
|
+
}
|
297
|
+
}
|
298
|
+
}
|
299
|
+
|
300
|
+
// #endif
|
301
|
+
|
302
|
+
export default bindIngXMixins
|
@@ -0,0 +1,12 @@
|
|
1
|
+
export function isPC() {
|
2
|
+
var userAgentInfo = navigator.userAgent;
|
3
|
+
var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];
|
4
|
+
var flag = true;
|
5
|
+
for (let v = 0; v < Agents.length - 1; v++) {
|
6
|
+
if (userAgentInfo.indexOf(Agents[v]) > 0) {
|
7
|
+
flag = false;
|
8
|
+
break;
|
9
|
+
}
|
10
|
+
}
|
11
|
+
return flag;
|
12
|
+
}
|
@@ -0,0 +1,195 @@
|
|
1
|
+
export default {
|
2
|
+
data() {
|
3
|
+
return {
|
4
|
+
x: 0,
|
5
|
+
transition: false,
|
6
|
+
width: 0,
|
7
|
+
viewWidth: 0,
|
8
|
+
swipeShow: 0
|
9
|
+
}
|
10
|
+
},
|
11
|
+
watch: {
|
12
|
+
show(newVal) {
|
13
|
+
if (this.autoClose) return
|
14
|
+
if (newVal && newVal !== 'none') {
|
15
|
+
this.transition = true
|
16
|
+
this.open(newVal)
|
17
|
+
} else {
|
18
|
+
this.close()
|
19
|
+
}
|
20
|
+
}
|
21
|
+
},
|
22
|
+
created() {
|
23
|
+
this.swipeaction = this.getSwipeAction()
|
24
|
+
if (this.swipeaction && Array.isArray(this.swipeaction.children)) {
|
25
|
+
this.swipeaction.children.push(this)
|
26
|
+
}
|
27
|
+
},
|
28
|
+
mounted() {
|
29
|
+
this.isopen = false
|
30
|
+
setTimeout(() => {
|
31
|
+
this.getQuerySelect()
|
32
|
+
}, 50)
|
33
|
+
},
|
34
|
+
methods: {
|
35
|
+
appTouchStart(e) {
|
36
|
+
const {
|
37
|
+
clientX
|
38
|
+
} = e.changedTouches[0]
|
39
|
+
this.clientX = clientX
|
40
|
+
this.timestamp = new Date().getTime()
|
41
|
+
},
|
42
|
+
appTouchEnd(e, index, item, position) {
|
43
|
+
const {
|
44
|
+
clientX
|
45
|
+
} = e.changedTouches[0]
|
46
|
+
// fixed by xxxx 模拟点击事件,解决 ios 13 点击区域错位的问题
|
47
|
+
let diff = Math.abs(this.clientX - clientX)
|
48
|
+
let time = (new Date().getTime()) - this.timestamp
|
49
|
+
if (diff < 40 && time < 300) {
|
50
|
+
this.$emit('click', {
|
51
|
+
content: item,
|
52
|
+
index,
|
53
|
+
position
|
54
|
+
})
|
55
|
+
}
|
56
|
+
},
|
57
|
+
/**
|
58
|
+
* 移动触发
|
59
|
+
* @param {Object} e
|
60
|
+
*/
|
61
|
+
onChange(e) {
|
62
|
+
this.moveX = e.detail.x
|
63
|
+
this.isclose = false
|
64
|
+
},
|
65
|
+
touchstart(e) {
|
66
|
+
this.transition = false
|
67
|
+
this.isclose = true
|
68
|
+
if (this.autoClose && this.swipeaction) {
|
69
|
+
this.swipeaction.closeOther(this)
|
70
|
+
}
|
71
|
+
},
|
72
|
+
touchmove(e) {},
|
73
|
+
touchend(e) {
|
74
|
+
// 0的位置什么都不执行
|
75
|
+
if (this.isclose && this.isopen === 'none') return
|
76
|
+
if (this.isclose && this.isopen !== 'none') {
|
77
|
+
this.transition = true
|
78
|
+
this.close()
|
79
|
+
} else {
|
80
|
+
this.move(this.moveX + this.leftWidth)
|
81
|
+
}
|
82
|
+
},
|
83
|
+
|
84
|
+
/**
|
85
|
+
* 移动
|
86
|
+
* @param {Object} moveX
|
87
|
+
*/
|
88
|
+
move(moveX) {
|
89
|
+
// 打开关闭的处理逻辑不太一样
|
90
|
+
this.transition = true
|
91
|
+
// 未打开状态
|
92
|
+
if (!this.isopen || this.isopen === 'none') {
|
93
|
+
if (moveX > this.threshold) {
|
94
|
+
this.open('left')
|
95
|
+
} else if (moveX < -this.threshold) {
|
96
|
+
this.open('right')
|
97
|
+
} else {
|
98
|
+
this.close()
|
99
|
+
}
|
100
|
+
} else {
|
101
|
+
if (moveX < 0 && moveX < this.rightWidth) {
|
102
|
+
const rightX = this.rightWidth + moveX
|
103
|
+
if (rightX < this.threshold) {
|
104
|
+
this.open('right')
|
105
|
+
} else {
|
106
|
+
this.close()
|
107
|
+
}
|
108
|
+
} else if (moveX > 0 && moveX < this.leftWidth) {
|
109
|
+
const leftX = this.leftWidth - moveX
|
110
|
+
if (leftX < this.threshold) {
|
111
|
+
this.open('left')
|
112
|
+
} else {
|
113
|
+
this.close()
|
114
|
+
}
|
115
|
+
}
|
116
|
+
|
117
|
+
}
|
118
|
+
|
119
|
+
},
|
120
|
+
|
121
|
+
/**
|
122
|
+
* 打开
|
123
|
+
*/
|
124
|
+
open(type) {
|
125
|
+
this.x = this.moveX
|
126
|
+
this.animation(type)
|
127
|
+
},
|
128
|
+
|
129
|
+
/**
|
130
|
+
* 关闭
|
131
|
+
*/
|
132
|
+
close() {
|
133
|
+
this.x = this.moveX
|
134
|
+
// TODO 解决 x 值不更新的问题,所以会多触发一次 nextTick ,待优化
|
135
|
+
this.$nextTick(() => {
|
136
|
+
this.x = -this.leftWidth
|
137
|
+
if (this.isopen !== 'none') {
|
138
|
+
this.$emit('change', 'none')
|
139
|
+
}
|
140
|
+
this.isopen = 'none'
|
141
|
+
})
|
142
|
+
},
|
143
|
+
|
144
|
+
/**
|
145
|
+
* 执行结束动画
|
146
|
+
* @param {Object} type
|
147
|
+
*/
|
148
|
+
animation(type) {
|
149
|
+
this.$nextTick(() => {
|
150
|
+
if (type === 'left') {
|
151
|
+
this.x = 0
|
152
|
+
} else {
|
153
|
+
this.x = -this.rightWidth - this.leftWidth
|
154
|
+
}
|
155
|
+
|
156
|
+
if (this.isopen !== type) {
|
157
|
+
this.$emit('change', type)
|
158
|
+
}
|
159
|
+
this.isopen = type
|
160
|
+
})
|
161
|
+
|
162
|
+
},
|
163
|
+
getSlide(x) {},
|
164
|
+
getQuerySelect() {
|
165
|
+
const query = uni.createSelectorQuery().in(this);
|
166
|
+
query.selectAll('.movable-view--hock').boundingClientRect(data => {
|
167
|
+
this.leftWidth = data[1].width
|
168
|
+
this.rightWidth = data[2].width
|
169
|
+
this.width = data[0].width
|
170
|
+
this.viewWidth = this.width + this.rightWidth + this.leftWidth
|
171
|
+
if (this.leftWidth === 0) {
|
172
|
+
// TODO 疑似bug ,初始化的时候如果x 是0,会导致移动位置错误,所以让元素超出一点
|
173
|
+
this.x = -0.1
|
174
|
+
} else {
|
175
|
+
this.x = -this.leftWidth
|
176
|
+
}
|
177
|
+
this.moveX = this.x
|
178
|
+
this.$nextTick(() => {
|
179
|
+
this.swipeShow = 1
|
180
|
+
})
|
181
|
+
|
182
|
+
if (!this.buttonWidth) {
|
183
|
+
this.disabledView = true
|
184
|
+
}
|
185
|
+
|
186
|
+
if (this.autoClose) return
|
187
|
+
if (this.show !== 'none') {
|
188
|
+
this.transition = true
|
189
|
+
this.open(this.shows)
|
190
|
+
}
|
191
|
+
}).exec();
|
192
|
+
|
193
|
+
}
|
194
|
+
}
|
195
|
+
}
|