@mpxjs/webpack-plugin 2.9.69 → 2.9.70-alpha.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/README.md +1 -1
- package/lib/config.js +14 -0
- package/lib/dependencies/AddEntryDependency.js +24 -0
- package/lib/dependencies/ResolveDependency.js +5 -0
- package/lib/index.js +38 -7
- package/lib/json-compiler/helper.js +3 -3
- package/lib/loader.js +53 -0
- package/lib/platform/template/wx/component-config/button.js +14 -2
- package/lib/platform/template/wx/component-config/image.js +4 -0
- package/lib/platform/template/wx/component-config/input.js +5 -1
- package/lib/platform/template/wx/component-config/rich-text.js +4 -0
- package/lib/platform/template/wx/component-config/scroll-view.js +4 -0
- package/lib/platform/template/wx/component-config/swiper.js +1 -1
- package/lib/platform/template/wx/component-config/switch.js +4 -0
- package/lib/platform/template/wx/component-config/text.js +4 -0
- package/lib/platform/template/wx/component-config/textarea.js +6 -1
- package/lib/platform/template/wx/component-config/view.js +4 -0
- package/lib/platform/template/wx/index.js +127 -1
- package/lib/react/processTemplate.js +3 -0
- package/lib/resolve-loader.js +4 -1
- package/lib/runtime/components/react/context.ts +4 -0
- package/lib/runtime/components/react/dist/context.js +1 -0
- package/lib/runtime/components/react/dist/event.config.js +24 -24
- package/lib/runtime/components/react/dist/getInnerListeners.js +183 -165
- package/lib/runtime/components/react/dist/mpx-button.jsx +35 -42
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +30 -12
- 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 +110 -97
- package/lib/runtime/components/react/dist/mpx-picker-view.jsx +32 -29
- 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 +29 -44
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +105 -42
- package/lib/runtime/components/react/dist/pickerFaces.js +12 -6
- 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/{pickerOverlay.jsx → pickerViewOverlay.jsx} +5 -3
- package/lib/runtime/components/react/dist/useAnimationHooks.js +35 -9
- package/lib/runtime/components/react/dist/utils.jsx +20 -24
- package/lib/runtime/components/react/getInnerListeners.ts +35 -28
- package/lib/runtime/components/react/mpx-button.tsx +55 -36
- package/lib/runtime/components/react/mpx-canvas/index.tsx +2 -2
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +13 -12
- package/lib/runtime/components/react/mpx-checkbox.tsx +28 -28
- package/lib/runtime/components/react/mpx-form.tsx +10 -8
- package/lib/runtime/components/react/mpx-icon.tsx +10 -15
- package/lib/runtime/components/react/mpx-image.tsx +396 -0
- package/lib/runtime/components/react/mpx-input.tsx +61 -33
- package/lib/runtime/components/react/mpx-label.tsx +14 -13
- package/lib/runtime/components/react/mpx-movable-area.tsx +8 -7
- package/lib/runtime/components/react/mpx-movable-view.tsx +1 -1
- 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 +4 -1
- package/lib/runtime/components/react/mpx-picker-view.tsx +7 -1
- package/lib/runtime/components/react/mpx-radio-group.tsx +11 -12
- package/lib/runtime/components/react/mpx-radio.tsx +26 -29
- package/lib/runtime/components/react/mpx-scroll-view.tsx +32 -30
- 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 +10 -8
- package/lib/runtime/components/react/mpx-text.tsx +6 -2
- package/lib/runtime/components/react/mpx-view.tsx +37 -45
- package/lib/runtime/components/react/mpx-web-view.tsx +25 -15
- package/lib/runtime/components/react/types/global.d.ts +1 -16
- package/lib/runtime/components/react/utils.tsx +24 -24
- package/lib/runtime/components/tenon/getInnerListeners.js +334 -0
- package/lib/runtime/components/tenon/tenon-button.vue +309 -0
- package/lib/runtime/components/tenon/tenon-image.vue +66 -0
- package/lib/runtime/components/tenon/tenon-input.vue +171 -0
- package/lib/runtime/components/tenon/tenon-rich-text.vue +26 -0
- package/lib/runtime/components/tenon/tenon-scroll-view.vue +127 -0
- package/lib/runtime/components/tenon/tenon-switch.vue +96 -0
- package/lib/runtime/components/tenon/tenon-text.vue +70 -0
- package/lib/runtime/components/tenon/tenon-textarea.vue +86 -0
- package/lib/runtime/components/tenon/tenon-view.vue +93 -0
- 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 +162 -162
- package/lib/runtime/optionProcessor.js +7 -16
- package/lib/runtime/optionProcessor.tenon.js +84 -0
- package/lib/runtime/utils.js +2 -0
- package/lib/style-compiler/index.js +1 -1
- package/lib/style-compiler/plugins/hm.js +20 -0
- package/lib/template-compiler/bind-this.js +7 -2
- package/lib/template-compiler/compiler.js +67 -40
- package/lib/template-compiler/gen-node-react.js +2 -2
- package/lib/tenon/index.js +117 -0
- package/lib/tenon/processJSON.js +352 -0
- package/lib/tenon/processScript.js +203 -0
- package/lib/tenon/processStyles.js +21 -0
- package/lib/tenon/processTemplate.js +126 -0
- package/lib/tenon/script-helper.js +223 -0
- package/lib/utils/env.js +6 -1
- package/lib/utils/get-relative-path.js +25 -0
- package/package.json +7 -3
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect, useCallback, useMemo, useRef, isValidElement, useContext, useState, Children, cloneElement } from 'react';
|
|
2
2
|
import { Image } from 'react-native';
|
|
3
|
-
import { isObject, isFunction, hasOwn, diffAndCloneA, error, warn, getFocusedNavigation } from '@mpxjs/utils';
|
|
3
|
+
import { isObject, isFunction, isNumber, hasOwn, diffAndCloneA, error, warn, getFocusedNavigation } from '@mpxjs/utils';
|
|
4
4
|
import { VarContext } from './context';
|
|
5
5
|
import { ExpressionParser, parseFunc, ReplaceSource } from './parser';
|
|
6
6
|
import { initialWindowMetrics } from 'react-native-safe-area-context';
|
|
@@ -8,8 +8,9 @@ import FastImage from '@d11/react-native-fast-image';
|
|
|
8
8
|
export const TEXT_STYLE_REGEX = /color|font.*|text.*|letterSpacing|lineHeight|includeFontPadding|writingDirection/;
|
|
9
9
|
export const PERCENT_REGEX = /^\s*-?\d+(\.\d+)?%\s*$/;
|
|
10
10
|
export const URL_REGEX = /^\s*url\(["']?(.*?)["']?\)\s*$/;
|
|
11
|
+
export const SVG_REGEXP = /https?:\/\/.*\.(?:svg)/i;
|
|
11
12
|
export const BACKGROUND_REGEX = /^background(Image|Size|Repeat|Position)$/;
|
|
12
|
-
export const TEXT_PROPS_REGEX = /ellipsizeMode|numberOfLines/;
|
|
13
|
+
export const TEXT_PROPS_REGEX = /ellipsizeMode|numberOfLines|allowFontScaling/;
|
|
13
14
|
export const DEFAULT_FONT_SIZE = 16;
|
|
14
15
|
export const HIDDEN_STYLE = {
|
|
15
16
|
opacity: 0
|
|
@@ -26,10 +27,7 @@ const safeAreaInsetMap = {
|
|
|
26
27
|
};
|
|
27
28
|
function getSafeAreaInset(name) {
|
|
28
29
|
const navigation = getFocusedNavigation();
|
|
29
|
-
const insets = {
|
|
30
|
-
...initialWindowMetrics?.insets,
|
|
31
|
-
...navigation?.insets
|
|
32
|
-
};
|
|
30
|
+
const insets = extendObject({}, initialWindowMetrics?.insets, navigation?.insets);
|
|
33
31
|
return insets[safeAreaInsetMap[name]];
|
|
34
32
|
}
|
|
35
33
|
export function omit(obj, fields) {
|
|
@@ -81,23 +79,13 @@ export const parseUrl = (cssUrl = '') => {
|
|
|
81
79
|
return match?.[1];
|
|
82
80
|
};
|
|
83
81
|
export const getRestProps = (transferProps = {}, originProps = {}, deletePropsKey = []) => {
|
|
84
|
-
return {
|
|
85
|
-
...transferProps,
|
|
86
|
-
...omit(originProps, deletePropsKey)
|
|
87
|
-
};
|
|
82
|
+
return extendObject({}, transferProps, omit(originProps, deletePropsKey));
|
|
88
83
|
};
|
|
89
84
|
export function isText(ele) {
|
|
90
85
|
if (isValidElement(ele)) {
|
|
91
86
|
const displayName = ele.type?.displayName;
|
|
92
87
|
const isCustomText = ele.type?.isCustomText;
|
|
93
|
-
return displayName === 'MpxText' || displayName === 'Text' || !!isCustomText;
|
|
94
|
-
}
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
export function isEmbedded(ele) {
|
|
98
|
-
if (isValidElement(ele)) {
|
|
99
|
-
const displayName = ele.type?.displayName || '';
|
|
100
|
-
return ['mpx-checkbox', 'mpx-radio', 'mpx-switch'].includes(displayName);
|
|
88
|
+
return displayName === 'MpxText' || displayName === 'MpxSimpleText' || displayName === 'Text' || !!isCustomText;
|
|
101
89
|
}
|
|
102
90
|
return false;
|
|
103
91
|
}
|
|
@@ -240,6 +228,14 @@ function transformCalc(styleObj, calcKeyPaths, formatter) {
|
|
|
240
228
|
});
|
|
241
229
|
});
|
|
242
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
|
+
}
|
|
243
239
|
export function useTransformStyle(styleObj = {}, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight }) {
|
|
244
240
|
const varStyle = {};
|
|
245
241
|
const normalStyle = {};
|
|
@@ -338,6 +334,8 @@ export function useTransformStyle(styleObj = {}, { enableVar, externalVarContext
|
|
|
338
334
|
}
|
|
339
335
|
}
|
|
340
336
|
});
|
|
337
|
+
// transform number enum stringify
|
|
338
|
+
transformStringify(normalStyle);
|
|
341
339
|
return {
|
|
342
340
|
normalStyle,
|
|
343
341
|
hasSelfPercent,
|
|
@@ -404,7 +402,7 @@ export function splitProps(props) {
|
|
|
404
402
|
export const useLayout = ({ props, hasSelfPercent, setWidth, setHeight, onLayout, nodeRef }) => {
|
|
405
403
|
const layoutRef = useRef({});
|
|
406
404
|
const hasLayoutRef = useRef(false);
|
|
407
|
-
const layoutStyle = !hasLayoutRef.current && hasSelfPercent ? HIDDEN_STYLE : {};
|
|
405
|
+
const layoutStyle = useMemo(() => { return !hasLayoutRef.current && hasSelfPercent ? HIDDEN_STYLE : {}; }, [hasLayoutRef.current]);
|
|
408
406
|
const layoutProps = {};
|
|
409
407
|
const enableOffset = props['enable-offset'];
|
|
410
408
|
if (hasSelfPercent || onLayout || enableOffset) {
|
|
@@ -435,8 +433,8 @@ export function wrapChildren(props = {}, { hasVarDec, varContext, textStyle, tex
|
|
|
435
433
|
if (textStyle || textProps) {
|
|
436
434
|
children = Children.map(children, (child) => {
|
|
437
435
|
if (isText(child)) {
|
|
438
|
-
const style = {
|
|
439
|
-
return cloneElement(child, {
|
|
436
|
+
const style = extendObject({}, textStyle, child.props.style);
|
|
437
|
+
return cloneElement(child, extendObject({}, textProps, { style }));
|
|
440
438
|
}
|
|
441
439
|
return child;
|
|
442
440
|
});
|
|
@@ -483,9 +481,7 @@ export function flatGesture(gestures = []) {
|
|
|
483
481
|
return gesture?.current ? [gesture] : [];
|
|
484
482
|
})) || [];
|
|
485
483
|
}
|
|
486
|
-
export
|
|
487
|
-
return Object.assign({}, ...args);
|
|
488
|
-
}
|
|
484
|
+
export const extendObject = Object.assign;
|
|
489
485
|
export function getCurrentPage(pageId) {
|
|
490
486
|
if (!global.getCurrentPages)
|
|
491
487
|
return;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useRef } from 'react'
|
|
2
|
-
import { collectDataset } from '@mpxjs/utils'
|
|
3
|
-
import { omit } from './utils'
|
|
2
|
+
import { hasOwn, collectDataset } from '@mpxjs/utils'
|
|
3
|
+
import { omit, extendObject } from './utils'
|
|
4
4
|
import eventConfigMap from './event.config'
|
|
5
5
|
import {
|
|
6
6
|
Props,
|
|
@@ -29,17 +29,22 @@ const getTouchEvent = (
|
|
|
29
29
|
} = nativeEvent
|
|
30
30
|
const { id } = props
|
|
31
31
|
const { layoutRef } = config
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
...(event.currentTarget || {}),
|
|
32
|
+
|
|
33
|
+
const currentTarget = extendObject(
|
|
34
|
+
{},
|
|
35
|
+
event.currentTarget,
|
|
36
|
+
{
|
|
38
37
|
id: id || '',
|
|
39
38
|
dataset: collectDataset(props),
|
|
40
39
|
offsetLeft: layoutRef?.current?.offsetLeft || 0,
|
|
41
40
|
offsetTop: layoutRef?.current?.offsetTop || 0
|
|
42
|
-
}
|
|
41
|
+
}
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
return extendObject({}, event, {
|
|
45
|
+
type,
|
|
46
|
+
timeStamp: timestamp,
|
|
47
|
+
currentTarget,
|
|
43
48
|
detail: {
|
|
44
49
|
x: pageX,
|
|
45
50
|
y: pageY
|
|
@@ -65,7 +70,7 @@ const getTouchEvent = (
|
|
|
65
70
|
persist: event.persist,
|
|
66
71
|
stopPropagation: event.stopPropagation,
|
|
67
72
|
preventDefault: event.preventDefault
|
|
68
|
-
}
|
|
73
|
+
})
|
|
69
74
|
}
|
|
70
75
|
|
|
71
76
|
export const getCustomEvent = (
|
|
@@ -74,21 +79,20 @@ export const getCustomEvent = (
|
|
|
74
79
|
{ detail = {}, layoutRef }: { detail?: Record<string, unknown>; layoutRef: LayoutRef },
|
|
75
80
|
props: Props = {}
|
|
76
81
|
) => {
|
|
77
|
-
|
|
78
|
-
|
|
82
|
+
const targetInfo = extendObject({}, oe.target, {
|
|
83
|
+
id: props.id || '',
|
|
84
|
+
dataset: collectDataset(props),
|
|
85
|
+
offsetLeft: layoutRef?.current?.offsetLeft || 0,
|
|
86
|
+
offsetTop: layoutRef?.current?.offsetTop || 0
|
|
87
|
+
})
|
|
88
|
+
return extendObject({}, oe, {
|
|
79
89
|
type,
|
|
80
90
|
detail,
|
|
81
|
-
target:
|
|
82
|
-
...(oe.target || {}),
|
|
83
|
-
id: props.id || '',
|
|
84
|
-
dataset: collectDataset(props),
|
|
85
|
-
offsetLeft: layoutRef?.current?.offsetLeft || 0,
|
|
86
|
-
offsetTop: layoutRef?.current?.offsetTop || 0
|
|
87
|
-
},
|
|
91
|
+
target: targetInfo,
|
|
88
92
|
persist: oe.persist,
|
|
89
93
|
stopPropagation: oe.stopPropagation,
|
|
90
94
|
preventDefault: oe.preventDefault
|
|
91
|
-
}
|
|
95
|
+
})
|
|
92
96
|
}
|
|
93
97
|
|
|
94
98
|
const useInnerProps = (
|
|
@@ -129,10 +133,10 @@ const useInnerProps = (
|
|
|
129
133
|
...userRemoveProps
|
|
130
134
|
]
|
|
131
135
|
|
|
132
|
-
propsRef.current = {
|
|
136
|
+
propsRef.current = extendObject({}, props, additionalProps)
|
|
133
137
|
|
|
134
138
|
for (const key in eventConfigMap) {
|
|
135
|
-
if (propsRef.current
|
|
139
|
+
if (hasOwn(propsRef.current, key)) {
|
|
136
140
|
eventConfig[key] = eventConfigMap[key]
|
|
137
141
|
}
|
|
138
142
|
}
|
|
@@ -275,9 +279,11 @@ const useInnerProps = (
|
|
|
275
279
|
|
|
276
280
|
const events: Record<string, (e: NativeTouchEvent) => void> = {}
|
|
277
281
|
|
|
278
|
-
|
|
282
|
+
let transformedEventKeys: string[] = []
|
|
279
283
|
for (const key in eventConfig) {
|
|
280
|
-
|
|
284
|
+
if (propsRef.current[key]) {
|
|
285
|
+
transformedEventKeys = transformedEventKeys.concat(eventConfig[key])
|
|
286
|
+
}
|
|
281
287
|
}
|
|
282
288
|
|
|
283
289
|
const finalEventKeys = [...new Set(transformedEventKeys)]
|
|
@@ -290,9 +296,10 @@ const useInnerProps = (
|
|
|
290
296
|
|
|
291
297
|
const rawEventKeys = Object.keys(eventConfig)
|
|
292
298
|
|
|
293
|
-
return
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
299
|
+
return extendObject(
|
|
300
|
+
{},
|
|
301
|
+
events,
|
|
302
|
+
omit(propsRef.current, [...rawEventKeys, ...removeProps])
|
|
303
|
+
)
|
|
297
304
|
}
|
|
298
305
|
export default useInnerProps
|
|
@@ -45,7 +45,7 @@ import {
|
|
|
45
45
|
NativeSyntheticEvent
|
|
46
46
|
} from 'react-native'
|
|
47
47
|
import { warn } from '@mpxjs/utils'
|
|
48
|
-
import { getCurrentPage, splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren } from './utils'
|
|
48
|
+
import { getCurrentPage, splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject } from './utils'
|
|
49
49
|
import useInnerProps, { getCustomEvent } from './getInnerListeners'
|
|
50
50
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
51
51
|
import { RouteContext, FormContext } from './context'
|
|
@@ -181,11 +181,14 @@ const Loading = ({ alone = false }: { alone: boolean }): JSX.Element => {
|
|
|
181
181
|
}
|
|
182
182
|
}, [])
|
|
183
183
|
|
|
184
|
-
const loadingStyle =
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
184
|
+
const loadingStyle = extendObject(
|
|
185
|
+
{},
|
|
186
|
+
styles.loading,
|
|
187
|
+
{
|
|
188
|
+
transform: [{ rotate }],
|
|
189
|
+
marginRight: alone ? 0 : 5
|
|
190
|
+
}
|
|
191
|
+
)
|
|
189
192
|
|
|
190
193
|
return <Animated.Image testID="loading" style={loadingStyle} source={{ uri: LOADING_IMAGE_URI }} />
|
|
191
194
|
}
|
|
@@ -274,28 +277,28 @@ const Button = forwardRef<HandlerRef<View, ButtonProps>, ButtonProps>((buttonPro
|
|
|
274
277
|
backgroundColor: plain ? 'transparent' : normalBackgroundColor
|
|
275
278
|
}
|
|
276
279
|
|
|
277
|
-
const defaultViewStyle =
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
280
|
+
const defaultViewStyle = extendObject(
|
|
281
|
+
{},
|
|
282
|
+
styles.button,
|
|
283
|
+
isMiniSize ? styles.buttonMini : null,
|
|
284
|
+
viewStyle
|
|
285
|
+
)
|
|
282
286
|
|
|
283
|
-
const defaultTextStyle =
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
287
|
+
const defaultTextStyle = extendObject(
|
|
288
|
+
{},
|
|
289
|
+
styles.text,
|
|
290
|
+
isMiniSize ? styles.textMini : {},
|
|
291
|
+
{ color: plain ? plainTextColor : normalTextColor }
|
|
292
|
+
)
|
|
288
293
|
|
|
289
|
-
const defaultStyle = {
|
|
290
|
-
...defaultViewStyle,
|
|
291
|
-
...defaultTextStyle
|
|
292
|
-
}
|
|
294
|
+
const defaultStyle = extendObject({}, defaultViewStyle, defaultTextStyle)
|
|
293
295
|
|
|
294
|
-
const styleObj =
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
296
|
+
const styleObj = extendObject(
|
|
297
|
+
{},
|
|
298
|
+
defaultStyle,
|
|
299
|
+
style,
|
|
300
|
+
applyHoverEffect ? hoverStyle : {}
|
|
301
|
+
)
|
|
299
302
|
|
|
300
303
|
const {
|
|
301
304
|
hasSelfPercent,
|
|
@@ -308,11 +311,11 @@ const Button = forwardRef<HandlerRef<View, ButtonProps>, ButtonProps>((buttonPro
|
|
|
308
311
|
|
|
309
312
|
const nodeRef = useRef(null)
|
|
310
313
|
|
|
311
|
-
useNodesRef(props, ref, nodeRef, {
|
|
314
|
+
useNodesRef(props, ref, nodeRef, { style: normalStyle })
|
|
312
315
|
|
|
313
316
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef })
|
|
314
317
|
|
|
315
|
-
const { textStyle, backgroundStyle, innerStyle } = splitStyle(normalStyle)
|
|
318
|
+
const { textStyle, backgroundStyle, innerStyle = {} } = splitStyle(normalStyle)
|
|
316
319
|
|
|
317
320
|
if (backgroundStyle) {
|
|
318
321
|
warn('Button does not support background image-related styles!')
|
|
@@ -408,15 +411,31 @@ const Button = forwardRef<HandlerRef<View, ButtonProps>, ButtonProps>((buttonPro
|
|
|
408
411
|
|
|
409
412
|
const innerProps = useInnerProps(
|
|
410
413
|
props,
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
414
|
+
extendObject(
|
|
415
|
+
{
|
|
416
|
+
ref: nodeRef,
|
|
417
|
+
style: extendObject({}, innerStyle, layoutStyle)
|
|
418
|
+
},
|
|
419
|
+
layoutProps,
|
|
420
|
+
{
|
|
421
|
+
bindtouchstart: (bindtouchstart || !disabled) && onTouchStart,
|
|
422
|
+
bindtouchend: (bindtouchend || !disabled) && onTouchEnd,
|
|
423
|
+
bindtap: !disabled && onTap
|
|
424
|
+
}
|
|
425
|
+
),
|
|
426
|
+
[
|
|
427
|
+
'disabled',
|
|
428
|
+
'size',
|
|
429
|
+
'type',
|
|
430
|
+
'plain',
|
|
431
|
+
'loading',
|
|
432
|
+
'hover-class',
|
|
433
|
+
'hover-style',
|
|
434
|
+
'hover-start-time',
|
|
435
|
+
'hover-stay-time',
|
|
436
|
+
'open-type',
|
|
437
|
+
'form-type'
|
|
438
|
+
],
|
|
420
439
|
{
|
|
421
440
|
layoutRef,
|
|
422
441
|
disableTap: disabled
|
|
@@ -73,7 +73,7 @@ const _Canvas = forwardRef<HandlerRef<CanvasProps & View, CanvasProps>, CanvasPr
|
|
|
73
73
|
hasSelfPercent,
|
|
74
74
|
setWidth,
|
|
75
75
|
setHeight
|
|
76
|
-
} = useTransformStyle(extendObject(style, stylesheet.container), {
|
|
76
|
+
} = useTransformStyle(extendObject({}, style, stylesheet.container), {
|
|
77
77
|
enableVar,
|
|
78
78
|
externalVarContext,
|
|
79
79
|
parentFontSize,
|
|
@@ -93,7 +93,7 @@ const _Canvas = forwardRef<HandlerRef<CanvasProps & View, CanvasProps>, CanvasPr
|
|
|
93
93
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef })
|
|
94
94
|
const innerProps = useInnerProps(props, {
|
|
95
95
|
ref: nodeRef,
|
|
96
|
-
style: extendObject(normalStyle, layoutStyle, { opacity: isLoaded ? 1 : 0 }),
|
|
96
|
+
style: extendObject({}, normalStyle, layoutStyle, { opacity: isLoaded ? 1 : 0 }),
|
|
97
97
|
...layoutProps
|
|
98
98
|
}, [], {
|
|
99
99
|
layoutRef
|
|
@@ -19,7 +19,7 @@ import { warn } from '@mpxjs/utils'
|
|
|
19
19
|
import { FormContext, FormFieldValue, CheckboxGroupContext, GroupValue } from './context'
|
|
20
20
|
import useInnerProps, { getCustomEvent } from './getInnerListeners'
|
|
21
21
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
22
|
-
import { useLayout, useTransformStyle, wrapChildren } from './utils'
|
|
22
|
+
import { useLayout, useTransformStyle, wrapChildren, extendObject } from './utils'
|
|
23
23
|
|
|
24
24
|
export interface CheckboxGroupProps {
|
|
25
25
|
name: string
|
|
@@ -64,10 +64,7 @@ const CheckboxGroup = forwardRef<
|
|
|
64
64
|
flexWrap: 'wrap'
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
const styleObj = {
|
|
68
|
-
...defaultStyle,
|
|
69
|
-
...style
|
|
70
|
-
}
|
|
67
|
+
const styleObj = extendObject({}, defaultStyle, style)
|
|
71
68
|
|
|
72
69
|
const {
|
|
73
70
|
hasSelfPercent,
|
|
@@ -80,7 +77,7 @@ const CheckboxGroup = forwardRef<
|
|
|
80
77
|
|
|
81
78
|
const nodeRef = useRef(null)
|
|
82
79
|
|
|
83
|
-
useNodesRef(props, ref, nodeRef, {
|
|
80
|
+
useNodesRef(props, ref, nodeRef, { style: normalStyle })
|
|
84
81
|
|
|
85
82
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef })
|
|
86
83
|
|
|
@@ -119,12 +116,16 @@ const CheckboxGroup = forwardRef<
|
|
|
119
116
|
|
|
120
117
|
const innerProps = useInnerProps(
|
|
121
118
|
props,
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
119
|
+
extendObject(
|
|
120
|
+
{
|
|
121
|
+
ref: nodeRef,
|
|
122
|
+
style: extendObject({}, normalStyle, layoutStyle)
|
|
123
|
+
},
|
|
124
|
+
layoutProps
|
|
125
|
+
),
|
|
126
|
+
[
|
|
127
|
+
'name'
|
|
128
|
+
],
|
|
128
129
|
{
|
|
129
130
|
layoutRef
|
|
130
131
|
}
|
|
@@ -25,7 +25,7 @@ import { warn } from '@mpxjs/utils'
|
|
|
25
25
|
import useInnerProps, { getCustomEvent } from './getInnerListeners'
|
|
26
26
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
27
27
|
import Icon from './mpx-icon'
|
|
28
|
-
import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren } from './utils'
|
|
28
|
+
import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject } from './utils'
|
|
29
29
|
import { CheckboxGroupContext, LabelContext } from './context'
|
|
30
30
|
|
|
31
31
|
interface Selection {
|
|
@@ -46,7 +46,7 @@ export interface CheckboxProps extends Selection {
|
|
|
46
46
|
'parent-height'?: number;
|
|
47
47
|
children?: ReactNode
|
|
48
48
|
bindtap?: (evt: NativeSyntheticEvent<TouchEvent> | unknown) => void
|
|
49
|
-
|
|
49
|
+
_onChange?: (evt: NativeSyntheticEvent<TouchEvent> | unknown, { checked }: { checked: boolean }) => void
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
const styles = StyleSheet.create({
|
|
@@ -92,7 +92,7 @@ const Checkbox = forwardRef<HandlerRef<View, CheckboxProps>, CheckboxProps>(
|
|
|
92
92
|
'parent-width': parentWidth,
|
|
93
93
|
'parent-height': parentHeight,
|
|
94
94
|
bindtap,
|
|
95
|
-
|
|
95
|
+
_onChange
|
|
96
96
|
} = props
|
|
97
97
|
|
|
98
98
|
const [isChecked, setIsChecked] = useState<boolean>(!!checked)
|
|
@@ -101,15 +101,13 @@ const Checkbox = forwardRef<HandlerRef<View, CheckboxProps>, CheckboxProps>(
|
|
|
101
101
|
let groupValue: { [key: string]: { checked: boolean; setValue: Dispatch<SetStateAction<boolean>>; } } | undefined
|
|
102
102
|
let notifyChange: (evt: NativeSyntheticEvent<TouchEvent>) => void | undefined
|
|
103
103
|
|
|
104
|
-
const defaultStyle =
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
104
|
+
const defaultStyle = extendObject(
|
|
105
|
+
{},
|
|
106
|
+
styles.wrapper,
|
|
107
|
+
disabled ? styles.wrapperDisabled : null
|
|
108
|
+
)
|
|
108
109
|
|
|
109
|
-
const styleObj = {
|
|
110
|
-
...styles.container,
|
|
111
|
-
...style
|
|
112
|
-
}
|
|
110
|
+
const styleObj = extendObject({}, styles.container, style)
|
|
113
111
|
|
|
114
112
|
const onChange = (evt: NativeSyntheticEvent<TouchEvent>) => {
|
|
115
113
|
if (disabled) return
|
|
@@ -119,20 +117,15 @@ const Checkbox = forwardRef<HandlerRef<View, CheckboxProps>, CheckboxProps>(
|
|
|
119
117
|
groupValue[value].checked = checked
|
|
120
118
|
}
|
|
121
119
|
notifyChange && notifyChange(evt)
|
|
120
|
+
// Called when the switch type attribute is checkbox
|
|
121
|
+
_onChange && _onChange(evt, { checked })
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
const onTap = (evt: NativeSyntheticEvent<TouchEvent>) => {
|
|
125
|
-
if (disabled) return
|
|
126
125
|
bindtap && bindtap(getCustomEvent('tap', evt, { layoutRef }, props))
|
|
127
126
|
onChange(evt)
|
|
128
127
|
}
|
|
129
128
|
|
|
130
|
-
const catchTap = (evt: NativeSyntheticEvent<TouchEvent>) => {
|
|
131
|
-
if (disabled) return
|
|
132
|
-
catchtap && catchtap(getCustomEvent('tap', evt, { layoutRef }, props))
|
|
133
|
-
onChange(evt)
|
|
134
|
-
}
|
|
135
|
-
|
|
136
129
|
const {
|
|
137
130
|
hasSelfPercent,
|
|
138
131
|
normalStyle,
|
|
@@ -145,13 +138,13 @@ const Checkbox = forwardRef<HandlerRef<View, CheckboxProps>, CheckboxProps>(
|
|
|
145
138
|
const nodeRef = useRef(null)
|
|
146
139
|
|
|
147
140
|
useNodesRef(props, ref, nodeRef, {
|
|
148
|
-
defaultStyle,
|
|
141
|
+
style: extendObject({}, defaultStyle, normalStyle),
|
|
149
142
|
change: onChange
|
|
150
143
|
})
|
|
151
144
|
|
|
152
145
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef })
|
|
153
146
|
|
|
154
|
-
const { textStyle, backgroundStyle, innerStyle } = splitStyle(normalStyle)
|
|
147
|
+
const { textStyle, backgroundStyle, innerStyle = {} } = splitStyle(normalStyle)
|
|
155
148
|
|
|
156
149
|
if (backgroundStyle) {
|
|
157
150
|
warn('Checkbox does not support background image-related styles!')
|
|
@@ -170,14 +163,21 @@ const Checkbox = forwardRef<HandlerRef<View, CheckboxProps>, CheckboxProps>(
|
|
|
170
163
|
|
|
171
164
|
const innerProps = useInnerProps(
|
|
172
165
|
props,
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
166
|
+
extendObject(
|
|
167
|
+
{
|
|
168
|
+
ref: nodeRef,
|
|
169
|
+
style: extendObject({}, innerStyle, layoutStyle)
|
|
170
|
+
},
|
|
171
|
+
layoutProps,
|
|
172
|
+
{
|
|
173
|
+
bindtap: !disabled && onTap
|
|
174
|
+
}
|
|
175
|
+
),
|
|
176
|
+
[
|
|
177
|
+
'value',
|
|
178
|
+
'disabled',
|
|
179
|
+
'checked'
|
|
180
|
+
],
|
|
181
181
|
{
|
|
182
182
|
layoutRef
|
|
183
183
|
}
|
|
@@ -9,7 +9,7 @@ import { JSX, useRef, forwardRef, ReactNode, useMemo, useCallback } from 'react'
|
|
|
9
9
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
10
10
|
import useInnerProps, { getCustomEvent } from './getInnerListeners'
|
|
11
11
|
import { FormContext } from './context'
|
|
12
|
-
import { useTransformStyle, splitProps, splitStyle, useLayout, wrapChildren } from './utils'
|
|
12
|
+
import { useTransformStyle, splitProps, splitStyle, useLayout, wrapChildren, extendObject } from './utils'
|
|
13
13
|
interface FormProps {
|
|
14
14
|
style?: Record<string, any>;
|
|
15
15
|
children?: ReactNode;
|
|
@@ -47,21 +47,23 @@ const _Form = forwardRef<HandlerRef<View, FormProps>, FormProps>((fromProps: For
|
|
|
47
47
|
setHeight
|
|
48
48
|
} = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
|
|
49
49
|
|
|
50
|
-
const { textStyle, innerStyle } = splitStyle(normalStyle)
|
|
50
|
+
const { textStyle, innerStyle = {} } = splitStyle(normalStyle)
|
|
51
51
|
|
|
52
52
|
const formRef = useRef(null)
|
|
53
|
-
useNodesRef(props, ref, formRef
|
|
53
|
+
useNodesRef(props, ref, formRef, {
|
|
54
|
+
style: normalStyle
|
|
55
|
+
})
|
|
54
56
|
|
|
55
57
|
const propsRef = useRef<FormProps>({})
|
|
56
58
|
propsRef.current = props
|
|
57
59
|
|
|
58
60
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: formRef })
|
|
59
61
|
|
|
60
|
-
const innerProps = useInnerProps(props, {
|
|
61
|
-
style: {
|
|
62
|
-
ref: formRef
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
const innerProps = useInnerProps(props, extendObject({
|
|
63
|
+
style: extendObject({}, innerStyle, layoutStyle),
|
|
64
|
+
ref: formRef
|
|
65
|
+
}, layoutProps)
|
|
66
|
+
, [
|
|
65
67
|
'bindsubmit',
|
|
66
68
|
'bindreset'
|
|
67
69
|
], { layoutRef })
|
|
@@ -7,7 +7,7 @@ import { JSX, forwardRef, useRef } from 'react'
|
|
|
7
7
|
import { Text, TextStyle, Image } from 'react-native'
|
|
8
8
|
import useInnerProps from './getInnerListeners'
|
|
9
9
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
10
|
-
import { useLayout, useTransformStyle } from './utils'
|
|
10
|
+
import { useLayout, useTransformStyle, extendObject } from './utils'
|
|
11
11
|
|
|
12
12
|
export type IconType =
|
|
13
13
|
| 'success'
|
|
@@ -63,10 +63,7 @@ const Icon = forwardRef<HandlerRef<Text, IconProps>, IconProps>(
|
|
|
63
63
|
|
|
64
64
|
const defaultStyle = { width: ~~size, height: ~~size }
|
|
65
65
|
|
|
66
|
-
const styleObj = {
|
|
67
|
-
...defaultStyle,
|
|
68
|
-
...style
|
|
69
|
-
}
|
|
66
|
+
const styleObj = extendObject({}, defaultStyle, style)
|
|
70
67
|
|
|
71
68
|
const {
|
|
72
69
|
hasSelfPercent,
|
|
@@ -76,22 +73,20 @@ const Icon = forwardRef<HandlerRef<Text, IconProps>, IconProps>(
|
|
|
76
73
|
} = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
|
|
77
74
|
|
|
78
75
|
const nodeRef = useRef(null)
|
|
79
|
-
useNodesRef(props, ref, nodeRef, {
|
|
76
|
+
useNodesRef(props, ref, nodeRef, { style: normalStyle })
|
|
80
77
|
|
|
81
78
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef })
|
|
82
79
|
|
|
83
80
|
const innerProps = useInnerProps(
|
|
84
81
|
props,
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
tintColor: color
|
|
82
|
+
extendObject(
|
|
83
|
+
{
|
|
84
|
+
ref: nodeRef,
|
|
85
|
+
source: { uri },
|
|
86
|
+
style: extendObject({}, normalStyle, layoutStyle, { tintColor: color })
|
|
91
87
|
},
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
},
|
|
88
|
+
layoutProps
|
|
89
|
+
),
|
|
95
90
|
[],
|
|
96
91
|
{
|
|
97
92
|
layoutRef
|