@mpxjs/webpack-plugin 2.9.65 → 2.9.67

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 (80) hide show
  1. package/lib/dependencies/RecordGlobalComponentsDependency.js +11 -12
  2. package/lib/dependencies/RecordRuntimeInfoDependency.js +1 -1
  3. package/lib/index.js +28 -8
  4. package/lib/json-compiler/index.js +2 -11
  5. package/lib/loader.js +24 -45
  6. package/lib/native-loader.js +49 -64
  7. package/lib/platform/json/wx/index.js +3 -10
  8. package/lib/platform/style/wx/index.js +32 -56
  9. package/lib/react/index.js +4 -3
  10. package/lib/react/processJSON.js +5 -13
  11. package/lib/react/processMainScript.js +7 -3
  12. package/lib/react/processScript.js +3 -4
  13. package/lib/react/processTemplate.js +6 -4
  14. package/lib/resolver/AddModePlugin.js +17 -4
  15. package/lib/runtime/components/react/context.ts +8 -0
  16. package/lib/runtime/components/react/dist/context.js +1 -0
  17. package/lib/runtime/components/react/dist/mpx-button.jsx +1 -1
  18. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +30 -17
  19. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +1 -1
  20. package/lib/runtime/components/react/dist/mpx-form.jsx +33 -24
  21. package/lib/runtime/components/react/dist/mpx-icon.jsx +1 -1
  22. package/lib/runtime/components/react/dist/mpx-image/index.jsx +1 -1
  23. package/lib/runtime/components/react/dist/mpx-input.jsx +44 -38
  24. package/lib/runtime/components/react/dist/mpx-label.jsx +10 -7
  25. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +10 -17
  26. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +378 -294
  27. package/lib/runtime/components/react/dist/mpx-navigator.jsx +1 -1
  28. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +30 -17
  29. package/lib/runtime/components/react/dist/mpx-radio.jsx +1 -1
  30. package/lib/runtime/components/react/dist/mpx-root-portal.jsx +1 -1
  31. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +58 -30
  32. package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +77 -77
  33. package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +1 -1
  34. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +1 -1
  35. package/lib/runtime/components/react/dist/mpx-switch.jsx +8 -1
  36. package/lib/runtime/components/react/dist/mpx-text.jsx +1 -1
  37. package/lib/runtime/components/react/dist/mpx-textarea.jsx +1 -1
  38. package/lib/runtime/components/react/dist/mpx-view.jsx +31 -12
  39. package/lib/runtime/components/react/dist/mpx-web-view.jsx +2 -2
  40. package/lib/runtime/components/react/dist/useAnimationHooks.js +303 -0
  41. package/lib/runtime/components/react/dist/utils.jsx +13 -3
  42. package/lib/runtime/components/react/getInnerListeners.ts +1 -0
  43. package/lib/runtime/components/react/mpx-button.tsx +1 -1
  44. package/lib/runtime/components/react/mpx-checkbox-group.tsx +52 -29
  45. package/lib/runtime/components/react/mpx-checkbox.tsx +1 -1
  46. package/lib/runtime/components/react/mpx-form.tsx +42 -34
  47. package/lib/runtime/components/react/mpx-icon.tsx +1 -1
  48. package/lib/runtime/components/react/mpx-image/index.tsx +2 -3
  49. package/lib/runtime/components/react/mpx-input.tsx +68 -66
  50. package/lib/runtime/components/react/mpx-label.tsx +11 -8
  51. package/lib/runtime/components/react/mpx-movable-area.tsx +11 -19
  52. package/lib/runtime/components/react/mpx-movable-view.tsx +456 -334
  53. package/lib/runtime/components/react/mpx-navigator.tsx +1 -1
  54. package/lib/runtime/components/react/mpx-radio-group.tsx +55 -29
  55. package/lib/runtime/components/react/mpx-radio.tsx +1 -1
  56. package/lib/runtime/components/react/mpx-root-portal.tsx +1 -1
  57. package/lib/runtime/components/react/mpx-scroll-view.tsx +92 -37
  58. package/lib/runtime/components/react/mpx-swiper/carouse.tsx +77 -76
  59. package/lib/runtime/components/react/mpx-swiper/index.tsx +2 -1
  60. package/lib/runtime/components/react/mpx-swiper-item.tsx +1 -1
  61. package/lib/runtime/components/react/mpx-switch.tsx +10 -2
  62. package/lib/runtime/components/react/mpx-text.tsx +1 -1
  63. package/lib/runtime/components/react/mpx-textarea.tsx +1 -1
  64. package/lib/runtime/components/react/mpx-view.tsx +40 -20
  65. package/lib/runtime/components/react/mpx-web-view.tsx +2 -2
  66. package/lib/runtime/components/react/types/common.ts +8 -2
  67. package/lib/runtime/components/react/useAnimationHooks.ts +332 -0
  68. package/lib/runtime/components/react/useNodesRef.ts +1 -0
  69. package/lib/runtime/components/react/utils.tsx +23 -6
  70. package/lib/runtime/optionProcessorReact.js +0 -15
  71. package/lib/runtime/swanHelper.wxs +1 -1
  72. package/lib/style-compiler/index.js +1 -1
  73. package/lib/style-compiler/plugins/scope-id.js +1 -0
  74. package/lib/template-compiler/compiler.js +68 -33
  75. package/lib/template-compiler/index.js +4 -4
  76. package/lib/utils/pre-process-json.js +113 -0
  77. package/lib/web/index.js +5 -4
  78. package/lib/web/processJSON.js +5 -13
  79. package/lib/web/processTemplate.js +2 -2
  80. package/package.json +5 -4
