@mpxjs/webpack-plugin 2.9.70-alpha.0 → 2.9.71

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 (126) hide show
  1. package/LICENSE +433 -0
  2. package/README.md +1 -1
  3. package/lib/config.js +0 -14
  4. package/lib/dependencies/ResolveDependency.js +0 -5
  5. package/lib/index.js +7 -38
  6. package/lib/json-compiler/helper.js +3 -3
  7. package/lib/loader.js +0 -53
  8. package/lib/parser.js +1 -1
  9. package/lib/platform/json/wx/index.js +21 -8
  10. package/lib/platform/style/wx/index.js +51 -54
  11. package/lib/platform/template/wx/component-config/button.js +2 -14
  12. package/lib/platform/template/wx/component-config/fix-component-name.js +15 -12
  13. package/lib/platform/template/wx/component-config/image.js +0 -4
  14. package/lib/platform/template/wx/component-config/index.js +1 -1
  15. package/lib/platform/template/wx/component-config/input.js +0 -4
  16. package/lib/platform/template/wx/component-config/movable-view.js +8 -1
  17. package/lib/platform/template/wx/component-config/picker-view.js +1 -5
  18. package/lib/platform/template/wx/component-config/rich-text.js +6 -2
  19. package/lib/platform/template/wx/component-config/scroll-view.js +1 -5
  20. package/lib/platform/template/wx/component-config/switch.js +0 -4
  21. package/lib/platform/template/wx/component-config/text.js +0 -4
  22. package/lib/platform/template/wx/component-config/textarea.js +0 -5
  23. package/lib/platform/template/wx/component-config/unsupported.js +1 -1
  24. package/lib/platform/template/wx/component-config/view.js +0 -4
  25. package/lib/platform/template/wx/index.js +1 -131
  26. package/lib/resolve-loader.js +1 -4
  27. package/lib/runtime/components/react/context.ts +8 -0
  28. package/lib/runtime/components/react/dist/context.js +2 -0
  29. package/lib/runtime/components/react/dist/getInnerListeners.js +39 -37
  30. package/lib/runtime/components/react/dist/mpx-button.jsx +16 -44
  31. package/lib/runtime/components/react/dist/mpx-canvas/html.js +2 -4
  32. package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +5 -1
  33. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +93 -58
  34. package/lib/runtime/components/react/dist/mpx-navigator.jsx +1 -1
  35. package/lib/runtime/components/react/dist/mpx-picker-view-column-item.jsx +10 -14
  36. package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +94 -81
  37. package/lib/runtime/components/react/dist/mpx-picker-view.jsx +19 -16
  38. package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +10 -11
  39. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +11 -4
  40. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +31 -8
  41. package/lib/runtime/components/react/dist/mpx-swiper.jsx +435 -371
  42. package/lib/runtime/components/react/dist/mpx-view.jsx +18 -53
  43. package/lib/runtime/components/react/dist/pickerFaces.js +3 -8
  44. package/lib/runtime/components/react/dist/pickerVIewContext.js +5 -0
  45. package/lib/runtime/components/react/dist/{pickerViewOverlay.jsx → pickerViewIndicator.jsx} +6 -6
  46. package/lib/runtime/components/react/dist/pickerViewMask.jsx +2 -2
  47. package/lib/runtime/components/react/dist/useAnimationHooks.js +27 -10
  48. package/lib/runtime/components/react/dist/utils.jsx +162 -70
  49. package/lib/runtime/components/react/event.config.ts +25 -26
  50. package/lib/runtime/components/react/getInnerListeners.ts +236 -182
  51. package/lib/runtime/components/react/mpx-button.tsx +27 -69
  52. package/lib/runtime/components/react/mpx-canvas/html.ts +2 -4
  53. package/lib/runtime/components/react/mpx-canvas/index.tsx +44 -46
  54. package/lib/runtime/components/react/mpx-checkbox-group.tsx +15 -13
  55. package/lib/runtime/components/react/mpx-checkbox.tsx +20 -21
  56. package/lib/runtime/components/react/mpx-form.tsx +15 -20
  57. package/lib/runtime/components/react/mpx-icon.tsx +2 -2
  58. package/lib/runtime/components/react/mpx-image.tsx +87 -47
  59. package/lib/runtime/components/react/mpx-input.tsx +24 -32
  60. package/lib/runtime/components/react/mpx-label.tsx +12 -14
  61. package/lib/runtime/components/react/mpx-movable-area.tsx +10 -16
  62. package/lib/runtime/components/react/mpx-movable-view.tsx +133 -92
  63. package/lib/runtime/components/react/mpx-navigator.tsx +3 -9
  64. package/lib/runtime/components/react/mpx-picker-view-column-item.tsx +76 -0
  65. package/lib/runtime/components/react/mpx-picker-view-column.tsx +206 -183
  66. package/lib/runtime/components/react/mpx-picker-view.tsx +49 -48
  67. package/lib/runtime/components/react/mpx-radio-group.tsx +13 -15
  68. package/lib/runtime/components/react/mpx-radio.tsx +19 -25
  69. package/lib/runtime/components/react/mpx-rich-text/html.ts +40 -0
  70. package/lib/runtime/components/react/mpx-rich-text/index.tsx +115 -0
  71. package/lib/runtime/components/react/mpx-root-portal.tsx +3 -5
  72. package/lib/runtime/components/react/mpx-scroll-view.tsx +53 -43
  73. package/lib/runtime/components/react/mpx-swiper-item.tsx +45 -11
  74. package/lib/runtime/components/react/mpx-swiper.tsx +742 -0
  75. package/lib/runtime/components/react/mpx-switch.tsx +19 -15
  76. package/lib/runtime/components/react/mpx-text.tsx +8 -16
  77. package/lib/runtime/components/react/mpx-textarea.tsx +11 -10
  78. package/lib/runtime/components/react/mpx-view.tsx +28 -77
  79. package/lib/runtime/components/react/mpx-web-view.tsx +94 -59
  80. package/lib/runtime/components/react/pickerFaces.ts +10 -7
  81. package/lib/runtime/components/react/pickerVIewContext.ts +27 -0
  82. package/lib/runtime/components/react/pickerViewIndicator.tsx +34 -0
  83. package/lib/runtime/components/react/pickerViewMask.tsx +30 -0
  84. package/lib/runtime/components/react/types/{getInnerListeners.ts → getInnerListeners.d.ts} +4 -5
  85. package/lib/runtime/components/react/types/global.d.ts +12 -1
  86. package/lib/runtime/components/react/useAnimationHooks.ts +60 -15
  87. package/lib/runtime/components/react/utils.tsx +175 -71
  88. package/lib/runtime/components/web/mpx-checkbox.vue +1 -1
  89. package/lib/runtime/components/web/mpx-picker-view-column.vue +9 -4
  90. package/lib/runtime/components/web/mpx-web-view.vue +34 -20
  91. package/lib/runtime/optionProcessor.js +0 -22
  92. package/lib/style-compiler/index.js +1 -1
  93. package/lib/style-compiler/plugins/scope-id.js +30 -2
  94. package/lib/template-compiler/compiler.js +91 -39
  95. package/lib/utils/env.js +1 -6
  96. package/lib/utils/pre-process-json.js +9 -5
  97. package/lib/wxss/loader.js +15 -2
  98. package/package.json +4 -7
  99. package/lib/dependencies/AddEntryDependency.js +0 -24
  100. package/lib/runtime/components/react/dist/types/common.js +0 -1
  101. package/lib/runtime/components/react/dist/types/getInnerListeners.js +0 -1
  102. package/lib/runtime/components/react/mpx-swiper/carouse.tsx +0 -527
  103. package/lib/runtime/components/react/mpx-swiper/index.tsx +0 -80
  104. package/lib/runtime/components/react/mpx-swiper/type.ts +0 -87
  105. package/lib/runtime/components/react/pickerOverlay.tsx +0 -32
  106. package/lib/runtime/components/tenon/getInnerListeners.js +0 -334
  107. package/lib/runtime/components/tenon/tenon-button.vue +0 -309
  108. package/lib/runtime/components/tenon/tenon-image.vue +0 -66
  109. package/lib/runtime/components/tenon/tenon-input.vue +0 -171
  110. package/lib/runtime/components/tenon/tenon-rich-text.vue +0 -26
  111. package/lib/runtime/components/tenon/tenon-scroll-view.vue +0 -127
  112. package/lib/runtime/components/tenon/tenon-switch.vue +0 -96
  113. package/lib/runtime/components/tenon/tenon-text.vue +0 -70
  114. package/lib/runtime/components/tenon/tenon-textarea.vue +0 -86
  115. package/lib/runtime/components/tenon/tenon-view.vue +0 -93
  116. package/lib/runtime/components/web/event.js +0 -105
  117. package/lib/runtime/optionProcessor.tenon.js +0 -84
  118. package/lib/style-compiler/plugins/hm.js +0 -20
  119. package/lib/tenon/index.js +0 -117
  120. package/lib/tenon/processJSON.js +0 -352
  121. package/lib/tenon/processScript.js +0 -203
  122. package/lib/tenon/processStyles.js +0 -21
  123. package/lib/tenon/processTemplate.js +0 -126
  124. package/lib/tenon/script-helper.js +0 -223
  125. package/lib/utils/get-relative-path.js +0 -25
  126. /package/lib/runtime/components/react/types/{common.ts → common.d.ts} +0 -0
