@mpxjs/webpack-plugin 2.10.15 → 2.10.16-beta.11
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 +60 -0
- package/lib/dependencies/AppEntryDependency.js +2 -2
- package/lib/dependencies/DynamicEntryDependency.js +1 -1
- package/lib/dependencies/ImportDependency.js +102 -0
- package/lib/dependencies/RecordModuleIdMapDependency.js +49 -0
- package/lib/dependencies/ResolveDependency.js +1 -1
- package/lib/{retry-runtime-module.js → dependencies/RetryRuntimeModule.js} +1 -1
- package/lib/file-loader.js +13 -3
- package/lib/helpers.js +2 -0
- package/lib/index.js +51 -25
- package/lib/json-compiler/helper.js +72 -2
- package/lib/json-compiler/index.js +16 -56
- package/lib/json-compiler/plugin.js +2 -2
- package/lib/loader.js +10 -4
- package/lib/native-loader.js +6 -3
- package/lib/platform/json/wx/index.js +30 -29
- package/lib/platform/style/wx/index.js +8 -1
- package/lib/platform/template/wx/component-config/ad.js +5 -0
- package/lib/platform/template/wx/component-config/button.js +21 -5
- package/lib/platform/template/wx/component-config/camera.js +25 -3
- package/lib/platform/template/wx/component-config/canvas.js +8 -1
- package/lib/platform/template/wx/component-config/component.js +31 -33
- package/lib/platform/template/wx/component-config/cover-image.js +7 -2
- package/lib/platform/template/wx/component-config/cover-view.js +3 -1
- package/lib/platform/template/wx/component-config/fix-component-name.js +2 -2
- package/lib/platform/template/wx/component-config/form.js +27 -2
- package/lib/platform/template/wx/component-config/image.js +5 -0
- package/lib/platform/template/wx/component-config/input.js +10 -0
- package/lib/platform/template/wx/component-config/label.js +10 -2
- package/lib/platform/template/wx/component-config/map.js +11 -0
- package/lib/platform/template/wx/component-config/movable-area.js +4 -1
- package/lib/platform/template/wx/component-config/movable-view.js +17 -2
- package/lib/platform/template/wx/component-config/navigator.js +26 -0
- package/lib/platform/template/wx/component-config/picker-view.js +12 -0
- package/lib/platform/template/wx/component-config/picker.js +3 -1
- package/lib/platform/template/wx/component-config/progress.js +11 -1
- package/lib/platform/template/wx/component-config/rich-text.js +5 -0
- package/lib/platform/template/wx/component-config/scroll-view.js +12 -1
- package/lib/platform/template/wx/component-config/slider.js +20 -0
- package/lib/platform/template/wx/component-config/swiper-item.js +5 -2
- package/lib/platform/template/wx/component-config/swiper.js +10 -0
- package/lib/platform/template/wx/component-config/text.js +5 -0
- package/lib/platform/template/wx/component-config/textarea.js +19 -2
- package/lib/platform/template/wx/component-config/unsupported.js +10 -1
- package/lib/platform/template/wx/component-config/video.js +10 -0
- package/lib/platform/template/wx/index.js +21 -1
- package/lib/react/index.js +2 -0
- package/lib/react/processJSON.js +39 -71
- package/lib/react/processStyles.js +3 -2
- package/lib/react/processTemplate.js +8 -6
- package/lib/react/script-helper.js +6 -16
- package/lib/react/style-helper.js +10 -2
- package/lib/resolver/AddEnvPlugin.js +13 -0
- package/lib/resolver/AddModePlugin.js +18 -0
- package/lib/runtime/components/react/context.ts +13 -6
- package/lib/runtime/components/react/dist/context.d.ts +76 -0
- package/lib/runtime/components/react/dist/context.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/context.js +1 -0
- package/lib/runtime/components/react/dist/event.config.d.ts +8 -0
- package/lib/runtime/components/react/dist/event.config.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/getInnerListeners.d.ts +8 -0
- package/lib/runtime/components/react/dist/getInnerListeners.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts +13 -0
- package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-button.d.ts +69 -0
- package/lib/runtime/components/react/dist/mpx-button.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-camera.d.ts +27 -0
- package/lib/runtime/components/react/dist/mpx-camera.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-camera.jsx +197 -0
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts +24 -0
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts +8 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts +21 -0
- package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts +9 -0
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts +11 -0
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts +3 -0
- package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +33 -0
- package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +53 -0
- package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +21 -0
- package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +33 -0
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-form.d.ts +28 -0
- package/lib/runtime/components/react/dist/mpx-form.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +19 -0
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-image.d.ts +22 -0
- package/lib/runtime/components/react/dist/mpx-image.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-image.jsx +81 -37
- package/lib/runtime/components/react/dist/mpx-inline-text.d.ts +8 -0
- package/lib/runtime/components/react/dist/mpx-inline-text.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-input.d.ts +51 -0
- package/lib/runtime/components/react/dist/mpx-input.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-input.jsx +40 -12
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts +13 -0
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +61 -50
- package/lib/runtime/components/react/dist/mpx-label.d.ts +21 -0
- package/lib/runtime/components/react/dist/mpx-label.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +21 -0
- package/lib/runtime/components/react/dist/mpx-movable-area.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +66 -0
- package/lib/runtime/components/react/dist/mpx-movable-view.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-nav.d.ts +9 -0
- package/lib/runtime/components/react/dist/mpx-nav.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-nav.jsx +132 -0
- package/lib/runtime/components/react/dist/mpx-navigator.d.ts +10 -0
- package/lib/runtime/components/react/dist/mpx-navigator.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/date.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-picker/date.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts +8 -0
- package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/index.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-picker/index.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/region.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-picker/region.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts +3 -0
- package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/time.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-picker/time.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +107 -0
- package/lib/runtime/components/react/dist/mpx-picker/type.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +33 -0
- package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +4 -3
- package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +9 -0
- package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +24 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +12 -18
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +15 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.jsx +8 -11
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts +14 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.jsx +20 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts +17 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts +13 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts +12 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +23 -0
- package/lib/runtime/components/react/dist/mpx-popup/index.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts +17 -0
- package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-portal/index.d.ts +16 -0
- package/lib/runtime/components/react/dist/mpx-portal/index.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-portal/index.jsx +5 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts +30 -0
- package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts +10 -0
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-progress.d.ts +24 -0
- package/lib/runtime/components/react/dist/mpx-progress.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-progress.jsx +26 -22
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +21 -0
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-radio.d.ts +27 -0
- package/lib/runtime/components/react/dist/mpx-radio.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts +2 -0
- package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +25 -0
- package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-root-portal.d.ts +15 -0
- package/lib/runtime/components/react/dist/mpx-root-portal.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +55 -0
- package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +6 -14
- package/lib/runtime/components/react/dist/mpx-simple-text.d.ts +8 -0
- package/lib/runtime/components/react/dist/mpx-simple-text.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +8 -0
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-slider.d.ts +31 -0
- package/lib/runtime/components/react/dist/mpx-slider.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-slider.jsx +321 -0
- package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +18 -0
- package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +16 -0
- package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +19 -0
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts +53 -0
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +9 -5
- package/lib/runtime/components/react/dist/mpx-switch.d.ts +27 -0
- package/lib/runtime/components/react/dist/mpx-switch.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-text.d.ts +23 -0
- package/lib/runtime/components/react/dist/mpx-text.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-text.jsx +33 -5
- package/lib/runtime/components/react/dist/mpx-textarea.d.ts +8 -0
- package/lib/runtime/components/react/dist/mpx-textarea.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-video.d.ts +102 -0
- package/lib/runtime/components/react/dist/mpx-video.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-view.d.ts +35 -0
- package/lib/runtime/components/react/dist/mpx-view.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-view.jsx +8 -11
- package/lib/runtime/components/react/dist/mpx-web-view.d.ts +23 -0
- package/lib/runtime/components/react/dist/mpx-web-view.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +1 -1
- package/lib/runtime/components/react/dist/parser.d.ts +40 -0
- package/lib/runtime/components/react/dist/parser.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/useAnimationHooks.d.ts +33 -0
- package/lib/runtime/components/react/dist/useAnimationHooks.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/useNodesRef.d.ts +12 -0
- package/lib/runtime/components/react/dist/useNodesRef.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/utils.d.ts +123 -0
- package/lib/runtime/components/react/dist/utils.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/utils.jsx +16 -6
- package/lib/runtime/components/react/mpx-camera.tsx +275 -0
- package/lib/runtime/components/react/mpx-image.tsx +89 -42
- package/lib/runtime/components/react/mpx-input.tsx +50 -18
- package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +69 -49
- package/lib/runtime/components/react/mpx-nav.tsx +155 -0
- package/lib/runtime/components/react/mpx-picker-view/index.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +26 -21
- package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItem.tsx +8 -12
- package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItemLite.tsx +55 -0
- package/lib/runtime/components/react/mpx-portal/index.tsx +8 -2
- package/lib/runtime/components/react/mpx-progress.tsx +26 -24
- package/lib/runtime/components/react/mpx-scroll-view.tsx +6 -17
- package/lib/runtime/components/react/mpx-slider.tsx +444 -0
- package/lib/runtime/components/react/mpx-swiper.tsx +9 -5
- package/lib/runtime/components/react/mpx-text.tsx +38 -5
- package/lib/runtime/components/react/mpx-view.tsx +8 -11
- package/lib/runtime/components/react/mpx-web-view.tsx +1 -1
- package/lib/runtime/components/react/types/common.d.ts +19 -0
- package/lib/runtime/components/react/utils.tsx +15 -6
- package/lib/runtime/components/web/mpx-input.vue +1 -1
- package/lib/runtime/components/web/mpx-scroll-view.vue +7 -1
- package/lib/runtime/components/web/mpx-video.vue +12 -1
- package/lib/runtime/optionProcessor.js +3 -1
- package/lib/runtime/optionProcessorReact.js +4 -2
- package/lib/runtime/stringify.wxs +2 -2
- package/lib/script-setup-compiler/index.js +2 -2
- package/lib/style-compiler/index.js +3 -2
- package/lib/style-compiler/load-postcss-config.js +1 -1
- package/lib/style-compiler/plugins/trans-special.js +10 -2
- package/lib/style-compiler/strip-conditional-loader.js +178 -15
- package/lib/template-compiler/bind-this.js +2 -2
- package/lib/template-compiler/compiler.js +277 -77
- package/lib/template-compiler/gen-node-react.js +18 -6
- package/lib/template-compiler/index.js +12 -10
- package/lib/template-compiler/parse-exps.js +1 -1
- package/lib/utils/chain-assign.js +47 -0
- package/lib/utils/check-core-version-match.js +75 -15
- package/lib/utils/const.js +2 -1
- package/lib/utils/dom-tag-config.js +6 -6
- package/lib/utils/env.js +6 -1
- package/lib/utils/get-build-tag-component.js +35 -0
- package/lib/utils/pre-process-json.js +5 -0
- package/lib/web/index.js +2 -0
- package/lib/web/processJSON.js +44 -16
- package/lib/web/processScript.js +1 -1
- package/lib/web/processTemplate.js +6 -4
- package/lib/web/script-helper.js +19 -9
- package/lib/wxs/pre-loader.js +6 -6
- package/lib/wxss/loader.js +1 -9
- package/package.json +17 -5
- package/LICENSE +0 -433
- package/lib/dependencies/ImportDependencyTemplate.js +0 -50
|
@@ -1,92 +1,103 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable space-before-function-paren */
|
|
2
|
+
import React, { useContext, useEffect, useRef } from 'react';
|
|
2
3
|
import { Keyboard, View } from 'react-native';
|
|
3
|
-
import Animated, { useSharedValue, useAnimatedStyle, withTiming, Easing } from 'react-native-reanimated';
|
|
4
|
+
import Animated, { useSharedValue, useAnimatedStyle, withTiming, Easing, cancelAnimation } from 'react-native-reanimated';
|
|
4
5
|
import { KeyboardAvoidContext } from './context';
|
|
5
|
-
import { isIOS } from './utils';
|
|
6
|
+
import { isAndroid, isIOS } from './utils';
|
|
6
7
|
const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
|
|
7
8
|
const duration = isIOS ? 250 : 300;
|
|
8
9
|
const easing = isIOS ? Easing.inOut(Easing.ease) : Easing.out(Easing.quad);
|
|
9
10
|
const offset = useSharedValue(0);
|
|
10
11
|
const basic = useSharedValue('auto');
|
|
11
12
|
const keyboardAvoid = useContext(KeyboardAvoidContext);
|
|
13
|
+
// fix: 某些特殊机型下隐藏键盘可能会先触发一次 keyboardWillShow,
|
|
14
|
+
// 比如机型 iPhone 11 Pro,可能会导致显隐动画冲突
|
|
15
|
+
// 因此增加状态标记 + cancelAnimation 来优化
|
|
16
|
+
const isShow = useRef(false);
|
|
12
17
|
const animatedStyle = useAnimatedStyle(() => ({
|
|
13
|
-
|
|
18
|
+
// translate/position top可能会导致底部渲染区域缺失
|
|
19
|
+
marginTop: -offset.value,
|
|
14
20
|
flexBasis: basic.value
|
|
15
21
|
}));
|
|
16
22
|
const resetKeyboard = () => {
|
|
23
|
+
if (!isShow.current) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
isShow.current = false;
|
|
17
27
|
if (keyboardAvoid?.current) {
|
|
28
|
+
const inputRef = keyboardAvoid.current.ref?.current;
|
|
29
|
+
if (inputRef && inputRef.isFocused()) {
|
|
30
|
+
// 修复 Android 点击键盘收起按钮时当前 input 没触发失焦的问题
|
|
31
|
+
inputRef.blur();
|
|
32
|
+
}
|
|
18
33
|
keyboardAvoid.current = null;
|
|
19
34
|
}
|
|
35
|
+
cancelAnimation(offset);
|
|
20
36
|
offset.value = withTiming(0, { duration, easing });
|
|
21
37
|
basic.value = 'auto';
|
|
22
38
|
};
|
|
23
39
|
const onTouchEnd = ({ nativeEvent }) => {
|
|
24
40
|
if (nativeEvent.origin !== 'input') {
|
|
41
|
+
if (keyboardAvoid?.current?.holdKeyboard) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
25
44
|
Keyboard.isVisible() && Keyboard.dismiss();
|
|
26
45
|
}
|
|
27
46
|
};
|
|
28
47
|
useEffect(() => {
|
|
29
48
|
let subscriptions = [];
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
49
|
+
function keybaordAvoding(evt) {
|
|
50
|
+
if (!keyboardAvoid?.current || isShow.current) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
isShow.current = true;
|
|
54
|
+
const { endCoordinates } = evt;
|
|
55
|
+
const { ref, cursorSpacing = 0, adjustPosition, onKeyboardShow } = keyboardAvoid.current;
|
|
56
|
+
keyboardAvoid.current.keyboardHeight = endCoordinates.height;
|
|
57
|
+
onKeyboardShow?.();
|
|
58
|
+
if (adjustPosition) {
|
|
59
|
+
// 默认沿用旧版本逻辑,在 android 原生关闭键盘避让的情况下应该将该配置设置为 false,走 mpx 的键盘避让逻辑,否则bundle内的所有input都会无法避让键盘
|
|
60
|
+
const enableNativeKeyboardAvoiding = mpxGlobal?.__mpx?.config?.rnConfig?.enableNativeKeyboardAvoiding ?? true;
|
|
61
|
+
const callback = () => {
|
|
62
|
+
ref?.current?.measure((x, y, width, height, pageX, pageY) => {
|
|
63
|
+
function calculateOffset() {
|
|
64
|
+
// enableNativeKeyboardAvoding 默认开启
|
|
65
|
+
if (enableNativeKeyboardAvoiding && isAndroid) {
|
|
66
|
+
const aboveOffset = pageY + height - endCoordinates.screenY;
|
|
67
|
+
const belowOffset = endCoordinates.height - aboveOffset;
|
|
68
|
+
const aboveValue = -aboveOffset >= cursorSpacing ? 0 : aboveOffset + cursorSpacing;
|
|
69
|
+
const belowValue = Math.min(belowOffset, cursorSpacing);
|
|
70
|
+
return aboveOffset > 0 ? belowValue : aboveValue;
|
|
71
|
+
}
|
|
39
72
|
const aboveOffset = offset.value + pageY + height - endCoordinates.screenY;
|
|
40
73
|
const aboveValue = -aboveOffset >= cursorSpacing ? 0 : aboveOffset + cursorSpacing;
|
|
41
74
|
const belowValue = Math.min(endCoordinates.height, aboveOffset + cursorSpacing);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
basic.value = '99.99%';
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
}),
|
|
52
|
-
Keyboard.addListener('keyboardWillHide', resetKeyboard)
|
|
53
|
-
];
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
subscriptions = [
|
|
57
|
-
Keyboard.addListener('keyboardDidShow', (evt) => {
|
|
58
|
-
if (!keyboardAvoid?.current)
|
|
59
|
-
return;
|
|
60
|
-
const { endCoordinates } = evt;
|
|
61
|
-
const { ref, cursorSpacing = 0 } = keyboardAvoid.current;
|
|
62
|
-
ref?.current?.measure((x, y, width, height, pageX, pageY) => {
|
|
63
|
-
const aboveOffset = pageY + height - endCoordinates.screenY;
|
|
64
|
-
const belowOffset = endCoordinates.height - aboveOffset;
|
|
65
|
-
const aboveValue = -aboveOffset >= cursorSpacing ? 0 : aboveOffset + cursorSpacing;
|
|
66
|
-
const belowValue = Math.min(belowOffset, cursorSpacing);
|
|
67
|
-
const value = aboveOffset > 0 ? belowValue : aboveValue;
|
|
68
|
-
offset.value = withTiming(value, { duration, easing }, (finished) => {
|
|
75
|
+
return aboveOffset > 0 ? belowValue : aboveValue;
|
|
76
|
+
}
|
|
77
|
+
cancelAnimation(offset);
|
|
78
|
+
offset.value = withTiming(calculateOffset(), { duration, easing }, finished => {
|
|
69
79
|
if (finished) {
|
|
70
80
|
// Set flexBasic after animation to trigger re-layout and reset layout information
|
|
71
81
|
basic.value = '99.99%';
|
|
72
82
|
}
|
|
73
83
|
});
|
|
74
84
|
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
85
|
+
};
|
|
86
|
+
(isIOS ? () => setTimeout(callback) : callback)();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (isIOS) {
|
|
90
|
+
subscriptions = [Keyboard.addListener('keyboardWillShow', keybaordAvoding), Keyboard.addListener('keyboardWillHide', resetKeyboard)];
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
subscriptions = [Keyboard.addListener('keyboardDidShow', keybaordAvoding), Keyboard.addListener('keyboardDidHide', resetKeyboard)];
|
|
78
94
|
}
|
|
79
95
|
return () => {
|
|
80
96
|
subscriptions.forEach(subscription => subscription.remove());
|
|
81
97
|
};
|
|
82
98
|
}, [keyboardAvoid]);
|
|
83
|
-
return (<View style={style} onTouchEnd={onTouchEnd}>
|
|
84
|
-
<Animated.View style={[
|
|
85
|
-
contentContainerStyle,
|
|
86
|
-
animatedStyle
|
|
87
|
-
]}>
|
|
88
|
-
{children}
|
|
89
|
-
</Animated.View>
|
|
99
|
+
return (<View style={style} onTouchEnd={onTouchEnd} onTouchMove={onTouchEnd}>
|
|
100
|
+
<Animated.View style={[contentContainerStyle, animatedStyle]}>{children}</Animated.View>
|
|
90
101
|
</View>);
|
|
91
102
|
};
|
|
92
103
|
KeyboardAvoidingView.displayName = 'MpxKeyboardAvoidingView';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ✘ for
|
|
3
|
+
*/
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
import { View, ViewStyle, NativeSyntheticEvent } from 'react-native';
|
|
6
|
+
import { HandlerRef } from './useNodesRef';
|
|
7
|
+
export interface LabelProps {
|
|
8
|
+
for?: string;
|
|
9
|
+
style?: ViewStyle & Record<string, any>;
|
|
10
|
+
'enable-offset'?: boolean;
|
|
11
|
+
'enable-var'?: boolean;
|
|
12
|
+
'external-var-context'?: Record<string, any>;
|
|
13
|
+
'parent-font-size'?: number;
|
|
14
|
+
'parent-width'?: number;
|
|
15
|
+
'parent-height'?: number;
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
bindtap?: (evt: NativeSyntheticEvent<TouchEvent> | unknown) => void;
|
|
18
|
+
}
|
|
19
|
+
declare const Label: import("react").ForwardRefExoticComponent<LabelProps & import("react").RefAttributes<HandlerRef<View, LabelProps>>>;
|
|
20
|
+
export default Label;
|
|
21
|
+
//# sourceMappingURL=mpx-label.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mpx-label.d.ts","sourceRoot":"","sources":["../mpx-label.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAA2B,SAAS,EAA8B,MAAM,OAAO,CAAA;AACtF,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAGpE,OAAoB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAKvD,MAAM,WAAW,UAAU;IACzB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACvC,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,sBAAsB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC5C,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,EAAE,SAAS,CAAA;IACnB,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,oBAAoB,CAAC,UAAU,CAAC,GAAG,OAAO,KAAK,IAAI,CAAA;CACpE;AAED,QAAA,MAAM,KAAK,qHA0FV,CAAA;AAID,eAAe,KAAK,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ✘ scale-area
|
|
3
|
+
*/
|
|
4
|
+
import { View } from 'react-native';
|
|
5
|
+
import { ReactNode } from 'react';
|
|
6
|
+
import { HandlerRef } from './useNodesRef';
|
|
7
|
+
interface MovableAreaProps {
|
|
8
|
+
style?: Record<string, any>;
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
width?: number;
|
|
11
|
+
height?: number;
|
|
12
|
+
'enable-offset'?: boolean;
|
|
13
|
+
'enable-var'?: boolean;
|
|
14
|
+
'external-var-context'?: Record<string, any>;
|
|
15
|
+
'parent-font-size'?: number;
|
|
16
|
+
'parent-width'?: number;
|
|
17
|
+
'parent-height'?: number;
|
|
18
|
+
}
|
|
19
|
+
declare const _MovableArea: import("react").ForwardRefExoticComponent<MovableAreaProps & import("react").RefAttributes<HandlerRef<View, MovableAreaProps>>>;
|
|
20
|
+
export default _MovableArea;
|
|
21
|
+
//# sourceMappingURL=mpx-movable-area.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mpx-movable-area.d.ts","sourceRoot":"","sources":["../mpx-movable-area.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAmB,SAAS,EAAkC,MAAM,OAAO,CAAA;AAClF,OAAoB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAMvD,UAAU,gBAAgB;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC3B,QAAQ,EAAE,SAAS,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,sBAAsB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC5C,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AAED,QAAA,MAAM,YAAY,iIAsDhB,CAAA;AAIF,eAAe,YAAY,CAAA"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ✔ direction
|
|
3
|
+
* ✔ inertia
|
|
4
|
+
* ✔ out-of-bounds
|
|
5
|
+
* ✔ x
|
|
6
|
+
* ✔ y
|
|
7
|
+
* ✔ damping
|
|
8
|
+
* ✔ friction
|
|
9
|
+
* ✔ disabled
|
|
10
|
+
* ✘ scale
|
|
11
|
+
* ✘ scale-min
|
|
12
|
+
* ✘ scale-max
|
|
13
|
+
* ✘ scale-value
|
|
14
|
+
* ✔ animation
|
|
15
|
+
* ✔ bindchange
|
|
16
|
+
* ✘ bindscale
|
|
17
|
+
* ✔ htouchmove
|
|
18
|
+
* ✔ vtouchmove
|
|
19
|
+
*/
|
|
20
|
+
import { ReactNode } from 'react';
|
|
21
|
+
import { View, LayoutChangeEvent } from 'react-native';
|
|
22
|
+
import { HandlerRef } from './useNodesRef';
|
|
23
|
+
import { GestureHandler } from './utils';
|
|
24
|
+
import { GestureTouchEvent } from 'react-native-gesture-handler';
|
|
25
|
+
interface MovableViewProps {
|
|
26
|
+
children: ReactNode;
|
|
27
|
+
style?: Record<string, any>;
|
|
28
|
+
direction: 'all' | 'vertical' | 'horizontal' | 'none';
|
|
29
|
+
x?: number;
|
|
30
|
+
y?: number;
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
animation?: boolean;
|
|
33
|
+
damping?: number;
|
|
34
|
+
friction?: number;
|
|
35
|
+
id?: string;
|
|
36
|
+
changeThrottleTime?: number;
|
|
37
|
+
bindchange?: (event: unknown) => void;
|
|
38
|
+
bindtouchstart?: (event: GestureTouchEvent) => void;
|
|
39
|
+
catchtouchstart?: (event: GestureTouchEvent) => void;
|
|
40
|
+
bindtouchmove?: (event: GestureTouchEvent) => void;
|
|
41
|
+
catchtouchmove?: (event: GestureTouchEvent) => void;
|
|
42
|
+
catchtouchend?: (event: GestureTouchEvent) => void;
|
|
43
|
+
bindtouchend?: (event: GestureTouchEvent) => void;
|
|
44
|
+
bindhtouchmove?: (event: GestureTouchEvent) => void;
|
|
45
|
+
bindvtouchmove?: (event: GestureTouchEvent) => void;
|
|
46
|
+
catchhtouchmove?: (event: GestureTouchEvent) => void;
|
|
47
|
+
catchvtouchmove?: (event: GestureTouchEvent) => void;
|
|
48
|
+
bindlongpress?: (event: GestureTouchEvent) => void;
|
|
49
|
+
catchlongpress?: (event: GestureTouchEvent) => void;
|
|
50
|
+
bindtap?: (event: GestureTouchEvent) => void;
|
|
51
|
+
catchtap?: (event: GestureTouchEvent) => void;
|
|
52
|
+
onLayout?: (event: LayoutChangeEvent) => void;
|
|
53
|
+
'out-of-bounds'?: boolean;
|
|
54
|
+
'wait-for'?: Array<GestureHandler>;
|
|
55
|
+
'simultaneous-handlers'?: Array<GestureHandler>;
|
|
56
|
+
inertia?: boolean;
|
|
57
|
+
'enable-var'?: boolean;
|
|
58
|
+
'external-var-context'?: Record<string, any>;
|
|
59
|
+
'parent-font-size'?: number;
|
|
60
|
+
'parent-width'?: number;
|
|
61
|
+
'parent-height'?: number;
|
|
62
|
+
'disable-event-passthrough'?: boolean;
|
|
63
|
+
}
|
|
64
|
+
declare const _MovableView: import("react").ForwardRefExoticComponent<MovableViewProps & import("react").RefAttributes<HandlerRef<View, MovableViewProps>>>;
|
|
65
|
+
export default _MovableView;
|
|
66
|
+
//# sourceMappingURL=mpx-movable-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mpx-movable-view.d.ts","sourceRoot":"","sources":["../mpx-movable-view.tsx"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare function useInnerHeaderHeight(pageConfig: PageConfig): number;
|
|
3
|
+
export interface MpxNavProps {
|
|
4
|
+
pageConfig: PageConfig;
|
|
5
|
+
navigation: any;
|
|
6
|
+
}
|
|
7
|
+
declare const MpxNav: import("react").MemoExoticComponent<({ pageConfig, navigation }: MpxNavProps) => import("react").JSX.Element>;
|
|
8
|
+
export default MpxNav;
|
|
9
|
+
//# sourceMappingURL=mpx-nav.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mpx-nav.d.ts","sourceRoot":"","sources":["../mpx-nav.tsx"],"names":[],"mappings":";AA0BA,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,UAAU,UAS1D;AA6CD,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,UAAU,CAAA;IACtB,UAAU,EAAE,GAAG,CAAA;CAChB;AAKD,QAAA,MAAM,MAAM,mEAAqC,WAAW,iCA+D1D,CAAA;AAGF,eAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/* eslint-disable space-before-function-paren */
|
|
2
|
+
import { useState, useMemo, memo } from 'react';
|
|
3
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
4
|
+
import { StatusBar, processColor, TouchableWithoutFeedback, Image, View, StyleSheet, Text } from 'react-native';
|
|
5
|
+
function convertToHex(color) {
|
|
6
|
+
try {
|
|
7
|
+
const intColor = processColor(color);
|
|
8
|
+
if (intColor === null || intColor === undefined) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
// 将32位整数颜色值转换为RGBA
|
|
12
|
+
const r = (intColor >> 16) & 255;
|
|
13
|
+
const g = (intColor >> 8) & 255;
|
|
14
|
+
const b = intColor & 255;
|
|
15
|
+
// 转换为十六进制
|
|
16
|
+
const hexR = r.toString(16).padStart(2, '0');
|
|
17
|
+
const hexG = g.toString(16).padStart(2, '0');
|
|
18
|
+
const hexB = b.toString(16).padStart(2, '0');
|
|
19
|
+
return `#${hexR}${hexG}${hexB}`;
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const titleHeight = 44;
|
|
26
|
+
export function useInnerHeaderHeight(pageConfig) {
|
|
27
|
+
const safeArea = useSafeAreaInsets();
|
|
28
|
+
if (pageConfig.navigationStyle === 'custom') {
|
|
29
|
+
return 0;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
const safeAreaTop = safeArea?.top || 0;
|
|
33
|
+
const headerHeight = safeAreaTop + titleHeight;
|
|
34
|
+
return headerHeight;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const styles = StyleSheet.create({
|
|
38
|
+
header: {
|
|
39
|
+
elevation: 3
|
|
40
|
+
},
|
|
41
|
+
headerContent: {
|
|
42
|
+
flexDirection: 'row',
|
|
43
|
+
alignItems: 'center',
|
|
44
|
+
justifyContent: 'center'
|
|
45
|
+
},
|
|
46
|
+
backButton: {
|
|
47
|
+
position: 'absolute',
|
|
48
|
+
height: '100%',
|
|
49
|
+
width: 40,
|
|
50
|
+
left: 0,
|
|
51
|
+
top: 0,
|
|
52
|
+
alignItems: 'center',
|
|
53
|
+
justifyContent: 'center'
|
|
54
|
+
},
|
|
55
|
+
backButtonImage: {
|
|
56
|
+
width: 22,
|
|
57
|
+
height: 22
|
|
58
|
+
},
|
|
59
|
+
title: {
|
|
60
|
+
fontSize: 17,
|
|
61
|
+
fontWeight: 600,
|
|
62
|
+
width: '60%',
|
|
63
|
+
textAlign: 'center'
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
const NavColor = {
|
|
67
|
+
White: '#ffffff',
|
|
68
|
+
Black: '#000000'
|
|
69
|
+
};
|
|
70
|
+
// navigationBarTextStyle 只支持黑白 'white'/'black
|
|
71
|
+
const validBarTextStyle = (textStyle) => {
|
|
72
|
+
const textStyleColor = convertToHex(textStyle);
|
|
73
|
+
if (textStyle && textStyleColor && [NavColor.White, NavColor.Black].includes(textStyleColor)) {
|
|
74
|
+
return textStyleColor;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
return NavColor.White;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const BACK_ICON = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAABICAYAAACqT5alAAAA2UlEQVR4nO3bMQrCUBRE0Yla6AYEN2nnBrTL+izcitW3MRDkEUWSvPzJvfCqgMwhZbAppWhNbbIHzB1g9wATERFRVyvpkj1irlpJ5X326D7WHh1hbdFD2CLpLmmftm7kfsEe09aNHFiBrT+wAlt/YAW2/sAKbP2BFdj6Ayuwy+ufz6XPL893krZ//O6iu2n4LT8kndLWTRTo4EC7BDo40C6BDg60S6CDA+0S6OBAuwQ6uNWiD2nrJmoIfU7cNWkR2hbb1UfbY7uuWhGWiIg+a/iHuHmA3QPs3gu4JW9Gan+OJAAAAABJRU5ErkJggg==';
|
|
81
|
+
const MpxNav = memo(({ pageConfig, navigation }) => {
|
|
82
|
+
const [innerPageConfig, setPageConfig] = useState(pageConfig || {});
|
|
83
|
+
const safeAreaTop = useSafeAreaInsets()?.top || 0;
|
|
84
|
+
navigation.setPageConfig = (config) => {
|
|
85
|
+
setPageConfig(Object.assign({}, innerPageConfig, config));
|
|
86
|
+
};
|
|
87
|
+
const isCustom = innerPageConfig.navigationStyle === 'custom';
|
|
88
|
+
const navigationBarTextStyle = useMemo(() => validBarTextStyle(innerPageConfig.navigationBarTextStyle), [innerPageConfig.navigationBarTextStyle]);
|
|
89
|
+
// 状态栏的颜色
|
|
90
|
+
const statusBarElement = (<StatusBar translucent backgroundColor='transparent' barStyle={navigationBarTextStyle === NavColor.White ? 'light-content' : 'dark-content'}></StatusBar>);
|
|
91
|
+
if (isCustom)
|
|
92
|
+
return statusBarElement;
|
|
93
|
+
// 假设是栈导航,获取栈的长度
|
|
94
|
+
const stackLength = navigation.getState()?.routes?.length;
|
|
95
|
+
const onStackTopBack = mpxGlobal?.__mpx?.config?.rnConfig?.onStackTopBack;
|
|
96
|
+
const isHandleStackTopBack = typeof onStackTopBack === 'function';
|
|
97
|
+
// 回退按钮与图标
|
|
98
|
+
// prettier-ignore
|
|
99
|
+
const backElement = stackLength > 1 || isHandleStackTopBack
|
|
100
|
+
? (<TouchableWithoutFeedback onPress={() => {
|
|
101
|
+
if (stackLength <= 1 && isHandleStackTopBack) {
|
|
102
|
+
onStackTopBack();
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
navigation.goBack();
|
|
106
|
+
}}>
|
|
107
|
+
<View style={[styles.backButton]}>
|
|
108
|
+
<Image style={[styles.backButtonImage, { tintColor: navigationBarTextStyle }]} source={{ uri: BACK_ICON }}></Image>
|
|
109
|
+
</View>
|
|
110
|
+
</TouchableWithoutFeedback>)
|
|
111
|
+
: null;
|
|
112
|
+
return (<View style={[
|
|
113
|
+
styles.header,
|
|
114
|
+
{
|
|
115
|
+
paddingTop: safeAreaTop,
|
|
116
|
+
backgroundColor: innerPageConfig.navigationBarBackgroundColor || '#000000'
|
|
117
|
+
}
|
|
118
|
+
]}>
|
|
119
|
+
{statusBarElement}
|
|
120
|
+
{/* TODO: 确定 height 的有效性 */}
|
|
121
|
+
{/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}
|
|
122
|
+
{/* @ts-expect-error */}
|
|
123
|
+
<View style={styles.headerContent} height={titleHeight}>
|
|
124
|
+
{backElement}
|
|
125
|
+
<Text style={[styles.title, { color: navigationBarTextStyle }]} numberOfLines={1}>
|
|
126
|
+
{innerPageConfig.navigationBarTitleText?.trim() || ''}
|
|
127
|
+
</Text>
|
|
128
|
+
</View>
|
|
129
|
+
</View>);
|
|
130
|
+
});
|
|
131
|
+
MpxNav.displayName = 'MpxNav';
|
|
132
|
+
export default MpxNav;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { _ViewProps } from './mpx-view';
|
|
3
|
+
interface _NavigatorProps extends _ViewProps {
|
|
4
|
+
['open-type']: 'navigate' | 'redirect' | 'switchTab' | 'reLaunch' | 'navigateBack';
|
|
5
|
+
url: string;
|
|
6
|
+
delta: number;
|
|
7
|
+
}
|
|
8
|
+
declare const _Navigator: import("react").ForwardRefExoticComponent<_NavigatorProps & import("react").RefAttributes<any>>;
|
|
9
|
+
export default _Navigator;
|
|
10
|
+
//# sourceMappingURL=mpx-navigator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mpx-navigator.d.ts","sourceRoot":"","sources":["../mpx-navigator.tsx"],"names":[],"mappings":";AAYA,OAAgB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEhD,UAAU,eAAgB,SAAQ,UAAU;IAC1C,CAAC,WAAW,CAAC,EAAE,UAAU,GAAG,UAAU,GAAG,WAAW,GAAG,UAAU,GAAG,cAAc,CAAA;IAClF,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;CACd;AAED,QAAA,MAAM,UAAU,iGAkCd,CAAA;AAIF,eAAe,UAAU,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { DateProps } from './type';
|
|
4
|
+
import { HandlerRef } from '../useNodesRef';
|
|
5
|
+
declare const PickerDate: React.ForwardRefExoticComponent<Omit<DateProps, "ref"> & React.RefAttributes<HandlerRef<View, DateProps>>>;
|
|
6
|
+
export default PickerDate;
|
|
7
|
+
//# sourceMappingURL=date.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../mpx-picker/date.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6F,MAAM,OAAO,CAAA;AACjH,OAAO,EAAoB,IAAI,EAAE,MAAM,cAAc,CAAA;AAGrD,OAAO,EAAE,SAAS,EAAa,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AA8J3C,QAAA,MAAM,UAAU,4GA4Ed,CAAA;AAGF,eAAe,UAAU,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const wrapDate: (union?: string) => (num: number) => string;
|
|
2
|
+
export declare const START_YEAR = 1900;
|
|
3
|
+
export declare const END_YEAR = 2099;
|
|
4
|
+
export declare const years: string[];
|
|
5
|
+
export declare const months: string[];
|
|
6
|
+
export declare const daysInMonthLength: (year: number, month: number) => 30 | 28 | 29 | 31;
|
|
7
|
+
export declare const daysInMonth: (year: number, month: number) => string[];
|
|
8
|
+
//# sourceMappingURL=dateData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dateData.d.ts","sourceRoot":"","sources":["../../mpx-picker/dateData.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,4BAAyB,MAAM,WAAyC,CAAA;AAE7F,eAAO,MAAM,UAAU,OAAO,CAAA;AAC9B,eAAO,MAAM,QAAQ,OAAO,CAAA;AAE5B,eAAO,MAAM,KAAK,UAAsE,CAAA;AAExF,eAAO,MAAM,MAAM,UAAyE,CAAA;AAE5F,eAAO,MAAM,iBAAiB,SAAU,MAAM,SAAS,MAAM,sBAQ5D,CAAA;AAED,eAAO,MAAM,WAAW,SAAU,MAAM,SAAS,MAAM,aAEtD,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { HandlerRef } from '../useNodesRef';
|
|
4
|
+
import { PickerProps } from './type';
|
|
5
|
+
declare const Picker: React.ForwardRefExoticComponent<(Omit<import("./type").DateProps, "ref"> | Omit<import("./type").SelectorProps, "ref"> | Omit<import("./type").MultiSelectorProps, "ref"> | Omit<import("./type").TimeProps, "ref"> | Omit<import("./type").RegionProps, "ref">) & React.RefAttributes<HandlerRef<View, PickerProps>>>;
|
|
6
|
+
export default Picker;
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../mpx-picker/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmE,MAAM,OAAO,CAAA;AACvF,OAAO,EAA8C,IAAI,EAAE,MAAM,cAAc,CAAA;AAQ/E,OAAoB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAIxD,OAAO,EAAuC,WAAW,EAAE,MAAM,QAAQ,CAAA;AAmGzE,QAAA,MAAM,MAAM,wTAuKX,CAAA;AAGD,eAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { MultiSelectorProps } from './type';
|
|
4
|
+
import { HandlerRef } from '../useNodesRef';
|
|
5
|
+
declare const PickerMultiSelector: React.ForwardRefExoticComponent<Omit<MultiSelectorProps, "ref"> & React.RefAttributes<HandlerRef<View, MultiSelectorProps>>>;
|
|
6
|
+
export default PickerMultiSelector;
|
|
7
|
+
//# sourceMappingURL=multiSelector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multiSelector.d.ts","sourceRoot":"","sources":["../../mpx-picker/multiSelector.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyE,MAAM,OAAO,CAAA;AAC7F,OAAO,EAAoB,IAAI,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,EAAE,kBAAkB,EAAkB,MAAM,QAAQ,CAAA;AAG3D,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AA8B3C,QAAA,MAAM,mBAAmB,8HA8EvB,CAAA;AAGF,eAAe,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { RegionProps } from './type';
|
|
4
|
+
import { HandlerRef } from '../useNodesRef';
|
|
5
|
+
declare const PickerRegion: React.ForwardRefExoticComponent<Omit<RegionProps, "ref"> & React.RefAttributes<HandlerRef<View, RegionProps>>>;
|
|
6
|
+
export default PickerRegion;
|
|
7
|
+
//# sourceMappingURL=region.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"region.d.ts","sourceRoot":"","sources":["../../mpx-picker/region.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkF,MAAM,OAAO,CAAA;AACtG,OAAO,EAAoB,IAAI,EAAE,MAAM,cAAc,CAAA;AAGrD,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AAEpC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AA+J3C,QAAA,MAAM,YAAY,gHAsEhB,CAAA;AAGF,eAAe,YAAY,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regionData.d.ts","sourceRoot":"","sources":["../../mpx-picker/regionData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAElC,eAAO,MAAM,UAAU,EAAE,SAAS,EAk9LjC,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { SelectorProps } from './type';
|
|
4
|
+
import { HandlerRef } from '../useNodesRef';
|
|
5
|
+
declare const PickerSelector: React.ForwardRefExoticComponent<Omit<SelectorProps, "ref"> & React.RefAttributes<HandlerRef<View, SelectorProps>>>;
|
|
6
|
+
export default PickerSelector;
|
|
7
|
+
//# sourceMappingURL=selector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selector.d.ts","sourceRoot":"","sources":["../../mpx-picker/selector.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAA;AAChF,OAAO,EAAoB,IAAI,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,EAAE,aAAa,EAAkB,MAAM,QAAQ,CAAA;AAGtD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AA4B3C,QAAA,MAAM,cAAc,oHAqDlB,CAAA;AAGF,eAAe,cAAc,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { TimeProps } from './type';
|
|
4
|
+
import { HandlerRef } from '../useNodesRef';
|
|
5
|
+
declare const PickerTime: React.ForwardRefExoticComponent<Omit<TimeProps, "ref"> & React.RefAttributes<HandlerRef<View, TimeProps>>>;
|
|
6
|
+
export default PickerTime;
|
|
7
|
+
//# sourceMappingURL=time.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../mpx-picker/time.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuE,MAAM,OAAO,CAAA;AAC3F,OAAO,EAAoB,IAAI,EAAE,MAAM,cAAc,CAAA;AAErD,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAGlC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAkE3C,QAAA,MAAM,UAAU,4GA2Ed,CAAA;AAGF,eAAe,UAAU,CAAA"}
|