@mpxjs/webpack-plugin 2.10.3 → 2.10.4-beta.11
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/lib/config.js +2 -1
- package/lib/index.js +1 -1
- package/lib/platform/json/wx/index.js +6 -4
- package/lib/platform/style/wx/index.js +42 -30
- package/lib/platform/template/wx/component-config/button.js +20 -3
- package/lib/platform/template/wx/component-config/canvas.js +4 -0
- package/lib/platform/template/wx/component-config/checkbox-group.js +4 -0
- package/lib/platform/template/wx/component-config/checkbox.js +4 -0
- package/lib/platform/template/wx/component-config/cover-image.js +7 -1
- package/lib/platform/template/wx/component-config/cover-view.js +4 -0
- package/lib/platform/template/wx/component-config/fix-component-name.js +3 -2
- package/lib/platform/template/wx/component-config/form.js +7 -1
- package/lib/platform/template/wx/component-config/icon.js +4 -0
- package/lib/platform/template/wx/component-config/image.js +7 -1
- package/lib/platform/template/wx/component-config/index.js +5 -1
- package/lib/platform/template/wx/component-config/input.js +19 -4
- package/lib/platform/template/wx/component-config/label.js +4 -0
- package/lib/platform/template/wx/component-config/movable-area.js +7 -1
- package/lib/platform/template/wx/component-config/movable-view.js +12 -3
- package/lib/platform/template/wx/component-config/navigator.js +4 -0
- package/lib/platform/template/wx/component-config/picker-view-column.js +4 -0
- package/lib/platform/template/wx/component-config/picker-view.js +7 -1
- package/lib/platform/template/wx/component-config/picker.js +7 -1
- package/lib/platform/template/wx/component-config/radio-group.js +4 -0
- package/lib/platform/template/wx/component-config/radio.js +4 -0
- package/lib/platform/template/wx/component-config/rich-text.js +4 -0
- package/lib/platform/template/wx/component-config/root-portal.js +4 -0
- package/lib/platform/template/wx/component-config/scroll-view.js +10 -2
- package/lib/platform/template/wx/component-config/sticky-header.js +23 -0
- package/lib/platform/template/wx/component-config/sticky-section.js +23 -0
- package/lib/platform/template/wx/component-config/swiper-item.js +7 -1
- package/lib/platform/template/wx/component-config/swiper.js +12 -3
- package/lib/platform/template/wx/component-config/switch.js +4 -0
- package/lib/platform/template/wx/component-config/text.js +24 -3
- package/lib/platform/template/wx/component-config/textarea.js +17 -2
- package/lib/platform/template/wx/component-config/unsupported.js +7 -0
- package/lib/platform/template/wx/component-config/video.js +10 -2
- package/lib/platform/template/wx/component-config/view.js +11 -1
- package/lib/platform/template/wx/component-config/web-view.js +4 -0
- package/lib/platform/template/wx/index.js +42 -75
- package/lib/react/processJSON.js +7 -6
- package/lib/react/processScript.js +1 -18
- package/lib/runtime/components/react/context.ts +12 -3
- package/lib/runtime/components/react/dist/context.js +4 -1
- package/lib/runtime/components/react/dist/event.config.js +0 -1
- package/lib/runtime/components/react/dist/getInnerListeners.js +127 -142
- package/lib/runtime/components/react/dist/mpx-button.jsx +4 -5
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +4 -5
- package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-checkbox.jsx +2 -3
- package/lib/runtime/components/react/dist/mpx-form.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-icon/index.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-image.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-inline-text.jsx +11 -0
- package/lib/runtime/components/react/dist/mpx-input.jsx +20 -17
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +24 -31
- package/lib/runtime/components/react/dist/mpx-label.jsx +2 -3
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-navigator.jsx +11 -3
- package/lib/runtime/components/react/dist/mpx-picker/date.jsx +194 -68
- package/lib/runtime/components/react/dist/mpx-picker/dateData.js +17 -0
- package/lib/runtime/components/react/dist/mpx-picker/index.jsx +180 -98
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +79 -139
- package/lib/runtime/components/react/dist/mpx-picker/region.jsx +190 -90
- package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +60 -75
- package/lib/runtime/components/react/dist/mpx-picker/time.jsx +100 -228
- package/lib/runtime/components/react/dist/{mpx-picker-view.jsx → mpx-picker-view/index.jsx} +5 -6
- package/lib/runtime/components/react/dist/{mpx-picker-view-column.jsx → mpx-picker-view-column/index.jsx} +66 -18
- package/lib/runtime/components/react/dist/{mpx-picker-view-column-item.jsx → mpx-picker-view-column/pickerViewColumnItem.jsx} +8 -5
- package/lib/runtime/components/react/dist/{pickerFaces.js → mpx-picker-view-column/pickerViewFaces.js} +6 -0
- package/lib/runtime/components/react/dist/mpx-popup/index.jsx +61 -0
- package/lib/runtime/components/react/dist/mpx-popup/popupBase.jsx +92 -0
- package/lib/runtime/components/react/dist/mpx-radio-group.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-radio.jsx +2 -3
- package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +207 -29
- package/lib/runtime/components/react/dist/mpx-simple-text.jsx +7 -5
- package/lib/runtime/components/react/dist/mpx-simple-view.jsx +11 -15
- package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +115 -0
- package/lib/runtime/components/react/dist/mpx-sticky-section.jsx +45 -0
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +4 -5
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +9 -9
- package/lib/runtime/components/react/dist/mpx-switch.jsx +3 -5
- package/lib/runtime/components/react/dist/mpx-text.jsx +4 -7
- package/lib/runtime/components/react/dist/mpx-video.jsx +5 -5
- package/lib/runtime/components/react/dist/mpx-view.jsx +23 -9
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +16 -13
- package/lib/runtime/components/react/dist/useAnimationHooks.js +26 -4
- package/lib/runtime/components/react/dist/utils.jsx +14 -2
- package/lib/runtime/components/react/event.config.ts +1 -6
- package/lib/runtime/components/react/getInnerListeners.ts +148 -191
- package/lib/runtime/components/react/mpx-button.tsx +7 -7
- package/lib/runtime/components/react/mpx-canvas/index.tsx +25 -17
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +4 -3
- package/lib/runtime/components/react/mpx-checkbox.tsx +8 -9
- package/lib/runtime/components/react/mpx-form.tsx +25 -19
- package/lib/runtime/components/react/mpx-icon/index.tsx +4 -3
- package/lib/runtime/components/react/mpx-image.tsx +4 -3
- package/lib/runtime/components/react/mpx-inline-text.tsx +18 -0
- package/lib/runtime/components/react/mpx-input.tsx +24 -21
- package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +31 -42
- package/lib/runtime/components/react/mpx-label.tsx +4 -5
- package/lib/runtime/components/react/mpx-movable-area.tsx +22 -13
- package/lib/runtime/components/react/mpx-movable-view.tsx +47 -40
- package/lib/runtime/components/react/mpx-navigator.tsx +4 -6
- package/lib/runtime/components/react/mpx-picker/date.tsx +226 -69
- package/lib/runtime/components/react/mpx-picker/dateData.ts +22 -0
- package/lib/runtime/components/react/mpx-picker/index.tsx +242 -118
- package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +96 -139
- package/lib/runtime/components/react/mpx-picker/region.tsx +217 -89
- package/lib/runtime/components/react/mpx-picker/selector.tsx +75 -80
- package/lib/runtime/components/react/mpx-picker/time.tsx +119 -236
- package/lib/runtime/components/react/mpx-picker/type.ts +85 -71
- package/lib/runtime/components/react/{mpx-picker-view.tsx → mpx-picker-view/index.tsx} +24 -21
- package/lib/runtime/components/react/{mpx-picker-view-column.tsx → mpx-picker-view-column/index.tsx} +72 -21
- package/lib/runtime/components/react/{mpx-picker-view-column-item.tsx → mpx-picker-view-column/pickerViewColumnItem.tsx} +8 -5
- package/lib/runtime/components/react/{pickerFaces.ts → mpx-picker-view-column/pickerViewFaces.ts} +7 -0
- package/lib/runtime/components/react/mpx-popup/index.tsx +86 -0
- package/lib/runtime/components/react/mpx-popup/popupBase.tsx +130 -0
- package/lib/runtime/components/react/mpx-radio-group.tsx +4 -3
- package/lib/runtime/components/react/mpx-radio.tsx +8 -9
- package/lib/runtime/components/react/mpx-rich-text/index.tsx +15 -6
- package/lib/runtime/components/react/mpx-scroll-view.tsx +326 -96
- package/lib/runtime/components/react/mpx-simple-text.tsx +17 -8
- package/lib/runtime/components/react/mpx-simple-view.tsx +17 -16
- package/lib/runtime/components/react/mpx-sticky-header.tsx +179 -0
- package/lib/runtime/components/react/mpx-sticky-section.tsx +96 -0
- package/lib/runtime/components/react/mpx-swiper-item.tsx +31 -24
- package/lib/runtime/components/react/mpx-swiper.tsx +67 -61
- package/lib/runtime/components/react/mpx-switch.tsx +19 -14
- package/lib/runtime/components/react/mpx-text.tsx +16 -13
- package/lib/runtime/components/react/mpx-video.tsx +36 -35
- package/lib/runtime/components/react/mpx-view.tsx +41 -17
- package/lib/runtime/components/react/mpx-web-view.tsx +15 -12
- package/lib/runtime/components/react/types/getInnerListeners.d.ts +69 -35
- package/lib/runtime/components/react/types/global.d.ts +1 -1
- package/lib/runtime/components/react/useAnimationHooks.ts +29 -9
- package/lib/runtime/components/react/utils.tsx +15 -3
- package/lib/runtime/components/web/mini-video-controls.min.js +1 -1
- package/lib/runtime/components/web/mpx-input.vue +1 -1
- package/lib/runtime/components/web/mpx-scroll-view.vue +21 -4
- package/lib/runtime/components/web/mpx-sticky-header.vue +91 -0
- package/lib/runtime/components/web/mpx-sticky-section.vue +15 -0
- package/lib/runtime/stringify.wxs +2 -2
- package/lib/template-compiler/compiler.js +8 -8
- package/lib/utils/env.js +1 -1
- package/package.json +4 -5
- package/LICENSE +0 -433
- /package/lib/runtime/components/react/dist/{pickerVIewContext.js → mpx-picker-view/pickerVIewContext.js} +0 -0
- /package/lib/runtime/components/react/dist/{pickerViewIndicator.jsx → mpx-picker-view-column/pickerViewIndicator.jsx} +0 -0
- /package/lib/runtime/components/react/dist/{pickerViewMask.jsx → mpx-picker-view-column/pickerViewMask.jsx} +0 -0
- /package/lib/runtime/components/react/{pickerVIewContext.ts → mpx-picker-view/pickerVIewContext.ts} +0 -0
- /package/lib/runtime/components/react/{pickerViewIndicator.tsx → mpx-picker-view-column/pickerViewIndicator.tsx} +0 -0
- /package/lib/runtime/components/react/{pickerViewMask.tsx → mpx-picker-view-column/pickerViewMask.tsx} +0 -0
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { useRef, useMemo
|
|
2
|
-
import {
|
|
1
|
+
import { useRef, useMemo } from 'react'
|
|
2
|
+
import { collectDataset } from '@mpxjs/utils'
|
|
3
3
|
import { omit, extendObject, useNavigation } from './utils'
|
|
4
|
-
import eventConfigMap
|
|
4
|
+
import eventConfigMap from './event.config'
|
|
5
5
|
import {
|
|
6
6
|
Props,
|
|
7
|
-
|
|
7
|
+
EventConfig,
|
|
8
|
+
RawConfig,
|
|
9
|
+
EventType,
|
|
8
10
|
RemoveProps,
|
|
9
|
-
UseInnerPropsConfig,
|
|
10
11
|
InnerRef,
|
|
11
|
-
SetTimeoutReturnType,
|
|
12
12
|
LayoutRef,
|
|
13
|
-
|
|
14
|
-
Navigation
|
|
13
|
+
ExtendedNativeTouchEvent
|
|
15
14
|
} from './types/getInnerListeners'
|
|
16
15
|
|
|
17
16
|
const globalEventState = {
|
|
@@ -20,22 +19,21 @@ const globalEventState = {
|
|
|
20
19
|
|
|
21
20
|
const getTouchEvent = (
|
|
22
21
|
type: string,
|
|
23
|
-
event:
|
|
24
|
-
|
|
25
|
-
config: UseInnerPropsConfig,
|
|
26
|
-
navigation: Navigation
|
|
22
|
+
event: ExtendedNativeTouchEvent,
|
|
23
|
+
config: EventConfig
|
|
27
24
|
) => {
|
|
25
|
+
const { navigation, propsRef, layoutRef } = config
|
|
26
|
+
const props = propsRef.current
|
|
28
27
|
const { y: navigationY = 0 } = navigation?.layout || {}
|
|
29
28
|
const nativeEvent = event.nativeEvent
|
|
30
29
|
const { timestamp, pageX, pageY, touches, changedTouches } = nativeEvent
|
|
31
30
|
const { id } = props
|
|
32
|
-
const { layoutRef } = config
|
|
33
31
|
|
|
34
32
|
const currentTarget = extendObject({}, event.currentTarget, {
|
|
35
33
|
id: id || '',
|
|
36
34
|
dataset: collectDataset(props),
|
|
37
|
-
offsetLeft: layoutRef
|
|
38
|
-
offsetTop: layoutRef
|
|
35
|
+
offsetLeft: layoutRef.current?.offsetLeft || 0,
|
|
36
|
+
offsetTop: layoutRef.current?.offsetTop || 0
|
|
39
37
|
})
|
|
40
38
|
|
|
41
39
|
const pendingProps = (event as any)._targetInst?.pendingProps || {}
|
|
@@ -108,183 +106,129 @@ export const getCustomEvent = (
|
|
|
108
106
|
}
|
|
109
107
|
|
|
110
108
|
function handleEmitEvent (
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
config: UseInnerPropsConfig,
|
|
116
|
-
navigation: Navigation
|
|
109
|
+
name: string,
|
|
110
|
+
e: ExtendedNativeTouchEvent,
|
|
111
|
+
type: EventType,
|
|
112
|
+
eventConfig: EventConfig
|
|
117
113
|
) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
propsRef.current[event](
|
|
125
|
-
getTouchEvent(type, oe, propsRef.current, config, navigation)
|
|
126
|
-
)
|
|
114
|
+
const { propsRef } = eventConfig
|
|
115
|
+
const eventCfg = eventConfig[name]
|
|
116
|
+
if (eventCfg) {
|
|
117
|
+
if (eventCfg.hasCatch && name !== 'tap' && name !== 'longpress') {
|
|
118
|
+
e.stopPropagation()
|
|
127
119
|
}
|
|
128
|
-
|
|
120
|
+
eventCfg[type].forEach((event) => {
|
|
121
|
+
propsRef.current[event]?.(getTouchEvent(name, e, eventConfig))
|
|
122
|
+
})
|
|
123
|
+
}
|
|
129
124
|
}
|
|
130
125
|
|
|
131
|
-
function checkIsNeedPress (e:
|
|
132
|
-
const tapDetailInfo = ref.current
|
|
133
|
-
const
|
|
134
|
-
const
|
|
135
|
-
const currentPageY = nativeEvent.changedTouches[0].pageY
|
|
126
|
+
function checkIsNeedPress (e: ExtendedNativeTouchEvent, type: 'bubble' | 'capture', ref: InnerRef) {
|
|
127
|
+
const tapDetailInfo = ref.current.mpxPressInfo.detail || { x: 0, y: 0 }
|
|
128
|
+
const currentPageX = e.nativeEvent.changedTouches[0].pageX
|
|
129
|
+
const currentPageY = e.nativeEvent.changedTouches[0].pageY
|
|
136
130
|
if (
|
|
137
131
|
Math.abs(currentPageX - tapDetailInfo.x) > 3 ||
|
|
138
|
-
|
|
132
|
+
Math.abs(currentPageY - tapDetailInfo.y) > 3
|
|
139
133
|
) {
|
|
140
134
|
globalEventState.needPress = false
|
|
141
|
-
ref.current
|
|
142
|
-
|
|
143
|
-
ref.current!.startTimer[type] = null
|
|
135
|
+
ref.current.startTimer[type] && clearTimeout(ref.current.startTimer[type] as unknown as number)
|
|
136
|
+
ref.current.startTimer[type] = null
|
|
144
137
|
}
|
|
145
138
|
}
|
|
146
139
|
|
|
147
|
-
function handleTouchstart (e:
|
|
140
|
+
function handleTouchstart (e: ExtendedNativeTouchEvent, type: EventType, eventConfig: EventConfig) {
|
|
141
|
+
// 阻止事件被释放放回对象池,导致对象复用 _stoppedEventTypes 状态被保留
|
|
148
142
|
e.persist()
|
|
149
|
-
const
|
|
150
|
-
const bubblePressEvent = ['catchlongpress', 'bindlongpress']
|
|
151
|
-
const captureTouchEvent = [
|
|
152
|
-
'capture-catchtouchstart',
|
|
153
|
-
'capture-bindtouchstart'
|
|
154
|
-
]
|
|
155
|
-
const capturePressEvent = [
|
|
156
|
-
'capture-catchlongpress',
|
|
157
|
-
'capture-bindlongpress'
|
|
158
|
-
]
|
|
159
|
-
ref.current!.startTimer[type] = null
|
|
143
|
+
const { innerRef } = eventConfig
|
|
160
144
|
globalEventState.needPress = true
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
y: nativeEvent.changedTouches[0].pageY
|
|
145
|
+
innerRef.current.mpxPressInfo.detail = {
|
|
146
|
+
x: e.nativeEvent.changedTouches[0].pageX,
|
|
147
|
+
y: e.nativeEvent.changedTouches[0].pageY
|
|
165
148
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
bindlongpress ||
|
|
180
|
-
captureCatchlongpress ||
|
|
181
|
-
captureBindlongpress
|
|
182
|
-
) {
|
|
183
|
-
ref.current!.startTimer[type] = setTimeout(() => {
|
|
149
|
+
|
|
150
|
+
handleEmitEvent('touchstart', e, type, eventConfig)
|
|
151
|
+
|
|
152
|
+
if (eventConfig.longpress) {
|
|
153
|
+
if (e._stoppedEventTypes?.has('longpress')) {
|
|
154
|
+
return
|
|
155
|
+
}
|
|
156
|
+
if (eventConfig.longpress.hasCatch) {
|
|
157
|
+
e._stoppedEventTypes = e._stoppedEventTypes || new Set()
|
|
158
|
+
e._stoppedEventTypes.add('longpress')
|
|
159
|
+
}
|
|
160
|
+
innerRef.current.startTimer[type] && clearTimeout(innerRef.current.startTimer[type] as unknown as number)
|
|
161
|
+
innerRef.current.startTimer[type] = setTimeout(() => {
|
|
184
162
|
// 只要触发过longpress, 全局就不再触发tap
|
|
185
163
|
globalEventState.needPress = false
|
|
186
|
-
handleEmitEvent(
|
|
164
|
+
handleEmitEvent('longpress', e, type, eventConfig)
|
|
187
165
|
}, 350)
|
|
188
166
|
}
|
|
189
167
|
}
|
|
190
168
|
|
|
191
|
-
function handleTouchmove (e:
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
]
|
|
197
|
-
const currentTouchEvent =
|
|
198
|
-
type === 'bubble' ? bubbleTouchEvent : captureTouchEvent
|
|
199
|
-
handleEmitEvent(currentTouchEvent, 'touchmove', e, propsRef, config, navigation)
|
|
200
|
-
if (TAP_EVENTS.some(eventName => propsRef.current[eventName])) {
|
|
201
|
-
checkIsNeedPress(e, type, ref)
|
|
169
|
+
function handleTouchmove (e: ExtendedNativeTouchEvent, type: EventType, eventConfig: EventConfig) {
|
|
170
|
+
const { innerRef } = eventConfig
|
|
171
|
+
handleEmitEvent('touchmove', e, type, eventConfig)
|
|
172
|
+
if (eventConfig.tap) {
|
|
173
|
+
checkIsNeedPress(e, type, innerRef)
|
|
202
174
|
}
|
|
203
175
|
}
|
|
204
176
|
|
|
205
|
-
function handleTouchend (e:
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
const captureTouchEvent = [
|
|
213
|
-
'capture-catchtouchend',
|
|
214
|
-
'capture-bindtouchend'
|
|
215
|
-
]
|
|
216
|
-
const captureTapEvent = ['capture-catchtap', 'capture-bindtap']
|
|
217
|
-
const currentTouchEvent =
|
|
218
|
-
type === 'bubble' ? bubbleTouchEvent : captureTouchEvent
|
|
219
|
-
const currentTapEvent =
|
|
220
|
-
type === 'bubble' ? bubbleTapEvent : captureTapEvent
|
|
221
|
-
ref.current!.startTimer[type] &&
|
|
222
|
-
clearTimeout(ref.current!.startTimer[type] as SetTimeoutReturnType)
|
|
223
|
-
ref.current!.startTimer[type] = null
|
|
224
|
-
handleEmitEvent(currentTouchEvent, 'touchend', e, propsRef, config, navigation)
|
|
225
|
-
if (globalEventState.needPress) {
|
|
226
|
-
if (type === 'bubble' && config.disableTap) {
|
|
177
|
+
function handleTouchend (e: ExtendedNativeTouchEvent, type: EventType, eventConfig: EventConfig) {
|
|
178
|
+
const { innerRef, disableTap } = eventConfig
|
|
179
|
+
handleEmitEvent('touchend', e, type, eventConfig)
|
|
180
|
+
innerRef.current.startTimer[type] && clearTimeout(innerRef.current.startTimer[type] as unknown as number)
|
|
181
|
+
if (eventConfig.tap) {
|
|
182
|
+
checkIsNeedPress(e, type, innerRef)
|
|
183
|
+
if (!globalEventState.needPress || (type === 'bubble' && disableTap) || e._stoppedEventTypes?.has('tap')) {
|
|
227
184
|
return
|
|
228
185
|
}
|
|
229
|
-
|
|
186
|
+
if (eventConfig.tap.hasCatch) {
|
|
187
|
+
e._stoppedEventTypes = e._stoppedEventTypes || new Set()
|
|
188
|
+
e._stoppedEventTypes.add('tap')
|
|
189
|
+
}
|
|
190
|
+
handleEmitEvent('tap', e, type, eventConfig)
|
|
230
191
|
}
|
|
231
192
|
}
|
|
232
193
|
|
|
233
|
-
function handleTouchcancel (
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
propsRef: Record<string, any>,
|
|
238
|
-
config: UseInnerPropsConfig,
|
|
239
|
-
navigation: Navigation
|
|
240
|
-
) {
|
|
241
|
-
const bubbleTouchEvent = ['catchtouchcancel', 'bindtouchcancel']
|
|
242
|
-
const captureTouchEvent = [
|
|
243
|
-
'capture-catchtouchcancel',
|
|
244
|
-
'capture-bindtouchcancel'
|
|
245
|
-
]
|
|
246
|
-
const currentTouchEvent =
|
|
247
|
-
type === 'bubble' ? bubbleTouchEvent : captureTouchEvent
|
|
248
|
-
ref.current!.startTimer[type] &&
|
|
249
|
-
clearTimeout(ref.current!.startTimer[type] as SetTimeoutReturnType)
|
|
250
|
-
ref.current!.startTimer[type] = null
|
|
251
|
-
handleEmitEvent(currentTouchEvent, 'touchcancel', e, propsRef, config, navigation)
|
|
194
|
+
function handleTouchcancel (e: ExtendedNativeTouchEvent, type: EventType, eventConfig: EventConfig) {
|
|
195
|
+
const { innerRef } = eventConfig
|
|
196
|
+
handleEmitEvent('touchcancel', e, type, eventConfig)
|
|
197
|
+
innerRef.current.startTimer[type] && clearTimeout(innerRef.current.startTimer[type] as unknown as number)
|
|
252
198
|
}
|
|
253
199
|
|
|
254
|
-
function createTouchEventHandler (eventName:
|
|
255
|
-
return (e:
|
|
256
|
-
const
|
|
200
|
+
function createTouchEventHandler (eventName: string, eventConfig: EventConfig) {
|
|
201
|
+
return (e: ExtendedNativeTouchEvent) => {
|
|
202
|
+
const bubbleHandlerMap: Record<string, any> = {
|
|
257
203
|
onTouchStart: handleTouchstart,
|
|
258
204
|
onTouchMove: handleTouchmove,
|
|
259
205
|
onTouchEnd: handleTouchend,
|
|
260
206
|
onTouchCancel: handleTouchcancel
|
|
261
207
|
}
|
|
262
208
|
|
|
263
|
-
const
|
|
264
|
-
|
|
265
|
-
|
|
209
|
+
const captureHandlerMap: Record<string, any> = {
|
|
210
|
+
onTouchStartCapture: handleTouchstart,
|
|
211
|
+
onTouchMoveCapture: handleTouchmove,
|
|
212
|
+
onTouchEndCapture: handleTouchend,
|
|
213
|
+
onTouchCancelCapture: handleTouchcancel
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (bubbleHandlerMap[eventName]) {
|
|
217
|
+
bubbleHandlerMap[eventName](e, 'bubble', eventConfig)
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (captureHandlerMap[eventName]) {
|
|
221
|
+
captureHandlerMap[eventName](e, 'capture', eventConfig)
|
|
266
222
|
}
|
|
267
223
|
}
|
|
268
224
|
}
|
|
269
225
|
|
|
270
|
-
const touchEventList = [
|
|
271
|
-
{ eventName: 'onTouchStart', handler: createTouchEventHandler('onTouchStart', 'bubble') },
|
|
272
|
-
{ eventName: 'onTouchMove', handler: createTouchEventHandler('onTouchMove', 'bubble') },
|
|
273
|
-
{ eventName: 'onTouchEnd', handler: createTouchEventHandler('onTouchEnd', 'bubble') },
|
|
274
|
-
{ eventName: 'onTouchCancel', handler: createTouchEventHandler('onTouchCancel', 'bubble') },
|
|
275
|
-
{ eventName: 'onTouchStartCapture', handler: createTouchEventHandler('onTouchStart', 'capture') },
|
|
276
|
-
{ eventName: 'onTouchMoveCapture', handler: createTouchEventHandler('onTouchMove', 'capture') },
|
|
277
|
-
{ eventName: 'onTouchEndCapture', handler: createTouchEventHandler('onTouchEnd', 'capture') },
|
|
278
|
-
{ eventName: 'onTouchCancelCapture', handler: createTouchEventHandler('onTouchCancel', 'capture') }
|
|
279
|
-
]
|
|
280
|
-
|
|
281
226
|
const useInnerProps = (
|
|
282
227
|
props: Props = {},
|
|
283
|
-
additionalProps: AdditionalProps = {},
|
|
284
228
|
userRemoveProps: RemoveProps = [],
|
|
285
|
-
rawConfig?:
|
|
229
|
+
rawConfig?: RawConfig
|
|
286
230
|
) => {
|
|
287
|
-
const
|
|
231
|
+
const innerRef: InnerRef = useRef({
|
|
288
232
|
startTimer: {
|
|
289
233
|
bubble: null,
|
|
290
234
|
capture: null
|
|
@@ -296,67 +240,80 @@ const useInnerProps = (
|
|
|
296
240
|
}
|
|
297
241
|
}
|
|
298
242
|
})
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
const eventConfig: { [key: string]: string[] } = {}
|
|
302
|
-
const config = rawConfig || {
|
|
303
|
-
layoutRef: { current: {} },
|
|
304
|
-
disableTap: false
|
|
305
|
-
}
|
|
243
|
+
const propsRef = useRef({})
|
|
244
|
+
propsRef.current = props
|
|
306
245
|
const navigation = useNavigation()
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
'parent-height',
|
|
317
|
-
...userRemoveProps
|
|
318
|
-
]
|
|
319
|
-
|
|
320
|
-
propsRef.current = extendObject({}, props, additionalProps)
|
|
246
|
+
const eventConfig: EventConfig = extendObject({
|
|
247
|
+
layoutRef: {
|
|
248
|
+
current: null
|
|
249
|
+
},
|
|
250
|
+
propsRef,
|
|
251
|
+
innerRef,
|
|
252
|
+
disableTap: false,
|
|
253
|
+
navigation
|
|
254
|
+
}, rawConfig)
|
|
321
255
|
|
|
322
256
|
let hashEventKey = ''
|
|
323
257
|
const rawEventKeys: Array<string> = []
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
if (
|
|
327
|
-
|
|
328
|
-
hashEventKey = hashEventKey + eventConfigMap[key].bitFlag
|
|
258
|
+
const transformedEventSet = new Set<string>()
|
|
259
|
+
Object.keys(props).forEach((key) => {
|
|
260
|
+
if (eventConfigMap[key]) {
|
|
261
|
+
hashEventKey += eventConfigMap[key].bitFlag
|
|
329
262
|
rawEventKeys.push(key)
|
|
263
|
+
eventConfigMap[key].events.forEach((event) => {
|
|
264
|
+
transformedEventSet.add(event)
|
|
265
|
+
})
|
|
266
|
+
const match = /^(bind|catch|capture-bind|capture-catch)(.*)$/.exec(key)!
|
|
267
|
+
const prefix = match[1]
|
|
268
|
+
const eventName = match[2]
|
|
269
|
+
eventConfig[eventName] = eventConfig[eventName] || {
|
|
270
|
+
bubble: [],
|
|
271
|
+
capture: [],
|
|
272
|
+
hasCatch: false
|
|
273
|
+
}
|
|
274
|
+
if (prefix === 'bind' || prefix === 'catch') {
|
|
275
|
+
eventConfig[eventName].bubble.push(key)
|
|
276
|
+
} else {
|
|
277
|
+
eventConfig[eventName].capture.push(key)
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
if (prefix === 'catch' || prefix === 'capture-catch') {
|
|
281
|
+
eventConfig[eventName].hasCatch = true
|
|
282
|
+
}
|
|
330
283
|
}
|
|
331
|
-
}
|
|
284
|
+
})
|
|
332
285
|
|
|
333
286
|
const events = useMemo(() => {
|
|
334
|
-
if (!
|
|
287
|
+
if (!hashEventKey) {
|
|
335
288
|
return {}
|
|
336
289
|
}
|
|
337
|
-
const transformedEventKeys = rawEventKeys.reduce((acc: string[], key) => {
|
|
338
|
-
if (propsRef.current[key]) {
|
|
339
|
-
return acc.concat(eventConfig[key])
|
|
340
|
-
}
|
|
341
|
-
return acc
|
|
342
|
-
}, [])
|
|
343
|
-
const finalEventKeys = [...new Set(transformedEventKeys)]
|
|
344
|
-
const events: Record<string, (e: NativeTouchEvent) => void> = {}
|
|
345
290
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
})
|
|
291
|
+
const events: Record<string, (e: ExtendedNativeTouchEvent) => void> = {}
|
|
292
|
+
|
|
293
|
+
for (const eventName of transformedEventSet) {
|
|
294
|
+
events[eventName] = createTouchEventHandler(eventName, eventConfig)
|
|
295
|
+
}
|
|
352
296
|
|
|
353
297
|
return events
|
|
354
298
|
}, [hashEventKey])
|
|
355
299
|
|
|
300
|
+
const removeProps = [
|
|
301
|
+
'children',
|
|
302
|
+
'enable-background',
|
|
303
|
+
'enable-offset',
|
|
304
|
+
'enable-var',
|
|
305
|
+
'external-var-context',
|
|
306
|
+
'parent-font-size',
|
|
307
|
+
'parent-width',
|
|
308
|
+
'parent-height',
|
|
309
|
+
...userRemoveProps,
|
|
310
|
+
...rawEventKeys
|
|
311
|
+
]
|
|
312
|
+
|
|
356
313
|
return extendObject(
|
|
357
314
|
{},
|
|
358
315
|
events,
|
|
359
|
-
omit(
|
|
316
|
+
omit(props, removeProps)
|
|
360
317
|
)
|
|
361
318
|
}
|
|
362
319
|
export default useInnerProps
|
|
@@ -42,7 +42,8 @@ import {
|
|
|
42
42
|
TextStyle,
|
|
43
43
|
Animated,
|
|
44
44
|
Easing,
|
|
45
|
-
NativeSyntheticEvent
|
|
45
|
+
NativeSyntheticEvent,
|
|
46
|
+
useAnimatedValue
|
|
46
47
|
} from 'react-native'
|
|
47
48
|
import { warn } from '@mpxjs/utils'
|
|
48
49
|
import { GestureDetector, PanGesture } from 'react-native-gesture-handler'
|
|
@@ -156,7 +157,7 @@ const timer = (data: any, time = 3000) => new Promise((resolve) => {
|
|
|
156
157
|
})
|
|
157
158
|
|
|
158
159
|
const Loading = ({ alone = false }: { alone: boolean }): JSX.Element => {
|
|
159
|
-
const image =
|
|
160
|
+
const image = useAnimatedValue(0)
|
|
160
161
|
|
|
161
162
|
const rotate = image.interpolate({
|
|
162
163
|
inputRange: [0, 1],
|
|
@@ -371,14 +372,13 @@ const Button = forwardRef<HandlerRef<View, ButtonProps>, ButtonProps>((buttonPro
|
|
|
371
372
|
}
|
|
372
373
|
|
|
373
374
|
const innerProps = useInnerProps(
|
|
374
|
-
props,
|
|
375
375
|
extendObject(
|
|
376
|
-
{
|
|
377
|
-
|
|
378
|
-
style: extendObject({}, innerStyle, layoutStyle)
|
|
379
|
-
},
|
|
376
|
+
{},
|
|
377
|
+
props,
|
|
380
378
|
layoutProps,
|
|
381
379
|
{
|
|
380
|
+
ref: nodeRef,
|
|
381
|
+
style: extendObject({}, innerStyle, layoutStyle),
|
|
382
382
|
bindtap: !disabled && onTap
|
|
383
383
|
}
|
|
384
384
|
),
|
|
@@ -48,19 +48,19 @@ const stylesheet = StyleSheet.create({
|
|
|
48
48
|
})
|
|
49
49
|
|
|
50
50
|
interface CanvasProps {
|
|
51
|
-
style?: Record<string, any
|
|
52
|
-
originWhitelist?: Array<string
|
|
51
|
+
style?: Record<string, any>
|
|
52
|
+
originWhitelist?: Array<string>
|
|
53
53
|
'enable-var'?: boolean
|
|
54
54
|
'parent-font-size'?: number
|
|
55
55
|
'parent-width'?: number
|
|
56
56
|
'parent-height'?: number
|
|
57
57
|
'external-var-context'?: Record<string, any>
|
|
58
|
-
bindtouchstart?: (event: NativeSyntheticEvent<TouchEvent>) => void
|
|
59
|
-
bindtouchmove?: (event: NativeSyntheticEvent<TouchEvent>) => void
|
|
60
|
-
bindtouchend?: (event: NativeSyntheticEvent<TouchEvent>) => void
|
|
61
|
-
bindtouchcancel?: (event: NativeSyntheticEvent<TouchEvent>) => void
|
|
62
|
-
bindlongtap?: (event: NativeSyntheticEvent<TouchEvent>) => void
|
|
63
|
-
binderror?: (event: NativeSyntheticEvent<ErrorEvent>) => void
|
|
58
|
+
bindtouchstart?: (event: NativeSyntheticEvent<TouchEvent>) => void
|
|
59
|
+
bindtouchmove?: (event: NativeSyntheticEvent<TouchEvent>) => void
|
|
60
|
+
bindtouchend?: (event: NativeSyntheticEvent<TouchEvent>) => void
|
|
61
|
+
bindtouchcancel?: (event: NativeSyntheticEvent<TouchEvent>) => void
|
|
62
|
+
bindlongtap?: (event: NativeSyntheticEvent<TouchEvent>) => void
|
|
63
|
+
binderror?: (event: NativeSyntheticEvent<ErrorEvent>) => void
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
const _Canvas = forwardRef<HandlerRef<CanvasProps & View, CanvasProps>, CanvasProps>((props: CanvasProps = {}, ref): JSX.Element => {
|
|
@@ -91,13 +91,21 @@ const _Canvas = forwardRef<HandlerRef<CanvasProps & View, CanvasProps>, CanvasPr
|
|
|
91
91
|
const { register } = useConstructorsRegistry()
|
|
92
92
|
|
|
93
93
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef })
|
|
94
|
-
const innerProps = useInnerProps(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
94
|
+
const innerProps = useInnerProps(
|
|
95
|
+
extendObject(
|
|
96
|
+
{},
|
|
97
|
+
props,
|
|
98
|
+
layoutProps,
|
|
99
|
+
{
|
|
100
|
+
ref: nodeRef,
|
|
101
|
+
style: extendObject({}, normalStyle, layoutStyle, { opacity: isLoaded ? 1 : 0 })
|
|
102
|
+
}
|
|
103
|
+
),
|
|
104
|
+
[],
|
|
105
|
+
{
|
|
106
|
+
layoutRef
|
|
107
|
+
}
|
|
108
|
+
)
|
|
101
109
|
|
|
102
110
|
const context2D = new CanvasRenderingContext2D(canvasRef.current) as any
|
|
103
111
|
|
|
@@ -251,8 +259,8 @@ const _Canvas = forwardRef<HandlerRef<CanvasProps & View, CanvasProps>, CanvasPr
|
|
|
251
259
|
context: context2D
|
|
252
260
|
})
|
|
253
261
|
|
|
254
|
-
if (
|
|
255
|
-
const isAndroid9 = Platform.Version >= 28
|
|
262
|
+
if (__mpx_mode__ !== 'ios') {
|
|
263
|
+
const isAndroid9 = Platform.Version as number >= 28
|
|
256
264
|
return createElement(View, innerProps, createElement(
|
|
257
265
|
WebView,
|
|
258
266
|
{
|
|
@@ -116,13 +116,14 @@ const CheckboxGroup = forwardRef<
|
|
|
116
116
|
}, [])
|
|
117
117
|
|
|
118
118
|
const innerProps = useInnerProps(
|
|
119
|
-
props,
|
|
120
119
|
extendObject(
|
|
120
|
+
{},
|
|
121
|
+
props,
|
|
122
|
+
layoutProps,
|
|
121
123
|
{
|
|
122
124
|
ref: nodeRef,
|
|
123
125
|
style: extendObject({}, normalStyle, layoutStyle)
|
|
124
|
-
}
|
|
125
|
-
layoutProps
|
|
126
|
+
}
|
|
126
127
|
),
|
|
127
128
|
[
|
|
128
129
|
'name'
|
|
@@ -42,9 +42,9 @@ export interface CheckboxProps extends Selection {
|
|
|
42
42
|
'enable-offset'?: boolean
|
|
43
43
|
'enable-var'?: boolean
|
|
44
44
|
'external-var-context'?: Record<string, any>
|
|
45
|
-
'parent-font-size'?: number
|
|
46
|
-
'parent-width'?: number
|
|
47
|
-
'parent-height'?: number
|
|
45
|
+
'parent-font-size'?: number
|
|
46
|
+
'parent-width'?: number
|
|
47
|
+
'parent-height'?: number
|
|
48
48
|
children?: ReactNode
|
|
49
49
|
bindtap?: (evt: NativeSyntheticEvent<TouchEvent> | unknown) => void
|
|
50
50
|
_onChange?: (evt: NativeSyntheticEvent<TouchEvent> | unknown, { checked }: { checked: boolean }) => void
|
|
@@ -99,7 +99,7 @@ const Checkbox = forwardRef<HandlerRef<View, CheckboxProps>, CheckboxProps>(
|
|
|
99
99
|
const [isChecked, setIsChecked] = useState<boolean>(!!checked)
|
|
100
100
|
|
|
101
101
|
const groupContext = useContext(CheckboxGroupContext)
|
|
102
|
-
let groupValue: { [key: string]: { checked: boolean; setValue: Dispatch<SetStateAction<boolean
|
|
102
|
+
let groupValue: { [key: string]: { checked: boolean; setValue: Dispatch<SetStateAction<boolean>> } } | undefined
|
|
103
103
|
let notifyChange: (evt: NativeSyntheticEvent<TouchEvent>) => void | undefined
|
|
104
104
|
|
|
105
105
|
const defaultStyle = extendObject(
|
|
@@ -163,14 +163,13 @@ const Checkbox = forwardRef<HandlerRef<View, CheckboxProps>, CheckboxProps>(
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
const innerProps = useInnerProps(
|
|
166
|
-
props,
|
|
167
166
|
extendObject(
|
|
168
|
-
{
|
|
169
|
-
|
|
170
|
-
style: extendObject({}, innerStyle, layoutStyle)
|
|
171
|
-
},
|
|
167
|
+
{},
|
|
168
|
+
props,
|
|
172
169
|
layoutProps,
|
|
173
170
|
{
|
|
171
|
+
ref: nodeRef,
|
|
172
|
+
style: extendObject({}, innerStyle, layoutStyle),
|
|
174
173
|
bindtap: !disabled && onTap
|
|
175
174
|
}
|
|
176
175
|
),
|
|
@@ -11,20 +11,20 @@ import useInnerProps, { getCustomEvent } from './getInnerListeners'
|
|
|
11
11
|
import { FormContext } from './context'
|
|
12
12
|
import { useTransformStyle, splitProps, splitStyle, useLayout, wrapChildren, extendObject } from './utils'
|
|
13
13
|
interface FormProps {
|
|
14
|
-
style?: Record<string, any
|
|
15
|
-
children?: ReactNode
|
|
16
|
-
'enable-offset'?: boolean
|
|
14
|
+
style?: Record<string, any>
|
|
15
|
+
children?: ReactNode
|
|
16
|
+
'enable-offset'?: boolean
|
|
17
17
|
'enable-var'?: boolean
|
|
18
|
-
'external-var-context'?: Record<string, any
|
|
19
|
-
'parent-font-size'?: number
|
|
20
|
-
'parent-width'?: number
|
|
21
|
-
'parent-height'?: number
|
|
18
|
+
'external-var-context'?: Record<string, any>
|
|
19
|
+
'parent-font-size'?: number
|
|
20
|
+
'parent-width'?: number
|
|
21
|
+
'parent-height'?: number
|
|
22
22
|
bindsubmit?: (evt: {
|
|
23
23
|
detail: {
|
|
24
|
-
value: any
|
|
25
|
-
}
|
|
26
|
-
}) => void
|
|
27
|
-
bindreset?: () => void
|
|
24
|
+
value: any
|
|
25
|
+
}
|
|
26
|
+
}) => void
|
|
27
|
+
bindreset?: () => void
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
const _Form = forwardRef<HandlerRef<View, FormProps>, FormProps>((fromProps: FormProps, ref): JSX.Element => {
|
|
@@ -59,14 +59,20 @@ const _Form = forwardRef<HandlerRef<View, FormProps>, FormProps>((fromProps: For
|
|
|
59
59
|
|
|
60
60
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: formRef })
|
|
61
61
|
|
|
62
|
-
const innerProps = useInnerProps(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
const innerProps = useInnerProps(
|
|
63
|
+
extendObject(
|
|
64
|
+
{},
|
|
65
|
+
props,
|
|
66
|
+
layoutProps,
|
|
67
|
+
{
|
|
68
|
+
style: extendObject({}, innerStyle, layoutStyle),
|
|
69
|
+
ref: formRef
|
|
70
|
+
}
|
|
71
|
+
)
|
|
72
|
+
, [
|
|
73
|
+
'bindsubmit',
|
|
74
|
+
'bindreset'
|
|
75
|
+
], { layoutRef })
|
|
70
76
|
|
|
71
77
|
const contextValue = useMemo(() => {
|
|
72
78
|
const formValuesMap = new Map()
|