@@ -1,32 +0,0 @@
1
- import React from 'react'
2
- import { StyleProp, StyleSheet, View, ViewStyle } from 'react-native'
3
-
4
- type OverlayProps = {
5
- itemHeight: number
6
- overlayItemStyle?: StyleProp<ViewStyle>
7
- overlayContainerStyle?: StyleProp<ViewStyle>
8
- }
9
-
10
- const Overlay = ({ itemHeight, overlayItemStyle, overlayContainerStyle }: OverlayProps) => {
11
- return (
12
- <View style={[styles.overlayContainer, overlayContainerStyle]} pointerEvents={'none'}>
13
- <View style={[styles.selection, { height: itemHeight }, overlayItemStyle]} />
14
- </View>
15
- )
16
- }
17
-
18
- const styles = StyleSheet.create({
19
- overlayContainer: {
20
- ...StyleSheet.absoluteFillObject,
21
- justifyContent: 'center',
22
- alignItems: 'center'
23
- },
24
- selection: {
25
- borderTopWidth: 1,
26
- borderBottomWidth: 1,
27
- borderColor: 'rgba(0, 0, 0, 0.05)',
28
- alignSelf: 'stretch'
29
- }
30
- })
31
-
32
- export default React.memo(Overlay)
@@ -1,334 +0,0 @@
1
- import { isEmptyObject } from '../../utils'
2
-
3
- const tapEvents = [
4
- 'onTouchstart',
5
- 'onTouchmove',
6
- 'onTouchcancel',
7
- 'onTouchend',
8
- 'onLongtap'
9
- ]
10
-
11
- function createTouch (context, hasLongTap, __mpxTapInfo) {
12
- return ({
13
- onTouch (e) {
14
- // 用touch模拟longtap
15
- switch (e.state) {
16
- case 1:
17
- context.$emit('touchstart', e)
18
- __mpxTapInfo.detail = {
19
- x: e.position.x,
20
- y: e.position.y
21
- }
22
- __mpxTapInfo.startTimer = null
23
-
24
- if (hasLongTap) {
25
- __mpxTapInfo.startTimer = setTimeout(() => {
26
- if (hasLongTap) {
27
- const re = inheritEvent(
28
- 'longtap',
29
- e,
30
- __mpxTapInfo.detail
31
- )
32
- context.$emit('longtap', re)
33
- __mpxTapInfo.startTimer = null
34
- }
35
- }, 350)
36
- }
37
-
38
- break
39
- case 2:
40
- context.$emit('touchmove', e)
41
- if (
42
- Math.abs(e.position.x - __mpxTapInfo.detail.x) > 1 ||
43
- Math.abs(e.position.y - __mpxTapInfo.detail.y) > 1
44
- ) {
45
- __mpxTapInfo.startTimer &&
46
- clearTimeout(__mpxTapInfo.startTimer)
47
- __mpxTapInfo.startTimer = null
48
- }
49
- break
50
- case 3:
51
- context.$emit('touchend', e)
52
- __mpxTapInfo.startTimer &&
53
- clearTimeout(__mpxTapInfo.startTimer)
54
- __mpxTapInfo.startTimer = null
55
- break
56
- case 4:
57
- context.$emit('touchcancel', e)
58
- break
59
- }
60
- }
61
- })
62
- }
63
-
64
- function processOriginEvent (listeners, context, _input) {
65
- // 给event添加_originEvent属性
66
- const ignoreEvents = ['onTap', 'onFocus', 'onChange', 'onBlur', 'onConfirm', 'onInput']
67
- Object.keys(listeners).forEach((key) => {
68
- if (!ignoreEvents.includes(key)) {
69
- const listener = listeners[key]
70
- listeners[key] = function (e) {
71
- if (e) {
72
- e._originEvent = { ...e }
73
- }
74
- listener.call(this, e)
75
- }
76
- }
77
- })
78
-
79
- // 处理input输入框事件
80
- if (listeners.onInput && _input) {
81
- delete listeners.onInput
82
- listeners.onInput = function (e) {
83
- let _type
84
- const { state } = e || {}
85
- if (state === 1) {
86
- _type = 'focus'
87
- } else if (state === 2) {
88
- _type = 'focus'
89
- } else if (state === 3) {
90
- _type = 'blur'
91
- } else {
92
- _type = 'confirm'
93
- }
94
- context.$emit(_type, { ...e, detail: e })
95
- }
96
- }
97
- }
98
-
99
- function processModel (listeners, context, _input = false) {
100
- // 该函数只有wx:model的情况下才调用,而且默认e.detail.value有值
101
- // 该函数必须在产生merge前执行
102
- // todo 此处对于$attrs的访问会导致父组件更新时子组件必然更新,暂时用短路效应避免影响,待优化
103
- // todo 访问$listeners也会导致上述现象,但是为了事件代理还必须访问$listeners,待后续思考处理
104
- const modelEvent = context.$attrs.mpxModelEvent
105
- const modelEventId = context.$attrs.mpxModelEventId
106
- if (modelEvent && modelEventId) {
107
- // 对于modelEvent,内部获得时间后向外部转发,触发外部listener的同时转发为mpxModel事件
108
-
109
- const listener = listeners.onInput
110
-
111
- listeners.onInput = function (e) {
112
- Hummer.notifyCenter.triggerEvent(modelEventId, {
113
- detail: e
114
- })
115
- context.$emit('mpxModel', {
116
- detail: e
117
- })
118
- listener && listener.call(this, e)
119
- }
120
- // 内部listener不需要mpxModel
121
- delete listeners.mpxModel
122
- }
123
- }
124
-
125
- function mergeListeners (listeners, otherListeners, options = {}, context, __mpxTapInfo) {
126
- if (!otherListeners) {
127
- return
128
- }
129
- // "onTouchstart",
130
- // "onTouchmove",
131
- // "onTouchcancel",
132
- // "onTouchend",
133
- // "onLongtap",
134
-
135
- // 都依赖touch事件 如果listener没有touch事件 如果是force需要强行添加一个touch事件 longTap需要根据context
136
- // 特殊处理
137
- const listenerMap = {}
138
- tapEvents.forEach((eventName) => {
139
- if (listeners[eventName]) {
140
- listenerMap[eventName] = true
141
- delete listeners[eventName]
142
- }
143
- })
144
- // const otherListenerKeys = Object.keys(otherListeners)
145
- // for (let key of otherListenerKeys) {
146
-
147
- // }
148
-
149
- Object.keys(otherListeners).forEach((key) => {
150
- const listener = otherListeners[key]
151
- let rawListener
152
- if (tapEvents.includes(key)) {
153
- // 判断onTouch是否存在 若存在 则直接处理
154
- rawListener = listeners.onTouch
155
-
156
- if (!rawListener && !options.force) {
157
- return
158
- } else if (!rawListener && options.force) {
159
- // 创建一个touh事件 并赋值
160
- listeners.onTouch = createTouch(context, listenerMap.onLongtap, __mpxTapInfo).onTouch
161
- rawListener = listeners.onTouch
162
- }
163
- // 事件处理 onTouchstart 1 onTouchmove 2 onTouchend 3 onTouchcancel 4
164
- listeners.onTouch = function (e) {
165
- // const thatKey = key
166
- let timer = null
167
- if (key === 'onLongtap') {
168
- if (e.state === 1) {
169
- // start
170
- timer = setTimeout(
171
- () => {
172
- listener.call(this, e)
173
- },
174
- options.before ? 340 : 360
175
- )
176
- } else if (e.state === 3) {
177
- timer && clearTimeout(timer)
178
- timer = null
179
- }
180
- } else {
181
- if (options.before) {
182
- if (key === 'onTouchstart' && e.state === 1) {
183
- listener.call(this, e)
184
- } else if (key === 'onTouchmove' && e.state === 2) {
185
- listener.call(this, e)
186
- } else if (key === 'onTouchend' && e.state === 3) {
187
- listener.call(this, e)
188
- } else if (key === 'onTouchcancel' && e.state === 4) {
189
- listener.call(this, e)
190
- }
191
- rawListener.call(this, e)
192
- } else {
193
- rawListener.call(this, e)
194
- if (key === 'onTouchstart' && e.state === 1) {
195
- listener.call(this, e)
196
- } else if (key === 'onTouchmove' && e.state === 2) {
197
- listener.call(this, e)
198
- } else if (key === 'onTouchend' && e.state === 3) {
199
- listener.call(this, e)
200
- } else if (key === 'onTouchcancel' && e.state === 4) {
201
- listener.call(this, e)
202
- }
203
- }
204
- }
205
- }
206
- } else {
207
- rawListener = listeners[key]
208
- if (!rawListener) {
209
- if (options.force) {
210
- listeners[key] = listener
211
- }
212
- } else {
213
- listeners[key] = function (e) {
214
- if (options.before) {
215
- listener.call(this, e)
216
- rawListener.call(this, e)
217
- } else {
218
- rawListener.call(this, e)
219
- listener.call(this, e)
220
- }
221
- }
222
- }
223
- }
224
- })
225
- }
226
- // 没有tap 用touch模拟 touchstart touchmove touchcancel touchend tap longpress langtap
227
- function processTouchAndLtap (listeners, context, __mpxTapInfo) {
228
- const listenerMap = {}
229
- tapEvents.forEach((eventName) => {
230
- if (listeners[eventName]) {
231
- listenerMap[eventName] = true
232
- delete listeners[eventName]
233
- }
234
- })
235
- if (isEmptyObject(listenerMap)) return
236
- const events = createTouch(context, listenerMap.onLongtap, __mpxTapInfo)
237
- mergeListeners(
238
- listeners,
239
- events,
240
- {
241
- force: true
242
- },
243
- context,
244
- __mpxTapInfo
245
- )
246
- }
247
-
248
- export function extendEvent (e, extendObj = {}) {
249
- Object.keys(extendObj).forEach((key) => {
250
- Object.defineProperty(e, key, {
251
- value: extendObj[key],
252
- enumerable: true,
253
- configurable: true,
254
- writable: true
255
- })
256
- })
257
- }
258
-
259
- export function inheritEvent (type, oe, detail = {}) {
260
- detail = Object.assign({}, oe.detail, detail)
261
- const ne = getCustomEvent(type, detail)
262
- extendEvent(ne, {
263
- timeStamp: oe.timeStamp,
264
- target: oe.target,
265
- currentTarget: oe.currentTarget,
266
- stopPropagation: oe.stopPropagation.bind(oe),
267
- preventDefault: oe.preventDefault.bind(oe)
268
- })
269
- return ne
270
- }
271
-
272
- export function getCustomEvent (type, detail = {}, target = null) {
273
- return {
274
- type,
275
- detail,
276
- target,
277
- timeStamp: new Date().valueOf()
278
- }
279
- }
280
-
281
- function noop () {}
282
-
283
- function getListeners (context) {
284
- const attrs = context.$attrs
285
- const listeners = {}
286
- Object.keys(attrs).forEach((v) => {
287
- if (/^on[A-Z]/.test(v)) {
288
- listeners[v] = attrs[v]
289
- }
290
- })
291
- return listeners
292
- }
293
-
294
- export default function getInnerListeners (context, options = {}) {
295
- let {
296
- mergeBefore = {},
297
- mergeAfter = {},
298
- defaultListeners = [],
299
- ignoredListeners = [],
300
- _input = false
301
- } = options
302
- const __mpxTapInfo = {}
303
- // 从attrs里面拿到以on开头的所有绑定的事件
304
- const listeners = Object.assign({}, getListeners(context))
305
-
306
- defaultListeners.forEach((key) => {
307
- if (!listeners[key]) listeners[key] = noop
308
- })
309
- const mergeBeforeOptions = {
310
- before: true
311
- }
312
- const mergeAfterOptions = {
313
- before: false
314
- }
315
-
316
- if (mergeBefore.listeners) {
317
- mergeBeforeOptions.force = mergeBefore.force
318
- mergeBefore = mergeBefore.listeners
319
- }
320
-
321
- if (mergeAfter.listeners) {
322
- mergeAfterOptions.force = mergeAfter.force
323
- mergeAfter = mergeAfter.listeners
324
- }
325
- processOriginEvent(listeners, context, _input)
326
- processModel(listeners, context, _input)
327
- processTouchAndLtap(listeners, context, __mpxTapInfo)
328
- mergeListeners(listeners, mergeBefore, mergeBeforeOptions, context, __mpxTapInfo)
329
- mergeListeners(listeners, mergeAfter, mergeAfterOptions, context, __mpxTapInfo)
330
- ignoredListeners.forEach((key) => {
331
- delete listeners[key]
332
- })
333
- return listeners
334
- }
@@ -1,309 +0,0 @@
1
- <script>
2
- import { h } from "@hummer/tenon-vue";
3
- import getInnerListeners from "./getInnerListeners";
4
-
5
- // 获取当前小程序样式版本配置
6
- const styleVersion = global.__style || "";
7
- const sizeClassMap = {
8
- default: "",
9
- mini: "mpx-button-size-mini",
10
- };
11
- const typeClassMap = {
12
- primary: "mpx-button-type-primary",
13
- warn: "mpx-button-type-warn",
14
- };
15
- const plainClassMap = {
16
- false: "",
17
- true: "mpx-button-plain",
18
- };
19
- const disabledClassMap = {
20
- false: "",
21
- true: "mpx-button-disabled",
22
- };
23
- const clickDisabledClassMap = {
24
- false: "",
25
- true: "mpx-button-click-disabled",
26
- };
27
- export default (function(){
28
- return {
29
- name: "mpx-button",
30
- data() {
31
- return {
32
- hover: false,
33
- };
34
- },
35
- props: {
36
- name: String,
37
- size: {
38
- type: String,
39
- default: "default",
40
- },
41
- type: {
42
- type: String,
43
- default: "default",
44
- },
45
- plain: Boolean,
46
- disabled: Boolean,
47
- loading: Boolean,
48
- formType: String,
49
- hoverClass: {
50
- type: String,
51
- default: "button-hover",
52
- },
53
- hoverStopPropagation: {
54
- type: Boolean,
55
- default: false,
56
- },
57
- hoverStartTime: {
58
- type: Number,
59
- default: 20,
60
- },
61
- hoverStayTime: {
62
- type: Number,
63
- default: 70,
64
- },
65
- },
66
- computed: {
67
- originRef() {
68
- return this.$refs["mpx-button"]
69
- },
70
- className() {
71
- if (this.hoverClass && this.hoverClass !== "none" && this.hover) {
72
- return this.hoverClass;
73
- }
74
- return "";
75
- },
76
- classNameList() {
77
- let classArr = [];
78
- if (this.hoverClass && this.hoverClass !== "none" && this.hover) {
79
- classArr.push(this.hoverClass);
80
- }
81
- if (styleVersion === "v2") {
82
- classArr.push(`${sizeClassMap[this.size]}${styleVersion}`);
83
- classArr.push(`${typeClassMap[this.type]}${styleVersion}`);
84
- classArr.push(`mpx-button-version${styleVersion}`);
85
- } else {
86
- classArr.push(sizeClassMap[this.size]);
87
- classArr.push(typeClassMap[this.type]);
88
- classArr.push(`mpx-button-version`);
89
- }
90
- classArr.push(plainClassMap[this.plain]);
91
- classArr.push(disabledClassMap["" + !!this.disabled]);
92
- // 禁用click
93
- classArr.push(clickDisabledClassMap["" + !!this.disabled]);
94
- return classArr;
95
- },
96
- },
97
- render() {
98
- let mergeAfter;
99
- if (this.hoverClass && this.hoverClass !== "none") {
100
- mergeAfter = {
101
- listeners: {
102
- onTouchstart: this.handleTouchstart,
103
- onTouchend: this.handleTouchend,
104
- },
105
- force: true,
106
- };
107
- }
108
- const domProps = {
109
- disabled: this.disabled,
110
- plain: this.plain,
111
- type: this.type,
112
- };
113
- const data = {
114
- class: ["mpx-button", ...this.classNameList],
115
- ref: "mpx-button",
116
- ...domProps,
117
- ...getInnerListeners(this, {
118
- mergeAfter,
119
- // 由于当前机制下tap事件只有存在tap监听才会触发,为了确保该组件能够触发tap,传递一个包含tap的defaultListeners用于模拟存在tap监听
120
- defaultListeners: ["onTap"],
121
- }),
122
- };
123
-
124
- let text = "";
125
- const nodes = this.$slots.default();
126
- nodes.forEach((item) => {
127
- if (item.shapeFlag === 8 && item.children) {
128
- text += item.children;
129
- }
130
- });
131
- return h("button", data, text);
132
- },
133
- methods: {
134
- handleTouchstart(e) {
135
- if (e.__hoverStopPropagation) {
136
- return;
137
- }
138
- e.__hoverStopPropagation = this.hoverStopPropagation;
139
- clearTimeout(this.startTimer);
140
- this.startTimer = setTimeout(() => {
141
- this.hover = true;
142
- }, this.hoverStartTime);
143
- },
144
- handleTouchend() {
145
- clearTimeout(this.endTimer);
146
- this.endTimer = setTimeout(() => {
147
- this.hover = false;
148
- }, this.hoverStayTime);
149
- },
150
- },
151
- }
152
- })()
153
- </script>
154
-
155
-
156
-
157
- <style lang="stylus" scoped>
158
- .mpx-button-versionv2
159
- width: 184px
160
- line-height 1.41176471
161
- font-weight: 700;
162
- padding-top 8px
163
- padding-bottom 8px
164
- .mpx-button-version
165
- width: 100%
166
- line-height 2.55555556
167
- cursor: pointer
168
- &:after
169
- border 1px solid rgba(0,0,0,.2)
170
-
171
- .mpx-button
172
- padding-left: 14px
173
- padding-right: 14px
174
- border none
175
- outline: none
176
- position relative
177
- display block
178
- margin-left auto
179
- margin-right auto
180
- margin-bottom 10px
181
- box-sizing border-box
182
- font-size 18px
183
- text-align center
184
- text-decoration none
185
- border-radius 5px
186
- -webkit-tap-highlight-color transparent
187
- overflow hidden
188
- color #000
189
- background-color #f8f8f8
190
- &:after
191
- content " "
192
- width 200%
193
- height 200%
194
- position absolute
195
- top 0
196
- left 0
197
- -webkit-transform scale(.5)
198
- transform scale(.5)
199
- -webkit-transform-origin 0 0
200
- transform-origin 0 0
201
- box-sizing border-box
202
- border-radius 10px
203
-
204
- &.button-hover
205
- background-color #dedede
206
-
207
- /* 默认版本 size=mini style */
208
- &.mpx-button-size-mini
209
- display inline-block
210
- line-height 2.3
211
- font-size 13px
212
- padding 0 1.34em
213
- width auto
214
- /* v2 size=mini style */
215
- &.mpx-button-size-miniv2
216
- width auto
217
- padding 0 0.75em
218
- line-height 2
219
- font-size 16px
220
- display inline-block
221
- &.mpx-button-plain
222
- color #353535
223
- border 1px solid #353535
224
- background-color transparent
225
- &.mpx-button-plain.button-hover
226
- background-color rgba(0, 0, 0, 0)
227
- color #828282
228
- border 1px solid #828282
229
-
230
- /* 默认版本 type=primary style */
231
- &.mpx-button-type-primary
232
- background-color #1aad19
233
- color #fff
234
- &.mpx-button-type-primary.mpx-button-plain
235
- color #1aad19
236
- border-color #1aad19
237
- background-color #fff
238
- /* v2 type=primary style */
239
- &.mpx-button-type-primaryv2
240
- background-color #07c160
241
- color #fff
242
- &.mpx-button-type-primaryv2.button-hover
243
- color #fff
244
- background-color #06ad56
245
- &.mpx-button-type-primaryv2.mpx-button-plain
246
- color #06ae56
247
- border-color #179c16
248
- background-color #fff
249
- &.mpx-button-type-primaryv2.button-hover.mpx-button-plain
250
- color #06ae56
251
- background-color rgba(0, 0, 0, .1)
252
-
253
- /* 默认版本 type=warn style */
254
- &.mpx-button-type-warn
255
- color #fff
256
- background-color #e64340
257
- &.mpx-button-type-warn.mpx-button-plain
258
- color #e64340
259
- background-color transparent
260
- border 1px solid #e64340
261
- /* v2 type=warn style */
262
- &.mpx-button-type-warnv2
263
- color #fa5151
264
- background-color #f2f2f2
265
- &.mpx-button-type-warnv2.button-hover
266
- background-color #d9d9d9
267
- &.mpx-button-type-warnv2.mpx-button-plain
268
- color #fa5151
269
- background-color #fff
270
- border 1px solid #e64340
271
- &.mpx-button-type-warnv2.button-hover.mpx-button-plain
272
- color: #f58c8d
273
- border 1px solid #f58a8b
274
- background-color #fff
275
-
276
- &.mpx-button-disabled
277
- color rgba(0, 0, 0, 0.18) !important
278
- background-color #fafafa !important
279
- border 1px solid rgba(0, 0, 0, .2) !important
280
- &.mpx-button-click-disabled
281
- pointer-events none
282
- &.mpx-button-loading
283
- &.mpx-button-type-warn
284
- color rgba(255,255,255,.6)
285
- background-color #ce3c39
286
- &.mpx-button-type-warnv2
287
- background-color #d9d9d9
288
- color #fa5151
289
- &.mpx-button-type-primary
290
- color: rgba(255,255,255,.6);
291
- background-color: #179b16;
292
- &:before
293
- content: " "
294
- display: inline-block
295
- width: 18px
296
- height: 18px
297
- vertical-align: middle
298
- -webkit-animation: mpxButton 1s steps(12,end) infinite
299
- animation: mpxButton 1s steps(12,end) infinite
300
- background transparent url('data:image/svg+xml;base64,PHN2ZyBjbGFzcz0iciIgd2lkdGg9JzEyMHB4JyBoZWlnaHQ9JzEyMHB4JyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIj4KICAgIDxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAiIGhlaWdodD0iMTAwIiBmaWxsPSJub25lIiBjbGFzcz0iYmsiPjwvcmVjdD4KICAgIDxyZWN0IHg9JzQ2LjUnIHk9JzQwJyB3aWR0aD0nNycgaGVpZ2h0PScyMCcgcng9JzUnIHJ5PSc1JyBmaWxsPScjRTlFOUU5JwogICAgICAgICAgdHJhbnNmb3JtPSdyb3RhdGUoMCA1MCA1MCkgdHJhb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naHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNFMkUyRTInCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgzMzAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0Pgo8L3N2Zz4=') no-repeat
301
- background-size: 100%
302
- margin -0.2em 0.34em 0 0
303
-
304
- @keyframes mpxButton
305
- 0%
306
- transform: rotate3d(0, 0, 1, 0deg)
307
- 100%
308
- transform: rotate3d(0, 0, 1, 360deg)
309
- </style>