hy-app 0.2.1 → 0.2.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.
Files changed (50) hide show
  1. package/components/hy-button/index.scss +4 -0
  2. package/components/hy-code-input/hy-code-input.vue +223 -0
  3. package/components/hy-code-input/index.scss +108 -0
  4. package/components/hy-code-input/props.ts +21 -0
  5. package/components/hy-code-input/typing.d.ts +65 -0
  6. package/components/hy-config-provider/hy-config-provider.vue +0 -1
  7. package/components/hy-dropdown/props.ts +1 -1
  8. package/components/hy-dropdown-item/hy-dropdown-item.vue +2 -5
  9. package/components/hy-dropdown-item/index.scss +11 -13
  10. package/components/hy-grid/hy-grid.vue +5 -5
  11. package/components/hy-icon/index.scss +1 -0
  12. package/components/hy-modal/hy-modal.vue +5 -5
  13. package/components/hy-modal/index.scss +0 -6
  14. package/components/hy-notify/hy-notify.vue +169 -0
  15. package/components/hy-notify/index.scss +25 -0
  16. package/components/hy-notify/props.ts +14 -0
  17. package/components/hy-notify/typing.d.ts +44 -0
  18. package/components/hy-pagination/hy-pagination.vue +125 -0
  19. package/components/hy-pagination/index.scss +46 -0
  20. package/components/hy-pagination/props.ts +15 -0
  21. package/components/hy-pagination/typing.d.ts +44 -0
  22. package/components/hy-picker/index.scss +4 -0
  23. package/components/hy-scroll-list/index.scss +1 -1
  24. package/components/hy-search/index.scss +1 -2
  25. package/components/hy-signature/canvasHelper.ts +51 -0
  26. package/components/hy-signature/hy-signature.vue +656 -0
  27. package/components/hy-signature/index.scss +31 -0
  28. package/components/hy-signature/props.ts +28 -0
  29. package/components/hy-signature/typing.d.ts +177 -0
  30. package/components/hy-slider/index.scss +5 -1
  31. package/components/hy-swipe-action/hy-swipe-action.vue +288 -248
  32. package/components/hy-swipe-action/index.scss +34 -0
  33. package/components/hy-swipe-action/index.ts +34 -0
  34. package/components/hy-swipe-action/props.ts +15 -9
  35. package/components/hy-swipe-action/typing.d.ts +20 -22
  36. package/components/hy-swiper/index.scss +5 -0
  37. package/components/hy-tabs/index.scss +2 -2
  38. package/components/hy-tag/index.scss +1 -1
  39. package/components/hy-textarea/hy-textarea.vue +5 -5
  40. package/components/hy-textarea/index.scss +5 -6
  41. package/components/hy-tooltip/index.scss +2 -2
  42. package/components/hy-upload/index.scss +1 -1
  43. package/composables/index.ts +1 -0
  44. package/composables/useTouch.ts +48 -0
  45. package/libs/css/mixin.scss +52 -13
  46. package/libs/css/vars.css +7 -1
  47. package/package.json +2 -2
  48. package/theme.scss +23 -46
  49. package/components/hy-swipe-action/index.wxs +0 -235
  50. package/components/hy-swipe-action/wxs.js +0 -15
