@mpxjs/webpack-plugin 2.10.1-beta.7 → 2.10.2
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/lib/config.js +1 -2
- package/lib/index.js +12 -2
- package/lib/platform/json/wx/index.js +3 -6
- package/lib/platform/style/wx/index.js +12 -23
- package/lib/platform/template/wx/component-config/button.js +2 -19
- package/lib/platform/template/wx/component-config/canvas.js +0 -4
- package/lib/platform/template/wx/component-config/checkbox-group.js +0 -4
- package/lib/platform/template/wx/component-config/checkbox.js +0 -4
- package/lib/platform/template/wx/component-config/cover-image.js +1 -7
- package/lib/platform/template/wx/component-config/cover-view.js +0 -4
- package/lib/platform/template/wx/component-config/fix-component-name.js +2 -3
- package/lib/platform/template/wx/component-config/form.js +1 -7
- package/lib/platform/template/wx/component-config/icon.js +0 -4
- package/lib/platform/template/wx/component-config/image.js +1 -7
- package/lib/platform/template/wx/component-config/input.js +3 -18
- package/lib/platform/template/wx/component-config/label.js +0 -4
- package/lib/platform/template/wx/component-config/movable-area.js +1 -7
- package/lib/platform/template/wx/component-config/movable-view.js +3 -12
- package/lib/platform/template/wx/component-config/navigator.js +0 -4
- package/lib/platform/template/wx/component-config/picker-view-column.js +0 -4
- package/lib/platform/template/wx/component-config/picker-view.js +1 -7
- package/lib/platform/template/wx/component-config/picker.js +1 -7
- package/lib/platform/template/wx/component-config/radio-group.js +0 -4
- package/lib/platform/template/wx/component-config/radio.js +0 -4
- package/lib/platform/template/wx/component-config/rich-text.js +0 -4
- package/lib/platform/template/wx/component-config/root-portal.js +0 -4
- package/lib/platform/template/wx/component-config/scroll-view.js +2 -10
- package/lib/platform/template/wx/component-config/swiper-item.js +1 -7
- package/lib/platform/template/wx/component-config/swiper.js +3 -12
- package/lib/platform/template/wx/component-config/switch.js +0 -4
- package/lib/platform/template/wx/component-config/text.js +1 -7
- package/lib/platform/template/wx/component-config/textarea.js +3 -18
- package/lib/platform/template/wx/component-config/unsupported.js +0 -7
- package/lib/platform/template/wx/component-config/video.js +2 -10
- package/lib/platform/template/wx/component-config/view.js +1 -7
- package/lib/platform/template/wx/component-config/web-view.js +0 -4
- package/lib/platform/template/wx/index.js +13 -32
- package/lib/react/processScript.js +2 -2
- package/lib/runtime/components/react/KeyboardAvoidingView.tsx +30 -18
- package/lib/runtime/components/react/context.ts +3 -4
- package/lib/runtime/components/react/dist/KeyboardAvoidingView.jsx +23 -13
- package/lib/runtime/components/react/dist/mpx-image.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-input.jsx +54 -44
- package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +7 -4
- package/lib/runtime/components/react/dist/mpx-textarea.jsx +6 -6
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +4 -4
- package/lib/runtime/components/react/dist/utils.jsx +0 -15
- package/lib/runtime/components/react/mpx-image.tsx +2 -2
- package/lib/runtime/components/react/mpx-input.tsx +66 -54
- package/lib/runtime/components/react/mpx-picker-view-column.tsx +2 -2
- package/lib/runtime/components/react/mpx-scroll-view.tsx +8 -4
- package/lib/runtime/components/react/mpx-textarea.tsx +10 -6
- package/lib/runtime/components/react/mpx-web-view.tsx +4 -4
- package/lib/runtime/components/react/types/global.d.ts +1 -1
- package/lib/runtime/components/react/utils.tsx +1 -16
- package/lib/runtime/components/web/mini-video-controls.min.js +1 -1
- package/lib/template-compiler/compiler.js +3 -3
- package/lib/utils/env.js +1 -1
- package/package.json +4 -4
|
@@ -89,7 +89,7 @@ const _WebView = forwardRef((props, ref) => {
|
|
|
89
89
|
return null;
|
|
90
90
|
}
|
|
91
91
|
const _reload = function () {
|
|
92
|
-
if (__mpx_mode__ === 'android'
|
|
92
|
+
if (__mpx_mode__ === 'android') {
|
|
93
93
|
fristLoaded.current = false; // 安卓需要重新设置
|
|
94
94
|
}
|
|
95
95
|
setPageLoadErr(false);
|
|
@@ -133,7 +133,7 @@ const _WebView = forwardRef((props, ref) => {
|
|
|
133
133
|
}
|
|
134
134
|
};
|
|
135
135
|
const _onLoadProgress = function (event) {
|
|
136
|
-
if (__mpx_mode__ === 'android'
|
|
136
|
+
if (__mpx_mode__ === 'android') {
|
|
137
137
|
canGoBack.current = event.nativeEvent.canGoBack;
|
|
138
138
|
}
|
|
139
139
|
};
|
|
@@ -251,8 +251,8 @@ const _WebView = forwardRef((props, ref) => {
|
|
|
251
251
|
}
|
|
252
252
|
};
|
|
253
253
|
const onLoadEnd = function (res) {
|
|
254
|
-
|
|
255
|
-
|
|
254
|
+
if (__mpx_mode__ === 'android') {
|
|
255
|
+
res.persist();
|
|
256
256
|
setTimeout(() => {
|
|
257
257
|
onLoadEndHandle(res);
|
|
258
258
|
}, 0);
|
|
@@ -19,7 +19,6 @@ export const HIDDEN_STYLE = {
|
|
|
19
19
|
};
|
|
20
20
|
export const isIOS = __mpx_mode__ === 'ios';
|
|
21
21
|
export const isAndroid = __mpx_mode__ === 'android';
|
|
22
|
-
export const isHarmony = __mpx_mode__ === 'harmony';
|
|
23
22
|
const varDecRegExp = /^--/;
|
|
24
23
|
const varUseRegExp = /var\(/;
|
|
25
24
|
const unoVarDecRegExp = /^--un-/;
|
|
@@ -68,20 +67,6 @@ export const useUpdateEffect = (effect, deps) => {
|
|
|
68
67
|
}
|
|
69
68
|
}, deps);
|
|
70
69
|
};
|
|
71
|
-
/**
|
|
72
|
-
* 解析行内样式
|
|
73
|
-
* @param inlineStyle
|
|
74
|
-
* @returns
|
|
75
|
-
*/
|
|
76
|
-
export const parseInlineStyle = (inlineStyle = '') => {
|
|
77
|
-
return inlineStyle.split(';').reduce((styleObj, style) => {
|
|
78
|
-
const [k, v, ...rest] = style.split(':');
|
|
79
|
-
if (rest.length || !v || !k)
|
|
80
|
-
return styleObj;
|
|
81
|
-
const key = k.trim().replace(/-./g, c => c.substring(1).toUpperCase());
|
|
82
|
-
return extendObject(styleObj, { [key]: global.__formatValue(v.trim()) });
|
|
83
|
-
}, {});
|
|
84
|
-
};
|
|
85
70
|
export const parseUrl = (cssUrl = '') => {
|
|
86
71
|
if (!cssUrl)
|
|
87
72
|
return;
|
|
@@ -411,7 +411,7 @@ const Image = forwardRef<HandlerRef<RNImage, ImageProps>, ImageProps>((props, re
|
|
|
411
411
|
onLayout: onSvgLoad,
|
|
412
412
|
onError: binderror && onSvgError,
|
|
413
413
|
style: extendObject(
|
|
414
|
-
{ transformOrigin: 'top
|
|
414
|
+
{ transformOrigin: 'left top' },
|
|
415
415
|
modeStyle
|
|
416
416
|
)
|
|
417
417
|
})
|
|
@@ -426,7 +426,7 @@ const Image = forwardRef<HandlerRef<RNImage, ImageProps>, ImageProps>((props, re
|
|
|
426
426
|
onError: binderror && onImageError,
|
|
427
427
|
style: extendObject(
|
|
428
428
|
{
|
|
429
|
-
transformOrigin: 'top
|
|
429
|
+
transformOrigin: 'left top',
|
|
430
430
|
width: isCropMode ? imageWidth : '100%',
|
|
431
431
|
height: isCropMode ? imageHeight : '100%'
|
|
432
432
|
},
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* ✔ password
|
|
5
5
|
* ✔ placeholder
|
|
6
6
|
* - placeholder-style: Only support color.
|
|
7
|
-
*
|
|
7
|
+
* - placeholder-class: Only support color.
|
|
8
8
|
* ✔ disabled
|
|
9
9
|
* ✔ maxlength
|
|
10
10
|
* ✔ cursor-spacing
|
|
@@ -54,7 +54,7 @@ import {
|
|
|
54
54
|
TextInputSubmitEditingEventData
|
|
55
55
|
} from 'react-native'
|
|
56
56
|
import { warn } from '@mpxjs/utils'
|
|
57
|
-
import {
|
|
57
|
+
import { useUpdateEffect, useTransformStyle, useLayout, extendObject } from './utils'
|
|
58
58
|
import useInnerProps, { getCustomEvent } from './getInnerListeners'
|
|
59
59
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
60
60
|
import { FormContext, FormFieldValue, KeyboardAvoidContext } from './context'
|
|
@@ -73,6 +73,8 @@ type InputStyle = Omit<
|
|
|
73
73
|
|
|
74
74
|
type Type = 'text' | 'number' | 'idcard' | 'digit'
|
|
75
75
|
|
|
76
|
+
type ConfirmType = 'done' | 'send' | 'search' | 'next' | 'go' | 'return'
|
|
77
|
+
|
|
76
78
|
export interface InputProps {
|
|
77
79
|
name?: string
|
|
78
80
|
style?: InputStyle & Record<string, any>
|
|
@@ -85,13 +87,13 @@ export interface InputProps {
|
|
|
85
87
|
maxlength?: number
|
|
86
88
|
'auto-focus'?: boolean
|
|
87
89
|
focus?: boolean
|
|
88
|
-
'confirm-type'?:
|
|
90
|
+
'confirm-type'?: ConfirmType
|
|
89
91
|
'confirm-hold'?: boolean
|
|
90
92
|
cursor?: number
|
|
91
93
|
'cursor-color'?: string
|
|
92
94
|
'selection-start'?: number
|
|
93
95
|
'selection-end'?: number
|
|
94
|
-
'placeholder-style'?: string
|
|
96
|
+
'placeholder-style'?: { color?: string }
|
|
95
97
|
'enable-offset'?: boolean,
|
|
96
98
|
'enable-var'?: boolean
|
|
97
99
|
'external-var-context'?: Record<string, any>
|
|
@@ -133,7 +135,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
133
135
|
type = 'text',
|
|
134
136
|
value,
|
|
135
137
|
password,
|
|
136
|
-
'placeholder-style': placeholderStyle,
|
|
138
|
+
'placeholder-style': placeholderStyle = {},
|
|
137
139
|
disabled,
|
|
138
140
|
maxlength = 140,
|
|
139
141
|
'cursor-spacing': cursorSpacing = 0,
|
|
@@ -185,10 +187,9 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
185
187
|
|
|
186
188
|
const keyboardType = keyboardTypeMap[type]
|
|
187
189
|
const defaultValue = parseValue(value)
|
|
188
|
-
const placeholderTextColor = parseInlineStyle(placeholderStyle)?.color
|
|
189
190
|
const textAlignVertical = multiline ? 'top' : 'auto'
|
|
190
191
|
|
|
191
|
-
const tmpValue = useRef<string
|
|
192
|
+
const tmpValue = useRef<string>(defaultValue)
|
|
192
193
|
const cursorIndex = useRef<number>(0)
|
|
193
194
|
const lineCount = useRef<number>(0)
|
|
194
195
|
|
|
@@ -200,7 +201,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
200
201
|
{ padding: 0, backgroundColor: '#fff' },
|
|
201
202
|
style,
|
|
202
203
|
multiline && autoHeight
|
|
203
|
-
? { minHeight: Math.max((style as any)?.minHeight || 35, contentHeight) }
|
|
204
|
+
? { height: 'auto', minHeight: Math.max((style as any)?.minHeight || 35, contentHeight) }
|
|
204
205
|
: {}
|
|
205
206
|
)
|
|
206
207
|
|
|
@@ -232,55 +233,64 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
232
233
|
}
|
|
233
234
|
}, [cursor, selectionStart, selectionEnd])
|
|
234
235
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
236
|
+
// have not selection on the Android platformg
|
|
237
|
+
const getCursorIndex = (
|
|
238
|
+
changedSelection: TextInputSelectionChangeEventData['selection'] | undefined,
|
|
239
|
+
prevValue: string,
|
|
240
|
+
curValue: string
|
|
241
|
+
) => {
|
|
242
|
+
if (changedSelection) return changedSelection.end
|
|
243
|
+
if (!prevValue || !curValue || prevValue.length === curValue.length) return curValue.length
|
|
244
|
+
const prevStr = prevValue.substring(cursorIndex.current)
|
|
245
|
+
const curStr = curValue.substring(cursorIndex.current)
|
|
246
|
+
return cursorIndex.current + curStr.length - prevStr.length
|
|
242
247
|
}
|
|
243
248
|
|
|
244
|
-
const onChange = (evt: NativeSyntheticEvent<TextInputChangeEventData>) => {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
249
|
+
const onChange = (evt: NativeSyntheticEvent<TextInputChangeEventData & TextInputSelectionChangeEventData>) => {
|
|
250
|
+
const { text, selection } = evt.nativeEvent
|
|
251
|
+
// will trigger twice on the Android platformg, prevent the second trigger
|
|
252
|
+
if (tmpValue.current === text) return
|
|
253
|
+
const index = getCursorIndex(selection, tmpValue.current, text)
|
|
254
|
+
tmpValue.current = text
|
|
255
|
+
cursorIndex.current = index
|
|
256
|
+
if (bindinput) {
|
|
257
|
+
const result = bindinput(
|
|
258
|
+
getCustomEvent(
|
|
259
|
+
'input',
|
|
260
|
+
evt,
|
|
261
|
+
{
|
|
262
|
+
detail: {
|
|
263
|
+
value: tmpValue.current,
|
|
264
|
+
cursor: cursorIndex.current
|
|
265
|
+
},
|
|
266
|
+
layoutRef
|
|
255
267
|
},
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
props
|
|
268
|
+
props
|
|
269
|
+
)
|
|
259
270
|
)
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
271
|
+
if (typeof result === 'string') {
|
|
272
|
+
tmpValue.current = result
|
|
273
|
+
setInputValue(result)
|
|
274
|
+
} else {
|
|
275
|
+
setInputValue(tmpValue.current)
|
|
276
|
+
}
|
|
264
277
|
} else {
|
|
265
278
|
setInputValue(tmpValue.current)
|
|
266
279
|
}
|
|
267
280
|
}
|
|
268
281
|
|
|
269
282
|
const setKeyboardAvoidContext = () => {
|
|
270
|
-
if (adjustPosition && keyboardAvoid
|
|
271
|
-
|
|
272
|
-
cursorSpacing,
|
|
273
|
-
ref: nodeRef
|
|
274
|
-
})
|
|
283
|
+
if (adjustPosition && keyboardAvoid) {
|
|
284
|
+
keyboardAvoid.current = { cursorSpacing, ref: nodeRef }
|
|
275
285
|
}
|
|
276
286
|
}
|
|
277
287
|
|
|
278
|
-
const
|
|
288
|
+
const onTouchStart = () => {
|
|
279
289
|
// sometimes the focus event occurs later than the keyboardWillShow event
|
|
280
290
|
setKeyboardAvoidContext()
|
|
281
291
|
}
|
|
282
292
|
|
|
283
|
-
const
|
|
293
|
+
const onFocus = (evt: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
284
294
|
setKeyboardAvoidContext()
|
|
285
295
|
bindfocus && bindfocus(
|
|
286
296
|
getCustomEvent(
|
|
@@ -297,7 +307,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
297
307
|
)
|
|
298
308
|
}
|
|
299
309
|
|
|
300
|
-
const
|
|
310
|
+
const onBlur = (evt: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
301
311
|
bindblur && bindblur(
|
|
302
312
|
getCustomEvent(
|
|
303
313
|
'blur',
|
|
@@ -348,15 +358,18 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
348
358
|
}
|
|
349
359
|
|
|
350
360
|
const onSelectionChange = (evt: NativeSyntheticEvent<TextInputSelectionChangeEventData>) => {
|
|
351
|
-
|
|
361
|
+
const { selection } = evt.nativeEvent
|
|
362
|
+
const { start, end } = selection
|
|
363
|
+
cursorIndex.current = start
|
|
364
|
+
setSelection(selection)
|
|
352
365
|
bindselectionchange && bindselectionchange(
|
|
353
366
|
getCustomEvent(
|
|
354
367
|
'selectionchange',
|
|
355
368
|
evt,
|
|
356
369
|
{
|
|
357
370
|
detail: {
|
|
358
|
-
selectionStart:
|
|
359
|
-
selectionEnd:
|
|
371
|
+
selectionStart: start,
|
|
372
|
+
selectionEnd: end
|
|
360
373
|
},
|
|
361
374
|
layoutRef
|
|
362
375
|
},
|
|
@@ -444,26 +457,25 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
444
457
|
maxLength: maxlength === -1 ? undefined : maxlength,
|
|
445
458
|
editable: !disabled,
|
|
446
459
|
autoFocus: !!autoFocus || !!focus,
|
|
447
|
-
returnKeyType: confirmType,
|
|
448
460
|
selection: selection,
|
|
449
461
|
selectionColor: cursorColor,
|
|
450
462
|
blurOnSubmit: !multiline && !confirmHold,
|
|
451
463
|
underlineColorAndroid: 'rgba(0,0,0,0)',
|
|
452
464
|
textAlignVertical: textAlignVertical,
|
|
453
|
-
placeholderTextColor:
|
|
465
|
+
placeholderTextColor: placeholderStyle?.color,
|
|
454
466
|
multiline: !!multiline
|
|
455
467
|
},
|
|
468
|
+
!!multiline && confirmType === 'return' ? {} : { enterKeyHint: confirmType },
|
|
456
469
|
layoutProps,
|
|
457
470
|
{
|
|
458
|
-
onTouchStart
|
|
459
|
-
onFocus
|
|
460
|
-
onBlur
|
|
471
|
+
onTouchStart,
|
|
472
|
+
onFocus,
|
|
473
|
+
onBlur,
|
|
474
|
+
onChange,
|
|
475
|
+
onSelectionChange,
|
|
476
|
+
onContentSizeChange,
|
|
461
477
|
onKeyPress: bindconfirm && onKeyPress,
|
|
462
|
-
onSubmitEditing: bindconfirm && multiline && onSubmitEditing
|
|
463
|
-
onSelectionChange: onSelectionChange,
|
|
464
|
-
onTextInput: onTextInput,
|
|
465
|
-
onChange: onChange,
|
|
466
|
-
onContentSizeChange: onContentSizeChange
|
|
478
|
+
onSubmitEditing: bindconfirm && multiline && onSubmitEditing
|
|
467
479
|
}
|
|
468
480
|
),
|
|
469
481
|
[
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { forwardRef, useRef, useState, useMemo, useEffect, useCallback } from 'react'
|
|
2
2
|
import { LayoutChangeEvent, NativeScrollEvent, NativeSyntheticEvent, ScrollView, StyleSheet, View } from 'react-native'
|
|
3
3
|
import Reanimated, { AnimatedRef, useAnimatedRef, useScrollViewOffset } from 'react-native-reanimated'
|
|
4
|
-
import { useTransformStyle, splitStyle, splitProps, useLayout, usePrevious, isAndroid, isIOS
|
|
4
|
+
import { useTransformStyle, splitStyle, splitProps, useLayout, usePrevious, isAndroid, isIOS } from './utils'
|
|
5
5
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
6
6
|
import PickerIndicator from './pickerViewIndicator'
|
|
7
7
|
import PickerMask from './pickerViewMask'
|
|
@@ -140,7 +140,7 @@ const _PickerViewColumn = forwardRef<HandlerRef<ScrollView & View, ColumnProps>,
|
|
|
140
140
|
y: initialIndex * itemRawH,
|
|
141
141
|
animated: false
|
|
142
142
|
})
|
|
143
|
-
}, isAndroid
|
|
143
|
+
}, isAndroid ? 200 : 0)
|
|
144
144
|
activeIndex.current = initialIndex
|
|
145
145
|
}, [itemRawH, maxIndex, initialIndex])
|
|
146
146
|
|
|
@@ -124,7 +124,7 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
124
124
|
'paging-enabled': pagingEnabled = false,
|
|
125
125
|
'upper-threshold': upperThreshold = 50,
|
|
126
126
|
'lower-threshold': lowerThreshold = 50,
|
|
127
|
-
'scroll-with-animation': scrollWithAnimation,
|
|
127
|
+
'scroll-with-animation': scrollWithAnimation = false,
|
|
128
128
|
'refresher-enabled': refresherEnabled,
|
|
129
129
|
'refresher-default-style': refresherDefaultStyle,
|
|
130
130
|
'refresher-background': refresherBackground,
|
|
@@ -189,7 +189,7 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
189
189
|
pagingEnabled,
|
|
190
190
|
fastDeceleration: false,
|
|
191
191
|
decelerationDisabled: false,
|
|
192
|
-
scrollTo
|
|
192
|
+
scrollTo
|
|
193
193
|
},
|
|
194
194
|
gestureRef: scrollViewRef
|
|
195
195
|
})
|
|
@@ -236,6 +236,10 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
236
236
|
firstScrollIntoViewChange.current = true
|
|
237
237
|
}, [scrollIntoView])
|
|
238
238
|
|
|
239
|
+
function scrollTo ({ top = 0, left = 0, animated = false } : { top?: number; left?: number; animated?: boolean }) {
|
|
240
|
+
scrollToOffset(left, top, animated)
|
|
241
|
+
}
|
|
242
|
+
|
|
239
243
|
function handleScrollIntoView () {
|
|
240
244
|
const refs = __selectRef!(`#${scrollIntoView}`, 'node')
|
|
241
245
|
if (!refs) return
|
|
@@ -371,9 +375,9 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
371
375
|
}
|
|
372
376
|
}
|
|
373
377
|
}
|
|
374
|
-
function scrollToOffset (x = 0, y = 0) {
|
|
378
|
+
function scrollToOffset (x = 0, y = 0, animated = scrollWithAnimation) {
|
|
375
379
|
if (scrollViewRef.current) {
|
|
376
|
-
scrollViewRef.current.scrollTo({ x, y, animated
|
|
380
|
+
scrollViewRef.current.scrollTo({ x, y, animated })
|
|
377
381
|
scrollOptions.current.scrollLeft = x
|
|
378
382
|
scrollOptions.current.scrollTop = y
|
|
379
383
|
snapScrollLeft.current = x
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
* Subtraction:
|
|
4
4
|
* type, password, confirm-hold
|
|
5
5
|
* Addition:
|
|
6
|
-
*
|
|
6
|
+
* ✔ confirm-type
|
|
7
7
|
* ✔ auto-height
|
|
8
8
|
* ✘ fixed
|
|
9
9
|
* ✘ show-confirm-bar
|
|
10
10
|
* ✔ bindlinechange: No `heightRpx` info.
|
|
11
11
|
*/
|
|
12
12
|
import { JSX, forwardRef, createElement } from 'react'
|
|
13
|
-
import {
|
|
13
|
+
import { TextInput } from 'react-native'
|
|
14
14
|
import Input, { InputProps, PrivateInputProps } from './mpx-input'
|
|
15
15
|
import { omit, extendObject } from './utils'
|
|
16
16
|
import { HandlerRef } from './useNodesRef'
|
|
@@ -25,7 +25,10 @@ const DEFAULT_TEXTAREA_HEIGHT = 150
|
|
|
25
25
|
|
|
26
26
|
const Textarea = forwardRef<HandlerRef<TextInput, TextareProps>, TextareProps>(
|
|
27
27
|
(props, ref): JSX.Element => {
|
|
28
|
-
const {
|
|
28
|
+
const {
|
|
29
|
+
style = {},
|
|
30
|
+
'confirm-type': confirmType = 'return'
|
|
31
|
+
} = props
|
|
29
32
|
|
|
30
33
|
const restProps = omit(props, [
|
|
31
34
|
'ref',
|
|
@@ -33,16 +36,17 @@ const Textarea = forwardRef<HandlerRef<TextInput, TextareProps>, TextareProps>(
|
|
|
33
36
|
'style',
|
|
34
37
|
'password',
|
|
35
38
|
'multiline',
|
|
39
|
+
'confirm-type',
|
|
36
40
|
'confirm-hold'
|
|
37
41
|
])
|
|
38
42
|
|
|
39
43
|
return createElement(
|
|
40
44
|
Input,
|
|
41
45
|
extendObject(restProps, {
|
|
42
|
-
ref
|
|
46
|
+
ref,
|
|
47
|
+
confirmType,
|
|
43
48
|
multiline: true,
|
|
44
|
-
|
|
45
|
-
bindblur: () => Keyboard.dismiss(),
|
|
49
|
+
'confirm-type': confirmType,
|
|
46
50
|
style: extendObject({
|
|
47
51
|
width: DEFAULT_TEXTAREA_WIDTH,
|
|
48
52
|
height: DEFAULT_TEXTAREA_HEIGHT
|
|
@@ -140,7 +140,7 @@ const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((pr
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
const _reload = function () {
|
|
143
|
-
if (__mpx_mode__ === 'android'
|
|
143
|
+
if (__mpx_mode__ === 'android') {
|
|
144
144
|
fristLoaded.current = false // 安卓需要重新设置
|
|
145
145
|
}
|
|
146
146
|
setPageLoadErr(false)
|
|
@@ -186,7 +186,7 @@ const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((pr
|
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
const _onLoadProgress = function (event: WebViewProgressEvent) {
|
|
189
|
-
if (__mpx_mode__ === 'android'
|
|
189
|
+
if (__mpx_mode__ === 'android') {
|
|
190
190
|
canGoBack.current = event.nativeEvent.canGoBack
|
|
191
191
|
}
|
|
192
192
|
}
|
|
@@ -302,8 +302,8 @@ const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((pr
|
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
304
|
const onLoadEnd = function (res: WebViewEvent) {
|
|
305
|
-
|
|
306
|
-
|
|
305
|
+
if (__mpx_mode__ === 'android') {
|
|
306
|
+
res.persist()
|
|
307
307
|
setTimeout(() => {
|
|
308
308
|
onLoadEndHandle(res)
|
|
309
309
|
}, 0)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare let __mpx_mode__: 'wx' | 'ali' | 'swan' | 'qq' | 'tt' | 'web' | 'dd' | 'qa' | 'jd' | 'android' | 'ios'
|
|
1
|
+
declare let __mpx_mode__: 'wx' | 'ali' | 'swan' | 'qq' | 'tt' | 'web' | 'dd' | 'qa' | 'jd' | 'android' | 'ios'
|
|
2
2
|
declare module '@mpxjs/utils' {
|
|
3
3
|
export function isEmptyObject (obj: Object): boolean
|
|
4
4
|
export function isFunction (fn: unknown): boolean
|
|
@@ -20,11 +20,10 @@ export const HIDDEN_STYLE = {
|
|
|
20
20
|
opacity: 0
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
declare const __mpx_mode__: 'ios' | 'android'
|
|
23
|
+
declare const __mpx_mode__: 'ios' | 'android'
|
|
24
24
|
|
|
25
25
|
export const isIOS = __mpx_mode__ === 'ios'
|
|
26
26
|
export const isAndroid = __mpx_mode__ === 'android'
|
|
27
|
-
export const isHarmony = __mpx_mode__ === 'harmony'
|
|
28
27
|
|
|
29
28
|
const varDecRegExp = /^--/
|
|
30
29
|
const varUseRegExp = /var\(/
|
|
@@ -81,20 +80,6 @@ export const useUpdateEffect = (effect: any, deps: any) => {
|
|
|
81
80
|
}, deps)
|
|
82
81
|
}
|
|
83
82
|
|
|
84
|
-
/**
|
|
85
|
-
* 解析行内样式
|
|
86
|
-
* @param inlineStyle
|
|
87
|
-
* @returns
|
|
88
|
-
*/
|
|
89
|
-
export const parseInlineStyle = (inlineStyle = ''): Record<string, string> => {
|
|
90
|
-
return inlineStyle.split(';').reduce((styleObj, style) => {
|
|
91
|
-
const [k, v, ...rest] = style.split(':')
|
|
92
|
-
if (rest.length || !v || !k) return styleObj
|
|
93
|
-
const key = k.trim().replace(/-./g, c => c.substring(1).toUpperCase())
|
|
94
|
-
return extendObject(styleObj, { [key]: global.__formatValue(v.trim()) })
|
|
95
|
-
}, {})
|
|
96
|
-
}
|
|
97
|
-
|
|
98
83
|
export const parseUrl = (cssUrl = '') => {
|
|
99
84
|
if (!cssUrl) return
|
|
100
85
|
const match = cssUrl.match(URL_REGEX)
|