@mpxjs/webpack-plugin 2.10.4 → 2.10.5

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 (70) hide show
  1. package/lib/platform/style/wx/index.js +22 -21
  2. package/lib/react/processScript.js +9 -1
  3. package/lib/react/script-helper.js +5 -1
  4. package/lib/runtime/components/react/dist/event.config.js +0 -2
  5. package/lib/runtime/components/react/dist/getInnerListeners.js +127 -153
  6. package/lib/runtime/components/react/dist/mpx-button.jsx +2 -3
  7. package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +3 -4
  8. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +2 -2
  9. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +2 -3
  10. package/lib/runtime/components/react/dist/mpx-form.jsx +2 -2
  11. package/lib/runtime/components/react/dist/mpx-icon/index.jsx +2 -2
  12. package/lib/runtime/components/react/dist/mpx-image.jsx +2 -2
  13. package/lib/runtime/components/react/dist/mpx-input.jsx +17 -11
  14. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +22 -29
  15. package/lib/runtime/components/react/dist/mpx-label.jsx +2 -3
  16. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +2 -2
  17. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +1 -1
  18. package/lib/runtime/components/react/dist/mpx-navigator.jsx +11 -3
  19. package/lib/runtime/components/react/dist/mpx-picker/index.jsx +2 -2
  20. package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +2 -3
  21. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +4 -4
  22. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +2 -2
  23. package/lib/runtime/components/react/dist/mpx-radio.jsx +2 -3
  24. package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +2 -2
  25. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +1 -1
  26. package/lib/runtime/components/react/dist/mpx-simple-text.jsx +3 -2
  27. package/lib/runtime/components/react/dist/mpx-simple-view.jsx +3 -3
  28. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +4 -5
  29. package/lib/runtime/components/react/dist/mpx-swiper.jsx +9 -9
  30. package/lib/runtime/components/react/dist/mpx-switch.jsx +3 -5
  31. package/lib/runtime/components/react/dist/mpx-text.jsx +4 -7
  32. package/lib/runtime/components/react/dist/mpx-video.jsx +2 -2
  33. package/lib/runtime/components/react/dist/mpx-view.jsx +13 -6
  34. package/lib/runtime/components/react/dist/useAnimationHooks.js +27 -4
  35. package/lib/runtime/components/react/dist/utils.jsx +85 -95
  36. package/lib/runtime/components/react/event.config.ts +1 -8
  37. package/lib/runtime/components/react/getInnerListeners.ts +146 -192
  38. package/lib/runtime/components/react/mpx-button.tsx +4 -5
  39. package/lib/runtime/components/react/mpx-canvas/index.tsx +23 -15
  40. package/lib/runtime/components/react/mpx-checkbox-group.tsx +4 -3
  41. package/lib/runtime/components/react/mpx-checkbox.tsx +8 -9
  42. package/lib/runtime/components/react/mpx-form.tsx +25 -19
  43. package/lib/runtime/components/react/mpx-icon/index.tsx +4 -3
  44. package/lib/runtime/components/react/mpx-image.tsx +4 -3
  45. package/lib/runtime/components/react/mpx-input.tsx +22 -15
  46. package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +30 -41
  47. package/lib/runtime/components/react/mpx-label.tsx +4 -5
  48. package/lib/runtime/components/react/mpx-movable-area.tsx +22 -13
  49. package/lib/runtime/components/react/mpx-movable-view.tsx +47 -40
  50. package/lib/runtime/components/react/mpx-navigator.tsx +4 -6
  51. package/lib/runtime/components/react/mpx-picker/index.tsx +7 -4
  52. package/lib/runtime/components/react/mpx-picker-view/index.tsx +17 -14
  53. package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +4 -4
  54. package/lib/runtime/components/react/mpx-radio-group.tsx +4 -3
  55. package/lib/runtime/components/react/mpx-radio.tsx +8 -9
  56. package/lib/runtime/components/react/mpx-rich-text/index.tsx +15 -6
  57. package/lib/runtime/components/react/mpx-scroll-view.tsx +96 -90
  58. package/lib/runtime/components/react/mpx-simple-text.tsx +10 -3
  59. package/lib/runtime/components/react/mpx-simple-view.tsx +10 -4
  60. package/lib/runtime/components/react/mpx-swiper-item.tsx +31 -24
  61. package/lib/runtime/components/react/mpx-swiper.tsx +67 -61
  62. package/lib/runtime/components/react/mpx-switch.tsx +19 -14
  63. package/lib/runtime/components/react/mpx-text.tsx +16 -13
  64. package/lib/runtime/components/react/mpx-video.tsx +34 -33
  65. package/lib/runtime/components/react/mpx-view.tsx +30 -14
  66. package/lib/runtime/components/react/types/getInnerListeners.d.ts +65 -35
  67. package/lib/runtime/components/react/useAnimationHooks.ts +30 -9
  68. package/lib/runtime/components/react/utils.tsx +91 -98
  69. package/lib/template-compiler/compiler.js +1 -1
  70. package/package.json +3 -3