@@ -121,27 +121,24 @@ const Input = forwardRef((props, ref) => {
121
121
  }
122
122
  };
123
123
  const onInputFocus = (evt) => {
124
- bindfocus &&
125
- bindfocus(getCustomEvent('focus', evt, {
126
- detail: {
127
- value: tmpValue.current || ''
128
- },
129
- layoutRef
130
- }, props));
124
+ bindfocus(getCustomEvent('focus', evt, {
125
+ detail: {
126
+ value: tmpValue.current || ''
127
+ },
128
+ layoutRef
129
+ }, props));
131
130
  };
132
131
  const onInputBlur = (evt) => {
133
- bindblur &&
134
- bindblur(getCustomEvent('blur', evt, {
135
- detail: {
136
- value: tmpValue.current || '',
137
- cursor: cursorIndex.current
138
- },
139
- layoutRef
140
- }, props));
132
+ bindblur(getCustomEvent('blur', evt, {
133
+ detail: {
134
+ value: tmpValue.current || '',
135
+ cursor: cursorIndex.current
136
+ },
137
+ layoutRef
138
+ }, props));
141
139
  };
142
140
  const onKeyPress = (evt) => {
143
- bindconfirm &&
144
- evt.nativeEvent.key === 'Enter' &&
141
+ evt.nativeEvent.key === 'Enter' &&
145
142
  bindconfirm(getCustomEvent('confirm', evt, {
146
143
  detail: {
147
144
  value: tmpValue.current || ''
@@ -150,14 +147,21 @@ const Input = forwardRef((props, ref) => {
150
147
  }, props));
151
148
  };
152
149
  const onSubmitEditing = (evt) => {
153
- bindconfirm &&
154
- multiline &&
155
- bindconfirm(getCustomEvent('confirm', evt, {
156
- detail: {
157
- value: tmpValue.current || ''
158
- },
159
- layoutRef
160
- }, props));
150
+ bindconfirm(getCustomEvent('confirm', evt, {
151
+ detail: {
152
+ value: tmpValue.current || ''
153
+ },
154
+ layoutRef
155
+ }, props));
156
+ };
157
+ const onSelectionChange = (evt) => {
158
+ bindselectionchange(getCustomEvent('selectionchange', evt, {
159
+ detail: {
160
+ selectionStart: evt.nativeEvent.selection.start,
161
+ selectionEnd: evt.nativeEvent.selection.end
162
+ },
163
+ layoutRef
164
+ }, props));
161
165
  };
162
166
  const onContentSizeChange = (evt) => {
163
167
  const { width, height } = evt.nativeEvent.contentSize;
@@ -178,16 +182,6 @@ const Input = forwardRef((props, ref) => {
178
182
  setContentHeight(height);
179
183
  }
180
184
  };
181
- const onSelectionChange = (evt) => {
182
- bindselectionchange &&
183
- bindselectionchange(getCustomEvent('selectionchange', evt, {
184
- detail: {
185
- selectionStart: evt.nativeEvent.selection.start,
186
- selectionEnd: evt.nativeEvent.selection.end
187
- },
188
- layoutRef
189
- }, props));
190
- };
191
185
  const resetValue = () => {
192
186
  setInputValue('');
193
187
  };
@@ -202,6 +196,13 @@ const Input = forwardRef((props, ref) => {
202
196
  formValuesMap.set(props.name, { getValue, resetValue });
203
197
  }
204
198
  }
199
+ useEffect(() => {
200
+ return () => {
201
+ if (formValuesMap && props.name) {
202
+ formValuesMap.delete(props.name);
203
+ }
204
+ };
205
+ }, []);
205
206
  useUpdateEffect(() => {
206
207
  if (!nodeRef?.current) {
207
208
  return;
@@ -220,11 +221,16 @@ const Input = forwardRef((props, ref) => {
220
221
  height: Math.max(composeStyle?.minHeight || 35, contentHeight)
221
222
  }
222
223
  },
223
- ...layoutProps
224
+ ...layoutProps,
225
+ onFocus: bindfocus && onInputFocus,
226
+ onBlur: bindblur && onInputBlur,
227
+ onKeyPress: bindconfirm && onKeyPress,
228
+ onSubmitEditing: bindconfirm && multiline && onSubmitEditing,
229
+ onSelectionChange: bindselectionchange && onSelectionChange
224
230
  }, [], {
225
231
  layoutRef
226
232
  });
227
- 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} onFocus={onInputFocus} onBlur={onInputBlur} onKeyPress={onKeyPress} onSubmitEditing={onSubmitEditing} onContentSizeChange={onContentSizeChange} onSelectionChange={onSelectionChange}/>);
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}/>);
228
234
  });
