@mpxjs/webpack-plugin 2.10.15 → 2.10.16-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 +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 +37 -11
- 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 +44 -17
- 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
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { WebView } from 'react-native-webview';
|
|
3
|
+
import Bus from './Bus';
|
|
4
|
+
export declare const WEBVIEW_TARGET = "@@WEBVIEW_TARGET";
|
|
5
|
+
export declare const constructors: Record<string, any>;
|
|
6
|
+
export declare const ID: () => string;
|
|
7
|
+
export interface Instance {
|
|
8
|
+
postMessage: (...args: any[]) => void;
|
|
9
|
+
[WEBVIEW_TARGET]?: string;
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
}
|
|
12
|
+
export interface WebviewConstructor {
|
|
13
|
+
new (...args: any[]): Instance;
|
|
14
|
+
constructLocally?: (...args: unknown[]) => Instance;
|
|
15
|
+
}
|
|
16
|
+
export interface WebviewMessage {
|
|
17
|
+
type: 'set' | 'exec' | 'listen' | 'event' | 'construct';
|
|
18
|
+
payload: {
|
|
19
|
+
target?: string | {
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
};
|
|
22
|
+
key?: string;
|
|
23
|
+
value?: any;
|
|
24
|
+
method?: string;
|
|
25
|
+
args?: any[];
|
|
26
|
+
types?: string[];
|
|
27
|
+
type?: string;
|
|
28
|
+
constructor?: string | Function;
|
|
29
|
+
id?: string;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export interface CanvasInstance {
|
|
33
|
+
webview: WebView | null;
|
|
34
|
+
bus: Bus | null;
|
|
35
|
+
context2D: CanvasRenderingContext2D;
|
|
36
|
+
getContext: (contextType: string) => CanvasRenderingContext2D | null;
|
|
37
|
+
createImage: (width?: number, height?: number) => any;
|
|
38
|
+
postMessage: (message: WebviewMessage) => Promise<any>;
|
|
39
|
+
listeners: Array<(payload: any) => void>;
|
|
40
|
+
addMessageListener: (listener: (payload: any) => void) => () => void;
|
|
41
|
+
removeMessageListener: (listener: (payload: any) => void) => void;
|
|
42
|
+
createImageData: (dataArray: number[], width?: number, height?: number) => any;
|
|
43
|
+
}
|
|
44
|
+
export declare const registerWebviewTarget: (instance: Instance, targetName: string) => void;
|
|
45
|
+
export declare const registerWebviewProperties: (instance: Instance, properties: Record<string, any>) => void;
|
|
46
|
+
export declare const registerWebviewMethods: (instance: Instance, methods: string[]) => void;
|
|
47
|
+
export declare const registerWebviewConstructor: (constructor: WebviewConstructor, constructorName: string) => void;
|
|
48
|
+
export declare const useWebviewBinding: ({ targetName, properties, methods }: {
|
|
49
|
+
targetName: string;
|
|
50
|
+
properties?: Record<string, any> | undefined;
|
|
51
|
+
methods?: string[] | undefined;
|
|
52
|
+
}) => import("react").MutableRefObject<{}>;
|
|
53
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../mpx-canvas/utils.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAC9C,OAAO,GAAG,MAAM,OAAO,CAAA;AAEvB,eAAO,MAAM,cAAc,qBAAqB,CAAA;AAEhD,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,CAAA;AAEnD,eAAO,MAAM,EAAE,cAA4C,CAAA;AAS3D,MAAM,WAAW,QAAQ;IACvB,WAAW,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;IACtC,CAAC,cAAc,CAAC,CAAC,EAAE,MAAM,CAAC;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,QAAQ,CAAC;IAC/B,gBAAgB,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,QAAQ,CAAC;CACrD;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,WAAW,CAAA;IACvD,OAAO,EAAE;QACP,MAAM,CAAC,EAAE,MAAM,GAAG;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;SAAE,CAAA;QACxC,GAAG,CAAC,EAAE,MAAM,CAAA;QACZ,KAAK,CAAC,EAAE,GAAG,CAAA;QACX,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;QACZ,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;QAChB,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,WAAW,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAA;QAC/B,EAAE,CAAC,EAAE,MAAM,CAAA;KACZ,CAAA;CACF;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACxB,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC;IAChB,SAAS,EAAE,wBAAwB,CAAC;IACpC,UAAU,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,wBAAwB,GAAG,IAAI,CAAC;IACrE,WAAW,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,GAAG,CAAC;IACtD,WAAW,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACvD,SAAS,EAAE,KAAK,CAAC,CAAC,OAAO,EAAE,GAAG,KAAK,IAAI,CAAC,CAAC;IACzC,kBAAkB,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;IACrE,qBAAqB,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,IAAI,KAAK,IAAI,CAAC;IAClE,eAAe,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,GAAG,CAAC;CAChF;AAED,eAAO,MAAM,qBAAqB,aAAc,QAAQ,cAAc,MAAM,KAAG,IAE9E,CAAA;AAED,eAAO,MAAM,yBAAyB,aAAc,QAAQ,cAAc,OAAO,MAAM,EAAE,GAAG,CAAC,KAAG,IA2B/F,CAAA;AAED,eAAO,MAAM,sBAAsB,aAAc,QAAQ,WAAW,MAAM,EAAE,KAAG,IAa9E,CAAA;AAED,eAAO,MAAM,0BAA0B,gBAAiB,kBAAkB,mBAAmB,MAAM,KAAG,IAwBrG,CAAA;AACD,eAAO,MAAM,iBAAiB;gBAKhB,MAAM;;;0CAenB,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ✔ bindchange
|
|
3
|
+
*/
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
import { View, NativeSyntheticEvent, ViewStyle } from 'react-native';
|
|
6
|
+
import { HandlerRef } from './useNodesRef';
|
|
7
|
+
export interface CheckboxGroupProps {
|
|
8
|
+
name: 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
|
+
bindchange?: (evt: NativeSyntheticEvent<TouchEvent> | unknown) => void;
|
|
18
|
+
}
|
|
19
|
+
declare const CheckboxGroup: import("react").ForwardRefExoticComponent<CheckboxGroupProps & import("react").RefAttributes<HandlerRef<View, CheckboxGroupProps>>>;
|
|
20
|
+
export default CheckboxGroup;
|
|
21
|
+
//# sourceMappingURL=mpx-checkbox-group.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mpx-checkbox-group.d.ts","sourceRoot":"","sources":["../mpx-checkbox-group.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAIL,SAAS,EAKV,MAAM,OAAO,CAAA;AACd,OAAO,EACL,IAAI,EACJ,oBAAoB,EACpB,SAAS,EACV,MAAM,cAAc,CAAA;AAIrB,OAAoB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAIvD,MAAM,WAAW,kBAAkB;IACjC,IAAI,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,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,oBAAoB,CAAC,UAAU,CAAC,GAAG,OAAO,KAAK,IAAI,CAAA;CACvE;AAED,QAAA,MAAM,aAAa,qIAkJjB,CAAA;AAIF,eAAe,aAAa,CAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ✔ value
|
|
3
|
+
* ✔ disabled
|
|
4
|
+
* ✔ checked
|
|
5
|
+
* ✔ color
|
|
6
|
+
*/
|
|
7
|
+
import { ReactNode } from 'react';
|
|
8
|
+
import { View, ViewStyle, NativeSyntheticEvent } from 'react-native';
|
|
9
|
+
import { HandlerRef } from './useNodesRef';
|
|
10
|
+
interface Selection {
|
|
11
|
+
value?: string;
|
|
12
|
+
checked?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface CheckboxProps extends Selection {
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
color?: string;
|
|
17
|
+
style?: ViewStyle & Record<string, any>;
|
|
18
|
+
groupValue?: Array<string>;
|
|
19
|
+
'enable-offset'?: boolean;
|
|
20
|
+
'enable-var'?: boolean;
|
|
21
|
+
'external-var-context'?: Record<string, any>;
|
|
22
|
+
'parent-font-size'?: number;
|
|
23
|
+
'parent-width'?: number;
|
|
24
|
+
'parent-height'?: number;
|
|
25
|
+
children?: ReactNode;
|
|
26
|
+
bindtap?: (evt: NativeSyntheticEvent<TouchEvent> | unknown) => void;
|
|
27
|
+
_onChange?: (evt: NativeSyntheticEvent<TouchEvent> | unknown, { checked }: {
|
|
28
|
+
checked: boolean;
|
|
29
|
+
}) => void;
|
|
30
|
+
}
|
|
31
|
+
declare const Checkbox: import("react").ForwardRefExoticComponent<CheckboxProps & import("react").RefAttributes<HandlerRef<View, CheckboxProps>>>;
|
|
32
|
+
export default Checkbox;
|
|
33
|
+
//# sourceMappingURL=mpx-checkbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mpx-checkbox.d.ts","sourceRoot":"","sources":["../mpx-checkbox.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAML,SAAS,EAKV,MAAM,OAAO,CAAA;AACd,OAAO,EACL,IAAI,EAEJ,SAAS,EACT,oBAAoB,EACrB,MAAM,cAAc,CAAA;AAGrB,OAAoB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAMvD,UAAU,SAAS;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,WAAW,aAAc,SAAQ,SAAS;IAC9C,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACvC,UAAU,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IAC1B,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,CAAC,EAAE,SAAS,CAAA;IACpB,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,oBAAoB,CAAC,UAAU,CAAC,GAAG,OAAO,KAAK,IAAI,CAAA;IACnE,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,oBAAoB,CAAC,UAAU,CAAC,GAAG,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAA;CACzG;AA6BD,QAAA,MAAM,QAAQ,2HA8Jb,CAAA;AAID,eAAe,QAAQ,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ✘ report-submit
|
|
3
|
+
* ✘ report-submit-timeout
|
|
4
|
+
* ✔ bindsubmit
|
|
5
|
+
* ✔ bindreset
|
|
6
|
+
*/
|
|
7
|
+
import { View } from 'react-native';
|
|
8
|
+
import { ReactNode } from 'react';
|
|
9
|
+
import { HandlerRef } from './useNodesRef';
|
|
10
|
+
interface FormProps {
|
|
11
|
+
style?: Record<string, any>;
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
'enable-offset'?: boolean;
|
|
14
|
+
'enable-var'?: boolean;
|
|
15
|
+
'external-var-context'?: Record<string, any>;
|
|
16
|
+
'parent-font-size'?: number;
|
|
17
|
+
'parent-width'?: number;
|
|
18
|
+
'parent-height'?: number;
|
|
19
|
+
bindsubmit?: (evt: {
|
|
20
|
+
detail: {
|
|
21
|
+
value: any;
|
|
22
|
+
};
|
|
23
|
+
}) => void;
|
|
24
|
+
bindreset?: () => void;
|
|
25
|
+
}
|
|
26
|
+
declare const _Form: import("react").ForwardRefExoticComponent<FormProps & import("react").RefAttributes<HandlerRef<View, FormProps>>>;
|
|
27
|
+
export default _Form;
|
|
28
|
+
//# sourceMappingURL=mpx-form.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mpx-form.d.ts","sourceRoot":"","sources":["../mpx-form.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAA2B,SAAS,EAA0B,MAAM,OAAO,CAAA;AAClF,OAAoB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAIvD,UAAU,SAAS;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC3B,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,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,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE;QACjB,MAAM,EAAE;YACN,KAAK,EAAE,GAAG,CAAA;SACX,CAAA;KACF,KAAK,IAAI,CAAA;IACV,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;CACvB;AAED,QAAA,MAAM,KAAK,mHA+FT,CAAA;AAIF,eAAe,KAAK,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Text, TextStyle } from 'react-native';
|
|
3
|
+
import { HandlerRef } from '../useNodesRef';
|
|
4
|
+
export type IconType = 'success' | 'success_no_circle' | 'info' | 'warn' | 'waiting' | 'cancel' | 'download' | 'search' | 'clear';
|
|
5
|
+
export interface IconProps {
|
|
6
|
+
type: IconType;
|
|
7
|
+
size?: number;
|
|
8
|
+
color?: string;
|
|
9
|
+
style?: TextStyle & 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
|
+
}
|
|
17
|
+
declare const Icon: import("react").ForwardRefExoticComponent<IconProps & import("react").RefAttributes<HandlerRef<Text, IconProps>>>;
|
|
18
|
+
export default Icon;
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../mpx-icon/index.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,IAAI,EAAE,SAAS,EAAS,MAAM,cAAc,CAAA;AAErD,OAAoB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAaxD,MAAM,MAAM,QAAQ,GAChB,SAAS,GACT,mBAAmB,GACnB,MAAM,GACN,MAAM,GACN,SAAS,GACT,QAAQ,GACR,UAAU,GACV,QAAQ,GACR,OAAO,CAAA;AAEX,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,QAAQ,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,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;CACzB;AAcD,QAAA,MAAM,IAAI,mHA0DT,CAAA;AAID,eAAe,IAAI,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Image as RNImage, ImageStyle, NativeSyntheticEvent, ImageErrorEventData, ImageLoadEventData } from 'react-native';
|
|
3
|
+
import { HandlerRef } from './useNodesRef';
|
|
4
|
+
export type Mode = 'scaleToFill' | 'aspectFit' | 'aspectFill' | 'widthFix' | 'heightFix' | 'top' | 'bottom' | 'center' | 'left' | 'right' | 'top left' | 'top right' | 'bottom left' | 'bottom right';
|
|
5
|
+
export interface ImageProps {
|
|
6
|
+
src?: string;
|
|
7
|
+
mode?: Mode;
|
|
8
|
+
svg?: boolean;
|
|
9
|
+
style?: ImageStyle & 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
|
+
'enable-fast-image'?: boolean;
|
|
17
|
+
bindload?: (evt: NativeSyntheticEvent<ImageLoadEventData> | unknown) => void;
|
|
18
|
+
binderror?: (evt: NativeSyntheticEvent<ImageErrorEventData> | unknown) => void;
|
|
19
|
+
}
|
|
20
|
+
declare const Image: import("react").ForwardRefExoticComponent<ImageProps & import("react").RefAttributes<HandlerRef<RNImage, ImageProps>>>;
|
|
21
|
+
export default Image;
|
|
22
|
+
//# sourceMappingURL=mpx-image.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mpx-image.d.ts","sourceRoot":"","sources":["../mpx-image.tsx"],"names":[],"mappings":";AAaA,OAAO,EACL,KAAK,IAAI,OAAO,EAEhB,UAAU,EAEV,oBAAoB,EACpB,mBAAmB,EAGnB,kBAAkB,EACnB,MAAM,cAAc,CAAA;AAIrB,OAAoB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAIvD,MAAM,MAAM,IAAI,GACZ,aAAa,GACb,WAAW,GACX,YAAY,GACZ,UAAU,GACV,WAAW,GACX,KAAK,GACL,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,OAAO,GACP,UAAU,GACV,WAAW,GACX,aAAa,GACb,cAAc,CAAA;AAElB,MAAM,WAAW,UAAU;IACzB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,KAAK,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACxC,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,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,oBAAoB,CAAC,kBAAkB,CAAC,GAAG,OAAO,KAAK,IAAI,CAAA;IAC5E,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,oBAAoB,CAAC,mBAAmB,CAAC,GAAG,OAAO,KAAK,IAAI,CAAA;CAC/E;AAmED,QAAA,MAAM,KAAK,wHA8XT,CAAA;AAIF,eAAe,KAAK,CAAA"}
|
|
@@ -40,7 +40,16 @@ const ModeMap = new Map([
|
|
|
40
40
|
...cropMode.map(mode => [mode, 'stretch'])
|
|
41
41
|
]);
|
|
42
42
|
const isNumber = (value) => typeof value === 'number';
|
|
43
|
-
const relativeCenteredSize = (viewSize, imageSize) =>
|
|
43
|
+
const relativeCenteredSize = (viewSize, imageSize) => {
|
|
44
|
+
return (viewSize - imageSize) / 2;
|
|
45
|
+
};
|
|
46
|
+
// 获取能完全显示图片的缩放比例:长宽方向的缩放比例最小值即为能完全展示的比例
|
|
47
|
+
function getFitScale(width1, height1, width2, height2) {
|
|
48
|
+
return Math.min(width2 / width1, height2 / height1);
|
|
49
|
+
}
|
|
50
|
+
function getFillScale(width1, height1, width2, height2) {
|
|
51
|
+
return Math.max(width2 / width1, height2 / height1);
|
|
52
|
+
}
|
|
44
53
|
function noMeetCalcRule(isSvg, mode, viewWidth, viewHeight, ratio) {
|
|
45
54
|
const isMeetSize = viewWidth && viewHeight && ratio;
|
|
46
55
|
if (isSvg && !isMeetSize)
|
|
@@ -49,6 +58,16 @@ function noMeetCalcRule(isSvg, mode, viewWidth, viewHeight, ratio) {
|
|
|
49
58
|
return true;
|
|
50
59
|
return false;
|
|
51
60
|
}
|
|
61
|
+
const getFixedWidth = (viewWidth, viewHeight, ratio) => {
|
|
62
|
+
if (!ratio)
|
|
63
|
+
return viewWidth;
|
|
64
|
+
const fixed = viewHeight / ratio;
|
|
65
|
+
return !fixed ? viewWidth : fixed;
|
|
66
|
+
};
|
|
67
|
+
const getFixedHeight = (viewWidth, viewHeight, ratio) => {
|
|
68
|
+
const fixed = viewWidth * ratio;
|
|
69
|
+
return !fixed ? viewHeight : fixed;
|
|
70
|
+
};
|
|
52
71
|
const Image = forwardRef((props, ref) => {
|
|
53
72
|
const { src = '', mode = 'scaleToFill', style = {}, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'enable-fast-image': enableFastImage, 'parent-width': parentWidth, 'parent-height': parentHeight, bindload, binderror } = props;
|
|
54
73
|
const defaultStyle = {
|
|
@@ -56,7 +75,6 @@ const Image = forwardRef((props, ref) => {
|
|
|
56
75
|
height: DEFAULT_IMAGE_HEIGHT
|
|
57
76
|
};
|
|
58
77
|
const styleObj = extendObject({}, defaultStyle, style, { overflow: 'hidden' });
|
|
59
|
-
const state = useRef({});
|
|
60
78
|
const nodeRef = useRef(null);
|
|
61
79
|
useNodesRef(props, ref, nodeRef, {
|
|
62
80
|
defaultStyle
|
|
@@ -70,13 +88,19 @@ const Image = forwardRef((props, ref) => {
|
|
|
70
88
|
const onLayout = ({ nativeEvent: { layout: { width, height } } }) => {
|
|
71
89
|
state.current.viewWidth = width;
|
|
72
90
|
state.current.viewHeight = height;
|
|
91
|
+
// 实际渲染尺寸可能会指定的值不一致,误差低于 0.5 则认为没有变化
|
|
92
|
+
if (Math.abs(viewHeight - height) < 0.5 && Math.abs(viewWidth - width) < 0.5) {
|
|
93
|
+
if (state.current.imageWidth && state.current.imageHeight && state.current.ratio) {
|
|
94
|
+
if (!loaded)
|
|
95
|
+
setLoaded(true);
|
|
96
|
+
}
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
73
99
|
if (state.current.imageWidth && state.current.imageHeight && state.current.ratio) {
|
|
74
|
-
setViewWidth(width);
|
|
75
|
-
setViewHeight(height);
|
|
76
100
|
setRatio(state.current.ratio);
|
|
77
101
|
setImageWidth(state.current.imageWidth);
|
|
78
102
|
setImageHeight(state.current.imageHeight);
|
|
79
|
-
state.current
|
|
103
|
+
setViewSize(state.current.viewWidth, state.current.viewHeight, state.current.ratio);
|
|
80
104
|
setLoaded(true);
|
|
81
105
|
}
|
|
82
106
|
};
|
|
@@ -96,43 +120,56 @@ const Image = forwardRef((props, ref) => {
|
|
|
96
120
|
const [imageHeight, setImageHeight] = useState(0);
|
|
97
121
|
const [ratio, setRatio] = useState(0);
|
|
98
122
|
const [loaded, setLoaded] = useState(!isLayoutMode);
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
123
|
+
const state = useRef({
|
|
124
|
+
viewWidth,
|
|
125
|
+
viewHeight
|
|
126
|
+
});
|
|
127
|
+
function setViewSize(viewWidth, viewHeight, ratio) {
|
|
128
|
+
// 在特定模式下可预测 view 的变化,在onLayout触发时能以此避免重复render
|
|
129
|
+
switch (mode) {
|
|
130
|
+
case 'widthFix': {
|
|
131
|
+
setViewWidth(viewWidth);
|
|
132
|
+
const fixedHeight = getFixedHeight(viewWidth, viewHeight, ratio);
|
|
133
|
+
setViewHeight(fixedHeight);
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
case 'heightFix': {
|
|
137
|
+
setViewHeight(viewHeight);
|
|
138
|
+
const fixedWidth = getFixedWidth(viewWidth, viewHeight, ratio);
|
|
139
|
+
setViewWidth(fixedWidth);
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
default:
|
|
143
|
+
setViewHeight(viewHeight);
|
|
144
|
+
setViewWidth(viewWidth);
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
109
148
|
const modeStyle = useMemo(() => {
|
|
110
149
|
if (noMeetCalcRule(isSvg, mode, viewWidth, viewHeight, ratio))
|
|
111
150
|
return {};
|
|
112
151
|
switch (mode) {
|
|
113
|
-
case 'scaleToFill':
|
|
152
|
+
case 'scaleToFill': // wx 中 svg 图片的 scaleToFill 模式效果与 aspectFit 一致,不会就行图片缩放,此处保持一致
|
|
114
153
|
case 'aspectFit':
|
|
115
154
|
if (isSvg) {
|
|
116
|
-
const scale =
|
|
117
|
-
? imageWidth >= viewWidth ? viewWidth / imageWidth : imageWidth / viewWidth
|
|
118
|
-
: imageHeight >= viewHeight ? viewHeight / imageHeight : imageHeight / viewHeight;
|
|
155
|
+
const scale = getFitScale(imageWidth, imageHeight, viewWidth, viewHeight);
|
|
119
156
|
return {
|
|
120
157
|
transform: [
|
|
121
|
-
{ scale },
|
|
122
|
-
|
|
158
|
+
{ translateY: relativeCenteredSize(viewHeight, imageHeight * scale) },
|
|
159
|
+
{ translateX: relativeCenteredSize(viewWidth, imageWidth * scale) },
|
|
160
|
+
{ scale }
|
|
123
161
|
]
|
|
124
162
|
};
|
|
125
163
|
}
|
|
126
164
|
return {};
|
|
127
165
|
case 'aspectFill':
|
|
128
166
|
if (isSvg) {
|
|
129
|
-
const scale =
|
|
130
|
-
? imageWidth >= viewWidth ? viewWidth / imageWidth : imageWidth / viewWidth
|
|
131
|
-
: imageHeight >= viewHeight ? viewHeight / imageHeight : imageHeight / viewHeight;
|
|
167
|
+
const scale = getFillScale(imageWidth, imageHeight, viewWidth, viewHeight);
|
|
132
168
|
return {
|
|
133
169
|
transform: [
|
|
134
|
-
{ scale },
|
|
135
|
-
|
|
170
|
+
{ translateY: relativeCenteredSize(viewHeight, imageHeight * scale) },
|
|
171
|
+
{ translateX: relativeCenteredSize(viewWidth, imageWidth * scale) },
|
|
172
|
+
{ scale }
|
|
136
173
|
]
|
|
137
174
|
};
|
|
138
175
|
}
|
|
@@ -140,9 +177,7 @@ const Image = forwardRef((props, ref) => {
|
|
|
140
177
|
case 'widthFix':
|
|
141
178
|
case 'heightFix':
|
|
142
179
|
if (isSvg) {
|
|
143
|
-
const scale =
|
|
144
|
-
? imageWidth >= fixedWidth ? fixedWidth / imageWidth : imageWidth / fixedWidth
|
|
145
|
-
: imageHeight >= fixedHeight ? fixedHeight / imageHeight : imageHeight / fixedHeight;
|
|
180
|
+
const scale = getFitScale(imageWidth, imageHeight, viewWidth, viewHeight);
|
|
146
181
|
return {
|
|
147
182
|
transform: [{ scale }]
|
|
148
183
|
};
|
|
@@ -205,12 +240,23 @@ const Image = forwardRef((props, ref) => {
|
|
|
205
240
|
default:
|
|
206
241
|
return {};
|
|
207
242
|
}
|
|
208
|
-
}, [isSvg, mode, viewWidth, viewHeight, imageWidth, imageHeight, ratio
|
|
243
|
+
}, [isSvg, mode, viewWidth, viewHeight, imageWidth, imageHeight, ratio]);
|
|
209
244
|
const onSvgLoad = (evt) => {
|
|
210
245
|
const { width, height } = evt.nativeEvent.layout;
|
|
211
|
-
|
|
212
|
-
setImageWidth(width);
|
|
246
|
+
state.current.imageHeight = height;
|
|
213
247
|
setImageHeight(height);
|
|
248
|
+
state.current.ratio = !width ? 0 : height / width;
|
|
249
|
+
if (isWidthFixMode
|
|
250
|
+
? state.current.viewWidth
|
|
251
|
+
: isHeightFixMode
|
|
252
|
+
? state.current.viewHeight
|
|
253
|
+
: state.current.viewWidth && state.current.viewHeight) {
|
|
254
|
+
setRatio(state.current.ratio);
|
|
255
|
+
setImageWidth(width);
|
|
256
|
+
setImageHeight(height);
|
|
257
|
+
setViewSize(state.current.viewWidth, state.current.viewHeight, state.current.ratio);
|
|
258
|
+
setLoaded(true);
|
|
259
|
+
}
|
|
214
260
|
bindload && bindload(getCustomEvent('load', evt, {
|
|
215
261
|
detail: { width, height },
|
|
216
262
|
layoutRef
|
|
@@ -248,12 +294,10 @@ const Image = forwardRef((props, ref) => {
|
|
|
248
294
|
: isHeightFixMode
|
|
249
295
|
? state.current.viewHeight
|
|
250
296
|
: state.current.viewWidth && state.current.viewHeight) {
|
|
251
|
-
|
|
252
|
-
state.current.viewHeight && setViewHeight(state.current.viewHeight);
|
|
253
|
-
setRatio(!width ? 0 : height / width);
|
|
297
|
+
setRatio(state.current.ratio);
|
|
254
298
|
setImageWidth(width);
|
|
255
299
|
setImageHeight(height);
|
|
256
|
-
state.current
|
|
300
|
+
setViewSize(state.current.viewWidth, state.current.viewHeight, state.current.ratio);
|
|
257
301
|
setLoaded(true);
|
|
258
302
|
}
|
|
259
303
|
}, () => {
|
|
@@ -263,7 +307,7 @@ const Image = forwardRef((props, ref) => {
|
|
|
263
307
|
}, [src, isSvg, isLayoutMode]);
|
|
264
308
|
const innerProps = useInnerProps(extendObject({}, props, layoutProps, {
|
|
265
309
|
ref: nodeRef,
|
|
266
|
-
style: extendObject({}, normalStyle, layoutStyle, isHeightFixMode ? { width:
|
|
310
|
+
style: extendObject({}, normalStyle, layoutStyle, isHeightFixMode ? { width: viewWidth } : {}, isWidthFixMode ? { height: viewHeight } : {})
|
|
267
311
|
}), [
|
|
268
312
|
'src',
|
|
269
313
|
'mode',
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mpx-inline-text.d.ts","sourceRoot":"","sources":["../mpx-inline-text.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,SAAS,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,GAAG,EAAiB,MAAM,OAAO,CAAA;AAI1C,QAAA,MAAM,UAAU;YAAW,SAAS,GAAG,WAAW;;CAQjD,CAAA;AAID,eAAe,UAAU,CAAA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TextInput, TextStyle, ViewStyle, NativeSyntheticEvent, TextInputTextInputEventData, TextInputKeyPressEventData, TextInputContentSizeChangeEventData, FlexStyle, TextInputSelectionChangeEventData, TextInputFocusEventData, TextInputSubmitEditingEventData } from 'react-native';
|
|
3
|
+
import { HandlerRef } from './useNodesRef';
|
|
4
|
+
type InputStyle = Omit<TextStyle & ViewStyle & Pick<FlexStyle, 'minHeight'>, 'borderLeftWidth' | 'borderTopWidth' | 'borderRightWidth' | 'borderBottomWidth' | 'borderTopLeftRadius' | 'borderTopRightRadius' | 'borderBottomRightRadius' | 'borderBottomLeftRadius'>;
|
|
5
|
+
type Type = 'text' | 'number' | 'idcard' | 'digit';
|
|
6
|
+
type ConfirmType = 'done' | 'send' | 'search' | 'next' | 'go' | 'return';
|
|
7
|
+
export interface InputProps {
|
|
8
|
+
name?: string;
|
|
9
|
+
style?: InputStyle & Record<string, any>;
|
|
10
|
+
value?: string | number;
|
|
11
|
+
type?: Type;
|
|
12
|
+
password?: boolean;
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
'cursor-spacing'?: number;
|
|
16
|
+
maxlength?: number;
|
|
17
|
+
'auto-focus'?: boolean;
|
|
18
|
+
focus?: boolean;
|
|
19
|
+
'confirm-type'?: ConfirmType;
|
|
20
|
+
'confirm-hold'?: boolean;
|
|
21
|
+
cursor?: number;
|
|
22
|
+
'cursor-color'?: string;
|
|
23
|
+
'selection-start'?: number;
|
|
24
|
+
'selection-end'?: number;
|
|
25
|
+
'placeholder-style'?: {
|
|
26
|
+
color?: string;
|
|
27
|
+
};
|
|
28
|
+
'enable-offset'?: boolean;
|
|
29
|
+
'enable-var'?: boolean;
|
|
30
|
+
'external-var-context'?: Record<string, any>;
|
|
31
|
+
'parent-font-size'?: number;
|
|
32
|
+
'parent-width'?: number;
|
|
33
|
+
'parent-height'?: number;
|
|
34
|
+
'adjust-position': boolean;
|
|
35
|
+
'hold-keyboard'?: boolean;
|
|
36
|
+
bindinput?: (evt: NativeSyntheticEvent<TextInputTextInputEventData> | unknown) => void;
|
|
37
|
+
bindfocus?: (evt: NativeSyntheticEvent<TextInputFocusEventData> | unknown) => void;
|
|
38
|
+
bindblur?: (evt: NativeSyntheticEvent<TextInputFocusEventData> | unknown) => void;
|
|
39
|
+
bindconfirm?: (evt: NativeSyntheticEvent<TextInputSubmitEditingEventData | TextInputKeyPressEventData> | unknown) => void;
|
|
40
|
+
bindselectionchange?: (evt: NativeSyntheticEvent<TextInputSelectionChangeEventData> | unknown) => void;
|
|
41
|
+
}
|
|
42
|
+
export interface PrivateInputProps {
|
|
43
|
+
allowFontScaling?: boolean;
|
|
44
|
+
multiline?: boolean;
|
|
45
|
+
'auto-height'?: boolean;
|
|
46
|
+
bindlinechange?: (evt: NativeSyntheticEvent<TextInputContentSizeChangeEventData> | unknown) => void;
|
|
47
|
+
}
|
|
48
|
+
type FinalInputProps = InputProps & PrivateInputProps;
|
|
49
|
+
declare const Input: import("react").ForwardRefExoticComponent<InputProps & PrivateInputProps & import("react").RefAttributes<HandlerRef<TextInput, FinalInputProps>>>;
|
|
50
|
+
export default Input;
|
|
51
|
+
//# sourceMappingURL=mpx-input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mpx-input.d.ts","sourceRoot":"","sources":["../mpx-input.tsx"],"names":[],"mappings":"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"}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* ✔ selection-start
|
|
19
19
|
* ✔ selection-end
|
|
20
20
|
* ✔ adjust-position
|
|
21
|
-
*
|
|
21
|
+
* ✔ hold-keyboard
|
|
22
22
|
* ✘ safe-password-cert-path
|
|
23
23
|
* ✘ safe-password-length
|
|
24
24
|
* ✘ safe-password-time-stamp
|
|
@@ -52,7 +52,7 @@ const keyboardTypeMap = {
|
|
|
52
52
|
digit: isIOS ? 'decimal-pad' : 'numeric'
|
|
53
53
|
};
|
|
54
54
|
const Input = forwardRef((props, ref) => {
|
|
55
|
-
const { style = {}, allowFontScaling = false, type = 'text', value, password, 'placeholder-style': placeholderStyle = {}, disabled, maxlength = 140, 'cursor-spacing': cursorSpacing = 0, '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 = true, bindinput, bindfocus, bindblur, bindconfirm, bindselectionchange,
|
|
55
|
+
const { style = {}, allowFontScaling = false, type = 'text', value, password, 'placeholder-style': placeholderStyle = {}, disabled, maxlength = 140, 'cursor-spacing': cursorSpacing = 0, '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 = true, 'hold-keyboard': holdKeyboard = false, bindinput, bindfocus, bindblur, bindconfirm, bindselectionchange,
|
|
56
56
|
// private
|
|
57
57
|
multiline, 'auto-height': autoHeight, bindlinechange } = props;
|
|
58
58
|
const formContext = useContext(FormContext);
|
|
@@ -144,8 +144,8 @@ const Input = forwardRef((props, ref) => {
|
|
|
144
144
|
}
|
|
145
145
|
};
|
|
146
146
|
const setKeyboardAvoidContext = () => {
|
|
147
|
-
if (
|
|
148
|
-
keyboardAvoid.current = { cursorSpacing, ref: nodeRef };
|
|
147
|
+
if (keyboardAvoid) {
|
|
148
|
+
keyboardAvoid.current = { cursorSpacing, ref: nodeRef, adjustPosition, holdKeyboard };
|
|
149
149
|
}
|
|
150
150
|
};
|
|
151
151
|
const onTouchStart = () => {
|
|
@@ -156,13 +156,39 @@ const Input = forwardRef((props, ref) => {
|
|
|
156
156
|
evt.nativeEvent.origin = 'input';
|
|
157
157
|
};
|
|
158
158
|
const onFocus = (evt) => {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
159
|
+
if (!keyboardAvoid?.current) {
|
|
160
|
+
setKeyboardAvoidContext();
|
|
161
|
+
}
|
|
162
|
+
if (bindfocus) {
|
|
163
|
+
const focusAction = () => {
|
|
164
|
+
bindfocus(getCustomEvent('focus', evt, {
|
|
165
|
+
detail: {
|
|
166
|
+
value: tmpValue.current || '',
|
|
167
|
+
height: keyboardAvoid?.current?.keyboardHeight
|
|
168
|
+
},
|
|
169
|
+
layoutRef
|
|
170
|
+
}, props));
|
|
171
|
+
if (keyboardAvoid?.current?.onKeyboardShow) {
|
|
172
|
+
keyboardAvoid.current.onKeyboardShow = undefined;
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
if (keyboardAvoid?.current) {
|
|
176
|
+
// 有 keyboardAvoiding
|
|
177
|
+
if (keyboardAvoid.current.keyboardHeight) {
|
|
178
|
+
// iOS: keyboard 获取高度时机 keyboardWillShow 在 input focus 之前,可以立即执行
|
|
179
|
+
focusAction();
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
// Android,Harmony: keyboard 获取高度时机 keyboardDidShow 在 input focus 之后,需要延迟回调
|
|
183
|
+
evt.persist();
|
|
184
|
+
keyboardAvoid.current.onKeyboardShow = focusAction;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
// 无 keyboardAvoiding,直接执行 focus 回调
|
|
189
|
+
focusAction();
|
|
190
|
+
}
|
|
191
|
+
}
|
|
166
192
|
};
|
|
167
193
|
const onBlur = (evt) => {
|
|
168
194
|
bindblur && bindblur(getCustomEvent('blur', evt, {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { ViewStyle } from 'react-native';
|
|
3
|
+
type KeyboardAvoidViewProps = {
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
style?: ViewStyle;
|
|
6
|
+
contentContainerStyle?: ViewStyle;
|
|
7
|
+
};
|
|
8
|
+
declare const KeyboardAvoidingView: {
|
|
9
|
+
({ children, style, contentContainerStyle }: KeyboardAvoidViewProps): React.JSX.Element;
|
|
10
|
+
displayName: string;
|
|
11
|
+
};
|
|
12
|
+
export default KeyboardAvoidingView;
|
|
13
|
+
//# sourceMappingURL=mpx-keyboard-avoiding-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mpx-keyboard-avoiding-view.d.ts","sourceRoot":"","sources":["../mpx-keyboard-avoiding-view.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAiC,MAAM,OAAO,CAAA;AACvE,OAAO,EAAuD,SAAS,EAA0C,MAAM,cAAc,CAAA;AAKrI,KAAK,sBAAsB,GAAG;IAC5B,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,qBAAqB,CAAC,EAAE,SAAS,CAAA;CAClC,CAAA;AAED,QAAA,MAAM,oBAAoB;iDAAgD,sBAAsB;;CAiH/F,CAAA;AAID,eAAe,oBAAoB,CAAA"}
|