@mpxjs/webpack-plugin 2.9.67 → 2.9.70-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/config.js +14 -0
- package/lib/dependencies/AddEntryDependency.js +24 -0
- package/lib/dependencies/ResolveDependency.js +5 -0
- package/lib/index.js +51 -15
- package/lib/json-compiler/helper.js +3 -3
- package/lib/loader.js +53 -0
- package/lib/platform/template/wx/component-config/button.js +14 -2
- package/lib/platform/template/wx/component-config/canvas.js +8 -0
- package/lib/platform/template/wx/component-config/image.js +4 -0
- package/lib/platform/template/wx/component-config/input.js +5 -1
- package/lib/platform/template/wx/component-config/rich-text.js +4 -0
- package/lib/platform/template/wx/component-config/scroll-view.js +4 -0
- package/lib/platform/template/wx/component-config/swiper.js +1 -1
- package/lib/platform/template/wx/component-config/switch.js +4 -0
- package/lib/platform/template/wx/component-config/text.js +4 -0
- package/lib/platform/template/wx/component-config/textarea.js +6 -1
- package/lib/platform/template/wx/component-config/unsupported.js +1 -1
- package/lib/platform/template/wx/component-config/view.js +4 -0
- package/lib/platform/template/wx/index.js +127 -1
- package/lib/react/processStyles.js +14 -4
- package/lib/react/processTemplate.js +3 -0
- package/lib/resolve-loader.js +4 -1
- package/lib/resolver/AddModePlugin.js +8 -8
- package/lib/runtime/components/react/context.ts +6 -0
- package/lib/runtime/components/react/dist/context.js +2 -0
- package/lib/runtime/components/react/dist/event.config.js +24 -24
- package/lib/runtime/components/react/dist/getInnerListeners.js +183 -174
- package/lib/runtime/components/react/dist/mpx-button.jsx +77 -49
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.js +60 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.js +15 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.js +84 -0
- package/lib/runtime/components/react/dist/mpx-canvas/Image.js +87 -0
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.js +15 -0
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.js +28 -0
- package/lib/runtime/components/react/dist/mpx-canvas/html.js +343 -0
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +232 -0
- package/lib/runtime/components/react/dist/mpx-canvas/utils.jsx +89 -0
- 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-item.jsx +39 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +160 -88
- package/lib/runtime/components/react/dist/mpx-picker-view.jsx +80 -121
- 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-item.jsx +4 -2
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +606 -0
- 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 +65 -61
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +112 -35
- package/lib/runtime/components/react/dist/pickerFaces.js +81 -0
- package/lib/runtime/components/react/dist/pickerVIewContext.js +9 -0
- package/lib/runtime/components/react/dist/pickerViewMask.jsx +18 -0
- package/lib/runtime/components/react/dist/pickerViewOverlay.jsx +23 -0
- package/lib/runtime/components/react/dist/useAnimationHooks.js +35 -9
- package/lib/runtime/components/react/dist/utils.jsx +70 -23
- package/lib/runtime/components/react/getInnerListeners.ts +36 -43
- package/lib/runtime/components/react/mpx-button.tsx +95 -43
- package/lib/runtime/components/react/mpx-canvas/Bus.ts +70 -0
- package/lib/runtime/components/react/mpx-canvas/CanvasGradient.ts +18 -0
- package/lib/runtime/components/react/mpx-canvas/CanvasRenderingContext2D.ts +87 -0
- package/lib/runtime/components/react/mpx-canvas/Image.ts +102 -0
- package/lib/runtime/components/react/mpx-canvas/ImageData.ts +23 -0
- package/lib/runtime/components/react/mpx-canvas/constructorsRegistry.ts +38 -0
- package/lib/runtime/components/react/mpx-canvas/html.ts +343 -0
- package/lib/runtime/components/react/mpx-canvas/index.tsx +302 -0
- package/lib/runtime/components/react/mpx-canvas/utils.tsx +150 -0
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +13 -12
- package/lib/runtime/components/react/mpx-checkbox.tsx +28 -28
- package/lib/runtime/components/react/mpx-form.tsx +10 -8
- package/lib/runtime/components/react/mpx-icon.tsx +10 -15
- package/lib/runtime/components/react/mpx-image.tsx +396 -0
- package/lib/runtime/components/react/mpx-input.tsx +61 -33
- package/lib/runtime/components/react/mpx-label.tsx +14 -13
- package/lib/runtime/components/react/mpx-movable-area.tsx +8 -7
- package/lib/runtime/components/react/mpx-movable-view.tsx +1 -1
- 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 +236 -104
- package/lib/runtime/components/react/mpx-picker-view.tsx +132 -122
- package/lib/runtime/components/react/mpx-radio-group.tsx +11 -12
- package/lib/runtime/components/react/mpx-radio.tsx +26 -29
- package/lib/runtime/components/react/mpx-scroll-view.tsx +32 -30
- 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 +10 -8
- package/lib/runtime/components/react/mpx-text.tsx +6 -2
- package/lib/runtime/components/react/mpx-view.tsx +81 -59
- package/lib/runtime/components/react/mpx-web-view.tsx +46 -19
- package/lib/runtime/components/react/pickerFaces.ts +104 -0
- package/lib/runtime/components/react/pickerOverlay.tsx +32 -0
- package/lib/runtime/components/react/types/common.ts +2 -0
- package/lib/runtime/components/react/types/global.d.ts +3 -16
- package/lib/runtime/components/react/utils.tsx +98 -27
- package/lib/runtime/components/tenon/getInnerListeners.js +334 -0
- package/lib/runtime/components/tenon/tenon-button.vue +309 -0
- package/lib/runtime/components/tenon/tenon-image.vue +66 -0
- package/lib/runtime/components/tenon/tenon-input.vue +171 -0
- package/lib/runtime/components/tenon/tenon-rich-text.vue +26 -0
- package/lib/runtime/components/tenon/tenon-scroll-view.vue +127 -0
- package/lib/runtime/components/tenon/tenon-switch.vue +96 -0
- package/lib/runtime/components/tenon/tenon-text.vue +70 -0
- package/lib/runtime/components/tenon/tenon-textarea.vue +86 -0
- package/lib/runtime/components/tenon/tenon-view.vue +93 -0
- 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 +162 -162
- package/lib/runtime/optionProcessor.js +7 -16
- package/lib/runtime/optionProcessor.tenon.js +84 -0
- package/lib/runtime/utils.js +2 -0
- package/lib/style-compiler/index.js +1 -1
- package/lib/style-compiler/plugins/hm.js +20 -0
- package/lib/template-compiler/bind-this.js +7 -2
- package/lib/template-compiler/compiler.js +70 -42
- package/lib/template-compiler/gen-node-react.js +3 -3
- package/lib/tenon/index.js +117 -0
- package/lib/tenon/processJSON.js +352 -0
- package/lib/tenon/processScript.js +203 -0
- package/lib/tenon/processStyles.js +21 -0
- package/lib/tenon/processTemplate.js +126 -0
- package/lib/tenon/script-helper.js +223 -0
- package/lib/utils/env.js +6 -1
- package/lib/utils/get-relative-path.js +25 -0
- package/package.json +9 -4
- package/LICENSE +0 -433
- 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/dist/mpx-swiper/carouse.jsx +0 -478
- package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +0 -68
- package/lib/runtime/components/react/dist/mpx-swiper/type.js +0 -1
- package/lib/runtime/components/react/mpx-image/index.tsx +0 -345
- package/lib/runtime/components/react/mpx-image/svg.tsx +0 -22
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import { View } from 'react-native'
|
|
2
|
-
import {
|
|
3
|
-
import React, { forwardRef, useState, useRef, ReactElement, JSX } from 'react'
|
|
2
|
+
import React, { forwardRef, useState, useRef } from 'react'
|
|
4
3
|
import useInnerProps, { getCustomEvent } from './getInnerListeners'
|
|
5
|
-
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
6
|
-
import {
|
|
4
|
+
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
5
|
+
import {
|
|
6
|
+
useLayout,
|
|
7
|
+
splitProps,
|
|
8
|
+
splitStyle,
|
|
9
|
+
wrapChildren,
|
|
10
|
+
parseInlineStyle,
|
|
11
|
+
useTransformStyle,
|
|
12
|
+
useDebounceCallback,
|
|
13
|
+
useStableCallback,
|
|
14
|
+
extendObject
|
|
15
|
+
} from './utils'
|
|
16
|
+
import type { AnyFunc } from './types/common'
|
|
7
17
|
/**
|
|
8
18
|
* ✔ value
|
|
9
19
|
* ✔ bindchange
|
|
@@ -18,9 +28,10 @@ import { parseInlineStyle, useTransformStyle, splitStyle, splitProps, useLayout,
|
|
|
18
28
|
|
|
19
29
|
interface PickerViewProps {
|
|
20
30
|
children: React.ReactNode
|
|
21
|
-
// 初始的defaultValue数组中的数字依次表示 picker-view 内的 picker-view-column 选择的第几项(下标从 0
|
|
31
|
+
// 初始的defaultValue数组中的数字依次表示 picker-view 内的 picker-view-column 选择的第几项(下标从 0 开始),
|
|
32
|
+
// 数字大于 picker-view-column 可选项长度时,选择最后一项。
|
|
22
33
|
value?: Array<number>
|
|
23
|
-
bindchange?:
|
|
34
|
+
bindchange?: AnyFunc
|
|
24
35
|
style: {
|
|
25
36
|
[key: string]: any
|
|
26
37
|
}
|
|
@@ -48,27 +59,29 @@ const styles: { [key: string]: Object } = {
|
|
|
48
59
|
justifyContent: 'space-around',
|
|
49
60
|
overflow: 'hidden',
|
|
50
61
|
alignItems: 'center'
|
|
51
|
-
},
|
|
52
|
-
maskTop: {
|
|
53
|
-
position: 'absolute',
|
|
54
|
-
width: 1000,
|
|
55
|
-
zIndex: 100
|
|
56
|
-
},
|
|
57
|
-
maskBottom: {
|
|
58
|
-
position: 'absolute',
|
|
59
|
-
width: 1000,
|
|
60
|
-
zIndex: 100
|
|
61
62
|
}
|
|
62
63
|
}
|
|
64
|
+
|
|
63
65
|
const _PickerView = forwardRef<HandlerRef<View, PickerViewProps>, PickerViewProps>((props: PickerViewProps, ref) => {
|
|
64
|
-
const {
|
|
66
|
+
const {
|
|
67
|
+
children,
|
|
68
|
+
value = [],
|
|
69
|
+
bindchange,
|
|
70
|
+
style,
|
|
71
|
+
'enable-var': enableVar,
|
|
72
|
+
'external-var-context': externalVarContext
|
|
73
|
+
} = props
|
|
74
|
+
|
|
65
75
|
// indicatorStyle 需要转换为rn的style
|
|
66
76
|
// 微信设置到pick-view上上设置的normalStyle如border等需要转换成RN的style然后进行透传
|
|
67
77
|
const indicatorStyle = parseInlineStyle(props['indicator-style'])
|
|
68
|
-
const { height: indicatorH,
|
|
78
|
+
const { height: indicatorH, ...pickerOverlayStyle } = indicatorStyle
|
|
79
|
+
const [pickMaxH, setPickMaxH] = useState(0)
|
|
69
80
|
const nodeRef = useRef(null)
|
|
70
|
-
|
|
71
|
-
|
|
81
|
+
const cloneRef = useRef(null)
|
|
82
|
+
const activeValueRef = useRef(value)
|
|
83
|
+
activeValueRef.current = value.slice()
|
|
84
|
+
|
|
72
85
|
const {
|
|
73
86
|
normalStyle,
|
|
74
87
|
hasVarDec,
|
|
@@ -77,69 +90,91 @@ const _PickerView = forwardRef<HandlerRef<View, PickerViewProps>, PickerViewProp
|
|
|
77
90
|
setWidth,
|
|
78
91
|
setHeight
|
|
79
92
|
} = useTransformStyle(style, { enableVar, externalVarContext })
|
|
80
|
-
|
|
81
|
-
|
|
93
|
+
|
|
94
|
+
useNodesRef<View, PickerViewProps>(props, ref, nodeRef, {
|
|
95
|
+
style: normalStyle
|
|
96
|
+
})
|
|
97
|
+
|
|
82
98
|
const {
|
|
83
99
|
// 存储layout布局信息
|
|
84
100
|
layoutRef,
|
|
85
101
|
layoutProps,
|
|
86
102
|
layoutStyle
|
|
87
103
|
} = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: nodeRef })
|
|
104
|
+
const { textProps } = splitProps(props)
|
|
105
|
+
const { textStyle } = splitStyle(normalStyle)
|
|
88
106
|
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const itemH = pickH / 5
|
|
94
|
-
if (normalStyle?.height && pickH && pickH !== normalStyle?.height) {
|
|
95
|
-
maskPos.height = itemH * 2 + Math.ceil((normalStyle.height - pickH) / 2)
|
|
96
|
-
} else {
|
|
97
|
-
maskPos.height = itemH * 2
|
|
107
|
+
const onColumnItemRawHChange = (height: number) => {
|
|
108
|
+
if (height > pickMaxH) {
|
|
109
|
+
setPickMaxH(height)
|
|
110
|
+
}
|
|
98
111
|
}
|
|
99
112
|
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
113
|
+
const bindchangeDebounce = useDebounceCallback(useStableCallback(bindchange), 300)
|
|
114
|
+
|
|
115
|
+
const onSelectChange = (columnIndex: number, selectedIndex: number) => {
|
|
116
|
+
bindchangeDebounce.clear()
|
|
117
|
+
const activeValue = activeValueRef.current
|
|
118
|
+
activeValue[columnIndex] = selectedIndex
|
|
119
|
+
const eventData = getCustomEvent(
|
|
120
|
+
'change',
|
|
121
|
+
{},
|
|
122
|
+
{ detail: { value: activeValue, source: 'change' }, layoutRef }
|
|
123
|
+
)
|
|
124
|
+
bindchangeDebounce(eventData)
|
|
103
125
|
}
|
|
104
126
|
|
|
105
|
-
const
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
127
|
+
const onInitialChange = (value: number[]) => {
|
|
128
|
+
const eventData = getCustomEvent(
|
|
129
|
+
'change',
|
|
130
|
+
{},
|
|
131
|
+
{ detail: { value, source: 'change' }, layoutRef }
|
|
132
|
+
)
|
|
133
|
+
bindchange?.(eventData) // immediate
|
|
110
134
|
}
|
|
111
135
|
|
|
112
|
-
const innerProps = useInnerProps(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
136
|
+
const innerProps = useInnerProps(
|
|
137
|
+
props,
|
|
138
|
+
extendObject({
|
|
139
|
+
ref: nodeRef,
|
|
140
|
+
style: extendObject(
|
|
141
|
+
{},
|
|
142
|
+
normalStyle,
|
|
143
|
+
layoutStyle,
|
|
144
|
+
{
|
|
145
|
+
position: 'relative',
|
|
146
|
+
overflow: 'hidden'
|
|
147
|
+
}
|
|
148
|
+
),
|
|
149
|
+
layoutProps
|
|
150
|
+
}),
|
|
151
|
+
['enable-offset'],
|
|
152
|
+
{ layoutRef }
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
const renderColumn = (child: React.ReactElement, index: number, columnData: React.ReactNode[], initialIndex: number) => {
|
|
127
156
|
const extraProps = {}
|
|
128
|
-
const childProps = {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
157
|
+
const childProps = child?.props || {}
|
|
158
|
+
const wrappedProps = extendObject(
|
|
159
|
+
{},
|
|
160
|
+
childProps,
|
|
161
|
+
{
|
|
162
|
+
columnData,
|
|
163
|
+
ref: cloneRef,
|
|
164
|
+
columnIndex: index,
|
|
165
|
+
key: `pick-view-${index}`,
|
|
166
|
+
wrapperStyle: {
|
|
167
|
+
height: normalStyle?.height || 0,
|
|
168
|
+
itemHeight: indicatorH || 0
|
|
169
|
+
},
|
|
170
|
+
onColumnItemRawHChange,
|
|
171
|
+
onSelectChange: onSelectChange.bind(null, index),
|
|
172
|
+
initialIndex,
|
|
173
|
+
pickerOverlayStyle
|
|
136
174
|
},
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
...extraProps
|
|
141
|
-
}
|
|
142
|
-
const realElement = React.cloneElement(child as ReactElement, childProps)
|
|
175
|
+
extraProps
|
|
176
|
+
)
|
|
177
|
+
const realElement = React.cloneElement(child, wrappedProps)
|
|
143
178
|
return wrapChildren(
|
|
144
179
|
{
|
|
145
180
|
children: realElement
|
|
@@ -153,69 +188,44 @@ const _PickerView = forwardRef<HandlerRef<View, PickerViewProps>, PickerViewProp
|
|
|
153
188
|
)
|
|
154
189
|
}
|
|
155
190
|
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
colors: ['rgba(255,255,255,0.8)', 'rgba(255,255,255,0.2)'],
|
|
159
|
-
style: [
|
|
160
|
-
styles.maskTop,
|
|
161
|
-
{
|
|
162
|
-
height: maskPos.height,
|
|
163
|
-
top: 0,
|
|
164
|
-
pointerEvents: 'none'
|
|
165
|
-
}
|
|
166
|
-
]
|
|
167
|
-
}
|
|
168
|
-
return (<LinearGradient {...linearProps}/>)
|
|
191
|
+
const validateChildInitialIndex = (index: number, data: React.ReactNode[]) => {
|
|
192
|
+
return Math.max(0, Math.min(value[index] || 0, data.length - 1))
|
|
169
193
|
}
|
|
170
194
|
|
|
171
|
-
const
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
{
|
|
177
|
-
height: maskPos.height,
|
|
178
|
-
bottom: 0,
|
|
179
|
-
pointerEvents: 'none'
|
|
180
|
-
}
|
|
181
|
-
]
|
|
195
|
+
const flatColumnChildren = (data: React.ReactElement) => {
|
|
196
|
+
const columnData = React.Children.toArray(data?.props?.children)
|
|
197
|
+
if (columnData.length === 1 && React.isValidElement(columnData[0]) && columnData[0].type === React.Fragment) {
|
|
198
|
+
// 只有一个 Fragment 嵌套情况
|
|
199
|
+
return React.Children.toArray(columnData[0].props.children)
|
|
182
200
|
}
|
|
183
|
-
return
|
|
201
|
+
return columnData
|
|
184
202
|
}
|
|
185
203
|
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
204
|
+
const renderPickerColumns = () => {
|
|
205
|
+
const columns = React.Children.toArray(children)
|
|
206
|
+
const renderColumns: React.ReactNode[] = []
|
|
207
|
+
const validValue: number[] = []
|
|
208
|
+
let isInvalid = false
|
|
209
|
+
columns.forEach((item: React.ReactElement, index) => {
|
|
210
|
+
const columnData = flatColumnChildren(item)
|
|
211
|
+
const validIndex = validateChildInitialIndex(index, columnData)
|
|
212
|
+
if (validIndex !== value[index]) {
|
|
213
|
+
isInvalid = true
|
|
214
|
+
}
|
|
215
|
+
validValue.push(validIndex)
|
|
216
|
+
renderColumns.push(renderColumn(item, index, columnData, validIndex))
|
|
217
|
+
})
|
|
218
|
+
isInvalid && onInitialChange(validValue)
|
|
219
|
+
return renderColumns
|
|
198
220
|
}
|
|
199
221
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
return cloneChild(item, index)
|
|
204
|
-
})
|
|
205
|
-
} else {
|
|
206
|
-
return cloneChild(children, 0)
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
return (<View {...innerProps}>
|
|
210
|
-
{renderTopMask()}
|
|
211
|
-
<View style={[styles.wrapper]}>
|
|
212
|
-
{renderSubChild()}
|
|
222
|
+
return (
|
|
223
|
+
<View {...innerProps}>
|
|
224
|
+
<View style={[styles.wrapper]}>{renderPickerColumns()}</View>
|
|
213
225
|
</View>
|
|
214
|
-
|
|
215
|
-
{!isSetW && renderLine()}
|
|
216
|
-
</View>)
|
|
226
|
+
)
|
|
217
227
|
})
|
|
218
228
|
|
|
219
|
-
_PickerView.displayName = '
|
|
229
|
+
_PickerView.displayName = 'MpxPickerView'
|
|
220
230
|
|
|
221
231
|
export default _PickerView
|
|
@@ -20,7 +20,7 @@ import { warn } from '@mpxjs/utils'
|
|
|
20
20
|
import { FormContext, FormFieldValue, RadioGroupContext, GroupValue } from './context'
|
|
21
21
|
import useInnerProps, { getCustomEvent } from './getInnerListeners'
|
|
22
22
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
23
|
-
import { useLayout, useTransformStyle, wrapChildren } from './utils'
|
|
23
|
+
import { useLayout, useTransformStyle, wrapChildren, extendObject } from './utils'
|
|
24
24
|
|
|
25
25
|
export interface RadioGroupProps {
|
|
26
26
|
name: string
|
|
@@ -67,10 +67,7 @@ const radioGroup = forwardRef<
|
|
|
67
67
|
flexWrap: 'wrap'
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
const styleObj = {
|
|
71
|
-
...defaultStyle,
|
|
72
|
-
...style
|
|
73
|
-
}
|
|
70
|
+
const styleObj = extendObject({}, defaultStyle, style)
|
|
74
71
|
|
|
75
72
|
const {
|
|
76
73
|
hasSelfPercent,
|
|
@@ -82,7 +79,7 @@ const radioGroup = forwardRef<
|
|
|
82
79
|
} = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
|
|
83
80
|
|
|
84
81
|
const nodeRef = useRef(null)
|
|
85
|
-
useNodesRef(props, ref, nodeRef, {
|
|
82
|
+
useNodesRef(props, ref, nodeRef, { style: normalStyle })
|
|
86
83
|
|
|
87
84
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef })
|
|
88
85
|
|
|
@@ -144,12 +141,14 @@ const radioGroup = forwardRef<
|
|
|
144
141
|
|
|
145
142
|
const innerProps = useInnerProps(
|
|
146
143
|
props,
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
144
|
+
extendObject(
|
|
145
|
+
{
|
|
146
|
+
ref: nodeRef,
|
|
147
|
+
style: extendObject({}, normalStyle, layoutStyle)
|
|
148
|
+
},
|
|
149
|
+
layoutProps
|
|
150
|
+
),
|
|
151
|
+
['name'],
|
|
153
152
|
{
|
|
154
153
|
layoutRef
|
|
155
154
|
}
|
|
@@ -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 } from './utils'
|
|
13
|
+
import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject } from './utils'
|
|
14
14
|
import Icon from './mpx-icon'
|
|
15
15
|
|
|
16
16
|
export interface RadioProps {
|
|
@@ -27,7 +27,6 @@ export interface RadioProps {
|
|
|
27
27
|
'parent-height'?: number;
|
|
28
28
|
children: ReactNode
|
|
29
29
|
bindtap?: (evt: NativeSyntheticEvent<TouchEvent> | unknown) => void
|
|
30
|
-
catchtap?: (evt: NativeSyntheticEvent<TouchEvent> | unknown) => void
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
const styles = StyleSheet.create({
|
|
@@ -79,8 +78,7 @@ const Radio = forwardRef<HandlerRef<View, RadioProps>, RadioProps>(
|
|
|
79
78
|
'parent-font-size': parentFontSize,
|
|
80
79
|
'parent-width': parentWidth,
|
|
81
80
|
'parent-height': parentHeight,
|
|
82
|
-
bindtap
|
|
83
|
-
catchtap
|
|
81
|
+
bindtap
|
|
84
82
|
} = props
|
|
85
83
|
|
|
86
84
|
const [isChecked, setIsChecked] = useState<boolean>(!!checked)
|
|
@@ -91,16 +89,14 @@ const Radio = forwardRef<HandlerRef<View, RadioProps>, RadioProps>(
|
|
|
91
89
|
|
|
92
90
|
const labelContext = useContext(LabelContext)
|
|
93
91
|
|
|
94
|
-
const defaultStyle =
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
92
|
+
const defaultStyle = extendObject(
|
|
93
|
+
{},
|
|
94
|
+
styles.wrapper,
|
|
95
|
+
isChecked ? styles.wrapperChecked : {},
|
|
96
|
+
disabled ? styles.wrapperDisabled : {}
|
|
97
|
+
)
|
|
99
98
|
|
|
100
|
-
const styleObj = {
|
|
101
|
-
...styles.container,
|
|
102
|
-
...style
|
|
103
|
-
}
|
|
99
|
+
const styleObj = extendObject({}, styles.container, style)
|
|
104
100
|
|
|
105
101
|
const onChange = (evt: NativeSyntheticEvent<TouchEvent>) => {
|
|
106
102
|
if (disabled || isChecked) return
|
|
@@ -116,16 +112,10 @@ const Radio = forwardRef<HandlerRef<View, RadioProps>, RadioProps>(
|
|
|
116
112
|
}
|
|
117
113
|
|
|
118
114
|
const onTap = (evt: NativeSyntheticEvent<TouchEvent>) => {
|
|
119
|
-
if (disabled) return
|
|
120
115
|
bindtap && bindtap(getCustomEvent('tap', evt, { layoutRef }, props))
|
|
121
116
|
onChange(evt)
|
|
122
117
|
}
|
|
123
118
|
|
|
124
|
-
const catchTap = (evt: NativeSyntheticEvent<TouchEvent>) => {
|
|
125
|
-
if (disabled) return
|
|
126
|
-
catchtap && catchtap(getCustomEvent('tap', evt, { layoutRef }, props))
|
|
127
|
-
}
|
|
128
|
-
|
|
129
119
|
const {
|
|
130
120
|
hasSelfPercent,
|
|
131
121
|
normalStyle,
|
|
@@ -135,7 +125,7 @@ const Radio = forwardRef<HandlerRef<View, RadioProps>, RadioProps>(
|
|
|
135
125
|
setHeight
|
|
136
126
|
} = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
|
|
137
127
|
|
|
138
|
-
const { textStyle, backgroundStyle, innerStyle } = splitStyle(normalStyle)
|
|
128
|
+
const { textStyle, backgroundStyle, innerStyle = {} } = splitStyle(normalStyle)
|
|
139
129
|
|
|
140
130
|
if (backgroundStyle) {
|
|
141
131
|
warn('Radio does not support background image-related styles!')
|
|
@@ -143,7 +133,7 @@ const Radio = forwardRef<HandlerRef<View, RadioProps>, RadioProps>(
|
|
|
143
133
|
|
|
144
134
|
const nodeRef = useRef(null)
|
|
145
135
|
useNodesRef(props, ref, nodeRef, {
|
|
146
|
-
defaultStyle,
|
|
136
|
+
style: extendObject({}, defaultStyle, normalStyle),
|
|
147
137
|
change: onChange
|
|
148
138
|
})
|
|
149
139
|
|
|
@@ -160,14 +150,21 @@ const Radio = forwardRef<HandlerRef<View, RadioProps>, RadioProps>(
|
|
|
160
150
|
|
|
161
151
|
const innerProps = useInnerProps(
|
|
162
152
|
props,
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
153
|
+
extendObject(
|
|
154
|
+
{
|
|
155
|
+
ref: nodeRef,
|
|
156
|
+
style: extendObject({}, innerStyle, layoutStyle)
|
|
157
|
+
},
|
|
158
|
+
layoutProps,
|
|
159
|
+
{
|
|
160
|
+
bindtap: !disabled && onTap
|
|
161
|
+
}
|
|
162
|
+
),
|
|
163
|
+
[
|
|
164
|
+
'value',
|
|
165
|
+
'disabled',
|
|
166
|
+
'checked'
|
|
167
|
+
],
|
|
171
168
|
{
|
|
172
169
|
layoutRef
|
|
173
170
|
}
|
|
@@ -38,7 +38,7 @@ import { useAnimatedRef } from 'react-native-reanimated'
|
|
|
38
38
|
import { warn } from '@mpxjs/utils'
|
|
39
39
|
import useInnerProps, { getCustomEvent } from './getInnerListeners'
|
|
40
40
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
41
|
-
import { splitProps, splitStyle, useTransformStyle, useLayout, wrapChildren, flatGesture, GestureHandler } from './utils'
|
|
41
|
+
import { splitProps, splitStyle, useTransformStyle, useLayout, wrapChildren, extendObject, flatGesture, GestureHandler } from './utils'
|
|
42
42
|
import { IntersectionObserverContext } from './context'
|
|
43
43
|
|
|
44
44
|
interface ScrollViewProps {
|
|
@@ -176,10 +176,11 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
176
176
|
setHeight
|
|
177
177
|
} = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
|
|
178
178
|
|
|
179
|
-
const { textStyle, innerStyle } = splitStyle(normalStyle)
|
|
179
|
+
const { textStyle, innerStyle = {} } = splitStyle(normalStyle)
|
|
180
180
|
|
|
181
181
|
const scrollViewRef = useAnimatedRef<ScrollView>()
|
|
182
182
|
useNodesRef(props, ref, scrollViewRef, {
|
|
183
|
+
style: normalStyle,
|
|
183
184
|
scrollOffset: scrollOptions,
|
|
184
185
|
node: {
|
|
185
186
|
scrollEnabled: scrollX || scrollY,
|
|
@@ -298,14 +299,13 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
298
299
|
const visibleLength = selectLength(e.nativeEvent.layoutMeasurement)
|
|
299
300
|
const contentLength = selectLength(e.nativeEvent.contentSize)
|
|
300
301
|
const offset = selectOffset(e.nativeEvent.contentOffset)
|
|
301
|
-
scrollOptions.current
|
|
302
|
-
...scrollOptions.current,
|
|
302
|
+
extendObject(scrollOptions.current, {
|
|
303
303
|
contentLength,
|
|
304
304
|
offset,
|
|
305
305
|
scrollLeft: position.scrollLeft,
|
|
306
306
|
scrollTop: position.scrollTop,
|
|
307
307
|
visibleLength
|
|
308
|
-
}
|
|
308
|
+
})
|
|
309
309
|
}
|
|
310
310
|
|
|
311
311
|
function onScroll (e: NativeSyntheticEvent<NativeScrollEvent>) {
|
|
@@ -426,34 +426,36 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
426
426
|
updateScrollOptions(e, { scrollLeft, scrollTop })
|
|
427
427
|
}
|
|
428
428
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
429
|
+
const scrollAdditionalProps: ScrollAdditionalProps = extendObject(
|
|
430
|
+
{
|
|
431
|
+
style: extendObject({}, innerStyle, layoutStyle),
|
|
432
|
+
pinchGestureEnabled: false,
|
|
433
|
+
horizontal: scrollX && !scrollY,
|
|
434
|
+
scrollEventThrottle: scrollEventThrottle,
|
|
435
|
+
scrollsToTop: enableBackToTop,
|
|
436
|
+
showsHorizontalScrollIndicator: scrollX && showScrollbar,
|
|
437
|
+
showsVerticalScrollIndicator: scrollY && showScrollbar,
|
|
438
|
+
scrollEnabled: scrollX || scrollY,
|
|
439
|
+
ref: scrollViewRef,
|
|
440
|
+
onScroll: onScroll,
|
|
441
|
+
onContentSizeChange: onContentSizeChange,
|
|
442
|
+
bindtouchstart: ((enhanced && binddragstart) || bindtouchstart) && onScrollTouchStart,
|
|
443
|
+
bindtouchmove: ((enhanced && binddragging) || bindtouchend) && onScrollTouchMove,
|
|
444
|
+
bindtouchend: ((enhanced && binddragend) || bindtouchend) && onScrollTouchEnd,
|
|
445
|
+
onScrollBeginDrag: onScrollDrag,
|
|
446
|
+
onScrollEndDrag: onScrollDrag,
|
|
447
|
+
onMomentumScrollEnd: onScrollEnd
|
|
448
|
+
},
|
|
449
|
+
(simultaneousHandlers ? { simultaneousHandlers } : {}),
|
|
450
|
+
(waitForHandlers ? { waitFor: waitForHandlers } : {}),
|
|
451
|
+
layoutProps
|
|
452
|
+
)
|
|
453
|
+
|
|
451
454
|
if (enhanced) {
|
|
452
|
-
scrollAdditionalProps
|
|
453
|
-
...scrollAdditionalProps,
|
|
455
|
+
Object.assign(scrollAdditionalProps, {
|
|
454
456
|
bounces,
|
|
455
457
|
pagingEnabled
|
|
456
|
-
}
|
|
458
|
+
})
|
|
457
459
|
}
|
|
458
460
|
|
|
459
461
|
const innerProps = useInnerProps(props, scrollAdditionalProps, [
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Text, TextProps } from 'react-native'
|
|
2
|
+
import { JSX, createElement } from 'react'
|
|
3
|
+
|
|
4
|
+
import { extendObject } from './utils'
|
|
5
|
+
|
|
6
|
+
const _Text2 = (props: TextProps): JSX.Element => {
|
|
7
|
+
const {
|
|
8
|
+
allowFontScaling = false
|
|
9
|
+
} = props
|
|
10
|
+
|
|
11
|
+
return createElement(Text, extendObject({}, props, {
|
|
12
|
+
allowFontScaling
|
|
13
|
+
}))
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
_Text2.displayName = 'MpxSimpleText'
|
|
17
|
+
|
|
18
|
+
export default _Text2
|
|
@@ -57,7 +57,7 @@ const _Carouse = forwardRef<HandlerRef<ScrollView & View, CarouseProps>, Carouse
|
|
|
57
57
|
parentWidth,
|
|
58
58
|
parentHeight
|
|
59
59
|
} = props
|
|
60
|
-
// 计算
|
|
60
|
+
// 计算transform之类的
|
|
61
61
|
const {
|
|
62
62
|
normalStyle,
|
|
63
63
|
hasVarDec,
|
|
@@ -92,7 +92,9 @@ const _Carouse = forwardRef<HandlerRef<ScrollView & View, CarouseProps>, Carouse
|
|
|
92
92
|
// 内部存储上一次的offset值
|
|
93
93
|
const autoplayTimerRef = useRef<ReturnType <typeof setTimeout> | null>(null)
|
|
94
94
|
const scrollViewRef = useRef<ScrollView & View>(null)
|
|
95
|
-
useNodesRef<ScrollView & View, CarouseProps>(props, ref, scrollViewRef, {
|
|
95
|
+
useNodesRef<ScrollView & View, CarouseProps>(props, ref, scrollViewRef, {
|
|
96
|
+
style: normalStyle
|
|
97
|
+
})
|
|
96
98
|
const {
|
|
97
99
|
// 存储layout布局信息
|
|
98
100
|
layoutRef,
|
|
@@ -18,7 +18,6 @@ interface SwiperItemProps {
|
|
|
18
18
|
|
|
19
19
|
const _SwiperItem = forwardRef<HandlerRef<View, SwiperItemProps>, SwiperItemProps>((props: SwiperItemProps, ref) => {
|
|
20
20
|
const {
|
|
21
|
-
'enable-offset': enableOffset,
|
|
22
21
|
'enable-var': enableVar,
|
|
23
22
|
'external-var-context': externalVarContext,
|
|
24
23
|
style
|
|
@@ -26,7 +25,6 @@ const _SwiperItem = forwardRef<HandlerRef<View, SwiperItemProps>, SwiperItemProp
|
|
|
26
25
|
|
|
27
26
|
const { textProps } = splitProps(props)
|
|
28
27
|
const nodeRef = useRef(null)
|
|
29
|
-
useNodesRef(props, ref, nodeRef, {})
|
|
30
28
|
|
|
31
29
|
const {
|
|
32
30
|
normalStyle,
|
|
@@ -37,6 +35,9 @@ const _SwiperItem = forwardRef<HandlerRef<View, SwiperItemProps>, SwiperItemProp
|
|
|
37
35
|
setHeight
|
|
38
36
|
} = useTransformStyle(style, { enableVar, externalVarContext })
|
|
39
37
|
const { textStyle, innerStyle } = splitStyle(normalStyle)
|
|
38
|
+
useNodesRef(props, ref, nodeRef, {
|
|
39
|
+
style: normalStyle
|
|
40
|
+
})
|
|
40
41
|
|
|
41
42
|
const {
|
|
42
43
|
// 存储layout布局信息
|