@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.
Files changed (259) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +3 -0
  3. package/cjs/api/index.ali.d.ts +1 -0
  4. package/cjs/api/index.ali.js +9 -0
  5. package/cjs/api/index.d.ts +1 -0
  6. package/cjs/api/index.js +9 -0
  7. package/cjs/api/index.toutiao.d.ts +1 -0
  8. package/cjs/api/index.toutiao.js +9 -0
  9. package/cjs/api/index.wechat.d.ts +5 -0
  10. package/cjs/api/index.wechat.js +9 -0
  11. package/cjs/components/Modal.d.ts +2 -0
  12. package/cjs/components/Modal.js +8 -0
  13. package/cjs/components/Modal.web.d.ts +2 -0
  14. package/cjs/components/Modal.web.js +41 -0
  15. package/cjs/constants.d.ts +1 -0
  16. package/cjs/constants.js +4 -0
  17. package/cjs/createHostComponent.d.ts +18 -0
  18. package/cjs/createHostComponent.js +205 -0
  19. package/cjs/hostComponents/Button/index.d.ts +24 -0
  20. package/cjs/hostComponents/Button/index.js +10 -0
  21. package/cjs/hostComponents/Button/index.web.d.ts +5 -0
  22. package/cjs/hostComponents/Button/index.web.js +57 -0
  23. package/cjs/hostComponents/Button/props/alias/index.d.ts +4 -0
  24. package/cjs/hostComponents/Button/props/alias/index.js +5 -0
  25. package/cjs/hostComponents/Button/props/default/index.d.ts +2 -0
  26. package/cjs/hostComponents/Button/props/default/index.js +3 -0
  27. package/cjs/hostComponents/Button/props/default/index.wechat.d.ts +6 -0
  28. package/cjs/hostComponents/Button/props/default/index.wechat.js +7 -0
  29. package/cjs/hostComponents/Button/props/index.d.ts +27 -0
  30. package/cjs/hostComponents/Button/props/index.js +10 -0
  31. package/cjs/hostComponents/Form/index.d.ts +5 -0
  32. package/cjs/hostComponents/Form/index.js +9 -0
  33. package/cjs/hostComponents/Form/index.web.d.ts +5 -0
  34. package/cjs/hostComponents/Form/index.web.js +29 -0
  35. package/cjs/hostComponents/Form/props/default/index.d.ts +2 -0
  36. package/cjs/hostComponents/Form/props/default/index.js +3 -0
  37. package/cjs/hostComponents/Form/props/default/index.wechat.d.ts +5 -0
  38. package/cjs/hostComponents/Form/props/default/index.wechat.js +6 -0
  39. package/cjs/hostComponents/Form/props/index.d.ts +15 -0
  40. package/cjs/hostComponents/Form/props/index.js +8 -0
  41. package/cjs/hostComponents/Image/index.d.ts +5 -0
  42. package/cjs/hostComponents/Image/index.js +9 -0
  43. package/cjs/hostComponents/Image/index.web.d.ts +5 -0
  44. package/cjs/hostComponents/Image/index.web.js +54 -0
  45. package/cjs/hostComponents/Image/modeStyle.d.ts +46 -0
  46. package/cjs/hostComponents/Image/modeStyle.js +47 -0
  47. package/cjs/hostComponents/Image/props/default/index.d.ts +2 -0
  48. package/cjs/hostComponents/Image/props/default/index.js +3 -0
  49. package/cjs/hostComponents/Image/props/default/index.wechat.d.ts +7 -0
  50. package/cjs/hostComponents/Image/props/default/index.wechat.js +8 -0
  51. package/cjs/hostComponents/Image/props/index.d.ts +27 -0
  52. package/cjs/hostComponents/Image/props/index.js +8 -0
  53. package/cjs/hostComponents/Input/index.d.ts +27 -0
  54. package/cjs/hostComponents/Input/index.js +86 -0
  55. package/cjs/hostComponents/Input/index.web.d.ts +5 -0
  56. package/cjs/hostComponents/Input/index.web.js +58 -0
  57. package/cjs/hostComponents/Input/props/alias/index.d.ts +4 -0
  58. package/cjs/hostComponents/Input/props/alias/index.js +5 -0
  59. package/cjs/hostComponents/Input/props/index.d.ts +35 -0
  60. package/cjs/hostComponents/Input/props/index.js +2 -0
  61. package/cjs/hostComponents/Label/index.d.ts +5 -0
  62. package/cjs/hostComponents/Label/index.js +8 -0
  63. package/cjs/hostComponents/Label/index.web.d.ts +5 -0
  64. package/cjs/hostComponents/Label/index.web.js +29 -0
  65. package/cjs/hostComponents/Label/props.d.ts +9 -0
  66. package/cjs/hostComponents/Label/props.js +2 -0
  67. package/cjs/hostComponents/Navigator/index.d.ts +5 -0
  68. package/cjs/hostComponents/Navigator/index.js +9 -0
  69. package/cjs/hostComponents/Navigator/index.web.d.ts +5 -0
  70. package/cjs/hostComponents/Navigator/index.web.js +64 -0
  71. package/cjs/hostComponents/Navigator/props/default/index.d.ts +2 -0
  72. package/cjs/hostComponents/Navigator/props/default/index.js +3 -0
  73. package/cjs/hostComponents/Navigator/props/default/index.wechat.d.ts +10 -0
  74. package/cjs/hostComponents/Navigator/props/default/index.wechat.js +11 -0
  75. package/cjs/hostComponents/Navigator/props/index.d.ts +22 -0
  76. package/cjs/hostComponents/Navigator/props/index.js +8 -0
  77. package/cjs/hostComponents/Text/index.d.ts +5 -0
  78. package/cjs/hostComponents/Text/index.js +9 -0
  79. package/cjs/hostComponents/Text/index.web.d.ts +5 -0
  80. package/cjs/hostComponents/Text/index.web.js +74 -0
  81. package/cjs/hostComponents/Text/props/default/index.d.ts +2 -0
  82. package/cjs/hostComponents/Text/props/default/index.js +3 -0
  83. package/cjs/hostComponents/Text/props/default/index.wechat.d.ts +5 -0
  84. package/cjs/hostComponents/Text/props/default/index.wechat.js +6 -0
  85. package/cjs/hostComponents/Text/props/index.d.ts +18 -0
  86. package/cjs/hostComponents/Text/props/index.js +8 -0
  87. package/cjs/hostComponents/Textarea/index.d.ts +29 -0
  88. package/cjs/hostComponents/Textarea/index.js +80 -0
  89. package/cjs/hostComponents/Textarea/index.web.d.ts +4 -0
  90. package/cjs/hostComponents/Textarea/index.web.js +64 -0
  91. package/cjs/hostComponents/Textarea/props/alias.d.ts +4 -0
  92. package/cjs/hostComponents/Textarea/props/alias.js +5 -0
  93. package/cjs/hostComponents/Textarea/props/index.d.ts +30 -0
  94. package/cjs/hostComponents/Textarea/props/index.js +8 -0
  95. package/cjs/hostComponents/View/index.d.ts +5 -0
  96. package/cjs/hostComponents/View/index.js +9 -0
  97. package/cjs/hostComponents/View/index.web.d.ts +5 -0
  98. package/cjs/hostComponents/View/index.web.js +57 -0
  99. package/cjs/hostComponents/View/props/default/index.d.ts +2 -0
  100. package/cjs/hostComponents/View/props/default/index.js +3 -0
  101. package/cjs/hostComponents/View/props/default/index.wechat.d.ts +7 -0
  102. package/cjs/hostComponents/View/props/default/index.wechat.js +8 -0
  103. package/cjs/hostComponents/View/props/index.d.ts +27 -0
  104. package/cjs/hostComponents/View/props/index.js +8 -0
  105. package/cjs/hostComponents/WebView/index.d.ts +9 -0
  106. package/cjs/hostComponents/WebView/index.js +8 -0
  107. package/cjs/hostComponents/WebView/index.web.d.ts +10 -0
  108. package/cjs/hostComponents/WebView/index.web.js +56 -0
  109. package/cjs/hostComponents/index.d.ts +20 -0
  110. package/cjs/hostComponents/index.js +50 -0
  111. package/cjs/hostComponents/useWebTouch.d.ts +18 -0
  112. package/cjs/hostComponents/useWebTouch.js +95 -0
  113. package/cjs/index.d.ts +4 -0
  114. package/cjs/index.js +25 -0
  115. package/cjs/types/event.d.ts +64 -0
  116. package/cjs/types/event.js +2 -0
  117. package/cjs/types/index.d.ts +1 -0
  118. package/cjs/types/index.js +17 -0
  119. package/cjs/useWebPlaceholderStyle/index.d.ts +2 -0
  120. package/cjs/useWebPlaceholderStyle/index.js +50 -0
  121. package/cjs/useWebPlaceholderStyle/plainStyle/CSSProperty.d.ts +6 -0
  122. package/cjs/useWebPlaceholderStyle/plainStyle/CSSProperty.js +71 -0
  123. package/cjs/useWebPlaceholderStyle/plainStyle/index.d.ts +3 -0
  124. package/cjs/useWebPlaceholderStyle/plainStyle/index.js +48 -0
  125. package/cjs/utils/isPlatformSpecifyProp.d.ts +3 -0
  126. package/cjs/utils/isPlatformSpecifyProp.js +22 -0
  127. package/cjs/utils/literalText.d.ts +2 -0
  128. package/cjs/utils/literalText.js +20 -0
  129. package/esm/api/index.ali.d.ts +1 -0
  130. package/esm/api/index.ali.js +1 -0
  131. package/esm/api/index.d.ts +1 -0
  132. package/esm/api/index.js +1 -0
  133. package/esm/api/index.toutiao.d.ts +1 -0
  134. package/esm/api/index.toutiao.js +1 -0
  135. package/esm/api/index.wechat.d.ts +5 -0
  136. package/esm/api/index.wechat.js +6 -0
  137. package/esm/components/Modal.d.ts +2 -0
  138. package/esm/components/Modal.js +5 -0
  139. package/esm/components/Modal.web.d.ts +2 -0
  140. package/esm/components/Modal.web.js +12 -0
  141. package/esm/constants.d.ts +1 -0
  142. package/esm/constants.js +1 -0
  143. package/esm/createHostComponent.d.ts +18 -0
  144. package/esm/createHostComponent.js +166 -0
  145. package/esm/hostComponents/Button/index.d.ts +24 -0
  146. package/esm/hostComponents/Button/index.js +5 -0
  147. package/esm/hostComponents/Button/index.web.d.ts +5 -0
  148. package/esm/hostComponents/Button/index.web.js +29 -0
  149. package/esm/hostComponents/Button/props/alias/index.d.ts +4 -0
  150. package/esm/hostComponents/Button/props/alias/index.js +3 -0
  151. package/esm/hostComponents/Button/props/default/index.d.ts +2 -0
  152. package/esm/hostComponents/Button/props/default/index.js +1 -0
  153. package/esm/hostComponents/Button/props/default/index.wechat.d.ts +6 -0
  154. package/esm/hostComponents/Button/props/default/index.wechat.js +5 -0
  155. package/esm/hostComponents/Button/props/index.d.ts +27 -0
  156. package/esm/hostComponents/Button/props/index.js +2 -0
  157. package/esm/hostComponents/Form/index.d.ts +5 -0
  158. package/esm/hostComponents/Form/index.js +4 -0
  159. package/esm/hostComponents/Form/index.web.d.ts +5 -0
  160. package/esm/hostComponents/Form/index.web.js +4 -0
  161. package/esm/hostComponents/Form/props/default/index.d.ts +2 -0
  162. package/esm/hostComponents/Form/props/default/index.js +1 -0
  163. package/esm/hostComponents/Form/props/default/index.wechat.d.ts +5 -0
  164. package/esm/hostComponents/Form/props/default/index.wechat.js +4 -0
  165. package/esm/hostComponents/Form/props/index.d.ts +15 -0
  166. package/esm/hostComponents/Form/props/index.js +1 -0
  167. package/esm/hostComponents/Image/index.d.ts +5 -0
  168. package/esm/hostComponents/Image/index.js +4 -0
  169. package/esm/hostComponents/Image/index.web.d.ts +5 -0
  170. package/esm/hostComponents/Image/index.web.js +26 -0
  171. package/esm/hostComponents/Image/modeStyle.d.ts +46 -0
  172. package/esm/hostComponents/Image/modeStyle.js +45 -0
  173. package/esm/hostComponents/Image/props/default/index.d.ts +2 -0
  174. package/esm/hostComponents/Image/props/default/index.js +1 -0
  175. package/esm/hostComponents/Image/props/default/index.wechat.d.ts +7 -0
  176. package/esm/hostComponents/Image/props/default/index.wechat.js +6 -0
  177. package/esm/hostComponents/Image/props/index.d.ts +27 -0
  178. package/esm/hostComponents/Image/props/index.js +1 -0
  179. package/esm/hostComponents/Input/index.d.ts +27 -0
  180. package/esm/hostComponents/Input/index.js +80 -0
  181. package/esm/hostComponents/Input/index.web.d.ts +5 -0
  182. package/esm/hostComponents/Input/index.web.js +30 -0
  183. package/esm/hostComponents/Input/props/alias/index.d.ts +4 -0
  184. package/esm/hostComponents/Input/props/alias/index.js +3 -0
  185. package/esm/hostComponents/Input/props/index.d.ts +35 -0
  186. package/esm/hostComponents/Input/props/index.js +1 -0
  187. package/esm/hostComponents/Label/index.d.ts +5 -0
  188. package/esm/hostComponents/Label/index.js +3 -0
  189. package/esm/hostComponents/Label/index.web.d.ts +5 -0
  190. package/esm/hostComponents/Label/index.web.js +4 -0
  191. package/esm/hostComponents/Label/props.d.ts +9 -0
  192. package/esm/hostComponents/Label/props.js +1 -0
  193. package/esm/hostComponents/Navigator/index.d.ts +5 -0
  194. package/esm/hostComponents/Navigator/index.js +4 -0
  195. package/esm/hostComponents/Navigator/index.web.d.ts +5 -0
  196. package/esm/hostComponents/Navigator/index.web.js +36 -0
  197. package/esm/hostComponents/Navigator/props/default/index.d.ts +2 -0
  198. package/esm/hostComponents/Navigator/props/default/index.js +1 -0
  199. package/esm/hostComponents/Navigator/props/default/index.wechat.d.ts +10 -0
  200. package/esm/hostComponents/Navigator/props/default/index.wechat.js +9 -0
  201. package/esm/hostComponents/Navigator/props/index.d.ts +22 -0
  202. package/esm/hostComponents/Navigator/props/index.js +1 -0
  203. package/esm/hostComponents/Text/index.d.ts +5 -0
  204. package/esm/hostComponents/Text/index.js +4 -0
  205. package/esm/hostComponents/Text/index.web.d.ts +5 -0
  206. package/esm/hostComponents/Text/index.web.js +46 -0
  207. package/esm/hostComponents/Text/props/default/index.d.ts +2 -0
  208. package/esm/hostComponents/Text/props/default/index.js +1 -0
  209. package/esm/hostComponents/Text/props/default/index.wechat.d.ts +5 -0
  210. package/esm/hostComponents/Text/props/default/index.wechat.js +4 -0
  211. package/esm/hostComponents/Text/props/index.d.ts +18 -0
  212. package/esm/hostComponents/Text/props/index.js +1 -0
  213. package/esm/hostComponents/Textarea/index.d.ts +29 -0
  214. package/esm/hostComponents/Textarea/index.js +74 -0
  215. package/esm/hostComponents/Textarea/index.web.d.ts +4 -0
  216. package/esm/hostComponents/Textarea/index.web.js +36 -0
  217. package/esm/hostComponents/Textarea/props/alias.d.ts +4 -0
  218. package/esm/hostComponents/Textarea/props/alias.js +3 -0
  219. package/esm/hostComponents/Textarea/props/index.d.ts +30 -0
  220. package/esm/hostComponents/Textarea/props/index.js +1 -0
  221. package/esm/hostComponents/View/index.d.ts +5 -0
  222. package/esm/hostComponents/View/index.js +4 -0
  223. package/esm/hostComponents/View/index.web.d.ts +5 -0
  224. package/esm/hostComponents/View/index.web.js +29 -0
  225. package/esm/hostComponents/View/props/default/index.d.ts +2 -0
  226. package/esm/hostComponents/View/props/default/index.js +1 -0
  227. package/esm/hostComponents/View/props/default/index.wechat.d.ts +7 -0
  228. package/esm/hostComponents/View/props/default/index.wechat.js +6 -0
  229. package/esm/hostComponents/View/props/index.d.ts +27 -0
  230. package/esm/hostComponents/View/props/index.js +1 -0
  231. package/esm/hostComponents/WebView/index.d.ts +9 -0
  232. package/esm/hostComponents/WebView/index.js +3 -0
  233. package/esm/hostComponents/WebView/index.web.d.ts +10 -0
  234. package/esm/hostComponents/WebView/index.web.js +28 -0
  235. package/esm/hostComponents/index.d.ts +20 -0
  236. package/esm/hostComponents/index.js +20 -0
  237. package/esm/hostComponents/useWebTouch.d.ts +18 -0
  238. package/esm/hostComponents/useWebTouch.js +70 -0
  239. package/esm/index.d.ts +4 -0
  240. package/esm/index.js +4 -0
  241. package/esm/types/event.d.ts +64 -0
  242. package/esm/types/event.js +1 -0
  243. package/esm/types/index.d.ts +1 -0
  244. package/esm/types/index.js +1 -0
  245. package/esm/useWebPlaceholderStyle/index.d.ts +2 -0
  246. package/esm/useWebPlaceholderStyle/index.js +21 -0
  247. package/esm/useWebPlaceholderStyle/plainStyle/CSSProperty.d.ts +6 -0
  248. package/esm/useWebPlaceholderStyle/plainStyle/CSSProperty.js +68 -0
  249. package/esm/useWebPlaceholderStyle/plainStyle/index.d.ts +3 -0
  250. package/esm/useWebPlaceholderStyle/plainStyle/index.js +46 -0
  251. package/esm/utils/isPlatformSpecifyProp.d.ts +3 -0
  252. package/esm/utils/isPlatformSpecifyProp.js +18 -0
  253. package/esm/utils/literalText.d.ts +2 -0
  254. package/esm/utils/literalText.js +15 -0
  255. package/node.js +1 -0
  256. package/package.json +45 -0
  257. package/scripts/postbuild.js +17 -0
  258. package/typings/index.d.ts +0 -0
  259. 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,5 @@
