@mpxjs/webpack-plugin 2.9.67 → 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/index.js +13 -8
- package/lib/platform/json/wx/index.js +21 -8
- package/lib/platform/style/wx/index.js +35 -38
- 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/processStyles.js +14 -4
- package/lib/react/processTemplate.js +3 -0
- package/lib/resolver/AddModePlugin.js +8 -8
- 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 +77 -49
- 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 +13 -19
- package/lib/runtime/components/react/dist/mpx-checkbox.jsx +29 -38
- package/lib/runtime/components/react/dist/mpx-form.jsx +16 -19
- package/lib/runtime/components/react/dist/mpx-icon.jsx +8 -16
- package/lib/runtime/components/react/dist/mpx-image.jsx +291 -0
- package/lib/runtime/components/react/dist/mpx-input.jsx +54 -27
- package/lib/runtime/components/react/dist/mpx-label.jsx +15 -22
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +13 -16
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +13 -13
- package/lib/runtime/components/react/dist/mpx-navigator.jsx +2 -4
- 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 +11 -19
- package/lib/runtime/components/react/dist/mpx-radio.jsx +27 -42
- 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 +6 -4
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +47 -41
- package/lib/runtime/components/react/dist/mpx-simple-text.jsx +11 -0
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +4 -2
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +606 -0
- package/lib/runtime/components/react/dist/mpx-switch.jsx +20 -10
- package/lib/runtime/components/react/dist/mpx-text.jsx +11 -10
- package/lib/runtime/components/react/dist/mpx-textarea.jsx +8 -3
- package/lib/runtime/components/react/dist/mpx-view.jsx +65 -61
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +112 -35
- 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 +35 -9
- package/lib/runtime/components/react/dist/utils.jsx +70 -23
- package/lib/runtime/components/react/event.config.ts +25 -26
- package/lib/runtime/components/react/getInnerListeners.ts +237 -199
- package/lib/runtime/components/react/mpx-button.tsx +104 -57
- 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 +28 -25
- package/lib/runtime/components/react/mpx-checkbox.tsx +48 -49
- package/lib/runtime/components/react/mpx-form.tsx +25 -28
- package/lib/runtime/components/react/mpx-icon.tsx +12 -17
- package/lib/runtime/components/react/mpx-image.tsx +436 -0
- package/lib/runtime/components/react/mpx-input.tsx +77 -57
- package/lib/runtime/components/react/mpx-label.tsx +26 -27
- package/lib/runtime/components/react/mpx-movable-area.tsx +18 -23
- package/lib/runtime/components/react/mpx-movable-view.tsx +21 -25
- package/lib/runtime/components/react/mpx-navigator.tsx +2 -8
- 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 +24 -27
- package/lib/runtime/components/react/mpx-radio.tsx +45 -54
- 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 +3 -5
- package/lib/runtime/components/react/mpx-scroll-view.tsx +72 -71
- package/lib/runtime/components/react/mpx-simple-text.tsx +18 -0
- package/lib/runtime/components/react/mpx-swiper/carouse.tsx +4 -2
- package/lib/runtime/components/react/mpx-swiper-item.tsx +3 -2
- package/lib/runtime/components/react/mpx-switch.tsx +29 -23
- package/lib/runtime/components/react/mpx-text.tsx +14 -18
- package/lib/runtime/components/react/mpx-textarea.tsx +11 -10
- package/lib/runtime/components/react/mpx-view.tsx +92 -76
- package/lib/runtime/components/react/mpx-web-view.tsx +116 -54
- 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 +36 -11
- package/lib/runtime/components/react/utils.tsx +99 -28
- 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/utils.js +2 -0
- package/lib/style-compiler/plugins/scope-id.js +30 -2
- package/lib/template-compiler/bind-this.js +7 -2
- package/lib/template-compiler/compiler.js +79 -47
- package/lib/template-compiler/gen-node-react.js +3 -3
- package/lib/utils/pre-process-json.js +9 -5
- 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 -345
- package/lib/runtime/components/react/mpx-image/svg.tsx +0 -22
- package/lib/runtime/components/web/event.js +0 -105
|
@@ -47,9 +47,32 @@ const InitialValue = Object.assign({
|
|
|
47
47
|
const TransformOrigin = 'transformOrigin';
|
|
48
48
|
// transform
|
|
49
49
|
const isTransform = (key) => Object.keys(TransformInitial).includes(key);
|
|
50
|
+
// 多value解析
|
|
51
|
+
const parseValues = (str, char = ' ') => {
|
|
52
|
+
let stack = 0;
|
|
53
|
+
let temp = '';
|
|
54
|
+
const result = [];
|
|
55
|
+
for (let i = 0; i < str.length; i++) {
|
|
56
|
+
if (str[i] === '(') {
|
|
57
|
+
stack++;
|
|
58
|
+
}
|
|
59
|
+
else if (str[i] === ')') {
|
|
60
|
+
stack--;
|
|
61
|
+
}
|
|
62
|
+
// 非括号内 或者 非分隔字符且非空
|
|
63
|
+
if (stack !== 0 || (str[i] !== char && str[i] !== ' ')) {
|
|
64
|
+
temp += str[i];
|
|
65
|
+
}
|
|
66
|
+
if ((stack === 0 && str[i] === char) || i === str.length - 1) {
|
|
67
|
+
result.push(temp);
|
|
68
|
+
temp = '';
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return result;
|
|
72
|
+
};
|
|
50
73
|
// parse string transform, eg: transform: 'rotateX(45deg) rotateZ(0.785398rad)'
|
|
51
74
|
const parseTransform = (transformStr) => {
|
|
52
|
-
const values = transformStr
|
|
75
|
+
const values = parseValues(transformStr);
|
|
53
76
|
const transform = [];
|
|
54
77
|
values.forEach(item => {
|
|
55
78
|
const match = item.match(/([/\w]+)\(([^)]+)\)/);
|
|
@@ -73,7 +96,7 @@ const parseTransform = (transformStr) => {
|
|
|
73
96
|
break;
|
|
74
97
|
case 'matrix':
|
|
75
98
|
case 'matrix3d':
|
|
76
|
-
transform.push({ [key]: val
|
|
99
|
+
transform.push({ [key]: parseValues(val, ',').map(val => +val) });
|
|
77
100
|
break;
|
|
78
101
|
case 'translate':
|
|
79
102
|
case 'scale':
|
|
@@ -84,8 +107,8 @@ const parseTransform = (transformStr) => {
|
|
|
84
107
|
{
|
|
85
108
|
// 2 个以上的值处理
|
|
86
109
|
key = key.replace('3d', '');
|
|
87
|
-
const vals = val
|
|
88
|
-
// scale(.5) === scaleX(.5) scaleY(.5)
|
|
110
|
+
const vals = parseValues(val, ',').splice(0, key === 'rotate' ? 4 : 3);
|
|
111
|
+
// scale(.5) === scaleX(.5) scaleY(.5)
|
|
89
112
|
if (vals.length === 1 && key === 'scale') {
|
|
90
113
|
vals.push(vals[0]);
|
|
91
114
|
}
|
|
@@ -183,11 +206,14 @@ export default function useAnimationHooks(props) {
|
|
|
183
206
|
}
|
|
184
207
|
// 添加每个key的多次step动画
|
|
185
208
|
animatedKeys.forEach(key => {
|
|
186
|
-
let toVal = (rules.get(key) || transform.get(key));
|
|
187
209
|
// key不存在,第一轮取shareValMap[key]value,非第一轮取上一轮的
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
210
|
+
const toVal = rules.get(key) !== undefined
|
|
211
|
+
? rules.get(key)
|
|
212
|
+
: transform.get(key) !== undefined
|
|
213
|
+
? transform.get(key)
|
|
214
|
+
: index > 0
|
|
215
|
+
? lastValueMap[key]
|
|
216
|
+
: shareValMap[key].value;
|
|
191
217
|
const animation = getAnimation({ key, value: toVal }, { delay, duration, easing }, needSetCallback ? setTransformOrigin : undefined);
|
|
192
218
|
needSetCallback = false;
|
|
193
219
|
if (!sequence[key]) {
|
|
@@ -298,6 +324,6 @@ export default function useAnimationHooks(props) {
|
|
|
298
324
|
styles[key] = shareValMap[key].value;
|
|
299
325
|
}
|
|
300
326
|
return styles;
|
|
301
|
-
},
|
|
327
|
+
}, {});
|
|
302
328
|
});
|
|
303
329
|
}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { useEffect, useRef, isValidElement, useContext, useState, Children, cloneElement } from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import { useEffect, useCallback, useMemo, useRef, isValidElement, useContext, useState, Children, cloneElement } from 'react';
|
|
2
|
+
import { Image } from 'react-native';
|
|
3
|
+
import { isObject, isFunction, isNumber, hasOwn, diffAndCloneA, error, warn, getFocusedNavigation } from '@mpxjs/utils';
|
|
3
4
|
import { VarContext } from './context';
|
|
4
5
|
import { ExpressionParser, parseFunc, ReplaceSource } from './parser';
|
|
5
6
|
import { initialWindowMetrics } from 'react-native-safe-area-context';
|
|
7
|
+
import FastImage from '@d11/react-native-fast-image';
|
|
6
8
|
export const TEXT_STYLE_REGEX = /color|font.*|text.*|letterSpacing|lineHeight|includeFontPadding|writingDirection/;
|
|
7
9
|
export const PERCENT_REGEX = /^\s*-?\d+(\.\d+)?%\s*$/;
|
|
8
10
|
export const URL_REGEX = /^\s*url\(["']?(.*?)["']?\)\s*$/;
|
|
11
|
+
export const SVG_REGEXP = /https?:\/\/.*\.(?:svg)/i;
|
|
9
12
|
export const BACKGROUND_REGEX = /^background(Image|Size|Repeat|Position)$/;
|
|
10
|
-
export const TEXT_PROPS_REGEX = /ellipsizeMode|numberOfLines/;
|
|
13
|
+
export const TEXT_PROPS_REGEX = /ellipsizeMode|numberOfLines|allowFontScaling/;
|
|
11
14
|
export const DEFAULT_FONT_SIZE = 16;
|
|
12
15
|
export const HIDDEN_STYLE = {
|
|
13
16
|
opacity: 0
|
|
@@ -24,10 +27,7 @@ const safeAreaInsetMap = {
|
|
|
24
27
|
};
|
|
25
28
|
function getSafeAreaInset(name) {
|
|
26
29
|
const navigation = getFocusedNavigation();
|
|
27
|
-
const insets = {
|
|
28
|
-
...initialWindowMetrics?.insets,
|
|
29
|
-
...navigation?.insets
|
|
30
|
-
};
|
|
30
|
+
const insets = extendObject({}, initialWindowMetrics?.insets, navigation?.insets);
|
|
31
31
|
return insets[safeAreaInsetMap[name]];
|
|
32
32
|
}
|
|
33
33
|
export function omit(obj, fields) {
|
|
@@ -69,7 +69,7 @@ export const parseInlineStyle = (inlineStyle = '') => {
|
|
|
69
69
|
if (rest.length || !v || !k)
|
|
70
70
|
return styleObj;
|
|
71
71
|
const key = k.trim().replace(/-./g, c => c.substring(1).toUpperCase());
|
|
72
|
-
return Object.assign(styleObj, { [key]: v.trim() });
|
|
72
|
+
return Object.assign(styleObj, { [key]: global.__formatValue(v.trim()) });
|
|
73
73
|
}, {});
|
|
74
74
|
};
|
|
75
75
|
export const parseUrl = (cssUrl = '') => {
|
|
@@ -79,23 +79,13 @@ export const parseUrl = (cssUrl = '') => {
|
|
|
79
79
|
return match?.[1];
|
|
80
80
|
};
|
|
81
81
|
export const getRestProps = (transferProps = {}, originProps = {}, deletePropsKey = []) => {
|
|
82
|
-
return {
|
|
83
|
-
...transferProps,
|
|
84
|
-
...omit(originProps, deletePropsKey)
|
|
85
|
-
};
|
|
82
|
+
return extendObject({}, transferProps, omit(originProps, deletePropsKey));
|
|
86
83
|
};
|
|
87
84
|
export function isText(ele) {
|
|
88
85
|
if (isValidElement(ele)) {
|
|
89
86
|
const displayName = ele.type?.displayName;
|
|
90
87
|
const isCustomText = ele.type?.isCustomText;
|
|
91
|
-
return displayName === 'MpxText' || displayName === 'Text' || !!isCustomText;
|
|
92
|
-
}
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
export function isEmbedded(ele) {
|
|
96
|
-
if (isValidElement(ele)) {
|
|
97
|
-
const displayName = ele.type?.displayName || '';
|
|
98
|
-
return ['mpx-checkbox', 'mpx-radio', 'mpx-switch'].includes(displayName);
|
|
88
|
+
return displayName === 'MpxText' || displayName === 'MpxSimpleText' || displayName === 'Text' || !!isCustomText;
|
|
99
89
|
}
|
|
100
90
|
return false;
|
|
101
91
|
}
|
|
@@ -238,6 +228,14 @@ function transformCalc(styleObj, calcKeyPaths, formatter) {
|
|
|
238
228
|
});
|
|
239
229
|
});
|
|
240
230
|
}
|
|
231
|
+
const stringifyProps = ['fontWeight'];
|
|
232
|
+
function transformStringify(styleObj) {
|
|
233
|
+
stringifyProps.forEach((prop) => {
|
|
234
|
+
if (isNumber(styleObj[prop])) {
|
|
235
|
+
styleObj[prop] = '' + styleObj[prop];
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
}
|
|
241
239
|
export function useTransformStyle(styleObj = {}, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight }) {
|
|
242
240
|
const varStyle = {};
|
|
243
241
|
const normalStyle = {};
|
|
@@ -336,6 +334,8 @@ export function useTransformStyle(styleObj = {}, { enableVar, externalVarContext
|
|
|
336
334
|
}
|
|
337
335
|
}
|
|
338
336
|
});
|
|
337
|
+
// transform number enum stringify
|
|
338
|
+
transformStringify(normalStyle);
|
|
339
339
|
return {
|
|
340
340
|
normalStyle,
|
|
341
341
|
hasSelfPercent,
|
|
@@ -402,7 +402,7 @@ export function splitProps(props) {
|
|
|
402
402
|
export const useLayout = ({ props, hasSelfPercent, setWidth, setHeight, onLayout, nodeRef }) => {
|
|
403
403
|
const layoutRef = useRef({});
|
|
404
404
|
const hasLayoutRef = useRef(false);
|
|
405
|
-
const layoutStyle = !hasLayoutRef.current && hasSelfPercent ? HIDDEN_STYLE : {};
|
|
405
|
+
const layoutStyle = useMemo(() => { return !hasLayoutRef.current && hasSelfPercent ? HIDDEN_STYLE : {}; }, [hasLayoutRef.current]);
|
|
406
406
|
const layoutProps = {};
|
|
407
407
|
const enableOffset = props['enable-offset'];
|
|
408
408
|
if (hasSelfPercent || onLayout || enableOffset) {
|
|
@@ -433,8 +433,8 @@ export function wrapChildren(props = {}, { hasVarDec, varContext, textStyle, tex
|
|
|
433
433
|
if (textStyle || textProps) {
|
|
434
434
|
children = Children.map(children, (child) => {
|
|
435
435
|
if (isText(child)) {
|
|
436
|
-
const style = {
|
|
437
|
-
return cloneElement(child, {
|
|
436
|
+
const style = extendObject({}, textStyle, child.props.style);
|
|
437
|
+
return cloneElement(child, extendObject({}, textProps, { style }));
|
|
438
438
|
}
|
|
439
439
|
return child;
|
|
440
440
|
});
|
|
@@ -444,6 +444,34 @@ export function wrapChildren(props = {}, { hasVarDec, varContext, textStyle, tex
|
|
|
444
444
|
}
|
|
445
445
|
return children;
|
|
446
446
|
}
|
|
447
|
+
export const debounce = (func, delay) => {
|
|
448
|
+
let timer;
|
|
449
|
+
const wrapper = (...args) => {
|
|
450
|
+
clearTimeout(timer);
|
|
451
|
+
timer = setTimeout(() => {
|
|
452
|
+
func(...args);
|
|
453
|
+
}, delay);
|
|
454
|
+
};
|
|
455
|
+
wrapper.clear = () => {
|
|
456
|
+
clearTimeout(timer);
|
|
457
|
+
};
|
|
458
|
+
return wrapper;
|
|
459
|
+
};
|
|
460
|
+
export const useDebounceCallback = (func, delay) => {
|
|
461
|
+
const debounced = useMemo(() => debounce(func, delay), [func]);
|
|
462
|
+
return debounced;
|
|
463
|
+
};
|
|
464
|
+
export const useStableCallback = (callback) => {
|
|
465
|
+
const ref = useRef(callback);
|
|
466
|
+
ref.current = callback;
|
|
467
|
+
return useCallback((...args) => ref.current?.(...args), []);
|
|
468
|
+
};
|
|
469
|
+
export const usePrevious = (value) => {
|
|
470
|
+
const ref = useRef(undefined);
|
|
471
|
+
const prev = ref.current;
|
|
472
|
+
ref.current = value;
|
|
473
|
+
return prev;
|
|
474
|
+
};
|
|
447
475
|
export function flatGesture(gestures = []) {
|
|
448
476
|
return (gestures && gestures.flatMap((gesture) => {
|
|
449
477
|
if (gesture && gesture.nodeRefs) {
|
|
@@ -453,3 +481,22 @@ export function flatGesture(gestures = []) {
|
|
|
453
481
|
return gesture?.current ? [gesture] : [];
|
|
454
482
|
})) || [];
|
|
455
483
|
}
|
|
484
|
+
export const extendObject = Object.assign;
|
|
485
|
+
export function getCurrentPage(pageId) {
|
|
486
|
+
if (!global.getCurrentPages)
|
|
487
|
+
return;
|
|
488
|
+
const pages = global.getCurrentPages();
|
|
489
|
+
return pages.find((page) => isFunction(page.getPageId) && page.getPageId() === pageId);
|
|
490
|
+
}
|
|
491
|
+
export function renderImage(imageProps, enableFastImage = false) {
|
|
492
|
+
const Component = enableFastImage ? FastImage : Image;
|
|
493
|
+
return <Component {...imageProps}/>;
|
|
494
|
+
}
|
|
495
|
+
export function pickStyle(styleObj = {}, pickedKeys, callback) {
|
|
496
|
+
return pickedKeys.reduce((acc, key) => {
|
|
497
|
+
if (key in styleObj) {
|
|
498
|
+
acc[key] = callback ? callback(key, styleObj[key]) : styleObj[key];
|
|
499
|
+
}
|
|
500
|
+
return acc;
|
|
501
|
+
}, {});
|
|
502
|
+
}
|
|
@@ -2,31 +2,30 @@ interface EventConfig {
|
|
|
2
2
|
[key: string]: string[];
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
-
const eventConfigMap:
|
|
6
|
-
bindtap: ['onTouchStart', 'onTouchMove', 'onTouchEnd'],
|
|
7
|
-
bindlongpress: ['onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel'],
|
|
8
|
-
bindtouchstart: ['onTouchStart'],
|
|
9
|
-
bindtouchmove: ['onTouchMove'],
|
|
10
|
-
bindtouchend: ['onTouchEnd'],
|
|
11
|
-
bindtouchcancel: ['onTouchCancel'],
|
|
12
|
-
catchtap: ['onTouchStart', 'onTouchMove', 'onTouchEnd'],
|
|
13
|
-
catchlongpress: ['onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel'],
|
|
14
|
-
catchtouchstart: ['onTouchStart'],
|
|
15
|
-
catchtouchmove: ['onTouchMove'],
|
|
16
|
-
catchtouchend: ['onTouchEnd'],
|
|
17
|
-
catchtouchcancel: ['onTouchCancel'],
|
|
18
|
-
'capture-bindtap': ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture'],
|
|
19
|
-
'capture-bindlongpress': ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture', 'onTouchCancelCapture'],
|
|
20
|
-
'capture-bindtouchstart': ['onTouchStartCapture'],
|
|
21
|
-
'capture-bindtouchmove': ['onTouchMoveCapture'],
|
|
22
|
-
'capture-bindtouchend': ['onTouchEndCapture'],
|
|
23
|
-
'capture-bindtouchcancel': ['onTouchCancelCapture'],
|
|
24
|
-
'capture-catchtap': ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture'],
|
|
25
|
-
'capture-catchlongpress': ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture', 'onTouchCancelCapture'],
|
|
26
|
-
'capture-catchtouchstart': ['onTouchStartCapture'],
|
|
27
|
-
'capture-catchtouchmove': ['onTouchMoveCapture'],
|
|
28
|
-
'capture-catchtouchend': ['onTouchEndCapture'],
|
|
29
|
-
'capture-catchtouchcancel': ['onTouchCancelCapture']
|
|
5
|
+
const eventConfigMap: { [key: string]: { bitFlag: string; events: string[] } } = {
|
|
6
|
+
bindtap: { bitFlag: '0', events: ['onTouchStart', 'onTouchMove', 'onTouchEnd'] },
|
|
7
|
+
bindlongpress: { bitFlag: '1', events: ['onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel'] },
|
|
8
|
+
bindtouchstart: { bitFlag: '2', events: ['onTouchStart'] },
|
|
9
|
+
bindtouchmove: { bitFlag: '3', events: ['onTouchMove'] },
|
|
10
|
+
bindtouchend: { bitFlag: '4', events: ['onTouchEnd'] },
|
|
11
|
+
bindtouchcancel: { bitFlag: '5', events: ['onTouchCancel'] },
|
|
12
|
+
catchtap: { bitFlag: '6', events: ['onTouchStart', 'onTouchMove', 'onTouchEnd'] },
|
|
13
|
+
catchlongpress: { bitFlag: '7', events: ['onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel'] },
|
|
14
|
+
catchtouchstart: { bitFlag: '8', events: ['onTouchStart'] },
|
|
15
|
+
catchtouchmove: { bitFlag: '9', events: ['onTouchMove'] },
|
|
16
|
+
catchtouchend: { bitFlag: 'a', events: ['onTouchEnd'] },
|
|
17
|
+
catchtouchcancel: { bitFlag: 'b', events: ['onTouchCancel'] },
|
|
18
|
+
'capture-bindtap': { bitFlag: 'c', events: ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture'] },
|
|
19
|
+
'capture-bindlongpress': { bitFlag: 'd', events: ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture', 'onTouchCancelCapture'] },
|
|
20
|
+
'capture-bindtouchstart': { bitFlag: 'e', events: ['onTouchStartCapture'] },
|
|
21
|
+
'capture-bindtouchmove': { bitFlag: 'f', events: ['onTouchMoveCapture'] },
|
|
22
|
+
'capture-bindtouchend': { bitFlag: 'g', events: ['onTouchEndCapture'] },
|
|
23
|
+
'capture-bindtouchcancel': { bitFlag: 'h', events: ['onTouchCancelCapture'] },
|
|
24
|
+
'capture-catchtap': { bitFlag: 'i', events: ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture'] },
|
|
25
|
+
'capture-catchlongpress': { bitFlag: 'j', events: ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture', 'onTouchCancelCapture'] },
|
|
26
|
+
'capture-catchtouchstart': { bitFlag: 'k', events: ['onTouchStartCapture'] },
|
|
27
|
+
'capture-catchtouchmove': { bitFlag: 'l', events: ['onTouchMoveCapture'] },
|
|
28
|
+
'capture-catchtouchend': { bitFlag: 'm', events: ['onTouchEndCapture'] },
|
|
29
|
+
'capture-catchtouchcancel': { bitFlag: 'n', events: ['onTouchCancelCapture'] }
|
|
30
30
|
}
|
|
31
|
-
|
|
32
31
|
export default eventConfigMap
|