@mpxjs/webpack-plugin 2.10.24 → 2.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +4 -1
- package/lib/platform/style/wx/index.js +417 -120
- package/lib/platform/template/wx/component-config/picker.js +0 -6
- package/lib/react/style-helper.js +6 -6
- package/lib/resolver/AddEnvPlugin.js +1 -1
- package/lib/resolver/AddModePlugin.js +1 -1
- package/lib/resolver/ExtendComponentsPlugin.js +68 -0
- package/lib/runtime/components/extends/section-list.mpx +14 -0
- 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 -2
- package/lib/runtime/components/react/dist/mpx-button.jsx +16 -9
- package/lib/runtime/components/react/dist/mpx-camera.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-camera.jsx +36 -5
- package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +1 -3
- 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 -2
- package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +3 -4
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +1 -2
- package/lib/runtime/components/react/dist/mpx-checkbox.jsx +8 -9
- package/lib/runtime/components/react/dist/mpx-form.d.ts +1 -2
- package/lib/runtime/components/react/dist/mpx-form.jsx +5 -5
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-icon/index.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-image.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-image.jsx +59 -43
- package/lib/runtime/components/react/dist/mpx-inline-text.jsx +13 -4
- package/lib/runtime/components/react/dist/mpx-input.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-input.jsx +16 -8
- package/lib/runtime/components/react/dist/mpx-label.d.ts +1 -2
- package/lib/runtime/components/react/dist/mpx-label.jsx +5 -6
- package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +3 -3
- package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +1 -2
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +6 -6
- package/lib/runtime/components/react/dist/mpx-nav.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-picker/index.jsx +72 -23
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +4 -0
- 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 +10 -14
- package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.js +0 -5
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +34 -14
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.jsx +4 -5
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.jsx +3 -5
- package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +5 -4
- package/lib/runtime/components/react/dist/mpx-popup/index.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-popup/popupBase.jsx +3 -2
- package/lib/runtime/components/react/dist/mpx-progress.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-progress.jsx +1 -3
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-radio-group.jsx +3 -4
- package/lib/runtime/components/react/dist/mpx-radio.d.ts +1 -2
- package/lib/runtime/components/react/dist/mpx-radio.jsx +8 -9
- package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +1 -3
- package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +1 -2
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +6 -6
- package/lib/runtime/components/react/dist/mpx-section-list.d.ts +51 -0
- package/lib/runtime/components/react/dist/mpx-section-list.jsx +376 -0
- package/lib/runtime/components/react/dist/mpx-simple-text.jsx +37 -19
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +4 -1
- package/lib/runtime/components/react/dist/mpx-simple-view.jsx +11 -4
- package/lib/runtime/components/react/dist/mpx-slider.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-slider.jsx +6 -7
- package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +1 -2
- package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +5 -5
- package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +1 -2
- package/lib/runtime/components/react/dist/mpx-sticky-section.jsx +6 -6
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +1 -2
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +5 -5
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts +1 -2
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +4 -8
- package/lib/runtime/components/react/dist/mpx-switch.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-switch.jsx +1 -3
- package/lib/runtime/components/react/dist/mpx-text.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-text.jsx +43 -25
- package/lib/runtime/components/react/dist/mpx-video.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-video.jsx +4 -5
- package/lib/runtime/components/react/dist/mpx-view.d.ts +2 -2
- package/lib/runtime/components/react/dist/mpx-view.jsx +214 -114
- package/lib/runtime/components/react/dist/mpx-web-view.d.ts +2 -1
- 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 +71 -70
- package/lib/runtime/components/react/dist/utils.jsx +1295 -456
- 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 -18
- package/lib/runtime/components/react/mpx-camera.tsx +40 -8
- package/lib/runtime/components/react/mpx-canvas/index.tsx +5 -7
- package/lib/runtime/components/react/mpx-canvas/utils.tsx +3 -1
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +2 -8
- package/lib/runtime/components/react/mpx-checkbox.tsx +9 -13
- package/lib/runtime/components/react/mpx-form.tsx +6 -8
- package/lib/runtime/components/react/mpx-icon/index.tsx +1 -5
- package/lib/runtime/components/react/mpx-image.tsx +66 -58
- package/lib/runtime/components/react/mpx-inline-text.tsx +13 -4
- package/lib/runtime/components/react/mpx-input.tsx +19 -12
- package/lib/runtime/components/react/mpx-label.tsx +6 -10
- package/lib/runtime/components/react/mpx-movable-area.tsx +3 -5
- package/lib/runtime/components/react/mpx-movable-view.tsx +7 -9
- package/lib/runtime/components/react/mpx-nav.tsx +1 -1
- package/lib/runtime/components/react/mpx-picker/index.tsx +100 -29
- package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +3 -3
- package/lib/runtime/components/react/mpx-picker/selector.tsx +1 -1
- package/lib/runtime/components/react/mpx-picker/type.ts +4 -0
- package/lib/runtime/components/react/mpx-picker-view/index.tsx +17 -24
- package/lib/runtime/components/react/mpx-picker-view/pickerVIewContext.ts +0 -9
- package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +44 -23
- package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItem.tsx +1 -9
- package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItemLite.tsx +0 -9
- package/lib/runtime/components/react/mpx-popup/index.tsx +7 -3
- package/lib/runtime/components/react/mpx-popup/popupBase.tsx +3 -2
- package/lib/runtime/components/react/mpx-progress.tsx +0 -6
- package/lib/runtime/components/react/mpx-radio-group.tsx +2 -8
- package/lib/runtime/components/react/mpx-radio.tsx +9 -13
- package/lib/runtime/components/react/mpx-rich-text/index.tsx +0 -6
- package/lib/runtime/components/react/mpx-scroll-view.tsx +7 -9
- package/lib/runtime/components/react/mpx-section-list.tsx +557 -0
- package/lib/runtime/components/react/mpx-simple-text.tsx +36 -25
- package/lib/runtime/components/react/mpx-simple-view.tsx +17 -5
- package/lib/runtime/components/react/mpx-slider.tsx +15 -13
- package/lib/runtime/components/react/mpx-sticky-header.tsx +6 -8
- package/lib/runtime/components/react/mpx-sticky-section.tsx +7 -9
- package/lib/runtime/components/react/mpx-swiper-item.tsx +6 -7
- package/lib/runtime/components/react/mpx-swiper.tsx +5 -11
- package/lib/runtime/components/react/mpx-switch.tsx +0 -6
- package/lib/runtime/components/react/mpx-text.tsx +45 -36
- package/lib/runtime/components/react/mpx-video.tsx +3 -8
- package/lib/runtime/components/react/mpx-view.tsx +235 -129
- package/lib/runtime/components/react/mpx-web-view.tsx +12 -6
- 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 +1352 -550
- package/lib/runtime/i18n.wxs +15 -9
- package/lib/style-compiler/strip-conditional.js +19 -4
- package/lib/template-compiler/compiler.js +6 -0
- package/package.json +6 -6
|
@@ -22,7 +22,7 @@ import { StyleSheet } from 'react-native';
|
|
|
22
22
|
import useInnerProps, { getCustomEvent } from './getInnerListeners';
|
|
23
23
|
import useNodesRef from './useNodesRef';
|
|
24
24
|
import { MovableAreaContext } from './context';
|
|
25
|
-
import { useTransformStyle, splitProps, splitStyle,
|
|
25
|
+
import { useTransformStyle, splitProps, splitStyle, hiddenStyle, wrapChildren, flatGesture, extendObject, omit, useNavigation, useRunOnJSCallback, useTextPassThrough } from './utils';
|
|
26
26
|
import { GestureDetector, Gesture } from 'react-native-gesture-handler';
|
|
27
27
|
import Animated, { useSharedValue, useAnimatedStyle, runOnJS, runOnUI, withTiming, Easing } from 'react-native-reanimated';
|
|
28
28
|
import { collectDataset, noop } from '@mpxjs/utils';
|
|
@@ -129,14 +129,14 @@ const _MovableView = forwardRef((movableViewProps, ref) => {
|
|
|
129
129
|
const hasLayoutRef = useRef(false);
|
|
130
130
|
const propsRef = useRef({});
|
|
131
131
|
propsRef.current = (props || {});
|
|
132
|
-
const { x = 0, y = 0, inertia = false, disabled = false, animation = true, damping = 20, friction = 2, 'out-of-bounds': outOfBounds = false, 'enable-var': enableVar, '
|
|
133
|
-
const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(Object.assign({}, style, styles.container), { enableVar,
|
|
132
|
+
const { x = 0, y = 0, inertia = false, disabled = false, animation = true, damping = 20, friction = 2, 'out-of-bounds': outOfBounds = false, 'enable-var': enableVar, 'enable-text-pass-through': enableTextPassThrough, 'parent-width': parentWidth, 'parent-height': parentHeight, direction = 'none', 'disable-event-passthrough': disableEventPassthrough = false, 'simultaneous-handlers': originSimultaneousHandlers = [], 'wait-for': waitFor = [], style = {}, changeThrottleTime = 60, bindtouchstart, catchtouchstart, bindhtouchmove, bindvtouchmove, bindtouchmove, catchhtouchmove, catchvtouchmove, catchtouchmove, bindtouchend, catchtouchend, bindchange } = props;
|
|
133
|
+
const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(Object.assign({}, style, styles.container), { enableVar, parentWidth, parentHeight });
|
|
134
134
|
const navigation = useNavigation();
|
|
135
135
|
const prevSimultaneousHandlersRef = useRef(originSimultaneousHandlers || []);
|
|
136
136
|
const prevWaitForHandlersRef = useRef(waitFor || []);
|
|
137
137
|
const gestureSwitch = useRef(false);
|
|
138
138
|
const { textStyle, innerStyle } = splitStyle(normalStyle);
|
|
139
|
-
const textPassThrough =
|
|
139
|
+
const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough });
|
|
140
140
|
const offsetX = useSharedValue(x);
|
|
141
141
|
const offsetY = useSharedValue(y);
|
|
142
142
|
const startPosition = useSharedValue({
|
|
@@ -564,7 +564,7 @@ const _MovableView = forwardRef((movableViewProps, ref) => {
|
|
|
564
564
|
});
|
|
565
565
|
return handlers;
|
|
566
566
|
};
|
|
567
|
-
const layoutStyle = !hasLayoutRef.current && hasSelfPercent ?
|
|
567
|
+
const layoutStyle = !hasLayoutRef.current && hasSelfPercent ? hiddenStyle : {};
|
|
568
568
|
// bind 相关 touch 事件直接由 gesture 触发,无须重复挂载
|
|
569
569
|
// catch 相关 touch 事件需要重写并通过 useInnerProps 注入阻止冒泡逻辑
|
|
570
570
|
const filterProps = omit(props, [
|
|
@@ -599,7 +599,7 @@ const _MovableView = forwardRef((movableViewProps, ref) => {
|
|
|
599
599
|
'changeThrottleTime',
|
|
600
600
|
'bindchange'
|
|
601
601
|
]);
|
|
602
|
-
return createElement(GestureDetector, { gesture: gesture }, createElement(Animated.View, innerProps, wrapChildren(props, {
|
|
602
|
+
return createElement(GestureDetector, { gesture: gesture }, createElement(Animated.View, innerProps, wrapChildren(props.children, {
|
|
603
603
|
hasVarDec,
|
|
604
604
|
varContext: varContextRef.current,
|
|
605
605
|
textPassThrough
|
|
@@ -86,7 +86,7 @@ const MpxNav = memo(({ pageConfig, navigation }) => {
|
|
|
86
86
|
};
|
|
87
87
|
const isCustom = innerPageConfig.navigationStyle === 'custom';
|
|
88
88
|
const navigationBarTextStyle = useMemo(() => validBarTextStyle(innerPageConfig.navigationBarTextStyle), [innerPageConfig.navigationBarTextStyle]);
|
|
89
|
-
//
|
|
89
|
+
// 状态栏由 MpxNav 根据页面配置统一控制,避免 native-stack screenOptions 在页面切换时覆盖页面级配置。
|
|
90
90
|
const statusBarElement = (<StatusBar translucent backgroundColor='transparent' barStyle={navigationBarTextStyle === NavColor.White ? 'light-content' : 'dark-content'}></StatusBar>);
|
|
91
91
|
if (isCustom)
|
|
92
92
|
return statusBarElement;
|
|
@@ -6,10 +6,11 @@ import PickerMultiSelector from './multiSelector';
|
|
|
6
6
|
import PickerTime from './time';
|
|
7
7
|
import PickerDate from './date';
|
|
8
8
|
import PickerRegion from './region';
|
|
9
|
+
import Portal from '../mpx-portal';
|
|
9
10
|
import { FormContext, RouteContext } from '../context';
|
|
10
11
|
import useNodesRef from '../useNodesRef';
|
|
11
12
|
import useInnerProps, { getCustomEvent } from '../getInnerListeners';
|
|
12
|
-
import { extendObject, useLayout } from '../utils';
|
|
13
|
+
import { extendObject, splitProps, splitStyle, useLayout, useTextPassThrough, useTransformStyle, wrapChildren } from '../utils';
|
|
13
14
|
import { createPopupManager } from '../mpx-popup';
|
|
14
15
|
/**
|
|
15
16
|
* ✔ mode
|
|
@@ -103,27 +104,48 @@ const buttonTextMap = {
|
|
|
103
104
|
confirm: 'Confirm'
|
|
104
105
|
}
|
|
105
106
|
};
|
|
106
|
-
const Picker = forwardRef((
|
|
107
|
-
const {
|
|
107
|
+
const Picker = forwardRef((pickerProps, ref) => {
|
|
108
|
+
const { textProps, innerProps: splitInnerProps } = splitProps(pickerProps);
|
|
109
|
+
const props = (splitInnerProps || {});
|
|
110
|
+
const { mode, value, range = [], children, disabled, bindcancel, bindchange, 'header-text': headerText = '', style, 'enable-var': enableVar, 'enable-text-pass-through': enableTextPassThrough, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
|
|
111
|
+
const modalProps = props;
|
|
112
|
+
const rangeKey = modalProps['range-key'];
|
|
108
113
|
const { pageId } = useContext(RouteContext) || {};
|
|
109
114
|
const buttonText = buttonTextMap[global.__mpx?.i18n?.locale || 'zh-CN'];
|
|
110
115
|
const pickerValue = useRef(value);
|
|
111
116
|
pickerValue.current = Array.isArray(value) ? value.slice() : value;
|
|
112
117
|
const nodeRef = useRef(null);
|
|
113
118
|
const pickerRef = useRef(null);
|
|
114
|
-
const { open, show, hide, remove } = useRef(createPopupManager()).current;
|
|
115
|
-
|
|
116
|
-
const {
|
|
119
|
+
const { open, show, hide, remove, update } = useRef(createPopupManager()).current;
|
|
120
|
+
const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, hasPositionFixed, setWidth, setHeight } = useTransformStyle(style, { enableVar, parentWidth, parentHeight });
|
|
121
|
+
const { textStyle, backgroundStyle, innerStyle = {} } = splitStyle(normalStyle);
|
|
122
|
+
const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough });
|
|
123
|
+
if (backgroundStyle) {
|
|
124
|
+
warn('Picker does not support background image-related styles!');
|
|
125
|
+
}
|
|
126
|
+
useNodesRef(props, ref, nodeRef, {
|
|
127
|
+
style: normalStyle
|
|
128
|
+
});
|
|
129
|
+
const { layoutRef, layoutProps, layoutStyle } = useLayout({
|
|
117
130
|
props,
|
|
118
|
-
hasSelfPercent
|
|
131
|
+
hasSelfPercent,
|
|
132
|
+
setWidth,
|
|
133
|
+
setHeight,
|
|
119
134
|
nodeRef
|
|
120
135
|
});
|
|
121
136
|
const innerProps = useInnerProps(extendObject({}, props, {
|
|
122
|
-
ref: nodeRef
|
|
137
|
+
ref: nodeRef,
|
|
138
|
+
style: extendObject({}, innerStyle, layoutStyle)
|
|
123
139
|
}, layoutProps), [
|
|
124
140
|
'mode',
|
|
125
141
|
'value',
|
|
126
142
|
'range',
|
|
143
|
+
'range-key',
|
|
144
|
+
'start',
|
|
145
|
+
'end',
|
|
146
|
+
'fields',
|
|
147
|
+
'level',
|
|
148
|
+
'custom-item',
|
|
127
149
|
'disabled',
|
|
128
150
|
'bindcancel',
|
|
129
151
|
'bindchange',
|
|
@@ -133,9 +155,9 @@ const Picker = forwardRef((props, ref) => {
|
|
|
133
155
|
], { layoutRef });
|
|
134
156
|
useEffect(() => {
|
|
135
157
|
if (range && pickerRef.current && mode === "multiSelector" /* PickerMode.MULTI_SELECTOR */) {
|
|
136
|
-
pickerRef.current.updateRange?.(range);
|
|
158
|
+
pickerRef.current.updateRange?.(range, rangeKey);
|
|
137
159
|
}
|
|
138
|
-
}, [JSON.stringify(range)]);
|
|
160
|
+
}, [JSON.stringify(range), rangeKey, mode]);
|
|
139
161
|
/** --- form 表单组件内部方法 --- */
|
|
140
162
|
const getValue = () => {
|
|
141
163
|
return pickerValue.current;
|
|
@@ -185,14 +207,8 @@ const Picker = forwardRef((props, ref) => {
|
|
|
185
207
|
bindchange?.(eventData);
|
|
186
208
|
hide();
|
|
187
209
|
};
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
children,
|
|
191
|
-
bindchange: onChange,
|
|
192
|
-
bindcolumnchange: onColumnChange,
|
|
193
|
-
getRange: () => range
|
|
194
|
-
});
|
|
195
|
-
const renderPickerContent = () => {
|
|
210
|
+
const getContentHeight = () => headerText ? 350 : 310;
|
|
211
|
+
const getPickerContent = () => {
|
|
196
212
|
if (disabled) {
|
|
197
213
|
return null;
|
|
198
214
|
}
|
|
@@ -200,9 +216,21 @@ const Picker = forwardRef((props, ref) => {
|
|
|
200
216
|
if (!(_mode in pickerModalMap)) {
|
|
201
217
|
return warn(`[Mpx runtime warn]: Unsupported <picker> mode: ${mode}`);
|
|
202
218
|
}
|
|
219
|
+
const specificProps = {
|
|
220
|
+
mode: _mode,
|
|
221
|
+
range,
|
|
222
|
+
'range-key': rangeKey,
|
|
223
|
+
start: modalProps.start,
|
|
224
|
+
end: modalProps.end,
|
|
225
|
+
fields: modalProps.fields,
|
|
226
|
+
level: modalProps.level,
|
|
227
|
+
'custom-item': modalProps['custom-item'],
|
|
228
|
+
bindchange: onChange,
|
|
229
|
+
bindcolumnchange: onColumnChange
|
|
230
|
+
};
|
|
203
231
|
const _value = value;
|
|
204
232
|
const PickerModal = pickerModalMap[_mode];
|
|
205
|
-
|
|
233
|
+
return (<>
|
|
206
234
|
{headerText && (<View style={[styles.header]}>
|
|
207
235
|
<Text style={[styles.headerText]}>{headerText}</Text>
|
|
208
236
|
</View>)}
|
|
@@ -216,16 +244,37 @@ const Picker = forwardRef((props, ref) => {
|
|
|
216
244
|
</View>
|
|
217
245
|
</View>
|
|
218
246
|
</>);
|
|
219
|
-
|
|
220
|
-
|
|
247
|
+
};
|
|
248
|
+
const openPickerContent = () => {
|
|
249
|
+
const renderPickerModal = getPickerContent();
|
|
250
|
+
if (!renderPickerModal) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
open(renderPickerModal, pageId, { contentHeight: getContentHeight() });
|
|
221
254
|
};
|
|
222
255
|
useEffect(() => {
|
|
223
|
-
|
|
256
|
+
openPickerContent();
|
|
224
257
|
return () => {
|
|
225
258
|
remove();
|
|
226
259
|
};
|
|
227
260
|
}, []);
|
|
228
|
-
|
|
261
|
+
const showPicker = () => {
|
|
262
|
+
const renderPickerModal = getPickerContent();
|
|
263
|
+
if (!renderPickerModal) {
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
update(renderPickerModal, { contentHeight: getContentHeight() });
|
|
267
|
+
show();
|
|
268
|
+
};
|
|
269
|
+
const finalComponent = createElement(TouchableWithoutFeedback, { onPress: showPicker }, createElement(View, innerProps, wrapChildren(children, {
|
|
270
|
+
hasVarDec,
|
|
271
|
+
varContext: varContextRef.current,
|
|
272
|
+
textPassThrough
|
|
273
|
+
})));
|
|
274
|
+
if (hasPositionFixed) {
|
|
275
|
+
return createElement(Portal, null, finalComponent);
|
|
276
|
+
}
|
|
277
|
+
return finalComponent;
|
|
229
278
|
});
|
|
230
279
|
Picker.displayName = 'MpxPicker';
|
|
231
280
|
export default Picker;
|
|
@@ -41,8 +41,8 @@ const PickerMultiSelector = forwardRef((props, ref) => {
|
|
|
41
41
|
setFormatValue(newValue);
|
|
42
42
|
}
|
|
43
43
|
}, [formatValue]);
|
|
44
|
-
const updateRange = (newRange) => {
|
|
45
|
-
const range = formatRangeFun(newRange.slice(),
|
|
44
|
+
const updateRange = (newRange, rangeKey) => {
|
|
45
|
+
const range = formatRangeFun(newRange.slice(), rangeKey);
|
|
46
46
|
setFormatRange(range);
|
|
47
47
|
};
|
|
48
48
|
const _props = useRef(props);
|
|
@@ -25,6 +25,10 @@ export interface BasePickerProps {
|
|
|
25
25
|
/** 作为表单组件时的名称 */
|
|
26
26
|
name?: string;
|
|
27
27
|
style?: Record<string, any>;
|
|
28
|
+
'enable-var'?: boolean;
|
|
29
|
+
'enable-text-pass-through'?: boolean;
|
|
30
|
+
'parent-width'?: number;
|
|
31
|
+
'parent-height'?: number;
|
|
28
32
|
children?: React.ReactNode;
|
|
29
33
|
range?: RangeItem[];
|
|
30
34
|
ref?: any;
|
|
@@ -25,7 +25,7 @@ interface PickerViewProps {
|
|
|
25
25
|
'indicator-style'?: Record<string, any>;
|
|
26
26
|
'mask-style'?: Record<string, any>;
|
|
27
27
|
'enable-var'?: boolean;
|
|
28
|
-
'
|
|
28
|
+
'enable-text-pass-through'?: boolean;
|
|
29
29
|
'enable-offset'?: boolean;
|
|
30
30
|
}
|
|
31
31
|
declare const _PickerView: React.ForwardRefExoticComponent<PickerViewProps & React.RefAttributes<HandlerRef<View, PickerViewProps>>>;
|
|
@@ -2,8 +2,7 @@ import { View } from 'react-native';
|
|
|
2
2
|
import React, { createElement, forwardRef, useRef } from 'react';
|
|
3
3
|
import useInnerProps, { getCustomEvent } from '../getInnerListeners';
|
|
4
4
|
import useNodesRef from '../useNodesRef';
|
|
5
|
-
import { useLayout, splitProps, splitStyle, wrapChildren, useTransformStyle, extendObject,
|
|
6
|
-
import { PickerViewStyleContext } from './pickerVIewContext';
|
|
5
|
+
import { useLayout, splitProps, splitStyle, wrapChildren, useTransformStyle, extendObject, useTextPassThrough } from '../utils';
|
|
7
6
|
import Portal from '../mpx-portal';
|
|
8
7
|
const styles = {
|
|
9
8
|
wrapper: {
|
|
@@ -17,21 +16,21 @@ const styles = {
|
|
|
17
16
|
};
|
|
18
17
|
const DefaultPickerItemH = 36;
|
|
19
18
|
const _PickerView = forwardRef((props, ref) => {
|
|
20
|
-
const { children, value = [], bindchange, style, 'enable-wheel-animation': enableWheelAnimation = true, 'indicator-style': indicatorStyle = {}, 'mask-style': pickerMaskStyle = {}, 'enable-var': enableVar, '
|
|
19
|
+
const { children, value = [], bindchange, style, 'enable-wheel-animation': enableWheelAnimation = true, 'indicator-style': indicatorStyle = {}, 'mask-style': pickerMaskStyle = {}, 'enable-var': enableVar, 'enable-text-pass-through': enableTextPassThrough } = props;
|
|
21
20
|
const { height: indicatorH, ...pickerIndicatorStyle } = indicatorStyle;
|
|
22
21
|
const nodeRef = useRef(null);
|
|
23
22
|
const cloneRef = useRef(null);
|
|
24
23
|
const activeValueRef = useRef(value);
|
|
25
24
|
activeValueRef.current = value.slice();
|
|
26
25
|
const snapActiveValueRef = useRef(null);
|
|
27
|
-
const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, setWidth, setHeight, hasPositionFixed } = useTransformStyle(style, { enableVar
|
|
26
|
+
const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, setWidth, setHeight, hasPositionFixed } = useTransformStyle(style, { enableVar });
|
|
28
27
|
useNodesRef(props, ref, nodeRef, {
|
|
29
28
|
style: normalStyle
|
|
30
29
|
});
|
|
31
30
|
const { layoutRef, layoutProps, layoutStyle } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: nodeRef });
|
|
32
31
|
const { textProps } = splitProps(props);
|
|
33
32
|
const { textStyle } = splitStyle(normalStyle);
|
|
34
|
-
const textPassThrough =
|
|
33
|
+
const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough });
|
|
35
34
|
const onSelectChange = (columnIndex, selectedIndex) => {
|
|
36
35
|
const activeValue = activeValueRef.current;
|
|
37
36
|
activeValue[columnIndex] = selectedIndex;
|
|
@@ -82,14 +81,7 @@ const _PickerView = forwardRef((props, ref) => {
|
|
|
82
81
|
pickerMaskStyle,
|
|
83
82
|
enableWheelAnimation
|
|
84
83
|
});
|
|
85
|
-
|
|
86
|
-
return wrapChildren({
|
|
87
|
-
children: realElement
|
|
88
|
-
}, {
|
|
89
|
-
hasVarDec,
|
|
90
|
-
varContext: varContextRef.current,
|
|
91
|
-
textPassThrough
|
|
92
|
-
});
|
|
84
|
+
return React.cloneElement(child, wrappedProps);
|
|
93
85
|
};
|
|
94
86
|
const validateChildInitialIndex = (index, data) => {
|
|
95
87
|
return Math.max(0, Math.min(value[index] || 0, data.length - 1));
|
|
@@ -119,7 +111,11 @@ const _PickerView = forwardRef((props, ref) => {
|
|
|
119
111
|
onInitialChange(isInvalid, validValue);
|
|
120
112
|
return renderColumns;
|
|
121
113
|
};
|
|
122
|
-
const finalComponent = createElement(
|
|
114
|
+
const finalComponent = createElement(View, innerProps, createElement(View, { style: [styles.wrapper] }, wrapChildren(renderPickerColumns(), {
|
|
115
|
+
hasVarDec,
|
|
116
|
+
varContext: varContextRef.current,
|
|
117
|
+
textPassThrough
|
|
118
|
+
})));
|
|
123
119
|
if (hasPositionFixed) {
|
|
124
120
|
return createElement(Portal, null, finalComponent);
|
|
125
121
|
}
|
|
@@ -3,6 +3,4 @@ import { SharedValue } from 'react-native-reanimated';
|
|
|
3
3
|
type ContextValue = SharedValue<number>;
|
|
4
4
|
export declare const PickerViewColumnAnimationContext: import("react").Context<ContextValue | undefined>;
|
|
5
5
|
export declare const usePickerViewColumnAnimationContext: () => ContextValue;
|
|
6
|
-
export declare const PickerViewStyleContext: import("react").Context<Record<string, any> | undefined>;
|
|
7
|
-
export declare const usePickerViewStyleContext: () => Record<string, any> | undefined;
|
|
8
6
|
export {};
|
|
@@ -7,8 +7,3 @@ export const usePickerViewColumnAnimationContext = () => {
|
|
|
7
7
|
}
|
|
8
8
|
return value;
|
|
9
9
|
};
|
|
10
|
-
export const PickerViewStyleContext = createContext(undefined);
|
|
11
|
-
export const usePickerViewStyleContext = () => {
|
|
12
|
-
const value = useContext(PickerViewStyleContext);
|
|
13
|
-
return value;
|
|
14
|
-
};
|
|
@@ -10,7 +10,6 @@ interface ColumnProps {
|
|
|
10
10
|
[key: string]: any;
|
|
11
11
|
};
|
|
12
12
|
'enable-var'?: boolean;
|
|
13
|
-
'external-var-context'?: Record<string, any>;
|
|
14
13
|
wrapperStyle: {
|
|
15
14
|
height: number;
|
|
16
15
|
itemHeight: number;
|
|
@@ -18,6 +17,7 @@ interface ColumnProps {
|
|
|
18
17
|
pickerMaskStyle: Record<string, any>;
|
|
19
18
|
pickerIndicatorStyle: Record<string, any>;
|
|
20
19
|
enableWheelAnimation?: boolean;
|
|
20
|
+
'enable-text-pass-through'?: boolean;
|
|
21
21
|
}
|
|
22
22
|
declare const _PickerViewColumn: React.ForwardRefExoticComponent<ColumnProps & React.RefAttributes<HandlerRef<ScrollView & View, ColumnProps>>>;
|
|
23
23
|
export default _PickerViewColumn;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { forwardRef, useRef, useState, useMemo, useEffect, useCallback, createElement } from 'react';
|
|
2
2
|
import { StyleSheet, View } from 'react-native';
|
|
3
3
|
import Reanimated, { useAnimatedRef, useScrollViewOffset } from 'react-native-reanimated';
|
|
4
|
-
import { useTransformStyle, splitStyle, splitProps, useLayout, usePrevious, isAndroid, isIOS, isHarmony, extendObject } from '../utils';
|
|
4
|
+
import { useTransformStyle, splitStyle, splitProps, useLayout, usePrevious, isAndroid, isIOS, isHarmony, extendObject, useTextPassThrough, wrapChildren } from '../utils';
|
|
5
5
|
import useNodesRef from '../useNodesRef';
|
|
6
6
|
import PickerIndicator from './pickerViewIndicator';
|
|
7
7
|
import PickerMask from './pickerViewMask';
|
|
@@ -11,17 +11,18 @@ import { PickerViewColumnAnimationContext } from '../mpx-picker-view/pickerVIewC
|
|
|
11
11
|
import { calcHeightOffsets } from './pickerViewFaces';
|
|
12
12
|
const visibleCount = 5;
|
|
13
13
|
const _PickerViewColumn = forwardRef((props, ref) => {
|
|
14
|
-
const { columnData, columnIndex, initialIndex, onSelectChange, style, wrapperStyle, pickerMaskStyle, pickerIndicatorStyle, enableWheelAnimation = true, 'enable-var': enableVar, '
|
|
15
|
-
const { normalStyle, hasSelfPercent, setWidth, setHeight } = useTransformStyle(style, { enableVar
|
|
16
|
-
const { textStyle
|
|
17
|
-
const { textProps
|
|
14
|
+
const { columnData, columnIndex, initialIndex, onSelectChange, style, wrapperStyle, pickerMaskStyle, pickerIndicatorStyle, enableWheelAnimation = true, 'enable-var': enableVar, 'enable-text-pass-through': enableTextPassThrough } = props;
|
|
15
|
+
const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, setWidth, setHeight } = useTransformStyle(style, { enableVar });
|
|
16
|
+
const { textStyle } = splitStyle(normalStyle);
|
|
17
|
+
const { textProps } = splitProps(props);
|
|
18
|
+
const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough });
|
|
18
19
|
const scrollViewRef = useAnimatedRef();
|
|
19
20
|
const offsetYShared = useScrollViewOffset(scrollViewRef);
|
|
20
21
|
useNodesRef(props, ref, scrollViewRef, {
|
|
21
22
|
style: normalStyle
|
|
22
23
|
});
|
|
23
24
|
const { height: pickerH, itemHeight } = wrapperStyle;
|
|
24
|
-
const [itemRawH, setItemRawH] = useState(itemHeight);
|
|
25
|
+
const [itemRawH, setItemRawH] = useState(Math.round(itemHeight));
|
|
25
26
|
const maxIndex = useMemo(() => columnData.length - 1, [columnData]);
|
|
26
27
|
const prevScrollingInfo = useRef({ index: initialIndex, y: 0 });
|
|
27
28
|
const dragging = useRef(false);
|
|
@@ -39,7 +40,7 @@ const _PickerViewColumn = forwardRef((props, ref) => {
|
|
|
39
40
|
setHeight,
|
|
40
41
|
nodeRef: scrollViewRef
|
|
41
42
|
});
|
|
42
|
-
const paddingHeight = useMemo(() =>
|
|
43
|
+
const paddingHeight = useMemo(() => (pickerH - itemRawH) / 2, [pickerH, itemRawH]);
|
|
43
44
|
const snapToOffsets = useMemo(() => Array.from({ length: maxIndex + 1 }, (_, i) => i * itemRawH), [maxIndex, itemRawH]);
|
|
44
45
|
const contentContainerStyle = useMemo(() => {
|
|
45
46
|
return [{ paddingVertical: paddingHeight }];
|
|
@@ -73,6 +74,15 @@ const _PickerViewColumn = forwardRef((props, ref) => {
|
|
|
73
74
|
clearTimerScrollTo();
|
|
74
75
|
};
|
|
75
76
|
}, []);
|
|
77
|
+
// `contentOffset` prop sets visual position but does not fire scroll events,
|
|
78
|
+
// so `offsetYShared` (from `useScrollViewOffset`) stays at 0 until the user scrolls.
|
|
79
|
+
// Directly sync it whenever `itemRawH` is established so wheel animation renders correctly.
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
if (!itemRawH || dragging.current || scrolling.current) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
offsetYShared.value = activeIndex.current * itemRawH;
|
|
85
|
+
}, [itemRawH]);
|
|
76
86
|
useEffect(() => {
|
|
77
87
|
if (!scrollViewRef.current ||
|
|
78
88
|
!itemRawH ||
|
|
@@ -94,13 +104,19 @@ const _PickerViewColumn = forwardRef((props, ref) => {
|
|
|
94
104
|
activeIndex.current = initialIndex;
|
|
95
105
|
}, isIOS ? 0 : 200);
|
|
96
106
|
}, [itemRawH, maxIndex, initialIndex]);
|
|
107
|
+
useEffect(() => {
|
|
108
|
+
const roundedH = Math.round(itemHeight);
|
|
109
|
+
if (roundedH) {
|
|
110
|
+
setItemRawH(roundedH);
|
|
111
|
+
}
|
|
112
|
+
}, [itemHeight]);
|
|
97
113
|
const onItemLayout = useCallback((e) => {
|
|
98
114
|
const { height: rawH } = e.nativeEvent.layout;
|
|
99
115
|
const roundedH = Math.round(rawH);
|
|
100
|
-
if (roundedH
|
|
116
|
+
if (roundedH) {
|
|
101
117
|
setItemRawH(roundedH);
|
|
102
118
|
}
|
|
103
|
-
}, [
|
|
119
|
+
}, []);
|
|
104
120
|
const resetScrollPosition = useCallback((y) => {
|
|
105
121
|
if (dragging.current || scrolling.current) {
|
|
106
122
|
return;
|
|
@@ -210,8 +226,8 @@ const _PickerViewColumn = forwardRef((props, ref) => {
|
|
|
210
226
|
}, [itemRawH, maxIndex, calcOffset, onMomentumScrollEnd]);
|
|
211
227
|
const renderInnerchild = () => columnData.map((item, index) => {
|
|
212
228
|
return enableWheelAnimation
|
|
213
|
-
? (<MpxPickerViewColumnItem key={index} item={item} index={index} itemHeight={
|
|
214
|
-
: (<MpxPickerViewColumnItemLite key={index} item={item} index={index} itemHeight={
|
|
229
|
+
? (<MpxPickerViewColumnItem key={index} item={item} index={index} itemHeight={itemRawH} visibleCount={visibleCount} onItemLayout={onItemLayout}/>)
|
|
230
|
+
: (<MpxPickerViewColumnItemLite key={index} item={item} index={index} itemHeight={itemRawH} onItemLayout={onItemLayout}/>);
|
|
215
231
|
});
|
|
216
232
|
const renderScollView = () => {
|
|
217
233
|
const innerProps = extendObject({}, layoutProps, {
|
|
@@ -235,10 +251,14 @@ const _PickerViewColumn = forwardRef((props, ref) => {
|
|
|
235
251
|
contentContainerStyle,
|
|
236
252
|
contentOffset: { x: 0, y: initialContentOffsetY }
|
|
237
253
|
});
|
|
238
|
-
return createElement(PickerViewColumnAnimationContext.Provider, { value: offsetYShared }, createElement(Reanimated.ScrollView, innerProps, renderInnerchild()
|
|
254
|
+
return createElement(PickerViewColumnAnimationContext.Provider, { value: offsetYShared }, createElement(Reanimated.ScrollView, innerProps, wrapChildren(renderInnerchild(), {
|
|
255
|
+
hasVarDec,
|
|
256
|
+
varContext: varContextRef.current,
|
|
257
|
+
textPassThrough
|
|
258
|
+
})));
|
|
239
259
|
};
|
|
240
|
-
const renderIndicator = () => (<PickerIndicator itemHeight={
|
|
241
|
-
const renderMask = () => (<PickerMask itemHeight={
|
|
260
|
+
const renderIndicator = () => (<PickerIndicator itemHeight={itemRawH} indicatorItemStyle={pickerIndicatorStyle}/>);
|
|
261
|
+
const renderMask = () => (<PickerMask itemHeight={itemRawH} maskContainerStyle={pickerMaskStyle}/>);
|
|
242
262
|
return (<View style={[styles.wrapper, normalStyle]}>
|
|
243
263
|
{renderScollView()}
|
|
244
264
|
{renderMask()}
|
|
@@ -5,9 +5,7 @@ interface PickerColumnItemProps {
|
|
|
5
5
|
index: number;
|
|
6
6
|
itemHeight: number;
|
|
7
7
|
itemWidth?: number | '100%';
|
|
8
|
-
textStyle: Record<string, any>;
|
|
9
8
|
visibleCount: number;
|
|
10
|
-
textProps?: any;
|
|
11
9
|
onItemLayout?: (e: LayoutChangeEvent) => void;
|
|
12
10
|
}
|
|
13
11
|
declare const PickerViewColumnItem: React.FC<PickerColumnItemProps>;
|
|
@@ -2,9 +2,8 @@ import React, { useMemo } from 'react';
|
|
|
2
2
|
import Reanimated, { Extrapolation, interpolate, useAnimatedStyle } from 'react-native-reanimated';
|
|
3
3
|
import { extendObject } from '../utils';
|
|
4
4
|
import { createFaces } from './pickerViewFaces';
|
|
5
|
-
import { usePickerViewColumnAnimationContext
|
|
6
|
-
const PickerViewColumnItem = ({ item, index, itemHeight, itemWidth = '100%',
|
|
7
|
-
const textStyleFromAncestor = usePickerViewStyleContext();
|
|
5
|
+
import { usePickerViewColumnAnimationContext } from '../mpx-picker-view/pickerVIewContext';
|
|
6
|
+
const PickerViewColumnItem = ({ item, index, itemHeight, itemWidth = '100%', visibleCount, onItemLayout }) => {
|
|
8
7
|
const offsetYShared = usePickerViewColumnAnimationContext();
|
|
9
8
|
const facesShared = useMemo(() => createFaces(itemHeight, visibleCount), [itemHeight, visibleCount]);
|
|
10
9
|
const animatedStyles = useAnimatedStyle(() => {
|
|
@@ -21,8 +20,8 @@ const PickerViewColumnItem = ({ item, index, itemHeight, itemWidth = '100%', tex
|
|
|
21
20
|
const strKey = `picker-column-item-${index}`;
|
|
22
21
|
const restProps = index === 0 ? { onLayout: onItemLayout } : {};
|
|
23
22
|
const itemProps = extendObject({
|
|
24
|
-
style: extendObject({ height: itemHeight, width: '100%' },
|
|
25
|
-
},
|
|
23
|
+
style: extendObject({ height: itemHeight, width: '100%' }, item.props.style)
|
|
24
|
+
}, restProps);
|
|
26
25
|
const realItem = React.cloneElement(item, itemProps);
|
|
27
26
|
return (<Reanimated.View key={strKey} style={[
|
|
28
27
|
{ height: itemHeight, width: itemWidth, pointerEvents: 'none' },
|
package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts
CHANGED
|
@@ -5,8 +5,6 @@ interface PickerColumnItemProps {
|
|
|
5
5
|
index: number;
|
|
6
6
|
itemHeight: number;
|
|
7
7
|
itemWidth?: number | '100%';
|
|
8
|
-
textStyle: Record<string, any>;
|
|
9
|
-
textProps?: any;
|
|
10
8
|
onItemLayout?: (e: LayoutChangeEvent) => void;
|
|
11
9
|
}
|
|
12
10
|
declare const PickerViewColumnItem: React.FC<PickerColumnItemProps>;
|
package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.jsx
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
import { extendObject } from '../utils';
|
|
4
|
-
|
|
5
|
-
const PickerViewColumnItem = ({ item, index, itemHeight, itemWidth = '100%', textStyle, textProps, onItemLayout }) => {
|
|
6
|
-
const textStyleFromAncestor = usePickerViewStyleContext();
|
|
4
|
+
const PickerViewColumnItem = ({ item, index, itemHeight, itemWidth = '100%', onItemLayout }) => {
|
|
7
5
|
const strKey = `picker-column-item-${index}`;
|
|
8
6
|
const restProps = index === 0 ? { onLayout: onItemLayout } : {};
|
|
9
7
|
const itemProps = extendObject({
|
|
10
|
-
style: extendObject({ height: itemHeight, width: '100%' },
|
|
11
|
-
},
|
|
8
|
+
style: extendObject({ height: itemHeight, width: '100%' }, item.props.style)
|
|
9
|
+
}, restProps);
|
|
12
10
|
const realItem = React.cloneElement(item, itemProps);
|
|
13
11
|
return (<View key={strKey} style={[
|
|
14
12
|
{ height: itemHeight, width: itemWidth, pointerEvents: 'none' }
|
|
@@ -7,16 +7,17 @@ export interface IUsePopupOptions {
|
|
|
7
7
|
modal?: React.ComponentType<PopupBaseProps>;
|
|
8
8
|
type?: PopupType;
|
|
9
9
|
}
|
|
10
|
+
type PopupOptions = {
|
|
11
|
+
contentHeight?: number;
|
|
12
|
+
};
|
|
10
13
|
/**
|
|
11
14
|
* 基于 Portal 封装的 Popup 弹窗组件管理 Hooks
|
|
12
15
|
*/
|
|
13
16
|
declare const createPopupManager: (options?: IUsePopupOptions) => {
|
|
14
|
-
open: (childComponent: React.ReactNode, pageId: number | undefined, options?:
|
|
15
|
-
contentHeight?: number;
|
|
16
|
-
}) => void;
|
|
17
|
+
open: (childComponent: React.ReactNode, pageId: number | undefined, options?: PopupOptions) => void;
|
|
17
18
|
show: () => void;
|
|
18
19
|
hide: () => void;
|
|
19
|
-
update: (updatedChild: ReactElement | null) => void;
|
|
20
|
+
update: (updatedChild: ReactElement | null, options?: PopupOptions) => void;
|
|
20
21
|
remove: () => void;
|
|
21
22
|
};
|
|
22
23
|
export { createPopupManager };
|
|
@@ -36,9 +36,9 @@ const createPopupManager = (options = {}) => {
|
|
|
36
36
|
popupKey = Portal.add(child, pageId);
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
|
-
const update = (updatedChild) => {
|
|
39
|
+
const update = (updatedChild, options) => {
|
|
40
40
|
if (popupKey !== null && child !== null && updatedChild !== null) {
|
|
41
|
-
child = cloneElement(child, { children: updatedChild });
|
|
41
|
+
child = cloneElement(child, Object.assign({ children: updatedChild }, options));
|
|
42
42
|
Portal.update(popupKey, child);
|
|
43
43
|
}
|
|
44
44
|
};
|
|
@@ -39,8 +39,9 @@ const MOVEOUT_HEIGHT = 330;
|
|
|
39
39
|
*/
|
|
40
40
|
const PopupBase = (props = {}) => {
|
|
41
41
|
const { children, hide = () => null, contentHeight = MOVEOUT_HEIGHT, visible = false } = props;
|
|
42
|
+
const moveoutHeight = contentHeight + bottom;
|
|
42
43
|
const fade = useSharedValue(MASK_OFF);
|
|
43
|
-
const slide = useSharedValue(
|
|
44
|
+
const slide = useSharedValue(moveoutHeight);
|
|
44
45
|
const animatedStylesMask = useAnimatedStyle(() => ({
|
|
45
46
|
opacity: fade.value
|
|
46
47
|
}));
|
|
@@ -62,7 +63,7 @@ const PopupBase = (props = {}) => {
|
|
|
62
63
|
easing: Easing.inOut(Easing.poly(3)),
|
|
63
64
|
duration: 300
|
|
64
65
|
});
|
|
65
|
-
slide.value = withTiming(
|
|
66
|
+
slide.value = withTiming(moveoutHeight, {
|
|
66
67
|
easing: Easing.inOut(Easing.poly(3)),
|
|
67
68
|
duration: 300
|
|
68
69
|
});
|
|
@@ -14,8 +14,6 @@ export interface ProgressProps {
|
|
|
14
14
|
style?: ViewStyle & Record<string, any>;
|
|
15
15
|
'enable-offset'?: boolean;
|
|
16
16
|
'enable-var'?: boolean;
|
|
17
|
-
'external-var-context'?: Record<string, any>;
|
|
18
|
-
'parent-font-size'?: number;
|
|
19
17
|
'parent-width'?: number;
|
|
20
18
|
'parent-height'?: number;
|
|
21
19
|
}
|
|
@@ -20,7 +20,7 @@ import useNodesRef from './useNodesRef';
|
|
|
20
20
|
import { useLayout, useTransformStyle, extendObject, useRunOnJSCallback } from './utils';
|
|
21
21
|
import Portal from './mpx-portal';
|
|
22
22
|
const Progress = forwardRef((props, ref) => {
|
|
23
|
-
const { percent = 0, 'stroke-width': strokeWidth = 6, color, activeColor = color || '#09BB07', backgroundColor = '#EBEBEB', active = false, 'active-mode': activeMode = 'backwards', duration = 30, style = {}, 'enable-var': enableVar, '
|
|
23
|
+
const { percent = 0, 'stroke-width': strokeWidth = 6, color, activeColor = color || '#09BB07', backgroundColor = '#EBEBEB', active = false, 'active-mode': activeMode = 'backwards', duration = 30, style = {}, 'enable-var': enableVar, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
|
|
24
24
|
const nodeRef = useRef(null);
|
|
25
25
|
const propsRef = useRef(props);
|
|
26
26
|
propsRef.current = props;
|
|
@@ -29,8 +29,6 @@ const Progress = forwardRef((props, ref) => {
|
|
|
29
29
|
const progressWidth = useSharedValue(0);
|
|
30
30
|
const { normalStyle, hasSelfPercent, setWidth, setHeight, hasPositionFixed } = useTransformStyle(style, {
|
|
31
31
|
enableVar,
|
|
32
|
-
externalVarContext,
|
|
33
|
-
parentFontSize,
|
|
34
32
|
parentWidth,
|
|
35
33
|
parentHeight
|
|
36
34
|
});
|
|
@@ -9,8 +9,6 @@ export interface RadioGroupProps {
|
|
|
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
|
-
'parent-font-size'?: number;
|
|
14
12
|
'parent-width'?: number;
|
|
15
13
|
'parent-height'?: number;
|
|
16
14
|
children: ReactNode;
|