@mpxjs/webpack-plugin 2.10.22 → 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/loader.js +2 -0
- package/lib/platform/style/wx/index.js +395 -104
- package/lib/react/index.js +3 -1
- package/lib/react/processTemplate.js +3 -1
- package/lib/react/style-helper.js +6 -6
- 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 -1
- 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 +36 -31
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +4 -2
- package/lib/runtime/components/react/dist/mpx-simple-view.jsx +24 -17
- 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 +44 -40
- 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 +229 -128
- 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 -69
- package/lib/runtime/components/react/dist/utils.jsx +1295 -442
- 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 +1 -3
- package/lib/runtime/components/react/mpx-canvas/utils.tsx +3 -1
- 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 +36 -38
- package/lib/runtime/components/react/mpx-simple-view.tsx +29 -17
- 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 +46 -49
- package/lib/runtime/components/react/mpx-video.tsx +3 -5
- package/lib/runtime/components/react/mpx-view.tsx +250 -141
- package/lib/runtime/components/react/mpx-web-view.tsx +8 -3
- 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 +1347 -539
- package/lib/runtime/i18n.wxs +15 -9
- package/lib/style-compiler/strip-conditional.js +19 -4
- package/lib/template-compiler/compiler.js +5 -1
- package/lib/utils/source-location.js +9 -13
- package/lib/web/index.js +3 -1
- package/lib/web/processTemplate.js +3 -1
- package/package.json +5 -4
- package/LICENSE +0 -433
|
@@ -23,11 +23,11 @@ import {
|
|
|
23
23
|
ImageLoadEventData,
|
|
24
24
|
ImageSourcePropType
|
|
25
25
|
} from 'react-native'
|
|
26
|
-
import { noop } from '@mpxjs/utils'
|
|
26
|
+
import { hasOwn, noop } from '@mpxjs/utils'
|
|
27
27
|
import { LocalSvg, SvgCssUri } from 'react-native-svg/css'
|
|
28
28
|
import useInnerProps, { getCustomEvent } from './getInnerListeners'
|
|
29
29
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
30
|
-
import {
|
|
30
|
+
import { svgRegExp, useLayout, useTransformStyle, renderImage, extendObject, isAndroid } from './utils'
|
|
31
31
|
import Portal from './mpx-portal'
|
|
32
32
|
|
|
33
33
|
export type Mode =
|
|
@@ -52,7 +52,6 @@ export interface ImageProps {
|
|
|
52
52
|
style?: ImageStyle & Record<string, any>
|
|
53
53
|
'enable-offset'?: boolean
|
|
54
54
|
'enable-var'?: boolean
|
|
55
|
-
'external-var-context'?: Record<string, any>
|
|
56
55
|
'parent-font-size'?: number
|
|
57
56
|
'parent-width'?: number
|
|
58
57
|
'parent-height'?: number
|
|
@@ -72,26 +71,46 @@ interface ImageState {
|
|
|
72
71
|
|
|
73
72
|
const DEFAULT_IMAGE_WIDTH = 320
|
|
74
73
|
const DEFAULT_IMAGE_HEIGHT = 240
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
'top left',
|
|
82
|
-
'top right',
|
|
83
|
-
'bottom left',
|
|
84
|
-
'bottom right'
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
74
|
+
const cropModeMap: Record<string, boolean> = {
|
|
75
|
+
top: true,
|
|
76
|
+
bottom: true,
|
|
77
|
+
center: true,
|
|
78
|
+
right: true,
|
|
79
|
+
left: true,
|
|
80
|
+
'top left': true,
|
|
81
|
+
'top right': true,
|
|
82
|
+
'bottom left': true,
|
|
83
|
+
'bottom right': true
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const modeResizeMap: Record<string, ImageResizeMode> = {
|
|
87
|
+
scaleToFill: 'stretch',
|
|
88
|
+
aspectFit: 'contain',
|
|
89
|
+
aspectFill: 'cover',
|
|
90
|
+
widthFix: 'stretch',
|
|
91
|
+
heightFix: 'stretch',
|
|
92
|
+
top: 'stretch',
|
|
93
|
+
bottom: 'stretch',
|
|
94
|
+
center: 'stretch',
|
|
95
|
+
right: 'stretch',
|
|
96
|
+
left: 'stretch',
|
|
97
|
+
'top left': 'stretch',
|
|
98
|
+
'top right': 'stretch',
|
|
99
|
+
'bottom left': 'stretch',
|
|
100
|
+
'bottom right': 'stretch'
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const DEFAULT_IMAGE_STYLE: ImageStyle = {
|
|
104
|
+
width: DEFAULT_IMAGE_WIDTH,
|
|
105
|
+
height: DEFAULT_IMAGE_HEIGHT
|
|
106
|
+
}
|
|
107
|
+
const OVERFLOW_HIDDEN_STYLE = { overflow: 'hidden' as const }
|
|
108
|
+
const SVG_TRANSFORM_ORIGIN_STYLE = { transformOrigin: 'left top' as const }
|
|
109
|
+
const BASE_IMAGE_FILL_STYLE: ImageStyle = {
|
|
110
|
+
transformOrigin: 'left top',
|
|
111
|
+
width: '100%',
|
|
112
|
+
height: '100%'
|
|
113
|
+
}
|
|
95
114
|
|
|
96
115
|
const isNumber = (value: DimensionValue): value is number => typeof value === 'number'
|
|
97
116
|
|
|
@@ -109,7 +128,7 @@ function getImageUri (src: string | ImageSourcePropType) {
|
|
|
109
128
|
|
|
110
129
|
function isSvgSource (src: string | ImageSourcePropType) {
|
|
111
130
|
const uri = getImageUri(src)
|
|
112
|
-
return
|
|
131
|
+
return svgRegExp.test(uri)
|
|
113
132
|
}
|
|
114
133
|
|
|
115
134
|
function getImageSize (src: string | ImageSourcePropType, success: (width: number, height: number) => void, fail: () => void = noop) {
|
|
@@ -158,7 +177,6 @@ const Image = forwardRef<HandlerRef<RNImage, ImageProps>, ImageProps>((props, re
|
|
|
158
177
|
mode = 'scaleToFill',
|
|
159
178
|
style = {},
|
|
160
179
|
'enable-var': enableVar,
|
|
161
|
-
'external-var-context': externalVarContext,
|
|
162
180
|
'parent-font-size': parentFontSize,
|
|
163
181
|
'enable-fast-image': enableFastImage,
|
|
164
182
|
'parent-width': parentWidth,
|
|
@@ -168,29 +186,17 @@ const Image = forwardRef<HandlerRef<RNImage, ImageProps>, ImageProps>((props, re
|
|
|
168
186
|
binderror
|
|
169
187
|
} = props
|
|
170
188
|
|
|
171
|
-
const
|
|
172
|
-
width: DEFAULT_IMAGE_WIDTH,
|
|
173
|
-
height: DEFAULT_IMAGE_HEIGHT
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
const styleObj = extendObject(
|
|
177
|
-
{},
|
|
178
|
-
defaultStyle,
|
|
179
|
-
style,
|
|
180
|
-
{ overflow: 'hidden' }
|
|
181
|
-
)
|
|
189
|
+
const styleObj = extendObject({}, style, OVERFLOW_HIDDEN_STYLE)
|
|
182
190
|
|
|
183
191
|
const nodeRef = useRef(null)
|
|
184
|
-
useNodesRef(props, ref, nodeRef, {
|
|
185
|
-
defaultStyle
|
|
186
|
-
})
|
|
187
192
|
|
|
188
|
-
const isSvg = isSvgProp || isSvgSource(src)
|
|
193
|
+
const isSvg = useMemo(() => isSvgProp || isSvgSource(src), [isSvgProp, src])
|
|
194
|
+
const imageSource = useMemo(() => normalizeImageSource(src), [src])
|
|
189
195
|
const isWidthFixMode = mode === 'widthFix'
|
|
190
196
|
const isHeightFixMode = mode === 'heightFix'
|
|
191
|
-
const isCropMode =
|
|
197
|
+
const isCropMode = hasOwn(cropModeMap, mode)
|
|
192
198
|
const isLayoutMode = isWidthFixMode || isHeightFixMode || isCropMode
|
|
193
|
-
const resizeMode: ImageResizeMode =
|
|
199
|
+
const resizeMode: ImageResizeMode = hasOwn(modeResizeMap, mode) ? modeResizeMap[mode] : 'stretch'
|
|
194
200
|
|
|
195
201
|
const onLayout = ({ nativeEvent: { layout: { width, height } } }: LayoutChangeEvent) => {
|
|
196
202
|
state.current.viewWidth = width
|
|
@@ -217,7 +223,12 @@ const Image = forwardRef<HandlerRef<RNImage, ImageProps>, ImageProps>((props, re
|
|
|
217
223
|
normalStyle,
|
|
218
224
|
setWidth,
|
|
219
225
|
setHeight
|
|
220
|
-
} = useTransformStyle(styleObj, { enableVar, transformRadiusPercent: isAndroid && !isSvg && !isLayoutMode,
|
|
226
|
+
} = useTransformStyle(styleObj, { enableVar, transformRadiusPercent: isAndroid && !isSvg && !isLayoutMode, parentFontSize, parentWidth, parentHeight, defaultStyle: DEFAULT_IMAGE_STYLE })
|
|
227
|
+
|
|
228
|
+
// normalStyle 已合入 DEFAULT_IMAGE_STYLE,对外暴露完整 style(含 default 兜底的 width/height)
|
|
229
|
+
useNodesRef(props, ref, nodeRef, {
|
|
230
|
+
style: normalStyle
|
|
231
|
+
})
|
|
221
232
|
|
|
222
233
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({
|
|
223
234
|
props,
|
|
@@ -225,7 +236,7 @@ const Image = forwardRef<HandlerRef<RNImage, ImageProps>, ImageProps>((props, re
|
|
|
225
236
|
setWidth,
|
|
226
237
|
setHeight,
|
|
227
238
|
nodeRef,
|
|
228
|
-
onLayout: isLayoutMode ? onLayout :
|
|
239
|
+
onLayout: isLayoutMode ? onLayout : undefined
|
|
229
240
|
})
|
|
230
241
|
|
|
231
242
|
const { width, height } = normalStyle
|
|
@@ -504,7 +515,8 @@ const Image = forwardRef<HandlerRef<RNImage, ImageProps>, ImageProps>((props, re
|
|
|
504
515
|
const svgProps = {
|
|
505
516
|
onLayout: onSvgLoad,
|
|
506
517
|
style: extendObject(
|
|
507
|
-
{
|
|
518
|
+
{},
|
|
519
|
+
SVG_TRANSFORM_ORIGIN_STYLE,
|
|
508
520
|
modeStyle
|
|
509
521
|
)
|
|
510
522
|
}
|
|
@@ -518,21 +530,20 @@ const Image = forwardRef<HandlerRef<RNImage, ImageProps>, ImageProps>((props, re
|
|
|
518
530
|
}
|
|
519
531
|
|
|
520
532
|
function renderBaseImage () {
|
|
533
|
+
const baseImageStyle = isCropMode
|
|
534
|
+
? extendObject(
|
|
535
|
+
{ transformOrigin: 'left top', width: imageWidth, height: imageHeight },
|
|
536
|
+
modeStyle
|
|
537
|
+
)
|
|
538
|
+
: BASE_IMAGE_FILL_STYLE
|
|
521
539
|
return renderImage(
|
|
522
540
|
extendObject(
|
|
523
541
|
{
|
|
524
|
-
source:
|
|
542
|
+
source: imageSource,
|
|
525
543
|
resizeMode: resizeMode,
|
|
526
544
|
onLoad: bindload && onImageLoad,
|
|
527
545
|
onError: binderror && onImageError,
|
|
528
|
-
style:
|
|
529
|
-
{
|
|
530
|
-
transformOrigin: 'left top',
|
|
531
|
-
width: isCropMode ? imageWidth : '100%',
|
|
532
|
-
height: isCropMode ? imageHeight : '100%'
|
|
533
|
-
},
|
|
534
|
-
isCropMode ? modeStyle : {}
|
|
535
|
-
)
|
|
546
|
+
style: baseImageStyle
|
|
536
547
|
},
|
|
537
548
|
isLayoutMode ? {} : innerProps
|
|
538
549
|
),
|
|
@@ -97,7 +97,6 @@ export interface InputProps {
|
|
|
97
97
|
'placeholder-style'?: { color?: string }
|
|
98
98
|
'enable-offset'?: boolean
|
|
99
99
|
'enable-var'?: boolean
|
|
100
|
-
'external-var-context'?: Record<string, any>
|
|
101
100
|
'parent-font-size'?: number
|
|
102
101
|
'parent-width'?: number
|
|
103
102
|
'parent-height'?: number
|
|
@@ -148,7 +147,6 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
148
147
|
'selection-start': selectionStart = -1,
|
|
149
148
|
'selection-end': selectionEnd = -1,
|
|
150
149
|
'enable-var': enableVar,
|
|
151
|
-
'external-var-context': externalVarContext,
|
|
152
150
|
'parent-font-size': parentFontSize,
|
|
153
151
|
'parent-width': parentWidth,
|
|
154
152
|
'parent-height': parentHeight,
|
|
@@ -212,7 +210,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
212
210
|
normalStyle,
|
|
213
211
|
setWidth,
|
|
214
212
|
setHeight
|
|
215
|
-
} = useTransformStyle(styleObj, { enableVar,
|
|
213
|
+
} = useTransformStyle(styleObj, { enableVar, parentFontSize, parentWidth, parentHeight })
|
|
216
214
|
|
|
217
215
|
const nodeRef = useRef(null)
|
|
218
216
|
useNodesRef(props, ref, nodeRef, {
|
|
@@ -6,7 +6,7 @@ import { View, ViewStyle, NativeSyntheticEvent } from 'react-native'
|
|
|
6
6
|
import { noop, warn } from '@mpxjs/utils'
|
|
7
7
|
import useInnerProps, { getCustomEvent } from './getInnerListeners'
|
|
8
8
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
9
|
-
import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject,
|
|
9
|
+
import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject, useTextPassThrough } from './utils'
|
|
10
10
|
import { LabelContext, LabelContextValue } from './context'
|
|
11
11
|
import Portal from './mpx-portal'
|
|
12
12
|
|
|
@@ -15,7 +15,7 @@ export interface LabelProps {
|
|
|
15
15
|
style?: ViewStyle & Record<string, any>
|
|
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
|
|
@@ -31,7 +31,7 @@ const Label = forwardRef<HandlerRef<View, LabelProps>, LabelProps>(
|
|
|
31
31
|
const {
|
|
32
32
|
style = {},
|
|
33
33
|
'enable-var': enableVar,
|
|
34
|
-
'
|
|
34
|
+
'enable-text-pass-through': enableTextPassThrough,
|
|
35
35
|
'parent-font-size': parentFontSize,
|
|
36
36
|
'parent-width': parentWidth,
|
|
37
37
|
'parent-height': parentHeight
|
|
@@ -43,8 +43,6 @@ const Label = forwardRef<HandlerRef<View, LabelProps>, LabelProps>(
|
|
|
43
43
|
flexDirection: 'row'
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
const styleObj = extendObject({}, defaultStyle, style)
|
|
47
|
-
|
|
48
46
|
const {
|
|
49
47
|
hasPositionFixed,
|
|
50
48
|
hasSelfPercent,
|
|
@@ -53,7 +51,7 @@ const Label = forwardRef<HandlerRef<View, LabelProps>, LabelProps>(
|
|
|
53
51
|
varContextRef,
|
|
54
52
|
setWidth,
|
|
55
53
|
setHeight
|
|
56
|
-
} = useTransformStyle(
|
|
54
|
+
} = useTransformStyle(style, { enableVar, parentFontSize, parentWidth, parentHeight, defaultStyle })
|
|
57
55
|
|
|
58
56
|
const nodeRef = useRef(null)
|
|
59
57
|
useNodesRef(props, ref, nodeRef, { style: normalStyle })
|
|
@@ -61,7 +59,7 @@ const Label = forwardRef<HandlerRef<View, LabelProps>, LabelProps>(
|
|
|
61
59
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef })
|
|
62
60
|
|
|
63
61
|
const { textStyle, backgroundStyle, innerStyle = {} } = splitStyle(normalStyle)
|
|
64
|
-
const textPassThrough =
|
|
62
|
+
const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough })
|
|
65
63
|
|
|
66
64
|
if (backgroundStyle) {
|
|
67
65
|
warn('Label does not support background image-related styles!')
|
|
@@ -100,7 +98,7 @@ const Label = forwardRef<HandlerRef<View, LabelProps>, LabelProps>(
|
|
|
100
98
|
LabelContext.Provider,
|
|
101
99
|
{ value: contextRef },
|
|
102
100
|
wrapChildren(
|
|
103
|
-
props,
|
|
101
|
+
props.children,
|
|
104
102
|
{
|
|
105
103
|
hasVarDec,
|
|
106
104
|
varContext: varContextRef.current,
|
|
@@ -17,14 +17,13 @@ interface MovableAreaProps {
|
|
|
17
17
|
height?: number
|
|
18
18
|
'enable-offset'?: boolean
|
|
19
19
|
'enable-var'?: boolean
|
|
20
|
-
'external-var-context'?: Record<string, any>
|
|
21
20
|
'parent-font-size'?: number
|
|
22
21
|
'parent-width'?: number
|
|
23
22
|
'parent-height'?: number
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
const _MovableArea = forwardRef<HandlerRef<View, MovableAreaProps>, MovableAreaProps>((props: MovableAreaProps, ref): JSX.Element => {
|
|
27
|
-
const { style = {}, 'enable-var': enableVar, '
|
|
26
|
+
const { style = {}, 'enable-var': enableVar, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props
|
|
28
27
|
|
|
29
28
|
const {
|
|
30
29
|
hasSelfPercent,
|
|
@@ -34,7 +33,7 @@ const _MovableArea = forwardRef<HandlerRef<View, MovableAreaProps>, MovableAreaP
|
|
|
34
33
|
hasPositionFixed,
|
|
35
34
|
setWidth,
|
|
36
35
|
setHeight
|
|
37
|
-
} = useTransformStyle(style, { enableVar,
|
|
36
|
+
} = useTransformStyle(style, { enableVar, parentFontSize, parentWidth, parentHeight })
|
|
38
37
|
|
|
39
38
|
const movableViewRef = useRef(null)
|
|
40
39
|
useNodesRef(props, ref, movableViewRef, {
|
|
@@ -66,7 +65,7 @@ const _MovableArea = forwardRef<HandlerRef<View, MovableAreaProps>, MovableAreaP
|
|
|
66
65
|
View,
|
|
67
66
|
innerProps,
|
|
68
67
|
wrapChildren(
|
|
69
|
-
props,
|
|
68
|
+
props.children,
|
|
70
69
|
{
|
|
71
70
|
hasVarDec,
|
|
72
71
|
varContext: varContextRef.current
|
|
@@ -22,7 +22,7 @@ import { StyleSheet, View, LayoutChangeEvent } from 'react-native'
|
|
|
22
22
|
import useInnerProps, { getCustomEvent } from './getInnerListeners'
|
|
23
23
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
24
24
|
import { MovableAreaContext } from './context'
|
|
25
|
-
import { useTransformStyle, splitProps, splitStyle,
|
|
25
|
+
import { useTransformStyle, splitProps, splitStyle, hiddenStyle, wrapChildren, GestureHandler, flatGesture, extendObject, omit, useNavigation, useRunOnJSCallback, useTextPassThrough } from './utils'
|
|
26
26
|
import { GestureDetector, Gesture, GestureTouchEvent, GestureStateChangeEvent, PanGestureHandlerEventPayload, PanGesture } from 'react-native-gesture-handler'
|
|
27
27
|
import Animated, {
|
|
28
28
|
useSharedValue,
|
|
@@ -179,7 +179,7 @@ interface MovableViewProps {
|
|
|
179
179
|
'simultaneous-handlers'?: Array<GestureHandler>
|
|
180
180
|
inertia?: boolean
|
|
181
181
|
'enable-var'?: boolean
|
|
182
|
-
'
|
|
182
|
+
'enable-text-pass-through'?: boolean
|
|
183
183
|
'parent-font-size'?: number
|
|
184
184
|
'parent-width'?: number
|
|
185
185
|
'parent-height'?: number
|
|
@@ -213,7 +213,7 @@ const _MovableView = forwardRef<HandlerRef<View, MovableViewProps>, MovableViewP
|
|
|
213
213
|
friction = 2,
|
|
214
214
|
'out-of-bounds': outOfBounds = false,
|
|
215
215
|
'enable-var': enableVar,
|
|
216
|
-
'
|
|
216
|
+
'enable-text-pass-through': enableTextPassThrough,
|
|
217
217
|
'parent-font-size': parentFontSize,
|
|
218
218
|
'parent-width': parentWidth,
|
|
219
219
|
'parent-height': parentHeight,
|
|
@@ -243,7 +243,7 @@ const _MovableView = forwardRef<HandlerRef<View, MovableViewProps>, MovableViewP
|
|
|
243
243
|
varContextRef,
|
|
244
244
|
setWidth,
|
|
245
245
|
setHeight
|
|
246
|
-
} = useTransformStyle(Object.assign({}, style, styles.container), { enableVar,
|
|
246
|
+
} = useTransformStyle(Object.assign({}, style, styles.container), { enableVar, parentFontSize, parentWidth, parentHeight })
|
|
247
247
|
|
|
248
248
|
const navigation = useNavigation()
|
|
249
249
|
|
|
@@ -251,7 +251,7 @@ const _MovableView = forwardRef<HandlerRef<View, MovableViewProps>, MovableViewP
|
|
|
251
251
|
const prevWaitForHandlersRef = useRef<Array<GestureHandler>>(waitFor || [])
|
|
252
252
|
const gestureSwitch = useRef(false)
|
|
253
253
|
const { textStyle, innerStyle } = splitStyle(normalStyle)
|
|
254
|
-
const textPassThrough =
|
|
254
|
+
const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough })
|
|
255
255
|
|
|
256
256
|
const offsetX = useSharedValue(x)
|
|
257
257
|
const offsetY = useSharedValue(y)
|
|
@@ -719,7 +719,7 @@ const _MovableView = forwardRef<HandlerRef<View, MovableViewProps>, MovableViewP
|
|
|
719
719
|
return handlers
|
|
720
720
|
}
|
|
721
721
|
|
|
722
|
-
const layoutStyle = !hasLayoutRef.current && hasSelfPercent ?
|
|
722
|
+
const layoutStyle = !hasLayoutRef.current && hasSelfPercent ? hiddenStyle : {}
|
|
723
723
|
|
|
724
724
|
// bind 相关 touch 事件直接由 gesture 触发,无须重复挂载
|
|
725
725
|
// catch 相关 touch 事件需要重写并通过 useInnerProps 注入阻止冒泡逻辑
|
|
@@ -769,7 +769,7 @@ const _MovableView = forwardRef<HandlerRef<View, MovableViewProps>, MovableViewP
|
|
|
769
769
|
Animated.View,
|
|
770
770
|
innerProps,
|
|
771
771
|
wrapChildren(
|
|
772
|
-
props,
|
|
772
|
+
props.children,
|
|
773
773
|
{
|
|
774
774
|
hasVarDec,
|
|
775
775
|
varContext: varContextRef.current,
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
wrapChildren,
|
|
10
10
|
useTransformStyle,
|
|
11
11
|
extendObject,
|
|
12
|
-
|
|
12
|
+
useTextPassThrough
|
|
13
13
|
} from '../utils'
|
|
14
14
|
import { PickerViewStyleContext } from './pickerVIewContext'
|
|
15
15
|
import Portal from '../mpx-portal'
|
|
@@ -38,7 +38,7 @@ interface PickerViewProps {
|
|
|
38
38
|
'indicator-style'?: Record<string, any>,
|
|
39
39
|
'mask-style'?: Record<string, any>,
|
|
40
40
|
'enable-var'?: boolean
|
|
41
|
-
'
|
|
41
|
+
'enable-text-pass-through'?: boolean
|
|
42
42
|
'enable-offset'?: boolean
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -75,7 +75,7 @@ const _PickerView = forwardRef<HandlerRef<View, PickerViewProps>, PickerViewProp
|
|
|
75
75
|
'indicator-style': indicatorStyle = {},
|
|
76
76
|
'mask-style': pickerMaskStyle = {},
|
|
77
77
|
'enable-var': enableVar,
|
|
78
|
-
'
|
|
78
|
+
'enable-text-pass-through': enableTextPassThrough
|
|
79
79
|
} = props
|
|
80
80
|
const { height: indicatorH, ...pickerIndicatorStyle } = indicatorStyle
|
|
81
81
|
const nodeRef = useRef(null)
|
|
@@ -92,7 +92,7 @@ const _PickerView = forwardRef<HandlerRef<View, PickerViewProps>, PickerViewProp
|
|
|
92
92
|
setWidth,
|
|
93
93
|
setHeight,
|
|
94
94
|
hasPositionFixed
|
|
95
|
-
} = useTransformStyle(style, { enableVar
|
|
95
|
+
} = useTransformStyle(style, { enableVar })
|
|
96
96
|
|
|
97
97
|
useNodesRef<View, PickerViewProps>(props, ref, nodeRef, {
|
|
98
98
|
style: normalStyle
|
|
@@ -105,7 +105,7 @@ const _PickerView = forwardRef<HandlerRef<View, PickerViewProps>, PickerViewProp
|
|
|
105
105
|
} = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: nodeRef })
|
|
106
106
|
const { textProps } = splitProps(props)
|
|
107
107
|
const { textStyle } = splitStyle(normalStyle)
|
|
108
|
-
const textPassThrough =
|
|
108
|
+
const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough })
|
|
109
109
|
|
|
110
110
|
const onSelectChange = (columnIndex: number, selectedIndex: number) => {
|
|
111
111
|
const activeValue = activeValueRef.current
|
|
@@ -189,9 +189,7 @@ const _PickerView = forwardRef<HandlerRef<View, PickerViewProps>, PickerViewProp
|
|
|
189
189
|
)
|
|
190
190
|
const realElement = React.cloneElement(child, wrappedProps)
|
|
191
191
|
return wrapChildren(
|
|
192
|
-
|
|
193
|
-
children: realElement
|
|
194
|
-
},
|
|
192
|
+
realElement,
|
|
195
193
|
{
|
|
196
194
|
hasVarDec,
|
|
197
195
|
varContext: varContextRef.current,
|
|
@@ -19,7 +19,6 @@ interface ColumnProps {
|
|
|
19
19
|
[key: string]: any
|
|
20
20
|
}
|
|
21
21
|
'enable-var'?: boolean
|
|
22
|
-
'external-var-context'?: Record<string, any>
|
|
23
22
|
wrapperStyle: {
|
|
24
23
|
height: number
|
|
25
24
|
itemHeight: number
|
|
@@ -42,8 +41,7 @@ const _PickerViewColumn = forwardRef<HandlerRef<ScrollView & View, ColumnProps>,
|
|
|
42
41
|
pickerMaskStyle,
|
|
43
42
|
pickerIndicatorStyle,
|
|
44
43
|
enableWheelAnimation = true,
|
|
45
|
-
'enable-var': enableVar
|
|
46
|
-
'external-var-context': externalVarContext
|
|
44
|
+
'enable-var': enableVar
|
|
47
45
|
} = props
|
|
48
46
|
|
|
49
47
|
const {
|
|
@@ -51,7 +49,7 @@ const _PickerViewColumn = forwardRef<HandlerRef<ScrollView & View, ColumnProps>,
|
|
|
51
49
|
hasSelfPercent,
|
|
52
50
|
setWidth,
|
|
53
51
|
setHeight
|
|
54
|
-
} = useTransformStyle(style, { enableVar
|
|
52
|
+
} = useTransformStyle(style, { enableVar })
|
|
55
53
|
const { textStyle = {} } = splitStyle(normalStyle)
|
|
56
54
|
const { textProps = {} } = splitProps(props)
|
|
57
55
|
const scrollViewRef = useAnimatedRef<Reanimated.ScrollView>()
|
|
@@ -51,7 +51,6 @@ export interface ProgressProps {
|
|
|
51
51
|
style?: ViewStyle & Record<string, any>
|
|
52
52
|
'enable-offset'?: boolean
|
|
53
53
|
'enable-var'?: boolean
|
|
54
|
-
'external-var-context'?: Record<string, any>
|
|
55
54
|
'parent-font-size'?: number
|
|
56
55
|
'parent-width'?: number
|
|
57
56
|
'parent-height'?: number
|
|
@@ -72,7 +71,6 @@ const Progress = forwardRef<
|
|
|
72
71
|
duration = 30,
|
|
73
72
|
style = {},
|
|
74
73
|
'enable-var': enableVar,
|
|
75
|
-
'external-var-context': externalVarContext,
|
|
76
74
|
'parent-font-size': parentFontSize,
|
|
77
75
|
'parent-width': parentWidth,
|
|
78
76
|
'parent-height': parentHeight
|
|
@@ -94,7 +92,6 @@ const Progress = forwardRef<
|
|
|
94
92
|
hasPositionFixed
|
|
95
93
|
} = useTransformStyle(style, {
|
|
96
94
|
enableVar,
|
|
97
|
-
externalVarContext,
|
|
98
95
|
parentFontSize,
|
|
99
96
|
parentWidth,
|
|
100
97
|
parentHeight
|
|
@@ -29,7 +29,6 @@ export interface RadioGroupProps {
|
|
|
29
29
|
style?: ViewStyle & Record<string, any>
|
|
30
30
|
'enable-offset'?: boolean
|
|
31
31
|
'enable-var'?: boolean
|
|
32
|
-
'external-var-context'?: Record<string, any>
|
|
33
32
|
'parent-font-size'?: number
|
|
34
33
|
'parent-width'?: number
|
|
35
34
|
'parent-height'?: number
|
|
@@ -44,7 +43,6 @@ const radioGroup = forwardRef<
|
|
|
44
43
|
const {
|
|
45
44
|
style = {},
|
|
46
45
|
'enable-var': enableVar,
|
|
47
|
-
'external-var-context': externalVarContext,
|
|
48
46
|
'parent-font-size': parentFontSize,
|
|
49
47
|
'parent-width': parentWidth,
|
|
50
48
|
'parent-height': parentHeight
|
|
@@ -69,8 +67,6 @@ const radioGroup = forwardRef<
|
|
|
69
67
|
flexWrap: 'wrap'
|
|
70
68
|
}
|
|
71
69
|
|
|
72
|
-
const styleObj = extendObject({}, defaultStyle, style)
|
|
73
|
-
|
|
74
70
|
const {
|
|
75
71
|
hasPositionFixed,
|
|
76
72
|
hasSelfPercent,
|
|
@@ -79,7 +75,7 @@ const radioGroup = forwardRef<
|
|
|
79
75
|
varContextRef,
|
|
80
76
|
setWidth,
|
|
81
77
|
setHeight
|
|
82
|
-
} = useTransformStyle(
|
|
78
|
+
} = useTransformStyle(style, { enableVar, parentFontSize, parentWidth, parentHeight, defaultStyle })
|
|
83
79
|
|
|
84
80
|
const nodeRef = useRef(null)
|
|
85
81
|
useNodesRef(props, ref, nodeRef, { style: normalStyle })
|
|
@@ -168,7 +164,7 @@ const radioGroup = forwardRef<
|
|
|
168
164
|
value: contextValue
|
|
169
165
|
},
|
|
170
166
|
wrapChildren(
|
|
171
|
-
props,
|
|
167
|
+
props.children,
|
|
172
168
|
{
|
|
173
169
|
hasVarDec,
|
|
174
170
|
varContext: varContextRef.current
|
|
@@ -10,7 +10,7 @@ import { warn } from '@mpxjs/utils'
|
|
|
10
10
|
import { LabelContext, RadioGroupContext } from './context'
|
|
11
11
|
import useInnerProps, { getCustomEvent } from './getInnerListeners'
|
|
12
12
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
13
|
-
import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject,
|
|
13
|
+
import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject, useTextPassThrough } from './utils'
|
|
14
14
|
import Icon from './mpx-icon'
|
|
15
15
|
import Portal from './mpx-portal'
|
|
16
16
|
|
|
@@ -22,7 +22,7 @@ export interface RadioProps {
|
|
|
22
22
|
style?: ViewStyle & Record<string, any>
|
|
23
23
|
'enable-offset'?: boolean
|
|
24
24
|
'enable-var'?: boolean
|
|
25
|
-
'
|
|
25
|
+
'enable-text-pass-through'?: boolean
|
|
26
26
|
'parent-font-size'?: number
|
|
27
27
|
'parent-width'?: number
|
|
28
28
|
'parent-height'?: number
|
|
@@ -75,7 +75,7 @@ const Radio = forwardRef<HandlerRef<View, RadioProps>, RadioProps>(
|
|
|
75
75
|
color = '#09BB07',
|
|
76
76
|
style = [],
|
|
77
77
|
'enable-var': enableVar,
|
|
78
|
-
'
|
|
78
|
+
'enable-text-pass-through': enableTextPassThrough,
|
|
79
79
|
'parent-font-size': parentFontSize,
|
|
80
80
|
'parent-width': parentWidth,
|
|
81
81
|
'parent-height': parentHeight,
|
|
@@ -90,15 +90,13 @@ const Radio = forwardRef<HandlerRef<View, RadioProps>, RadioProps>(
|
|
|
90
90
|
|
|
91
91
|
const labelContext = useContext(LabelContext)
|
|
92
92
|
|
|
93
|
-
const
|
|
93
|
+
const wrapperStyle = extendObject(
|
|
94
94
|
{},
|
|
95
95
|
styles.wrapper,
|
|
96
96
|
isChecked ? styles.wrapperChecked : {},
|
|
97
97
|
disabled ? styles.wrapperDisabled : {}
|
|
98
98
|
)
|
|
99
99
|
|
|
100
|
-
const styleObj = extendObject({}, styles.container, style)
|
|
101
|
-
|
|
102
100
|
const onChange = (evt: NativeSyntheticEvent<TouchEvent>) => {
|
|
103
101
|
if (disabled || isChecked) return
|
|
104
102
|
setIsChecked(!isChecked)
|
|
@@ -125,10 +123,10 @@ const Radio = forwardRef<HandlerRef<View, RadioProps>, RadioProps>(
|
|
|
125
123
|
varContextRef,
|
|
126
124
|
setWidth,
|
|
127
125
|
setHeight
|
|
128
|
-
} = useTransformStyle(
|
|
126
|
+
} = useTransformStyle(style, { enableVar, parentFontSize, parentWidth, parentHeight, defaultStyle: styles.container })
|
|
129
127
|
|
|
130
128
|
const { textStyle, backgroundStyle, innerStyle = {} } = splitStyle(normalStyle)
|
|
131
|
-
const textPassThrough =
|
|
129
|
+
const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough })
|
|
132
130
|
|
|
133
131
|
if (backgroundStyle) {
|
|
134
132
|
warn('Radio does not support background image-related styles!')
|
|
@@ -136,7 +134,7 @@ const Radio = forwardRef<HandlerRef<View, RadioProps>, RadioProps>(
|
|
|
136
134
|
|
|
137
135
|
const nodeRef = useRef(null)
|
|
138
136
|
useNodesRef(props, ref, nodeRef, {
|
|
139
|
-
style:
|
|
137
|
+
style: normalStyle,
|
|
140
138
|
change: onChange
|
|
141
139
|
})
|
|
142
140
|
|
|
@@ -199,7 +197,7 @@ const Radio = forwardRef<HandlerRef<View, RadioProps>, RadioProps>(
|
|
|
199
197
|
const finalComponent = createElement(View, innerProps,
|
|
200
198
|
createElement(
|
|
201
199
|
View,
|
|
202
|
-
{ style:
|
|
200
|
+
{ style: wrapperStyle },
|
|
203
201
|
createElement(Icon, {
|
|
204
202
|
type: 'success',
|
|
205
203
|
size: 24,
|
|
@@ -208,7 +206,7 @@ const Radio = forwardRef<HandlerRef<View, RadioProps>, RadioProps>(
|
|
|
208
206
|
})
|
|
209
207
|
),
|
|
210
208
|
wrapChildren(
|
|
211
|
-
props,
|
|
209
|
+
props.children,
|
|
212
210
|
{
|
|
213
211
|
hasVarDec,
|
|
214
212
|
varContext: varContextRef.current,
|
|
@@ -23,7 +23,6 @@ interface _RichTextProps extends ViewProps {
|
|
|
23
23
|
style?: ViewStyle
|
|
24
24
|
nodes: string | Array<Node>
|
|
25
25
|
'enable-var'?: boolean
|
|
26
|
-
'external-var-context'?: Record<string, any>
|
|
27
26
|
'parent-font-size'?: number
|
|
28
27
|
'parent-width'?: number
|
|
29
28
|
'parent-height'?: number
|
|
@@ -57,7 +56,6 @@ const _RichText = forwardRef<HandlerRef<View, _RichTextProps>, _RichTextProps>((
|
|
|
57
56
|
style = {},
|
|
58
57
|
nodes,
|
|
59
58
|
'enable-var': enableVar,
|
|
60
|
-
'external-var-context': externalVarContext,
|
|
61
59
|
'parent-font-size': parentFontSize,
|
|
62
60
|
'parent-width': parentWidth,
|
|
63
61
|
'parent-height': parentHeight
|
|
@@ -77,7 +75,6 @@ const _RichText = forwardRef<HandlerRef<View, _RichTextProps>, _RichTextProps>((
|
|
|
77
75
|
height: webViewHeight
|
|
78
76
|
}, style), {
|
|
79
77
|
enableVar,
|
|
80
|
-
externalVarContext,
|
|
81
78
|
parentFontSize,
|
|
82
79
|
parentWidth,
|
|
83
80
|
parentHeight
|