@mpxjs/webpack-plugin 2.9.69 → 2.9.70

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/lib/parser.js +1 -1
  2. package/lib/platform/json/wx/index.js +21 -8
  3. package/lib/platform/style/wx/index.js +51 -54
  4. package/lib/platform/template/wx/component-config/fix-component-name.js +15 -12
  5. package/lib/platform/template/wx/component-config/index.js +1 -1
  6. package/lib/platform/template/wx/component-config/input.js +1 -1
  7. package/lib/platform/template/wx/component-config/rich-text.js +8 -0
  8. package/lib/platform/template/wx/component-config/swiper.js +1 -1
  9. package/lib/platform/template/wx/component-config/textarea.js +1 -1
  10. package/lib/platform/template/wx/component-config/unsupported.js +1 -1
  11. package/lib/react/processTemplate.js +3 -0
  12. package/lib/runtime/components/react/context.ts +4 -0
  13. package/lib/runtime/components/react/dist/context.js +1 -0
  14. package/lib/runtime/components/react/dist/event.config.js +24 -24
  15. package/lib/runtime/components/react/dist/getInnerListeners.js +183 -166
  16. package/lib/runtime/components/react/dist/mpx-button.jsx +35 -42
  17. package/lib/runtime/components/react/dist/mpx-canvas/html.js +2 -4
  18. package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +35 -13
  19. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +13 -19
  20. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +29 -38
  21. package/lib/runtime/components/react/dist/mpx-form.jsx +16 -19
  22. package/lib/runtime/components/react/dist/mpx-icon.jsx +8 -16
  23. package/lib/runtime/components/react/dist/mpx-image.jsx +291 -0
  24. package/lib/runtime/components/react/dist/mpx-input.jsx +54 -27
  25. package/lib/runtime/components/react/dist/mpx-label.jsx +15 -22
  26. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +13 -16
  27. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +13 -13
  28. package/lib/runtime/components/react/dist/mpx-navigator.jsx +2 -4
  29. package/lib/runtime/components/react/dist/mpx-picker/date.jsx +6 -2
  30. package/lib/runtime/components/react/dist/mpx-picker/index.jsx +5 -3
  31. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +6 -2
  32. package/lib/runtime/components/react/dist/mpx-picker/region.jsx +6 -2
  33. package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +6 -2
  34. package/lib/runtime/components/react/dist/mpx-picker/time.jsx +10 -15
  35. package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +3 -1
  36. package/lib/runtime/components/react/dist/mpx-picker-view.jsx +5 -3
  37. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +11 -19
  38. package/lib/runtime/components/react/dist/mpx-radio.jsx +27 -42
  39. package/lib/runtime/components/react/dist/mpx-rich-text/html.js +39 -0
  40. package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +63 -0
  41. package/lib/runtime/components/react/dist/mpx-root-portal.jsx +6 -4
  42. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +47 -41
  43. package/lib/runtime/components/react/dist/mpx-simple-text.jsx +11 -0
  44. package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +4 -2
  45. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +4 -2
  46. package/lib/runtime/components/react/dist/mpx-switch.jsx +20 -10
  47. package/lib/runtime/components/react/dist/mpx-text.jsx +11 -10
  48. package/lib/runtime/components/react/dist/mpx-textarea.jsx +8 -3
  49. package/lib/runtime/components/react/dist/mpx-view.jsx +34 -46
  50. package/lib/runtime/components/react/dist/mpx-web-view.jsx +105 -42
  51. package/lib/runtime/components/react/dist/useAnimationHooks.js +35 -10
  52. package/lib/runtime/components/react/dist/utils.jsx +107 -82
  53. package/lib/runtime/components/react/event.config.ts +25 -26
  54. package/lib/runtime/components/react/getInnerListeners.ts +238 -188
  55. package/lib/runtime/components/react/mpx-button.tsx +64 -50
  56. package/lib/runtime/components/react/mpx-canvas/html.ts +2 -4
  57. package/lib/runtime/components/react/mpx-canvas/index.tsx +46 -48
  58. package/lib/runtime/components/react/mpx-checkbox-group.tsx +28 -25
  59. package/lib/runtime/components/react/mpx-checkbox.tsx +48 -49
  60. package/lib/runtime/components/react/mpx-form.tsx +25 -28
  61. package/lib/runtime/components/react/mpx-icon.tsx +12 -17
  62. package/lib/runtime/components/react/mpx-image.tsx +436 -0
  63. package/lib/runtime/components/react/mpx-input.tsx +77 -57
  64. package/lib/runtime/components/react/mpx-label.tsx +26 -27
  65. package/lib/runtime/components/react/mpx-movable-area.tsx +18 -23
  66. package/lib/runtime/components/react/mpx-movable-view.tsx +21 -25
  67. package/lib/runtime/components/react/mpx-navigator.tsx +2 -8
  68. package/lib/runtime/components/react/mpx-picker/date.tsx +5 -2
  69. package/lib/runtime/components/react/mpx-picker/index.tsx +3 -2
  70. package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +5 -2
  71. package/lib/runtime/components/react/mpx-picker/region.tsx +5 -2
  72. package/lib/runtime/components/react/mpx-picker/selector.tsx +5 -2
  73. package/lib/runtime/components/react/mpx-picker/time.tsx +10 -15
  74. package/lib/runtime/components/react/mpx-picker/type.ts +48 -43
  75. package/lib/runtime/components/react/mpx-picker-view-column.tsx +4 -1
  76. package/lib/runtime/components/react/mpx-picker-view.tsx +7 -1
  77. package/lib/runtime/components/react/mpx-radio-group.tsx +24 -27
  78. package/lib/runtime/components/react/mpx-radio.tsx +45 -54
  79. package/lib/runtime/components/react/mpx-rich-text/html.ts +40 -0
  80. package/lib/runtime/components/react/mpx-rich-text/index.tsx +121 -0
  81. package/lib/runtime/components/react/mpx-root-portal.tsx +3 -5
  82. package/lib/runtime/components/react/mpx-scroll-view.tsx +72 -71
  83. package/lib/runtime/components/react/mpx-simple-text.tsx +18 -0
  84. package/lib/runtime/components/react/mpx-swiper/carouse.tsx +4 -2
  85. package/lib/runtime/components/react/mpx-swiper-item.tsx +3 -2
  86. package/lib/runtime/components/react/mpx-switch.tsx +29 -23
  87. package/lib/runtime/components/react/mpx-text.tsx +14 -18
  88. package/lib/runtime/components/react/mpx-textarea.tsx +11 -10
  89. package/lib/runtime/components/react/mpx-view.tsx +55 -65
  90. package/lib/runtime/components/react/mpx-web-view.tsx +108 -63
  91. package/lib/runtime/components/react/types/global.d.ts +3 -17
  92. package/lib/runtime/components/react/useAnimationHooks.ts +36 -12
  93. package/lib/runtime/components/react/utils.tsx +113 -82
  94. package/lib/runtime/components/web/getInnerListeners.js +6 -6
  95. package/lib/runtime/components/web/mpx-movable-view.vue +334 -344
  96. package/lib/runtime/components/web/mpx-picker-view-column.vue +75 -75
  97. package/lib/runtime/components/web/mpx-picker.vue +382 -385
  98. package/lib/runtime/components/web/mpx-web-view.vue +175 -161
  99. package/lib/runtime/optionProcessor.js +7 -38
  100. package/lib/runtime/utils.js +2 -0
  101. package/lib/style-compiler/plugins/scope-id.js +30 -2
  102. package/lib/template-compiler/bind-this.js +7 -2
  103. package/lib/template-compiler/compiler.js +77 -46
  104. package/lib/template-compiler/gen-node-react.js +2 -2
  105. package/lib/utils/pre-process-json.js +9 -5
  106. package/package.json +5 -4
  107. package/lib/runtime/components/react/dist/mpx-image/index.jsx +0 -226
  108. package/lib/runtime/components/react/dist/mpx-image/svg.jsx +0 -7
  109. package/lib/runtime/components/react/mpx-image/index.tsx +0 -345
  110. package/lib/runtime/components/react/mpx-image/svg.tsx +0 -22
  111. package/lib/runtime/components/web/event.js +0 -105