@@ -1,235 +0,0 @@
1
- /**
2
- * 此为wxs模块,只支持APP-VUE,微信和QQ小程序以及H5平台
3
- * wxs内部不支持es6语法,变量只能使用var定义,无法使用解构,箭头函数等特性
4
- */
5
-
6
-
7
- // 开始触摸
8
- function touchstart(event, ownerInstance) {
9
- // 触发事件的组件的ComponentDescriptor实例
10
- var instance = event.instance
11
- // wxs内的局部变量快照,此快照是属于整个组件的,在touchstart和touchmove事件中都能获取到相同的结果
12
- var state = instance.getState()
13
- if (state.disabled) return
14
- var touches = event.touches
15
- // 如果进行的是多指触控,不允许进行操作
16
- if (touches && touches.length > 1) return
17
- // 标识当前为滑动中状态
18
- state.moving = true
19
- // 记录触摸开始点的坐标值
20
- state.startX = touches[0].pageX
21
- state.startY = touches[0].pageY
22
-
23
- ownerInstance.callMethod('closeOther')
24
- }
25
-
26
- // 触摸滑动
27
- function touchmove(event, ownerInstance) {
28
- // 触发事件的组件的ComponentDescriptor实例
29
- var instance = event.instance
30
- // wxs内的局部变量快照
31
- var state = instance.getState()
32
- if (state.disabled || !state.moving) return
33
- var touches = event.touches
34
- var pageX = touches[0].pageX
35
- var pageY = touches[0].pageY
36
- var moveX = pageX - state.startX
37
- var moveY = pageY - state.startY
38
- var buttonsWidth = state.buttonsWidth
39
-
40
- // 移动的X轴距离大于Y轴距离,也即终点与起点位置连线,与X轴夹角小于45度时,禁止页面滚动
41
- if (Math.abs(moveX) > Math.abs(moveY) || Math.abs(moveX) > state.threshold) {
42
- event.preventDefault && event.preventDefault()
43
- event.stopPropagation && event.stopPropagation()
44
- }
45
- // 如果移动的X轴距离小于Y轴距离,也即终点位置与起点位置连线,与Y轴夹角小于45度时,认为是页面上下滑动,而不是左右滑动单元格
46
- if (Math.abs(moveX) < Math.abs(moveY)) return
47
-
48
- // 限制右滑的距离,不允许内容部分往右偏移,右滑会导致X轴偏移值大于0,以此做判断
49
- // 此处不能直接return,因为滑动过程中会缺失某些关键点坐标,会导致错乱,最好的办法就是
50
- // 在超出后,设置为0
51
- if (state.status === 'open') {
52
- // 在开启状态下,向左滑动,需忽略
53
- if (moveX < 0) moveX = 0
54
- // 想要收起菜单,最大能移动的距离为按钮的总宽度
55
- if (moveX > buttonsWidth) moveX = buttonsWidth
56
- // 如果是已经打开了的状态,向左滑动时,移动收起菜单
57
- moveSwipeAction(-buttonsWidth + moveX, instance, ownerInstance)
58
- } else {
59
- // 关闭状态下,右滑动需忽略
60
- if (moveX > 0) moveX = 0
61
- // 滑动的距离不允许超过所有按钮的总宽度,此时只能是左滑,最终设置按钮的总宽度,同时为负数
62
- if (Math.abs(moveX) > buttonsWidth) moveX = -buttonsWidth
63
- // 只要是在滑过程中,就不断移动单元格内容部分,从而使隐藏的菜单显示出来
64
- moveSwipeAction(moveX, instance, ownerInstance)
65
- }
66
- }
67
-
68
- // 触摸结束
69
- function touchend(event, ownerInstance) {
70
- // 触发事件的组件的ComponentDescriptor实例
71
- var instance = event.instance
72
- // wxs内的局部变量快照
73
- var state = instance.getState()
74
- if (!state.moving || state.disabled) return
75
- var touches = event.changedTouches ? event.changedTouches[0] : {}
76
- var pageX = touches.pageX
77
- var pageY = touches.pageY
78
- var moveX = pageX - state.startX
79
- if (state.status === 'open') {
80
- // 在展开的状态下,继续左滑,无需操作
81
- if (moveX < 0) return
82
- // 在开启状态下,点击一下内容区域,moveX为0,也即没有进行移动,这时执行收起菜单逻辑
83
- if (moveX === 0) {
84
- return closeSwipeAction(instance, ownerInstance)
85
- }
86
- // 在开启状态下,滑动距离小于阈值,则默认为不关闭,同时恢复原来的打开状态
87
- if (Math.abs(moveX) < state.threshold) {
88
- openSwipeAction(instance, ownerInstance)
89
- } else {
90
- // 如果滑动距离大于阈值,则执行收起逻辑
91
- closeSwipeAction(instance, ownerInstance)
92
- }
93
- } else {
94
- // 在关闭的状态下,右滑,无需操作
95
- if (moveX > 0) return
96
- // 理由同上
97
- if (Math.abs(moveX) < state.threshold) {
98
- closeSwipeAction(instance, ownerInstance)
99
- } else {
100
- openSwipeAction(instance, ownerInstance)
101
- }
102
- }
103
- }
104
-
105
- // 获取过渡时间
106
- function getDuration(value) {
107
- if (value.toString().indexOf('s') >= 0) return value
108
- return value > 30 ? value + 'ms' : value + 's'
109
- }
110
-
111
- // 滑动结束时判断滑动的方向
112
- function getMoveDirection(instance, ownerInstance) {
113
- var state = instance.getState()
114
- }
115
-
116
- // 移动滑动选择器内容区域,同时显示出其隐藏的菜单
117
- function moveSwipeAction(moveX, instance, ownerInstance) {
118
- var state = instance.getState()
119
- // 获取所有按钮的实例,需要通过它去设置按钮的位移
120
- var buttons = ownerInstance.selectAllComponents('.hy-swipe-action-item__right__button')
121
-
122
- // 设置菜单内容部分的偏移
123
- instance.requestAnimationFrame(function() {
124
- instance.setStyle({
125
- // 设置translateX的值
126
- 'transition': 'none',
127
- transform: 'translateX(' + moveX + 'px)',
128
- '-webkit-transform': 'translateX(' + moveX + 'px)'
129
- })
130
- })
131
- }
132
-
133
- // 一次性展开滑动菜单
134
- function openSwipeAction(instance, ownerInstance) {
135
- var state = instance.getState()
136
- // 获取所有按钮的实例,需要通过它去设置按钮的位移
137
- var buttons = ownerInstance.selectAllComponents('.hy-swipe-action-item__right__button')
138
- // 处理duration单位问题
139
- var duration = getDuration(state.duration)
140
- // 展开过程中,是向左移动,所以X的偏移应该为负值
141
- var buttonsWidth = -state.buttonsWidth
142
- instance.requestAnimationFrame(function() {
143
- // 设置菜单主体内容
144
- instance.setStyle({
145
- 'transition': 'transform ' + duration,
146
- 'transform': 'translateX(' + buttonsWidth + 'px)',
147
- '-webkit-transform': 'translateX(' + buttonsWidth + 'px)',
148
- })
149
- })
150
- setStatus('open', instance, ownerInstance)
151
- }
152
-
153
- // 标记菜单的当前状态,open-已经打开,close-已经关闭
154
- function setStatus(status, instance, ownerInstance) {
155
- var state = instance.getState()
156
- state.status = status
157
- ownerInstance.callMethod('setState', status)
158
- }
159
-
160
- // 一次性收起滑动菜单
161
- function closeSwipeAction(instance, ownerInstance) {
162
- var state = instance.getState()
163
- // 获取所有按钮的实例,需要通过它去设置按钮的位移
164
- var buttons = ownerInstance.selectAllComponents('.hy-swipe-action-item__right__button')
165
- var len = buttons.length
166
- // 处理duration单位问题
167
- var duration = getDuration(state.duration)
168
- instance.requestAnimationFrame(function() {
169
- // 设置菜单主体内容
170
- instance.setStyle({
171
- 'transition': 'transform ' + duration,
172
- 'transform': 'translateX(0px)',
173
- '-webkit-transform': 'translateX(0px)'
174
- })
175
- // 设置各个隐藏的按钮为收起的状态
176
- for (var i = len - 1; i >= 0; i--) {
177
- buttons[i].setStyle({
178
- 'transition': 'transform ' + duration,
179
- 'transform': 'translateX(0px)',
180
- '-webkit-transform': 'translateX(0px)'
181
- })
182
- }
183
- })
184
- setStatus('close', instance, ownerInstance)
185
- }
186
-
187
- // status的状态发生变化
188
- function statusChange(newValue, oldValue, ownerInstance, instance) {
189
- var state = instance.getState()
190
- if (state.disabled) return
191
- // 打开或关闭单元格
192
- if (newValue === 'close' && state.status === 'open') {
193
- closeSwipeAction(instance, ownerInstance)
194
- } else if(newValue === 'open' && state.status === 'close') {
195
- openSwipeAction(instance, ownerInstance)
196
- }
197
- }
198
-
199
- // 菜单尺寸发生变化
200
- function sizeChange(newValue, oldValue, ownerInstance, instance) {
201
- // wxs内的局部变量快照
202
- var state = instance.getState()
203
- // 临时防止nv_disabled报错
204
- if (!state || !newValue) {
205
- return;
206
- }
207
- state.disabled = newValue.disabled
208
- state.duration = newValue.duration
209
- state.show = newValue.show
210
- state.threshold = newValue.threshold
211
- state.buttons = newValue.buttons
212
-
213
- if (state.buttons) {
214
- var len = state.buttons.length
215
- var buttonsWidth = 0
216
- var buttons = newValue.buttons
217
- for (var i = 0; i < len; i++) {
218
- buttonsWidth += buttons[i].width
219
- }
220
- }
221
- state.buttonsWidth = buttonsWidth
222
-
223
- // 支持默认打开
224
- if (state.show) {
225
- openSwipeAction(instance, ownerInstance)
226
- }
227
- }
228
-
229
- module.exports = {
230
- touchstart: touchstart,
231
- touchmove: touchmove,
232
- touchend: touchend,
233
- sizeChange: sizeChange,
234
- statusChange: statusChange
235
- }
@@ -1,15 +0,0 @@
1
- export default {
2
- methods: {
3
- // 关闭时执行
4
- closeHandler() {
5
- this.status = 'close'
6
- },
7
- setState(status) {
8
- this.status = status
9
- },
10
- closeOther() {
11
- // 尝试关闭其他打开的单元格
12
- this.parent && this.parent.closeOther(this)
13
- }
14
- }
15
- }