@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,80 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import memoizeOne from 'memoize-one';
|
|
3
|
+
import { aliasProps, createCallback, createInputEvent } from '../../createHostComponent';
|
|
4
|
+
import alias from './props/alias';
|
|
5
|
+
const createInputCallback = memoizeOne(createCallback);
|
|
6
|
+
const createConfirmCallback = memoizeOne(createCallback);
|
|
7
|
+
const createFocusCallback = memoizeOne(createCallback);
|
|
8
|
+
const createBlurCallback = memoizeOne(createCallback);
|
|
9
|
+
export default class Input extends React.Component {
|
|
10
|
+
constructor(props) {
|
|
11
|
+
super(props);
|
|
12
|
+
this.state = {
|
|
13
|
+
value: '',
|
|
14
|
+
// 阿里
|
|
15
|
+
controlled: false,
|
|
16
|
+
};
|
|
17
|
+
this.handleInput = (e) => {
|
|
18
|
+
const { controlled } = this.state;
|
|
19
|
+
if (typeof this.props.onInput === 'function') {
|
|
20
|
+
return this.props.onInput(e);
|
|
21
|
+
}
|
|
22
|
+
// 微信
|
|
23
|
+
// 注意,微信要对 input 受控,必须要在 onInput 方法返回值
|
|
24
|
+
return controlled ? this.props.value : undefined;
|
|
25
|
+
};
|
|
26
|
+
const controlled = props.value !== undefined;
|
|
27
|
+
const value = controlled ? props.value : props.defaultValue;
|
|
28
|
+
this.state = {
|
|
29
|
+
value,
|
|
30
|
+
controlled,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
componentDidUpdate() {
|
|
34
|
+
if (this.props.value !== undefined && this.props.value !== this.state.value) {
|
|
35
|
+
this.setState({ value: this.props.value });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
render() {
|
|
39
|
+
var _a, _b, _c, _d, _e, _f;
|
|
40
|
+
const inputProps = Object.assign({}, this.props);
|
|
41
|
+
if (inputProps.onInput) {
|
|
42
|
+
inputProps.onInput = createInputCallback(this.handleInput, createInputEvent);
|
|
43
|
+
}
|
|
44
|
+
if (inputProps.onConfirm) {
|
|
45
|
+
inputProps.onConfirm = createConfirmCallback(this.props.onConfirm, createInputEvent);
|
|
46
|
+
}
|
|
47
|
+
if (inputProps.onFocus) {
|
|
48
|
+
inputProps.onFocus = createFocusCallback(this.props.onFocus, createInputEvent);
|
|
49
|
+
}
|
|
50
|
+
if (inputProps.onBlur) {
|
|
51
|
+
inputProps.onBlur = createBlurCallback(this.props.onBlur, createInputEvent);
|
|
52
|
+
}
|
|
53
|
+
// 通用属性的默认属性根据平台在这里设置
|
|
54
|
+
if (process.env.RSMAX_PLATFORM === 'toutiao') {
|
|
55
|
+
inputProps.maxLength = (_a = inputProps.maxLength) !== null && _a !== void 0 ? _a : 140;
|
|
56
|
+
}
|
|
57
|
+
if (process.env.RSMAX_PLATFORM === 'wechat') {
|
|
58
|
+
inputProps.type = (_b = inputProps.type) !== null && _b !== void 0 ? _b : 'text';
|
|
59
|
+
inputProps.password = (_c = inputProps.password) !== null && _c !== void 0 ? _c : false;
|
|
60
|
+
inputProps.disabled = (_d = inputProps.disabled) !== null && _d !== void 0 ? _d : false;
|
|
61
|
+
inputProps.focus = (_e = inputProps.focus) !== null && _e !== void 0 ? _e : false;
|
|
62
|
+
inputProps.maxLength = (_f = inputProps.maxLength) !== null && _f !== void 0 ? _f : 140;
|
|
63
|
+
}
|
|
64
|
+
const nextProps = aliasProps(Object.assign(Object.assign({}, inputProps), this.state), alias);
|
|
65
|
+
return React.createElement('input', nextProps);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// 平台独有的属性默认值写在这
|
|
69
|
+
Input.defaultProps = {
|
|
70
|
+
'toutiao-selection-end': 999,
|
|
71
|
+
'toutiao-selection-start': 999,
|
|
72
|
+
'wechat-placeholder-class': 'input-placeholder',
|
|
73
|
+
'wechat-cursor-spacing': 0,
|
|
74
|
+
'wechat-confirm-type': 'done',
|
|
75
|
+
'wechat-confirm-hold': false,
|
|
76
|
+
'wechat-selection-end': -1,
|
|
77
|
+
'wechat-selection-start': -1,
|
|
78
|
+
'wechat-adjust-position': true,
|
|
79
|
+
'wechat-hold-keyboard': false,
|
|
80
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
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 useWebPlaceholderStyle from '../../useWebPlaceholderStyle';
|
|
15
|
+
import clsx from 'clsx';
|
|
16
|
+
const Input = (props, ref) => {
|
|
17
|
+
const _a = filterProps(props), { password, type, onConfirm, onKeyPress, placeholderStyle, className } = _a, restProps = __rest(_a, ["password", "type", "onConfirm", "onKeyPress", "placeholderStyle", "className"]);
|
|
18
|
+
const [placeholderStyleClassName] = useWebPlaceholderStyle(placeholderStyle);
|
|
19
|
+
const inputType = password ? 'password' : type;
|
|
20
|
+
function handleKeyPress(e) {
|
|
21
|
+
if (e.key === 'Enter' && typeof onConfirm === 'function') {
|
|
22
|
+
onConfirm(e);
|
|
23
|
+
}
|
|
24
|
+
if (typeof onKeyPress === 'function') {
|
|
25
|
+
onKeyPress(e);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return (React.createElement("input", Object.assign({}, restProps, { ref: ref, type: inputType, onKeyPress: handleKeyPress, className: clsx('remax-input', className, placeholderStyleClassName) })));
|
|
29
|
+
};
|
|
30
|
+
export default React.forwardRef(Input);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { InputEvent } from '../../../types';
|
|
3
|
+
interface CommonProps {
|
|
4
|
+
readonly dataset?: DOMStringMap;
|
|
5
|
+
id?: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
/** 输入框的初始内容 */
|
|
9
|
+
defaultValue?: string;
|
|
10
|
+
value?: string;
|
|
11
|
+
name?: string;
|
|
12
|
+
/** input 的类型 */
|
|
13
|
+
type?: 'text' | 'number' | 'digit' | 'idcard';
|
|
14
|
+
/** 是否是密码类型 */
|
|
15
|
+
password?: boolean;
|
|
16
|
+
/** 输入框为空时占位符 */
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
placeholderStyle?: React.CSSProperties;
|
|
19
|
+
/** 是否禁用 */
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
/** 最大输入长度,设置为 -1 的时候不限制最大长度 */
|
|
22
|
+
maxLength?: number;
|
|
23
|
+
/** 获取焦点 */
|
|
24
|
+
focus?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface InputProps extends CommonProps {
|
|
27
|
+
onInput?: (e: InputEvent) => any;
|
|
28
|
+
onConfirm?: (e: InputEvent) => void;
|
|
29
|
+
onFocus?: (e: InputEvent) => void;
|
|
30
|
+
onBlur?: (e: InputEvent) => void;
|
|
31
|
+
}
|
|
32
|
+
export interface InputWebProps extends Omit<CommonProps, 'defaultValue'>, React.HTMLAttributes<HTMLInputElement> {
|
|
33
|
+
onConfirm?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
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 { RuntimeOptions } from '@rsmax/framework-shared';
|
|
15
|
+
import { filterProps } from '../../utils/isPlatformSpecifyProp';
|
|
16
|
+
const Navigator = (props, ref) => {
|
|
17
|
+
const _a = filterProps(props), { className, url, action, hoverClassName, hoverStartTime, hoverStayTime } = _a, restProps = __rest(_a, ["className", "url", "action", "hoverClassName", "hoverStartTime", "hoverStayTime"]);
|
|
18
|
+
const history = RuntimeOptions.get('history');
|
|
19
|
+
function handleTap() {
|
|
20
|
+
switch (action) {
|
|
21
|
+
case 'reLaunch':
|
|
22
|
+
window.location.href = window.location.hostname + url;
|
|
23
|
+
break;
|
|
24
|
+
case 'redirect':
|
|
25
|
+
history.replace(url);
|
|
26
|
+
break;
|
|
27
|
+
case 'navigate':
|
|
28
|
+
case 'switchTab':
|
|
29
|
+
default:
|
|
30
|
+
history.push(url);
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return React.createElement("div", Object.assign({}, restProps, { className: clsx(className), onClick: handleTap }));
|
|
35
|
+
};
|
|
36
|
+
export default React.forwardRef(Navigator);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
'wechat-target': string;
|
|
3
|
+
'wechat-open-type': string;
|
|
4
|
+
'wechat-delta': number;
|
|
5
|
+
hoverClassName: string;
|
|
6
|
+
'wechat-hover-stop-propagation': boolean;
|
|
7
|
+
hoverStartTime: number;
|
|
8
|
+
hoverStayTime: number;
|
|
9
|
+
};
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export { default as defaults } from './default';
|
|
3
|
+
export interface NavigatorProps {
|
|
4
|
+
readonly dataset?: DOMStringMap;
|
|
5
|
+
id?: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
url: string;
|
|
9
|
+
action: 'navigate' | 'redirect' | 'switchTab' | 'reLaunch';
|
|
10
|
+
/**
|
|
11
|
+
* 指定点击时的样式类
|
|
12
|
+
*/
|
|
13
|
+
hoverClassName?: string;
|
|
14
|
+
/**
|
|
15
|
+
* 按住后多久出现点击态,单位毫秒
|
|
16
|
+
*/
|
|
17
|
+
hoverStartTime?: number;
|
|
18
|
+
/**
|
|
19
|
+
* 手指松开后点击态保留时间,单位毫秒
|
|
20
|
+
*/
|
|
21
|
+
hoverStayTime?: number;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as defaults } from './default';
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
const Text = (props, ref) => {
|
|
16
|
+
const _a = filterProps(props), { onTap, onTouchStart, onTouchMove, onTouchEnd, onTouchCancel, className, selectable } = _a, restProps = __rest(_a, ["onTap", "onTouchStart", "onTouchMove", "onTouchEnd", "onTouchCancel", "className", "selectable"]);
|
|
17
|
+
const hoveringRef = React.useRef(false);
|
|
18
|
+
function handleTouchStart(e) {
|
|
19
|
+
hoveringRef.current = true;
|
|
20
|
+
if (typeof onTouchStart === 'function') {
|
|
21
|
+
return onTouchStart(e);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function handleTouchMove(e) {
|
|
25
|
+
hoveringRef.current = false;
|
|
26
|
+
if (typeof onTouchMove === 'function') {
|
|
27
|
+
return onTouchMove(e);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function handleTouchEnd(e) {
|
|
31
|
+
hoveringRef.current = false;
|
|
32
|
+
if (typeof onTouchEnd === 'function') {
|
|
33
|
+
return onTouchEnd(e);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function handleTouchCancel(e) {
|
|
37
|
+
hoveringRef.current = false;
|
|
38
|
+
if (typeof onTouchCancel === 'function') {
|
|
39
|
+
return onTouchCancel(e);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return (React.createElement("span", Object.assign({}, restProps, { className: clsx(className, {
|
|
43
|
+
'remax-text-selectable': selectable,
|
|
44
|
+
}), ref: ref, onClick: onTap, onTouchStart: handleTouchStart, onTouchMove: handleTouchMove, onTouchEnd: handleTouchEnd, onTouchCancel: handleTouchCancel })));
|
|
45
|
+
};
|
|
46
|
+
export default React.forwardRef(Text);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { TapEvent } from '../../../types';
|
|
2
|
+
import React from 'react';
|
|
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
|
+
selectable?: boolean;
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
}
|
|
13
|
+
export default interface TextProps extends CommonProps, React.AriaAttributes {
|
|
14
|
+
onTap?: (event: TapEvent) => void;
|
|
15
|
+
}
|
|
16
|
+
export interface TextWebProps extends CommonProps, React.HTMLAttributes<HTMLSpanElement> {
|
|
17
|
+
onTap?: (event: React.MouseEvent<HTMLSpanElement>) => void;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as defaults } from './default';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { InputEvent } from '../../types';
|
|
3
|
+
import { TextareaProps } from './props';
|
|
4
|
+
export type { TextareaProps };
|
|
5
|
+
export interface TextareaState {
|
|
6
|
+
value?: string;
|
|
7
|
+
controlled: boolean;
|
|
8
|
+
}
|
|
9
|
+
export default class Textarea extends React.Component<TextareaProps, TextareaState> {
|
|
10
|
+
static defaultProps: {
|
|
11
|
+
'toutiao-selection-end': number;
|
|
12
|
+
'toutiao-selection-start': number;
|
|
13
|
+
'wechat-selection-end': number;
|
|
14
|
+
'wechat-selection-start': number;
|
|
15
|
+
'wechat-fixed': boolean;
|
|
16
|
+
'wechat-placeholder-class': string;
|
|
17
|
+
'wechat-cursor-spacing': number;
|
|
18
|
+
'wechat-cursor': number;
|
|
19
|
+
'wechat-show-confirm-bar': boolean;
|
|
20
|
+
'wechat-adjust-position': boolean;
|
|
21
|
+
'wechat-hold-keyboard': boolean;
|
|
22
|
+
'wechat-disable-default-padding': boolean;
|
|
23
|
+
};
|
|
24
|
+
state: TextareaState;
|
|
25
|
+
constructor(props: TextareaProps);
|
|
26
|
+
componentDidUpdate(): void;
|
|
27
|
+
handleInput: (e: InputEvent) => any;
|
|
28
|
+
render(): React.DetailedReactHTMLElement<any, HTMLElement>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { aliasProps, createCallback, createInputEvent } from '../../createHostComponent';
|
|
3
|
+
import alias from './props/alias';
|
|
4
|
+
export default class Textarea extends React.Component {
|
|
5
|
+
constructor(props) {
|
|
6
|
+
super(props);
|
|
7
|
+
this.state = {
|
|
8
|
+
value: '',
|
|
9
|
+
// 阿里
|
|
10
|
+
controlled: false,
|
|
11
|
+
};
|
|
12
|
+
this.handleInput = (e) => {
|
|
13
|
+
const { controlled } = this.state;
|
|
14
|
+
if (!controlled) {
|
|
15
|
+
this.setState({ value: e.target.value });
|
|
16
|
+
}
|
|
17
|
+
if (typeof this.props.onInput === 'function') {
|
|
18
|
+
return this.props.onInput(e);
|
|
19
|
+
}
|
|
20
|
+
// 微信
|
|
21
|
+
// 注意,微信要对 input 受控,必须要在 onInput 方法返回值
|
|
22
|
+
return controlled ? this.props.value : e.target.value;
|
|
23
|
+
};
|
|
24
|
+
const controlled = props.value !== undefined;
|
|
25
|
+
const value = controlled ? props.value : props.defaultValue;
|
|
26
|
+
this.state = {
|
|
27
|
+
value,
|
|
28
|
+
controlled,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
componentDidUpdate() {
|
|
32
|
+
if (this.props.value !== undefined && this.props.value !== this.state.value) {
|
|
33
|
+
this.setState({ value: this.props.value });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
render() {
|
|
37
|
+
var _a, _b, _c, _d, _e;
|
|
38
|
+
const inputProps = Object.assign(Object.assign({}, this.props), { onInput: createCallback(this.handleInput, createInputEvent) });
|
|
39
|
+
if (inputProps.onConfirm) {
|
|
40
|
+
inputProps.onConfirm = createCallback(this.props.onConfirm, createInputEvent);
|
|
41
|
+
}
|
|
42
|
+
if (inputProps.onFocus) {
|
|
43
|
+
inputProps.onFocus = createCallback(this.props.onFocus, createInputEvent);
|
|
44
|
+
}
|
|
45
|
+
if (inputProps.onBlur) {
|
|
46
|
+
inputProps.onBlur = createCallback(this.props.onBlur, createInputEvent);
|
|
47
|
+
}
|
|
48
|
+
if (process.env.RSMAX_PLATFORM === 'toutiao') {
|
|
49
|
+
inputProps.maxLength = (_a = inputProps.maxLength) !== null && _a !== void 0 ? _a : 140;
|
|
50
|
+
}
|
|
51
|
+
if (process.env.RSMAX_PLATFORM === 'wechat') {
|
|
52
|
+
inputProps.maxLength = (_b = inputProps.maxLength) !== null && _b !== void 0 ? _b : 140;
|
|
53
|
+
inputProps.disabled = (_c = inputProps.disabled) !== null && _c !== void 0 ? _c : false;
|
|
54
|
+
inputProps.focus = (_d = inputProps.focus) !== null && _d !== void 0 ? _d : false;
|
|
55
|
+
inputProps.autoHeight = (_e = inputProps.autoHeight) !== null && _e !== void 0 ? _e : false;
|
|
56
|
+
}
|
|
57
|
+
const nextProps = aliasProps(Object.assign(Object.assign({}, inputProps), this.state), alias);
|
|
58
|
+
return React.createElement('textarea', nextProps);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
Textarea.defaultProps = {
|
|
62
|
+
'toutiao-selection-end': 999,
|
|
63
|
+
'toutiao-selection-start': 999,
|
|
64
|
+
'wechat-selection-end': -1,
|
|
65
|
+
'wechat-selection-start': -1,
|
|
66
|
+
'wechat-fixed': false,
|
|
67
|
+
'wechat-placeholder-class': 'textarea-placeholder',
|
|
68
|
+
'wechat-cursor-spacing': 0,
|
|
69
|
+
'wechat-cursor': -1,
|
|
70
|
+
'wechat-show-confirm-bar': true,
|
|
71
|
+
'wechat-adjust-position': true,
|
|
72
|
+
'wechat-hold-keyboard': false,
|
|
73
|
+
'wechat-disable-default-padding': false,
|
|
74
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
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 TextareaAutoSize from 'react-autosize-textarea';
|
|
14
|
+
import useWebPlaceholderStyle from '../../useWebPlaceholderStyle';
|
|
15
|
+
import { filterProps } from '../../utils/isPlatformSpecifyProp';
|
|
16
|
+
import clsx from 'clsx';
|
|
17
|
+
const Textarea = (props, ref) => {
|
|
18
|
+
const _a = filterProps(props), { onConfirm, onKeyPress, autoHeight, className, placeholderStyle } = _a, restProps = __rest(_a, ["onConfirm", "onKeyPress", "autoHeight", "className", "placeholderStyle"]);
|
|
19
|
+
const [placeholderStyleClassName] = useWebPlaceholderStyle(placeholderStyle);
|
|
20
|
+
function handleKeyPress(e) {
|
|
21
|
+
if (e.key === 'Enter' && typeof onConfirm === 'function') {
|
|
22
|
+
onConfirm(e);
|
|
23
|
+
}
|
|
24
|
+
if (typeof onKeyPress === 'function') {
|
|
25
|
+
onKeyPress(e);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const textareaClassName = clsx('remax-textarea', className, placeholderStyleClassName);
|
|
29
|
+
if (autoHeight) {
|
|
30
|
+
// @ts-ignore
|
|
31
|
+
// todo 需要修正这里
|
|
32
|
+
return React.createElement(TextareaAutoSize, Object.assign({}, restProps, { className: textareaClassName, ref: ref, onKeyPress: handleKeyPress }));
|
|
33
|
+
}
|
|
34
|
+
return React.createElement("textarea", Object.assign({}, restProps, { className: textareaClassName, ref: ref, onKeyPress: handleKeyPress }));
|
|
35
|
+
};
|
|
36
|
+
export default React.forwardRef(Textarea);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { InputEvent } from '../../../types';
|
|
3
|
+
export { default as alias } from './alias';
|
|
4
|
+
interface CommonProps {
|
|
5
|
+
readonly dataset?: DOMStringMap;
|
|
6
|
+
id?: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
style?: React.CSSProperties;
|
|
9
|
+
name?: string;
|
|
10
|
+
value?: any;
|
|
11
|
+
defaultValue?: any;
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
placeholderStyle?: React.CSSProperties;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
/** 最大输入长度,设置为 -1 的时候不限制最大长度 */
|
|
16
|
+
maxLength?: number;
|
|
17
|
+
focus?: boolean;
|
|
18
|
+
/** 是否自动增高,设置auto-height时,style.height不生效 */
|
|
19
|
+
autoHeight?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface TextareaProps extends CommonProps {
|
|
22
|
+
onInput?: (event: InputEvent) => any;
|
|
23
|
+
onFocus?: (event: InputEvent) => void;
|
|
24
|
+
onBlur?: (event: InputEvent) => void;
|
|
25
|
+
onConfirm?: (event: InputEvent) => void;
|
|
26
|
+
}
|
|
27
|
+
export interface TextareaWebProps extends Omit<CommonProps, 'defaultValue'>, React.HTMLAttributes<HTMLTextAreaElement> {
|
|
28
|
+
onConfirm?: (e: React.KeyboardEvent<HTMLTextAreaElement>) => void;
|
|
29
|
+
children?: React.ReactNode;
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as alias } from './alias';
|