@mpxjs/webpack-plugin 2.10.24 → 2.11.0

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 (151) hide show
  1. package/lib/index.js +4 -1
  2. package/lib/platform/style/wx/index.js +417 -120
  3. package/lib/platform/template/wx/component-config/picker.js +0 -6
  4. package/lib/react/style-helper.js +6 -6
  5. package/lib/resolver/AddEnvPlugin.js +1 -1
  6. package/lib/resolver/AddModePlugin.js +1 -1
  7. package/lib/resolver/ExtendComponentsPlugin.js +68 -0
  8. package/lib/runtime/components/extends/section-list.mpx +14 -0
  9. package/lib/runtime/components/react/animationHooks/index.ts +7 -3
  10. package/lib/runtime/components/react/dist/animationHooks/index.d.ts +0 -2
  11. package/lib/runtime/components/react/dist/animationHooks/index.js +6 -1
  12. package/lib/runtime/components/react/dist/event.config.d.ts +2 -6
  13. package/lib/runtime/components/react/dist/event.config.js +28 -24
  14. package/lib/runtime/components/react/dist/getInnerListeners.d.ts +1 -1
  15. package/lib/runtime/components/react/dist/getInnerListeners.js +74 -56
  16. package/lib/runtime/components/react/dist/mpx-button.d.ts +1 -2
  17. package/lib/runtime/components/react/dist/mpx-button.jsx +16 -9
  18. package/lib/runtime/components/react/dist/mpx-camera.d.ts +0 -2
  19. package/lib/runtime/components/react/dist/mpx-camera.jsx +36 -5
  20. package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +0 -2
  21. package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +1 -3
  22. package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +1 -1
  23. package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +0 -2
  24. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +3 -4
  25. package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +1 -2
  26. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +8 -9
  27. package/lib/runtime/components/react/dist/mpx-form.d.ts +1 -2
  28. package/lib/runtime/components/react/dist/mpx-form.jsx +5 -5
  29. package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +0 -2
  30. package/lib/runtime/components/react/dist/mpx-icon/index.jsx +2 -2
  31. package/lib/runtime/components/react/dist/mpx-image.d.ts +0 -2
  32. package/lib/runtime/components/react/dist/mpx-image.jsx +59 -43
  33. package/lib/runtime/components/react/dist/mpx-inline-text.jsx +13 -4
  34. package/lib/runtime/components/react/dist/mpx-input.d.ts +0 -2
  35. package/lib/runtime/components/react/dist/mpx-input.jsx +16 -8
  36. package/lib/runtime/components/react/dist/mpx-label.d.ts +1 -2
  37. package/lib/runtime/components/react/dist/mpx-label.jsx +5 -6
  38. package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +0 -2
  39. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +3 -3
  40. package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +1 -2
  41. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +6 -6
  42. package/lib/runtime/components/react/dist/mpx-nav.jsx +1 -1
  43. package/lib/runtime/components/react/dist/mpx-picker/index.jsx +72 -23
  44. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +2 -2
  45. package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +4 -0
  46. package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +1 -1
  47. package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +10 -14
  48. package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +0 -2
  49. package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.js +0 -5
  50. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +1 -1
  51. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +34 -14
  52. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +0 -2
  53. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.jsx +4 -5
  54. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts +0 -2
  55. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.jsx +3 -5
  56. package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +5 -4
  57. package/lib/runtime/components/react/dist/mpx-popup/index.jsx +2 -2
  58. package/lib/runtime/components/react/dist/mpx-popup/popupBase.jsx +3 -2
  59. package/lib/runtime/components/react/dist/mpx-progress.d.ts +0 -2
  60. package/lib/runtime/components/react/dist/mpx-progress.jsx +1 -3
  61. package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +0 -2
  62. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +3 -4
  63. package/lib/runtime/components/react/dist/mpx-radio.d.ts +1 -2
  64. package/lib/runtime/components/react/dist/mpx-radio.jsx +8 -9
  65. package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +0 -2
  66. package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +1 -3
  67. package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +1 -2
  68. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +6 -6
  69. package/lib/runtime/components/react/dist/mpx-section-list.d.ts +51 -0
  70. package/lib/runtime/components/react/dist/mpx-section-list.jsx +376 -0
  71. package/lib/runtime/components/react/dist/mpx-simple-text.jsx +37 -19
  72. package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +4 -1
  73. package/lib/runtime/components/react/dist/mpx-simple-view.jsx +11 -4
  74. package/lib/runtime/components/react/dist/mpx-slider.d.ts +0 -2
  75. package/lib/runtime/components/react/dist/mpx-slider.jsx +6 -7
  76. package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +1 -2
  77. package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +5 -5
  78. package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +1 -2
  79. package/lib/runtime/components/react/dist/mpx-sticky-section.jsx +6 -6
  80. package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +1 -2
  81. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +5 -5
  82. package/lib/runtime/components/react/dist/mpx-swiper.d.ts +1 -2
  83. package/lib/runtime/components/react/dist/mpx-swiper.jsx +4 -8
  84. package/lib/runtime/components/react/dist/mpx-switch.d.ts +0 -2
  85. package/lib/runtime/components/react/dist/mpx-switch.jsx +1 -3
  86. package/lib/runtime/components/react/dist/mpx-text.d.ts +0 -2
  87. package/lib/runtime/components/react/dist/mpx-text.jsx +43 -25
  88. package/lib/runtime/components/react/dist/mpx-video.d.ts +0 -2
  89. package/lib/runtime/components/react/dist/mpx-video.jsx +4 -5
  90. package/lib/runtime/components/react/dist/mpx-view.d.ts +2 -2
  91. package/lib/runtime/components/react/dist/mpx-view.jsx +214 -114
  92. package/lib/runtime/components/react/dist/mpx-web-view.d.ts +2 -1
  93. package/lib/runtime/components/react/dist/mpx-web-view.jsx +5 -1
  94. package/lib/runtime/components/react/dist/namedColorSet.d.ts +2 -0
  95. package/lib/runtime/components/react/dist/namedColorSet.js +149 -0
  96. package/lib/runtime/components/react/dist/utils.d.ts +71 -70
  97. package/lib/runtime/components/react/dist/utils.jsx +1295 -456
  98. package/lib/runtime/components/react/event.config.ts +32 -25
  99. package/lib/runtime/components/react/getInnerListeners.ts +84 -60
  100. package/lib/runtime/components/react/mpx-button.tsx +18 -18
  101. package/lib/runtime/components/react/mpx-camera.tsx +40 -8
  102. package/lib/runtime/components/react/mpx-canvas/index.tsx +5 -7
  103. package/lib/runtime/components/react/mpx-canvas/utils.tsx +3 -1
  104. package/lib/runtime/components/react/mpx-checkbox-group.tsx +2 -8
  105. package/lib/runtime/components/react/mpx-checkbox.tsx +9 -13
  106. package/lib/runtime/components/react/mpx-form.tsx +6 -8
  107. package/lib/runtime/components/react/mpx-icon/index.tsx +1 -5
  108. package/lib/runtime/components/react/mpx-image.tsx +66 -58
  109. package/lib/runtime/components/react/mpx-inline-text.tsx +13 -4
  110. package/lib/runtime/components/react/mpx-input.tsx +19 -12
  111. package/lib/runtime/components/react/mpx-label.tsx +6 -10
  112. package/lib/runtime/components/react/mpx-movable-area.tsx +3 -5
  113. package/lib/runtime/components/react/mpx-movable-view.tsx +7 -9
  114. package/lib/runtime/components/react/mpx-nav.tsx +1 -1
  115. package/lib/runtime/components/react/mpx-picker/index.tsx +100 -29
  116. package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +3 -3
  117. package/lib/runtime/components/react/mpx-picker/selector.tsx +1 -1
  118. package/lib/runtime/components/react/mpx-picker/type.ts +4 -0
  119. package/lib/runtime/components/react/mpx-picker-view/index.tsx +17 -24
  120. package/lib/runtime/components/react/mpx-picker-view/pickerVIewContext.ts +0 -9
  121. package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +44 -23
  122. package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItem.tsx +1 -9
  123. package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItemLite.tsx +0 -9
  124. package/lib/runtime/components/react/mpx-popup/index.tsx +7 -3
  125. package/lib/runtime/components/react/mpx-popup/popupBase.tsx +3 -2
  126. package/lib/runtime/components/react/mpx-progress.tsx +0 -6
  127. package/lib/runtime/components/react/mpx-radio-group.tsx +2 -8
  128. package/lib/runtime/components/react/mpx-radio.tsx +9 -13
  129. package/lib/runtime/components/react/mpx-rich-text/index.tsx +0 -6
  130. package/lib/runtime/components/react/mpx-scroll-view.tsx +7 -9
  131. package/lib/runtime/components/react/mpx-section-list.tsx +557 -0
  132. package/lib/runtime/components/react/mpx-simple-text.tsx +36 -25
  133. package/lib/runtime/components/react/mpx-simple-view.tsx +17 -5
  134. package/lib/runtime/components/react/mpx-slider.tsx +15 -13
  135. package/lib/runtime/components/react/mpx-sticky-header.tsx +6 -8
  136. package/lib/runtime/components/react/mpx-sticky-section.tsx +7 -9
  137. package/lib/runtime/components/react/mpx-swiper-item.tsx +6 -7
  138. package/lib/runtime/components/react/mpx-swiper.tsx +5 -11
  139. package/lib/runtime/components/react/mpx-switch.tsx +0 -6
  140. package/lib/runtime/components/react/mpx-text.tsx +45 -36
  141. package/lib/runtime/components/react/mpx-video.tsx +3 -8
  142. package/lib/runtime/components/react/mpx-view.tsx +235 -129
  143. package/lib/runtime/components/react/mpx-web-view.tsx +12 -6
  144. package/lib/runtime/components/react/namedColorSet.ts +150 -0
  145. package/lib/runtime/components/react/types/getInnerListeners.d.ts +21 -1
  146. package/lib/runtime/components/react/types/global.d.ts +1 -0
  147. package/lib/runtime/components/react/utils.tsx +1352 -550
  148. package/lib/runtime/i18n.wxs +15 -9
  149. package/lib/style-compiler/strip-conditional.js +19 -4
  150. package/lib/template-compiler/compiler.js +6 -0
  151. package/package.json +6 -6
