@mpxjs/webpack-plugin 2.10.14-beta.12 → 2.10.14-beta.14

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.
@@ -12,6 +12,7 @@ export type KeyboardAvoidContextValue = MutableRefObject<{
12
12
  adjustPosition: boolean
13
13
  keyboardHeight?: number
14
14
  onKeyboardShow?: () => void
15
+ readyToShow?: boolean
15
16
  } | null>
16
17
 
17
18
  export interface GroupValue {
@@ -9,6 +9,7 @@ export type KeyboardAvoidContextValue = MutableRefObject<{
9
9
  adjustPosition: boolean;
10
10
  keyboardHeight?: number;
11
11
  onKeyboardShow?: () => void;
12
+ readyToShow?: boolean;
12
13
  } | null>;
13
14
  export interface GroupValue {
14
15
  [key: string]: {
@@ -52,7 +52,7 @@ const inputModeMap = {
52
52
  digit: 'decimal'
53
53
  };
54
54
  const Input = forwardRef((props, ref) => {
55
- const { style = {}, allowFontScaling = false, type = 'text', value, password, 'placeholder-style': placeholderStyle = {}, disabled, maxlength = 140, 'cursor-spacing': cursorSpacing = 0, 'auto-focus': autoFocus, focus, 'confirm-type': confirmType = 'done', 'confirm-hold': confirmHold = false, cursor, 'cursor-color': cursorColor, 'selection-start': selectionStart = -1, 'selection-end': selectionEnd = -1, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, 'adjust-position': adjustPosition = true, 'keyboard-type': originalKeyboardType, bindinput, bindfocus, bindblur, bindconfirm, bindselectionchange,
55
+ const { style = {}, allowFontScaling = false, type = 'text', value, password, 'placeholder-style': placeholderStyle = {}, disabled, maxlength = 140, 'cursor-spacing': cursorSpacing = 0, 'auto-focus': autoFocus, focus, 'confirm-type': confirmType = 'done', 'confirm-hold': confirmHold = true, cursor, 'cursor-color': cursorColor, 'selection-start': selectionStart = -1, 'selection-end': selectionEnd = -1, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, 'adjust-position': adjustPosition = true, 'keyboard-type': originalKeyboardType, bindinput, bindfocus, bindblur, bindconfirm, bindselectionchange,
56
56
  // private
57
57
  multiline, 'auto-height': autoHeight, bindlinechange } = props;
58
58
  const formContext = useContext(FormContext);
@@ -144,7 +144,7 @@ const Input = forwardRef((props, ref) => {
144
144
  };
145
145
  const setKeyboardAvoidContext = () => {
146
146
  if (keyboardAvoid) {
147
- keyboardAvoid.current = { cursorSpacing, ref: nodeRef, adjustPosition };
147
+ keyboardAvoid.current = { cursorSpacing, ref: nodeRef, adjustPosition, readyToShow: true };
148
148
  }
149
149
  };
150
150
  const onTouchStart = () => {
@@ -280,7 +280,7 @@ const Input = forwardRef((props, ref) => {
280
280
  autoFocus: !!autoFocus || !!focus,
281
281
  selection: selectionStart > -1 || typeof cursor === 'number' ? selection : undefined,
282
282
  selectionColor: cursorColor,
283
- blurOnSubmit: !multiline && !confirmHold,
283
+ blurOnSubmit: multiline ? confirmType !== 'return' : confirmHold,
284
284
  underlineColorAndroid: 'rgba(0,0,0,0)',
285
285
  textAlignVertical: textAlignVertical,
286
286
  placeholderTextColor: placeholderStyle?.color,
@@ -292,7 +292,7 @@ const Input = forwardRef((props, ref) => {
292
292
  onChange,
293
293
  onSelectionChange,
294
294
  onContentSizeChange,
295
- onSubmitEditing: bindconfirm && !multiline && onSubmitEditing
295
+ onSubmitEditing: bindconfirm && onSubmitEditing
296
296
  }, !!multiline && confirmType === 'return' ? {} : { enterKeyHint: confirmType }), [
297
297
  'type',
298
298
  'password',
@@ -28,8 +28,9 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
28
28
  timerRef.current && clearTimeout(timerRef.current);
29
29
  if (keyboardAvoid?.current) {
30
30
  const inputRef = keyboardAvoid.current.ref?.current;
31
- if (inputRef && inputRef.isFocused()) {
31
+ if (inputRef && inputRef.isFocused() && !keyboardAvoid.current.readyToShow) {
32
32
  // 修复 Android 点击键盘收起按钮时当前 input 没触发失焦的问题
33
+ // keyboardAvoid.current.readyToShow = true 表示聚焦到了新的输入框,不需要手动触发失焦
33
34
  inputRef.blur();
34
35
  }
35
36
  if (!keyboardAvoid.current.onKeyboardShow) {
@@ -48,6 +49,10 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
48
49
  useEffect(() => {
49
50
  let subscriptions = [];
50
51
  function keybaordAvoding(evt, ios = false) {
52
+ if (keyboardAvoid?.current?.readyToShow) {
53
+ // 重置标记位
54
+ keyboardAvoid.current.readyToShow = false;
55
+ }
51
56
  if (!keyboardAvoid?.current || isShow.current) {
52
57
  return;
53
58
  }
@@ -4,6 +4,7 @@
4
4
  * type, password, confirm-hold
5
5
  * Addition:
6
6
  * ✔ confirm-type
7
+ * ✘ confirm-hold
7
8
  * ✔ auto-height
8
9
  * ✘ fixed
9
10
  * ✘ show-confirm-bar
@@ -141,7 +141,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
141
141
  'auto-focus': autoFocus,
142
142
  focus,
143
143
  'confirm-type': confirmType = 'done',
144
- 'confirm-hold': confirmHold = false,
144
+ 'confirm-hold': confirmHold = true,
145
145
  cursor,
146
146
  'cursor-color': cursorColor,
147
147
  'selection-start': selectionStart = -1,
@@ -283,7 +283,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
283
283
 
284
284
  const setKeyboardAvoidContext = () => {
285
285
  if (keyboardAvoid) {
286
- keyboardAvoid.current = { cursorSpacing, ref: nodeRef, adjustPosition }
286
+ keyboardAvoid.current = { cursorSpacing, ref: nodeRef, adjustPosition, readyToShow: true }
287
287
  }
288
288
  }
289
289
 
@@ -471,7 +471,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
471
471
  autoFocus: !!autoFocus || !!focus,
472
472
  selection: selectionStart > -1 || typeof cursor === 'number' ? selection : undefined,
473
473
  selectionColor: cursorColor,
474
- blurOnSubmit: !multiline && !confirmHold,
474
+ blurOnSubmit: multiline ? confirmType !== 'return' : confirmHold,
475
475
  underlineColorAndroid: 'rgba(0,0,0,0)',
476
476
  textAlignVertical: textAlignVertical,
477
477
  placeholderTextColor: placeholderStyle?.color,
@@ -483,7 +483,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
483
483
  onChange,
484
484
  onSelectionChange,
485
485
  onContentSizeChange,
486
- onSubmitEditing: bindconfirm && !multiline && onSubmitEditing
486
+ onSubmitEditing: bindconfirm && onSubmitEditing
487
487
  },
488
488
  !!multiline && confirmType === 'return' ? {} : { enterKeyHint: confirmType }
489
489
  ),
@@ -41,8 +41,9 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
41
41
 
42
42
  if (keyboardAvoid?.current) {
43
43
  const inputRef = keyboardAvoid.current.ref?.current
44
- if (inputRef && inputRef.isFocused()) {
44
+ if (inputRef && inputRef.isFocused() && !keyboardAvoid.current.readyToShow) {
45
45
  // 修复 Android 点击键盘收起按钮时当前 input 没触发失焦的问题
46
+ // keyboardAvoid.current.readyToShow = true 表示聚焦到了新的输入框,不需要手动触发失焦
46
47
  inputRef.blur()
47
48
  }
48
49
  if (!keyboardAvoid.current.onKeyboardShow) {
@@ -65,6 +66,10 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
65
66
  let subscriptions: EmitterSubscription[] = []
66
67
 
67
68
  function keybaordAvoding(evt: any, ios = false) {
69
+ if (keyboardAvoid?.current?.readyToShow) {
70
+ // 重置标记位
71
+ keyboardAvoid.current.readyToShow = false
72
+ }
68
73
  if (!keyboardAvoid?.current || isShow.current) {
69
74
  return
70
75
  }
@@ -4,6 +4,7 @@
4
4
  * type, password, confirm-hold
5
5
  * Addition:
6
6
  * ✔ confirm-type
7
+ * ✘ confirm-hold
7
8
  * ✔ auto-height
8
9
  * ✘ fixed
9
10
  * ✘ show-confirm-bar
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.10.14-beta.12",
3
+ "version": "2.10.14-beta.14",
4
4
  "description": "mpx compile core",
5
5
  "keywords": [
6
6
  "mpx"