@mpxjs/webpack-plugin 2.9.69 → 2.9.70
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/parser.js +1 -1
- package/lib/platform/json/wx/index.js +21 -8
- package/lib/platform/style/wx/index.js +51 -54
- package/lib/platform/template/wx/component-config/fix-component-name.js +15 -12
- package/lib/platform/template/wx/component-config/index.js +1 -1
- package/lib/platform/template/wx/component-config/input.js +1 -1
- package/lib/platform/template/wx/component-config/rich-text.js +8 -0
- package/lib/platform/template/wx/component-config/swiper.js +1 -1
- package/lib/platform/template/wx/component-config/textarea.js +1 -1
- package/lib/platform/template/wx/component-config/unsupported.js +1 -1
- package/lib/react/processTemplate.js +3 -0
- package/lib/runtime/components/react/context.ts +4 -0
- package/lib/runtime/components/react/dist/context.js +1 -0
- package/lib/runtime/components/react/dist/event.config.js +24 -24
- package/lib/runtime/components/react/dist/getInnerListeners.js +183 -166
- package/lib/runtime/components/react/dist/mpx-button.jsx +35 -42
- package/lib/runtime/components/react/dist/mpx-canvas/html.js +2 -4
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +35 -13
- package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +13 -19
- package/lib/runtime/components/react/dist/mpx-checkbox.jsx +29 -38
- package/lib/runtime/components/react/dist/mpx-form.jsx +16 -19
- package/lib/runtime/components/react/dist/mpx-icon.jsx +8 -16
- package/lib/runtime/components/react/dist/mpx-image.jsx +291 -0
- package/lib/runtime/components/react/dist/mpx-input.jsx +54 -27
- package/lib/runtime/components/react/dist/mpx-label.jsx +15 -22
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +13 -16
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +13 -13
- package/lib/runtime/components/react/dist/mpx-navigator.jsx +2 -4
- package/lib/runtime/components/react/dist/mpx-picker/date.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/index.jsx +5 -3
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/region.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/time.jsx +10 -15
- package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +3 -1
- package/lib/runtime/components/react/dist/mpx-picker-view.jsx +5 -3
- package/lib/runtime/components/react/dist/mpx-radio-group.jsx +11 -19
- package/lib/runtime/components/react/dist/mpx-radio.jsx +27 -42
- package/lib/runtime/components/react/dist/mpx-rich-text/html.js +39 -0
- package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +63 -0
- package/lib/runtime/components/react/dist/mpx-root-portal.jsx +6 -4
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +47 -41
- package/lib/runtime/components/react/dist/mpx-simple-text.jsx +11 -0
- package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +4 -2
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +4 -2
- package/lib/runtime/components/react/dist/mpx-switch.jsx +20 -10
- package/lib/runtime/components/react/dist/mpx-text.jsx +11 -10
- package/lib/runtime/components/react/dist/mpx-textarea.jsx +8 -3
- package/lib/runtime/components/react/dist/mpx-view.jsx +34 -46
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +105 -42
- package/lib/runtime/components/react/dist/useAnimationHooks.js +35 -10
- package/lib/runtime/components/react/dist/utils.jsx +107 -82
- package/lib/runtime/components/react/event.config.ts +25 -26
- package/lib/runtime/components/react/getInnerListeners.ts +238 -188
- package/lib/runtime/components/react/mpx-button.tsx +64 -50
- package/lib/runtime/components/react/mpx-canvas/html.ts +2 -4
- package/lib/runtime/components/react/mpx-canvas/index.tsx +46 -48
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +28 -25
- package/lib/runtime/components/react/mpx-checkbox.tsx +48 -49
- package/lib/runtime/components/react/mpx-form.tsx +25 -28
- package/lib/runtime/components/react/mpx-icon.tsx +12 -17
- package/lib/runtime/components/react/mpx-image.tsx +436 -0
- package/lib/runtime/components/react/mpx-input.tsx +77 -57
- package/lib/runtime/components/react/mpx-label.tsx +26 -27
- package/lib/runtime/components/react/mpx-movable-area.tsx +18 -23
- package/lib/runtime/components/react/mpx-movable-view.tsx +21 -25
- package/lib/runtime/components/react/mpx-navigator.tsx +2 -8
- package/lib/runtime/components/react/mpx-picker/date.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/index.tsx +3 -2
- package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/region.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/selector.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/time.tsx +10 -15
- package/lib/runtime/components/react/mpx-picker/type.ts +48 -43
- package/lib/runtime/components/react/mpx-picker-view-column.tsx +4 -1
- package/lib/runtime/components/react/mpx-picker-view.tsx +7 -1
- package/lib/runtime/components/react/mpx-radio-group.tsx +24 -27
- package/lib/runtime/components/react/mpx-radio.tsx +45 -54
- package/lib/runtime/components/react/mpx-rich-text/html.ts +40 -0
- package/lib/runtime/components/react/mpx-rich-text/index.tsx +121 -0
- package/lib/runtime/components/react/mpx-root-portal.tsx +3 -5
- package/lib/runtime/components/react/mpx-scroll-view.tsx +72 -71
- package/lib/runtime/components/react/mpx-simple-text.tsx +18 -0
- package/lib/runtime/components/react/mpx-swiper/carouse.tsx +4 -2
- package/lib/runtime/components/react/mpx-swiper-item.tsx +3 -2
- package/lib/runtime/components/react/mpx-switch.tsx +29 -23
- package/lib/runtime/components/react/mpx-text.tsx +14 -18
- package/lib/runtime/components/react/mpx-textarea.tsx +11 -10
- package/lib/runtime/components/react/mpx-view.tsx +55 -65
- package/lib/runtime/components/react/mpx-web-view.tsx +108 -63
- package/lib/runtime/components/react/types/global.d.ts +3 -17
- package/lib/runtime/components/react/useAnimationHooks.ts +36 -12
- package/lib/runtime/components/react/utils.tsx +113 -82
- package/lib/runtime/components/web/getInnerListeners.js +6 -6
- package/lib/runtime/components/web/mpx-movable-view.vue +334 -344
- package/lib/runtime/components/web/mpx-picker-view-column.vue +75 -75
- package/lib/runtime/components/web/mpx-picker.vue +382 -385
- package/lib/runtime/components/web/mpx-web-view.vue +175 -161
- package/lib/runtime/optionProcessor.js +7 -38
- package/lib/runtime/utils.js +2 -0
- package/lib/style-compiler/plugins/scope-id.js +30 -2
- package/lib/template-compiler/bind-this.js +7 -2
- package/lib/template-compiler/compiler.js +77 -46
- package/lib/template-compiler/gen-node-react.js +2 -2
- package/lib/utils/pre-process-json.js +9 -5
- package/package.json +5 -4
- package/lib/runtime/components/react/dist/mpx-image/index.jsx +0 -226
- package/lib/runtime/components/react/dist/mpx-image/svg.jsx +0 -7
- package/lib/runtime/components/react/mpx-image/index.tsx +0 -345
- package/lib/runtime/components/react/mpx-image/svg.tsx +0 -22
- package/lib/runtime/components/web/event.js +0 -105
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ✘ for
|
|
3
3
|
*/
|
|
4
|
-
import { JSX, useRef, forwardRef, ReactNode, useCallback } from 'react'
|
|
4
|
+
import { JSX, useRef, forwardRef, ReactNode, useCallback, createElement } from 'react'
|
|
5
5
|
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 } from './utils'
|
|
9
|
+
import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject } from './utils'
|
|
10
10
|
import { LabelContext, LabelContextValue } from './context'
|
|
11
11
|
|
|
12
12
|
export interface LabelProps {
|
|
@@ -42,10 +42,7 @@ const Label = forwardRef<HandlerRef<View, LabelProps>, LabelProps>(
|
|
|
42
42
|
flexDirection: 'row'
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
const styleObj = {
|
|
46
|
-
...defaultStyle,
|
|
47
|
-
...style
|
|
48
|
-
}
|
|
45
|
+
const styleObj = extendObject({}, defaultStyle, style)
|
|
49
46
|
|
|
50
47
|
const {
|
|
51
48
|
hasSelfPercent,
|
|
@@ -57,11 +54,11 @@ const Label = forwardRef<HandlerRef<View, LabelProps>, LabelProps>(
|
|
|
57
54
|
} = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
|
|
58
55
|
|
|
59
56
|
const nodeRef = useRef(null)
|
|
60
|
-
useNodesRef(props, ref, nodeRef, {
|
|
57
|
+
useNodesRef(props, ref, nodeRef, { style: normalStyle })
|
|
61
58
|
|
|
62
59
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef })
|
|
63
60
|
|
|
64
|
-
const { textStyle, backgroundStyle, innerStyle } = splitStyle(normalStyle)
|
|
61
|
+
const { textStyle, backgroundStyle, innerStyle = {} } = splitStyle(normalStyle)
|
|
65
62
|
|
|
66
63
|
if (backgroundStyle) {
|
|
67
64
|
warn('Label does not support background image-related styles!')
|
|
@@ -79,33 +76,35 @@ const Label = forwardRef<HandlerRef<View, LabelProps>, LabelProps>(
|
|
|
79
76
|
|
|
80
77
|
const innerProps = useInnerProps(
|
|
81
78
|
props,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
79
|
+
extendObject(
|
|
80
|
+
{
|
|
81
|
+
ref: nodeRef,
|
|
82
|
+
style: extendObject({}, innerStyle, layoutStyle)
|
|
83
|
+
},
|
|
84
|
+
layoutProps,
|
|
85
|
+
{
|
|
86
|
+
bindtap: onTap
|
|
87
|
+
}
|
|
88
|
+
),
|
|
88
89
|
[],
|
|
89
90
|
{
|
|
90
91
|
layoutRef
|
|
91
92
|
}
|
|
92
93
|
)
|
|
93
94
|
|
|
94
|
-
return
|
|
95
|
-
|
|
95
|
+
return createElement(View, innerProps, createElement(
|
|
96
|
+
LabelContext.Provider,
|
|
97
|
+
{ value: contextRef },
|
|
98
|
+
wrapChildren(
|
|
99
|
+
props,
|
|
96
100
|
{
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
varContext: varContextRef.current,
|
|
102
|
-
textStyle,
|
|
103
|
-
textProps
|
|
104
|
-
}
|
|
105
|
-
)
|
|
101
|
+
hasVarDec,
|
|
102
|
+
varContext: varContextRef.current,
|
|
103
|
+
textStyle,
|
|
104
|
+
textProps
|
|
106
105
|
}
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
)
|
|
107
|
+
))
|
|
109
108
|
}
|
|
110
109
|
)
|
|
111
110
|
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { View } from 'react-native'
|
|
6
|
-
import { JSX, forwardRef, ReactNode, useRef, useMemo } from 'react'
|
|
6
|
+
import { JSX, forwardRef, ReactNode, useRef, useMemo, createElement } from 'react'
|
|
7
7
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
8
8
|
import useInnerProps from './getInnerListeners'
|
|
9
9
|
import { MovableAreaContext } from './context'
|
|
10
|
-
import { useTransformStyle, wrapChildren, useLayout } from './utils'
|
|
10
|
+
import { useTransformStyle, wrapChildren, useLayout, extendObject } from './utils'
|
|
11
11
|
|
|
12
12
|
interface MovableAreaProps {
|
|
13
13
|
style?: Record<string, any>;
|
|
@@ -35,7 +35,9 @@ const _MovableArea = forwardRef<HandlerRef<View, MovableAreaProps>, MovableAreaP
|
|
|
35
35
|
} = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
|
|
36
36
|
|
|
37
37
|
const movableViewRef = useRef(null)
|
|
38
|
-
useNodesRef(props, ref, movableViewRef
|
|
38
|
+
useNodesRef(props, ref, movableViewRef, {
|
|
39
|
+
style: normalStyle
|
|
40
|
+
})
|
|
39
41
|
|
|
40
42
|
const contextValue = useMemo(() => ({
|
|
41
43
|
height: normalStyle.height || 10,
|
|
@@ -44,29 +46,22 @@ const _MovableArea = forwardRef<HandlerRef<View, MovableAreaProps>, MovableAreaP
|
|
|
44
46
|
|
|
45
47
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: movableViewRef })
|
|
46
48
|
|
|
47
|
-
const innerProps = useInnerProps(props, {
|
|
48
|
-
style: { height: contextValue.height, width: contextValue.width, overflow: 'hidden',
|
|
49
|
-
ref: movableViewRef
|
|
50
|
-
|
|
51
|
-
}, [], { layoutRef })
|
|
49
|
+
const innerProps = useInnerProps(props, extendObject({
|
|
50
|
+
style: extendObject({ height: contextValue.height, width: contextValue.width, overflow: 'hidden' }, normalStyle, layoutStyle),
|
|
51
|
+
ref: movableViewRef
|
|
52
|
+
}, layoutProps), [], { layoutRef })
|
|
52
53
|
|
|
53
|
-
return (
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
return createElement(MovableAreaContext.Provider, { value: contextValue }, createElement(
|
|
55
|
+
View,
|
|
56
|
+
innerProps,
|
|
57
|
+
wrapChildren(
|
|
58
|
+
props,
|
|
58
59
|
{
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
{
|
|
62
|
-
hasVarDec,
|
|
63
|
-
varContext: varContextRef.current
|
|
64
|
-
}
|
|
65
|
-
)
|
|
60
|
+
hasVarDec,
|
|
61
|
+
varContext: varContextRef.current
|
|
66
62
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
)
|
|
63
|
+
)
|
|
64
|
+
))
|
|
70
65
|
})
|
|
71
66
|
|
|
72
67
|
_MovableArea.displayName = 'MpxMovableArea'
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
* ✔ htouchmove
|
|
18
18
|
* ✔ vtouchmove
|
|
19
19
|
*/
|
|
20
|
-
import { useEffect, forwardRef, ReactNode, useContext, useCallback, useRef, useMemo } from 'react'
|
|
20
|
+
import { useEffect, forwardRef, ReactNode, useContext, useCallback, useRef, useMemo, createElement } from 'react'
|
|
21
21
|
import { StyleSheet, NativeSyntheticEvent, View, LayoutChangeEvent } from 'react-native'
|
|
22
22
|
import { getCustomEvent } from './getInnerListeners'
|
|
23
23
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
24
24
|
import { MovableAreaContext } from './context'
|
|
25
|
-
import { useTransformStyle, splitProps, splitStyle, HIDDEN_STYLE, wrapChildren, GestureHandler, flatGesture } from './utils'
|
|
25
|
+
import { useTransformStyle, splitProps, splitStyle, HIDDEN_STYLE, wrapChildren, GestureHandler, flatGesture, extendObject } from './utils'
|
|
26
26
|
import { GestureDetector, Gesture, GestureTouchEvent, GestureStateChangeEvent, PanGestureHandlerEventPayload, PanGesture } from 'react-native-gesture-handler'
|
|
27
27
|
import Animated, {
|
|
28
28
|
useSharedValue,
|
|
@@ -148,7 +148,7 @@ const _MovableView = forwardRef<HandlerRef<View, MovableViewProps>, MovableViewP
|
|
|
148
148
|
const nodeRef = useRef<View>(null)
|
|
149
149
|
|
|
150
150
|
useNodesRef(props, ref, nodeRef, {
|
|
151
|
-
|
|
151
|
+
style: normalStyle,
|
|
152
152
|
gestureRef: movableGestureRef
|
|
153
153
|
})
|
|
154
154
|
|
|
@@ -518,28 +518,24 @@ const _MovableView = forwardRef<HandlerRef<View, MovableViewProps>, MovableViewP
|
|
|
518
518
|
|
|
519
519
|
const catchEventHandlers = injectCatchEvent(props)
|
|
520
520
|
const layoutStyle = !hasLayoutRef.current && hasSelfPercent ? HIDDEN_STYLE : {}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
}
|
|
540
|
-
</Animated.View>
|
|
541
|
-
</GestureDetector>
|
|
542
|
-
)
|
|
521
|
+
|
|
522
|
+
return createElement(GestureDetector, { gesture: gesture }, createElement(
|
|
523
|
+
Animated.View,
|
|
524
|
+
extendObject({
|
|
525
|
+
ref: nodeRef,
|
|
526
|
+
onLayout: onLayout,
|
|
527
|
+
style: [innerStyle, animatedStyles, layoutStyle]
|
|
528
|
+
}, catchEventHandlers),
|
|
529
|
+
wrapChildren(
|
|
530
|
+
props,
|
|
531
|
+
{
|
|
532
|
+
hasVarDec,
|
|
533
|
+
varContext: varContextRef.current,
|
|
534
|
+
textStyle,
|
|
535
|
+
textProps
|
|
536
|
+
}
|
|
537
|
+
)
|
|
538
|
+
))
|
|
543
539
|
})
|
|
544
540
|
|
|
545
541
|
_MovableView.displayName = 'MpxMovableView'
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* ✔ delta
|
|
9
9
|
*/
|
|
10
10
|
import { View } from 'react-native'
|
|
11
|
-
import { useCallback, forwardRef, JSX } from 'react'
|
|
11
|
+
import { useCallback, forwardRef, JSX, createElement } from 'react'
|
|
12
12
|
import useInnerProps from './getInnerListeners'
|
|
13
13
|
import { redirectTo, navigateTo, navigateBack, reLaunch, switchTab } from '@mpxjs/api-proxy'
|
|
14
14
|
|
|
@@ -53,13 +53,7 @@ const _Navigator = forwardRef<View, _NavigatorProps>((props, ref): JSX.Element =
|
|
|
53
53
|
bindtap: handleClick
|
|
54
54
|
})
|
|
55
55
|
|
|
56
|
-
return (
|
|
57
|
-
<MpxView
|
|
58
|
-
{...innerProps}
|
|
59
|
-
>
|
|
60
|
-
{children}
|
|
61
|
-
</MpxView>
|
|
62
|
-
)
|
|
56
|
+
return createElement(MpxView, innerProps, children)
|
|
63
57
|
})
|
|
64
58
|
|
|
65
59
|
_Navigator.displayName = 'MpxNavigator'
|
|
@@ -27,12 +27,14 @@ function dateToString (date: Date, fields: 'day' | 'month' | 'year' = 'day'): st
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
const _DatePicker = forwardRef<HandlerRef<View, DateProps>, DateProps>((props: DateProps, ref): React.JSX.Element => {
|
|
30
|
-
const { children, start = '1970-01-01', end = '2999-01-01', value, bindchange, bindcancel, disabled, fields } = props
|
|
30
|
+
const { children, start = '1970-01-01', end = '2999-01-01', value, bindchange, bindcancel, disabled, fields, style } = props
|
|
31
31
|
const [datevalue, setDateValue] = useState(value)
|
|
32
32
|
// 存储layout布局信息
|
|
33
33
|
const layoutRef = useRef({})
|
|
34
34
|
const viewRef = useRef<View>(null)
|
|
35
|
-
|
|
35
|
+
const nodeRef = useRef<View>(null)
|
|
36
|
+
useNodesRef<View, DateProps>(props, ref, nodeRef, {
|
|
37
|
+
style
|
|
36
38
|
})
|
|
37
39
|
|
|
38
40
|
useEffect(() => {
|
|
@@ -58,6 +60,7 @@ const _DatePicker = forwardRef<HandlerRef<View, DateProps>, DateProps>((props: D
|
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
const dateProps = {
|
|
63
|
+
ref: nodeRef,
|
|
61
64
|
precision: fields,
|
|
62
65
|
value: formatTimeStr(datevalue),
|
|
63
66
|
minDate: formatTimeStr(start),
|
|
@@ -32,10 +32,11 @@ import { FormContext, FormFieldValue } from '../context'
|
|
|
32
32
|
*/
|
|
33
33
|
|
|
34
34
|
const _Picker = forwardRef<HandlerRef<View, PickerProps>, PickerProps>((props: PickerProps, ref): React.JSX.Element => {
|
|
35
|
-
const { mode = 'selector', value, bindcancel, bindchange, children, bindcolumnchange } = props
|
|
35
|
+
const { mode = 'selector', value, bindcancel, bindchange, children, bindcolumnchange, style } = props
|
|
36
36
|
const innerLayout = useRef({})
|
|
37
37
|
const nodeRef = useRef(null)
|
|
38
38
|
useNodesRef<View, PickerProps>(props, ref, nodeRef, {
|
|
39
|
+
style
|
|
39
40
|
})
|
|
40
41
|
const innerProps = useInnerProps(props, {
|
|
41
42
|
ref: nodeRef
|
|
@@ -92,7 +93,7 @@ const _Picker = forwardRef<HandlerRef<View, PickerProps>, PickerProps>((props: P
|
|
|
92
93
|
bindcolumnchange && bindcolumnchange(eventData)
|
|
93
94
|
}
|
|
94
95
|
const commonProps = {
|
|
95
|
-
...
|
|
96
|
+
...innerProps,
|
|
96
97
|
mode,
|
|
97
98
|
children,
|
|
98
99
|
bindchange: onChange,
|
|
@@ -80,7 +80,7 @@ function getColumnIndexByValue (range: any[] = [], column: number, value: any[]
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
const _MultiSelectorPicker = forwardRef<HandlerRef<View, MultiSelectorProps>, MultiSelectorProps>((props: MultiSelectorProps, ref): React.JSX.Element => {
|
|
83
|
-
const { range, value, disabled, bindchange, bindcancel, children, bindcolumnchange } = props
|
|
83
|
+
const { range, value, disabled, bindchange, bindcancel, children, bindcolumnchange, style } = props
|
|
84
84
|
const formatRange = formatRangeFun(range, props['range-key'])
|
|
85
85
|
const initValue = getInnerValueByIndex(formatRange, value)
|
|
86
86
|
// 选中的索引值
|
|
@@ -90,7 +90,9 @@ const _MultiSelectorPicker = forwardRef<HandlerRef<View, MultiSelectorProps>, Mu
|
|
|
90
90
|
// 存储layout布局信息
|
|
91
91
|
const layoutRef = useRef({})
|
|
92
92
|
const viewRef = useRef<View>(null)
|
|
93
|
-
|
|
93
|
+
const nodeRef = useRef<View>(null)
|
|
94
|
+
useNodesRef<View, MultiSelectorProps>(props, ref, nodeRef, {
|
|
95
|
+
style
|
|
94
96
|
})
|
|
95
97
|
|
|
96
98
|
useEffect(() => {
|
|
@@ -126,6 +128,7 @@ const _MultiSelectorPicker = forwardRef<HandlerRef<View, MultiSelectorProps>, Mu
|
|
|
126
128
|
}
|
|
127
129
|
|
|
128
130
|
const antPickerProps = {
|
|
131
|
+
ref: nodeRef,
|
|
129
132
|
data,
|
|
130
133
|
value: selected,
|
|
131
134
|
cols: range.length,
|
|
@@ -38,14 +38,16 @@ function formateRegionData (clObj: RegionObj[] = [], customItem?: string, depth
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
const _RegionPicker = forwardRef<HandlerRef<View, RegionProps>, RegionProps>((props: RegionProps, ref): React.JSX.Element => {
|
|
41
|
-
const { children, value, bindchange, bindcancel, disabled } = props
|
|
41
|
+
const { children, value, bindchange, bindcancel, disabled, style } = props
|
|
42
42
|
const formatRegionData = formateRegionData(regionData, props['custom-item'])
|
|
43
43
|
|
|
44
44
|
const [regionvalue, setRegionValue] = useState(value)
|
|
45
45
|
// 存储layout布局信息
|
|
46
46
|
const layoutRef = useRef({})
|
|
47
47
|
const viewRef = useRef<View>(null)
|
|
48
|
-
|
|
48
|
+
const nodeRef = useRef(null)
|
|
49
|
+
useNodesRef<View, RegionProps>(props, ref, nodeRef, {
|
|
50
|
+
style
|
|
49
51
|
})
|
|
50
52
|
|
|
51
53
|
const onChange = (value: string[]): void => {
|
|
@@ -83,6 +85,7 @@ const _RegionPicker = forwardRef<HandlerRef<View, RegionProps>, RegionProps>((pr
|
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
const regionProps = {
|
|
88
|
+
ref: nodeRef,
|
|
86
89
|
data: formatRegionData,
|
|
87
90
|
value: regionvalue,
|
|
88
91
|
onChange,
|
|
@@ -22,7 +22,7 @@ const formatRangeFun = (range: Array<RangeItemType>, rangeKey = ''): any => {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
const _SelectorPicker = forwardRef<HandlerRef<View, SelectorProps>, SelectorProps>((props: SelectorProps, ref): React.JSX.Element => {
|
|
25
|
-
const { range, children, value, disabled, bindchange, bindcancel } = props
|
|
25
|
+
const { range, children, value, disabled, bindchange, bindcancel, style } = props
|
|
26
26
|
// 格式化数据为Array<*>
|
|
27
27
|
const formatRange: PickerColumn = formatRangeFun(range, props['range-key'])
|
|
28
28
|
// 选中的索引值
|
|
@@ -32,7 +32,9 @@ const _SelectorPicker = forwardRef<HandlerRef<View, SelectorProps>, SelectorProp
|
|
|
32
32
|
// 存储layout布局信息
|
|
33
33
|
const layoutRef = useRef({})
|
|
34
34
|
const viewRef = useRef<View>(null)
|
|
35
|
-
|
|
35
|
+
const nodeRef = useRef(null)
|
|
36
|
+
useNodesRef<View, SelectorProps>(props, ref, nodeRef, {
|
|
37
|
+
style
|
|
36
38
|
})
|
|
37
39
|
|
|
38
40
|
useEffect(() => {
|
|
@@ -62,6 +64,7 @@ const _SelectorPicker = forwardRef<HandlerRef<View, SelectorProps>, SelectorProp
|
|
|
62
64
|
}
|
|
63
65
|
|
|
64
66
|
const antPickerProps = {
|
|
67
|
+
ref: nodeRef,
|
|
65
68
|
data,
|
|
66
69
|
value: [selected],
|
|
67
70
|
cols: 1,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { View, Text, Modal, TouchableWithoutFeedback } from 'react-native'
|
|
2
|
-
import { PickerView } from '@ant-design/react-native'
|
|
2
|
+
import { PickerView, Portal } from '@ant-design/react-native'
|
|
3
3
|
import React, { forwardRef, useState, useRef, useEffect } from 'react'
|
|
4
4
|
import useNodesRef, { HandlerRef } from '../useNodesRef' // 引入辅助函数
|
|
5
5
|
import { TimeProps } from './type'
|
|
@@ -13,8 +13,8 @@ const styles: { [key: string]: Object } = {
|
|
|
13
13
|
showModal: {
|
|
14
14
|
backgroundColor: 'black',
|
|
15
15
|
opacity: 0.5,
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
width: '100%',
|
|
17
|
+
height: '100%'
|
|
18
18
|
},
|
|
19
19
|
hideModal: {
|
|
20
20
|
opacity: 1,
|
|
@@ -125,7 +125,7 @@ function checkSelectedIsValid (strStart: string, strEnd: string, selected: numbe
|
|
|
125
125
|
// start="02:10" end = 23:01
|
|
126
126
|
|
|
127
127
|
const _TimePicker = forwardRef<HandlerRef<View, TimeProps>, TimeProps>((props: TimeProps, ref): React.JSX.Element => {
|
|
128
|
-
const { children, start, end, value, bindchange, bindcancel,
|
|
128
|
+
const { children, start, end, value, bindchange, bindcancel, style } = props
|
|
129
129
|
const defaultProps = {
|
|
130
130
|
start: '00:10',
|
|
131
131
|
end: '23:59'
|
|
@@ -135,11 +135,11 @@ const _TimePicker = forwardRef<HandlerRef<View, TimeProps>, TimeProps>((props: T
|
|
|
135
135
|
// 存储layout布局信息
|
|
136
136
|
const layoutRef = useRef({})
|
|
137
137
|
const viewRef = useRef<View>(null)
|
|
138
|
-
|
|
138
|
+
const nodeRef = useRef<View>(null)
|
|
139
|
+
useNodesRef<View, TimeProps>(props, ref, nodeRef, { style })
|
|
139
140
|
// 存储modal的布局信息
|
|
140
141
|
const modalLayoutRef = useRef({})
|
|
141
142
|
const modalRef = useRef<View>(null)
|
|
142
|
-
useNodesRef<View, TimeProps>(props, ref, modalRef, {})
|
|
143
143
|
const [visible, setVisible] = useState(false)
|
|
144
144
|
const columnData = generateColumns()
|
|
145
145
|
const [data, setData] = useState(columnData)
|
|
@@ -188,12 +188,6 @@ const _TimePicker = forwardRef<HandlerRef<View, TimeProps>, TimeProps>((props: T
|
|
|
188
188
|
} else {
|
|
189
189
|
// [9, 13]
|
|
190
190
|
setTimeValue(date)
|
|
191
|
-
const strDate = formatStr(date)
|
|
192
|
-
bindchange && bindchange({
|
|
193
|
-
detail: {
|
|
194
|
-
value: strDate
|
|
195
|
-
}
|
|
196
|
-
})
|
|
197
191
|
}
|
|
198
192
|
}
|
|
199
193
|
|
|
@@ -213,6 +207,7 @@ const _TimePicker = forwardRef<HandlerRef<View, TimeProps>, TimeProps>((props: T
|
|
|
213
207
|
|
|
214
208
|
const renderModalChildren = () => {
|
|
215
209
|
const pickerProps = {
|
|
210
|
+
ref: nodeRef,
|
|
216
211
|
data,
|
|
217
212
|
value: timevalue,
|
|
218
213
|
defaultValue: timevalue,
|
|
@@ -249,12 +244,11 @@ const _TimePicker = forwardRef<HandlerRef<View, TimeProps>, TimeProps>((props: T
|
|
|
249
244
|
</TouchableWithoutFeedback>
|
|
250
245
|
</View>
|
|
251
246
|
}
|
|
252
|
-
const strStyle = visible ? styles.showModal : styles.hideModal
|
|
253
|
-
const mheight = Math.floor(offsetTop)
|
|
254
247
|
|
|
255
248
|
// Animated.View
|
|
256
249
|
return (<>
|
|
257
|
-
<
|
|
250
|
+
<Portal>
|
|
251
|
+
<View style={visible ? styles.showModal : styles.hideModal}>
|
|
258
252
|
<Modal
|
|
259
253
|
animationType="slide"
|
|
260
254
|
transparent={true}
|
|
@@ -263,6 +257,7 @@ const _TimePicker = forwardRef<HandlerRef<View, TimeProps>, TimeProps>((props: T
|
|
|
263
257
|
{renderModalChildren()}
|
|
264
258
|
</Modal>
|
|
265
259
|
</View>
|
|
260
|
+
</Portal>
|
|
266
261
|
{renderChildren()}
|
|
267
262
|
</>)
|
|
268
263
|
})
|
|
@@ -3,87 +3,92 @@ import { PickerValue } from '@ant-design/react-native'
|
|
|
3
3
|
|
|
4
4
|
export type Obj = Record<string, any>
|
|
5
5
|
export type SelectorProps = {
|
|
6
|
-
mode: string
|
|
6
|
+
mode: string
|
|
7
7
|
// 表示选择了 range 中的第几个(下标从 0 开始)
|
|
8
8
|
value: PickerValue
|
|
9
|
-
disabled?: boolean
|
|
10
|
-
children: ReactNode
|
|
11
|
-
bindcancel?: Function
|
|
12
|
-
bindchange: Function
|
|
9
|
+
disabled?: boolean
|
|
10
|
+
children: ReactNode
|
|
11
|
+
bindcancel?: Function
|
|
12
|
+
bindchange: Function
|
|
13
13
|
// mode 为 selector 或 multiSelector 时,range 有效
|
|
14
|
-
range: Array<number|string|Obj
|
|
14
|
+
range: Array<number|string|Obj>
|
|
15
15
|
// 当 range 是一个 Object Array 时,通过 range-key 来指定 Object 中 key 的值作为选择器《显示内容》 对象中的属性
|
|
16
|
-
'range-key': string
|
|
16
|
+
'range-key': string
|
|
17
17
|
getInnerLayout: Function
|
|
18
|
+
style?: Record<string, any>
|
|
18
19
|
// bindcolumnchange?: Function
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
export type MultiSelectorProps = {
|
|
22
|
-
mode: string
|
|
23
|
+
mode: string
|
|
23
24
|
// 表示选择了 range 中的第几个(下标从 0 开始)
|
|
24
|
-
value: Array<number
|
|
25
|
-
disabled?: boolean
|
|
26
|
-
children: ReactNode
|
|
27
|
-
bindcancel?: Function
|
|
28
|
-
bindchange: Function
|
|
29
|
-
bindcolumnchange?: Function
|
|
25
|
+
value: Array<number>
|
|
26
|
+
disabled?: boolean
|
|
27
|
+
children: ReactNode
|
|
28
|
+
bindcancel?: Function
|
|
29
|
+
bindchange: Function
|
|
30
|
+
bindcolumnchange?: Function
|
|
30
31
|
// mode 为 selector 或 multiSelector 时,range 有效
|
|
31
|
-
range: Array<Array<any
|
|
32
|
+
range: Array<Array<any>>
|
|
32
33
|
// 当 range 是一个 Object Array 时,通过 range-key 来指定 Object 中 key 的值作为选择器《显示内容》 对象中的属性
|
|
33
|
-
'range-key': string
|
|
34
|
+
'range-key': string
|
|
34
35
|
getInnerLayout: Function
|
|
36
|
+
style?: Record<string, any>
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
export type TimeProps = {
|
|
38
|
-
mode: string
|
|
40
|
+
mode: string
|
|
39
41
|
// 表示选择了 range 中的第几个(下标从 0 开始)
|
|
40
|
-
value: string
|
|
41
|
-
disabled?: boolean
|
|
42
|
-
children: ReactNode
|
|
43
|
-
bindcancel?: Function
|
|
44
|
-
bindchange: Function
|
|
45
|
-
start: string
|
|
46
|
-
end: string
|
|
42
|
+
value: string
|
|
43
|
+
disabled?: boolean
|
|
44
|
+
children: ReactNode
|
|
45
|
+
bindcancel?: Function
|
|
46
|
+
bindchange: Function
|
|
47
|
+
start: string
|
|
48
|
+
end: string
|
|
47
49
|
getInnerLayout: Function
|
|
50
|
+
style?: Record<string, any>
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
export type DateProps = {
|
|
51
|
-
mode: string
|
|
54
|
+
mode: string
|
|
52
55
|
// 表示选择了 range 中的第几个(下标从 0 开始)
|
|
53
|
-
value: string
|
|
54
|
-
fields?: 'day' | 'month' | 'year'
|
|
55
|
-
disabled?: boolean
|
|
56
|
-
children: ReactNode
|
|
57
|
-
bindcancel?: Function
|
|
58
|
-
bindchange: Function
|
|
59
|
-
start: string
|
|
60
|
-
end: string
|
|
56
|
+
value: string
|
|
57
|
+
fields?: 'day' | 'month' | 'year'
|
|
58
|
+
disabled?: boolean
|
|
59
|
+
children: ReactNode
|
|
60
|
+
bindcancel?: Function
|
|
61
|
+
bindchange: Function
|
|
62
|
+
start: string
|
|
63
|
+
end: string
|
|
61
64
|
getInnerLayout: Function
|
|
65
|
+
style?: Record<string, any>
|
|
62
66
|
}
|
|
63
67
|
|
|
64
68
|
export type RegionProps = {
|
|
65
|
-
mode: string
|
|
69
|
+
mode: string
|
|
66
70
|
// 表示选择了 range 中的第几个(下标从 0 开始)
|
|
67
|
-
value: Array<string
|
|
71
|
+
value: Array<string>
|
|
68
72
|
level: 'province' | 'city' | 'region' | 'sub-district'
|
|
69
|
-
'custom-item'?: string
|
|
70
|
-
disabled?: boolean
|
|
71
|
-
children: ReactNode
|
|
72
|
-
bindcancel?: Function
|
|
73
|
-
bindchange: Function
|
|
73
|
+
'custom-item'?: string
|
|
74
|
+
disabled?: boolean
|
|
75
|
+
children: ReactNode
|
|
76
|
+
bindcancel?: Function
|
|
77
|
+
bindchange: Function
|
|
74
78
|
getInnerLayout: Function
|
|
79
|
+
style?: Record<string, any>
|
|
75
80
|
}
|
|
76
81
|
|
|
77
82
|
export type RegionObj = {
|
|
78
|
-
value: string
|
|
83
|
+
value: string
|
|
79
84
|
code: string
|
|
80
85
|
postcode?: string
|
|
81
86
|
children?: RegionObj[]
|
|
82
87
|
}
|
|
83
88
|
|
|
84
89
|
export type PickerData = {
|
|
85
|
-
value: string
|
|
86
|
-
label: string
|
|
90
|
+
value: string
|
|
91
|
+
label: string
|
|
87
92
|
children?: Array<Object>
|
|
88
93
|
}
|
|
89
94
|
|
|
@@ -57,7 +57,10 @@ const _PickerViewColumn = forwardRef<HandlerRef<ScrollView & View, ColumnProps>,
|
|
|
57
57
|
const { textStyle } = splitStyle(normalStyle)
|
|
58
58
|
const { textProps } = splitProps(props)
|
|
59
59
|
const scrollViewRef = useRef<ScrollView>(null)
|
|
60
|
-
|
|
60
|
+
|
|
61
|
+
useNodesRef(props, ref, scrollViewRef, {
|
|
62
|
+
style: normalStyle
|
|
63
|
+
})
|
|
61
64
|
|
|
62
65
|
const { height: pickerH, itemHeight = DefaultPickerItemH } = wrapperStyle
|
|
63
66
|
const [itemRawH, setItemRawH] = useState(0) // 单个选项真实渲染高度
|
|
@@ -90,7 +90,11 @@ const _PickerView = forwardRef<HandlerRef<View, PickerViewProps>, PickerViewProp
|
|
|
90
90
|
setWidth,
|
|
91
91
|
setHeight
|
|
92
92
|
} = useTransformStyle(style, { enableVar, externalVarContext })
|
|
93
|
-
|
|
93
|
+
|
|
94
|
+
useNodesRef<View, PickerViewProps>(props, ref, nodeRef, {
|
|
95
|
+
style: normalStyle
|
|
96
|
+
})
|
|
97
|
+
|
|
94
98
|
const {
|
|
95
99
|
// 存储layout布局信息
|
|
96
100
|
layoutRef,
|
|
@@ -134,6 +138,7 @@ const _PickerView = forwardRef<HandlerRef<View, PickerViewProps>, PickerViewProp
|
|
|
134
138
|
extendObject({
|
|
135
139
|
ref: nodeRef,
|
|
136
140
|
style: extendObject(
|
|
141
|
+
{},
|
|
137
142
|
normalStyle,
|
|
138
143
|
layoutStyle,
|
|
139
144
|
{
|
|
@@ -151,6 +156,7 @@ const _PickerView = forwardRef<HandlerRef<View, PickerViewProps>, PickerViewProp
|
|
|
151
156
|
const extraProps = {}
|
|
152
157
|
const childProps = child?.props || {}
|
|
153
158
|
const wrappedProps = extendObject(
|
|
159
|
+
{},
|
|
154
160
|
childProps,
|
|
155
161
|
{
|
|
156
162
|
columnData,
|