1
+ import * as React from 'react';
2
+ import { InputWebProps } from './props';
3
+ export type InputProps = InputWebProps;
4
+ declare const _default: React.ForwardRefExoticComponent<InputWebProps & React.RefAttributes<any>>;
5
+ export default _default;
@@ -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,4 @@
1
+ declare const _default: {
2
+ maxLength: string;
3
+ };
4
+ export default _default;
@@ -0,0 +1,3 @@
1
+ export default {
2
+ maxLength: 'maxlength',
3
+ };
@@ -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,5 @@
1
+ import React from 'react';
2
+ import { LabelProps } from './props';
3
+ export type { LabelProps };
4
+ declare const Label: React.ComponentType<LabelProps>;
5
+ export default Label;
@@ -0,0 +1,3 @@
1
+ import createHostComponent from '../../createHostComponent';
2
+ const Label = createHostComponent('label', { htmlFor: 'for' });
3
+ export default Label;
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import { LabelProps } from './props';
3
+ export type { LabelProps };
4
+ declare const _default: React.ForwardRefExoticComponent<LabelProps & React.RefAttributes<any>>;
5
+ export default _default;
@@ -0,0 +1,4 @@
1
+ import * as React from 'react';
2
+ import { filterProps } from '../../utils/isPlatformSpecifyProp';
3
+ const Label = (props, ref) => (React.createElement("label", Object.assign({}, filterProps(props), { ref: ref })));
4
+ export default React.forwardRef(Label);
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+ export interface LabelProps extends React.AriaAttributes {
3
+ readonly dataset?: DOMStringMap;
4
+ id?: string;
5
+ className?: string;
6
+ style?: React.CSSProperties;
7
+ /** 绑定控件的 id */
8
+ htmlFor?: string;
9
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { NavigatorProps } from './props';
3
+ export type { NavigatorProps };
4
+ declare const Navigator: React.ComponentType<NavigatorProps>;
5
+ export default Navigator;
@@ -0,0 +1,4 @@
1
+ import createHostComponent from '../../createHostComponent';
2
+ import defaults from './props/default';
3
+ const Navigator = createHostComponent('navigator', null, defaults);
4
+ export default Navigator;
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import { NavigatorProps } from './props';
3
+ export type { NavigatorProps };
4
+ declare const _default: React.ForwardRefExoticComponent<NavigatorProps & React.RefAttributes<any>>;
5
+ export default _default;
@@ -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,2 @@
1
+ declare const _default: {};
2
+ export default _default;
@@ -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,9 @@
1
+ export default {
2
+ 'wechat-target': 'self',
3
+ 'wechat-open-type': 'navigate',
4
+ 'wechat-delta': 1,
5
+ hoverClassName: 'navigator-hover',
6
+ 'wechat-hover-stop-propagation': false,
7
+ hoverStartTime: 50,
8
+ hoverStayTime: 600,
9
+ };
@@ -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,5 @@
1
+ import React from 'react';
2
+ import TextProps from './props';
3
+ export type { TextProps };
4
+ declare const Text: React.ComponentType<TextProps>;
5
+ export default Text;
@@ -0,0 +1,4 @@
1
+ import createHostComponent from '../../createHostComponent';
2
+ import defaults from './props/default';
3
+ const Text = createHostComponent('text', null, defaults);
4
+ export default Text;
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import { TextWebProps } from './props';
3
+ export type TextProps = TextWebProps;
4
+ declare const _default: React.ForwardRefExoticComponent<TextWebProps & React.RefAttributes<any>>;
5
+ export default _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,2 @@
1
+ declare const _default: {};
2
+ export default _default;
@@ -0,0 +1 @@
1
+ export default {};
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ selectable: boolean;
3
+ 'wechat-decode': boolean;
4
+ };
5
+ export default _default;
@@ -0,0 +1,4 @@
1
+ export default {
2
+ selectable: false,
3
+ 'wechat-decode': false,
4
+ };
@@ -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,4 @@
1
+ import * as React from 'react';
2
+ import { TextareaWebProps } from './props';
3
+ declare const _default: React.ForwardRefExoticComponent<TextareaWebProps & React.RefAttributes<any>>;
4
+ export default _default;
@@ -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,4 @@
1
+ declare const _default: {
2
+ maxLength: string;
3
+ };
4
+ export default _default;
@@ -0,0 +1,3 @@
1
+ export default {
2
+ maxLength: 'maxlength',
3
+ };
@@ -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';
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import ViewProps from './props';
3
+ export type { ViewProps };
4
+ declare const View: React.ComponentType<ViewProps>;
5
+ export default View;
@@ -0,0 +1,4 @@
1
+ import createHostComponent from '../../createHostComponent';
2
+ import defaults from './props/default';
3
+ const View = createHostComponent('view', null, defaults);
4
+ export default View;
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import { ViewWebProps } from './props';
3
+ export type ViewProps = ViewWebProps;
4
+ declare const _default: React.ForwardRefExoticComponent<ViewWebProps & React.RefAttributes<any>>;
5
+ export default _default;