@mpxjs/webpack-plugin 2.9.59 → 2.9.62
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/platform/style/wx/index.js +314 -254
- package/lib/platform/template/wx/component-config/checkbox-group.js +8 -0
- package/lib/platform/template/wx/component-config/checkbox.js +8 -0
- package/lib/platform/template/wx/component-config/cover-image.js +15 -0
- package/lib/platform/template/wx/component-config/cover-view.js +9 -0
- package/lib/platform/template/wx/component-config/form.js +13 -1
- package/lib/platform/template/wx/component-config/icon.js +8 -0
- package/lib/platform/template/wx/component-config/index.js +5 -1
- package/lib/platform/template/wx/component-config/label.js +15 -0
- package/lib/platform/template/wx/component-config/movable-area.js +18 -1
- package/lib/platform/template/wx/component-config/movable-view.js +18 -1
- package/lib/platform/template/wx/component-config/navigator.js +8 -0
- package/lib/platform/template/wx/component-config/picker-view-column.js +8 -0
- package/lib/platform/template/wx/component-config/picker-view.js +18 -2
- package/lib/platform/template/wx/component-config/picker.js +14 -1
- package/lib/platform/template/wx/component-config/radio-group.js +8 -0
- package/lib/platform/template/wx/component-config/radio.js +8 -0
- package/lib/platform/template/wx/component-config/root-portal.js +15 -0
- package/lib/platform/template/wx/component-config/switch.js +8 -0
- package/lib/platform/template/wx/component-config/unsupported.js +1 -3
- package/lib/react/processScript.js +2 -0
- package/lib/runtime/components/react/context.ts +38 -0
- package/lib/runtime/components/react/dist/context.js +7 -0
- package/lib/runtime/components/react/dist/getInnerListeners.js +22 -11
- package/lib/runtime/components/react/dist/mpx-button.jsx +67 -45
- package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +81 -0
- package/lib/runtime/components/react/dist/mpx-checkbox.jsx +152 -0
- package/lib/runtime/components/react/dist/mpx-form.jsx +59 -0
- package/lib/runtime/components/react/dist/mpx-icon.jsx +51 -0
- package/lib/runtime/components/react/dist/mpx-image/index.jsx +17 -22
- package/lib/runtime/components/react/dist/mpx-image/svg.jsx +0 -1
- package/lib/runtime/components/react/dist/mpx-input.jsx +38 -16
- package/lib/runtime/components/react/dist/mpx-label.jsx +63 -0
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +46 -0
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +346 -0
- package/lib/runtime/components/react/dist/mpx-navigator.jsx +35 -0
- package/lib/runtime/components/react/dist/mpx-picker/date.jsx +69 -0
- package/lib/runtime/components/react/dist/mpx-picker/index.jsx +138 -0
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +139 -0
- package/lib/runtime/components/react/dist/mpx-picker/region.jsx +90 -0
- package/lib/runtime/components/react/dist/mpx-picker/regionData.js +6099 -0
- package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +76 -0
- package/lib/runtime/components/react/dist/mpx-picker/time.jsx +244 -0
- package/lib/runtime/components/react/dist/mpx-picker/type.js +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +15 -0
- package/lib/runtime/components/react/dist/mpx-picker-view.jsx +68 -0
- package/lib/runtime/components/react/dist/mpx-radio-group.jsx +79 -0
- package/lib/runtime/components/react/dist/mpx-radio.jsx +169 -0
- package/lib/runtime/components/react/dist/mpx-root-portal.jsx +11 -0
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +66 -50
- package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +206 -147
- package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +9 -7
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +3 -3
- package/lib/runtime/components/react/dist/mpx-switch.jsx +76 -0
- package/lib/runtime/components/react/dist/mpx-text.jsx +7 -19
- package/lib/runtime/components/react/dist/mpx-textarea.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-view.jsx +326 -96
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +9 -15
- package/lib/runtime/components/react/dist/types/common.js +1 -0
- package/lib/runtime/components/react/dist/useNodesRef.js +3 -8
- package/lib/runtime/components/react/dist/utils.js +82 -14
- package/lib/runtime/components/react/getInnerListeners.ts +25 -13
- package/lib/runtime/components/react/mpx-button.tsx +87 -67
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +147 -0
- package/lib/runtime/components/react/mpx-checkbox.tsx +245 -0
- package/lib/runtime/components/react/mpx-form.tsx +89 -0
- package/lib/runtime/components/react/mpx-icon.tsx +103 -0
- package/lib/runtime/components/react/mpx-image/index.tsx +20 -32
- package/lib/runtime/components/react/mpx-image/svg.tsx +2 -2
- package/lib/runtime/components/react/mpx-input.tsx +54 -26
- package/lib/runtime/components/react/mpx-label.tsx +115 -0
- package/lib/runtime/components/react/mpx-movable-area.tsx +67 -0
- package/lib/runtime/components/react/mpx-movable-view.tsx +425 -0
- package/lib/runtime/components/react/mpx-navigator.tsx +67 -0
- package/lib/runtime/components/react/mpx-picker/date.tsx +83 -0
- package/lib/runtime/components/react/mpx-picker/index.tsx +155 -0
- package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +153 -0
- package/lib/runtime/components/react/mpx-picker/region.tsx +104 -0
- package/lib/runtime/components/react/mpx-picker/regionData.ts +6101 -0
- package/lib/runtime/components/react/mpx-picker/selector.tsx +92 -0
- package/lib/runtime/components/react/mpx-picker/time.tsx +274 -0
- package/lib/runtime/components/react/mpx-picker/type.ts +107 -0
- package/lib/runtime/components/react/mpx-picker-view-column.tsx +28 -0
- package/lib/runtime/components/react/mpx-picker-view.tsx +104 -0
- package/lib/runtime/components/react/mpx-radio-group.tsx +147 -0
- package/lib/runtime/components/react/mpx-radio.tsx +246 -0
- package/lib/runtime/components/react/mpx-root-portal.tsx +25 -0
- package/lib/runtime/components/react/mpx-scroll-view.tsx +82 -58
- package/lib/runtime/components/react/mpx-swiper/carouse.tsx +203 -156
- package/lib/runtime/components/react/mpx-swiper/index.tsx +12 -13
- package/lib/runtime/components/react/mpx-swiper/type.ts +11 -4
- package/lib/runtime/components/react/mpx-swiper-item.tsx +5 -3
- package/lib/runtime/components/react/mpx-switch.tsx +127 -0
- package/lib/runtime/components/react/mpx-text.tsx +52 -68
- package/lib/runtime/components/react/mpx-textarea.tsx +2 -2
- package/lib/runtime/components/react/mpx-view.tsx +373 -140
- package/lib/runtime/components/react/mpx-web-view.tsx +24 -28
- package/lib/runtime/components/react/types/common.ts +12 -0
- package/lib/runtime/components/react/types/getInnerListeners.ts +2 -1
- package/lib/runtime/components/react/types/global.d.ts +4 -0
- package/lib/runtime/components/react/useNodesRef.ts +3 -8
- package/lib/runtime/components/react/utils.ts +93 -15
- package/lib/runtime/optionProcessor.js +19 -17
- package/lib/template-compiler/compiler.js +56 -41
- package/lib/template-compiler/gen-node-react.js +7 -7
- package/package.json +6 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { JSX } from 'react'
|
|
2
2
|
import type { ImageSourcePropType, ImageStyle, StyleProp } from 'react-native'
|
|
3
3
|
import { SvgCssUri, WithLocalSvg } from 'react-native-svg/css'
|
|
4
4
|
interface SvgProps {
|
|
@@ -9,7 +9,7 @@ interface SvgProps {
|
|
|
9
9
|
height?: string | number
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
const Svg = ({ local = false, src, style, width, height }: SvgProps):
|
|
12
|
+
const Svg = ({ local = false, src, style, width, height }: SvgProps): JSX.Element => {
|
|
13
13
|
return local ? (
|
|
14
14
|
<WithLocalSvg style={style} asset={src as ImageSourcePropType} width={width} height={height} />
|
|
15
15
|
) : (
|
|
@@ -37,11 +37,10 @@
|
|
|
37
37
|
* ✘ bind:keyboardcompositionend
|
|
38
38
|
* ✘ bind:onkeyboardheightchange
|
|
39
39
|
*/
|
|
40
|
-
import
|
|
40
|
+
import { JSX, forwardRef, useMemo, useRef, useState, useContext, useEffect } from 'react'
|
|
41
41
|
import {
|
|
42
42
|
KeyboardTypeOptions,
|
|
43
43
|
Platform,
|
|
44
|
-
StyleProp,
|
|
45
44
|
TextInput,
|
|
46
45
|
TextStyle,
|
|
47
46
|
ViewStyle,
|
|
@@ -55,9 +54,10 @@ import {
|
|
|
55
54
|
TextInputChangeEventData,
|
|
56
55
|
TextInputSubmitEditingEventData
|
|
57
56
|
} from 'react-native'
|
|
58
|
-
import { parseInlineStyle, useUpdateEffect } from './utils'
|
|
57
|
+
import { parseInlineStyle, useUpdateEffect, throwReactWarning } from './utils'
|
|
59
58
|
import useInnerProps, { getCustomEvent } from './getInnerListeners'
|
|
60
59
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
60
|
+
import { FormContext, FormFieldValue } from './context'
|
|
61
61
|
|
|
62
62
|
type InputStyle = Omit<
|
|
63
63
|
TextStyle & ViewStyle & Pick<FlexStyle, 'minHeight'>,
|
|
@@ -73,7 +73,8 @@ type InputStyle = Omit<
|
|
|
73
73
|
|
|
74
74
|
type Type = 'text' | 'number' | 'idcard' | 'digit'
|
|
75
75
|
export interface InputProps {
|
|
76
|
-
|
|
76
|
+
name?: string
|
|
77
|
+
style?: InputStyle & Record<string, any>
|
|
77
78
|
value?: string
|
|
78
79
|
type?: Type
|
|
79
80
|
password?: boolean
|
|
@@ -116,9 +117,9 @@ const keyboardTypeMap: Record<Type, string> = {
|
|
|
116
117
|
}) || '',
|
|
117
118
|
}
|
|
118
119
|
|
|
119
|
-
const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps>((props: FinalInputProps, ref):
|
|
120
|
+
const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps>((props: FinalInputProps, ref): JSX.Element => {
|
|
120
121
|
const {
|
|
121
|
-
style =
|
|
122
|
+
style = {},
|
|
122
123
|
type = 'text',
|
|
123
124
|
value,
|
|
124
125
|
password,
|
|
@@ -145,6 +146,14 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
145
146
|
bindlinechange,
|
|
146
147
|
} = props
|
|
147
148
|
|
|
149
|
+
const formContext = useContext(FormContext)
|
|
150
|
+
|
|
151
|
+
let formValuesMap: Map<string, FormFieldValue> | undefined
|
|
152
|
+
|
|
153
|
+
if (formContext) {
|
|
154
|
+
formValuesMap = formContext.formValuesMap
|
|
155
|
+
}
|
|
156
|
+
|
|
148
157
|
const { nodeRef } = useNodesRef(props, ref)
|
|
149
158
|
|
|
150
159
|
const keyboardType = keyboardTypeMap[type]
|
|
@@ -157,9 +166,15 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
157
166
|
const cursorIndex = useRef<number>(0)
|
|
158
167
|
const lineCount = useRef<number>(0)
|
|
159
168
|
|
|
160
|
-
const [inputValue, setInputValue] = useState()
|
|
169
|
+
const [inputValue, setInputValue] = useState(defaultValue)
|
|
161
170
|
const [contentHeight, setContentHeight] = useState(0)
|
|
162
171
|
|
|
172
|
+
useEffect(() => {
|
|
173
|
+
if (inputValue !== value) {
|
|
174
|
+
setInputValue(value)
|
|
175
|
+
}
|
|
176
|
+
}, [value])
|
|
177
|
+
|
|
163
178
|
const selection = useMemo(() => {
|
|
164
179
|
if (selectionStart >= 0 && selectionEnd >= 0) {
|
|
165
180
|
return { start: selectionStart, end: selectionEnd }
|
|
@@ -197,8 +212,8 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
197
212
|
if (typeof result === 'string') {
|
|
198
213
|
tmpValue.current = result
|
|
199
214
|
setInputValue(result)
|
|
200
|
-
} else
|
|
201
|
-
setInputValue(
|
|
215
|
+
} else {
|
|
216
|
+
setInputValue(tmpValue.current)
|
|
202
217
|
}
|
|
203
218
|
}
|
|
204
219
|
|
|
@@ -323,6 +338,22 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
323
338
|
})
|
|
324
339
|
}
|
|
325
340
|
|
|
341
|
+
const resetValue = () => {
|
|
342
|
+
setInputValue('')
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const getValue = () => {
|
|
346
|
+
return inputValue
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
if (formValuesMap) {
|
|
350
|
+
if (!props.name) {
|
|
351
|
+
throwReactWarning('[Mpx runtime warn]: If a form component is used, the name attribute is required.')
|
|
352
|
+
} else {
|
|
353
|
+
formValuesMap.set(props.name, { getValue, resetValue })
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
326
357
|
useUpdateEffect(() => {
|
|
327
358
|
if (!nodeRef?.current) {
|
|
328
359
|
return
|
|
@@ -336,13 +367,12 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
336
367
|
ref: nodeRef,
|
|
337
368
|
...(enableOffset ? { onLayout } : {}),
|
|
338
369
|
},
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
370
|
+
[
|
|
371
|
+
'enable-offset'
|
|
372
|
+
],
|
|
373
|
+
{
|
|
374
|
+
layoutRef
|
|
375
|
+
})
|
|
346
376
|
|
|
347
377
|
return (
|
|
348
378
|
<TextInput
|
|
@@ -370,16 +400,14 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
370
400
|
onSubmitEditing={onSubmitEditing}
|
|
371
401
|
onContentSizeChange={onContentSizeChange}
|
|
372
402
|
onSelectionChange={onSelectionChange}
|
|
373
|
-
style={
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
},
|
|
382
|
-
]}
|
|
403
|
+
style={{
|
|
404
|
+
padding: 0,
|
|
405
|
+
...style,
|
|
406
|
+
...multiline && autoHeight && {
|
|
407
|
+
height: Math.max((style as any)?.minHeight || 35, contentHeight)
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
383
411
|
/>
|
|
384
412
|
)
|
|
385
413
|
})
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ✘ for
|
|
3
|
+
*/
|
|
4
|
+
import { JSX, useRef, forwardRef, ReactNode } from 'react'
|
|
5
|
+
import {
|
|
6
|
+
View,
|
|
7
|
+
Text,
|
|
8
|
+
ViewStyle,
|
|
9
|
+
NativeSyntheticEvent,
|
|
10
|
+
TextStyle,
|
|
11
|
+
} from 'react-native'
|
|
12
|
+
import useInnerProps, { getCustomEvent } from './getInnerListeners'
|
|
13
|
+
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
14
|
+
import { every, splitStyle, splitProps, isText, throwReactWarning } from './utils'
|
|
15
|
+
import { LabelContext, LabelContextValue } from './context'
|
|
16
|
+
|
|
17
|
+
export interface LabelProps {
|
|
18
|
+
for?: string
|
|
19
|
+
style?: ViewStyle & Record<string, any>
|
|
20
|
+
'enable-offset'?: boolean
|
|
21
|
+
children: ReactNode
|
|
22
|
+
bindtap?: (evt: NativeSyntheticEvent<TouchEvent> | unknown) => void
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const Label = forwardRef<HandlerRef<View, LabelProps>, LabelProps>(
|
|
26
|
+
(props, ref): JSX.Element => {
|
|
27
|
+
const {
|
|
28
|
+
style = {},
|
|
29
|
+
'enable-offset': enableOffset,
|
|
30
|
+
children,
|
|
31
|
+
bindtap
|
|
32
|
+
} = props
|
|
33
|
+
|
|
34
|
+
const { textStyle, imageStyle, innerStyle } = splitStyle(style)
|
|
35
|
+
|
|
36
|
+
if (imageStyle) {
|
|
37
|
+
throwReactWarning('[Mpx runtime warn]: Label does not support background image-related styles!')
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const defaultStyle = {
|
|
41
|
+
flexDirection: 'row',
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const contextRef: LabelContextValue = useRef({
|
|
45
|
+
triggerChange: () => { }
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
const layoutRef = useRef({})
|
|
49
|
+
|
|
50
|
+
const { nodeRef } = useNodesRef(props, ref, {
|
|
51
|
+
defaultStyle
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const onLayout = () => {
|
|
55
|
+
nodeRef.current?.measure(
|
|
56
|
+
(
|
|
57
|
+
x: number,
|
|
58
|
+
y: number,
|
|
59
|
+
width: number,
|
|
60
|
+
height: number,
|
|
61
|
+
offsetLeft: number,
|
|
62
|
+
offsetTop: number
|
|
63
|
+
) => {
|
|
64
|
+
layoutRef.current = { x, y, width, height, offsetLeft, offsetTop }
|
|
65
|
+
}
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const onTap = (evt: NativeSyntheticEvent<TouchEvent>) => {
|
|
70
|
+
bindtap && bindtap(getCustomEvent('tap', evt, { layoutRef }, props))
|
|
71
|
+
contextRef.current.triggerChange?.(evt)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const wrapChildren = (
|
|
75
|
+
children: ReactNode,
|
|
76
|
+
textStyle?: TextStyle
|
|
77
|
+
) => {
|
|
78
|
+
const { textProps } = splitProps(props)
|
|
79
|
+
|
|
80
|
+
if (every(children, (child) => isText(child))) {
|
|
81
|
+
if (textStyle || textProps) {
|
|
82
|
+
children = <Text key='labelTextWrap' style={textStyle || {}} {...(textProps || {})}>{children}</Text>
|
|
83
|
+
}
|
|
84
|
+
} else {
|
|
85
|
+
if (textStyle) throwReactWarning('[Mpx runtime warn]: Text style will be ignored unless every child of the Label is Text node!')
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return children
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const innerProps = useInnerProps(
|
|
92
|
+
props,
|
|
93
|
+
{
|
|
94
|
+
ref: nodeRef,
|
|
95
|
+
style: { ...defaultStyle, ...innerStyle },
|
|
96
|
+
bindtap: onTap,
|
|
97
|
+
...(enableOffset ? { onLayout } : {})
|
|
98
|
+
},
|
|
99
|
+
['enable-offset'],
|
|
100
|
+
{
|
|
101
|
+
layoutRef
|
|
102
|
+
}
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
return <View {...innerProps}>
|
|
106
|
+
<LabelContext.Provider value={contextRef}>
|
|
107
|
+
{wrapChildren(children, textStyle)}
|
|
108
|
+
</LabelContext.Provider>
|
|
109
|
+
</View>
|
|
110
|
+
}
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
Label.displayName = 'mpx-label'
|
|
114
|
+
|
|
115
|
+
export default Label
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ✘ scale-area
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { View, LayoutChangeEvent } from 'react-native'
|
|
6
|
+
import { JSX, useState, useEffect, useRef, forwardRef, ReactNode } from 'react'
|
|
7
|
+
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
8
|
+
import useInnerProps from './getInnerListeners'
|
|
9
|
+
import { MovableAreaContext } from './context'
|
|
10
|
+
|
|
11
|
+
interface MovableAreaProps {
|
|
12
|
+
style?: Record<string, any>;
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
width?: number;
|
|
15
|
+
height?: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const _MovableArea = forwardRef<HandlerRef<View, MovableAreaProps>, MovableAreaProps>((props: MovableAreaProps, ref): JSX.Element => {
|
|
19
|
+
const { children, style = {}, width = 10, height = 10 } = props;
|
|
20
|
+
const [areaWidth, setAreaWidth] = useState(0);
|
|
21
|
+
const [areaHeight, setAreaHeight] = useState(0);
|
|
22
|
+
|
|
23
|
+
const layoutRef = useRef<any>({})
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
setAreaWidth(width)
|
|
27
|
+
setAreaHeight(height)
|
|
28
|
+
}, [width, height])
|
|
29
|
+
|
|
30
|
+
const { nodeRef: movableViewRef } = useNodesRef(props, ref)
|
|
31
|
+
|
|
32
|
+
const onLayout = (e: LayoutChangeEvent) => {
|
|
33
|
+
const { width = 10, height = 10 } = e.nativeEvent.layout
|
|
34
|
+
setAreaWidth(width)
|
|
35
|
+
setAreaHeight(height)
|
|
36
|
+
movableViewRef.current?.measure((x: number, y: number, width: number, height: number, offsetLeft: number, offsetTop: number) => {
|
|
37
|
+
layoutRef.current = { x, y, width, height, offsetLeft, offsetTop }
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
const innerProps = useInnerProps(props, {
|
|
41
|
+
ref: movableViewRef,
|
|
42
|
+
onLayout
|
|
43
|
+
}, [
|
|
44
|
+
'children',
|
|
45
|
+
'style',
|
|
46
|
+
], { layoutRef })
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<MovableAreaContext.Provider value={{ height: areaHeight, width: areaWidth }}>
|
|
50
|
+
<View
|
|
51
|
+
{...innerProps}
|
|
52
|
+
style={{
|
|
53
|
+
height: areaHeight,
|
|
54
|
+
width: areaWidth,
|
|
55
|
+
overflow: 'hidden',
|
|
56
|
+
...style
|
|
57
|
+
}}
|
|
58
|
+
>
|
|
59
|
+
{children}
|
|
60
|
+
</View>
|
|
61
|
+
</MovableAreaContext.Provider>
|
|
62
|
+
);
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
_MovableArea.displayName = 'mpx-movable-area';
|
|
66
|
+
|
|
67
|
+
export default _MovableArea
|