@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,341 @@
|
|
1
|
+
var MIN_DISTANCE = 10;
|
2
|
+
|
3
|
+
/**
|
4
|
+
* 判断当前是否为H5、app-vue
|
5
|
+
*/
|
6
|
+
var IS_HTML5 = false
|
7
|
+
if (typeof window === 'object') IS_HTML5 = true
|
8
|
+
|
9
|
+
/**
|
10
|
+
* 监听页面内值的变化,主要用于动态开关swipe-action
|
11
|
+
* @param {Object} newValue
|
12
|
+
* @param {Object} oldValue
|
13
|
+
* @param {Object} ownerInstance
|
14
|
+
* @param {Object} instance
|
15
|
+
*/
|
16
|
+
function showWatch(newVal, oldVal, ownerInstance, instance) {
|
17
|
+
var state = instance.getState()
|
18
|
+
getDom(instance, ownerInstance)
|
19
|
+
if (newVal && newVal !== 'none') {
|
20
|
+
openState(newVal, instance, ownerInstance)
|
21
|
+
return
|
22
|
+
}
|
23
|
+
|
24
|
+
if (state.left) {
|
25
|
+
openState('none', instance, ownerInstance)
|
26
|
+
}
|
27
|
+
resetTouchStatus(instance)
|
28
|
+
}
|
29
|
+
|
30
|
+
/**
|
31
|
+
* 开始触摸操作
|
32
|
+
* @param {Object} e
|
33
|
+
* @param {Object} ins
|
34
|
+
*/
|
35
|
+
function touchstart(e, ownerInstance) {
|
36
|
+
var instance = e.instance;
|
37
|
+
var disabled = instance.getDataset().disabled
|
38
|
+
var state = instance.getState();
|
39
|
+
getDom(instance, ownerInstance)
|
40
|
+
// fix by mehaotian, TODO 兼容 app-vue 获取dataset为字符串 , h5 获取 为 undefined 的问题,待框架修复
|
41
|
+
disabled = (typeof(disabled) === 'string' ? JSON.parse(disabled) : disabled) || false;
|
42
|
+
if (disabled) return
|
43
|
+
// 开始触摸时移除动画类
|
44
|
+
instance.requestAnimationFrame(function() {
|
45
|
+
instance.removeClass('ani');
|
46
|
+
ownerInstance.callMethod('closeSwipe');
|
47
|
+
})
|
48
|
+
|
49
|
+
// 记录上次的位置
|
50
|
+
state.x = state.left || 0
|
51
|
+
// 计算滑动开始位置
|
52
|
+
stopTouchStart(e, ownerInstance)
|
53
|
+
}
|
54
|
+
|
55
|
+
/**
|
56
|
+
* 开始滑动操作
|
57
|
+
* @param {Object} e
|
58
|
+
* @param {Object} ownerInstance
|
59
|
+
*/
|
60
|
+
function touchmove(e, ownerInstance) {
|
61
|
+
var instance = e.instance;
|
62
|
+
var disabled = instance.getDataset().disabled
|
63
|
+
var state = instance.getState()
|
64
|
+
// fix by mehaotian, TODO 兼容 app-vue 获取dataset为字符串 , h5 获取 为 undefined 的问题,待框架修复
|
65
|
+
disabled = (typeof(disabled) === 'string' ? JSON.parse(disabled) : disabled) || false;
|
66
|
+
if (disabled) return
|
67
|
+
// 是否可以滑动页面
|
68
|
+
stopTouchMove(e);
|
69
|
+
if (state.direction !== 'horizontal') {
|
70
|
+
return;
|
71
|
+
}
|
72
|
+
|
73
|
+
if (e.preventDefault) {
|
74
|
+
// 阻止页面滚动
|
75
|
+
e.preventDefault()
|
76
|
+
}
|
77
|
+
|
78
|
+
move(state.x + state.deltaX, instance, ownerInstance)
|
79
|
+
}
|
80
|
+
|
81
|
+
/**
|
82
|
+
* 结束触摸操作
|
83
|
+
* @param {Object} e
|
84
|
+
* @param {Object} ownerInstance
|
85
|
+
*/
|
86
|
+
function touchend(e, ownerInstance) {
|
87
|
+
var instance = e.instance;
|
88
|
+
var disabled = instance.getDataset().disabled
|
89
|
+
var state = instance.getState()
|
90
|
+
// fix by mehaotian, TODO 兼容 app-vue 获取dataset为字符串 , h5 获取 为 undefined 的问题,待框架修复
|
91
|
+
disabled = (typeof(disabled) === 'string' ? JSON.parse(disabled) : disabled) || false;
|
92
|
+
|
93
|
+
if (disabled) return
|
94
|
+
// 滑动过程中触摸结束,通过阙值判断是开启还是关闭
|
95
|
+
// fixed by mehaotian 定时器解决点击按钮,touchend 触发比 click 事件时机早的问题 ,主要是 ios13
|
96
|
+
moveDirection(state.left, instance, ownerInstance)
|
97
|
+
|
98
|
+
}
|
99
|
+
|
100
|
+
/**
|
101
|
+
* 设置移动距离
|
102
|
+
* @param {Object} value
|
103
|
+
* @param {Object} instance
|
104
|
+
* @param {Object} ownerInstance
|
105
|
+
*/
|
106
|
+
function move(value, instance, ownerInstance) {
|
107
|
+
value = value || 0
|
108
|
+
var state = instance.getState()
|
109
|
+
var leftWidth = state.leftWidth
|
110
|
+
var rightWidth = state.rightWidth
|
111
|
+
// 获取可滑动范围
|
112
|
+
state.left = range(value, -rightWidth, leftWidth);
|
113
|
+
instance.requestAnimationFrame(function() {
|
114
|
+
instance.setStyle({
|
115
|
+
transform: 'translateX(' + state.left + 'px)',
|
116
|
+
'-webkit-transform': 'translateX(' + state.left + 'px)'
|
117
|
+
})
|
118
|
+
})
|
119
|
+
|
120
|
+
}
|
121
|
+
|
122
|
+
/**
|
123
|
+
* 获取元素信息
|
124
|
+
* @param {Object} instance
|
125
|
+
* @param {Object} ownerInstance
|
126
|
+
*/
|
127
|
+
function getDom(instance, ownerInstance) {
|
128
|
+
var state = instance.getState()
|
129
|
+
var leftDom = ownerInstance.selectComponent('.button-group--left')
|
130
|
+
var rightDom = ownerInstance.selectComponent('.button-group--right')
|
131
|
+
var leftStyles = {
|
132
|
+
width: 0
|
133
|
+
}
|
134
|
+
var rightStyles = {
|
135
|
+
width: 0
|
136
|
+
}
|
137
|
+
leftStyles = leftDom.getBoundingClientRect()
|
138
|
+
rightStyles = rightDom.getBoundingClientRect()
|
139
|
+
|
140
|
+
state.leftWidth = leftStyles.width || 0
|
141
|
+
state.rightWidth = rightStyles.width || 0
|
142
|
+
state.threshold = instance.getDataset().threshold
|
143
|
+
}
|
144
|
+
|
145
|
+
/**
|
146
|
+
* 获取范围
|
147
|
+
* @param {Object} num
|
148
|
+
* @param {Object} min
|
149
|
+
* @param {Object} max
|
150
|
+
*/
|
151
|
+
function range(num, min, max) {
|
152
|
+
return Math.min(Math.max(num, min), max);
|
153
|
+
}
|
154
|
+
|
155
|
+
|
156
|
+
/**
|
157
|
+
* 移动方向判断
|
158
|
+
* @param {Object} left
|
159
|
+
* @param {Object} value
|
160
|
+
* @param {Object} ownerInstance
|
161
|
+
* @param {Object} ins
|
162
|
+
*/
|
163
|
+
function moveDirection(left, ins, ownerInstance) {
|
164
|
+
var state = ins.getState()
|
165
|
+
var threshold = state.threshold
|
166
|
+
var position = state.position
|
167
|
+
var isopen = state.isopen || 'none'
|
168
|
+
var leftWidth = state.leftWidth
|
169
|
+
var rightWidth = state.rightWidth
|
170
|
+
if (state.deltaX === 0) {
|
171
|
+
openState('none', ins, ownerInstance)
|
172
|
+
return
|
173
|
+
}
|
174
|
+
if ((isopen === 'none' && rightWidth > 0 && -left > threshold) || (isopen !== 'none' && rightWidth > 0 &&
|
175
|
+
rightWidth +
|
176
|
+
left < threshold)) {
|
177
|
+
// right
|
178
|
+
openState('right', ins, ownerInstance)
|
179
|
+
} else if ((isopen === 'none' && leftWidth > 0 && left > threshold) || (isopen !== 'none' && leftWidth > 0 &&
|
180
|
+
leftWidth - left < threshold)) {
|
181
|
+
// left
|
182
|
+
openState('left', ins, ownerInstance)
|
183
|
+
} else {
|
184
|
+
// default
|
185
|
+
openState('none', ins, ownerInstance)
|
186
|
+
}
|
187
|
+
}
|
188
|
+
|
189
|
+
|
190
|
+
/**
|
191
|
+
* 开启状态
|
192
|
+
* @param {Boolean} type
|
193
|
+
* @param {Object} ins
|
194
|
+
* @param {Object} ownerInstance
|
195
|
+
*/
|
196
|
+
function openState(type, ins, ownerInstance) {
|
197
|
+
var state = ins.getState()
|
198
|
+
var leftWidth = state.leftWidth
|
199
|
+
var rightWidth = state.rightWidth
|
200
|
+
var left = ''
|
201
|
+
state.isopen = state.isopen ? state.isopen : 'none'
|
202
|
+
switch (type) {
|
203
|
+
case "left":
|
204
|
+
left = leftWidth
|
205
|
+
break
|
206
|
+
case "right":
|
207
|
+
left = -rightWidth
|
208
|
+
break
|
209
|
+
default:
|
210
|
+
left = 0
|
211
|
+
}
|
212
|
+
|
213
|
+
// && !state.throttle
|
214
|
+
|
215
|
+
if (state.isopen !== type) {
|
216
|
+
state.throttle = true
|
217
|
+
ownerInstance.callMethod('change', {
|
218
|
+
open: type
|
219
|
+
})
|
220
|
+
|
221
|
+
}
|
222
|
+
|
223
|
+
state.isopen = type
|
224
|
+
// 添加动画类
|
225
|
+
ins.requestAnimationFrame(function() {
|
226
|
+
ins.addClass('ani');
|
227
|
+
move(left, ins, ownerInstance)
|
228
|
+
})
|
229
|
+
// 设置最终移动位置,理论上只要进入到这个函数,肯定是要打开的
|
230
|
+
}
|
231
|
+
|
232
|
+
|
233
|
+
function getDirection(x, y) {
|
234
|
+
if (x > y && x > MIN_DISTANCE) {
|
235
|
+
return 'horizontal';
|
236
|
+
}
|
237
|
+
if (y > x && y > MIN_DISTANCE) {
|
238
|
+
return 'vertical';
|
239
|
+
}
|
240
|
+
return '';
|
241
|
+
}
|
242
|
+
|
243
|
+
/**
|
244
|
+
* 重置滑动状态
|
245
|
+
* @param {Object} event
|
246
|
+
*/
|
247
|
+
function resetTouchStatus(instance) {
|
248
|
+
var state = instance.getState();
|
249
|
+
state.direction = '';
|
250
|
+
state.deltaX = 0;
|
251
|
+
state.deltaY = 0;
|
252
|
+
state.offsetX = 0;
|
253
|
+
state.offsetY = 0;
|
254
|
+
}
|
255
|
+
|
256
|
+
/**
|
257
|
+
* 设置滑动开始位置
|
258
|
+
* @param {Object} event
|
259
|
+
*/
|
260
|
+
function stopTouchStart(event) {
|
261
|
+
var instance = event.instance;
|
262
|
+
var state = instance.getState();
|
263
|
+
resetTouchStatus(instance);
|
264
|
+
var touch = event.touches[0];
|
265
|
+
if (IS_HTML5 && isPC()) {
|
266
|
+
touch = event;
|
267
|
+
}
|
268
|
+
state.startX = touch.clientX;
|
269
|
+
state.startY = touch.clientY;
|
270
|
+
}
|
271
|
+
|
272
|
+
/**
|
273
|
+
* 滑动中,是否禁止打开
|
274
|
+
* @param {Object} event
|
275
|
+
*/
|
276
|
+
function stopTouchMove(event) {
|
277
|
+
var instance = event.instance;
|
278
|
+
var state = instance.getState();
|
279
|
+
var touch = event.touches[0];
|
280
|
+
if (IS_HTML5 && isPC()) {
|
281
|
+
touch = event;
|
282
|
+
}
|
283
|
+
state.deltaX = touch.clientX - state.startX;
|
284
|
+
state.deltaY = touch.clientY - state.startY;
|
285
|
+
state.offsetY = Math.abs(state.deltaY);
|
286
|
+
state.offsetX = Math.abs(state.deltaX);
|
287
|
+
state.direction = state.direction || getDirection(state.offsetX, state.offsetY);
|
288
|
+
}
|
289
|
+
|
290
|
+
function isPC() {
|
291
|
+
var userAgentInfo = navigator.userAgent;
|
292
|
+
var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];
|
293
|
+
var flag = true;
|
294
|
+
for (var v = 0; v < Agents.length - 1; v++) {
|
295
|
+
if (userAgentInfo.indexOf(Agents[v]) > 0) {
|
296
|
+
flag = false;
|
297
|
+
break;
|
298
|
+
}
|
299
|
+
}
|
300
|
+
return flag;
|
301
|
+
}
|
302
|
+
|
303
|
+
var movable = false
|
304
|
+
|
305
|
+
function mousedown(e, ins) {
|
306
|
+
if (!IS_HTML5) return
|
307
|
+
if (!isPC()) return
|
308
|
+
touchstart(e, ins)
|
309
|
+
movable = true
|
310
|
+
}
|
311
|
+
|
312
|
+
function mousemove(e, ins) {
|
313
|
+
if (!IS_HTML5) return
|
314
|
+
if (!isPC()) return
|
315
|
+
if (!movable) return
|
316
|
+
touchmove(e, ins)
|
317
|
+
}
|
318
|
+
|
319
|
+
function mouseup(e, ins) {
|
320
|
+
if (!IS_HTML5) return
|
321
|
+
if (!isPC()) return
|
322
|
+
touchend(e, ins)
|
323
|
+
movable = false
|
324
|
+
}
|
325
|
+
|
326
|
+
function mouseleave(e, ins) {
|
327
|
+
if (!IS_HTML5) return
|
328
|
+
if (!isPC()) return
|
329
|
+
movable = false
|
330
|
+
}
|
331
|
+
|
332
|
+
module.exports = {
|
333
|
+
showWatch: showWatch,
|
334
|
+
touchstart: touchstart,
|
335
|
+
touchmove: touchmove,
|
336
|
+
touchend: touchend,
|
337
|
+
mousedown: mousedown,
|
338
|
+
mousemove: mousemove,
|
339
|
+
mouseup: mouseup,
|
340
|
+
mouseleave: mouseleave
|
341
|
+
}
|