@@ -1,28 +1,35 @@
1
- const eventConfigMap: { [key: string]: { bitFlag: string; events: string[] } } = {
2
- bindtap: { bitFlag: '0', events: ['onTouchStart', 'onTouchMove', 'onTouchEnd'] },
3
- bindlongpress: { bitFlag: '1', events: ['onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel'] },
4
- bindtouchstart: { bitFlag: '2', events: ['onTouchStart'] },
5
- bindtouchmove: { bitFlag: '3', events: ['onTouchMove'] },
6
- bindtouchend: { bitFlag: '4', events: ['onTouchEnd'] },
7
- bindtouchcancel: { bitFlag: '5', events: ['onTouchCancel'] },
8
- catchtap: { bitFlag: '6', events: ['onTouchStart', 'onTouchMove', 'onTouchEnd'] },
9
- catchlongpress: { bitFlag: '7', events: ['onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel'] },
10
- catchtouchstart: { bitFlag: '8', events: ['onTouchStart'] },
11
- catchtouchmove: { bitFlag: '9', events: ['onTouchMove'] },
12
- catchtouchend: { bitFlag: 'a', events: ['onTouchEnd'] },
13
- catchtouchcancel: { bitFlag: 'b', events: ['onTouchCancel'] },
14
- 'capture-bindtap': { bitFlag: 'c', events: ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture'] },
15
- 'capture-bindlongpress': { bitFlag: 'd', events: ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture', 'onTouchCancelCapture'] },
16
- 'capture-bindtouchstart': { bitFlag: 'e', events: ['onTouchStartCapture'] },
17
- 'capture-bindtouchmove': { bitFlag: 'f', events: ['onTouchMoveCapture'] },
18
- 'capture-bindtouchend': { bitFlag: 'g', events: ['onTouchEndCapture'] },
19
- 'capture-bindtouchcancel': { bitFlag: 'h', events: ['onTouchCancelCapture'] },
20
- 'capture-catchtap': { bitFlag: 'i', events: ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture'] },
21
- 'capture-catchlongpress': { bitFlag: 'j', events: ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture', 'onTouchCancelCapture'] },
22
- 'capture-catchtouchstart': { bitFlag: 'k', events: ['onTouchStartCapture'] },
23
- 'capture-catchtouchmove': { bitFlag: 'l', events: ['onTouchMoveCapture'] },
24
- 'capture-catchtouchend': { bitFlag: 'm', events: ['onTouchEndCapture'] },
25
- 'capture-catchtouchcancel': { bitFlag: 'n', events: ['onTouchCancelCapture'] }
1
+ import type { EventMeta } from './types/getInnerListeners'
2
+
3
+ const tapEvents = ['onTouchStart', 'onTouchMove', 'onTouchEnd']
4
+ const longpressEvents = ['onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel']
5
+ const tapCaptureEvents = ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture']
6
+ const longpressCaptureEvents = ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture', 'onTouchCancelCapture']
7
+
8
+ const eventConfigMap: Record<string, EventMeta> = {
9
+ bindtap: { bitFlag: '0', events: tapEvents, eventName: 'tap', eventType: 'bubble', hasCatch: false },
10
+ bindlongpress: { bitFlag: '1', events: longpressEvents, eventName: 'longpress', eventType: 'bubble', hasCatch: false },
11
+ bindtouchstart: { bitFlag: '2', events: ['onTouchStart'], eventName: 'touchstart', eventType: 'bubble', hasCatch: false },
12
+ bindtouchmove: { bitFlag: '3', events: ['onTouchMove'], eventName: 'touchmove', eventType: 'bubble', hasCatch: false },
13
+ bindtouchend: { bitFlag: '4', events: ['onTouchEnd'], eventName: 'touchend', eventType: 'bubble', hasCatch: false },
14
+ bindtouchcancel: { bitFlag: '5', events: ['onTouchCancel'], eventName: 'touchcancel', eventType: 'bubble', hasCatch: false },
15
+ catchtap: { bitFlag: '6', events: tapEvents, eventName: 'tap', eventType: 'bubble', hasCatch: true },
16
+ catchlongpress: { bitFlag: '7', events: longpressEvents, eventName: 'longpress', eventType: 'bubble', hasCatch: true },
17
+ catchtouchstart: { bitFlag: '8', events: ['onTouchStart'], eventName: 'touchstart', eventType: 'bubble', hasCatch: true },
18
+ catchtouchmove: { bitFlag: '9', events: ['onTouchMove'], eventName: 'touchmove', eventType: 'bubble', hasCatch: true },
19
+ catchtouchend: { bitFlag: 'a', events: ['onTouchEnd'], eventName: 'touchend', eventType: 'bubble', hasCatch: true },
20
+ catchtouchcancel: { bitFlag: 'b', events: ['onTouchCancel'], eventName: 'touchcancel', eventType: 'bubble', hasCatch: true },
21
+ 'capture-bindtap': { bitFlag: 'c', events: tapCaptureEvents, eventName: 'tap', eventType: 'capture', hasCatch: false },
22
+ 'capture-bindlongpress': { bitFlag: 'd', events: longpressCaptureEvents, eventName: 'longpress', eventType: 'capture', hasCatch: false },
23
+ 'capture-bindtouchstart': { bitFlag: 'e', events: ['onTouchStartCapture'], eventName: 'touchstart', eventType: 'capture', hasCatch: false },
24
+ 'capture-bindtouchmove': { bitFlag: 'f', events: ['onTouchMoveCapture'], eventName: 'touchmove', eventType: 'capture', hasCatch: false },
25
+ 'capture-bindtouchend': { bitFlag: 'g', events: ['onTouchEndCapture'], eventName: 'touchend', eventType: 'capture', hasCatch: false },
26
+ 'capture-bindtouchcancel': { bitFlag: 'h', events: ['onTouchCancelCapture'], eventName: 'touchcancel', eventType: 'capture', hasCatch: false },
27
+ 'capture-catchtap': { bitFlag: 'i', events: tapCaptureEvents, eventName: 'tap', eventType: 'capture', hasCatch: true },
28
+ 'capture-catchlongpress': { bitFlag: 'j', events: longpressCaptureEvents, eventName: 'longpress', eventType: 'capture', hasCatch: true },
29
+ 'capture-catchtouchstart': { bitFlag: 'k', events: ['onTouchStartCapture'], eventName: 'touchstart', eventType: 'capture', hasCatch: true },
30
+ 'capture-catchtouchmove': { bitFlag: 'l', events: ['onTouchMoveCapture'], eventName: 'touchmove', eventType: 'capture', hasCatch: true },
31
+ 'capture-catchtouchend': { bitFlag: 'm', events: ['onTouchEndCapture'], eventName: 'touchend', eventType: 'capture', hasCatch: true },
32
+ 'capture-catchtouchcancel': { bitFlag: 'n', events: ['onTouchCancelCapture'], eventName: 'touchcancel', eventType: 'capture', hasCatch: true }
26
33
  }
27
34
 
28
35
  export default eventConfigMap
@@ -1,17 +1,19 @@
1
1
  import { useRef, useMemo } from 'react'
2
2
  import { collectDataset } from '@mpxjs/utils'
3
- import { omit, extendObject, useNavigation } from './utils'
3
+ import { extendObject, useNavigation } from './utils'
4
4
  import eventConfigMap from './event.config'
5
5
  import {
6
6
  Props,
7
7
  EventConfig,
8
+ EventConfigRef,
8
9
  RawConfig,
9
10
  EventType,
10
11
  RemoveProps,
11
12
  InnerRef,
12
13
  LayoutRef,
13
14
  ExtendedNativeTouchEvent,
14
- GlobalEventState
15
+ GlobalEventState,
16
+ TouchHandlerConfig
15
17
  } from './types/getInnerListeners'
16
18
 
17
19
  const globalEventState: GlobalEventState = {
@@ -19,6 +21,18 @@ const globalEventState: GlobalEventState = {
19
21
  identifier: null
20
22
  }
21
23
 
24
+ const baseRemovePropsMap: Record<string, boolean> = {
25
+ children: true,
26
+ 'enable-background': true,
27
+ 'enable-offset': true,
28
+ 'enable-var': true,
29
+ 'external-var-context': true,
30
+ 'parent-font-size': true,
31
+ 'parent-width': true,
32
+ 'parent-height': true,
33
+ 'enable-text-pass-through': true
34
+ }
35
+
22
36
  const getTouchEvent = (
23
37
  type: string,
24
38
  event: ExtendedNativeTouchEvent,
@@ -216,29 +230,45 @@ function handleTouchcancel (e: ExtendedNativeTouchEvent, type: EventType, eventC
216
230
  innerRef.current.startTimer[type] && clearTimeout(innerRef.current.startTimer[type] as unknown as number)
217
231
  }
218
232
 
219
- function createTouchEventHandler (eventName: string, eventConfig: EventConfig) {
220
- return (e: ExtendedNativeTouchEvent) => {
221
- const bubbleHandlerMap: Record<string, any> = {
222
- onTouchStart: handleTouchstart,
223
- onTouchMove: handleTouchmove,
224
- onTouchEnd: handleTouchend,
225
- onTouchCancel: handleTouchcancel
226
- }
227
-
228
- const captureHandlerMap: Record<string, any> = {
229
- onTouchStartCapture: handleTouchstart,
230
- onTouchMoveCapture: handleTouchmove,
231
- onTouchEndCapture: handleTouchend,
232
- onTouchCancelCapture: handleTouchcancel
233
- }
234
-
235
- if (bubbleHandlerMap[eventName]) {
236
- bubbleHandlerMap[eventName](e, 'bubble', eventConfig)
237
- }
233
+ const touchHandlerMap: Record<string, TouchHandlerConfig> = {
234
+ onTouchStart: {
235
+ type: 'bubble',
236
+ handler: handleTouchstart
237
+ },
238
+ onTouchMove: {
239
+ type: 'bubble',
240
+ handler: handleTouchmove
241
+ },
242
+ onTouchEnd: {
243
+ type: 'bubble',
244
+ handler: handleTouchend
245
+ },
246
+ onTouchCancel: {
247
+ type: 'bubble',
248
+ handler: handleTouchcancel
249
+ },
250
+ onTouchStartCapture: {
251
+ type: 'capture',
252
+ handler: handleTouchstart
253
+ },
254
+ onTouchMoveCapture: {
255
+ type: 'capture',
256
+ handler: handleTouchmove
257
+ },
258
+ onTouchEndCapture: {
259
+ type: 'capture',
260
+ handler: handleTouchend
261
+ },
262
+ onTouchCancelCapture: {
263
+ type: 'capture',
264
+ handler: handleTouchcancel
265
+ }
266
+ }
238
267
 
239
- if (captureHandlerMap[eventName]) {
240
- captureHandlerMap[eventName](e, 'capture', eventConfig)
241
- }
268
+ function createTouchEventHandler (eventName: string, eventConfigRef: EventConfigRef) {
269
+ const eventHandler = touchHandlerMap[eventName]
270
+ return (e: ExtendedNativeTouchEvent) => {
271
+ eventHandler.handler(e, eventHandler.type, eventConfigRef.current)
242
272
  }
243
273
  }
244
274
 
@@ -271,37 +301,45 @@ const useInnerProps = (
271
301
  disableTap: false,
272
302
  navigation
273
303
  }, rawConfig)
304
+ const eventConfigRef = useRef<EventConfig>(eventConfig)
274
305
 
306
+ const restProps: Props = {}
307
+ const eventNameMap: Record<string, boolean> = {}
308
+ const userRemovePropsMap: Record<string, boolean> = {}
275
309
  let hashEventKey = ''
276
- const rawEventKeys: Array<string> = []
277
- const transformedEventSet = new Set<string>()
310
+
311
+ userRemoveProps.forEach((key) => {
312
+ userRemovePropsMap[key] = true
313
+ })
314
+
278
315
  Object.keys(props).forEach((key) => {
279
- if (eventConfigMap[key]) {
280
- hashEventKey += eventConfigMap[key].bitFlag
281
- rawEventKeys.push(key)
282
- eventConfigMap[key].events.forEach((event) => {
283
- transformedEventSet.add(event)
316
+ const eventMeta = eventConfigMap[key]
317
+
318
+ if (eventMeta) {
319
+ hashEventKey += eventMeta.bitFlag
320
+ eventMeta.events.forEach((event) => {
321
+ eventNameMap[event] = true
284
322
  })
285
- const match = /^(bind|catch|capture-bind|capture-catch)(.*)$/.exec(key)!
286
- const prefix = match[1]
287
- const eventName = match[2]
288
- eventConfig[eventName] = eventConfig[eventName] || {
323
+ eventConfig[eventMeta.eventName] = eventConfig[eventMeta.eventName] || {
289
324
  bubble: [],
290
325
  capture: [],
291
326
  hasCatch: false
292
327
  }
293
- if (prefix === 'bind' || prefix === 'catch') {
294
- eventConfig[eventName].bubble.push(key)
295
- } else {
296
- eventConfig[eventName].capture.push(key)
297
- }
328
+ eventConfig[eventMeta.eventName][eventMeta.eventType].push(key)
298
329
 
299
- if (prefix === 'catch' || prefix === 'capture-catch') {
300
- eventConfig[eventName].hasCatch = true
330
+ if (eventMeta.hasCatch) {
331
+ eventConfig[eventMeta.eventName].hasCatch = true
301
332
  }
333
+ return
334
+ }
335
+
336
+ if (!baseRemovePropsMap[key] && !userRemovePropsMap[key]) {
337
+ restProps[key] = props[key]
302
338
  }
303
339
  })
304
340
 
341
+ eventConfigRef.current = eventConfig
342
+
305
343
  const events = useMemo(() => {
306
344
  if (!hashEventKey) {
307
345
  return {}
@@ -309,31 +347,17 @@ const useInnerProps = (
309
347
 
310
348
  const events: Record<string, (e: ExtendedNativeTouchEvent) => void> = {}
311
349
 
312
- for (const eventName of transformedEventSet) {
313
- events[eventName] = createTouchEventHandler(eventName, eventConfig)
314
- }
350
+ Object.keys(eventNameMap).forEach((eventName) => {
351
+ events[eventName] = createTouchEventHandler(eventName, eventConfigRef)
352
+ })
315
353
 
316
354
  return events
317
355
  }, [hashEventKey])
318
356
 
319
- const removeProps = [
320
- 'children',
321
- 'enable-background',
322
- 'enable-offset',
323
- 'enable-var',
324
- 'external-var-context',
325
- 'parent-font-size',
326
- 'parent-width',
327
- 'parent-height',
328
- 'enable-text-pass-through',
329
- ...userRemoveProps,
330
- ...rawEventKeys
331
- ]
332
-
333
357
  return extendObject(
334
358
  {},
335
359
  events,
336
- omit(props, removeProps)
360
+ restProps
337
361
  )
338
362
  }
339
363
  export default useInnerProps
@@ -45,9 +45,9 @@ import {
45
45
  NativeSyntheticEvent,
46
46
  useAnimatedValue
47
47
  } from 'react-native'
48
- import { warn } from '@mpxjs/utils'
48
+ import { warn, hasOwn } from '@mpxjs/utils'
49
49
  import { GestureDetector, PanGesture } from 'react-native-gesture-handler'
50
- import { getCurrentPage, splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject, useHover, useTextPassThroughValue } from './utils'
50
+ import { getCurrentPage, splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject, useHover, useTextPassThrough } from './utils'
51
51
  import useInnerProps, { getCustomEvent } from './getInnerListeners'
52
52
  import useNodesRef, { HandlerRef } from './useNodesRef'
53
53
  import { RouteContext, FormContext } from './context'
@@ -79,8 +79,7 @@ export interface ButtonProps {
79
79
  'form-type'?: 'submit' | 'reset'
80
80
  'enable-offset'?: boolean,
81
81
  'enable-var'?: boolean
82
- 'external-var-context'?: Record<string, any>
83
- 'parent-font-size'?: number
82
+ 'enable-text-pass-through'?: boolean
84
83
  'parent-width'?: number
85
84
  'parent-height'?: number
86
85
  style?: ViewStyle & TextStyle & Record<string, any>
@@ -105,14 +104,14 @@ const OpenTypeEventsMap = new Map<OpenType, OpenTypeEvent>([
105
104
 
106
105
  const styles = StyleSheet.create({
107
106
  button: {
108
- width: '100%',
109
107
  flexDirection: 'row',
110
108
  justifyContent: 'center',
111
109
  alignItems: 'center',
112
110
  height: 46,
113
111
  borderRadius: 5,
114
112
  backgroundColor: '#F8F8F8',
115
- marginHorizontal: 'auto' // 按钮默认居中
113
+ marginHorizontal: 'auto',
114
+ paddingHorizontal: 14
116
115
  },
117
116
  buttonMini: {
118
117
  height: 30
@@ -211,8 +210,7 @@ const Button = forwardRef<HandlerRef<View, ButtonProps>, ButtonProps>((buttonPro
211
210
  'open-type': openType,
212
211
  'form-type': formType,
213
212
  'enable-var': enableVar,
214
- 'external-var-context': externalVarContext,
215
- 'parent-font-size': parentFontSize,
213
+ 'enable-text-pass-through': enableTextPassThrough,
216
214
  'parent-width': parentWidth,
217
215
  'parent-height': parentHeight,
218
216
  style = {},
@@ -282,14 +280,16 @@ const Button = forwardRef<HandlerRef<View, ButtonProps>, ButtonProps>((buttonPro
282
280
  { color: plain ? plainTextColor : normalTextColor }
283
281
  )
284
282
 
285
- const defaultStyle = extendObject({}, defaultViewStyle, defaultTextStyle)
283
+ const styleObj = isHover ? extendObject({}, style, hoverStyle) : style
286
284
 
287
- const styleObj = extendObject(
288
- {},
289
- defaultStyle,
290
- style,
291
- isHover ? hoverStyle : {}
292
- )
285
+ const defaultStyle: Record<string, any> = extendObject({}, defaultViewStyle, defaultTextStyle)
286
+ // 用户 shorthand 优先:避免 longhand default 反向覆盖
287
+ if (hasOwn(styleObj, 'margin')) {
288
+ delete defaultStyle.marginHorizontal
289
+ }
290
+ if (hasOwn(styleObj, 'padding')) {
291
+ delete defaultStyle.paddingHorizontal
292
+ }
293
293
 
294
294
  const {
295
295
  hasPositionFixed,
@@ -299,7 +299,7 @@ const Button = forwardRef<HandlerRef<View, ButtonProps>, ButtonProps>((buttonPro
299
299
  varContextRef,
300
300
  setWidth,
301
301
  setHeight
302
- } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
302
+ } = useTransformStyle(styleObj, { enableVar, parentWidth, parentHeight, defaultStyle })
303
303
 
304
304
  const nodeRef = useRef(null)
305
305
 
@@ -308,7 +308,7 @@ const Button = forwardRef<HandlerRef<View, ButtonProps>, ButtonProps>((buttonPro
308
308
  const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef })
309
309
 
310
310
  const { textStyle, backgroundStyle, innerStyle = {} } = splitStyle(normalStyle)
311
- const textPassThrough = useTextPassThroughValue(textStyle, textProps)
311
+ const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough })
312
312
 
313
313
  if (backgroundStyle) {
314
314
  warn('Button does not support background image-related styles!')
@@ -407,7 +407,7 @@ const Button = forwardRef<HandlerRef<View, ButtonProps>, ButtonProps>((buttonPro
407
407
 
408
408
  const baseButton = createElement(View, innerProps, loading && createElement(Loading, { alone: !children }),
409
409
  wrapChildren(
410
- props,
410
+ props.children,
411
411
  {
412
412
  hasVarDec,
413
413
  varContext: varContextRef.current,
@@ -24,11 +24,9 @@ interface CameraProps {
24
24
  binderror?: (error: { message: string }) => void
25
25
  bindinitdone?: (result: { type: string, data: string }) => void
26
26
  bindscancode?: (result: { type: string, data: string }) => void
27
- 'parent-font-size'?: number
28
27
  'parent-width'?: number
29
28
  'parent-height'?: number
30
29
  'enable-var'?: boolean
31
- 'external-var-context'?: any
32
30
  }
33
31
 
34
32
  interface TakePhotoOptions {
@@ -59,12 +57,29 @@ interface CameraRef {
59
57
  stopRecord: (options?: StopRecordOptions) => void
60
58
  }
61
59
 
60
+ interface CameraPermissionCache {
61
+ promise?: Promise<any>
62
+ result?: boolean
63
+ }
64
+
62
65
  type HandlerRef<T, P> = {
63
66
  current: T | null
64
67
  }
65
68
 
66
69
  let RecordRes: any = null
67
70
 
71
+ const cameraPermissionCacheMap = new Map<number, CameraPermissionCache>()
72
+
73
+ function getCameraPermissionCache (pageId: number | undefined) {
74
+ if (pageId == null) return
75
+ let cache = cameraPermissionCacheMap.get(pageId)
76
+ if (!cache) {
77
+ cache = {}
78
+ cameraPermissionCacheMap.set(pageId, cache)
79
+ }
80
+ return cache
81
+ }
82
+
68
83
  const _camera = forwardRef<HandlerRef<any, CameraProps>, CameraProps>((props: CameraProps, ref): JSX.Element | null => {
69
84
  // eslint-disable-next-line @typescript-eslint/no-var-requires
70
85
  const cameraRef = useRef<any>(null)
@@ -77,11 +92,9 @@ const _camera = forwardRef<HandlerRef<any, CameraProps>, CameraProps>((props: Ca
77
92
  bindinitdone,
78
93
  bindstop,
79
94
  bindscancode,
80
- 'parent-font-size': parentFontSize,
81
95
  'parent-width': parentWidth,
82
96
  'parent-height': parentHeight,
83
97
  'enable-var': enableVar,
84
- 'external-var-context': externalVarContext,
85
98
  style = {}
86
99
  } = props
87
100
  const styleObj = extendObject(
@@ -95,8 +108,6 @@ const _camera = forwardRef<HandlerRef<any, CameraProps>, CameraProps>((props: Ca
95
108
  setHeight
96
109
  } = useTransformStyle(styleObj, {
97
110
  enableVar,
98
- externalVarContext,
99
- parentFontSize,
100
111
  parentWidth,
101
112
  parentHeight
102
113
  })
@@ -286,12 +297,33 @@ const _camera = forwardRef<HandlerRef<any, CameraProps>, CameraProps>((props: Ca
286
297
  try {
287
298
  const cameraPermission = global?.__mpx?.config?.rnConfig?.cameraPermission
288
299
  if (typeof cameraPermission === 'function') {
289
- const permissionResult = await cameraPermission()
290
- setHasPermission(permissionResult === true)
300
+ const permissionCache = getCameraPermissionCache(pageId)
301
+ if (permissionCache && hasOwn(permissionCache, 'result')) {
302
+ setHasPermission(permissionCache.result === true)
303
+ return
304
+ }
305
+ let permissionResult
306
+ if (permissionCache) {
307
+ if (!permissionCache.promise) {
308
+ permissionCache.promise = cameraPermission()
309
+ }
310
+ permissionResult = await permissionCache.promise
311
+ } else {
312
+ permissionResult = await cameraPermission()
313
+ }
314
+ const granted = permissionResult === true
315
+ if (permissionCache) {
316
+ permissionCache.result = granted
317
+ }
318
+ setHasPermission(granted)
291
319
  } else {
292
320
  setHasPermission(true)
293
321
  }
294
322
  } catch (error) {
323
+ const permissionCache = getCameraPermissionCache(pageId)
324
+ if (permissionCache) {
325
+ permissionCache.result = false
326
+ }
295
327
  setHasPermission(false)
296
328
  }
297
329
  }
@@ -33,6 +33,8 @@ import { createImageData as canvasCreateImageData } from './ImageData'
33
33
  import { useConstructorsRegistry } from './constructorsRegistry'
34
34
  import Portal from '../mpx-portal'
35
35
 
36
+ type WebViewInstance = WebView<any>
37
+
36
38
  const stylesheet = StyleSheet.create({
37
39
  container: { overflow: 'hidden', flex: 0 },
38
40
  webview: {
@@ -52,10 +54,8 @@ interface CanvasProps {
52
54
  style?: Record<string, any>
53
55
  originWhitelist?: Array<string>
54
56
  'enable-var'?: boolean
55
- 'parent-font-size'?: number
56
57
  'parent-width'?: number
57
58
  'parent-height'?: number
58
- 'external-var-context'?: Record<string, any>
59
59
  bindtouchstart?: (event: NativeSyntheticEvent<TouchEvent>) => void
60
60
  bindtouchmove?: (event: NativeSyntheticEvent<TouchEvent>) => void
61
61
  bindtouchend?: (event: NativeSyntheticEvent<TouchEvent>) => void
@@ -65,7 +65,7 @@ interface CanvasProps {
65
65
  }
66
66
 
67
67
  const _Canvas = forwardRef<HandlerRef<CanvasProps & View, CanvasProps>, CanvasProps>((props: CanvasProps = {}, ref): JSX.Element => {
68
- const { style = {}, originWhitelist = ['*'], 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props
68
+ const { style = {}, originWhitelist = ['*'], 'enable-var': enableVar, 'parent-width': parentWidth, 'parent-height': parentHeight } = props
69
69
  const [isLoaded, setIsLoaded] = useState(false)
70
70
  const nodeRef = useRef(null)
71
71
 
@@ -77,8 +77,6 @@ const _Canvas = forwardRef<HandlerRef<CanvasProps & View, CanvasProps>, CanvasPr
77
77
  setHeight
78
78
  } = useTransformStyle(extendObject({}, style, stylesheet.container), {
79
79
  enableVar,
80
- externalVarContext,
81
- parentFontSize,
82
80
  parentWidth,
83
81
  parentHeight
84
82
  })
@@ -268,7 +266,7 @@ const _Canvas = forwardRef<HandlerRef<CanvasProps & View, CanvasProps>, CanvasPr
268
266
  canvasComponent = createElement(View, innerProps, createElement(
269
267
  WebView,
270
268
  {
271
- ref: (element) => {
269
+ ref: (element: WebViewInstance | null) => {
272
270
  if (canvasRef.current) {
273
271
  canvasRef.current.webview = element
274
272
  }
@@ -293,7 +291,7 @@ const _Canvas = forwardRef<HandlerRef<CanvasProps & View, CanvasProps>, CanvasPr
293
291
  }
294
292
 
295
293
  canvasComponent = createElement(View, innerProps, createElement(WebView, {
296
- ref: (element) => {
294
+ ref: (element: WebViewInstance | null) => {
297
295
  if (canvasRef.current) {
298
296
  canvasRef.current.webview = element
299
297
  }
@@ -42,7 +42,9 @@ export interface WebviewMessage {
42
42
  }
43
43
 
44
44
  export interface CanvasInstance {
45
- webview: WebView | null;
45
+ // react-native-webview@13.17+ WebView 泛型默认值由 {} 改为 undefined,
46
+ // ref 回调推断出的 WebView<unknown> 无法赋给默认实参化后的类型,这里显式用 any 兼容各版本
47
+ webview: WebView<any> | null;
46
48
  bus: Bus | null;
47
49
  context2D: CanvasRenderingContext2D;
48
50
  getContext: (contextType: string) => CanvasRenderingContext2D | null;
@@ -28,8 +28,6 @@ export interface CheckboxGroupProps {
28
28
  style?: ViewStyle & Record<string, any>
29
29
  'enable-offset'?: boolean
30
30
  'enable-var'?: boolean
31
- 'external-var-context'?: Record<string, any>
32
- 'parent-font-size'?: number
33
31
  'parent-width'?: number
34
32
  'parent-height'?: number
35
33
  children: ReactNode
@@ -45,8 +43,6 @@ const CheckboxGroup = forwardRef<
45
43
  const {
46
44
  style = {},
47
45
  'enable-var': enableVar,
48
- 'external-var-context': externalVarContext,
49
- 'parent-font-size': parentFontSize,
50
46
  'parent-width': parentWidth,
51
47
  'parent-height': parentHeight
52
48
  } = props
@@ -66,8 +62,6 @@ const CheckboxGroup = forwardRef<
66
62
  flexWrap: 'wrap'
67
63
  }
68
64
 
69
- const styleObj = extendObject({}, defaultStyle, style)
70
-
71
65
  const {
72
66
  hasPositionFixed,
73
67
  hasSelfPercent,
@@ -76,7 +70,7 @@ const CheckboxGroup = forwardRef<
76
70
  varContextRef,
77
71
  setWidth,
78
72
  setHeight
79
- } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
73
+ } = useTransformStyle(style, { enableVar, parentWidth, parentHeight, defaultStyle })
80
74
 
81
75
  const nodeRef = useRef(null)
82
76
 
@@ -169,7 +163,7 @@ const CheckboxGroup = forwardRef<
169
163
  CheckboxGroupContext.Provider,
170
164
  { value: contextValue },
171
165
  wrapChildren(
172
- props,
166
+ props.children,
173
167
  {
174
168
  hasVarDec,
175
169
  varContext: varContextRef.current