@@ -17,7 +17,7 @@
17
17
  * ✔ cursor-color
18
18
  * ✔ selection-start
19
19
  * ✔ selection-end
20
- * adjust-position
20
+ * adjust-position
21
21
  * ✘ hold-keyboard
22
22
  * ✘ safe-password-cert-path
23
23
  * ✘ safe-password-length
@@ -37,13 +37,13 @@
37
37
  * ✘ bind:keyboardcompositionend
38
38
  * ✘ bind:onkeyboardheightchange
39
39
  */
40
- import { forwardRef, useMemo, useRef, useState, useContext, useEffect } from 'react';
40
+ import { forwardRef, useMemo, useRef, useState, useContext, useEffect, createElement } from 'react';
41
41
  import { Platform, TextInput } from 'react-native';
42
42
  import { warn } from '@mpxjs/utils';
43
- import { parseInlineStyle, useUpdateEffect, useTransformStyle, useLayout } from './utils';
43
+ import { parseInlineStyle, useUpdateEffect, useTransformStyle, useLayout, extendObject } from './utils';
44
44
  import useInnerProps, { getCustomEvent } from './getInnerListeners';
45
45
  import useNodesRef from './useNodesRef';
46
- import { FormContext } from './context';
46
+ import { FormContext, KeyboardAvoidContext } from './context';
47
47
  const keyboardTypeMap = {
48
48
  text: 'default',
49
49
  number: 'numeric',
@@ -54,10 +54,11 @@ const keyboardTypeMap = {
54
54
  }) || ''
55
55
  };
