@mpxjs/webpack-plugin 2.10.22 → 2.10.24-test.1
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/loader.js +2 -0
- package/lib/platform/style/wx/index.js +395 -104
- package/lib/react/index.js +3 -1
- package/lib/react/processTemplate.js +3 -1
- package/lib/react/style-helper.js +6 -6
- package/lib/runtime/components/react/animationHooks/index.ts +7 -3
- package/lib/runtime/components/react/dist/animationHooks/index.d.ts +0 -2
- package/lib/runtime/components/react/dist/animationHooks/index.js +6 -1
- package/lib/runtime/components/react/dist/event.config.d.ts +2 -6
- package/lib/runtime/components/react/dist/event.config.js +28 -24
- package/lib/runtime/components/react/dist/getInnerListeners.d.ts +1 -1
- package/lib/runtime/components/react/dist/getInnerListeners.js +74 -56
- package/lib/runtime/components/react/dist/mpx-button.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-button.jsx +16 -9
- package/lib/runtime/components/react/dist/mpx-camera.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-camera.jsx +1 -2
- package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +1 -2
- package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +3 -4
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-checkbox.jsx +8 -9
- package/lib/runtime/components/react/dist/mpx-form.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-form.jsx +5 -5
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-icon/index.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-image.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-image.jsx +59 -43
- package/lib/runtime/components/react/dist/mpx-input.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-input.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-label.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-label.jsx +5 -6
- package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +3 -3
- package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +6 -6
- package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +5 -7
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-progress.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-progress.jsx +1 -2
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-radio-group.jsx +3 -4
- package/lib/runtime/components/react/dist/mpx-radio.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-radio.jsx +8 -9
- package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +1 -2
- package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +6 -6
- package/lib/runtime/components/react/dist/mpx-simple-text.jsx +36 -31
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +4 -2
- package/lib/runtime/components/react/dist/mpx-simple-view.jsx +24 -17
- package/lib/runtime/components/react/dist/mpx-slider.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-slider.jsx +6 -6
- package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +5 -5
- package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-sticky-section.jsx +6 -6
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +5 -5
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +4 -7
- package/lib/runtime/components/react/dist/mpx-switch.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-switch.jsx +1 -2
- package/lib/runtime/components/react/dist/mpx-text.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-text.jsx +44 -40
- package/lib/runtime/components/react/dist/mpx-video.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-video.jsx +4 -4
- package/lib/runtime/components/react/dist/mpx-view.d.ts +2 -1
- package/lib/runtime/components/react/dist/mpx-view.jsx +229 -128
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +5 -1
- package/lib/runtime/components/react/dist/namedColorSet.d.ts +2 -0
- package/lib/runtime/components/react/dist/namedColorSet.js +149 -0
- package/lib/runtime/components/react/dist/utils.d.ts +73 -69
- package/lib/runtime/components/react/dist/utils.jsx +1295 -442
- package/lib/runtime/components/react/event.config.ts +32 -25
- package/lib/runtime/components/react/getInnerListeners.ts +84 -60
- package/lib/runtime/components/react/mpx-button.tsx +18 -16
- package/lib/runtime/components/react/mpx-camera.tsx +0 -3
- package/lib/runtime/components/react/mpx-canvas/index.tsx +1 -3
- package/lib/runtime/components/react/mpx-canvas/utils.tsx +3 -1
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +2 -6
- package/lib/runtime/components/react/mpx-checkbox.tsx +9 -11
- package/lib/runtime/components/react/mpx-form.tsx +6 -6
- package/lib/runtime/components/react/mpx-icon/index.tsx +1 -3
- package/lib/runtime/components/react/mpx-image.tsx +65 -54
- package/lib/runtime/components/react/mpx-input.tsx +1 -3
- package/lib/runtime/components/react/mpx-label.tsx +6 -8
- package/lib/runtime/components/react/mpx-movable-area.tsx +3 -4
- package/lib/runtime/components/react/mpx-movable-view.tsx +7 -7
- package/lib/runtime/components/react/mpx-picker-view/index.tsx +6 -8
- package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +2 -4
- package/lib/runtime/components/react/mpx-progress.tsx +0 -3
- package/lib/runtime/components/react/mpx-radio-group.tsx +2 -6
- package/lib/runtime/components/react/mpx-radio.tsx +9 -11
- package/lib/runtime/components/react/mpx-rich-text/index.tsx +0 -3
- package/lib/runtime/components/react/mpx-scroll-view.tsx +7 -7
- package/lib/runtime/components/react/mpx-simple-text.tsx +36 -38
- package/lib/runtime/components/react/mpx-simple-view.tsx +29 -17
- package/lib/runtime/components/react/mpx-slider.tsx +15 -10
- package/lib/runtime/components/react/mpx-sticky-header.tsx +6 -6
- package/lib/runtime/components/react/mpx-sticky-section.tsx +7 -7
- package/lib/runtime/components/react/mpx-swiper-item.tsx +6 -6
- package/lib/runtime/components/react/mpx-swiper.tsx +5 -8
- package/lib/runtime/components/react/mpx-switch.tsx +0 -3
- package/lib/runtime/components/react/mpx-text.tsx +46 -49
- package/lib/runtime/components/react/mpx-video.tsx +3 -5
- package/lib/runtime/components/react/mpx-view.tsx +250 -141
- package/lib/runtime/components/react/mpx-web-view.tsx +8 -3
- package/lib/runtime/components/react/namedColorSet.ts +150 -0
- package/lib/runtime/components/react/types/getInnerListeners.d.ts +21 -1
- package/lib/runtime/components/react/types/global.d.ts +1 -0
- package/lib/runtime/components/react/utils.tsx +1347 -539
- package/lib/runtime/i18n.wxs +15 -9
- package/lib/style-compiler/strip-conditional.js +19 -4
- package/lib/template-compiler/compiler.js +5 -1
- package/lib/utils/source-location.js +9 -13
- package/lib/web/index.js +3 -1
- package/lib/web/processTemplate.js +3 -1
- package/package.json +5 -4
- package/LICENSE +0 -433
package/lib/react/index.js
CHANGED
|
@@ -23,6 +23,7 @@ module.exports = function ({
|
|
|
23
23
|
usingComponentsInfo,
|
|
24
24
|
originalUsingComponents,
|
|
25
25
|
componentGenerics,
|
|
26
|
+
componentPlaceholder,
|
|
26
27
|
autoScope,
|
|
27
28
|
callback
|
|
28
29
|
}) {
|
|
@@ -55,7 +56,8 @@ module.exports = function ({
|
|
|
55
56
|
ctorType,
|
|
56
57
|
usingComponentsInfo,
|
|
57
58
|
originalUsingComponents,
|
|
58
|
-
componentGenerics
|
|
59
|
+
componentGenerics,
|
|
60
|
+
componentPlaceholder
|
|
59
61
|
}, callback)
|
|
60
62
|
},
|
|
61
63
|
(callback) => {
|
|
@@ -32,7 +32,8 @@ module.exports = function (template, {
|
|
|
32
32
|
ctorType,
|
|
33
33
|
usingComponentsInfo,
|
|
34
34
|
originalUsingComponents,
|
|
35
|
-
componentGenerics
|
|
35
|
+
componentGenerics,
|
|
36
|
+
componentPlaceholder
|
|
36
37
|
}, callback) {
|
|
37
38
|
const mpx = loaderContext.getMpx()
|
|
38
39
|
const {
|
|
@@ -103,6 +104,7 @@ module.exports = function (template, {
|
|
|
103
104
|
i18n: null,
|
|
104
105
|
// 与 template-compiler/index 一致:usingComponentsInfo 已合并 globalComponentsInfo,此处白名单避免对仅 app 注册的组件误报「未使用」
|
|
105
106
|
globalComponents: Object.keys(globalComponents || {}),
|
|
107
|
+
componentPlaceholder,
|
|
106
108
|
// rn模式下实现抽象组件
|
|
107
109
|
componentGenerics,
|
|
108
110
|
hasVirtualHost: matchCondition(resourcePath, autoVirtualHostRules),
|
|
@@ -5,21 +5,21 @@ const getRulesRunner = require('../platform/index')
|
|
|
5
5
|
const createDiagnostic = require('../platform/create-diagnostic')
|
|
6
6
|
const dash2hump = require('../utils/hump-dash').dash2hump
|
|
7
7
|
const parseValues = require('../utils/string').parseValues
|
|
8
|
-
const unitRegExp = /^\s*(
|
|
8
|
+
const unitRegExp = /^\s*(-?(?:\d+(?:\.\d+)?|\.\d+))(rpx|vw|vh|px)?\s*$/
|
|
9
9
|
const hairlineRegExp = /^\s*hairlineWidth\s*$/
|
|
10
10
|
const varRegExp = /^--/
|
|
11
11
|
const cssPrefixExp = /^-(webkit|moz|ms|o)-/
|
|
12
12
|
function getClassMap ({ content, styles, filename, inputFileSystem, mode, srcMode, ctorType, formatValueName, warn, error }) {
|
|
13
13
|
const classMap = ctorType === 'page'
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
? { [MPX_TAG_PAGE_SELECTOR]: { flex: 1, height: "'100%'" } }
|
|
15
|
+
: {}
|
|
16
16
|
|
|
17
17
|
styles = styles && styles.length
|
|
18
18
|
? styles
|
|
19
19
|
: [{
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
content,
|
|
21
|
+
filename
|
|
22
|
+
}]
|
|
23
23
|
|
|
24
24
|
function formatValue (value) {
|
|
25
25
|
let needStringify = true
|
|
@@ -4,14 +4,13 @@ import useAnimationAPIHooks from './useAnimationAPIHooks'
|
|
|
4
4
|
import useTransitionHooks from './useTransitionHooks'
|
|
5
5
|
import type { AnimatableValue } from 'react-native-reanimated'
|
|
6
6
|
import type { MutableRefObject } from 'react'
|
|
7
|
-
import type { NativeSyntheticEvent } from 'react-native'
|
|
8
7
|
import type { _ViewProps } from '../mpx-view'
|
|
9
8
|
|
|
10
9
|
// 动画类型
|
|
11
10
|
export type AnimationType = 'api'|'animation'|'transition'|'none'
|
|
12
11
|
|
|
13
|
-
export default function useAnimationHooks<T, P> (props: _ViewProps & { enableAnimation?: boolean | AnimationType, layoutRef: MutableRefObject<any
|
|
14
|
-
const { style: originalStyle = {}, enableAnimation, animation,
|
|
12
|
+
export default function useAnimationHooks<T, P> (props: _ViewProps & { enableAnimation?: boolean | AnimationType, layoutRef: MutableRefObject<any> }) {
|
|
13
|
+
const { style: originalStyle = {}, enableAnimation, animation, catchtransitionend, bindtransitionend, layoutRef } = props
|
|
15
14
|
// 记录动画类型
|
|
16
15
|
let animationType = ''
|
|
17
16
|
if (hasOwn(originalStyle, 'animation') || (hasOwn(originalStyle, 'animationName') && hasOwn(originalStyle, 'animationDuration'))) {
|
|
@@ -42,6 +41,11 @@ export default function useAnimationHooks<T, P> (props: _ViewProps & { enableAni
|
|
|
42
41
|
if (!animationTypeRef.current) return { enableStyleAnimation: false }
|
|
43
42
|
|
|
44
43
|
const hooksProps = { style: originalStyle }
|
|
44
|
+
const transitionend = typeof catchtransitionend === 'function'
|
|
45
|
+
? catchtransitionend
|
|
46
|
+
: typeof bindtransitionend === 'function'
|
|
47
|
+
? bindtransitionend
|
|
48
|
+
: undefined
|
|
45
49
|
if (transitionend && typeof transitionend === 'function') {
|
|
46
50
|
function withTimingCallback (finished?: boolean, current?: AnimatableValue, duration?: number) {
|
|
47
51
|
const target = {
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import type { MutableRefObject } from 'react';
|
|
2
|
-
import type { NativeSyntheticEvent } from 'react-native';
|
|
3
2
|
import type { _ViewProps } from '../mpx-view';
|
|
4
3
|
export type AnimationType = 'api' | 'animation' | 'transition' | 'none';
|
|
5
4
|
export default function useAnimationHooks<T, P>(props: _ViewProps & {
|
|
6
5
|
enableAnimation?: boolean | AnimationType;
|
|
7
6
|
layoutRef: MutableRefObject<any>;
|
|
8
|
-
transitionend?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void;
|
|
9
7
|
}): {
|
|
10
8
|
enableStyleAnimation: boolean;
|
|
11
9
|
animationStyle?: undefined;
|
|
@@ -3,7 +3,7 @@ import { useRef } from 'react';
|
|
|
3
3
|
import useAnimationAPIHooks from './useAnimationAPIHooks';
|
|
4
4
|
import useTransitionHooks from './useTransitionHooks';
|
|
5
5
|
export default function useAnimationHooks(props) {
|
|
6
|
-
const { style: originalStyle = {}, enableAnimation, animation,
|
|
6
|
+
const { style: originalStyle = {}, enableAnimation, animation, catchtransitionend, bindtransitionend, layoutRef } = props;
|
|
7
7
|
// 记录动画类型
|
|
8
8
|
let animationType = '';
|
|
9
9
|
if (hasOwn(originalStyle, 'animation') || (hasOwn(originalStyle, 'animationName') && hasOwn(originalStyle, 'animationDuration'))) {
|
|
@@ -34,6 +34,11 @@ export default function useAnimationHooks(props) {
|
|
|
34
34
|
if (!animationTypeRef.current)
|
|
35
35
|
return { enableStyleAnimation: false };
|
|
36
36
|
const hooksProps = { style: originalStyle };
|
|
37
|
+
const transitionend = typeof catchtransitionend === 'function'
|
|
38
|
+
? catchtransitionend
|
|
39
|
+
: typeof bindtransitionend === 'function'
|
|
40
|
+
? bindtransitionend
|
|
41
|
+
: undefined;
|
|
37
42
|
if (transitionend && typeof transitionend === 'function') {
|
|
38
43
|
function withTimingCallback(finished, current, duration) {
|
|
39
44
|
const target = {
|
|
@@ -1,27 +1,31 @@
|
|
|
1
|
+
const tapEvents = ['onTouchStart', 'onTouchMove', 'onTouchEnd'];
|
|
2
|
+
const longpressEvents = ['onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel'];
|
|
3
|
+
const tapCaptureEvents = ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture'];
|
|
4
|
+
const longpressCaptureEvents = ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture', 'onTouchCancelCapture'];
|
|
1
5
|
const eventConfigMap = {
|
|
2
|
-
bindtap: { bitFlag: '0', events:
|
|
3
|
-
bindlongpress: { bitFlag: '1', events:
|
|
4
|
-
bindtouchstart: { bitFlag: '2', events: ['onTouchStart'] },
|
|
5
|
-
bindtouchmove: { bitFlag: '3', events: ['onTouchMove'] },
|
|
6
|
-
bindtouchend: { bitFlag: '4', events: ['onTouchEnd'] },
|
|
7
|
-
bindtouchcancel: { bitFlag: '5', events: ['onTouchCancel'] },
|
|
8
|
-
catchtap: { bitFlag: '6', events:
|
|
9
|
-
catchlongpress: { bitFlag: '7', events:
|
|
10
|
-
catchtouchstart: { bitFlag: '8', events: ['onTouchStart'] },
|
|
11
|
-
catchtouchmove: { bitFlag: '9', events: ['onTouchMove'] },
|
|
12
|
-
catchtouchend: { bitFlag: 'a', events: ['onTouchEnd'] },
|
|
13
|
-
catchtouchcancel: { bitFlag: 'b', events: ['onTouchCancel'] },
|
|
14
|
-
'capture-bindtap': { bitFlag: 'c', events:
|
|
15
|
-
'capture-bindlongpress': { bitFlag: 'd', events:
|
|
16
|
-
'capture-bindtouchstart': { bitFlag: 'e', events: ['onTouchStartCapture'] },
|
|
17
|
-
'capture-bindtouchmove': { bitFlag: 'f', events: ['onTouchMoveCapture'] },
|
|
18
|
-
'capture-bindtouchend': { bitFlag: 'g', events: ['onTouchEndCapture'] },
|
|
19
|
-
'capture-bindtouchcancel': { bitFlag: 'h', events: ['onTouchCancelCapture'] },
|
|
20
|
-
'capture-catchtap': { bitFlag: 'i', events:
|
|
21
|
-
'capture-catchlongpress': { bitFlag: 'j', events:
|
|
22
|
-
'capture-catchtouchstart': { bitFlag: 'k', events: ['onTouchStartCapture'] },
|
|
23
|
-
'capture-catchtouchmove': { bitFlag: 'l', events: ['onTouchMoveCapture'] },
|
|
24
|
-
'capture-catchtouchend': { bitFlag: 'm', events: ['onTouchEndCapture'] },
|
|
25
|
-
'capture-catchtouchcancel': { bitFlag: 'n', events: ['onTouchCancelCapture'] }
|
|
6
|
+
bindtap: { bitFlag: '0', events: tapEvents, eventName: 'tap', eventType: 'bubble', hasCatch: false },
|
|
7
|
+
bindlongpress: { bitFlag: '1', events: longpressEvents, eventName: 'longpress', eventType: 'bubble', hasCatch: false },
|
|
8
|
+
bindtouchstart: { bitFlag: '2', events: ['onTouchStart'], eventName: 'touchstart', eventType: 'bubble', hasCatch: false },
|
|
9
|
+
bindtouchmove: { bitFlag: '3', events: ['onTouchMove'], eventName: 'touchmove', eventType: 'bubble', hasCatch: false },
|
|
10
|
+
bindtouchend: { bitFlag: '4', events: ['onTouchEnd'], eventName: 'touchend', eventType: 'bubble', hasCatch: false },
|
|
11
|
+
bindtouchcancel: { bitFlag: '5', events: ['onTouchCancel'], eventName: 'touchcancel', eventType: 'bubble', hasCatch: false },
|
|
12
|
+
catchtap: { bitFlag: '6', events: tapEvents, eventName: 'tap', eventType: 'bubble', hasCatch: true },
|
|
13
|
+
catchlongpress: { bitFlag: '7', events: longpressEvents, eventName: 'longpress', eventType: 'bubble', hasCatch: true },
|
|
14
|
+
catchtouchstart: { bitFlag: '8', events: ['onTouchStart'], eventName: 'touchstart', eventType: 'bubble', hasCatch: true },
|
|
15
|
+
catchtouchmove: { bitFlag: '9', events: ['onTouchMove'], eventName: 'touchmove', eventType: 'bubble', hasCatch: true },
|
|
16
|
+
catchtouchend: { bitFlag: 'a', events: ['onTouchEnd'], eventName: 'touchend', eventType: 'bubble', hasCatch: true },
|
|
17
|
+
catchtouchcancel: { bitFlag: 'b', events: ['onTouchCancel'], eventName: 'touchcancel', eventType: 'bubble', hasCatch: true },
|
|
18
|
+
'capture-bindtap': { bitFlag: 'c', events: tapCaptureEvents, eventName: 'tap', eventType: 'capture', hasCatch: false },
|
|
19
|
+
'capture-bindlongpress': { bitFlag: 'd', events: longpressCaptureEvents, eventName: 'longpress', eventType: 'capture', hasCatch: false },
|
|
20
|
+
'capture-bindtouchstart': { bitFlag: 'e', events: ['onTouchStartCapture'], eventName: 'touchstart', eventType: 'capture', hasCatch: false },
|
|
21
|
+
'capture-bindtouchmove': { bitFlag: 'f', events: ['onTouchMoveCapture'], eventName: 'touchmove', eventType: 'capture', hasCatch: false },
|
|
22
|
+
'capture-bindtouchend': { bitFlag: 'g', events: ['onTouchEndCapture'], eventName: 'touchend', eventType: 'capture', hasCatch: false },
|
|
23
|
+
'capture-bindtouchcancel': { bitFlag: 'h', events: ['onTouchCancelCapture'], eventName: 'touchcancel', eventType: 'capture', hasCatch: false },
|
|
24
|
+
'capture-catchtap': { bitFlag: 'i', events: tapCaptureEvents, eventName: 'tap', eventType: 'capture', hasCatch: true },
|
|
25
|
+
'capture-catchlongpress': { bitFlag: 'j', events: longpressCaptureEvents, eventName: 'longpress', eventType: 'capture', hasCatch: true },
|
|
26
|
+
'capture-catchtouchstart': { bitFlag: 'k', events: ['onTouchStartCapture'], eventName: 'touchstart', eventType: 'capture', hasCatch: true },
|
|
27
|
+
'capture-catchtouchmove': { bitFlag: 'l', events: ['onTouchMoveCapture'], eventName: 'touchmove', eventType: 'capture', hasCatch: true },
|
|
28
|
+
'capture-catchtouchend': { bitFlag: 'm', events: ['onTouchEndCapture'], eventName: 'touchend', eventType: 'capture', hasCatch: true },
|
|
29
|
+
'capture-catchtouchcancel': { bitFlag: 'n', events: ['onTouchCancelCapture'], eventName: 'touchcancel', eventType: 'capture', hasCatch: true }
|
|
26
30
|
};
|
|
27
31
|
export default eventConfigMap;
|
|
@@ -3,5 +3,5 @@ export declare const getCustomEvent: (type: string | undefined, oe: any, { detai
|
|
|
3
3
|
detail?: Record<string, unknown> | undefined;
|
|
4
4
|
layoutRef?: LayoutRef | undefined;
|
|
5
5
|
}, props?: Props) => any;
|
|
6
|
-
declare const useInnerProps: (props?: Props, userRemoveProps?: RemoveProps, rawConfig?: RawConfig) => Record<string, (e: ExtendedNativeTouchEvent) => void> &
|
|
6
|
+
declare const useInnerProps: (props?: Props, userRemoveProps?: RemoveProps, rawConfig?: RawConfig) => Record<string, (e: ExtendedNativeTouchEvent) => void> & Props;
|
|
7
7
|
export default useInnerProps;
|
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import { useRef, useMemo } from 'react';
|
|
2
2
|
import { collectDataset } from '@mpxjs/utils';
|
|
3
|
-
import {
|
|
3
|
+
import { extendObject, useNavigation } from './utils';
|
|
4
4
|
import eventConfigMap from './event.config';
|
|
5
5
|
const globalEventState = {
|
|
6
6
|
needPress: true,
|
|
7
7
|
identifier: null
|
|
8
8
|
};
|
|
9
|
+
const baseRemovePropsMap = {
|
|
10
|
+
children: true,
|
|
11
|
+
'enable-background': true,
|
|
12
|
+
'enable-offset': true,
|
|
13
|
+
'enable-var': true,
|
|
14
|
+
'external-var-context': true,
|
|
15
|
+
'parent-font-size': true,
|
|
16
|
+
'parent-width': true,
|
|
17
|
+
'parent-height': true,
|
|
18
|
+
'enable-text-pass-through': true
|
|
19
|
+
};
|
|
9
20
|
const getTouchEvent = (type, event, config) => {
|
|
10
21
|
const { navigation, propsRef, layoutRef } = config;
|
|
11
22
|
const props = propsRef.current;
|
|
@@ -162,26 +173,44 @@ function handleTouchcancel(e, type, eventConfig) {
|
|
|
162
173
|
handleEmitEvent('touchcancel', e, type, eventConfig);
|
|
163
174
|
innerRef.current.startTimer[type] && clearTimeout(innerRef.current.startTimer[type]);
|
|
164
175
|
}
|
|
165
|
-
|
|
176
|
+
const touchHandlerMap = {
|
|
177
|
+
onTouchStart: {
|
|
178
|
+
type: 'bubble',
|
|
179
|
+
handler: handleTouchstart
|
|
180
|
+
},
|
|
181
|
+
onTouchMove: {
|
|
182
|
+
type: 'bubble',
|
|
183
|
+
handler: handleTouchmove
|
|
184
|
+
},
|
|
185
|
+
onTouchEnd: {
|
|
186
|
+
type: 'bubble',
|
|
187
|
+
handler: handleTouchend
|
|
188
|
+
},
|
|
189
|
+
onTouchCancel: {
|
|
190
|
+
type: 'bubble',
|
|
191
|
+
handler: handleTouchcancel
|
|
192
|
+
},
|
|
193
|
+
onTouchStartCapture: {
|
|
194
|
+
type: 'capture',
|
|
195
|
+
handler: handleTouchstart
|
|
196
|
+
},
|
|
197
|
+
onTouchMoveCapture: {
|
|
198
|
+
type: 'capture',
|
|
199
|
+
handler: handleTouchmove
|
|
200
|
+
},
|
|
201
|
+
onTouchEndCapture: {
|
|
202
|
+
type: 'capture',
|
|
203
|
+
handler: handleTouchend
|
|
204
|
+
},
|
|
205
|
+
onTouchCancelCapture: {
|
|
206
|
+
type: 'capture',
|
|
207
|
+
handler: handleTouchcancel
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
function createTouchEventHandler(eventName, eventConfigRef) {
|
|
211
|
+
const eventHandler = touchHandlerMap[eventName];
|
|
166
212
|
return (e) => {
|
|
167
|
-
|
|
168
|
-
onTouchStart: handleTouchstart,
|
|
169
|
-
onTouchMove: handleTouchmove,
|
|
170
|
-
onTouchEnd: handleTouchend,
|
|
171
|
-
onTouchCancel: handleTouchcancel
|
|
172
|
-
};
|
|
173
|
-
const captureHandlerMap = {
|
|
174
|
-
onTouchStartCapture: handleTouchstart,
|
|
175
|
-
onTouchMoveCapture: handleTouchmove,
|
|
176
|
-
onTouchEndCapture: handleTouchend,
|
|
177
|
-
onTouchCancelCapture: handleTouchcancel
|
|
178
|
-
};
|
|
179
|
-
if (bubbleHandlerMap[eventName]) {
|
|
180
|
-
bubbleHandlerMap[eventName](e, 'bubble', eventConfig);
|
|
181
|
-
}
|
|
182
|
-
if (captureHandlerMap[eventName]) {
|
|
183
|
-
captureHandlerMap[eventName](e, 'capture', eventConfig);
|
|
184
|
-
}
|
|
213
|
+
eventHandler.handler(e, eventHandler.type, eventConfigRef.current);
|
|
185
214
|
};
|
|
186
215
|
}
|
|
187
216
|
const useInnerProps = (props = {}, userRemoveProps = [], rawConfig) => {
|
|
@@ -209,58 +238,47 @@ const useInnerProps = (props = {}, userRemoveProps = [], rawConfig) => {
|
|
|
209
238
|
disableTap: false,
|
|
210
239
|
navigation
|
|
211
240
|
}, rawConfig);
|
|
241
|
+
const eventConfigRef = useRef(eventConfig);
|
|
242
|
+
const restProps = {};
|
|
243
|
+
const eventNameMap = {};
|
|
244
|
+
const userRemovePropsMap = {};
|
|
212
245
|
let hashEventKey = '';
|
|
213
|
-
|
|
214
|
-
|
|
246
|
+
userRemoveProps.forEach((key) => {
|
|
247
|
+
userRemovePropsMap[key] = true;
|
|
248
|
+
});
|
|
215
249
|
Object.keys(props).forEach((key) => {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
250
|
+
const eventMeta = eventConfigMap[key];
|
|
251
|
+
if (eventMeta) {
|
|
252
|
+
hashEventKey += eventMeta.bitFlag;
|
|
253
|
+
eventMeta.events.forEach((event) => {
|
|
254
|
+
eventNameMap[event] = true;
|
|
221
255
|
});
|
|
222
|
-
|
|
223
|
-
const prefix = match[1];
|
|
224
|
-
const eventName = match[2];
|
|
225
|
-
eventConfig[eventName] = eventConfig[eventName] || {
|
|
256
|
+
eventConfig[eventMeta.eventName] = eventConfig[eventMeta.eventName] || {
|
|
226
257
|
bubble: [],
|
|
227
258
|
capture: [],
|
|
228
259
|
hasCatch: false
|
|
229
260
|
};
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
else {
|
|
234
|
-
eventConfig[eventName].capture.push(key);
|
|
235
|
-
}
|
|
236
|
-
if (prefix === 'catch' || prefix === 'capture-catch') {
|
|
237
|
-
eventConfig[eventName].hasCatch = true;
|
|
261
|
+
eventConfig[eventMeta.eventName][eventMeta.eventType].push(key);
|
|
262
|
+
if (eventMeta.hasCatch) {
|
|
263
|
+
eventConfig[eventMeta.eventName].hasCatch = true;
|
|
238
264
|
}
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
if (!baseRemovePropsMap[key] && !userRemovePropsMap[key]) {
|
|
268
|
+
restProps[key] = props[key];
|
|
239
269
|
}
|
|
240
270
|
});
|
|
271
|
+
eventConfigRef.current = eventConfig;
|
|
241
272
|
const events = useMemo(() => {
|
|
242
273
|
if (!hashEventKey) {
|
|
243
274
|
return {};
|
|
244
275
|
}
|
|
245
276
|
const events = {};
|
|
246
|
-
|
|
247
|
-
events[eventName] = createTouchEventHandler(eventName,
|
|
248
|
-
}
|
|
277
|
+
Object.keys(eventNameMap).forEach((eventName) => {
|
|
278
|
+
events[eventName] = createTouchEventHandler(eventName, eventConfigRef);
|
|
279
|
+
});
|
|
249
280
|
return events;
|
|
250
281
|
}, [hashEventKey]);
|
|
251
|
-
|
|
252
|
-
'children',
|
|
253
|
-
'enable-background',
|
|
254
|
-
'enable-offset',
|
|
255
|
-
'enable-var',
|
|
256
|
-
'external-var-context',
|
|
257
|
-
'parent-font-size',
|
|
258
|
-
'parent-width',
|
|
259
|
-
'parent-height',
|
|
260
|
-
'enable-text-pass-through',
|
|
261
|
-
...userRemoveProps,
|
|
262
|
-
...rawEventKeys
|
|
263
|
-
];
|
|
264
|
-
return extendObject({}, events, omit(props, removeProps));
|
|
282
|
+
return extendObject({}, events, restProps);
|
|
265
283
|
};
|
|
266
284
|
export default useInnerProps;
|
|
@@ -55,7 +55,7 @@ export interface ButtonProps {
|
|
|
55
55
|
'form-type'?: 'submit' | 'reset';
|
|
56
56
|
'enable-offset'?: boolean;
|
|
57
57
|
'enable-var'?: boolean;
|
|
58
|
-
'
|
|
58
|
+
'enable-text-pass-through'?: boolean;
|
|
59
59
|
'parent-font-size'?: number;
|
|
60
60
|
'parent-width'?: number;
|
|
61
61
|
'parent-height'?: number;
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
*/
|
|
37
37
|
import { createElement, useEffect, useRef, forwardRef, useContext } from 'react';
|
|
38
38
|
import { View, StyleSheet, Animated, Easing, useAnimatedValue } from 'react-native';
|
|
39
|
-
import { warn } from '@mpxjs/utils';
|
|
39
|
+
import { warn, hasOwn } from '@mpxjs/utils';
|
|
40
40
|
import { GestureDetector } from 'react-native-gesture-handler';
|
|
41
|
-
import { getCurrentPage, splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject, useHover,
|
|
41
|
+
import { getCurrentPage, splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject, useHover, useTextPassThrough } from './utils';
|
|
42
42
|
import useInnerProps, { getCustomEvent } from './getInnerListeners';
|
|
43
43
|
import useNodesRef from './useNodesRef';
|
|
44
44
|
import { RouteContext, FormContext } from './context';
|
|
@@ -55,14 +55,14 @@ const OpenTypeEventsMap = new Map([
|
|
|
55
55
|
]);
|
|
56
56
|
const styles = StyleSheet.create({
|
|
57
57
|
button: {
|
|
58
|
-
width: '100%',
|
|
59
58
|
flexDirection: 'row',
|
|
60
59
|
justifyContent: 'center',
|
|
61
60
|
alignItems: 'center',
|
|
62
61
|
height: 46,
|
|
63
62
|
borderRadius: 5,
|
|
64
63
|
backgroundColor: '#F8F8F8',
|
|
65
|
-
marginHorizontal: 'auto'
|
|
64
|
+
marginHorizontal: 'auto',
|
|
65
|
+
paddingHorizontal: 14
|
|
66
66
|
},
|
|
67
67
|
buttonMini: {
|
|
68
68
|
height: 30
|
|
@@ -130,7 +130,7 @@ const Loading = ({ alone = false }) => {
|
|
|
130
130
|
};
|
|
131
131
|
const Button = forwardRef((buttonProps, ref) => {
|
|
132
132
|
const { textProps, innerProps: props = {} } = splitProps(buttonProps);
|
|
133
|
-
const { size = 'default', type = 'default', plain = false, disabled = false, loading = false, 'hover-class': hoverClass, 'hover-style': hoverStyle = {}, 'hover-start-time': hoverStartTime = 20, 'hover-stay-time': hoverStayTime = 70, 'open-type': openType, 'form-type': formType, 'enable-var': enableVar, '
|
|
133
|
+
const { size = 'default', type = 'default', plain = false, disabled = false, loading = false, 'hover-class': hoverClass, 'hover-style': hoverStyle = {}, 'hover-start-time': hoverStartTime = 20, 'hover-stay-time': hoverStayTime = 70, 'open-type': openType, 'form-type': formType, 'enable-var': enableVar, 'enable-text-pass-through': enableTextPassThrough, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, style = {}, children, bindgetuserinfo, bindtap } = props;
|
|
134
134
|
const { pageId } = useContext(RouteContext) || {};
|
|
135
135
|
const formContext = useContext(FormContext);
|
|
136
136
|
const enableHover = hoverClass !== 'none';
|
|
@@ -166,14 +166,21 @@ const Button = forwardRef((buttonProps, ref) => {
|
|
|
166
166
|
};
|
|
167
167
|
const defaultViewStyle = extendObject({}, styles.button, isMiniSize ? styles.buttonMini : null, viewStyle);
|
|
168
168
|
const defaultTextStyle = extendObject({}, styles.text, isMiniSize ? styles.textMini : {}, { color: plain ? plainTextColor : normalTextColor });
|
|
169
|
+
const styleObj = isHover ? extendObject({}, style, hoverStyle) : style;
|
|
169
170
|
const defaultStyle = extendObject({}, defaultViewStyle, defaultTextStyle);
|
|
170
|
-
|
|
171
|
-
|
|
171
|
+
// 用户 shorthand 优先:避免 longhand default 反向覆盖
|
|
172
|
+
if (hasOwn(styleObj, 'margin')) {
|
|
173
|
+
delete defaultStyle.marginHorizontal;
|
|
174
|
+
}
|
|
175
|
+
if (hasOwn(styleObj, 'padding')) {
|
|
176
|
+
delete defaultStyle.paddingHorizontal;
|
|
177
|
+
}
|
|
178
|
+
const { hasPositionFixed, hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, parentFontSize, parentWidth, parentHeight, defaultStyle });
|
|
172
179
|
const nodeRef = useRef(null);
|
|
173
180
|
useNodesRef(props, ref, nodeRef, { style: normalStyle });
|
|
174
181
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef });
|
|
175
182
|
const { textStyle, backgroundStyle, innerStyle = {} } = splitStyle(normalStyle);
|
|
176
|
-
const textPassThrough =
|
|
183
|
+
const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough });
|
|
177
184
|
if (backgroundStyle) {
|
|
178
185
|
warn('Button does not support background image-related styles!');
|
|
179
186
|
}
|
|
@@ -259,7 +266,7 @@ const Button = forwardRef((buttonProps, ref) => {
|
|
|
259
266
|
layoutRef,
|
|
260
267
|
disableTap: disabled
|
|
261
268
|
});
|
|
262
|
-
const baseButton = createElement(View, innerProps, loading && createElement(Loading, { alone: !children }), wrapChildren(props, {
|
|
269
|
+
const baseButton = createElement(View, innerProps, loading && createElement(Loading, { alone: !children }), wrapChildren(props.children, {
|
|
263
270
|
hasVarDec,
|
|
264
271
|
varContext: varContextRef.current,
|
|
265
272
|
textPassThrough
|
|
@@ -15,11 +15,10 @@ let RecordRes = null;
|
|
|
15
15
|
const _camera = forwardRef((props, ref) => {
|
|
16
16
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
17
17
|
const cameraRef = useRef(null);
|
|
18
|
-
const { mode = 'normal', resolution = 'medium', 'device-position': devicePosition = 'back', flash = 'auto', 'frame-size': frameSize = 'medium', bindinitdone, bindstop, bindscancode, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, 'enable-var': enableVar,
|
|
18
|
+
const { mode = 'normal', resolution = 'medium', 'device-position': devicePosition = 'back', flash = 'auto', 'frame-size': frameSize = 'medium', bindinitdone, bindstop, bindscancode, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, 'enable-var': enableVar, style = {} } = props;
|
|
19
19
|
const styleObj = extendObject({}, style);
|
|
20
20
|
const { normalStyle, hasSelfPercent, setWidth, setHeight } = useTransformStyle(styleObj, {
|
|
21
21
|
enableVar,
|
|
22
|
-
externalVarContext,
|
|
23
22
|
parentFontSize,
|
|
24
23
|
parentWidth,
|
|
25
24
|
parentHeight
|
|
@@ -20,7 +20,6 @@ interface CanvasProps {
|
|
|
20
20
|
'parent-font-size'?: number;
|
|
21
21
|
'parent-width'?: number;
|
|
22
22
|
'parent-height'?: number;
|
|
23
|
-
'external-var-context'?: Record<string, any>;
|
|
24
23
|
bindtouchstart?: (event: NativeSyntheticEvent<TouchEvent>) => void;
|
|
25
24
|
bindtouchmove?: (event: NativeSyntheticEvent<TouchEvent>) => void;
|
|
26
25
|
bindtouchend?: (event: NativeSyntheticEvent<TouchEvent>) => void;
|
|
@@ -39,12 +39,11 @@ const stylesheet = StyleSheet.create({
|
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
41
|
const _Canvas = forwardRef((props = {}, ref) => {
|
|
42
|
-
const { style = {}, originWhitelist = ['*'], 'enable-var': enableVar, '
|
|
42
|
+
const { style = {}, originWhitelist = ['*'], 'enable-var': enableVar, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
|
|
43
43
|
const [isLoaded, setIsLoaded] = useState(false);
|
|
44
44
|
const nodeRef = useRef(null);
|
|
45
45
|
const { normalStyle, hasSelfPercent, hasPositionFixed, setWidth, setHeight } = useTransformStyle(extendObject({}, style, stylesheet.container), {
|
|
46
46
|
enableVar,
|
|
47
|
-
externalVarContext,
|
|
48
47
|
parentFontSize,
|
|
49
48
|
parentWidth,
|
|
50
49
|
parentHeight
|
|
@@ -30,7 +30,7 @@ export interface WebviewMessage {
|
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
export interface CanvasInstance {
|
|
33
|
-
webview: WebView | null;
|
|
33
|
+
webview: WebView<any> | null;
|
|
34
34
|
bus: Bus | null;
|
|
35
35
|
context2D: CanvasRenderingContext2D;
|
|
36
36
|
getContext: (contextType: string) => CanvasRenderingContext2D | null;
|
|
@@ -9,7 +9,6 @@ export interface CheckboxGroupProps {
|
|
|
9
9
|
style?: ViewStyle & Record<string, any>;
|
|
10
10
|
'enable-offset'?: boolean;
|
|
11
11
|
'enable-var'?: boolean;
|
|
12
|
-
'external-var-context'?: Record<string, any>;
|
|
13
12
|
'parent-font-size'?: number;
|
|
14
13
|
'parent-width'?: number;
|
|
15
14
|
'parent-height'?: number;
|
|
@@ -12,7 +12,7 @@ import Portal from './mpx-portal';
|
|
|
12
12
|
const CheckboxGroup = forwardRef((props, ref) => {
|
|
13
13
|
const propsRef = useRef({});
|
|
14
14
|
propsRef.current = props;
|
|
15
|
-
const { style = {}, 'enable-var': enableVar, '
|
|
15
|
+
const { style = {}, 'enable-var': enableVar, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
|
|
16
16
|
const formContext = useContext(FormContext);
|
|
17
17
|
let formValuesMap;
|
|
18
18
|
if (formContext) {
|
|
@@ -23,8 +23,7 @@ const CheckboxGroup = forwardRef((props, ref) => {
|
|
|
23
23
|
flexDirection: 'row',
|
|
24
24
|
flexWrap: 'wrap'
|
|
25
25
|
};
|
|
26
|
-
const
|
|
27
|
-
const { hasPositionFixed, hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
|
|
26
|
+
const { hasPositionFixed, hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(style, { enableVar, parentFontSize, parentWidth, parentHeight, defaultStyle });
|
|
28
27
|
const nodeRef = useRef(null);
|
|
29
28
|
useNodesRef(props, ref, nodeRef, { style: normalStyle });
|
|
30
29
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef });
|
|
@@ -83,7 +82,7 @@ const CheckboxGroup = forwardRef((props, ref) => {
|
|
|
83
82
|
notifyChange
|
|
84
83
|
};
|
|
85
84
|
}, []);
|
|
86
|
-
const finalComponent = createElement(View, innerProps, createElement(CheckboxGroupContext.Provider, { value: contextValue }, wrapChildren(props, {
|
|
85
|
+
const finalComponent = createElement(View, innerProps, createElement(CheckboxGroupContext.Provider, { value: contextValue }, wrapChildren(props.children, {
|
|
87
86
|
hasVarDec,
|
|
88
87
|
varContext: varContextRef.current
|
|
89
88
|
})));
|
|
@@ -18,7 +18,7 @@ export interface CheckboxProps extends Selection {
|
|
|
18
18
|
groupValue?: Array<string>;
|
|
19
19
|
'enable-offset'?: boolean;
|
|
20
20
|
'enable-var'?: boolean;
|
|
21
|
-
'
|
|
21
|
+
'enable-text-pass-through'?: boolean;
|
|
22
22
|
'parent-font-size'?: number;
|
|
23
23
|
'parent-width'?: number;
|
|
24
24
|
'parent-height'?: number;
|
|
@@ -10,7 +10,7 @@ import { warn } from '@mpxjs/utils';
|
|
|
10
10
|
import useInnerProps, { getCustomEvent } from './getInnerListeners';
|
|
11
11
|
import useNodesRef from './useNodesRef';
|
|
12
12
|
import Icon from './mpx-icon';
|
|
13
|
-
import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject,
|
|
13
|
+
import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject, useTextPassThrough } from './utils';
|
|
14
14
|
import { CheckboxGroupContext, LabelContext } from './context';
|
|
15
15
|
import Portal from './mpx-portal';
|
|
16
16
|
const styles = StyleSheet.create({
|
|
@@ -41,13 +41,12 @@ const styles = StyleSheet.create({
|
|
|
41
41
|
});
|
|
42
42
|
const Checkbox = forwardRef((checkboxProps, ref) => {
|
|
43
43
|
const { textProps, innerProps: props = {} } = splitProps(checkboxProps);
|
|
44
|
-
const { value = '', disabled = false, checked = false, color = '#09BB07', style = {}, 'enable-var': enableVar, '
|
|
44
|
+
const { value = '', disabled = false, checked = false, color = '#09BB07', style = {}, 'enable-var': enableVar, 'enable-text-pass-through': enableTextPassThrough, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, bindtap, _onChange } = props;
|
|
45
45
|
const [isChecked, setIsChecked] = useState(!!checked);
|
|
46
46
|
const groupContext = useContext(CheckboxGroupContext);
|
|
47
47
|
let groupValue;
|
|
48
48
|
let notifyChange;
|
|
49
|
-
const
|
|
50
|
-
const styleObj = extendObject({}, styles.container, style);
|
|
49
|
+
const wrapperStyle = extendObject({}, styles.wrapper, disabled ? styles.wrapperDisabled : null);
|
|
51
50
|
const onChange = (evt) => {
|
|
52
51
|
if (disabled)
|
|
53
52
|
return;
|
|
@@ -64,15 +63,15 @@ const Checkbox = forwardRef((checkboxProps, ref) => {
|
|
|
64
63
|
bindtap && bindtap(getCustomEvent('tap', evt, { layoutRef }, props));
|
|
65
64
|
onChange(evt);
|
|
66
65
|
};
|
|
67
|
-
const { hasPositionFixed, hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(
|
|
66
|
+
const { hasPositionFixed, hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(style, { enableVar, parentFontSize, parentWidth, parentHeight, defaultStyle: styles.container });
|
|
68
67
|
const nodeRef = useRef(null);
|
|
69
68
|
useNodesRef(props, ref, nodeRef, {
|
|
70
|
-
style:
|
|
69
|
+
style: normalStyle,
|
|
71
70
|
change: onChange
|
|
72
71
|
});
|
|
73
72
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef });
|
|
74
73
|
const { textStyle, backgroundStyle, innerStyle = {} } = splitStyle(normalStyle);
|
|
75
|
-
const textPassThrough =
|
|
74
|
+
const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough });
|
|
76
75
|
if (backgroundStyle) {
|
|
77
76
|
warn('Checkbox does not support background image-related styles!');
|
|
78
77
|
}
|
|
@@ -118,12 +117,12 @@ const Checkbox = forwardRef((checkboxProps, ref) => {
|
|
|
118
117
|
}
|
|
119
118
|
}
|
|
120
119
|
}, [checked]);
|
|
121
|
-
const finalComponent = createElement(View, innerProps, createElement(View, { style:
|
|
120
|
+
const finalComponent = createElement(View, innerProps, createElement(View, { style: wrapperStyle }, createElement(Icon, {
|
|
122
121
|
type: 'success_no_circle',
|
|
123
122
|
size: 18,
|
|
124
123
|
color: disabled ? '#ADADAD' : color,
|
|
125
124
|
style: isChecked ? styles.iconChecked : styles.icon
|
|
126
|
-
})), wrapChildren(props, {
|
|
125
|
+
})), wrapChildren(props.children, {
|
|
127
126
|
hasVarDec,
|
|
128
127
|
varContext: varContextRef.current,
|
|
129
128
|
textPassThrough
|