@@ -1,17 +1,16 @@
1
- import { useRef, useMemo, RefObject } from 'react'
2
- import { hasOwn, collectDataset } from '@mpxjs/utils'
1
+ import { useRef, useMemo } from 'react'
2
+ import { collectDataset } from '@mpxjs/utils'
3
3
  import { omit, extendObject, useNavigation } from './utils'
4
- import eventConfigMap, { TAP_EVENTS, LONGPRESS_EVENTS } from './event.config'
4
+ import eventConfigMap from './event.config'
5
5
  import {
6
6
  Props,
7
- AdditionalProps,
7
+ EventConfig,
8
+ RawConfig,
9
+ EventType,
8
10
  RemoveProps,
9
- UseInnerPropsConfig,
10
11
  InnerRef,
11
- SetTimeoutReturnType,
12
12
  LayoutRef,
13
- ExtendedNativeTouchEvent,
14
- Navigation
13
+ ExtendedNativeTouchEvent
15
14
  } from './types/getInnerListeners'
16
15
 
17
16
  const globalEventState = {
@@ -21,21 +20,20 @@ const globalEventState = {
21
20
  const getTouchEvent = (
22
21
  type: string,
23
22
  event: ExtendedNativeTouchEvent,
24
- props: Props,
25
- config: UseInnerPropsConfig,
26
- navigation: Navigation
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?.current?.offsetLeft || 0,
38
- offsetTop: layoutRef?.current?.offsetTop || 0
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,186 +106,129 @@ export const getCustomEvent = (
108
106
  }
109
107
 
110
108
  function handleEmitEvent (
111
- events: string[],
112
- type: string,
113
- oe: ExtendedNativeTouchEvent,
114
- propsRef: Record<string, any>,
115
- config: UseInnerPropsConfig,
116
- navigation: Navigation
109
+ name: string,
110
+ e: ExtendedNativeTouchEvent,
111
+ type: EventType,
112
+ eventConfig: EventConfig
117
113
  ) {
118
- events.forEach((event) => {
119
- if (propsRef.current[event]) {
120
- const match = /^(catch|capture-catch):?(.*?)(?:\.(.*))?$/.exec(event)
121
- // 检查是否已经被上层的 catch 阻止
122
- if ((type === 'tap' || type === 'longpress') && oe._stoppedEventTypes?.has(type)) {
123
- return
124
- }
125
- if (match) {
126
- const eventBase = match[2] || ''
127
- if (eventBase === 'tap' || eventBase === 'longpress') {
128
- // 为 tap、longpress 添加标记,影响后续的冒泡
129
- if (!oe._stoppedEventTypes) {
130
- oe._stoppedEventTypes = new Set()
131
- }
132
- oe._stoppedEventTypes.add(eventBase)
133
- } else {
134
- // 原生 touch 事件使用 stopPropagation
135
- oe.stopPropagation()
136
- }
137
- }
138
- propsRef.current[event](
139
- getTouchEvent(type, oe, propsRef.current, config, navigation)
140
- )
114
+ const { propsRef } = eventConfig
115
+ const eventCfg = eventConfig[name]
116
+ if (eventCfg) {
117
+ if (eventCfg.hasCatch && name !== 'tap' && name !== 'longpress') {
118
+ e.stopPropagation()
141
119
  }
142
- })
120
+ eventCfg[type].forEach((event) => {
121
+ propsRef.current[event]?.(getTouchEvent(name, e, eventConfig))
122
+ })
123
+ }
143
124
  }
144
125
 
145
- function checkIsNeedPress (e: ExtendedNativeTouchEvent, type: 'bubble' | 'capture', ref: RefObject<InnerRef>) {
146
- const tapDetailInfo = ref.current!.mpxPressInfo.detail || { x: 0, y: 0 }
147
- const nativeEvent = e.nativeEvent
148
- const currentPageX = nativeEvent.changedTouches[0].pageX
149
- 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
150
130
  if (
151
131
  Math.abs(currentPageX - tapDetailInfo.x) > 3 ||
152
- Math.abs(currentPageY - tapDetailInfo.y) > 3
132
+ Math.abs(currentPageY - tapDetailInfo.y) > 3
153
133
  ) {
154
134
  globalEventState.needPress = false
155
- ref.current!.startTimer[type] &&
156
- clearTimeout(ref.current!.startTimer[type] as SetTimeoutReturnType)
157
- 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
158
137
  }
159
138
  }
160
139
 
161
- function handleTouchstart (e: ExtendedNativeTouchEvent, type: 'bubble' | 'capture', ref: RefObject<InnerRef>, propsRef: Record<string, any>, config: UseInnerPropsConfig, navigation: Navigation) {
140
+ function handleTouchstart (e: ExtendedNativeTouchEvent, type: EventType, eventConfig: EventConfig) {
141
+ // 阻止事件被释放放回对象池,导致对象复用 _stoppedEventTypes 状态被保留
162
142
  e.persist()
163
- const bubbleTouchEvent = ['catchtouchstart', 'bindtouchstart']
164
- const bubblePressEvent = ['catchlongpress', 'bindlongpress']
165
- const captureTouchEvent = [
166
- 'capture-catchtouchstart',
167
- 'capture-bindtouchstart'
168
- ]
169
- const capturePressEvent = [
170
- 'capture-catchlongpress',
171
- 'capture-bindlongpress'
172
- ]
173
- ref.current!.startTimer[type] = null
143
+ const { innerRef } = eventConfig
174
144
  globalEventState.needPress = true
175
- const nativeEvent = e.nativeEvent
176
- ref.current!.mpxPressInfo.detail = {
177
- x: nativeEvent.changedTouches[0].pageX,
178
- y: nativeEvent.changedTouches[0].pageY
145
+ innerRef.current.mpxPressInfo.detail = {
146
+ x: e.nativeEvent.changedTouches[0].pageX,
147
+ y: e.nativeEvent.changedTouches[0].pageY
179
148
  }
180
- const currentTouchEvent =
181
- type === 'bubble' ? bubbleTouchEvent : captureTouchEvent
182
- const currentPressEvent =
183
- type === 'bubble' ? bubblePressEvent : capturePressEvent
184
- handleEmitEvent(currentTouchEvent, 'touchstart', e, propsRef, config, navigation)
185
- if (LONGPRESS_EVENTS.some(eventName => propsRef.current[eventName])) {
186
- 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(() => {
187
162
  // 只要触发过longpress, 全局就不再触发tap
188
163
  globalEventState.needPress = false
189
- handleEmitEvent(currentPressEvent, 'longpress', e, propsRef, config, navigation)
164
+ handleEmitEvent('longpress', e, type, eventConfig)
190
165
  }, 350)
191
166
  }
192
167
  }
193
168
 
194
- function handleTouchmove (e: ExtendedNativeTouchEvent, type: 'bubble' | 'capture', ref: RefObject<InnerRef>, propsRef: Record<string, any>, config: UseInnerPropsConfig, navigation: Navigation) {
195
- const bubbleTouchEvent = ['catchtouchmove', 'bindtouchmove']
196
- const captureTouchEvent = [
197
- 'capture-catchtouchmove',
198
- 'capture-bindtouchmove'
199
- ]
200
- const currentTouchEvent =
201
- type === 'bubble' ? bubbleTouchEvent : captureTouchEvent
202
- handleEmitEvent(currentTouchEvent, 'touchmove', e, propsRef, config, navigation)
203
- if (TAP_EVENTS.some(eventName => propsRef.current[eventName])) {
204
- 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)
205
174
  }
206
175
  }
207
176
 
208
- function handleTouchend (e: ExtendedNativeTouchEvent, type: 'bubble' | 'capture', ref: RefObject<InnerRef>, propsRef: Record<string, any>, config: UseInnerPropsConfig, navigation: Navigation) {
209
- // move event may not be triggered
210
- if (TAP_EVENTS.some(eventName => propsRef.current[eventName])) {
211
- checkIsNeedPress(e, type, ref)
212
- }
213
- const bubbleTouchEvent = ['catchtouchend', 'bindtouchend']
214
- const bubbleTapEvent = ['catchtap', 'bindtap']
215
- const captureTouchEvent = [
216
- 'capture-catchtouchend',
217
- 'capture-bindtouchend'
218
- ]
219
- const captureTapEvent = ['capture-catchtap', 'capture-bindtap']
220
- const currentTouchEvent =
221
- type === 'bubble' ? bubbleTouchEvent : captureTouchEvent
222
- const currentTapEvent =
223
- type === 'bubble' ? bubbleTapEvent : captureTapEvent
224
- ref.current!.startTimer[type] &&
225
- clearTimeout(ref.current!.startTimer[type] as SetTimeoutReturnType)
226
- ref.current!.startTimer[type] = null
227
- handleEmitEvent(currentTouchEvent, 'touchend', e, propsRef, config, navigation)
228
- if (globalEventState.needPress) {
229
- 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')) {
230
184
  return
231
185
  }
232
- handleEmitEvent(currentTapEvent, 'tap', e, propsRef, config, navigation)
186
+ if (eventConfig.tap.hasCatch) {
187
+ e._stoppedEventTypes = e._stoppedEventTypes || new Set()
188
+ e._stoppedEventTypes.add('tap')
189
+ }
190
+ handleEmitEvent('tap', e, type, eventConfig)
233
191
  }
234
192
  }
235
193
 
236
- function handleTouchcancel (
237
- e: ExtendedNativeTouchEvent,
238
- type: 'bubble' | 'capture',
239
- ref: RefObject<InnerRef>,
240
- propsRef: Record<string, any>,
241
- config: UseInnerPropsConfig,
242
- navigation: Navigation
243
- ) {
244
- const bubbleTouchEvent = ['catchtouchcancel', 'bindtouchcancel']
245
- const captureTouchEvent = [
246
- 'capture-catchtouchcancel',
247
- 'capture-bindtouchcancel'
248
- ]
249
- const currentTouchEvent =
250
- type === 'bubble' ? bubbleTouchEvent : captureTouchEvent
251
- ref.current!.startTimer[type] &&
252
- clearTimeout(ref.current!.startTimer[type] as SetTimeoutReturnType)
253
- ref.current!.startTimer[type] = null
254
- 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)
255
198
  }
256
199
 
257
- function createTouchEventHandler (eventName: 'onTouchStart'|'onTouchMove'|'onTouchEnd'|'onTouchCancel', type: 'bubble' | 'capture') {
258
- return (e: ExtendedNativeTouchEvent, ref: RefObject<InnerRef>, propsRef: Record<string, any>, config: UseInnerPropsConfig, navigation: Navigation) => {
259
- const handlerMap = {
200
+ function createTouchEventHandler (eventName: string, eventConfig: EventConfig) {
201
+ return (e: ExtendedNativeTouchEvent) => {
202
+ const bubbleHandlerMap: Record<string, any> = {
260
203
  onTouchStart: handleTouchstart,
261
204
  onTouchMove: handleTouchmove,
262
205
  onTouchEnd: handleTouchend,
263
206
  onTouchCancel: handleTouchcancel
264
207
  }
265
208
 
266
- const handler = handlerMap[eventName]
267
- if (handler) {
268
- handler(e, type, ref, propsRef, config, navigation)
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)
269
222
  }
270
223
  }
271
224
  }
272
225
 
273
- const touchEventList = [
274
- { eventName: 'onTouchStart', handler: createTouchEventHandler('onTouchStart', 'bubble') },
275
- { eventName: 'onTouchMove', handler: createTouchEventHandler('onTouchMove', 'bubble') },
276
- { eventName: 'onTouchEnd', handler: createTouchEventHandler('onTouchEnd', 'bubble') },
277
- { eventName: 'onTouchCancel', handler: createTouchEventHandler('onTouchCancel', 'bubble') },
278
- { eventName: 'onTouchStartCapture', handler: createTouchEventHandler('onTouchStart', 'capture') },
279
- { eventName: 'onTouchMoveCapture', handler: createTouchEventHandler('onTouchMove', 'capture') },
280
- { eventName: 'onTouchEndCapture', handler: createTouchEventHandler('onTouchEnd', 'capture') },
281
- { eventName: 'onTouchCancelCapture', handler: createTouchEventHandler('onTouchCancel', 'capture') }
282
- ]
283
-
284
226
  const useInnerProps = (
285
227
  props: Props = {},
286
- additionalProps: AdditionalProps = {},
287
228
  userRemoveProps: RemoveProps = [],
288
- rawConfig?: UseInnerPropsConfig
229
+ rawConfig?: RawConfig
289
230
  ) => {
290
- const ref = useRef<InnerRef>({
231
+ const innerRef: InnerRef = useRef({
291
232
  startTimer: {
292
233
  bubble: null,
293
234
  capture: null
@@ -299,67 +240,80 @@ const useInnerProps = (
299
240
  }
300
241
  }
301
242
  })
302
-
303
- const propsRef = useRef<Record<string, any>>({})
304
- const eventConfig: { [key: string]: string[] } = {}
305
- const config = rawConfig || {
306
- layoutRef: { current: {} },
307
- disableTap: false
308
- }
243
+ const propsRef = useRef({})
244
+ propsRef.current = props
309
245
  const navigation = useNavigation()
310
-
311
- const removeProps = [
312
- 'children',
313
- 'enable-background',
314
- 'enable-offset',
315
- 'enable-var',
316
- 'external-var-context',
317
- 'parent-font-size',
318
- 'parent-width',
319
- 'parent-height',
320
- ...userRemoveProps
321
- ]
322
-
323
- 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)
324
255
 
325
256
  let hashEventKey = ''
326
257
  const rawEventKeys: Array<string> = []
327
-
328
- for (const key in eventConfigMap) {
329
- if (hasOwn(propsRef.current, key)) {
330
- eventConfig[key] = eventConfigMap[key].events
331
- 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
332
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
+ }
333
283
  }
334
- }
284
+ })
335
285
 
336
286
  const events = useMemo(() => {
337
- if (!rawEventKeys.length) {
287
+ if (!hashEventKey) {
338
288
  return {}
339
289
  }
340
- const transformedEventKeys = rawEventKeys.reduce((acc: string[], key) => {
341
- if (propsRef.current[key]) {
342
- return acc.concat(eventConfig[key])
343
- }
344
- return acc
345
- }, [])
346
- const finalEventKeys = [...new Set(transformedEventKeys)]
290
+
347
291
  const events: Record<string, (e: ExtendedNativeTouchEvent) => void> = {}
348
292
 
349
- touchEventList.forEach((item) => {
350
- if (finalEventKeys.includes(item.eventName)) {
351
- events[item.eventName] = (e: ExtendedNativeTouchEvent) =>
352
- item.handler(e, ref, propsRef, config, navigation)
353
- }
354
- })
293
+ for (const eventName of transformedEventSet) {
294
+ events[eventName] = createTouchEventHandler(eventName, eventConfig)
295
+ }
355
296
 
356
297
  return events
357
298
  }, [hashEventKey])
358
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
+
359
313
  return extendObject(
360
314
  {},
361
315
  events,
362
- omit(propsRef.current, [...rawEventKeys, ...removeProps])
316
+ omit(props, removeProps)
363
317
  )
364
318
  }
365
319
  export default useInnerProps
@@ -371,14 +371,13 @@ const Button = forwardRef<HandlerRef<View, ButtonProps>, ButtonProps>((buttonPro
371
371
  }
372
372
 
373
373
  const innerProps = useInnerProps(
374
- props,
375
374
  extendObject(
376
- {
377
- ref: nodeRef,
378
- style: extendObject({}, innerStyle, layoutStyle)
379
- },
375
+ {},
376
+ props,
380
377
  layoutProps,
381
378
  {
379
+ ref: nodeRef,
380
+ style: extendObject({}, innerStyle, layoutStyle),
382
381
  bindtap: !disabled && onTap
383
382
  }
384
383
  ),
@@ -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(props, {
95
- ref: nodeRef,
96
- style: extendObject({}, normalStyle, layoutStyle, { opacity: isLoaded ? 1 : 0 }),
97
- ...layoutProps
98
- }, [], {
99
- layoutRef
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
 
@@ -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>>; } } | undefined
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
- ref: nodeRef,
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(props, extendObject({
63
- style: extendObject({}, innerStyle, layoutStyle),
64
- ref: formRef
65
- }, layoutProps)
66
- , [
67
- 'bindsubmit',
68
- 'bindreset'
69
- ], { layoutRef })
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()
@@ -87,14 +87,15 @@ const Icon = forwardRef<HandlerRef<Text, IconProps>, IconProps>(
87
87
  const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef })
88
88
 
89
89
  const innerProps = useInnerProps(
90
- props,
91
90
  extendObject(
91
+ {},
92
+ props,
93
+ layoutProps,
92
94
  {
93
95
  ref: nodeRef,
94
96
  source,
95
97
  style: extendObject({}, normalStyle, layoutStyle, { tintColor: color })
96
- },
97
- layoutProps
98
+ }
98
99
  ),
99
100
  [],
100
101
  {