56
56
  const Input = forwardRef((props, ref) => {
57
- const { style = {}, type = 'text', value, password, 'placeholder-style': placeholderStyle, disabled, maxlength = 140, '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, bindinput, bindfocus, bindblur, bindconfirm, bindselectionchange,
57
+ const { style = {}, allowFontScaling = false, type = 'text', value, password, 'placeholder-style': placeholderStyle, disabled, maxlength = 140, '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, bindinput, bindfocus, bindblur, bindconfirm, bindselectionchange,
58
58
  // private
59
59
  multiline, 'auto-height': autoHeight, bindlinechange } = props;
60
60
  const formContext = useContext(FormContext);
61
+ const setKeyboardAvoidEnabled = useContext(KeyboardAvoidContext);
61
62
  let formValuesMap;
62
63
  if (formContext) {
63
64
  formValuesMap = formContext.formValuesMap;
@@ -66,21 +67,19 @@ const Input = forwardRef((props, ref) => {
66
67
  const defaultValue = type === 'number' && value ? value + '' : value;
67
68
  const placeholderTextColor = parseInlineStyle(placeholderStyle)?.color;
68
69
  const textAlignVertical = multiline ? 'top' : 'auto';
69
- const tmpValue = useRef();
70
+ const tmpValue = useRef(defaultValue);
70
71
  const cursorIndex = useRef(0);
71
72
  const lineCount = useRef(0);
72
73
  const [inputValue, setInputValue] = useState(defaultValue);
73
74
  const [contentHeight, setContentHeight] = useState(0);
74
- const styleObj = {
75
- padding: 0,
76
- ...style,
77
- ...multiline && autoHeight && {
78
- height: Math.max(style?.minHeight || 35, contentHeight)
79
- }
80
- };
75
+ const styleObj = extendObject({ padding: 0, backgroundColor: '#fff' }, style, multiline && autoHeight
76
+ ? { minHeight: Math.max(style?.minHeight || 35, contentHeight) }
77
+ : {});
81
78
  const { hasSelfPercent, normalStyle, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
82
79
  const nodeRef = useRef(null);
83
- useNodesRef(props, ref, nodeRef);
80
+ useNodesRef(props, ref, nodeRef, {
81
+ style: normalStyle
82
+ });
84
83
  const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef });
85
84
  useEffect(() => {
86
85
  if (inputValue !== value) {
@@ -203,6 +202,9 @@ const Input = forwardRef((props, ref) => {
203
202
  }
204
203
  };
205
204
  }, []);
205
+ useEffect(() => {
206
+ setKeyboardAvoidEnabled?.(adjustPosition);
207
+ }, [adjustPosition]);
206
208
  useUpdateEffect(() => {
207
209
  if (!nodeRef?.current) {
208
210
  return;
@@ -211,26 +213,51 @@ const Input = forwardRef((props, ref) => {
211
213
  ? nodeRef.current?.focus()
212
214
  : nodeRef.current?.blur();
213
215
  }, [focus]);
214
- const composeStyle = { ...normalStyle, ...layoutStyle };
215
- const innerProps = useInnerProps(props, {
216
+ const innerProps = useInnerProps(props, extendObject({
216
217
  ref: nodeRef,
217
- style: {
218
- padding: 0,
219
- ...composeStyle,
220
- ...multiline && autoHeight && {
221
- height: Math.max(composeStyle?.minHeight || 35, contentHeight)
222
- }
223
- },
224
- ...layoutProps,
218
+ style: extendObject({}, normalStyle, layoutStyle),
219
+ allowFontScaling,
220
+ keyboardType: keyboardType,
221
+ secureTextEntry: !!password,
222
+ defaultValue: defaultValue,
223
+ value: inputValue,
224
+ maxLength: maxlength === -1 ? undefined : maxlength,
225
+ editable: !disabled,
226
+ autoFocus: !!autoFocus || !!focus,
227
+ returnKeyType: confirmType,
228
+ selection: selection,
229
+ selectionColor: cursorColor,
230
+ blurOnSubmit: !multiline && !confirmHold,
231
+ underlineColorAndroid: 'rgba(0,0,0,0)',
232
+ textAlignVertical: textAlignVertical,
233
+ placeholderTextColor: placeholderTextColor,
234
+ multiline: !!multiline
235
+ }, layoutProps, {
225
236
  onFocus: bindfocus && onInputFocus,
226
237
  onBlur: bindblur && onInputBlur,
227
238
  onKeyPress: bindconfirm && onKeyPress,
228
239
  onSubmitEditing: bindconfirm && multiline && onSubmitEditing,
229
- onSelectionChange: bindselectionchange && onSelectionChange
230
- }, [], {
240
+ onSelectionChange: bindselectionchange && onSelectionChange,
241
+ onTextInput: onTextInput,
242
+ onChange: onChange,
243
+ onContentSizeChange: onContentSizeChange
244
+ }), [
245
+ 'type',
246
+ 'password',
247
+ 'placeholder-style',
248
+ 'disabled',
249
+ 'auto-focus',
250
+ 'focus',
251
+ 'confirm-type',
252
+ 'confirm-hold',
253
+ 'cursor',
254
+ 'cursor-color',
255
+ 'selection-start',
256
+ 'selection-end'
257
+ ], {
231
258
  layoutRef
232
259
  });
233
- return (<TextInput {...innerProps} keyboardType={keyboardType} secureTextEntry={!!password} defaultValue={defaultValue} value={inputValue} maxLength={maxlength === -1 ? undefined : maxlength} editable={!disabled} autoFocus={!!autoFocus || !!focus} returnKeyType={confirmType} selection={selection} selectionColor={cursorColor} blurOnSubmit={!multiline && !confirmHold} underlineColorAndroid="rgba(0,0,0,0)" textAlignVertical={textAlignVertical} placeholderTextColor={placeholderTextColor} multiline={!!multiline} onTextInput={onTextInput} onChange={onChange} onContentSizeChange={onContentSizeChange}/>);
260
+ return createElement(TextInput, innerProps);
234
261
  });
235
262
  Input.displayName = 'MpxInput';
236
263
  export default Input;
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * ✘ for
3
3
  */
4
- import { useRef, forwardRef, useCallback } from 'react';
4
+ import { useRef, forwardRef, useCallback, createElement } from 'react';
5
5
  import { View } from 'react-native';
6
6
  import { noop, warn } from '@mpxjs/utils';
7
7
  import useInnerProps, { getCustomEvent } from './getInnerListeners';
8
8
  import useNodesRef from './useNodesRef';
9
- import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren } from './utils';
9
+ import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject } from './utils';
10
10
  import { LabelContext } from './context';
11
11
  const Label = forwardRef((labelProps, ref) => {
12
12
  const { textProps, innerProps: props = {} } = splitProps(labelProps);
@@ -16,15 +16,12 @@ const Label = forwardRef((labelProps, ref) => {
16
16
  const defaultStyle = {
17
17
  flexDirection: 'row'
18
18
  };
19
- const styleObj = {
20
- ...defaultStyle,
21
- ...style
22
- };
19
+ const styleObj = extendObject({}, defaultStyle, style);
23
20
  const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
24
21
  const nodeRef = useRef(null);
25
- useNodesRef(props, ref, nodeRef, { defaultStyle });
22
+ useNodesRef(props, ref, nodeRef, { style: normalStyle });
26
23
  const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef });
27
- const { textStyle, backgroundStyle, innerStyle } = splitStyle(normalStyle);
24
+ const { textStyle, backgroundStyle, innerStyle = {} } = splitStyle(normalStyle);
28
25
  if (backgroundStyle) {
29
26
  warn('Label does not support background image-related styles!');
30
27
  }
@@ -36,24 +33,20 @@ const Label = forwardRef((labelProps, ref) => {
36
33
  bindtap && bindtap(getCustomEvent('tap', evt, { layoutRef }, { props: propsRef.current }));
37
34
  contextRef.current.triggerChange(evt);
38
35
  }, []);
39
- const innerProps = useInnerProps(props, {
36
+ const innerProps = useInnerProps(props, extendObject({
40
37
  ref: nodeRef,
41
- style: { ...innerStyle, ...layoutStyle },
42
- ...layoutProps,
38
+ style: extendObject({}, innerStyle, layoutStyle)
39
+ }, layoutProps, {
43
40
  bindtap: onTap
44
- }, [], {
41
+ }), [], {
45
42
  layoutRef
46
43
  });
47
- return <View {...innerProps}>
48
- <LabelContext.Provider value={contextRef}>
49
- {wrapChildren(props, {
50
- hasVarDec,
51
- varContext: varContextRef.current,
52
- textStyle,
53
- textProps
54
- })}
55
- </LabelContext.Provider>
56
- </View>;
44
+ return createElement(View, innerProps, createElement(LabelContext.Provider, { value: contextRef }, wrapChildren(props, {
45
+ hasVarDec,
46
+ varContext: varContextRef.current,
47
+ textStyle,
48
+ textProps
49
+ })));
57
50
  });
58
51
  Label.displayName = 'MpxLabel';
59
52
  export default Label;
@@ -2,34 +2,31 @@
2
2
  * ✘ scale-area
3
3
  */
4
4
  import { View } from 'react-native';
5
- import { forwardRef, useRef, useMemo } from 'react';
5
+ import { forwardRef, useRef, useMemo, createElement } from 'react';
6
6
  import useNodesRef from './useNodesRef';
7
7
  import useInnerProps from './getInnerListeners';
8
8
  import { MovableAreaContext } from './context';
9
- import { useTransformStyle, wrapChildren, useLayout } from './utils';
9
+ import { useTransformStyle, wrapChildren, useLayout, extendObject } from './utils';
10
10
  const _MovableArea = forwardRef((props, ref) => {
11
11
  const { style = {}, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
12
12
  const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
13
13
  const movableViewRef = useRef(null);
14
- useNodesRef(props, ref, movableViewRef);
14
+ useNodesRef(props, ref, movableViewRef, {
15
+ style: normalStyle
16
+ });
15
17
  const contextValue = useMemo(() => ({
16
18
  height: normalStyle.height || 10,
17
19
  width: normalStyle.width || 10
18
20
  }), [normalStyle.width, normalStyle.height]);
19
21
  const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: movableViewRef });
20
- const innerProps = useInnerProps(props, {
21
- style: { height: contextValue.height, width: contextValue.width, overflow: 'hidden', ...normalStyle, ...layoutStyle },
22
- ref: movableViewRef,
23
- ...layoutProps
24
- }, [], { layoutRef });
25
- return (<MovableAreaContext.Provider value={contextValue}>
26
- <View {...innerProps}>
27
- {wrapChildren(props, {
28
- hasVarDec,
29
- varContext: varContextRef.current
30
- })}
31
- </View>
32
- </MovableAreaContext.Provider>);
22
+ const innerProps = useInnerProps(props, extendObject({
23
+ style: extendObject({ height: contextValue.height, width: contextValue.width, overflow: 'hidden' }, normalStyle, layoutStyle),
24
+ ref: movableViewRef
25
+ }, layoutProps), [], { layoutRef });
26
+ return createElement(MovableAreaContext.Provider, { value: contextValue }, createElement(View, innerProps, wrapChildren(props, {
27
+ hasVarDec,
28
+ varContext: varContextRef.current
29
+ })));
33
30
  });
34
31
  _MovableArea.displayName = 'MpxMovableArea';
35
32
  export default _MovableArea;
@@ -17,12 +17,12 @@
17
17
  * ✔ htouchmove
18
18
  * ✔ vtouchmove
19
19
  */
20
- import { useEffect, forwardRef, useContext, useCallback, useRef, useMemo } from 'react';
20
+ import { useEffect, forwardRef, useContext, useCallback, useRef, useMemo, createElement } from 'react';
21
21
  import { StyleSheet } from 'react-native';
22
22
  import { getCustomEvent } from './getInnerListeners';
23
23
  import useNodesRef from './useNodesRef';
24
24
  import { MovableAreaContext } from './context';
25
- import { useTransformStyle, splitProps, splitStyle, HIDDEN_STYLE, wrapChildren, flatGesture } from './utils';
25
+ import { useTransformStyle, splitProps, splitStyle, HIDDEN_STYLE, wrapChildren, flatGesture, extendObject } from './utils';
26
26
  import { GestureDetector, Gesture } from 'react-native-gesture-handler';
27
27
  import Animated, { useSharedValue, useAnimatedStyle, withDecay, runOnJS, runOnUI, useAnimatedReaction, withSpring } from 'react-native-reanimated';
28
28
  const styles = StyleSheet.create({
@@ -64,7 +64,7 @@ const _MovableView = forwardRef((movableViewProps, ref) => {
64
64
  const waitForHandlers = flatGesture(waitFor);
65
65
  const nodeRef = useRef(null);
66
66
  useNodesRef(props, ref, nodeRef, {
67
- defaultStyle: styles.container,
67
+ style: normalStyle,
68
68
  gestureRef: movableGestureRef
69
69
  });
70
70
  const hasSimultaneousHandlersChanged = prevSimultaneousHandlersRef.current.length !== (originSimultaneousHandlers?.length || 0) ||
@@ -416,16 +416,16 @@ const _MovableView = forwardRef((movableViewProps, ref) => {
416
416
  };
417
417
  const catchEventHandlers = injectCatchEvent(props);
418
418
  const layoutStyle = !hasLayoutRef.current && hasSelfPercent ? HIDDEN_STYLE : {};
419
- return (<GestureDetector gesture={gesture}>
420
- <Animated.View ref={nodeRef} onLayout={onLayout} style={[innerStyle, animatedStyles, layoutStyle]} {...catchEventHandlers}>
421
- {wrapChildren(props, {
422
- hasVarDec,
423
- varContext: varContextRef.current,
424
- textStyle,
425
- textProps
426
- })}
427
- </Animated.View>
428
- </GestureDetector>);
419
+ return createElement(GestureDetector, { gesture: gesture }, createElement(Animated.View, extendObject({
420
+ ref: nodeRef,
421
+ onLayout: onLayout,
422
+ style: [innerStyle, animatedStyles, layoutStyle]
423
+ }, catchEventHandlers), wrapChildren(props, {
424
+ hasVarDec,
425
+ varContext: varContextRef.current,
426
+ textStyle,
427
+ textProps
428
+ })));
429
429
  });
430
430
  _MovableView.displayName = 'MpxMovableView';
431
431
  export default _MovableView;
@@ -1,4 +1,4 @@
1
- import { useCallback, forwardRef } from 'react';
1
+ import { useCallback, forwardRef, createElement } from 'react';
2
2
  import useInnerProps from './getInnerListeners';
3
3
  import { redirectTo, navigateTo, navigateBack, reLaunch, switchTab } from '@mpxjs/api-proxy';
4
4
  import MpxView from './mpx-view';
@@ -27,9 +27,7 @@ const _Navigator = forwardRef((props, ref) => {
27
27
  ref,
28
28
  bindtap: handleClick
29
29
  });
30
- return (<MpxView {...innerProps}>
31
- {children}
32
- </MpxView>);
30
+ return createElement(MpxView, innerProps, children);
33
31
  });
34
32
  _Navigator.displayName = 'MpxNavigator';
35
33
  export default _Navigator;
@@ -23,12 +23,15 @@ function dateToString(date, fields = 'day') {
23
23
  return ret;
24
24
  }
25
25
  const _DatePicker = forwardRef((props, ref) => {
26
- const { children, start = '1970-01-01', end = '2999-01-01', value, bindchange, bindcancel, disabled, fields } = props;
26
+ const { children, start = '1970-01-01', end = '2999-01-01', value, bindchange, bindcancel, disabled, fields, style } = props;
27
27
  const [datevalue, setDateValue] = useState(value);
28
28
  // 存储layout布局信息
29
29
  const layoutRef = useRef({});
30
30
  const viewRef = useRef(null);
31
- useNodesRef(props, ref, viewRef, {});
31
+ const nodeRef = useRef(null);
32
+ useNodesRef(props, ref, nodeRef, {
33
+ style
34
+ });
32
35
  useEffect(() => {
33
36
  value && setDateValue(value);
34
37
  }, [value]);
@@ -48,6 +51,7 @@ const _DatePicker = forwardRef((props, ref) => {
48
51
  });
49
52
  };
50
53
  const dateProps = {
54
+ ref: nodeRef,
51
55
  precision: fields,
52
56
  value: formatTimeStr(datevalue),
53
57
  minDate: formatTimeStr(start),
@@ -28,10 +28,12 @@ import { FormContext } from '../context';
28
28
  * ✘ bindcolumnchange
29
29
  */
30
30
  const _Picker = forwardRef((props, ref) => {
31
- const { mode = 'selector', value, bindcancel, bindchange, children, bindcolumnchange } = props;
31
+ const { mode = 'selector', value, bindcancel, bindchange, children, bindcolumnchange, style } = props;
32
32
  const innerLayout = useRef({});
33
33
  const nodeRef = useRef(null);
34
- useNodesRef(props, ref, nodeRef, {});
34
+ useNodesRef(props, ref, nodeRef, {
35
+ style
36
+ });
35
37
  const innerProps = useInnerProps(props, {
36
38
  ref: nodeRef
37
39
  }, [], { layoutRef: innerLayout });
@@ -78,7 +80,7 @@ const _Picker = forwardRef((props, ref) => {
78
80
  bindcolumnchange && bindcolumnchange(eventData);
79
81
  };
80
82
  const commonProps = {
81
- ...{ innerProps },
83
+ ...innerProps,
82
84
  mode,
83
85
  children,
84
86
  bindchange: onChange,
@@ -77,7 +77,7 @@ function getColumnIndexByValue(range = [], column, value = []) {
77
77
  return changeIndex;
78
78
  }
79
79
  const _MultiSelectorPicker = forwardRef((props, ref) => {
80
- const { range, value, disabled, bindchange, bindcancel, children, bindcolumnchange } = props;
80
+ const { range, value, disabled, bindchange, bindcancel, children, bindcolumnchange, style } = props;
81
81
  const formatRange = formatRangeFun(range, props['range-key']);
82
82
  const initValue = getInnerValueByIndex(formatRange, value);
83
83
  // 选中的索引值
@@ -87,7 +87,10 @@ const _MultiSelectorPicker = forwardRef((props, ref) => {
87
87
  // 存储layout布局信息
88
88
  const layoutRef = useRef({});
89
89
  const viewRef = useRef(null);
90
- useNodesRef(props, ref, viewRef, {});
90
+ const nodeRef = useRef(null);
91
+ useNodesRef(props, ref, nodeRef, {
92
+ style
93
+ });
91
94
  useEffect(() => {
92
95
  if (range) {
93
96
  const newFormatRange = formatRangeFun(range, props['range-key']);
@@ -117,6 +120,7 @@ const _MultiSelectorPicker = forwardRef((props, ref) => {
117
120
  });
118
121
  };
119
122
  const antPickerProps = {
123
+ ref: nodeRef,
120
124
  data,
121
125
  value: selected,
122
126
  cols: range.length,
@@ -35,13 +35,16 @@ function formateRegionData(clObj = [], customItem, depth = 2) {
35
35
  return obj;
36
36
  }
37
37
  const _RegionPicker = forwardRef((props, ref) => {
38
- const { children, value, bindchange, bindcancel, disabled } = props;
38
+ const { children, value, bindchange, bindcancel, disabled, style } = props;
39
39
  const formatRegionData = formateRegionData(regionData, props['custom-item']);
40
40
  const [regionvalue, setRegionValue] = useState(value);
41
41
  // 存储layout布局信息
42
42
  const layoutRef = useRef({});
43
43
  const viewRef = useRef(null);
44
- useNodesRef(props, ref, viewRef, {});
44
+ const nodeRef = useRef(null);
45
+ useNodesRef(props, ref, nodeRef, {
46
+ style
47
+ });
45
48
  const onChange = (value) => {
46
49
  // 通过 value 查找 code
47
50
  let tmp = regionData;
@@ -75,6 +78,7 @@ const _RegionPicker = forwardRef((props, ref) => {
75
78
  bindcancel && bindcancel();
76
79
  };
77
80
  const regionProps = {
81
+ ref: nodeRef,
78
82
  data: formatRegionData,
79
83
  value: regionvalue,
80
84
  onChange,
@@ -18,7 +18,7 @@ const formatRangeFun = (range, rangeKey = '') => {
18
18
  return newRange;
19
19
  };
20
20
  const _SelectorPicker = forwardRef((props, ref) => {
21
- const { range, children, value, disabled, bindchange, bindcancel } = props;
21
+ const { range, children, value, disabled, bindchange, bindcancel, style } = props;
22
22
  // 格式化数据为Array<*>
23
23
  const formatRange = formatRangeFun(range, props['range-key']);
24
24
  // 选中的索引值
@@ -28,7 +28,10 @@ const _SelectorPicker = forwardRef((props, ref) => {
28
28
  // 存储layout布局信息
29
29
  const layoutRef = useRef({});
30
30
  const viewRef = useRef(null);
31
- useNodesRef(props, ref, viewRef, {});
31
+ const nodeRef = useRef(null);
32
+ useNodesRef(props, ref, nodeRef, {
33
+ style
34
+ });
32
35
  useEffect(() => {
33
36
  if (range) {
34
37
  const newFormatRange = formatRangeFun(range, props['range-key']);
@@ -53,6 +56,7 @@ const _SelectorPicker = forwardRef((props, ref) => {
53
56
  });
54
57
  };
55
58
  const antPickerProps = {
59
+ ref: nodeRef,
56
60
  data,
57
61
  value: [selected],
58
62
  cols: 1,
@@ -1,5 +1,5 @@
1
1
  import { View, Text, Modal, TouchableWithoutFeedback } from 'react-native';
2
- import { PickerView } from '@ant-design/react-native';
2
+ import { PickerView, Portal } from '@ant-design/react-native';
3
3
  import React, { forwardRef, useState, useRef, useEffect } from 'react';
4
4
  import useNodesRef from '../useNodesRef'; // 引入辅助函数
5
5
  // 可见应用窗口的大小。
@@ -11,8 +11,8 @@ const styles = {
11
11
  showModal: {
12
12
  backgroundColor: 'black',
13
13
  opacity: 0.5,
14
- position: 'absolute',
15
- width: '100%'
14
+ width: '100%',
15
+ height: '100%'
16
16
  },
17
17
  hideModal: {
18
18
  opacity: 1,
@@ -117,7 +117,7 @@ function checkSelectedIsValid(strStart, strEnd, selected) {
117
117
  */
118
118
  // start="02:10" end = 23:01
119
119
  const _TimePicker = forwardRef((props, ref) => {
120
- const { children, start, end, value, bindchange, bindcancel, disabled } = props;
120
+ const { children, start, end, value, bindchange, bindcancel, style } = props;
121
121
  const defaultProps = {
122
122
  start: '00:10',
123
123
  end: '23:59'
@@ -127,11 +127,11 @@ const _TimePicker = forwardRef((props, ref) => {
127
127
  // 存储layout布局信息
128
128
  const layoutRef = useRef({});
129
129
  const viewRef = useRef(null);
130
- useNodesRef(props, ref, viewRef, {});
130
+ const nodeRef = useRef(null);
131
+ useNodesRef(props, ref, nodeRef, { style });
131
132
  // 存储modal的布局信息
132
133
  const modalLayoutRef = useRef({});
133
134
  const modalRef = useRef(null);
134
- useNodesRef(props, ref, modalRef, {});
135
135
  const [visible, setVisible] = useState(false);
136
136
  const columnData = generateColumns();
137
137
  const [data, setData] = useState(columnData);
@@ -175,12 +175,6 @@ const _TimePicker = forwardRef((props, ref) => {
175
175
  else {
176
176
  // [9, 13]
177
177
  setTimeValue(date);
178
- const strDate = formatStr(date);
179
- bindchange && bindchange({
180
- detail: {
181
- value: strDate
182
- }
183
- });
184
178
  }
185
179
  };
186
180
  const onElementLayout = () => {
@@ -197,6 +191,7 @@ const _TimePicker = forwardRef((props, ref) => {
197
191
  };
198
192
  const renderModalChildren = () => {
199
193
  const pickerProps = {
194
+ ref: nodeRef,
200
195
  data,
201
196
  value: timevalue,
202
197
  defaultValue: timevalue,
@@ -230,15 +225,15 @@ const _TimePicker = forwardRef((props, ref) => {
230
225
  </TouchableWithoutFeedback>
231
226
  </View>;
232
227
  };
233
- const strStyle = visible ? styles.showModal : styles.hideModal;
234
- const mheight = Math.floor(offsetTop);
235
228
  // Animated.View
236
229
  return (<>
237
- <View style={{ ...strStyle, height: visible ? mheight : 0, bottom: 0 }}>
230
+ <Portal>
231
+ <View style={visible ? styles.showModal : styles.hideModal}>
238
232
  <Modal animationType="slide" transparent={true} visible={visible}>
239
233
  {renderModalChildren()}
240
234
  </Modal>
241
235
  </View>
236
+ </Portal>
242
237
  {renderChildren()}
243
238
  </>);
244
239
  });
@@ -14,7 +14,9 @@ const _PickerViewColumn = forwardRef((props, ref) => {
14
14
  const { textStyle } = splitStyle(normalStyle);
15
15
  const { textProps } = splitProps(props);
16
16
  const scrollViewRef = useRef(null);
17
- useNodesRef(props, ref, scrollViewRef, {});
17
+ useNodesRef(props, ref, scrollViewRef, {
18
+ style: normalStyle
19
+ });
18
20
  const { height: pickerH, itemHeight = DefaultPickerItemH } = wrapperStyle;
19
21
  const [itemRawH, setItemRawH] = useState(0); // 单个选项真实渲染高度
20
22
  const maxIndex = useMemo(() => columnData.length - 1, [columnData]);
@@ -25,7 +25,9 @@ const _PickerView = forwardRef((props, ref) => {
25
25
  const activeValueRef = useRef(value);
26
26
  activeValueRef.current = value.slice();
27
27
  const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, setWidth, setHeight } = useTransformStyle(style, { enableVar, externalVarContext });
28
- useNodesRef(props, ref, nodeRef, {});
28
+ useNodesRef(props, ref, nodeRef, {
29
+ style: normalStyle
30
+ });
29
31
  const {
30
32
  // 存储layout布局信息
31
33
  layoutRef, layoutProps, layoutStyle } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: nodeRef });
@@ -50,7 +52,7 @@ const _PickerView = forwardRef((props, ref) => {
50
52
  };
51
53
  const innerProps = useInnerProps(props, extendObject({
52
54
  ref: nodeRef,
53
- style: extendObject(normalStyle, layoutStyle, {
55
+ style: extendObject({}, normalStyle, layoutStyle, {
54
56
  position: 'relative',
55
57
  overflow: 'hidden'
56
58
  }),
@@ -59,7 +61,7 @@ const _PickerView = forwardRef((props, ref) => {
59
61
  const renderColumn = (child, index, columnData, initialIndex) => {
60
62
  const extraProps = {};
61
63
  const childProps = child?.props || {};
62
- const wrappedProps = extendObject(childProps, {
64
+ const wrappedProps = extendObject({}, childProps, {
63
65
  columnData,
64
66
  ref: cloneRef,
65
67
  columnIndex: index,
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * ✔ bindchange
3
3
  */
4
- import { useRef, forwardRef, useContext, useMemo, useEffect } from 'react';
4
+ import { useRef, forwardRef, useContext, useMemo, useEffect, createElement } from 'react';
5
5
  import { View } from 'react-native';
6
6
  import { warn } from '@mpxjs/utils';
7
7
  import { FormContext, RadioGroupContext } from './context';
8
8
  import useInnerProps, { getCustomEvent } from './getInnerListeners';
9
9
  import useNodesRef from './useNodesRef';
10
- import { useLayout, useTransformStyle, wrapChildren } from './utils';
10
+ import { useLayout, useTransformStyle, wrapChildren, extendObject } from './utils';
11
11
  const radioGroup = forwardRef((props, ref) => {
12
12
  const { style = {}, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
13
13
  const propsRef = useRef({});
@@ -22,13 +22,10 @@ const radioGroup = forwardRef((props, ref) => {
22
22
  flexDirection: 'row',
23
23
  flexWrap: 'wrap'
24
24
  };
25
- const styleObj = {
26
- ...defaultStyle,
27
- ...style
28
- };
25
+ const styleObj = extendObject({}, defaultStyle, style);
29
26
  const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
30
27
  const nodeRef = useRef(null);
31
- useNodesRef(props, ref, nodeRef, { defaultStyle });
28
+ useNodesRef(props, ref, nodeRef, { style: normalStyle });
32
29
  const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef });
33
30
  const getValue = () => {
34
31
  for (const key in groupValue) {
@@ -74,21 +71,16 @@ const radioGroup = forwardRef((props, ref) => {
74
71
  notifyChange
75
72
  };
76
73
  }, []);
77
- const innerProps = useInnerProps(props, {
74
+ const innerProps = useInnerProps(props, extendObject({
78
75
  ref: nodeRef,
79
- style: { ...normalStyle, ...layoutStyle },
80
- ...layoutProps
81
- }, [], {
76
+ style: extendObject({}, normalStyle, layoutStyle)
77
+ }, layoutProps), ['name'], {
82
78
  layoutRef
83
79
  });
84
- return (<View {...innerProps}>
85
- <RadioGroupContext.Provider value={contextValue}>
86
- {wrapChildren(props, {
87
- hasVarDec,
88
- varContext: varContextRef.current
89
- })}
90
- </RadioGroupContext.Provider>
91
- </View>);
80
+ return createElement(View, innerProps, createElement(RadioGroupContext.Provider, { value: contextValue }, wrapChildren(props, {
81
+ hasVarDec,
82
+ varContext: varContextRef.current
83
+ })));
92
84
  });
93
85
  radioGroup.displayName = 'MpxRadioGroup';
94
86
  export default radioGroup;