@mpxjs/webpack-plugin 2.10.24-beta.1 → 2.10.24-test.1
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/index.js +1 -4
- package/lib/platform/style/wx/index.js +395 -104
- package/lib/react/style-helper.js +6 -6
- package/lib/resolver/AddEnvPlugin.js +1 -1
- package/lib/resolver/AddModePlugin.js +1 -1
- package/lib/runtime/components/react/animationHooks/index.ts +7 -3
- package/lib/runtime/components/react/dist/animationHooks/index.d.ts +0 -2
- package/lib/runtime/components/react/dist/animationHooks/index.js +6 -1
- package/lib/runtime/components/react/dist/event.config.d.ts +2 -6
- package/lib/runtime/components/react/dist/event.config.js +28 -24
- package/lib/runtime/components/react/dist/getInnerListeners.d.ts +1 -1
- package/lib/runtime/components/react/dist/getInnerListeners.js +74 -56
- package/lib/runtime/components/react/dist/mpx-button.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-button.jsx +16 -9
- package/lib/runtime/components/react/dist/mpx-camera.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-camera.jsx +1 -2
- package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +1 -2
- package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +1 -3
- package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +3 -4
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-checkbox.jsx +8 -9
- package/lib/runtime/components/react/dist/mpx-form.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-form.jsx +5 -5
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-icon/index.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-image.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-image.jsx +59 -43
- package/lib/runtime/components/react/dist/mpx-input.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-input.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-label.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-label.jsx +5 -6
- package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +3 -3
- package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +6 -6
- package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +5 -7
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-progress.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-progress.jsx +1 -2
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-radio-group.jsx +3 -4
- package/lib/runtime/components/react/dist/mpx-radio.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-radio.jsx +8 -9
- package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +1 -2
- package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +6 -6
- package/lib/runtime/components/react/dist/mpx-simple-text.jsx +24 -19
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +4 -1
- package/lib/runtime/components/react/dist/mpx-simple-view.jsx +11 -4
- package/lib/runtime/components/react/dist/mpx-slider.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-slider.jsx +6 -6
- package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +5 -5
- package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-sticky-section.jsx +6 -6
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +5 -5
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +4 -7
- package/lib/runtime/components/react/dist/mpx-switch.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-switch.jsx +1 -2
- package/lib/runtime/components/react/dist/mpx-text.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-text.jsx +29 -25
- package/lib/runtime/components/react/dist/mpx-video.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-video.jsx +4 -4
- package/lib/runtime/components/react/dist/mpx-view.d.ts +2 -1
- package/lib/runtime/components/react/dist/mpx-view.jsx +214 -113
- package/lib/runtime/components/react/dist/mpx-web-view.d.ts +1 -2
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +5 -1
- package/lib/runtime/components/react/dist/namedColorSet.d.ts +2 -0
- package/lib/runtime/components/react/dist/namedColorSet.js +149 -0
- package/lib/runtime/components/react/dist/utils.d.ts +73 -70
- package/lib/runtime/components/react/dist/utils.jsx +1295 -445
- package/lib/runtime/components/react/event.config.ts +32 -25
- package/lib/runtime/components/react/getInnerListeners.ts +84 -60
- package/lib/runtime/components/react/mpx-button.tsx +18 -16
- package/lib/runtime/components/react/mpx-camera.tsx +0 -3
- package/lib/runtime/components/react/mpx-canvas/index.tsx +3 -7
- package/lib/runtime/components/react/mpx-canvas/utils.tsx +3 -3
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +2 -6
- package/lib/runtime/components/react/mpx-checkbox.tsx +9 -11
- package/lib/runtime/components/react/mpx-form.tsx +6 -6
- package/lib/runtime/components/react/mpx-icon/index.tsx +1 -3
- package/lib/runtime/components/react/mpx-image.tsx +65 -54
- package/lib/runtime/components/react/mpx-input.tsx +1 -3
- package/lib/runtime/components/react/mpx-label.tsx +6 -8
- package/lib/runtime/components/react/mpx-movable-area.tsx +3 -4
- package/lib/runtime/components/react/mpx-movable-view.tsx +7 -7
- package/lib/runtime/components/react/mpx-picker-view/index.tsx +6 -8
- package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +2 -4
- package/lib/runtime/components/react/mpx-progress.tsx +0 -3
- package/lib/runtime/components/react/mpx-radio-group.tsx +2 -6
- package/lib/runtime/components/react/mpx-radio.tsx +9 -11
- package/lib/runtime/components/react/mpx-rich-text/index.tsx +0 -3
- package/lib/runtime/components/react/mpx-scroll-view.tsx +7 -7
- package/lib/runtime/components/react/mpx-simple-text.tsx +24 -26
- package/lib/runtime/components/react/mpx-simple-view.tsx +17 -5
- package/lib/runtime/components/react/mpx-slider.tsx +15 -10
- package/lib/runtime/components/react/mpx-sticky-header.tsx +6 -6
- package/lib/runtime/components/react/mpx-sticky-section.tsx +7 -7
- package/lib/runtime/components/react/mpx-swiper-item.tsx +6 -6
- package/lib/runtime/components/react/mpx-swiper.tsx +5 -8
- package/lib/runtime/components/react/mpx-switch.tsx +0 -3
- package/lib/runtime/components/react/mpx-text.tsx +31 -34
- package/lib/runtime/components/react/mpx-video.tsx +3 -5
- package/lib/runtime/components/react/mpx-view.tsx +235 -126
- package/lib/runtime/components/react/mpx-web-view.tsx +11 -7
- package/lib/runtime/components/react/namedColorSet.ts +150 -0
- package/lib/runtime/components/react/types/getInnerListeners.d.ts +21 -1
- package/lib/runtime/components/react/types/global.d.ts +1 -0
- package/lib/runtime/components/react/utils.tsx +1348 -544
- package/lib/runtime/i18n.wxs +15 -9
- package/lib/style-compiler/strip-conditional.js +19 -4
- package/package.json +2 -2
- package/lib/resolver/ExtendComponentsPlugin.js +0 -91
- package/lib/runtime/components/extends/section-list.mpx +0 -14
- package/lib/runtime/components/react/dist/mpx-section-list.d.ts +0 -56
- package/lib/runtime/components/react/dist/mpx-section-list.jsx +0 -484
- package/lib/runtime/components/react/mpx-section-list.tsx +0 -734
|
@@ -1,28 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
'capture-
|
|
22
|
-
'capture-
|
|
23
|
-
'capture-
|
|
24
|
-
'capture-
|
|
25
|
-
'capture-
|
|
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 {
|
|
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
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
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
|
-
|
|
240
|
-
|
|
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
|
-
|
|
277
|
-
|
|
310
|
+
|
|
311
|
+
userRemoveProps.forEach((key) => {
|
|
312
|
+
userRemovePropsMap[key] = true
|
|
313
|
+
})
|
|
314
|
+
|
|
278
315
|
Object.keys(props).forEach((key) => {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 (
|
|
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
|
-
|
|
313
|
-
events[eventName] = createTouchEventHandler(eventName,
|
|
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
|
-
|
|
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,
|
|
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,7 +79,7 @@ export interface ButtonProps {
|
|
|
79
79
|
'form-type'?: 'submit' | 'reset'
|
|
80
80
|
'enable-offset'?: boolean,
|
|
81
81
|
'enable-var'?: boolean
|
|
82
|
-
'
|
|
82
|
+
'enable-text-pass-through'?: boolean
|
|
83
83
|
'parent-font-size'?: number
|
|
84
84
|
'parent-width'?: number
|
|
85
85
|
'parent-height'?: number
|
|
@@ -105,14 +105,14 @@ const OpenTypeEventsMap = new Map<OpenType, OpenTypeEvent>([
|
|
|
105
105
|
|
|
106
106
|
const styles = StyleSheet.create({
|
|
107
107
|
button: {
|
|
108
|
-
width: '100%',
|
|
109
108
|
flexDirection: 'row',
|
|
110
109
|
justifyContent: 'center',
|
|
111
110
|
alignItems: 'center',
|
|
112
111
|
height: 46,
|
|
113
112
|
borderRadius: 5,
|
|
114
113
|
backgroundColor: '#F8F8F8',
|
|
115
|
-
marginHorizontal: 'auto'
|
|
114
|
+
marginHorizontal: 'auto',
|
|
115
|
+
paddingHorizontal: 14
|
|
116
116
|
},
|
|
117
117
|
buttonMini: {
|
|
118
118
|
height: 30
|
|
@@ -211,7 +211,7 @@ const Button = forwardRef<HandlerRef<View, ButtonProps>, ButtonProps>((buttonPro
|
|
|
211
211
|
'open-type': openType,
|
|
212
212
|
'form-type': formType,
|
|
213
213
|
'enable-var': enableVar,
|
|
214
|
-
'
|
|
214
|
+
'enable-text-pass-through': enableTextPassThrough,
|
|
215
215
|
'parent-font-size': parentFontSize,
|
|
216
216
|
'parent-width': parentWidth,
|
|
217
217
|
'parent-height': parentHeight,
|
|
@@ -282,14 +282,16 @@ const Button = forwardRef<HandlerRef<View, ButtonProps>, ButtonProps>((buttonPro
|
|
|
282
282
|
{ color: plain ? plainTextColor : normalTextColor }
|
|
283
283
|
)
|
|
284
284
|
|
|
285
|
-
const
|
|
285
|
+
const styleObj = isHover ? extendObject({}, style, hoverStyle) : style
|
|
286
286
|
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
)
|
|
287
|
+
const defaultStyle: Record<string, any> = extendObject({}, defaultViewStyle, defaultTextStyle)
|
|
288
|
+
// 用户 shorthand 优先:避免 longhand default 反向覆盖
|
|
289
|
+
if (hasOwn(styleObj, 'margin')) {
|
|
290
|
+
delete defaultStyle.marginHorizontal
|
|
291
|
+
}
|
|
292
|
+
if (hasOwn(styleObj, 'padding')) {
|
|
293
|
+
delete defaultStyle.paddingHorizontal
|
|
294
|
+
}
|
|
293
295
|
|
|
294
296
|
const {
|
|
295
297
|
hasPositionFixed,
|
|
@@ -299,7 +301,7 @@ const Button = forwardRef<HandlerRef<View, ButtonProps>, ButtonProps>((buttonPro
|
|
|
299
301
|
varContextRef,
|
|
300
302
|
setWidth,
|
|
301
303
|
setHeight
|
|
302
|
-
} = useTransformStyle(styleObj, { enableVar,
|
|
304
|
+
} = useTransformStyle(styleObj, { enableVar, parentFontSize, parentWidth, parentHeight, defaultStyle })
|
|
303
305
|
|
|
304
306
|
const nodeRef = useRef(null)
|
|
305
307
|
|
|
@@ -308,7 +310,7 @@ const Button = forwardRef<HandlerRef<View, ButtonProps>, ButtonProps>((buttonPro
|
|
|
308
310
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef })
|
|
309
311
|
|
|
310
312
|
const { textStyle, backgroundStyle, innerStyle = {} } = splitStyle(normalStyle)
|
|
311
|
-
const textPassThrough =
|
|
313
|
+
const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough })
|
|
312
314
|
|
|
313
315
|
if (backgroundStyle) {
|
|
314
316
|
warn('Button does not support background image-related styles!')
|
|
@@ -407,7 +409,7 @@ const Button = forwardRef<HandlerRef<View, ButtonProps>, ButtonProps>((buttonPro
|
|
|
407
409
|
|
|
408
410
|
const baseButton = createElement(View, innerProps, loading && createElement(Loading, { alone: !children }),
|
|
409
411
|
wrapChildren(
|
|
410
|
-
props,
|
|
412
|
+
props.children,
|
|
411
413
|
{
|
|
412
414
|
hasVarDec,
|
|
413
415
|
varContext: varContextRef.current,
|
|
@@ -28,7 +28,6 @@ interface CameraProps {
|
|
|
28
28
|
'parent-width'?: number
|
|
29
29
|
'parent-height'?: number
|
|
30
30
|
'enable-var'?: boolean
|
|
31
|
-
'external-var-context'?: any
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
interface TakePhotoOptions {
|
|
@@ -81,7 +80,6 @@ const _camera = forwardRef<HandlerRef<any, CameraProps>, CameraProps>((props: Ca
|
|
|
81
80
|
'parent-width': parentWidth,
|
|
82
81
|
'parent-height': parentHeight,
|
|
83
82
|
'enable-var': enableVar,
|
|
84
|
-
'external-var-context': externalVarContext,
|
|
85
83
|
style = {}
|
|
86
84
|
} = props
|
|
87
85
|
const styleObj = extendObject(
|
|
@@ -95,7 +93,6 @@ const _camera = forwardRef<HandlerRef<any, CameraProps>, CameraProps>((props: Ca
|
|
|
95
93
|
setHeight
|
|
96
94
|
} = useTransformStyle(styleObj, {
|
|
97
95
|
enableVar,
|
|
98
|
-
externalVarContext,
|
|
99
96
|
parentFontSize,
|
|
100
97
|
parentWidth,
|
|
101
98
|
parentHeight
|
|
@@ -33,8 +33,6 @@ 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<{}>
|
|
37
|
-
|
|
38
36
|
const stylesheet = StyleSheet.create({
|
|
39
37
|
container: { overflow: 'hidden', flex: 0 },
|
|
40
38
|
webview: {
|
|
@@ -57,7 +55,6 @@ interface CanvasProps {
|
|
|
57
55
|
'parent-font-size'?: number
|
|
58
56
|
'parent-width'?: number
|
|
59
57
|
'parent-height'?: number
|
|
60
|
-
'external-var-context'?: Record<string, any>
|
|
61
58
|
bindtouchstart?: (event: NativeSyntheticEvent<TouchEvent>) => void
|
|
62
59
|
bindtouchmove?: (event: NativeSyntheticEvent<TouchEvent>) => void
|
|
63
60
|
bindtouchend?: (event: NativeSyntheticEvent<TouchEvent>) => void
|
|
@@ -67,7 +64,7 @@ interface CanvasProps {
|
|
|
67
64
|
}
|
|
68
65
|
|
|
69
66
|
const _Canvas = forwardRef<HandlerRef<CanvasProps & View, CanvasProps>, CanvasProps>((props: CanvasProps = {}, ref): JSX.Element => {
|
|
70
|
-
const { style = {}, originWhitelist = ['*'], 'enable-var': enableVar, '
|
|
67
|
+
const { style = {}, originWhitelist = ['*'], 'enable-var': enableVar, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props
|
|
71
68
|
const [isLoaded, setIsLoaded] = useState(false)
|
|
72
69
|
const nodeRef = useRef(null)
|
|
73
70
|
|
|
@@ -79,7 +76,6 @@ const _Canvas = forwardRef<HandlerRef<CanvasProps & View, CanvasProps>, CanvasPr
|
|
|
79
76
|
setHeight
|
|
80
77
|
} = useTransformStyle(extendObject({}, style, stylesheet.container), {
|
|
81
78
|
enableVar,
|
|
82
|
-
externalVarContext,
|
|
83
79
|
parentFontSize,
|
|
84
80
|
parentWidth,
|
|
85
81
|
parentHeight
|
|
@@ -270,7 +266,7 @@ const _Canvas = forwardRef<HandlerRef<CanvasProps & View, CanvasProps>, CanvasPr
|
|
|
270
266
|
canvasComponent = createElement(View, innerProps, createElement(
|
|
271
267
|
WebView,
|
|
272
268
|
{
|
|
273
|
-
ref: (element
|
|
269
|
+
ref: (element) => {
|
|
274
270
|
if (canvasRef.current) {
|
|
275
271
|
canvasRef.current.webview = element
|
|
276
272
|
}
|
|
@@ -295,7 +291,7 @@ const _Canvas = forwardRef<HandlerRef<CanvasProps & View, CanvasProps>, CanvasPr
|
|
|
295
291
|
}
|
|
296
292
|
|
|
297
293
|
canvasComponent = createElement(View, innerProps, createElement(WebView, {
|
|
298
|
-
ref: (element
|
|
294
|
+
ref: (element) => {
|
|
299
295
|
if (canvasRef.current) {
|
|
300
296
|
canvasRef.current.webview = element
|
|
301
297
|
}
|
|
@@ -2,8 +2,6 @@ import { useEffect, useRef } from 'react'
|
|
|
2
2
|
import { WebView } from 'react-native-webview'
|
|
3
3
|
import Bus from './Bus'
|
|
4
4
|
|
|
5
|
-
type WebViewInstance = WebView<{}>
|
|
6
|
-
|
|
7
5
|
export const WEBVIEW_TARGET = '@@WEBVIEW_TARGET'
|
|
8
6
|
|
|
9
7
|
export const constructors: Record<string, any> = {}
|
|
@@ -44,7 +42,9 @@ export interface WebviewMessage {
|
|
|
44
42
|
}
|
|
45
43
|
|
|
46
44
|
export interface CanvasInstance {
|
|
47
|
-
webview
|
|
45
|
+
// react-native-webview@13.17+ 将 WebView 泛型默认值由 {} 改为 undefined,
|
|
46
|
+
// ref 回调推断出的 WebView<unknown> 无法赋给默认实参化后的类型,这里显式用 any 兼容各版本
|
|
47
|
+
webview: WebView<any> | null;
|
|
48
48
|
bus: Bus | null;
|
|
49
49
|
context2D: CanvasRenderingContext2D;
|
|
50
50
|
getContext: (contextType: string) => CanvasRenderingContext2D | null;
|
|
@@ -28,7 +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
31
|
'parent-font-size'?: number
|
|
33
32
|
'parent-width'?: number
|
|
34
33
|
'parent-height'?: number
|
|
@@ -45,7 +44,6 @@ const CheckboxGroup = forwardRef<
|
|
|
45
44
|
const {
|
|
46
45
|
style = {},
|
|
47
46
|
'enable-var': enableVar,
|
|
48
|
-
'external-var-context': externalVarContext,
|
|
49
47
|
'parent-font-size': parentFontSize,
|
|
50
48
|
'parent-width': parentWidth,
|
|
51
49
|
'parent-height': parentHeight
|
|
@@ -66,8 +64,6 @@ const CheckboxGroup = forwardRef<
|
|
|
66
64
|
flexWrap: 'wrap'
|
|
67
65
|
}
|
|
68
66
|
|
|
69
|
-
const styleObj = extendObject({}, defaultStyle, style)
|
|
70
|
-
|
|
71
67
|
const {
|
|
72
68
|
hasPositionFixed,
|
|
73
69
|
hasSelfPercent,
|
|
@@ -76,7 +72,7 @@ const CheckboxGroup = forwardRef<
|
|
|
76
72
|
varContextRef,
|
|
77
73
|
setWidth,
|
|
78
74
|
setHeight
|
|
79
|
-
} = useTransformStyle(
|
|
75
|
+
} = useTransformStyle(style, { enableVar, parentFontSize, parentWidth, parentHeight, defaultStyle })
|
|
80
76
|
|
|
81
77
|
const nodeRef = useRef(null)
|
|
82
78
|
|
|
@@ -169,7 +165,7 @@ const CheckboxGroup = forwardRef<
|
|
|
169
165
|
CheckboxGroupContext.Provider,
|
|
170
166
|
{ value: contextValue },
|
|
171
167
|
wrapChildren(
|
|
172
|
-
props,
|
|
168
|
+
props.children,
|
|
173
169
|
{
|
|
174
170
|
hasVarDec,
|
|
175
171
|
varContext: varContextRef.current
|
|
@@ -26,7 +26,7 @@ import { warn } from '@mpxjs/utils'
|
|
|
26
26
|
import useInnerProps, { getCustomEvent } from './getInnerListeners'
|
|
27
27
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
28
28
|
import Icon from './mpx-icon'
|
|
29
|
-
import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject,
|
|
29
|
+
import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject, useTextPassThrough } from './utils'
|
|
30
30
|
import { CheckboxGroupContext, LabelContext } from './context'
|
|
31
31
|
import Portal from './mpx-portal'
|
|
32
32
|
|
|
@@ -42,7 +42,7 @@ export interface CheckboxProps extends Selection {
|
|
|
42
42
|
groupValue?: Array<string>
|
|
43
43
|
'enable-offset'?: boolean
|
|
44
44
|
'enable-var'?: boolean
|
|
45
|
-
'
|
|
45
|
+
'enable-text-pass-through'?: boolean
|
|
46
46
|
'parent-font-size'?: number
|
|
47
47
|
'parent-width'?: number
|
|
48
48
|
'parent-height'?: number
|
|
@@ -89,7 +89,7 @@ const Checkbox = forwardRef<HandlerRef<View, CheckboxProps>, CheckboxProps>(
|
|
|
89
89
|
color = '#09BB07',
|
|
90
90
|
style = {},
|
|
91
91
|
'enable-var': enableVar,
|
|
92
|
-
'
|
|
92
|
+
'enable-text-pass-through': enableTextPassThrough,
|
|
93
93
|
'parent-font-size': parentFontSize,
|
|
94
94
|
'parent-width': parentWidth,
|
|
95
95
|
'parent-height': parentHeight,
|
|
@@ -103,14 +103,12 @@ const Checkbox = forwardRef<HandlerRef<View, CheckboxProps>, CheckboxProps>(
|
|
|
103
103
|
let groupValue: { [key: string]: { checked: boolean; setValue: Dispatch<SetStateAction<boolean>> } } | undefined
|
|
104
104
|
let notifyChange: (evt: NativeSyntheticEvent<TouchEvent>) => void | undefined
|
|
105
105
|
|
|
106
|
-
const
|
|
106
|
+
const wrapperStyle = extendObject(
|
|
107
107
|
{},
|
|
108
108
|
styles.wrapper,
|
|
109
109
|
disabled ? styles.wrapperDisabled : null
|
|
110
110
|
)
|
|
111
111
|
|
|
112
|
-
const styleObj = extendObject({}, styles.container, style)
|
|
113
|
-
|
|
114
112
|
const onChange = (evt: NativeSyntheticEvent<TouchEvent>) => {
|
|
115
113
|
if (disabled) return
|
|
116
114
|
const checked = !isChecked
|
|
@@ -136,19 +134,19 @@ const Checkbox = forwardRef<HandlerRef<View, CheckboxProps>, CheckboxProps>(
|
|
|
136
134
|
varContextRef,
|
|
137
135
|
setWidth,
|
|
138
136
|
setHeight
|
|
139
|
-
} = useTransformStyle(
|
|
137
|
+
} = useTransformStyle(style, { enableVar, parentFontSize, parentWidth, parentHeight, defaultStyle: styles.container })
|
|
140
138
|
|
|
141
139
|
const nodeRef = useRef(null)
|
|
142
140
|
|
|
143
141
|
useNodesRef(props, ref, nodeRef, {
|
|
144
|
-
style:
|
|
142
|
+
style: normalStyle,
|
|
145
143
|
change: onChange
|
|
146
144
|
})
|
|
147
145
|
|
|
148
146
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef })
|
|
149
147
|
|
|
150
148
|
const { textStyle, backgroundStyle, innerStyle = {} } = splitStyle(normalStyle)
|
|
151
|
-
const textPassThrough =
|
|
149
|
+
const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough })
|
|
152
150
|
|
|
153
151
|
if (backgroundStyle) {
|
|
154
152
|
warn('Checkbox does not support background image-related styles!')
|
|
@@ -214,7 +212,7 @@ const Checkbox = forwardRef<HandlerRef<View, CheckboxProps>, CheckboxProps>(
|
|
|
214
212
|
const finalComponent = createElement(View, innerProps,
|
|
215
213
|
createElement(
|
|
216
214
|
View,
|
|
217
|
-
{ style:
|
|
215
|
+
{ style: wrapperStyle },
|
|
218
216
|
createElement(Icon, {
|
|
219
217
|
type: 'success_no_circle',
|
|
220
218
|
size: 18,
|
|
@@ -223,7 +221,7 @@ const Checkbox = forwardRef<HandlerRef<View, CheckboxProps>, CheckboxProps>(
|
|
|
223
221
|
})
|
|
224
222
|
),
|
|
225
223
|
wrapChildren(
|
|
226
|
-
props,
|
|
224
|
+
props.children,
|
|
227
225
|
{
|
|
228
226
|
hasVarDec,
|
|
229
227
|
varContext: varContextRef.current,
|
|
@@ -9,13 +9,13 @@ import { JSX, useRef, forwardRef, ReactNode, useMemo, createElement } from 'reac
|
|
|
9
9
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
10
10
|
import useInnerProps, { getCustomEvent } from './getInnerListeners'
|
|
11
11
|
import { FormContext } from './context'
|
|
12
|
-
import { useTransformStyle, splitProps, splitStyle, useLayout, wrapChildren, extendObject,
|
|
12
|
+
import { useTransformStyle, splitProps, splitStyle, useLayout, wrapChildren, extendObject, useTextPassThrough } from './utils'
|
|
13
13
|
interface FormProps {
|
|
14
14
|
style?: Record<string, any>
|
|
15
15
|
children?: ReactNode
|
|
16
16
|
'enable-offset'?: boolean
|
|
17
17
|
'enable-var'?: boolean
|
|
18
|
-
'
|
|
18
|
+
'enable-text-pass-through'?: boolean
|
|
19
19
|
'parent-font-size'?: number
|
|
20
20
|
'parent-width'?: number
|
|
21
21
|
'parent-height'?: number
|
|
@@ -32,7 +32,7 @@ const _Form = forwardRef<HandlerRef<View, FormProps>, FormProps>((fromProps: For
|
|
|
32
32
|
const {
|
|
33
33
|
style,
|
|
34
34
|
'enable-var': enableVar,
|
|
35
|
-
'
|
|
35
|
+
'enable-text-pass-through': enableTextPassThrough,
|
|
36
36
|
'parent-font-size': parentFontSize,
|
|
37
37
|
'parent-width': parentWidth,
|
|
38
38
|
'parent-height': parentHeight
|
|
@@ -45,10 +45,10 @@ const _Form = forwardRef<HandlerRef<View, FormProps>, FormProps>((fromProps: For
|
|
|
45
45
|
varContextRef,
|
|
46
46
|
setWidth,
|
|
47
47
|
setHeight
|
|
48
|
-
} = useTransformStyle(style, { enableVar,
|
|
48
|
+
} = useTransformStyle(style, { enableVar, parentFontSize, parentWidth, parentHeight })
|
|
49
49
|
|
|
50
50
|
const { textStyle, innerStyle = {} } = splitStyle(normalStyle)
|
|
51
|
-
const textPassThrough =
|
|
51
|
+
const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough })
|
|
52
52
|
|
|
53
53
|
const formRef = useRef(null)
|
|
54
54
|
useNodesRef(props, ref, formRef, {
|
|
@@ -114,7 +114,7 @@ const _Form = forwardRef<HandlerRef<View, FormProps>, FormProps>((fromProps: For
|
|
|
114
114
|
FormContext.Provider,
|
|
115
115
|
{ value: contextValue },
|
|
116
116
|
wrapChildren(
|
|
117
|
-
props,
|
|
117
|
+
props.children,
|
|
118
118
|
{
|
|
119
119
|
hasVarDec,
|
|
120
120
|
varContext: varContextRef.current,
|