@mpxjs/webpack-plugin 2.9.70-alpha.0 → 2.9.71
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/LICENSE +433 -0
- package/README.md +1 -1
- package/lib/config.js +0 -14
- package/lib/dependencies/ResolveDependency.js +0 -5
- package/lib/index.js +7 -38
- package/lib/json-compiler/helper.js +3 -3
- package/lib/loader.js +0 -53
- 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/button.js +2 -14
- package/lib/platform/template/wx/component-config/fix-component-name.js +15 -12
- package/lib/platform/template/wx/component-config/image.js +0 -4
- package/lib/platform/template/wx/component-config/index.js +1 -1
- package/lib/platform/template/wx/component-config/input.js +0 -4
- package/lib/platform/template/wx/component-config/movable-view.js +8 -1
- package/lib/platform/template/wx/component-config/picker-view.js +1 -5
- package/lib/platform/template/wx/component-config/rich-text.js +6 -2
- package/lib/platform/template/wx/component-config/scroll-view.js +1 -5
- package/lib/platform/template/wx/component-config/switch.js +0 -4
- package/lib/platform/template/wx/component-config/text.js +0 -4
- package/lib/platform/template/wx/component-config/textarea.js +0 -5
- package/lib/platform/template/wx/component-config/unsupported.js +1 -1
- package/lib/platform/template/wx/component-config/view.js +0 -4
- package/lib/platform/template/wx/index.js +1 -131
- package/lib/resolve-loader.js +1 -4
- package/lib/runtime/components/react/context.ts +8 -0
- package/lib/runtime/components/react/dist/context.js +2 -0
- package/lib/runtime/components/react/dist/getInnerListeners.js +39 -37
- package/lib/runtime/components/react/dist/mpx-button.jsx +16 -44
- package/lib/runtime/components/react/dist/mpx-canvas/html.js +2 -4
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +5 -1
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +93 -58
- package/lib/runtime/components/react/dist/mpx-navigator.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column-item.jsx +10 -14
- package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +94 -81
- package/lib/runtime/components/react/dist/mpx-picker-view.jsx +19 -16
- package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +10 -11
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +11 -4
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +31 -8
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +435 -371
- package/lib/runtime/components/react/dist/mpx-view.jsx +18 -53
- package/lib/runtime/components/react/dist/pickerFaces.js +3 -8
- package/lib/runtime/components/react/dist/pickerVIewContext.js +5 -0
- package/lib/runtime/components/react/dist/{pickerViewOverlay.jsx → pickerViewIndicator.jsx} +6 -6
- package/lib/runtime/components/react/dist/pickerViewMask.jsx +2 -2
- package/lib/runtime/components/react/dist/useAnimationHooks.js +27 -10
- package/lib/runtime/components/react/dist/utils.jsx +162 -70
- package/lib/runtime/components/react/event.config.ts +25 -26
- package/lib/runtime/components/react/getInnerListeners.ts +236 -182
- package/lib/runtime/components/react/mpx-button.tsx +27 -69
- package/lib/runtime/components/react/mpx-canvas/html.ts +2 -4
- package/lib/runtime/components/react/mpx-canvas/index.tsx +44 -46
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +15 -13
- package/lib/runtime/components/react/mpx-checkbox.tsx +20 -21
- package/lib/runtime/components/react/mpx-form.tsx +15 -20
- package/lib/runtime/components/react/mpx-icon.tsx +2 -2
- package/lib/runtime/components/react/mpx-image.tsx +87 -47
- package/lib/runtime/components/react/mpx-input.tsx +24 -32
- package/lib/runtime/components/react/mpx-label.tsx +12 -14
- package/lib/runtime/components/react/mpx-movable-area.tsx +10 -16
- package/lib/runtime/components/react/mpx-movable-view.tsx +133 -92
- package/lib/runtime/components/react/mpx-navigator.tsx +3 -9
- package/lib/runtime/components/react/mpx-picker-view-column-item.tsx +76 -0
- package/lib/runtime/components/react/mpx-picker-view-column.tsx +206 -183
- package/lib/runtime/components/react/mpx-picker-view.tsx +49 -48
- package/lib/runtime/components/react/mpx-radio-group.tsx +13 -15
- package/lib/runtime/components/react/mpx-radio.tsx +19 -25
- package/lib/runtime/components/react/mpx-rich-text/html.ts +40 -0
- package/lib/runtime/components/react/mpx-rich-text/index.tsx +115 -0
- package/lib/runtime/components/react/mpx-root-portal.tsx +3 -5
- package/lib/runtime/components/react/mpx-scroll-view.tsx +53 -43
- package/lib/runtime/components/react/mpx-swiper-item.tsx +45 -11
- package/lib/runtime/components/react/mpx-swiper.tsx +742 -0
- package/lib/runtime/components/react/mpx-switch.tsx +19 -15
- package/lib/runtime/components/react/mpx-text.tsx +8 -16
- package/lib/runtime/components/react/mpx-textarea.tsx +11 -10
- package/lib/runtime/components/react/mpx-view.tsx +28 -77
- package/lib/runtime/components/react/mpx-web-view.tsx +94 -59
- package/lib/runtime/components/react/pickerFaces.ts +10 -7
- package/lib/runtime/components/react/pickerVIewContext.ts +27 -0
- package/lib/runtime/components/react/pickerViewIndicator.tsx +34 -0
- package/lib/runtime/components/react/pickerViewMask.tsx +30 -0
- package/lib/runtime/components/react/types/{getInnerListeners.ts → getInnerListeners.d.ts} +4 -5
- package/lib/runtime/components/react/types/global.d.ts +12 -1
- package/lib/runtime/components/react/useAnimationHooks.ts +60 -15
- package/lib/runtime/components/react/utils.tsx +175 -71
- package/lib/runtime/components/web/mpx-checkbox.vue +1 -1
- package/lib/runtime/components/web/mpx-picker-view-column.vue +9 -4
- package/lib/runtime/components/web/mpx-web-view.vue +34 -20
- package/lib/runtime/optionProcessor.js +0 -22
- package/lib/style-compiler/index.js +1 -1
- package/lib/style-compiler/plugins/scope-id.js +30 -2
- package/lib/template-compiler/compiler.js +91 -39
- package/lib/utils/env.js +1 -6
- package/lib/utils/pre-process-json.js +9 -5
- package/lib/wxss/loader.js +15 -2
- package/package.json +4 -7
- package/lib/dependencies/AddEntryDependency.js +0 -24
- package/lib/runtime/components/react/dist/types/common.js +0 -1
- package/lib/runtime/components/react/dist/types/getInnerListeners.js +0 -1
- package/lib/runtime/components/react/mpx-swiper/carouse.tsx +0 -527
- package/lib/runtime/components/react/mpx-swiper/index.tsx +0 -80
- package/lib/runtime/components/react/mpx-swiper/type.ts +0 -87
- package/lib/runtime/components/react/pickerOverlay.tsx +0 -32
- package/lib/runtime/components/tenon/getInnerListeners.js +0 -334
- package/lib/runtime/components/tenon/tenon-button.vue +0 -309
- package/lib/runtime/components/tenon/tenon-image.vue +0 -66
- package/lib/runtime/components/tenon/tenon-input.vue +0 -171
- package/lib/runtime/components/tenon/tenon-rich-text.vue +0 -26
- package/lib/runtime/components/tenon/tenon-scroll-view.vue +0 -127
- package/lib/runtime/components/tenon/tenon-switch.vue +0 -96
- package/lib/runtime/components/tenon/tenon-text.vue +0 -70
- package/lib/runtime/components/tenon/tenon-textarea.vue +0 -86
- package/lib/runtime/components/tenon/tenon-view.vue +0 -93
- package/lib/runtime/components/web/event.js +0 -105
- package/lib/runtime/optionProcessor.tenon.js +0 -84
- package/lib/style-compiler/plugins/hm.js +0 -20
- package/lib/tenon/index.js +0 -117
- package/lib/tenon/processJSON.js +0 -352
- package/lib/tenon/processScript.js +0 -203
- package/lib/tenon/processStyles.js +0 -21
- package/lib/tenon/processTemplate.js +0 -126
- package/lib/tenon/script-helper.js +0 -223
- package/lib/utils/get-relative-path.js +0 -25
- /package/lib/runtime/components/react/types/{common.ts → common.d.ts} +0 -0
|
@@ -316,8 +316,7 @@ var handleError = function (err, message) {
|
|
|
316
316
|
document.removeEventListener('message', handleIncomingMessage);
|
|
317
317
|
};
|
|
318
318
|
|
|
319
|
-
function handleIncomingMessage(
|
|
320
|
-
var data = JSON.parse(e.data);
|
|
319
|
+
function handleIncomingMessage(data) {
|
|
321
320
|
if (Array.isArray(data)) {
|
|
322
321
|
for (var i = 0; i < data.length; i++) {
|
|
323
322
|
try {
|
|
@@ -335,8 +334,7 @@ function handleIncomingMessage(e) {
|
|
|
335
334
|
}
|
|
336
335
|
}
|
|
337
336
|
|
|
338
|
-
window.
|
|
339
|
-
document.addEventListener('message', handleIncomingMessage);
|
|
337
|
+
window.mpxWebviewMessageCallback = handleIncomingMessage
|
|
340
338
|
</script>
|
|
341
339
|
|
|
342
340
|
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* ✔ bindlongtap
|
|
10
10
|
* ✔ binderror
|
|
11
11
|
*/
|
|
12
|
-
import React, { useRef, useState, useCallback, useEffect, forwardRef, JSX, TouchEvent, MutableRefObject } from 'react'
|
|
12
|
+
import React, { createElement, useRef, useState, useCallback, useEffect, forwardRef, JSX, TouchEvent, MutableRefObject } from 'react'
|
|
13
13
|
import { View, Platform, StyleSheet, NativeSyntheticEvent } from 'react-native'
|
|
14
14
|
import { WebView } from 'react-native-webview'
|
|
15
15
|
import useNodesRef, { HandlerRef } from '../useNodesRef'
|
|
@@ -106,7 +106,11 @@ const _Canvas = forwardRef<HandlerRef<CanvasProps & View, CanvasProps>, CanvasPr
|
|
|
106
106
|
useEffect(() => {
|
|
107
107
|
const webviewPostMessage = (message: WebviewMessage) => {
|
|
108
108
|
if (canvasRef.current.webview) {
|
|
109
|
-
|
|
109
|
+
const jsCode = `
|
|
110
|
+
window.mpxWebviewMessageCallback(${JSON.stringify(message)});
|
|
111
|
+
true;
|
|
112
|
+
`
|
|
113
|
+
canvasRef.current.webview.injectJavaScript(jsCode)
|
|
110
114
|
}
|
|
111
115
|
}
|
|
112
116
|
|
|
@@ -249,54 +253,48 @@ const _Canvas = forwardRef<HandlerRef<CanvasProps & View, CanvasProps>, CanvasPr
|
|
|
249
253
|
|
|
250
254
|
if (Platform.OS === 'android') {
|
|
251
255
|
const isAndroid9 = Platform.Version >= 28
|
|
252
|
-
return (
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
if (canvasRef.current) {
|
|
257
|
-
canvasRef.current.webview = element
|
|
258
|
-
}
|
|
259
|
-
}}
|
|
260
|
-
style={[
|
|
261
|
-
isAndroid9 ? stylesheet.webviewAndroid9 : stylesheet.webview,
|
|
262
|
-
{ height, width }
|
|
263
|
-
]}
|
|
264
|
-
source={{ html }}
|
|
265
|
-
originWhitelist={originWhitelist}
|
|
266
|
-
onMessage={onMessage}
|
|
267
|
-
onLoad={onLoad}
|
|
268
|
-
overScrollMode="never"
|
|
269
|
-
mixedContentMode="always"
|
|
270
|
-
scalesPageToFit={false}
|
|
271
|
-
javaScriptEnabled
|
|
272
|
-
domStorageEnabled
|
|
273
|
-
thirdPartyCookiesEnabled
|
|
274
|
-
allowUniversalAccessFromFileURLs
|
|
275
|
-
/>
|
|
276
|
-
</View>
|
|
277
|
-
)
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
return (
|
|
281
|
-
<View
|
|
282
|
-
{...innerProps}
|
|
283
|
-
>
|
|
284
|
-
<WebView
|
|
285
|
-
ref={(element) => {
|
|
256
|
+
return createElement(View, innerProps, createElement(
|
|
257
|
+
WebView,
|
|
258
|
+
{
|
|
259
|
+
ref: (element) => {
|
|
286
260
|
if (canvasRef.current) {
|
|
287
261
|
canvasRef.current.webview = element
|
|
288
262
|
}
|
|
289
|
-
}
|
|
290
|
-
style
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
263
|
+
},
|
|
264
|
+
style: [
|
|
265
|
+
isAndroid9 ? stylesheet.webviewAndroid9 : stylesheet.webview,
|
|
266
|
+
{ height, width }
|
|
267
|
+
],
|
|
268
|
+
source: { html },
|
|
269
|
+
originWhitelist: originWhitelist,
|
|
270
|
+
onMessage: onMessage,
|
|
271
|
+
onLoad: onLoad,
|
|
272
|
+
overScrollMode: 'never',
|
|
273
|
+
mixedContentMode: 'always',
|
|
274
|
+
scalesPageToFit: false,
|
|
275
|
+
javaScriptEnabled: true,
|
|
276
|
+
domStorageEnabled: true,
|
|
277
|
+
thirdPartyCookiesEnabled: true,
|
|
278
|
+
allowUniversalAccessFromFileURLs: true
|
|
279
|
+
})
|
|
280
|
+
)
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
return createElement(View, innerProps, createElement(WebView, {
|
|
284
|
+
ref: (element) => {
|
|
285
|
+
if (canvasRef.current) {
|
|
286
|
+
canvasRef.current.webview = element
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
style: [stylesheet.webview, { height, width }],
|
|
290
|
+
source: { html },
|
|
291
|
+
originWhitelist: originWhitelist,
|
|
292
|
+
onMessage: onMessage,
|
|
293
|
+
onLoad: onLoad,
|
|
294
|
+
scrollEnabled: false
|
|
295
|
+
}))
|
|
299
296
|
})
|
|
297
|
+
|
|
300
298
|
_Canvas.displayName = 'mpxCanvas'
|
|
301
299
|
|
|
302
300
|
export default _Canvas
|
|
@@ -8,7 +8,8 @@ import {
|
|
|
8
8
|
ReactNode,
|
|
9
9
|
useContext,
|
|
10
10
|
useMemo,
|
|
11
|
-
useEffect
|
|
11
|
+
useEffect,
|
|
12
|
+
createElement
|
|
12
13
|
} from 'react'
|
|
13
14
|
import {
|
|
14
15
|
View,
|
|
@@ -156,20 +157,21 @@ const CheckboxGroup = forwardRef<
|
|
|
156
157
|
notifyChange
|
|
157
158
|
}
|
|
158
159
|
}, [])
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
160
|
+
|
|
161
|
+
return createElement(
|
|
162
|
+
View,
|
|
163
|
+
innerProps,
|
|
164
|
+
createElement(
|
|
165
|
+
CheckboxGroupContext.Provider,
|
|
166
|
+
{ value: contextValue },
|
|
167
|
+
wrapChildren(
|
|
168
|
+
props,
|
|
162
169
|
{
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
{
|
|
166
|
-
hasVarDec,
|
|
167
|
-
varContext: varContextRef.current
|
|
168
|
-
}
|
|
169
|
-
)
|
|
170
|
+
hasVarDec,
|
|
171
|
+
varContext: varContextRef.current
|
|
170
172
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
+
)
|
|
174
|
+
)
|
|
173
175
|
)
|
|
174
176
|
})
|
|
175
177
|
|
|
@@ -13,7 +13,8 @@ import {
|
|
|
13
13
|
ReactNode,
|
|
14
14
|
useContext,
|
|
15
15
|
Dispatch,
|
|
16
|
-
SetStateAction
|
|
16
|
+
SetStateAction,
|
|
17
|
+
createElement
|
|
17
18
|
} from 'react'
|
|
18
19
|
import {
|
|
19
20
|
View,
|
|
@@ -206,28 +207,26 @@ const Checkbox = forwardRef<HandlerRef<View, CheckboxProps>, CheckboxProps>(
|
|
|
206
207
|
}
|
|
207
208
|
}, [checked])
|
|
208
209
|
|
|
209
|
-
return (
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
210
|
+
return createElement(View, innerProps,
|
|
211
|
+
createElement(
|
|
212
|
+
View,
|
|
213
|
+
{ style: defaultStyle },
|
|
214
|
+
createElement(Icon, {
|
|
215
|
+
type: 'success_no_circle',
|
|
216
|
+
size: 18,
|
|
217
|
+
color: disabled ? '#ADADAD' : color,
|
|
218
|
+
style: isChecked ? styles.iconChecked : styles.icon
|
|
219
|
+
})
|
|
220
|
+
),
|
|
221
|
+
wrapChildren(
|
|
222
|
+
props,
|
|
219
223
|
{
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
varContext: varContextRef.current,
|
|
225
|
-
textStyle,
|
|
226
|
-
textProps
|
|
227
|
-
}
|
|
228
|
-
)
|
|
224
|
+
hasVarDec,
|
|
225
|
+
varContext: varContextRef.current,
|
|
226
|
+
textStyle,
|
|
227
|
+
textProps
|
|
229
228
|
}
|
|
230
|
-
|
|
229
|
+
)
|
|
231
230
|
)
|
|
232
231
|
}
|
|
233
232
|
)
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* ✔ bindreset
|
|
6
6
|
*/
|
|
7
7
|
import { View } from 'react-native'
|
|
8
|
-
import { JSX, useRef, forwardRef, ReactNode, useMemo,
|
|
8
|
+
import { JSX, useRef, forwardRef, ReactNode, useMemo, createElement } from 'react'
|
|
9
9
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
10
10
|
import useInnerProps, { getCustomEvent } from './getInnerListeners'
|
|
11
11
|
import { FormContext } from './context'
|
|
@@ -102,25 +102,20 @@ const _Form = forwardRef<HandlerRef<View, FormProps>, FormProps>((fromProps: For
|
|
|
102
102
|
reset
|
|
103
103
|
}
|
|
104
104
|
}, [])
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
)
|
|
120
|
-
}
|
|
121
|
-
</FormContext.Provider>
|
|
122
|
-
</View>
|
|
123
|
-
)
|
|
105
|
+
|
|
106
|
+
return createElement(View, innerProps, createElement(
|
|
107
|
+
FormContext.Provider,
|
|
108
|
+
{ value: contextValue },
|
|
109
|
+
wrapChildren(
|
|
110
|
+
props,
|
|
111
|
+
{
|
|
112
|
+
hasVarDec,
|
|
113
|
+
varContext: varContextRef.current,
|
|
114
|
+
textStyle,
|
|
115
|
+
textProps
|
|
116
|
+
}
|
|
117
|
+
)
|
|
118
|
+
))
|
|
124
119
|
})
|
|
125
120
|
|
|
126
121
|
_Form.displayName = 'MpxForm'
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* ✔ size
|
|
4
4
|
* ✔ color
|
|
5
5
|
*/
|
|
6
|
-
import { JSX, forwardRef, useRef } from 'react'
|
|
6
|
+
import { JSX, forwardRef, useRef, createElement } from 'react'
|
|
7
7
|
import { Text, TextStyle, Image } from 'react-native'
|
|
8
8
|
import useInnerProps from './getInnerListeners'
|
|
9
9
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
@@ -93,7 +93,7 @@ const Icon = forwardRef<HandlerRef<Text, IconProps>, IconProps>(
|
|
|
93
93
|
}
|
|
94
94
|
)
|
|
95
95
|
|
|
96
|
-
return
|
|
96
|
+
return createElement(Image, innerProps)
|
|
97
97
|
}
|
|
98
98
|
)
|
|
99
99
|
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* ✔ bindtap
|
|
11
11
|
* ✔ DEFAULT_SIZE
|
|
12
12
|
*/
|
|
13
|
-
import { useEffect, useMemo, useState, useRef, forwardRef } from 'react'
|
|
13
|
+
import { useEffect, useMemo, useState, useRef, forwardRef, createElement } from 'react'
|
|
14
14
|
import {
|
|
15
15
|
Image as RNImage,
|
|
16
16
|
View,
|
|
@@ -22,10 +22,11 @@ import {
|
|
|
22
22
|
DimensionValue,
|
|
23
23
|
ImageLoadEventData
|
|
24
24
|
} from 'react-native'
|
|
25
|
+
import { noop } from '@mpxjs/utils'
|
|
25
26
|
import { SvgCssUri } from 'react-native-svg/css'
|
|
26
27
|
import useInnerProps, { getCustomEvent } from './getInnerListeners'
|
|
27
28
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
28
|
-
import { SVG_REGEXP, useLayout, useTransformStyle, extendObject } from './utils'
|
|
29
|
+
import { SVG_REGEXP, useLayout, useTransformStyle, renderImage, extendObject } from './utils'
|
|
29
30
|
|
|
30
31
|
export type Mode =
|
|
31
32
|
| 'scaleToFill'
|
|
@@ -54,10 +55,19 @@ export interface ImageProps {
|
|
|
54
55
|
'parent-font-size'?: number
|
|
55
56
|
'parent-width'?: number
|
|
56
57
|
'parent-height'?: number
|
|
58
|
+
'enable-fast-image'?: boolean
|
|
57
59
|
bindload?: (evt: NativeSyntheticEvent<ImageLoadEventData> | unknown) => void
|
|
58
60
|
binderror?: (evt: NativeSyntheticEvent<ImageErrorEventData> | unknown) => void
|
|
59
61
|
}
|
|
60
62
|
|
|
63
|
+
interface ImageState {
|
|
64
|
+
viewWidth?: number
|
|
65
|
+
viewHeight?: number
|
|
66
|
+
imageWidth?: number
|
|
67
|
+
imageHeight?: number
|
|
68
|
+
ratio?: number
|
|
69
|
+
}
|
|
70
|
+
|
|
61
71
|
const DEFAULT_IMAGE_WIDTH = 320
|
|
62
72
|
const DEFAULT_IMAGE_HEIGHT = 240
|
|
63
73
|
|
|
@@ -101,6 +111,7 @@ const Image = forwardRef<HandlerRef<RNImage, ImageProps>, ImageProps>((props, re
|
|
|
101
111
|
'enable-var': enableVar,
|
|
102
112
|
'external-var-context': externalVarContext,
|
|
103
113
|
'parent-font-size': parentFontSize,
|
|
114
|
+
'enable-fast-image': enableFastImage,
|
|
104
115
|
'parent-width': parentWidth,
|
|
105
116
|
'parent-height': parentHeight,
|
|
106
117
|
bindload,
|
|
@@ -119,23 +130,13 @@ const Image = forwardRef<HandlerRef<RNImage, ImageProps>, ImageProps>((props, re
|
|
|
119
130
|
{ overflow: 'hidden' }
|
|
120
131
|
)
|
|
121
132
|
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
const onLayout = ({ nativeEvent: { layout: { width, height } } }: LayoutChangeEvent) => {
|
|
125
|
-
setViewWidth(width)
|
|
126
|
-
setViewHeight(height)
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const { normalStyle, hasSelfPercent, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
|
|
133
|
+
const state = useRef<ImageState>({})
|
|
130
134
|
|
|
135
|
+
const nodeRef = useRef(null)
|
|
131
136
|
useNodesRef(props, ref, nodeRef, {
|
|
132
|
-
|
|
137
|
+
defaultStyle
|
|
133
138
|
})
|
|
134
139
|
|
|
135
|
-
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef, onLayout })
|
|
136
|
-
|
|
137
|
-
const { width, height } = normalStyle
|
|
138
|
-
|
|
139
140
|
const isSvg = SVG_REGEXP.test(src)
|
|
140
141
|
const isWidthFixMode = mode === 'widthFix'
|
|
141
142
|
const isHeightFixMode = mode === 'heightFix'
|
|
@@ -143,11 +144,40 @@ const Image = forwardRef<HandlerRef<RNImage, ImageProps>, ImageProps>((props, re
|
|
|
143
144
|
const isLayoutMode = isWidthFixMode || isHeightFixMode || isCropMode
|
|
144
145
|
const resizeMode: ImageResizeMode = ModeMap.get(mode) || 'stretch'
|
|
145
146
|
|
|
147
|
+
const onLayout = ({ nativeEvent: { layout: { width, height } } }: LayoutChangeEvent) => {
|
|
148
|
+
state.current.viewWidth = width
|
|
149
|
+
state.current.viewHeight = height
|
|
150
|
+
|
|
151
|
+
if (state.current.imageWidth && state.current.imageHeight && state.current.ratio) {
|
|
152
|
+
setViewWidth(width)
|
|
153
|
+
setViewHeight(height)
|
|
154
|
+
setRatio(state.current.ratio)
|
|
155
|
+
setImageWidth(state.current.imageWidth)
|
|
156
|
+
setImageHeight(state.current.imageHeight)
|
|
157
|
+
state.current = {}
|
|
158
|
+
setLoaded(true)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const { normalStyle, hasSelfPercent, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
|
|
163
|
+
|
|
164
|
+
const { layoutRef, layoutStyle, layoutProps } = useLayout({
|
|
165
|
+
props,
|
|
166
|
+
hasSelfPercent,
|
|
167
|
+
setWidth,
|
|
168
|
+
setHeight,
|
|
169
|
+
nodeRef,
|
|
170
|
+
onLayout: isLayoutMode ? onLayout : noop
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
const { width, height } = normalStyle
|
|
174
|
+
|
|
146
175
|
const [viewWidth, setViewWidth] = useState(isNumber(width) ? width : 0)
|
|
147
176
|
const [viewHeight, setViewHeight] = useState(isNumber(height) ? height : 0)
|
|
148
177
|
const [imageWidth, setImageWidth] = useState(0)
|
|
149
178
|
const [imageHeight, setImageHeight] = useState(0)
|
|
150
179
|
const [ratio, setRatio] = useState(0)
|
|
180
|
+
const [loaded, setLoaded] = useState(!isLayoutMode)
|
|
151
181
|
|
|
152
182
|
const fixedHeight = useMemo(() => {
|
|
153
183
|
const fixed = viewWidth * ratio
|
|
@@ -327,9 +357,23 @@ const Image = forwardRef<HandlerRef<RNImage, ImageProps>, ImageProps>((props, re
|
|
|
327
357
|
useEffect(() => {
|
|
328
358
|
if (!isSvg && isLayoutMode) {
|
|
329
359
|
RNImage.getSize(src, (width: number, height: number) => {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
360
|
+
state.current.imageWidth = width
|
|
361
|
+
state.current.imageHeight = height
|
|
362
|
+
state.current.ratio = !width ? 0 : height / width
|
|
363
|
+
|
|
364
|
+
if (isWidthFixMode
|
|
365
|
+
? state.current.viewWidth
|
|
366
|
+
: isHeightFixMode
|
|
367
|
+
? state.current.viewHeight
|
|
368
|
+
: state.current.viewWidth && state.current.viewHeight) {
|
|
369
|
+
state.current.viewWidth && setViewWidth(state.current.viewWidth)
|
|
370
|
+
state.current.viewHeight && setViewHeight(state.current.viewHeight)
|
|
371
|
+
setRatio(!width ? 0 : height / width)
|
|
372
|
+
setImageWidth(width)
|
|
373
|
+
setImageHeight(height)
|
|
374
|
+
state.current = {}
|
|
375
|
+
setLoaded(true)
|
|
376
|
+
}
|
|
333
377
|
})
|
|
334
378
|
}
|
|
335
379
|
}, [src, isSvg, isLayoutMode])
|
|
@@ -359,35 +403,31 @@ const Image = forwardRef<HandlerRef<RNImage, ImageProps>, ImageProps>((props, re
|
|
|
359
403
|
}
|
|
360
404
|
)
|
|
361
405
|
|
|
362
|
-
return (
|
|
363
|
-
|
|
364
|
-
{
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
)}
|
|
388
|
-
/>
|
|
389
|
-
}
|
|
390
|
-
</View>
|
|
406
|
+
return createElement(View, innerProps,
|
|
407
|
+
isSvg
|
|
408
|
+
? createElement(SvgCssUri, {
|
|
409
|
+
uri: src,
|
|
410
|
+
onLayout: onSvgLoad,
|
|
411
|
+
onError: binderror && onSvgError,
|
|
412
|
+
style: extendObject(
|
|
413
|
+
{ transformOrigin: 'top left' },
|
|
414
|
+
modeStyle
|
|
415
|
+
)
|
|
416
|
+
})
|
|
417
|
+
: loaded && renderImage({
|
|
418
|
+
source: { uri: src },
|
|
419
|
+
resizeMode: resizeMode,
|
|
420
|
+
onLoad: bindload && onImageLoad,
|
|
421
|
+
onError: binderror && onImageError,
|
|
422
|
+
style: extendObject(
|
|
423
|
+
{
|
|
424
|
+
transformOrigin: 'top left',
|
|
425
|
+
width: isCropMode ? imageWidth : '100%',
|
|
426
|
+
height: isCropMode ? imageHeight : '100%'
|
|
427
|
+
},
|
|
428
|
+
isCropMode ? modeStyle : {}
|
|
429
|
+
)
|
|
430
|
+
}, enableFastImage)
|
|
391
431
|
)
|
|
392
432
|
})
|
|
393
433
|
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
* ✘ bind:keyboardcompositionend
|
|
38
38
|
* ✘ bind:onkeyboardheightchange
|
|
39
39
|
*/
|
|
40
|
-
import { JSX, forwardRef, useMemo, useRef, useState, useContext, useEffect } from 'react'
|
|
40
|
+
import { JSX, forwardRef, useMemo, useRef, useState, useContext, useEffect, createElement } from 'react'
|
|
41
41
|
import {
|
|
42
42
|
KeyboardTypeOptions,
|
|
43
43
|
Platform,
|
|
@@ -187,7 +187,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
187
187
|
{ padding: 0, backgroundColor: '#fff' },
|
|
188
188
|
style,
|
|
189
189
|
multiline && autoHeight
|
|
190
|
-
? {
|
|
190
|
+
? { minHeight: Math.max((style as any)?.minHeight || 35, contentHeight) }
|
|
191
191
|
: {}
|
|
192
192
|
)
|
|
193
193
|
|
|
@@ -405,7 +405,22 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
405
405
|
{
|
|
406
406
|
ref: nodeRef,
|
|
407
407
|
style: extendObject({}, normalStyle, layoutStyle),
|
|
408
|
-
allowFontScaling
|
|
408
|
+
allowFontScaling,
|
|
409
|
+
keyboardType: keyboardType,
|
|
410
|
+
secureTextEntry: !!password,
|
|
411
|
+
defaultValue: defaultValue,
|
|
412
|
+
value: inputValue,
|
|
413
|
+
maxLength: maxlength === -1 ? undefined : maxlength,
|
|
414
|
+
editable: !disabled,
|
|
415
|
+
autoFocus: !!autoFocus || !!focus,
|
|
416
|
+
returnKeyType: confirmType,
|
|
417
|
+
selection: selection,
|
|
418
|
+
selectionColor: cursorColor,
|
|
419
|
+
blurOnSubmit: !multiline && !confirmHold,
|
|
420
|
+
underlineColorAndroid: 'rgba(0,0,0,0)',
|
|
421
|
+
textAlignVertical: textAlignVertical,
|
|
422
|
+
placeholderTextColor: placeholderTextColor,
|
|
423
|
+
multiline: !!multiline
|
|
409
424
|
},
|
|
410
425
|
layoutProps,
|
|
411
426
|
{
|
|
@@ -413,16 +428,17 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
413
428
|
onBlur: bindblur && onInputBlur,
|
|
414
429
|
onKeyPress: bindconfirm && onKeyPress,
|
|
415
430
|
onSubmitEditing: bindconfirm && multiline && onSubmitEditing,
|
|
416
|
-
onSelectionChange: bindselectionchange && onSelectionChange
|
|
431
|
+
onSelectionChange: bindselectionchange && onSelectionChange,
|
|
432
|
+
onTextInput: onTextInput,
|
|
433
|
+
onChange: onChange,
|
|
434
|
+
onContentSizeChange: onContentSizeChange
|
|
417
435
|
}
|
|
418
436
|
),
|
|
419
437
|
[
|
|
420
438
|
'type',
|
|
421
|
-
'keyboardType',
|
|
422
439
|
'password',
|
|
423
440
|
'placeholder-style',
|
|
424
441
|
'disabled',
|
|
425
|
-
'maxlength',
|
|
426
442
|
'auto-focus',
|
|
427
443
|
'focus',
|
|
428
444
|
'confirm-type',
|
|
@@ -430,37 +446,13 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
430
446
|
'cursor',
|
|
431
447
|
'cursor-color',
|
|
432
448
|
'selection-start',
|
|
433
|
-
'selection-end'
|
|
434
|
-
'multiline'
|
|
449
|
+
'selection-end'
|
|
435
450
|
],
|
|
436
451
|
{
|
|
437
452
|
layoutRef
|
|
438
453
|
}
|
|
439
454
|
)
|
|
440
|
-
|
|
441
|
-
return (
|
|
442
|
-
<TextInput
|
|
443
|
-
{...innerProps}
|
|
444
|
-
keyboardType={keyboardType as KeyboardTypeOptions}
|
|
445
|
-
secureTextEntry={!!password}
|
|
446
|
-
defaultValue={defaultValue}
|
|
447
|
-
value={inputValue}
|
|
448
|
-
maxLength={maxlength === -1 ? undefined : maxlength}
|
|
449
|
-
editable={!disabled}
|
|
450
|
-
autoFocus={!!autoFocus || !!focus}
|
|
451
|
-
returnKeyType={confirmType}
|
|
452
|
-
selection={selection}
|
|
453
|
-
selectionColor={cursorColor}
|
|
454
|
-
blurOnSubmit={!multiline && !confirmHold}
|
|
455
|
-
underlineColorAndroid="rgba(0,0,0,0)"
|
|
456
|
-
textAlignVertical={textAlignVertical}
|
|
457
|
-
placeholderTextColor={placeholderTextColor}
|
|
458
|
-
multiline={!!multiline}
|
|
459
|
-
onTextInput={onTextInput}
|
|
460
|
-
onChange={onChange}
|
|
461
|
-
onContentSizeChange={onContentSizeChange}
|
|
462
|
-
/>
|
|
463
|
-
)
|
|
455
|
+
return createElement(TextInput, innerProps)
|
|
464
456
|
})
|
|
465
457
|
|
|
466
458
|
Input.displayName = 'MpxInput'
|
|
@@ -1,7 +1,7 @@
|
|
|
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'
|
|
@@ -92,21 +92,19 @@ const Label = forwardRef<HandlerRef<View, LabelProps>, LabelProps>(
|
|
|
92
92
|
}
|
|
93
93
|
)
|
|
94
94
|
|
|
95
|
-
return
|
|
96
|
-
|
|
95
|
+
return createElement(View, innerProps, createElement(
|
|
96
|
+
LabelContext.Provider,
|
|
97
|
+
{ value: contextRef },
|
|
98
|
+
wrapChildren(
|
|
99
|
+
props,
|
|
97
100
|
{
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
varContext: varContextRef.current,
|
|
103
|
-
textStyle,
|
|
104
|
-
textProps
|
|
105
|
-
}
|
|
106
|
-
)
|
|
101
|
+
hasVarDec,
|
|
102
|
+
varContext: varContextRef.current,
|
|
103
|
+
textStyle,
|
|
104
|
+
textProps
|
|
107
105
|
}
|
|
108
|
-
|
|
109
|
-
|
|
106
|
+
)
|
|
107
|
+
))
|
|
110
108
|
}
|
|
111
109
|
)
|
|
112
110
|
|