@rsmax/one 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +3 -0
- package/cjs/api/index.ali.d.ts +1 -0
- package/cjs/api/index.ali.js +9 -0
- package/cjs/api/index.d.ts +1 -0
- package/cjs/api/index.js +9 -0
- package/cjs/api/index.toutiao.d.ts +1 -0
- package/cjs/api/index.toutiao.js +9 -0
- package/cjs/api/index.wechat.d.ts +5 -0
- package/cjs/api/index.wechat.js +9 -0
- package/cjs/components/Modal.d.ts +2 -0
- package/cjs/components/Modal.js +8 -0
- package/cjs/components/Modal.web.d.ts +2 -0
- package/cjs/components/Modal.web.js +41 -0
- package/cjs/constants.d.ts +1 -0
- package/cjs/constants.js +4 -0
- package/cjs/createHostComponent.d.ts +18 -0
- package/cjs/createHostComponent.js +205 -0
- package/cjs/hostComponents/Button/index.d.ts +24 -0
- package/cjs/hostComponents/Button/index.js +10 -0
- package/cjs/hostComponents/Button/index.web.d.ts +5 -0
- package/cjs/hostComponents/Button/index.web.js +57 -0
- package/cjs/hostComponents/Button/props/alias/index.d.ts +4 -0
- package/cjs/hostComponents/Button/props/alias/index.js +5 -0
- package/cjs/hostComponents/Button/props/default/index.d.ts +2 -0
- package/cjs/hostComponents/Button/props/default/index.js +3 -0
- package/cjs/hostComponents/Button/props/default/index.wechat.d.ts +6 -0
- package/cjs/hostComponents/Button/props/default/index.wechat.js +7 -0
- package/cjs/hostComponents/Button/props/index.d.ts +27 -0
- package/cjs/hostComponents/Button/props/index.js +10 -0
- package/cjs/hostComponents/Form/index.d.ts +5 -0
- package/cjs/hostComponents/Form/index.js +9 -0
- package/cjs/hostComponents/Form/index.web.d.ts +5 -0
- package/cjs/hostComponents/Form/index.web.js +29 -0
- package/cjs/hostComponents/Form/props/default/index.d.ts +2 -0
- package/cjs/hostComponents/Form/props/default/index.js +3 -0
- package/cjs/hostComponents/Form/props/default/index.wechat.d.ts +5 -0
- package/cjs/hostComponents/Form/props/default/index.wechat.js +6 -0
- package/cjs/hostComponents/Form/props/index.d.ts +15 -0
- package/cjs/hostComponents/Form/props/index.js +8 -0
- package/cjs/hostComponents/Image/index.d.ts +5 -0
- package/cjs/hostComponents/Image/index.js +9 -0
- package/cjs/hostComponents/Image/index.web.d.ts +5 -0
- package/cjs/hostComponents/Image/index.web.js +54 -0
- package/cjs/hostComponents/Image/modeStyle.d.ts +46 -0
- package/cjs/hostComponents/Image/modeStyle.js +47 -0
- package/cjs/hostComponents/Image/props/default/index.d.ts +2 -0
- package/cjs/hostComponents/Image/props/default/index.js +3 -0
- package/cjs/hostComponents/Image/props/default/index.wechat.d.ts +7 -0
- package/cjs/hostComponents/Image/props/default/index.wechat.js +8 -0
- package/cjs/hostComponents/Image/props/index.d.ts +27 -0
- package/cjs/hostComponents/Image/props/index.js +8 -0
- package/cjs/hostComponents/Input/index.d.ts +27 -0
- package/cjs/hostComponents/Input/index.js +86 -0
- package/cjs/hostComponents/Input/index.web.d.ts +5 -0
- package/cjs/hostComponents/Input/index.web.js +58 -0
- package/cjs/hostComponents/Input/props/alias/index.d.ts +4 -0
- package/cjs/hostComponents/Input/props/alias/index.js +5 -0
- package/cjs/hostComponents/Input/props/index.d.ts +35 -0
- package/cjs/hostComponents/Input/props/index.js +2 -0
- package/cjs/hostComponents/Label/index.d.ts +5 -0
- package/cjs/hostComponents/Label/index.js +8 -0
- package/cjs/hostComponents/Label/index.web.d.ts +5 -0
- package/cjs/hostComponents/Label/index.web.js +29 -0
- package/cjs/hostComponents/Label/props.d.ts +9 -0
- package/cjs/hostComponents/Label/props.js +2 -0
- package/cjs/hostComponents/Navigator/index.d.ts +5 -0
- package/cjs/hostComponents/Navigator/index.js +9 -0
- package/cjs/hostComponents/Navigator/index.web.d.ts +5 -0
- package/cjs/hostComponents/Navigator/index.web.js +64 -0
- package/cjs/hostComponents/Navigator/props/default/index.d.ts +2 -0
- package/cjs/hostComponents/Navigator/props/default/index.js +3 -0
- package/cjs/hostComponents/Navigator/props/default/index.wechat.d.ts +10 -0
- package/cjs/hostComponents/Navigator/props/default/index.wechat.js +11 -0
- package/cjs/hostComponents/Navigator/props/index.d.ts +22 -0
- package/cjs/hostComponents/Navigator/props/index.js +8 -0
- package/cjs/hostComponents/Text/index.d.ts +5 -0
- package/cjs/hostComponents/Text/index.js +9 -0
- package/cjs/hostComponents/Text/index.web.d.ts +5 -0
- package/cjs/hostComponents/Text/index.web.js +74 -0
- package/cjs/hostComponents/Text/props/default/index.d.ts +2 -0
- package/cjs/hostComponents/Text/props/default/index.js +3 -0
- package/cjs/hostComponents/Text/props/default/index.wechat.d.ts +5 -0
- package/cjs/hostComponents/Text/props/default/index.wechat.js +6 -0
- package/cjs/hostComponents/Text/props/index.d.ts +18 -0
- package/cjs/hostComponents/Text/props/index.js +8 -0
- package/cjs/hostComponents/Textarea/index.d.ts +29 -0
- package/cjs/hostComponents/Textarea/index.js +80 -0
- package/cjs/hostComponents/Textarea/index.web.d.ts +4 -0
- package/cjs/hostComponents/Textarea/index.web.js +64 -0
- package/cjs/hostComponents/Textarea/props/alias.d.ts +4 -0
- package/cjs/hostComponents/Textarea/props/alias.js +5 -0
- package/cjs/hostComponents/Textarea/props/index.d.ts +30 -0
- package/cjs/hostComponents/Textarea/props/index.js +8 -0
- package/cjs/hostComponents/View/index.d.ts +5 -0
- package/cjs/hostComponents/View/index.js +9 -0
- package/cjs/hostComponents/View/index.web.d.ts +5 -0
- package/cjs/hostComponents/View/index.web.js +57 -0
- package/cjs/hostComponents/View/props/default/index.d.ts +2 -0
- package/cjs/hostComponents/View/props/default/index.js +3 -0
- package/cjs/hostComponents/View/props/default/index.wechat.d.ts +7 -0
- package/cjs/hostComponents/View/props/default/index.wechat.js +8 -0
- package/cjs/hostComponents/View/props/index.d.ts +27 -0
- package/cjs/hostComponents/View/props/index.js +8 -0
- package/cjs/hostComponents/WebView/index.d.ts +9 -0
- package/cjs/hostComponents/WebView/index.js +8 -0
- package/cjs/hostComponents/WebView/index.web.d.ts +10 -0
- package/cjs/hostComponents/WebView/index.web.js +56 -0
- package/cjs/hostComponents/index.d.ts +20 -0
- package/cjs/hostComponents/index.js +50 -0
- package/cjs/hostComponents/useWebTouch.d.ts +18 -0
- package/cjs/hostComponents/useWebTouch.js +95 -0
- package/cjs/index.d.ts +4 -0
- package/cjs/index.js +25 -0
- package/cjs/types/event.d.ts +64 -0
- package/cjs/types/event.js +2 -0
- package/cjs/types/index.d.ts +1 -0
- package/cjs/types/index.js +17 -0
- package/cjs/useWebPlaceholderStyle/index.d.ts +2 -0
- package/cjs/useWebPlaceholderStyle/index.js +50 -0
- package/cjs/useWebPlaceholderStyle/plainStyle/CSSProperty.d.ts +6 -0
- package/cjs/useWebPlaceholderStyle/plainStyle/CSSProperty.js +71 -0
- package/cjs/useWebPlaceholderStyle/plainStyle/index.d.ts +3 -0
- package/cjs/useWebPlaceholderStyle/plainStyle/index.js +48 -0
- package/cjs/utils/isPlatformSpecifyProp.d.ts +3 -0
- package/cjs/utils/isPlatformSpecifyProp.js +22 -0
- package/cjs/utils/literalText.d.ts +2 -0
- package/cjs/utils/literalText.js +20 -0
- package/esm/api/index.ali.d.ts +1 -0
- package/esm/api/index.ali.js +1 -0
- package/esm/api/index.d.ts +1 -0
- package/esm/api/index.js +1 -0
- package/esm/api/index.toutiao.d.ts +1 -0
- package/esm/api/index.toutiao.js +1 -0
- package/esm/api/index.wechat.d.ts +5 -0
- package/esm/api/index.wechat.js +6 -0
- package/esm/components/Modal.d.ts +2 -0
- package/esm/components/Modal.js +5 -0
- package/esm/components/Modal.web.d.ts +2 -0
- package/esm/components/Modal.web.js +12 -0
- package/esm/constants.d.ts +1 -0
- package/esm/constants.js +1 -0
- package/esm/createHostComponent.d.ts +18 -0
- package/esm/createHostComponent.js +166 -0
- package/esm/hostComponents/Button/index.d.ts +24 -0
- package/esm/hostComponents/Button/index.js +5 -0
- package/esm/hostComponents/Button/index.web.d.ts +5 -0
- package/esm/hostComponents/Button/index.web.js +29 -0
- package/esm/hostComponents/Button/props/alias/index.d.ts +4 -0
- package/esm/hostComponents/Button/props/alias/index.js +3 -0
- package/esm/hostComponents/Button/props/default/index.d.ts +2 -0
- package/esm/hostComponents/Button/props/default/index.js +1 -0
- package/esm/hostComponents/Button/props/default/index.wechat.d.ts +6 -0
- package/esm/hostComponents/Button/props/default/index.wechat.js +5 -0
- package/esm/hostComponents/Button/props/index.d.ts +27 -0
- package/esm/hostComponents/Button/props/index.js +2 -0
- package/esm/hostComponents/Form/index.d.ts +5 -0
- package/esm/hostComponents/Form/index.js +4 -0
- package/esm/hostComponents/Form/index.web.d.ts +5 -0
- package/esm/hostComponents/Form/index.web.js +4 -0
- package/esm/hostComponents/Form/props/default/index.d.ts +2 -0
- package/esm/hostComponents/Form/props/default/index.js +1 -0
- package/esm/hostComponents/Form/props/default/index.wechat.d.ts +5 -0
- package/esm/hostComponents/Form/props/default/index.wechat.js +4 -0
- package/esm/hostComponents/Form/props/index.d.ts +15 -0
- package/esm/hostComponents/Form/props/index.js +1 -0
- package/esm/hostComponents/Image/index.d.ts +5 -0
- package/esm/hostComponents/Image/index.js +4 -0
- package/esm/hostComponents/Image/index.web.d.ts +5 -0
- package/esm/hostComponents/Image/index.web.js +26 -0
- package/esm/hostComponents/Image/modeStyle.d.ts +46 -0
- package/esm/hostComponents/Image/modeStyle.js +45 -0
- package/esm/hostComponents/Image/props/default/index.d.ts +2 -0
- package/esm/hostComponents/Image/props/default/index.js +1 -0
- package/esm/hostComponents/Image/props/default/index.wechat.d.ts +7 -0
- package/esm/hostComponents/Image/props/default/index.wechat.js +6 -0
- package/esm/hostComponents/Image/props/index.d.ts +27 -0
- package/esm/hostComponents/Image/props/index.js +1 -0
- package/esm/hostComponents/Input/index.d.ts +27 -0
- package/esm/hostComponents/Input/index.js +80 -0
- package/esm/hostComponents/Input/index.web.d.ts +5 -0
- package/esm/hostComponents/Input/index.web.js +30 -0
- package/esm/hostComponents/Input/props/alias/index.d.ts +4 -0
- package/esm/hostComponents/Input/props/alias/index.js +3 -0
- package/esm/hostComponents/Input/props/index.d.ts +35 -0
- package/esm/hostComponents/Input/props/index.js +1 -0
- package/esm/hostComponents/Label/index.d.ts +5 -0
- package/esm/hostComponents/Label/index.js +3 -0
- package/esm/hostComponents/Label/index.web.d.ts +5 -0
- package/esm/hostComponents/Label/index.web.js +4 -0
- package/esm/hostComponents/Label/props.d.ts +9 -0
- package/esm/hostComponents/Label/props.js +1 -0
- package/esm/hostComponents/Navigator/index.d.ts +5 -0
- package/esm/hostComponents/Navigator/index.js +4 -0
- package/esm/hostComponents/Navigator/index.web.d.ts +5 -0
- package/esm/hostComponents/Navigator/index.web.js +36 -0
- package/esm/hostComponents/Navigator/props/default/index.d.ts +2 -0
- package/esm/hostComponents/Navigator/props/default/index.js +1 -0
- package/esm/hostComponents/Navigator/props/default/index.wechat.d.ts +10 -0
- package/esm/hostComponents/Navigator/props/default/index.wechat.js +9 -0
- package/esm/hostComponents/Navigator/props/index.d.ts +22 -0
- package/esm/hostComponents/Navigator/props/index.js +1 -0
- package/esm/hostComponents/Text/index.d.ts +5 -0
- package/esm/hostComponents/Text/index.js +4 -0
- package/esm/hostComponents/Text/index.web.d.ts +5 -0
- package/esm/hostComponents/Text/index.web.js +46 -0
- package/esm/hostComponents/Text/props/default/index.d.ts +2 -0
- package/esm/hostComponents/Text/props/default/index.js +1 -0
- package/esm/hostComponents/Text/props/default/index.wechat.d.ts +5 -0
- package/esm/hostComponents/Text/props/default/index.wechat.js +4 -0
- package/esm/hostComponents/Text/props/index.d.ts +18 -0
- package/esm/hostComponents/Text/props/index.js +1 -0
- package/esm/hostComponents/Textarea/index.d.ts +29 -0
- package/esm/hostComponents/Textarea/index.js +74 -0
- package/esm/hostComponents/Textarea/index.web.d.ts +4 -0
- package/esm/hostComponents/Textarea/index.web.js +36 -0
- package/esm/hostComponents/Textarea/props/alias.d.ts +4 -0
- package/esm/hostComponents/Textarea/props/alias.js +3 -0
- package/esm/hostComponents/Textarea/props/index.d.ts +30 -0
- package/esm/hostComponents/Textarea/props/index.js +1 -0
- package/esm/hostComponents/View/index.d.ts +5 -0
- package/esm/hostComponents/View/index.js +4 -0
- package/esm/hostComponents/View/index.web.d.ts +5 -0
- package/esm/hostComponents/View/index.web.js +29 -0
- package/esm/hostComponents/View/props/default/index.d.ts +2 -0
- package/esm/hostComponents/View/props/default/index.js +1 -0
- package/esm/hostComponents/View/props/default/index.wechat.d.ts +7 -0
- package/esm/hostComponents/View/props/default/index.wechat.js +6 -0
- package/esm/hostComponents/View/props/index.d.ts +27 -0
- package/esm/hostComponents/View/props/index.js +1 -0
- package/esm/hostComponents/WebView/index.d.ts +9 -0
- package/esm/hostComponents/WebView/index.js +3 -0
- package/esm/hostComponents/WebView/index.web.d.ts +10 -0
- package/esm/hostComponents/WebView/index.web.js +28 -0
- package/esm/hostComponents/index.d.ts +20 -0
- package/esm/hostComponents/index.js +20 -0
- package/esm/hostComponents/useWebTouch.d.ts +18 -0
- package/esm/hostComponents/useWebTouch.js +70 -0
- package/esm/index.d.ts +4 -0
- package/esm/index.js +4 -0
- package/esm/types/event.d.ts +64 -0
- package/esm/types/event.js +1 -0
- package/esm/types/index.d.ts +1 -0
- package/esm/types/index.js +1 -0
- package/esm/useWebPlaceholderStyle/index.d.ts +2 -0
- package/esm/useWebPlaceholderStyle/index.js +21 -0
- package/esm/useWebPlaceholderStyle/plainStyle/CSSProperty.d.ts +6 -0
- package/esm/useWebPlaceholderStyle/plainStyle/CSSProperty.js +68 -0
- package/esm/useWebPlaceholderStyle/plainStyle/index.d.ts +3 -0
- package/esm/useWebPlaceholderStyle/plainStyle/index.js +46 -0
- package/esm/utils/isPlatformSpecifyProp.d.ts +3 -0
- package/esm/utils/isPlatformSpecifyProp.js +18 -0
- package/esm/utils/literalText.d.ts +2 -0
- package/esm/utils/literalText.js +15 -0
- package/node.js +1 -0
- package/package.json +45 -0
- package/scripts/postbuild.js +17 -0
- package/typings/index.d.ts +0 -0
- package/vitest.config.js +7 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom';
|
|
3
|
+
export default function Modal({ children }) {
|
|
4
|
+
const domNode = React.useRef(document.createElement('div'));
|
|
5
|
+
React.useEffect(() => {
|
|
6
|
+
document.body.appendChild(domNode.current);
|
|
7
|
+
return () => {
|
|
8
|
+
document.body.removeChild(domNode.current);
|
|
9
|
+
};
|
|
10
|
+
}, []);
|
|
11
|
+
return ReactDOM.createPortal(children, domNode.current);
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LONG_TAP_DURATION = 350;
|
package/esm/constants.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const LONG_TAP_DURATION = 350;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { TapEvent, TouchEvent, EventTarget, EventCurrentTarget, ImageLoadEvent, ImageErrorEvent, InputEvent, FormEvent } from './types';
|
|
3
|
+
export declare function createTarget(target: any, detail: any): EventTarget;
|
|
4
|
+
export declare function createCurrentTarget(currentTarget: any): EventCurrentTarget;
|
|
5
|
+
export declare const createTapEvent: (originalEvent: any) => TapEvent;
|
|
6
|
+
export declare const createTouchEvent: (originalEvent: any) => TouchEvent;
|
|
7
|
+
export declare const createImageEvent: (originalEvent: any) => ImageLoadEvent | ImageErrorEvent;
|
|
8
|
+
export declare function createCallback(fn: ((event: any) => void) | undefined, eventCreator: (event: any) => any): ((originalEvent: any) => void) | undefined;
|
|
9
|
+
export declare const createInputEvent: (originalEvent: any) => InputEvent;
|
|
10
|
+
export declare const createFormEvent: (originalEvent: any) => FormEvent;
|
|
11
|
+
export declare function aliasProps(props: any, alias: {
|
|
12
|
+
[key: string]: string;
|
|
13
|
+
}): any;
|
|
14
|
+
export default function createHostComponent<P = any>(name: string, alias: {
|
|
15
|
+
[key: string]: string;
|
|
16
|
+
} | null, defaults?: {
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
}): React.ForwardRefExoticComponent<React.PropsWithoutRef<React.PropsWithChildren<P>> & React.RefAttributes<any>>;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import memoizeOne from 'memoize-one';
|
|
3
|
+
import { formatDisplayName } from '@rsmax/framework-shared';
|
|
4
|
+
export function createTarget(target, detail) {
|
|
5
|
+
return {
|
|
6
|
+
id: target.id,
|
|
7
|
+
offsetLeft: target.offsetLeft,
|
|
8
|
+
offsetTop: target.offsetTop,
|
|
9
|
+
dataset: target.targetDataset || target.dataset,
|
|
10
|
+
value: detail === null || detail === void 0 ? void 0 : detail.value,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function createCurrentTarget(currentTarget) {
|
|
14
|
+
return {
|
|
15
|
+
id: currentTarget.id,
|
|
16
|
+
offsetLeft: currentTarget.offsetLeft,
|
|
17
|
+
offsetTop: currentTarget.offsetTop,
|
|
18
|
+
dataset: currentTarget.dataset,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export const createTapEvent = (originalEvent) => ({
|
|
22
|
+
type: originalEvent.type,
|
|
23
|
+
stopPropagation: originalEvent.stopPropagation,
|
|
24
|
+
target: createTarget(originalEvent.target, originalEvent.detail),
|
|
25
|
+
currentTarget: createCurrentTarget(originalEvent.currentTarget),
|
|
26
|
+
originalEvent,
|
|
27
|
+
nativeEvent: originalEvent,
|
|
28
|
+
});
|
|
29
|
+
export const createTouchEvent = (originalEvent) => ({
|
|
30
|
+
type: originalEvent.type,
|
|
31
|
+
stopPropagation: originalEvent.stopPropagation,
|
|
32
|
+
target: createTarget(originalEvent.target, originalEvent.detail),
|
|
33
|
+
currentTarget: createCurrentTarget(originalEvent.currentTarget),
|
|
34
|
+
touches: originalEvent.touches,
|
|
35
|
+
changedTouches: originalEvent.touches,
|
|
36
|
+
originalEvent,
|
|
37
|
+
nativeEvent: originalEvent,
|
|
38
|
+
});
|
|
39
|
+
export const createImageEvent = (originalEvent) => ({
|
|
40
|
+
type: originalEvent.type,
|
|
41
|
+
target: createTarget(originalEvent.target, originalEvent.detail),
|
|
42
|
+
currentTarget: createCurrentTarget(originalEvent.currentTarget),
|
|
43
|
+
originalEvent,
|
|
44
|
+
nativeEvent: originalEvent,
|
|
45
|
+
});
|
|
46
|
+
export function createCallback(fn, eventCreator) {
|
|
47
|
+
if (typeof fn !== 'function') {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
return (originalEvent) => fn(eventCreator(originalEvent));
|
|
51
|
+
}
|
|
52
|
+
export const createInputEvent = (originalEvent) => ({
|
|
53
|
+
type: originalEvent.type,
|
|
54
|
+
target: createTarget(originalEvent.target, originalEvent.detail),
|
|
55
|
+
currentTarget: createCurrentTarget(originalEvent.currentTarget),
|
|
56
|
+
originalEvent,
|
|
57
|
+
nativeEvent: originalEvent,
|
|
58
|
+
});
|
|
59
|
+
export const createFormEvent = (originalEvent) => ({
|
|
60
|
+
type: originalEvent.type,
|
|
61
|
+
target: createTarget(originalEvent.target, originalEvent.detail),
|
|
62
|
+
currentTarget: createCurrentTarget(originalEvent.currentTarget),
|
|
63
|
+
originalEvent,
|
|
64
|
+
nativeEvent: originalEvent,
|
|
65
|
+
});
|
|
66
|
+
function assignDefaultProps(inputProps, defaultProps) {
|
|
67
|
+
if (defaultProps) {
|
|
68
|
+
Object.keys(defaultProps).forEach(key => {
|
|
69
|
+
var _a;
|
|
70
|
+
inputProps[key] = (_a = inputProps[key]) !== null && _a !== void 0 ? _a : defaultProps[key];
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export function aliasProps(props, alias) {
|
|
75
|
+
var _a;
|
|
76
|
+
if (!alias) {
|
|
77
|
+
return props;
|
|
78
|
+
}
|
|
79
|
+
const nextProps = {};
|
|
80
|
+
for (const key in props) {
|
|
81
|
+
nextProps[(_a = alias[key]) !== null && _a !== void 0 ? _a : key] = props[key];
|
|
82
|
+
}
|
|
83
|
+
return nextProps;
|
|
84
|
+
}
|
|
85
|
+
const createLongTapCallback = memoizeOne(createCallback);
|
|
86
|
+
const createTapCallback = memoizeOne(createCallback);
|
|
87
|
+
const createTouchStartCallback = memoizeOne(createCallback);
|
|
88
|
+
const createTouchMoveCallback = memoizeOne(createCallback);
|
|
89
|
+
const createTouchEndCallback = memoizeOne(createCallback);
|
|
90
|
+
const createTouchCancelCallback = memoizeOne(createCallback);
|
|
91
|
+
const createChangeCallback = memoizeOne(createCallback);
|
|
92
|
+
const createInputCallback = memoizeOne(createCallback);
|
|
93
|
+
const createConfirmCallback = memoizeOne(createCallback);
|
|
94
|
+
const createFocusCallback = memoizeOne(createCallback);
|
|
95
|
+
const createBlurCallback = memoizeOne(createCallback);
|
|
96
|
+
const createSubmitCallback = memoizeOne(createCallback);
|
|
97
|
+
const createResetCallback = memoizeOne(createCallback);
|
|
98
|
+
const createImageLoadCallback = memoizeOne(createCallback);
|
|
99
|
+
const createImageErrorCallback = memoizeOne(createCallback);
|
|
100
|
+
export default function createHostComponent(name, alias, defaults) {
|
|
101
|
+
const Component = (props, ref) => {
|
|
102
|
+
const inputProps = Object.assign({}, props);
|
|
103
|
+
// 默认属性根据平台在这里设置
|
|
104
|
+
if (defaults) {
|
|
105
|
+
assignDefaultProps(inputProps, defaults);
|
|
106
|
+
}
|
|
107
|
+
if (props.onLongTap) {
|
|
108
|
+
inputProps.onLongTap = createLongTapCallback(inputProps.onLongTap, createTapEvent);
|
|
109
|
+
}
|
|
110
|
+
if (inputProps.onTap) {
|
|
111
|
+
inputProps.onTap = createTapCallback(inputProps.onTap, createTapEvent);
|
|
112
|
+
}
|
|
113
|
+
if (inputProps.onTouchStart) {
|
|
114
|
+
inputProps.onTouchStart = createTouchStartCallback(inputProps.onTouchStart, createTouchEvent);
|
|
115
|
+
}
|
|
116
|
+
if (inputProps.onTouchMove) {
|
|
117
|
+
inputProps.onTouchMove = createTouchMoveCallback(inputProps.onTouchMove, createTouchEvent);
|
|
118
|
+
}
|
|
119
|
+
if (inputProps.onTouchEnd) {
|
|
120
|
+
inputProps.onTouchEnd = createTouchEndCallback(inputProps.onTouchEnd, createTouchEvent);
|
|
121
|
+
}
|
|
122
|
+
if (inputProps.onTouchCancel) {
|
|
123
|
+
inputProps.onTouchCancel = createTouchCancelCallback(inputProps.onTouchCancel, createTouchEvent);
|
|
124
|
+
}
|
|
125
|
+
if (inputProps.onChange) {
|
|
126
|
+
inputProps.onChange = createChangeCallback(inputProps.onChange, createInputEvent);
|
|
127
|
+
}
|
|
128
|
+
if (inputProps.onInput) {
|
|
129
|
+
inputProps.onInput = createInputCallback(inputProps.onInput, createInputEvent);
|
|
130
|
+
}
|
|
131
|
+
if (inputProps.onConfirm) {
|
|
132
|
+
inputProps.onConfirm = createConfirmCallback(inputProps.onConfirm, createInputEvent);
|
|
133
|
+
}
|
|
134
|
+
if (inputProps.onFocus) {
|
|
135
|
+
inputProps.onFocus = createFocusCallback(inputProps.onFocus, createInputEvent);
|
|
136
|
+
}
|
|
137
|
+
if (inputProps.onBlur) {
|
|
138
|
+
inputProps.onBlur = createBlurCallback(inputProps.onBlur, createInputEvent);
|
|
139
|
+
}
|
|
140
|
+
if (inputProps.onSubmit) {
|
|
141
|
+
inputProps.onSubmit = createSubmitCallback(inputProps.onSubmit, createFormEvent);
|
|
142
|
+
}
|
|
143
|
+
if (inputProps.onReset) {
|
|
144
|
+
inputProps.onReset = createResetCallback(inputProps.onReset, createFormEvent);
|
|
145
|
+
}
|
|
146
|
+
if (name === 'image') {
|
|
147
|
+
if (inputProps.onLoad) {
|
|
148
|
+
inputProps.onLoad = createImageLoadCallback(props.onLoad, createImageEvent);
|
|
149
|
+
}
|
|
150
|
+
if (inputProps.onError) {
|
|
151
|
+
inputProps.onError = createImageErrorCallback(props.onError, createImageEvent);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
let nextProps = inputProps;
|
|
155
|
+
if (alias) {
|
|
156
|
+
nextProps = aliasProps(inputProps, alias);
|
|
157
|
+
}
|
|
158
|
+
nextProps.ref = ref;
|
|
159
|
+
return React.createElement(name, nextProps);
|
|
160
|
+
};
|
|
161
|
+
if (process.env.NODE_ENV === 'development') {
|
|
162
|
+
Component.displayName = formatDisplayName(name);
|
|
163
|
+
}
|
|
164
|
+
// @ts-expect-error
|
|
165
|
+
return React.forwardRef(Component);
|
|
166
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TapEvent } from '../../types';
|
|
3
|
+
export interface ButtonProps extends React.AriaAttributes {
|
|
4
|
+
readonly dataset?: DOMStringMap;
|
|
5
|
+
id?: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
/** 是否禁用 */
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
/** 指定按钮按下去的样式类。当 hover-class="none" 时,没有点击态效果 */
|
|
11
|
+
hoverClassName?: string;
|
|
12
|
+
/** 按住后多久出现点击态,单位毫秒 */
|
|
13
|
+
hoverStartTime?: number;
|
|
14
|
+
/** 手指松开后点击态保留时间,单位毫秒 */
|
|
15
|
+
hoverStayTime?: number;
|
|
16
|
+
/** 指定是否阻止本节点的祖先节点出现点击态 */
|
|
17
|
+
hoverStopPropagation?: boolean;
|
|
18
|
+
/** 用于 form 组件,点击分别会触发 form 组件的 submit/reset 事件 */
|
|
19
|
+
type?: 'submit' | 'reset';
|
|
20
|
+
onTap?: (event: TapEvent) => void;
|
|
21
|
+
children?: React.ReactNode;
|
|
22
|
+
}
|
|
23
|
+
declare const Button: React.ComponentType<ButtonProps>;
|
|
24
|
+
export default Button;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import * as React from 'react';
|
|
13
|
+
import clsx from 'clsx';
|
|
14
|
+
import { filterProps } from '../../utils/isPlatformSpecifyProp';
|
|
15
|
+
import useWebTouch from '../useWebTouch';
|
|
16
|
+
const Button = (props, ref) => {
|
|
17
|
+
const _a = filterProps(props), { hoverClassName, hoverStartTime = 400, hoverStayTime = 50, className, onTouchStart, onTouchMove, onTouchEnd, onTouchCancel, onTap, onLongTap } = _a, restProps = __rest(_a, ["hoverClassName", "hoverStartTime", "hoverStayTime", "className", "onTouchStart", "onTouchMove", "onTouchEnd", "onTouchCancel", "onTap", "onLongTap"]);
|
|
18
|
+
const [hovered, handleTouchStart, handleTouchMove, handleTouchEnd, handleTouchCancel] = useWebTouch({
|
|
19
|
+
hoverDelay: hoverStartTime,
|
|
20
|
+
hoverDuration: hoverStayTime,
|
|
21
|
+
onLongTap,
|
|
22
|
+
onTouchStart,
|
|
23
|
+
onTouchMove,
|
|
24
|
+
onTouchEnd,
|
|
25
|
+
onTouchCancel,
|
|
26
|
+
});
|
|
27
|
+
return (React.createElement("button", Object.assign({}, restProps, { onTouchStart: handleTouchStart, onTouchMove: handleTouchMove, onTouchEnd: handleTouchEnd, ref: ref, onTouchCancel: handleTouchCancel, className: clsx('remax-button', className, { [hoverClassName || '']: hovered }), onClick: onTap })));
|
|
28
|
+
};
|
|
29
|
+
export default React.forwardRef(Button);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { TapEvent } from '../../../types';
|
|
3
|
+
export { default as defaults } from './default';
|
|
4
|
+
export { default as alias } from './alias';
|
|
5
|
+
interface CommonProps {
|
|
6
|
+
readonly dataset?: DOMStringMap;
|
|
7
|
+
id?: string;
|
|
8
|
+
className?: string;
|
|
9
|
+
style?: React.CSSProperties;
|
|
10
|
+
/** 是否禁用 */
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
/** 指定按钮按下去的样式类。当 hover-class="none" 时,没有点击态效果 */
|
|
13
|
+
hoverClassName?: string;
|
|
14
|
+
/** 按住后多久出现点击态,单位毫秒 */
|
|
15
|
+
hoverStartTime?: number;
|
|
16
|
+
/** 手指松开后点击态保留时间,单位毫秒 */
|
|
17
|
+
hoverStayTime?: number;
|
|
18
|
+
/** 用于 form 组件,点击分别会触发 form 组件的 submit/reset 事件 */
|
|
19
|
+
type?: 'submit' | 'reset';
|
|
20
|
+
}
|
|
21
|
+
export interface ButtonProps extends CommonProps, React.AriaAttributes {
|
|
22
|
+
onTap?: (event: TapEvent) => void;
|
|
23
|
+
}
|
|
24
|
+
export interface ButtonWebProps extends CommonProps, React.HTMLAttributes<HTMLButtonElement> {
|
|
25
|
+
onTap?: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
26
|
+
onLongTap?: (event: React.TouchEvent<HTMLButtonElement>) => void;
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { FormEvent } from '../../../types';
|
|
3
|
+
export { default as defaults } from './default';
|
|
4
|
+
interface CommonProps {
|
|
5
|
+
readonly dataset?: DOMStringMap;
|
|
6
|
+
id?: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
style?: React.CSSProperties;
|
|
9
|
+
}
|
|
10
|
+
export interface FormProps extends CommonProps {
|
|
11
|
+
onSubmit?: (e: FormEvent) => void;
|
|
12
|
+
onReset?: (e: FormEvent) => void;
|
|
13
|
+
}
|
|
14
|
+
export interface FormWebProps extends CommonProps, React.HTMLAttributes<HTMLFormElement> {
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as defaults } from './default';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import * as React from 'react';
|
|
13
|
+
import { filterProps } from '../../utils/isPlatformSpecifyProp';
|
|
14
|
+
import modeStyle from './modeStyle';
|
|
15
|
+
import clsx from 'clsx';
|
|
16
|
+
const Image = (props, ref) => {
|
|
17
|
+
const _a = filterProps(props), { className, src, style, mode = 'scaleToFill', onTap, onLoad, onError } = _a, restProps = __rest(_a, ["className", "src", "style", "mode", "onTap", "onLoad", "onError"]);
|
|
18
|
+
const isWidthFixMode = mode === 'widthFix';
|
|
19
|
+
return (React.createElement("div", Object.assign({}, restProps, { onClick: onTap, className: clsx('remax-image', className), style: Object.assign(Object.assign(Object.assign({}, modeStyle[mode]), { backgroundImage: `url(${src})`, backgroundRepeat: `no-repeat` }), style) }),
|
|
20
|
+
React.createElement("img", { src: src, ref: ref, style: {
|
|
21
|
+
visibility: 'hidden',
|
|
22
|
+
width: isWidthFixMode ? '100%' : undefined,
|
|
23
|
+
height: isWidthFixMode ? 'auto' : '1px',
|
|
24
|
+
}, onLoad: onLoad, onError: onError })));
|
|
25
|
+
};
|
|
26
|
+
export default React.forwardRef(Image);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
scaleToFill: {
|
|
3
|
+
backgroundSize: string;
|
|
4
|
+
};
|
|
5
|
+
aspectFit: {
|
|
6
|
+
backgroundSize: string;
|
|
7
|
+
backgroundPosition: string;
|
|
8
|
+
};
|
|
9
|
+
widthFix: {
|
|
10
|
+
backgroundSize: string;
|
|
11
|
+
height: string;
|
|
12
|
+
lineHeight: number;
|
|
13
|
+
};
|
|
14
|
+
aspectFill: {
|
|
15
|
+
backgroundSize: string;
|
|
16
|
+
backgroundPosition: string;
|
|
17
|
+
};
|
|
18
|
+
top: {
|
|
19
|
+
backgroundPosition: string;
|
|
20
|
+
};
|
|
21
|
+
bottom: {
|
|
22
|
+
backgroundPosition: string;
|
|
23
|
+
};
|
|
24
|
+
center: {
|
|
25
|
+
backgroundPosition: string;
|
|
26
|
+
};
|
|
27
|
+
left: {
|
|
28
|
+
backgroundPosition: string;
|
|
29
|
+
};
|
|
30
|
+
right: {
|
|
31
|
+
backgroundPosition: string;
|
|
32
|
+
};
|
|
33
|
+
'top left': {
|
|
34
|
+
backgroundPosition: string;
|
|
35
|
+
};
|
|
36
|
+
'top right': {
|
|
37
|
+
backgroundPosition: string;
|
|
38
|
+
};
|
|
39
|
+
'bottom left': {
|
|
40
|
+
backgroundPosition: string;
|
|
41
|
+
};
|
|
42
|
+
'bottom right': {
|
|
43
|
+
backgroundPosition: string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export default _default;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
scaleToFill: {
|
|
3
|
+
backgroundSize: '100% 100%',
|
|
4
|
+
},
|
|
5
|
+
aspectFit: {
|
|
6
|
+
backgroundSize: 'contain',
|
|
7
|
+
backgroundPosition: 'center',
|
|
8
|
+
},
|
|
9
|
+
widthFix: {
|
|
10
|
+
backgroundSize: '100% 100%',
|
|
11
|
+
height: 'auto',
|
|
12
|
+
lineHeight: 0,
|
|
13
|
+
},
|
|
14
|
+
aspectFill: {
|
|
15
|
+
backgroundSize: 'cover',
|
|
16
|
+
backgroundPosition: 'center',
|
|
17
|
+
},
|
|
18
|
+
top: {
|
|
19
|
+
backgroundPosition: 'top',
|
|
20
|
+
},
|
|
21
|
+
bottom: {
|
|
22
|
+
backgroundPosition: 'bottom',
|
|
23
|
+
},
|
|
24
|
+
center: {
|
|
25
|
+
backgroundPosition: 'center',
|
|
26
|
+
},
|
|
27
|
+
left: {
|
|
28
|
+
backgroundPosition: 'center left',
|
|
29
|
+
},
|
|
30
|
+
right: {
|
|
31
|
+
backgroundPosition: 'center right',
|
|
32
|
+
},
|
|
33
|
+
'top left': {
|
|
34
|
+
backgroundPosition: 'top left',
|
|
35
|
+
},
|
|
36
|
+
'top right': {
|
|
37
|
+
backgroundPosition: 'top right',
|
|
38
|
+
},
|
|
39
|
+
'bottom left': {
|
|
40
|
+
backgroundPosition: 'bottom left',
|
|
41
|
+
},
|
|
42
|
+
'bottom right': {
|
|
43
|
+
backgroundPosition: 'bottom right',
|
|
44
|
+
},
|
|
45
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ImageLoadEvent, ImageErrorEvent, TapEvent, TouchStartEvent } from '../../../types';
|
|
3
|
+
export { default as defaults } from './default';
|
|
4
|
+
interface CommonProps {
|
|
5
|
+
readonly dataset?: DOMStringMap;
|
|
6
|
+
id?: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
style?: React.CSSProperties;
|
|
9
|
+
/** 图片资源地址 */
|
|
10
|
+
src?: string;
|
|
11
|
+
/** 图片裁剪、缩放的模式 */
|
|
12
|
+
mode?: 'scaleToFill' | 'aspectFit' | 'aspectFill' | 'widthFix' | 'top' | 'bottom' | 'center' | 'left' | 'right' | 'top left' | 'top right' | 'bottom left' | 'bottom right';
|
|
13
|
+
}
|
|
14
|
+
export default interface ImageProps extends CommonProps, React.AriaAttributes {
|
|
15
|
+
/** 当图片载入完毕时触发 */
|
|
16
|
+
onLoad?: (e: ImageLoadEvent) => void;
|
|
17
|
+
/** 当错误发生时触发 */
|
|
18
|
+
onError?: (e: ImageErrorEvent) => void;
|
|
19
|
+
onTap?: (e: TapEvent) => void;
|
|
20
|
+
onTouchStart?: (e: TouchStartEvent) => void;
|
|
21
|
+
onTouchMove?: (e: TouchStartEvent) => void;
|
|
22
|
+
onTouchEnd?: (e: TouchStartEvent) => void;
|
|
23
|
+
onTouchCancel?: (e: TouchStartEvent) => void;
|
|
24
|
+
}
|
|
25
|
+
export interface ImageWebProps extends CommonProps, React.HTMLAttributes<HTMLImageElement> {
|
|
26
|
+
onTap?: (e: React.MouseEvent<HTMLImageElement>) => void;
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as defaults } from './default';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { InputEvent } from '../../types';
|
|
3
|
+
import type { InputProps } from './props';
|
|
4
|
+
export type { InputProps };
|
|
5
|
+
export interface InputState {
|
|
6
|
+
value?: string;
|
|
7
|
+
controlled: boolean;
|
|
8
|
+
}
|
|
9
|
+
export default class Input extends React.Component<InputProps, InputState> {
|
|
10
|
+
static defaultProps: {
|
|
11
|
+
'toutiao-selection-end': number;
|
|
12
|
+
'toutiao-selection-start': number;
|
|
13
|
+
'wechat-placeholder-class': string;
|
|
14
|
+
'wechat-cursor-spacing': number;
|
|
15
|
+
'wechat-confirm-type': string;
|
|
16
|
+
'wechat-confirm-hold': boolean;
|
|
17
|
+
'wechat-selection-end': number;
|
|
18
|
+
'wechat-selection-start': number;
|
|
19
|
+
'wechat-adjust-position': boolean;
|
|
20
|
+
'wechat-hold-keyboard': boolean;
|
|
21
|
+
};
|
|
22
|
+
state: InputState;
|
|
23
|
+
constructor(props: InputProps);
|
|
24
|
+
componentDidUpdate(): void;
|
|
25
|
+
handleInput: (e: InputEvent) => any;
|
|
26
|
+
render(): React.DetailedReactHTMLElement<any, HTMLElement>;
|
|
27
|
+
}
|