@mpxjs/webpack-plugin 2.9.69-beta.0 → 2.9.69-beta.10
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/config.js +3 -1
- package/lib/index.js +17 -1
- package/lib/platform/style/wx/index.js +18 -18
- package/lib/platform/template/wx/component-config/movable-view.js +8 -1
- package/lib/platform/template/wx/component-config/scroll-view.js +1 -1
- package/lib/platform/template/wx/index.js +3 -1
- package/lib/react/processScript.js +6 -4
- package/lib/resolver/AddEnvPlugin.js +1 -0
- package/lib/resolver/AddModePlugin.js +1 -0
- package/lib/runtime/components/react/context.ts +25 -0
- package/lib/runtime/components/react/dist/context.js +4 -0
- package/lib/runtime/components/react/dist/getInnerListeners.js +5 -6
- package/lib/runtime/components/react/dist/locale-provider.jsx +15 -0
- package/lib/runtime/components/react/dist/mpx-button.jsx +16 -44
- package/lib/runtime/components/react/dist/mpx-image.jsx +13 -9
- package/lib/runtime/components/react/dist/mpx-input.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-picker/time.jsx +2 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column-item.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +72 -57
- package/lib/runtime/components/react/dist/mpx-picker-view.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-consumer.jsx +23 -0
- package/lib/runtime/components/react/dist/mpx-portal/portal-host.jsx +93 -0
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.jsx +40 -0
- package/lib/runtime/components/react/dist/mpx-portal.jsx +13 -0
- package/lib/runtime/components/react/dist/mpx-provider.jsx +31 -0
- package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +10 -11
- package/lib/runtime/components/react/dist/mpx-root-portal.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +18 -9
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +31 -8
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +437 -372
- package/lib/runtime/components/react/dist/mpx-view.jsx +18 -53
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +163 -49
- package/lib/runtime/components/react/dist/pickerFaces.js +3 -8
- package/lib/runtime/components/react/dist/useAnimationHooks.js +31 -14
- package/lib/runtime/components/react/dist/utils.jsx +120 -4
- package/lib/runtime/components/react/getInnerListeners.ts +5 -7
- package/lib/runtime/components/react/locale-provider.tsx +83 -0
- package/lib/runtime/components/react/mpx-button.tsx +20 -57
- package/lib/runtime/components/react/mpx-image.tsx +41 -25
- package/lib/runtime/components/react/mpx-input.tsx +1 -1
- package/lib/runtime/components/react/mpx-movable-view.tsx +1 -1
- package/lib/runtime/components/react/mpx-picker/time.tsx +2 -1
- package/lib/runtime/components/react/mpx-picker-view-column-item.tsx +88 -0
- package/lib/runtime/components/react/mpx-picker-view-column.tsx +196 -163
- package/lib/runtime/components/react/mpx-picker-view.tsx +35 -37
- package/lib/runtime/components/react/mpx-portal/portal-consumer.tsx +32 -0
- package/lib/runtime/components/react/mpx-portal/portal-host.tsx +127 -0
- package/lib/runtime/components/react/mpx-portal/portal-manager.tsx +64 -0
- package/lib/runtime/components/react/mpx-portal.tsx +30 -0
- package/lib/runtime/components/react/mpx-provider.tsx +51 -0
- package/lib/runtime/components/react/mpx-rich-text/index.tsx +12 -18
- package/lib/runtime/components/react/mpx-root-portal.tsx +1 -1
- package/lib/runtime/components/react/mpx-scroll-view.tsx +29 -18
- package/lib/runtime/components/react/mpx-swiper-item.tsx +45 -11
- package/lib/runtime/components/react/mpx-swiper.tsx +743 -0
- package/lib/runtime/components/react/mpx-view.tsx +22 -65
- package/lib/runtime/components/react/mpx-web-view.tsx +199 -47
- package/lib/runtime/components/react/pickerFaces.ts +10 -7
- package/lib/runtime/components/react/pickerVIewContext.ts +18 -0
- package/lib/runtime/components/react/pickerViewMask.tsx +30 -0
- package/lib/runtime/components/react/{pickerOverlay.tsx → pickerViewOverlay.tsx} +5 -3
- package/lib/runtime/components/react/types/global.d.ts +10 -1
- package/lib/runtime/components/react/useAnimationHooks.ts +35 -15
- package/lib/runtime/components/react/utils.tsx +139 -5
- package/lib/style-compiler/index.js +3 -4
- package/lib/style-compiler/strip-conditional-loader.js +118 -0
- package/lib/template-compiler/compiler.js +10 -15
- package/lib/utils/pre-process-json.js +5 -9
- package/lib/wxss/loader.js +15 -2
- package/package.json +1 -1
- package/lib/runtime/components/react/mpx-swiper/carouse.tsx +0 -527
- package/lib/runtime/components/react/mpx-swiper/index.tsx +0 -80
- package/lib/runtime/components/react/mpx-swiper/type.ts +0 -87
package/lib/config.js
CHANGED
|
@@ -138,7 +138,9 @@ module.exports = {
|
|
|
138
138
|
}
|
|
139
139
|
},
|
|
140
140
|
getEvent (eventName, prefix = 'on') {
|
|
141
|
-
return
|
|
141
|
+
return prefix + dash2hump(eventName.replace(/^./, (matched) => {
|
|
142
|
+
return matched.toUpperCase()
|
|
143
|
+
}))
|
|
142
144
|
},
|
|
143
145
|
defaultModelProp: 'value',
|
|
144
146
|
defaultModelEvent: 'input',
|
package/lib/index.js
CHANGED
|
@@ -54,11 +54,13 @@ const wxssLoaderPath = normalize.lib('wxss/index')
|
|
|
54
54
|
const wxmlLoaderPath = normalize.lib('wxml/loader')
|
|
55
55
|
const wxsLoaderPath = normalize.lib('wxs/loader')
|
|
56
56
|
const styleCompilerPath = normalize.lib('style-compiler/index')
|
|
57
|
+
const styleStripConditaionalPath = normalize.lib('style-compiler/strip-conditional-loader')
|
|
57
58
|
const templateCompilerPath = normalize.lib('template-compiler/index')
|
|
58
59
|
const jsonCompilerPath = normalize.lib('json-compiler/index')
|
|
59
60
|
const jsonThemeCompilerPath = normalize.lib('json-compiler/theme')
|
|
60
61
|
const jsonPluginCompilerPath = normalize.lib('json-compiler/plugin')
|
|
61
62
|
const extractorPath = normalize.lib('extractor')
|
|
63
|
+
const selectorPath = normalize.lib('selector')
|
|
62
64
|
const async = require('async')
|
|
63
65
|
const { parseQuery } = require('loader-utils')
|
|
64
66
|
const stringifyLoadersAndResource = require('./utils/stringify-loaders-resource')
|
|
@@ -1775,7 +1777,7 @@ try {
|
|
|
1775
1777
|
})
|
|
1776
1778
|
|
|
1777
1779
|
const typeLoaderProcessInfo = {
|
|
1778
|
-
styles: ['node_modules/css-loader', wxssLoaderPath, styleCompilerPath],
|
|
1780
|
+
styles: ['node_modules/css-loader', wxssLoaderPath, styleCompilerPath, styleStripConditaionalPath],
|
|
1779
1781
|
template: ['node_modules/html-loader', wxmlLoaderPath, templateCompilerPath]
|
|
1780
1782
|
}
|
|
1781
1783
|
|
|
@@ -1833,6 +1835,20 @@ try {
|
|
|
1833
1835
|
loader: extractorPath
|
|
1834
1836
|
})
|
|
1835
1837
|
}
|
|
1838
|
+
if (type === 'styles') {
|
|
1839
|
+
// 判断最后一个loader是否是 selectorPath, 如果是,则在sectorPath之前插入strip-conditional
|
|
1840
|
+
const lastLoader = loaders[loaders.length - 1]
|
|
1841
|
+
if (lastLoader.loader.includes(selectorPath)) {
|
|
1842
|
+
loaders.splice(loaders.length - 1, 0, {
|
|
1843
|
+
loader: styleStripConditaionalPath
|
|
1844
|
+
})
|
|
1845
|
+
} else {
|
|
1846
|
+
// 在最后一个插入strip-conditional
|
|
1847
|
+
loaders.push({
|
|
1848
|
+
loader: styleStripConditaionalPath
|
|
1849
|
+
})
|
|
1850
|
+
}
|
|
1851
|
+
}
|
|
1836
1852
|
createData.resource = addQuery(createData.resource, { mpx: MPX_PROCESSED_FLAG }, true)
|
|
1837
1853
|
}
|
|
1838
1854
|
// mpxStyleOptions 为 mpx style 文件的标识,避免 Vue 文件插入 styleCompiler 后导致 vue scoped 样式隔离失效
|
|
@@ -374,11 +374,11 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
374
374
|
// transform 转换
|
|
375
375
|
const formatTransform = ({ prop, value, selector }, { mode }) => {
|
|
376
376
|
// css var & 数组直接返回
|
|
377
|
-
if (Array.isArray(value) ||
|
|
377
|
+
if (Array.isArray(value) || cssVariableExp.test(value)) return { prop, value }
|
|
378
378
|
const values = parseValues(value)
|
|
379
379
|
const transform = []
|
|
380
380
|
values.forEach(item => {
|
|
381
|
-
const match = item.match(/([/\w]+)\((
|
|
381
|
+
const match = item.match(/([/\w]+)\((.+)\)/)
|
|
382
382
|
if (match && match.length >= 3) {
|
|
383
383
|
let key = match[1]
|
|
384
384
|
const val = match[2]
|
|
@@ -407,23 +407,23 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
407
407
|
case 'rotate3d': // x y z angle
|
|
408
408
|
case 'translate3d': // x y 支持 z不支持
|
|
409
409
|
case 'scale3d': // x y 支持 z不支持
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
}
|
|
418
|
-
const xyz = ['X', 'Y', 'Z']
|
|
419
|
-
transform.push(...vals.map((v, index) => {
|
|
420
|
-
if (key !== 'rotate' && index > 1) {
|
|
421
|
-
unsupportedPropError({ prop: `${key}Z`, value, selector }, { mode })
|
|
422
|
-
}
|
|
423
|
-
return { [`${key}${xyz[index] || ''}`]: v.trim() }
|
|
424
|
-
}))
|
|
425
|
-
break
|
|
410
|
+
{
|
|
411
|
+
// 2 个以上的值处理
|
|
412
|
+
key = key.replace('3d', '')
|
|
413
|
+
const vals = parseValues(val, ',').splice(0, key === 'rotate' ? 4 : 3)
|
|
414
|
+
// scale(.5) === scaleX(.5) scaleY(.5)
|
|
415
|
+
if (vals.length === 1 && key === 'scale') {
|
|
416
|
+
vals.push(vals[0])
|
|
426
417
|
}
|
|
418
|
+
const xyz = ['X', 'Y', 'Z']
|
|
419
|
+
transform.push(...vals.map((v, index) => {
|
|
420
|
+
if (key !== 'rotate' && index > 1) {
|
|
421
|
+
unsupportedPropError({ prop: `${key}Z`, value, selector }, { mode })
|
|
422
|
+
}
|
|
423
|
+
return { [`${key}${xyz[index] || ''}`]: v.trim() }
|
|
424
|
+
}))
|
|
425
|
+
break
|
|
426
|
+
}
|
|
427
427
|
case 'translateZ':
|
|
428
428
|
case 'scaleZ':
|
|
429
429
|
default:
|
|
@@ -2,6 +2,8 @@ const TAG_NAME = 'movable-view'
|
|
|
2
2
|
|
|
3
3
|
module.exports = function ({ print }) {
|
|
4
4
|
const aliEventLog = print({ platform: 'ali', tag: TAG_NAME, isError: false, type: 'event' })
|
|
5
|
+
const androidEventLog = print({ platform: 'android', tag: TAG_NAME, isError: false, type: 'event' })
|
|
6
|
+
const iosEventLog = print({ platform: 'ios', tag: TAG_NAME, isError: false, type: 'event' })
|
|
5
7
|
const qaPropLog = print({ platform: 'qa', tag: TAG_NAME, isError: false })
|
|
6
8
|
const androidPropLog = print({ platform: 'android', tag: TAG_NAME, isError: false })
|
|
7
9
|
const iosPropLog = print({ platform: 'ios', tag: TAG_NAME, isError: false })
|
|
@@ -27,7 +29,7 @@ module.exports = function ({ print }) {
|
|
|
27
29
|
android: androidPropLog
|
|
28
30
|
},
|
|
29
31
|
{
|
|
30
|
-
test: /^(
|
|
32
|
+
test: /^(damping|friction|scale|scale-min|scale-max|scale-value)$/,
|
|
31
33
|
ios: iosPropLog,
|
|
32
34
|
android: androidPropLog
|
|
33
35
|
}
|
|
@@ -36,6 +38,11 @@ module.exports = function ({ print }) {
|
|
|
36
38
|
{
|
|
37
39
|
test: /^(htouchmove|vtouchmove)$/,
|
|
38
40
|
ali: aliEventLog
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
test: /^(bindscale)$/,
|
|
44
|
+
ios: iosEventLog,
|
|
45
|
+
android: androidEventLog
|
|
39
46
|
}
|
|
40
47
|
]
|
|
41
48
|
}
|
|
@@ -53,7 +53,7 @@ module.exports = function ({ print }) {
|
|
|
53
53
|
qa: qaPropLog
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
|
-
test: /^(
|
|
56
|
+
test: /^(refresher-threshold|enable-passive|scroll-anchoring|using-sticky|fast-deceleration|enable-flex)$/,
|
|
57
57
|
android: androidPropLog,
|
|
58
58
|
ios: iosPropLog
|
|
59
59
|
},
|
|
@@ -302,7 +302,9 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
302
302
|
const rPrefix = runRules(spec.event.prefix, prefix, { mode: 'ali' })
|
|
303
303
|
const rEventName = runRules(eventRules, eventName, { mode: 'ali' })
|
|
304
304
|
return {
|
|
305
|
-
name:
|
|
305
|
+
name: rPrefix + dash2hump(rEventName.replace(/^./, (matched) => {
|
|
306
|
+
return matched.toUpperCase()
|
|
307
|
+
})) + modifierStr,
|
|
306
308
|
value
|
|
307
309
|
}
|
|
308
310
|
},
|
|
@@ -14,25 +14,27 @@ module.exports = function (script, {
|
|
|
14
14
|
localPagesMap
|
|
15
15
|
}, callback) {
|
|
16
16
|
let scriptSrcMode = srcMode
|
|
17
|
+
const mode = loaderContext.getMpx().mode
|
|
17
18
|
if (script) {
|
|
18
19
|
scriptSrcMode = script.mode || scriptSrcMode
|
|
19
20
|
} else {
|
|
20
21
|
script = { tag: 'script' }
|
|
21
22
|
}
|
|
22
|
-
|
|
23
23
|
let output = '/* script */\n'
|
|
24
24
|
if (ctorType === 'app') {
|
|
25
25
|
output += `
|
|
26
26
|
import { getComponent } from ${stringifyRequest(loaderContext, optionProcessorPath)}
|
|
27
27
|
import { NavigationContainer, StackActions } from '@react-navigation/native'
|
|
28
|
-
import { createStackNavigator } from '@react-navigation/stack'
|
|
29
|
-
import {
|
|
28
|
+
${mode === 'ios' ? "import { createNativeStackNavigator } from '@react-navigation/native-stack'" : "import { createStackNavigator } from '@react-navigation/stack'" }
|
|
29
|
+
import { useHeaderHeight } from '@react-navigation/elements';
|
|
30
|
+
import Provider from '@mpxjs/webpack-plugin/lib/runtime/components/react/dist/mpx-provider'
|
|
30
31
|
import { SafeAreaProvider, useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
31
32
|
import { GestureHandlerRootView } from 'react-native-gesture-handler'
|
|
32
33
|
|
|
33
34
|
global.__navigationHelper = {
|
|
34
35
|
NavigationContainer: NavigationContainer,
|
|
35
|
-
createStackNavigator: createStackNavigator,
|
|
36
|
+
createStackNavigator: ${mode === 'ios' ? 'createNativeStackNavigator' : 'createStackNavigator'},
|
|
37
|
+
useHeaderHeight: useHeaderHeight,
|
|
36
38
|
StackActions: StackActions,
|
|
37
39
|
GestureHandlerRootView: GestureHandlerRootView,
|
|
38
40
|
Provider: Provider,
|
|
@@ -34,6 +34,7 @@ module.exports = class AddEnvPlugin {
|
|
|
34
34
|
if (!extname || !matchCondition(resourcePath, this.fileConditionRules)) return callback()
|
|
35
35
|
const queryObj = parseQuery(request.query || '?')
|
|
36
36
|
queryObj.infix = `${queryObj.infix || ''}.${env}`
|
|
37
|
+
// css | stylus | less | sass 中 import file 过滤query,避免在对应的 loader 中无法读取到文件
|
|
37
38
|
obj.query = stringifyQuery(queryObj)
|
|
38
39
|
obj.path = addInfix(resourcePath, env, extname)
|
|
39
40
|
obj.relativePath = request.relativePath && addInfix(request.relativePath, env, extname)
|
|
@@ -43,6 +43,7 @@ module.exports = class AddModePlugin {
|
|
|
43
43
|
resolver.doResolve(target, Object.assign({}, request, obj), 'add mode: ' + mode, resolveContext, (err, result) => {
|
|
44
44
|
if (defaultMode && !result) {
|
|
45
45
|
queryObj.infix = `${queryInfix || ''}.${defaultMode}`
|
|
46
|
+
// css | stylus | less | sass 中 import file 过滤query,避免在对应的 loader 中无法读取到文件
|
|
46
47
|
obj.query = stringifyQuery(queryObj)
|
|
47
48
|
obj.path = addInfix(resourcePath, defaultMode, extname)
|
|
48
49
|
resolver.doResolve(target, Object.assign({}, request, obj), 'add mode: ' + defaultMode, resolveContext, (err, result) => {
|
|
@@ -32,6 +32,23 @@ export interface IntersectionObserver {
|
|
|
32
32
|
throttleMeasure: () => void
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
+
export interface PortalManagerContextValue {
|
|
36
|
+
mount: (key: number, children: React.ReactNode) => void
|
|
37
|
+
update: (key: number, children: React.ReactNode) => void
|
|
38
|
+
unmount: (key: number) => void,
|
|
39
|
+
portals: Array<{key: number, children: React.ReactNode}>
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface PortalContextValue {
|
|
43
|
+
mount: (children: React.ReactNode, key?: number, pageId?: number|null) => number| undefined
|
|
44
|
+
update: (key: number, children: React.ReactNode, pageId?: number|null) => void
|
|
45
|
+
unmount: (key: number) => void
|
|
46
|
+
manager?: PortalManagerContextValue
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface ScrollViewContextValue {
|
|
50
|
+
gestureRef: React.RefObject<any> | null
|
|
51
|
+
}
|
|
35
52
|
|
|
36
53
|
export const MovableAreaContext = createContext({ width: 0, height: 0 })
|
|
37
54
|
|
|
@@ -51,4 +68,12 @@ export const IntersectionObserverContext = createContext<IntersectionObserver |
|
|
|
51
68
|
|
|
52
69
|
export const RouteContext = createContext<number | null>(null)
|
|
53
70
|
|
|
71
|
+
export const SwiperContext = createContext({})
|
|
72
|
+
|
|
54
73
|
export const KeyboardAvoidContext = createContext<KeyboardAvoidContextValue | null>(null)
|
|
74
|
+
|
|
75
|
+
export const ScrollViewContext = createContext<ScrollViewContextValue>({ gestureRef: null })
|
|
76
|
+
|
|
77
|
+
export const PortalContext = createContext<PortalContextValue>(null as any)
|
|
78
|
+
|
|
79
|
+
export const PortalManagerContext = createContext<PortalManagerContextValue| null>(null)
|
|
@@ -8,4 +8,8 @@ export const PickerContext = createContext(null);
|
|
|
8
8
|
export const VarContext = createContext({});
|
|
9
9
|
export const IntersectionObserverContext = createContext(null);
|
|
10
10
|
export const RouteContext = createContext(null);
|
|
11
|
+
export const SwiperContext = createContext({});
|
|
11
12
|
export const KeyboardAvoidContext = createContext(null);
|
|
13
|
+
export const ScrollViewContext = createContext({ gestureRef: null });
|
|
14
|
+
export const PortalContext = createContext(null);
|
|
15
|
+
export const PortalManagerContext = createContext(null);
|
|
@@ -82,8 +82,8 @@ function checkIsNeedPress(e, type, ref) {
|
|
|
82
82
|
const nativeEvent = e.nativeEvent;
|
|
83
83
|
const currentPageX = nativeEvent.changedTouches[0].pageX;
|
|
84
84
|
const currentPageY = nativeEvent.changedTouches[0].pageY;
|
|
85
|
-
if (Math.abs(currentPageX - tapDetailInfo.x) >
|
|
86
|
-
Math.abs(currentPageY - tapDetailInfo.y) >
|
|
85
|
+
if (Math.abs(currentPageX - tapDetailInfo.x) > 3 ||
|
|
86
|
+
Math.abs(currentPageY - tapDetailInfo.y) > 3) {
|
|
87
87
|
ref.current.needPress[type] = false;
|
|
88
88
|
ref.current.startTimer[type] &&
|
|
89
89
|
clearTimeout(ref.current.startTimer[type]);
|
|
@@ -213,7 +213,6 @@ const useInnerProps = (props = {}, additionalProps = {}, userRemoveProps = [], r
|
|
|
213
213
|
const eventConfig = {};
|
|
214
214
|
const config = rawConfig || {
|
|
215
215
|
layoutRef: { current: {} },
|
|
216
|
-
disableTouch: false,
|
|
217
216
|
disableTap: false
|
|
218
217
|
};
|
|
219
218
|
const removeProps = [
|
|
@@ -237,10 +236,10 @@ const useInnerProps = (props = {}, additionalProps = {}, userRemoveProps = [], r
|
|
|
237
236
|
rawEventKeys.push(key);
|
|
238
237
|
}
|
|
239
238
|
}
|
|
240
|
-
if (!rawEventKeys.length || config.disableTouch) {
|
|
241
|
-
return omit(propsRef.current, removeProps);
|
|
242
|
-
}
|
|
243
239
|
const events = useMemo(() => {
|
|
240
|
+
if (!rawEventKeys.length) {
|
|
241
|
+
return {};
|
|
242
|
+
}
|
|
244
243
|
const transformedEventKeys = rawEventKeys.reduce((acc, key) => {
|
|
245
244
|
if (propsRef.current[key]) {
|
|
246
245
|
return acc.concat(eventConfig[key]);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createContext, useMemo, memo } from 'react';
|
|
2
|
+
import { extendObject } from './utils';
|
|
3
|
+
export const LocaleContext = createContext(undefined);
|
|
4
|
+
const LocaleProvider = (props) => {
|
|
5
|
+
const locale = useMemo(() => {
|
|
6
|
+
return {
|
|
7
|
+
antLocale: extendObject({}, props.locale, { exist: true })
|
|
8
|
+
};
|
|
9
|
+
}, [props.locale]);
|
|
10
|
+
return (<LocaleContext.Provider value={locale}>
|
|
11
|
+
{props.children}
|
|
12
|
+
</LocaleContext.Provider>);
|
|
13
|
+
};
|
|
14
|
+
LocaleProvider.displayName = 'LocaleProvider';
|
|
15
|
+
export default memo(LocaleProvider);
|
|
@@ -34,10 +34,11 @@
|
|
|
34
34
|
* ✘ bindagreeprivacyauthorization
|
|
35
35
|
* ✔ bindtap
|
|
36
36
|
*/
|
|
37
|
-
import { createElement, useEffect, useRef,
|
|
37
|
+
import { createElement, useEffect, useRef, forwardRef, useContext } from 'react';
|
|
38
38
|
import { View, StyleSheet, Animated, Easing } from 'react-native';
|
|
39
39
|
import { warn } from '@mpxjs/utils';
|
|
40
|
-
import {
|
|
40
|
+
import { GestureDetector } from 'react-native-gesture-handler';
|
|
41
|
+
import { getCurrentPage, splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject, useHover } from './utils';
|
|
41
42
|
import useInnerProps, { getCustomEvent } from './getInnerListeners';
|
|
42
43
|
import useNodesRef from './useNodesRef';
|
|
43
44
|
import { RouteContext, FormContext } from './context';
|
|
@@ -128,38 +129,34 @@ const Loading = ({ alone = false }) => {
|
|
|
128
129
|
};
|
|
129
130
|
const Button = forwardRef((buttonProps, ref) => {
|
|
130
131
|
const { textProps, innerProps: props = {} } = splitProps(buttonProps);
|
|
131
|
-
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, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, style = {}, children, bindgetuserinfo, bindtap
|
|
132
|
+
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, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, style = {}, children, bindgetuserinfo, bindtap } = props;
|
|
132
133
|
const pageId = useContext(RouteContext);
|
|
133
134
|
const formContext = useContext(FormContext);
|
|
135
|
+
const enableHover = hoverClass !== 'none';
|
|
136
|
+
const { isHover, gesture } = useHover({ enableHover, hoverStartTime, hoverStayTime, disabled });
|
|
134
137
|
let submitFn;
|
|
135
138
|
let resetFn;
|
|
136
139
|
if (formContext) {
|
|
137
140
|
submitFn = formContext.submit;
|
|
138
141
|
resetFn = formContext.reset;
|
|
139
142
|
}
|
|
140
|
-
const refs = useRef({
|
|
141
|
-
hoverStartTimer: undefined,
|
|
142
|
-
hoverStayTimer: undefined
|
|
143
|
-
});
|
|
144
|
-
const [isHover, setIsHover] = useState(false);
|
|
145
143
|
const isMiniSize = size === 'mini';
|
|
146
|
-
const applyHoverEffect = isHover && hoverClass !== 'none';
|
|
147
144
|
const [color, hoverColor, plainColor, disabledColor] = TypeColorMap[type];
|
|
148
|
-
const normalBackgroundColor = disabled ? disabledColor :
|
|
145
|
+
const normalBackgroundColor = disabled ? disabledColor : isHover || loading ? hoverColor : color;
|
|
149
146
|
const plainBorderColor = disabled
|
|
150
147
|
? 'rgba(0, 0, 0, .2)'
|
|
151
|
-
:
|
|
148
|
+
: isHover
|
|
152
149
|
? `rgba(${plainColor},.6)`
|
|
153
150
|
: `rgb(${plainColor})`;
|
|
154
151
|
const normalBorderColor = type === 'default' ? 'rgba(0, 0, 0, .2)' : normalBackgroundColor;
|
|
155
152
|
const plainTextColor = disabled
|
|
156
153
|
? 'rgba(0, 0, 0, .2)'
|
|
157
|
-
:
|
|
154
|
+
: isHover
|
|
158
155
|
? `rgba(${plainColor}, .6)`
|
|
159
156
|
: `rgb(${plainColor})`;
|
|
160
157
|
const normalTextColor = type === 'default'
|
|
161
|
-
? `rgba(0, 0, 0, ${disabled ? 0.3 :
|
|
162
|
-
: `rgba(255 ,255 ,255 , ${disabled ||
|
|
158
|
+
? `rgba(0, 0, 0, ${disabled ? 0.3 : isHover || loading ? 0.6 : 1})`
|
|
159
|
+
: `rgba(255 ,255 ,255 , ${disabled || isHover || loading ? 0.6 : 1})`;
|
|
163
160
|
const viewStyle = {
|
|
164
161
|
borderWidth: 1,
|
|
165
162
|
borderStyle: 'solid',
|
|
@@ -169,7 +166,7 @@ const Button = forwardRef((buttonProps, ref) => {
|
|
|
169
166
|
const defaultViewStyle = extendObject({}, styles.button, isMiniSize ? styles.buttonMini : null, viewStyle);
|
|
170
167
|
const defaultTextStyle = extendObject({}, styles.text, isMiniSize ? styles.textMini : {}, { color: plain ? plainTextColor : normalTextColor });
|
|
171
168
|
const defaultStyle = extendObject({}, defaultViewStyle, defaultTextStyle);
|
|
172
|
-
const styleObj = extendObject({}, defaultStyle, style,
|
|
169
|
+
const styleObj = extendObject({}, defaultStyle, style, isHover ? hoverStyle : {});
|
|
173
170
|
const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
|
|
174
171
|
const nodeRef = useRef(null);
|
|
175
172
|
useNodesRef(props, ref, nodeRef, { style: normalStyle });
|
|
@@ -224,32 +221,6 @@ const Button = forwardRef((buttonProps, ref) => {
|
|
|
224
221
|
});
|
|
225
222
|
}
|
|
226
223
|
};
|
|
227
|
-
const setStayTimer = () => {
|
|
228
|
-
clearTimeout(refs.current.hoverStayTimer);
|
|
229
|
-
refs.current.hoverStayTimer = setTimeout(() => {
|
|
230
|
-
setIsHover(false);
|
|
231
|
-
clearTimeout(refs.current.hoverStayTimer);
|
|
232
|
-
}, hoverStayTime);
|
|
233
|
-
};
|
|
234
|
-
const setStartTimer = () => {
|
|
235
|
-
clearTimeout(refs.current.hoverStartTimer);
|
|
236
|
-
refs.current.hoverStartTimer = setTimeout(() => {
|
|
237
|
-
setIsHover(true);
|
|
238
|
-
clearTimeout(refs.current.hoverStartTimer);
|
|
239
|
-
}, hoverStartTime);
|
|
240
|
-
};
|
|
241
|
-
const onTouchStart = (evt) => {
|
|
242
|
-
bindtouchstart && bindtouchstart(evt);
|
|
243
|
-
if (disabled)
|
|
244
|
-
return;
|
|
245
|
-
setStartTimer();
|
|
246
|
-
};
|
|
247
|
-
const onTouchEnd = (evt) => {
|
|
248
|
-
bindtouchend && bindtouchend(evt);
|
|
249
|
-
if (disabled)
|
|
250
|
-
return;
|
|
251
|
-
setStayTimer();
|
|
252
|
-
};
|
|
253
224
|
const handleFormTypeFn = () => {
|
|
254
225
|
if (formType === 'submit') {
|
|
255
226
|
submitFn && submitFn();
|
|
@@ -269,8 +240,6 @@ const Button = forwardRef((buttonProps, ref) => {
|
|
|
269
240
|
ref: nodeRef,
|
|
270
241
|
style: extendObject({}, innerStyle, layoutStyle)
|
|
271
242
|
}, layoutProps, {
|
|
272
|
-
bindtouchstart: (bindtouchstart || !disabled) && onTouchStart,
|
|
273
|
-
bindtouchend: (bindtouchend || !disabled) && onTouchEnd,
|
|
274
243
|
bindtap: !disabled && onTap
|
|
275
244
|
}), [
|
|
276
245
|
'disabled',
|
|
@@ -288,12 +257,15 @@ const Button = forwardRef((buttonProps, ref) => {
|
|
|
288
257
|
layoutRef,
|
|
289
258
|
disableTap: disabled
|
|
290
259
|
});
|
|
291
|
-
|
|
260
|
+
const baseButton = createElement(View, innerProps, loading && createElement(Loading, { alone: !children }), wrapChildren(props, {
|
|
292
261
|
hasVarDec,
|
|
293
262
|
varContext: varContextRef.current,
|
|
294
263
|
textStyle,
|
|
295
264
|
textProps
|
|
296
265
|
}));
|
|
266
|
+
return enableHover
|
|
267
|
+
? createElement(GestureDetector, { gesture: gesture }, baseButton)
|
|
268
|
+
: baseButton;
|
|
297
269
|
});
|
|
298
270
|
Button.displayName = 'MpxButton';
|
|
299
271
|
export default Button;
|
|
@@ -268,14 +268,8 @@ const Image = forwardRef((props, ref) => {
|
|
|
268
268
|
], {
|
|
269
269
|
layoutRef
|
|
270
270
|
});
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
uri: src,
|
|
274
|
-
onLayout: onSvgLoad,
|
|
275
|
-
onError: binderror && onSvgError,
|
|
276
|
-
style: extendObject({ transformOrigin: 'top left' }, modeStyle)
|
|
277
|
-
})
|
|
278
|
-
: loaded && renderImage({
|
|
271
|
+
const createBaseImage = (innerProps = {}) => {
|
|
272
|
+
return renderImage(extendObject({
|
|
279
273
|
source: { uri: src },
|
|
280
274
|
resizeMode: resizeMode,
|
|
281
275
|
onLoad: bindload && onImageLoad,
|
|
@@ -285,7 +279,17 @@ const Image = forwardRef((props, ref) => {
|
|
|
285
279
|
width: isCropMode ? imageWidth : '100%',
|
|
286
280
|
height: isCropMode ? imageHeight : '100%'
|
|
287
281
|
}, isCropMode ? modeStyle : {})
|
|
288
|
-
}, enableFastImage)
|
|
282
|
+
}, innerProps), enableFastImage);
|
|
283
|
+
};
|
|
284
|
+
const SvgImage = createElement(View, innerProps, createElement(SvgCssUri, {
|
|
285
|
+
uri: src,
|
|
286
|
+
onLayout: onSvgLoad,
|
|
287
|
+
onError: binderror && onSvgError,
|
|
288
|
+
style: extendObject({ transformOrigin: 'top left' }, modeStyle)
|
|
289
|
+
}));
|
|
290
|
+
const BaseImage = createBaseImage(innerProps);
|
|
291
|
+
const LayoutImage = createElement(View, innerProps, loaded && createBaseImage());
|
|
292
|
+
return isSvg ? SvgImage : isLayoutMode ? LayoutImage : BaseImage;
|
|
289
293
|
});
|
|
290
294
|
Image.displayName = 'mpx-image';
|
|
291
295
|
export default Image;
|
|
@@ -54,7 +54,7 @@ const keyboardTypeMap = {
|
|
|
54
54
|
}) || ''
|
|
55
55
|
};
|
|
56
56
|
const Input = forwardRef((props, ref) => {
|
|
57
|
-
const { style = {}, allowFontScaling = false, type = 'text', value, password, 'placeholder-style': placeholderStyle, disabled, maxlength = 140, 'auto-focus': autoFocus, focus, 'confirm-type': confirmType = 'done', 'confirm-hold': confirmHold = false, cursor, 'cursor-color': cursorColor, 'selection-start': selectionStart = -1, 'selection-end': selectionEnd = -1, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, 'adjust-position': adjustPosition =
|
|
57
|
+
const { style = {}, allowFontScaling = false, type = 'text', value, password, 'placeholder-style': placeholderStyle, disabled, maxlength = 140, 'auto-focus': autoFocus, focus, 'confirm-type': confirmType = 'done', 'confirm-hold': confirmHold = false, cursor, 'cursor-color': cursorColor, 'selection-start': selectionStart = -1, 'selection-end': selectionEnd = -1, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, 'adjust-position': adjustPosition = false, bindinput, bindfocus, bindblur, bindconfirm, bindselectionchange,
|
|
58
58
|
// private
|
|
59
59
|
multiline, 'auto-height': autoHeight, bindlinechange } = props;
|
|
60
60
|
const formContext = useContext(FormContext);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { View, Text, Modal, TouchableWithoutFeedback } from 'react-native';
|
|
2
|
-
import
|
|
2
|
+
import Portal from '../mpx-portal';
|
|
3
|
+
import { PickerView } from '@ant-design/react-native';
|
|
3
4
|
import React, { forwardRef, useState, useRef, useEffect } from 'react';
|
|
4
5
|
import useNodesRef from '../useNodesRef'; // 引入辅助函数
|
|
5
6
|
// 可见应用窗口的大小。
|
|
@@ -3,7 +3,7 @@ import Reanimated, { Extrapolation, interpolate, useAnimatedStyle, useSharedValu
|
|
|
3
3
|
import { wrapChildren, extendObject } from './utils';
|
|
4
4
|
import { createFaces } from './pickerFaces';
|
|
5
5
|
import { usePickerViewColumnAnimationContext } from './pickerVIewContext';
|
|
6
|
-
const _PickerViewColumnItem = ({ item, index, itemHeight, itemWidth, textStyleFromParent, textStyle, hasVarDec, varContext, textProps, visibleCount, onItemLayout }) => {
|
|
6
|
+
const _PickerViewColumnItem = ({ item, index, itemHeight, itemWidth = '100%', textStyleFromParent, textStyle, hasVarDec, varContext, textProps, visibleCount, onItemLayout }) => {
|
|
7
7
|
const offsetYShared = usePickerViewColumnAnimationContext();
|
|
8
8
|
const facesShared = useSharedValue(createFaces(itemHeight, visibleCount));
|
|
9
9
|
useEffect(() => {
|
|
@@ -14,8 +14,8 @@ const _PickerViewColumnItem = ({ item, index, itemHeight, itemWidth, textStyleFr
|
|
|
14
14
|
return {
|
|
15
15
|
opacity: interpolate(offsetYShared.value, inputRange, facesShared.value.map((x) => x.opacity), Extrapolation.CLAMP),
|
|
16
16
|
transform: [
|
|
17
|
-
{ rotateX: interpolate(offsetYShared.value, inputRange, facesShared.value.map((x) => x.deg), Extrapolation.CLAMP) + 'deg' },
|
|
18
17
|
{ translateY: interpolate(offsetYShared.value, inputRange, facesShared.value.map((x) => x.offsetY), Extrapolation.EXTEND) },
|
|
18
|
+
{ rotateX: interpolate(offsetYShared.value, inputRange, facesShared.value.map((x) => x.deg), Extrapolation.CLAMP) + 'deg' },
|
|
19
19
|
{ scale: interpolate(offsetYShared.value, inputRange, facesShared.value.map((x) => x.scale), Extrapolation.EXTEND) }
|
|
20
20
|
]
|
|
21
21
|
};
|