229
- Input.displayName = 'mpx-input';
235
+ Input.displayName = 'MpxInput';
230
236
  export default Input;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * ✘ for
3
3
  */
4
- import { useRef, forwardRef } from 'react';
4
+ import { useRef, forwardRef, useCallback } from 'react';
5
5
  import { View } from 'react-native';
6
6
  import { noop, warn } from '@mpxjs/utils';
7
7
  import useInnerProps, { getCustomEvent } from './getInnerListeners';
@@ -10,7 +10,9 @@ import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren } fr
10
10
  import { LabelContext } from './context';
11
11
  const Label = forwardRef((labelProps, ref) => {
12
12
  const { textProps, innerProps: props = {} } = splitProps(labelProps);
13
- const { style = {}, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, bindtap } = props;
13
+ const propsRef = useRef({});
14
+ const { style = {}, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
15
+ propsRef.current = props;
14
16
  const defaultStyle = {
15
17
  flexDirection: 'row'
16
18
  };
@@ -29,10 +31,11 @@ const Label = forwardRef((labelProps, ref) => {
29
31
  const contextRef = useRef({
30
32
  triggerChange: noop
31
33
  });
32
- const onTap = (evt) => {
33
- bindtap && bindtap(getCustomEvent('tap', evt, { layoutRef }, props));
34
- contextRef.current.triggerChange?.(evt);
35
- };
34
+ const onTap = useCallback((evt) => {
35
+ const { bindtap } = propsRef.current;
36
+ bindtap && bindtap(getCustomEvent('tap', evt, { layoutRef }, { props: propsRef.current }));
37
+ contextRef.current.triggerChange(evt);
38
+ }, []);
36
39
  const innerProps = useInnerProps(props, {
37
40
  ref: nodeRef,
38
41
  style: { ...innerStyle, ...layoutStyle },
@@ -52,5 +55,5 @@ const Label = forwardRef((labelProps, ref) => {
52
55
  </LabelContext.Provider>
53
56
  </View>;
54
57
  });
55
- Label.displayName = 'mpx-label';
58
+ Label.displayName = 'MpxLabel';
56
59
  export default Label;
@@ -2,34 +2,27 @@
2
2
  * ✘ scale-area
3
3
  */
4
4
  import { View } from 'react-native';
5
- import { useState, useEffect, forwardRef, useRef } from 'react';
5
+ import { forwardRef, useRef, useMemo } from 'react';
6
6
  import useNodesRef from './useNodesRef';
7
7
  import useInnerProps from './getInnerListeners';
8
8
  import { MovableAreaContext } from './context';
9
9
  import { useTransformStyle, wrapChildren, useLayout } from './utils';
10
10
  const _MovableArea = forwardRef((props, ref) => {
11
- const { style = {}, width = 10, height = 10, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
12
- const [areaWidth, setAreaWidth] = useState(0);
13
- const [areaHeight, setAreaHeight] = useState(0);
14
- useEffect(() => {
15
- setAreaWidth(width);
16
- setAreaHeight(height);
17
- }, [width, height]);
11
+ const { style = {}, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
18
12
  const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
19
13
  const movableViewRef = useRef(null);
20
14
  useNodesRef(props, ref, movableViewRef);
21
- const onLayout = (e) => {
22
- const { width = 10, height = 10 } = e.nativeEvent.layout;
23
- setAreaWidth(width);
24
- setAreaHeight(height);
25
- };
26
- const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: movableViewRef, onLayout });
15
+ const contextValue = useMemo(() => ({
16
+ height: normalStyle.height || 10,
17
+ width: normalStyle.width || 10
18
+ }), [normalStyle.width, normalStyle.height]);
19
+ const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: movableViewRef });
27
20
  const innerProps = useInnerProps(props, {
28
- style: { height: areaHeight, width: areaWidth, overflow: 'hidden', ...normalStyle, ...layoutStyle },
21
+ style: { height: contextValue.height, width: contextValue.width, overflow: 'hidden', ...normalStyle, ...layoutStyle },
29
22
  ref: movableViewRef,
30
23
  ...layoutProps
31
24
  }, [], { layoutRef });
32
- return (<MovableAreaContext.Provider value={{ height: areaHeight, width: areaWidth }}>
25
+ return (<MovableAreaContext.Provider value={contextValue}>
33
26
  <View {...innerProps}>
34
27
  {wrapChildren(props, {
35
28
  hasVarDec,
@@ -38,5 +31,5 @@ const _MovableArea = forwardRef((props, ref) => {
38
31
  </View>
39
32
  </MovableAreaContext.Provider>);
40
33
  });
41
- _MovableArea.displayName = 'mpx-movable-area';
34
+ _MovableArea.displayName = 'MpxMovableArea';
42
35
  export default _MovableArea;