@mpxjs/webpack-plugin 2.9.66 → 2.9.69-beta.0
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/lib/dependencies/RecordGlobalComponentsDependency.js +11 -12
- package/lib/dependencies/RecordRuntimeInfoDependency.js +1 -1
- package/lib/index.js +29 -8
- package/lib/json-compiler/index.js +2 -11
- package/lib/loader.js +24 -45
- package/lib/native-loader.js +49 -64
- package/lib/platform/json/wx/index.js +24 -18
- package/lib/platform/style/wx/index.js +49 -47
- package/lib/platform/template/wx/component-config/canvas.js +8 -0
- package/lib/platform/template/wx/component-config/fix-component-name.js +15 -12
- package/lib/platform/template/wx/component-config/index.js +1 -1
- package/lib/platform/template/wx/component-config/input.js +1 -1
- package/lib/platform/template/wx/component-config/rich-text.js +8 -0
- package/lib/platform/template/wx/component-config/swiper.js +1 -1
- package/lib/platform/template/wx/component-config/textarea.js +1 -1
- package/lib/platform/template/wx/component-config/unsupported.js +1 -1
- package/lib/react/index.js +4 -3
- package/lib/react/processJSON.js +5 -13
- package/lib/react/processMainScript.js +7 -3
- package/lib/react/processScript.js +3 -4
- package/lib/react/processStyles.js +14 -4
- package/lib/react/processTemplate.js +5 -2
- package/lib/resolver/AddModePlugin.js +20 -7
- package/lib/runtime/components/react/context.ts +6 -0
- package/lib/runtime/components/react/dist/context.js +2 -0
- package/lib/runtime/components/react/dist/event.config.js +24 -24
- package/lib/runtime/components/react/dist/getInnerListeners.js +183 -174
- package/lib/runtime/components/react/dist/mpx-button.jsx +78 -50
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.js +60 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.js +15 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.js +84 -0
- package/lib/runtime/components/react/dist/mpx-canvas/Image.js +87 -0
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.js +15 -0
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.js +28 -0
- package/lib/runtime/components/react/dist/mpx-canvas/html.js +343 -0
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +232 -0
- package/lib/runtime/components/react/dist/mpx-canvas/utils.jsx +89 -0
- package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +41 -34
- package/lib/runtime/components/react/dist/mpx-checkbox.jsx +30 -39
- package/lib/runtime/components/react/dist/mpx-form.jsx +47 -41
- package/lib/runtime/components/react/dist/mpx-icon.jsx +9 -17
- package/lib/runtime/components/react/dist/mpx-image.jsx +291 -0
- package/lib/runtime/components/react/dist/mpx-input.jsx +95 -62
- package/lib/runtime/components/react/dist/mpx-label.jsx +24 -28
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +20 -30
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +377 -293
- package/lib/runtime/components/react/dist/mpx-navigator.jsx +3 -5
- package/lib/runtime/components/react/dist/mpx-picker/date.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/index.jsx +5 -3
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/region.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/time.jsx +10 -15
- package/lib/runtime/components/react/dist/mpx-picker-view-column-item.jsx +39 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +160 -88
- package/lib/runtime/components/react/dist/mpx-picker-view.jsx +80 -121
- package/lib/runtime/components/react/dist/mpx-radio-group.jsx +39 -34
- package/lib/runtime/components/react/dist/mpx-radio.jsx +28 -43
- package/lib/runtime/components/react/dist/mpx-rich-text/html.js +39 -0
- package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +63 -0
- package/lib/runtime/components/react/dist/mpx-root-portal.jsx +7 -5
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +77 -51
- package/lib/runtime/components/react/dist/mpx-simple-text.jsx +11 -0
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +5 -3
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +606 -0
- package/lib/runtime/components/react/dist/mpx-switch.jsx +28 -11
- package/lib/runtime/components/react/dist/mpx-text.jsx +12 -11
- package/lib/runtime/components/react/dist/mpx-textarea.jsx +9 -4
- package/lib/runtime/components/react/dist/mpx-view.jsx +66 -62
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +113 -36
- package/lib/runtime/components/react/dist/pickerFaces.js +81 -0
- package/lib/runtime/components/react/dist/pickerVIewContext.js +9 -0
- package/lib/runtime/components/react/dist/pickerViewMask.jsx +18 -0
- package/lib/runtime/components/react/dist/pickerViewOverlay.jsx +23 -0
- package/lib/runtime/components/react/dist/useAnimationHooks.js +126 -12
- package/lib/runtime/components/react/dist/utils.jsx +80 -24
- package/lib/runtime/components/react/event.config.ts +25 -26
- package/lib/runtime/components/react/getInnerListeners.ts +237 -198
- package/lib/runtime/components/react/mpx-button.tsx +105 -58
- package/lib/runtime/components/react/mpx-canvas/Bus.ts +70 -0
- package/lib/runtime/components/react/mpx-canvas/CanvasGradient.ts +18 -0
- package/lib/runtime/components/react/mpx-canvas/CanvasRenderingContext2D.ts +87 -0
- package/lib/runtime/components/react/mpx-canvas/Image.ts +102 -0
- package/lib/runtime/components/react/mpx-canvas/ImageData.ts +23 -0
- package/lib/runtime/components/react/mpx-canvas/constructorsRegistry.ts +38 -0
- package/lib/runtime/components/react/mpx-canvas/html.ts +343 -0
- package/lib/runtime/components/react/mpx-canvas/index.tsx +296 -0
- package/lib/runtime/components/react/mpx-canvas/utils.tsx +150 -0
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +77 -51
- package/lib/runtime/components/react/mpx-checkbox.tsx +49 -50
- package/lib/runtime/components/react/mpx-form.tsx +62 -57
- package/lib/runtime/components/react/mpx-icon.tsx +13 -18
- package/lib/runtime/components/react/mpx-image.tsx +436 -0
- package/lib/runtime/components/react/mpx-input.tsx +139 -117
- package/lib/runtime/components/react/mpx-label.tsx +36 -34
- package/lib/runtime/components/react/mpx-movable-area.tsx +26 -39
- package/lib/runtime/components/react/mpx-movable-view.tsx +455 -337
- package/lib/runtime/components/react/mpx-navigator.tsx +3 -9
- package/lib/runtime/components/react/mpx-picker/date.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/index.tsx +3 -2
- package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/region.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/selector.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/time.tsx +10 -15
- package/lib/runtime/components/react/mpx-picker/type.ts +48 -43
- package/lib/runtime/components/react/mpx-picker-view-column.tsx +236 -104
- package/lib/runtime/components/react/mpx-picker-view.tsx +132 -122
- package/lib/runtime/components/react/mpx-radio-group.tsx +77 -54
- package/lib/runtime/components/react/mpx-radio.tsx +46 -55
- package/lib/runtime/components/react/mpx-rich-text/html.ts +40 -0
- package/lib/runtime/components/react/mpx-rich-text/index.tsx +121 -0
- package/lib/runtime/components/react/mpx-root-portal.tsx +4 -6
- package/lib/runtime/components/react/mpx-scroll-view.tsx +122 -76
- package/lib/runtime/components/react/mpx-simple-text.tsx +18 -0
- package/lib/runtime/components/react/mpx-swiper/carouse.tsx +6 -4
- package/lib/runtime/components/react/mpx-swiper/index.tsx +2 -1
- package/lib/runtime/components/react/mpx-swiper-item.tsx +4 -3
- package/lib/runtime/components/react/mpx-switch.tsx +39 -25
- package/lib/runtime/components/react/mpx-text.tsx +15 -19
- package/lib/runtime/components/react/mpx-textarea.tsx +12 -11
- package/lib/runtime/components/react/mpx-view.tsx +93 -77
- package/lib/runtime/components/react/mpx-web-view.tsx +117 -55
- package/lib/runtime/components/react/pickerFaces.ts +104 -0
- package/lib/runtime/components/react/pickerOverlay.tsx +32 -0
- package/lib/runtime/components/react/types/common.ts +2 -0
- package/lib/runtime/components/react/types/global.d.ts +5 -17
- package/lib/runtime/components/react/useAnimationHooks.ts +127 -18
- package/lib/runtime/components/react/useNodesRef.ts +1 -0
- package/lib/runtime/components/react/utils.tsx +113 -27
- package/lib/runtime/components/web/getInnerListeners.js +6 -6
- package/lib/runtime/components/web/mpx-movable-view.vue +334 -344
- package/lib/runtime/components/web/mpx-picker-view-column.vue +75 -75
- package/lib/runtime/components/web/mpx-picker.vue +382 -385
- package/lib/runtime/components/web/mpx-web-view.vue +175 -161
- package/lib/runtime/optionProcessor.js +7 -38
- package/lib/runtime/optionProcessorReact.js +0 -15
- package/lib/runtime/swanHelper.wxs +1 -1
- package/lib/runtime/utils.js +2 -0
- package/lib/style-compiler/index.js +1 -1
- package/lib/style-compiler/plugins/scope-id.js +31 -2
- package/lib/template-compiler/bind-this.js +7 -2
- package/lib/template-compiler/compiler.js +118 -56
- package/lib/template-compiler/gen-node-react.js +3 -3
- package/lib/template-compiler/index.js +4 -4
- package/lib/utils/pre-process-json.js +117 -0
- package/lib/web/index.js +5 -4
- package/lib/web/processJSON.js +5 -13
- package/lib/web/processTemplate.js +2 -2
- package/package.json +6 -4
- package/LICENSE +0 -433
- package/lib/runtime/components/react/dist/mpx-image/index.jsx +0 -226
- package/lib/runtime/components/react/dist/mpx-image/svg.jsx +0 -7
- package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +0 -478
- package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +0 -68
- package/lib/runtime/components/react/dist/mpx-swiper/type.js +0 -1
- package/lib/runtime/components/react/mpx-image/index.tsx +0 -346
- package/lib/runtime/components/react/mpx-image/svg.tsx +0 -22
- package/lib/runtime/components/web/event.js +0 -105
|
@@ -1,56 +1,52 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ✘ for
|
|
3
3
|
*/
|
|
4
|
-
import { useRef, forwardRef } 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);
|
|
13
|
-
const
|
|
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
|
};
|
|
17
|
-
const styleObj = {
|
|
18
|
-
...defaultStyle,
|
|
19
|
-
...style
|
|
20
|
-
};
|
|
19
|
+
const styleObj = extendObject({}, defaultStyle, style);
|
|
21
20
|
const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
|
|
22
21
|
const nodeRef = useRef(null);
|
|
23
|
-
useNodesRef(props, ref, nodeRef, {
|
|
22
|
+
useNodesRef(props, ref, nodeRef, { style: normalStyle });
|
|
24
23
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef });
|
|
25
|
-
const { textStyle, backgroundStyle, innerStyle } = splitStyle(normalStyle);
|
|
24
|
+
const { textStyle, backgroundStyle, innerStyle = {} } = splitStyle(normalStyle);
|
|
26
25
|
if (backgroundStyle) {
|
|
27
26
|
warn('Label does not support background image-related styles!');
|
|
28
27
|
}
|
|
29
28
|
const contextRef = useRef({
|
|
30
29
|
triggerChange: noop
|
|
31
30
|
});
|
|
32
|
-
const onTap = (evt) => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
const onTap = useCallback((evt) => {
|
|
32
|
+
const { bindtap } = propsRef.current;
|
|
33
|
+
bindtap && bindtap(getCustomEvent('tap', evt, { layoutRef }, { props: propsRef.current }));
|
|
34
|
+
contextRef.current.triggerChange(evt);
|
|
35
|
+
}, []);
|
|
36
|
+
const innerProps = useInnerProps(props, extendObject({
|
|
37
37
|
ref: nodeRef,
|
|
38
|
-
style: {
|
|
39
|
-
|
|
38
|
+
style: extendObject({}, innerStyle, layoutStyle)
|
|
39
|
+
}, layoutProps, {
|
|
40
40
|
bindtap: onTap
|
|
41
|
-
}, [], {
|
|
41
|
+
}), [], {
|
|
42
42
|
layoutRef
|
|
43
43
|
});
|
|
44
|
-
return
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
textProps
|
|
51
|
-
})}
|
|
52
|
-
</LabelContext.Provider>
|
|
53
|
-
</View>;
|
|
44
|
+
return createElement(View, innerProps, createElement(LabelContext.Provider, { value: contextRef }, wrapChildren(props, {
|
|
45
|
+
hasVarDec,
|
|
46
|
+
varContext: varContextRef.current,
|
|
47
|
+
textStyle,
|
|
48
|
+
textProps
|
|
49
|
+
})));
|
|
54
50
|
});
|
|
55
|
-
Label.displayName = '
|
|
51
|
+
Label.displayName = 'MpxLabel';
|
|
56
52
|
export default Label;
|
|
@@ -2,41 +2,31 @@
|
|
|
2
2
|
* ✘ scale-area
|
|
3
3
|
*/
|
|
4
4
|
import { View } from 'react-native';
|
|
5
|
-
import {
|
|
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
|
-
const { style = {},
|
|
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
|
-
useNodesRef(props, ref, movableViewRef
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}, [], { layoutRef });
|
|
32
|
-
return (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
varContext: varContextRef.current
|
|
37
|
-
})}
|
|
38
|
-
</View>
|
|
39
|
-
</MovableAreaContext.Provider>);
|
|
14
|
+
useNodesRef(props, ref, movableViewRef, {
|
|
15
|
+
style: normalStyle
|
|
16
|
+
});
|
|
17
|
+
const contextValue = useMemo(() => ({
|
|
18
|
+
height: normalStyle.height || 10,
|
|
19
|
+
width: normalStyle.width || 10
|
|
20
|
+
}), [normalStyle.width, normalStyle.height]);
|
|
21
|
+
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: movableViewRef });
|
|
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
|
+
})));
|
|
40
30
|
});
|
|
41
|
-
_MovableArea.displayName = '
|
|
31
|
+
_MovableArea.displayName = 'MpxMovableArea';
|
|
42
32
|
export default _MovableArea;
|