@sheinoutmobile/shineoutmobile 1.8.2

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.

Potentially problematic release.


This version of @sheinoutmobile/shineoutmobile might be problematic. Click here for more details.

Files changed (171) hide show
  1. package/.eslintignore +20 -0
  2. package/.eslintrc +8 -0
  3. package/.gitlab-ci.yml +53 -0
  4. package/.yarnrc +1 -0
  5. package/CHANGELOG.md +8 -0
  6. package/README.md +14 -0
  7. package/build.config.js +6 -0
  8. package/doc.config.js +16 -0
  9. package/lib/index.esm.js +5414 -0
  10. package/lib/index.esm.js.map +1 -0
  11. package/lib/index.js +8 -0
  12. package/lib/index.js.map +1 -0
  13. package/package.json +47 -0
  14. package/src/component/button/button.jsx +83 -0
  15. package/src/component/button/index.jsx +3 -0
  16. package/src/component/button/style.less +132 -0
  17. package/src/component/cell/cell.jsx +71 -0
  18. package/src/component/cell/index.jsx +3 -0
  19. package/src/component/cell/style.less +86 -0
  20. package/src/component/cell-group/cell-group.jsx +26 -0
  21. package/src/component/cell-group/index.jsx +3 -0
  22. package/src/component/cell-group/style.less +22 -0
  23. package/src/component/checkbox/checkbox.jsx +92 -0
  24. package/src/component/checkbox/index.js +3 -0
  25. package/src/component/checkbox/kind/checkbox-button.jsx +41 -0
  26. package/src/component/checkbox/style.less +49 -0
  27. package/src/component/dialog/dialog.jsx +58 -0
  28. package/src/component/dialog/index.js +3 -0
  29. package/src/component/dialog/kind/dialog-alert.jsx +22 -0
  30. package/src/component/dialog/kind/dialog-confirm.jsx +54 -0
  31. package/src/component/dialog/style.less +80 -0
  32. package/src/component/drawer/drawer.jsx +151 -0
  33. package/src/component/drawer/index.jsx +3 -0
  34. package/src/component/drawer/js/tools.js +1 -0
  35. package/src/component/drawer/style.less +17 -0
  36. package/src/component/field/field.jsx +49 -0
  37. package/src/component/field/index.js +3 -0
  38. package/src/component/icon/icon.jsx +55 -0
  39. package/src/component/icon/index.jsx +19 -0
  40. package/src/component/icon/style.less +9 -0
  41. package/src/component/icons/index.js +3 -0
  42. package/src/component/icons/mrp.js +3 -0
  43. package/src/component/image-previewer/image-previewer.jsx +54 -0
  44. package/src/component/image-previewer/index.js +3 -0
  45. package/src/component/index-sort-list/group.jsx +49 -0
  46. package/src/component/index-sort-list/index-bar.jsx +34 -0
  47. package/src/component/index-sort-list/index.js +3 -0
  48. package/src/component/index-sort-list/js/rules.js +14 -0
  49. package/src/component/index-sort-list/js/sort-rule.js +41 -0
  50. package/src/component/index-sort-list/list.jsx +110 -0
  51. package/src/component/index-sort-list/style.less +109 -0
  52. package/src/component/input/index.js +3 -0
  53. package/src/component/input/input.jsx +285 -0
  54. package/src/component/input/style.less +77 -0
  55. package/src/component/list-view/index.js +3 -0
  56. package/src/component/list-view/jsx/empty.jsx +23 -0
  57. package/src/component/list-view/list-view.jsx +165 -0
  58. package/src/component/list-view/style.less +79 -0
  59. package/src/component/loading/index.js +3 -0
  60. package/src/component/loading/loading.jsx +97 -0
  61. package/src/component/loading/styles.less +128 -0
  62. package/src/component/multiple-selector/index.jsx +3 -0
  63. package/src/component/multiple-selector/item.jsx +23 -0
  64. package/src/component/multiple-selector/multiple-selector.jsx +116 -0
  65. package/src/component/multiple-selector/selector.jsx +41 -0
  66. package/src/component/multiple-selector/style.less +78 -0
  67. package/src/component/notice-bar/index.jsx +3 -0
  68. package/src/component/notice-bar/notice-bar.jsx +86 -0
  69. package/src/component/notice-bar/style.less +72 -0
  70. package/src/component/notify/index.js +37 -0
  71. package/src/component/notify/notify.jsx +125 -0
  72. package/src/component/notify/style.less +48 -0
  73. package/src/component/picker/drawPicker.jsx +110 -0
  74. package/src/component/picker/index.js +3 -0
  75. package/src/component/picker/picker.jsx +380 -0
  76. package/src/component/picker/pickerItem.jsx +31 -0
  77. package/src/component/picker/style.less +80 -0
  78. package/src/component/pull-refresh/index.js +3 -0
  79. package/src/component/pull-refresh/pull-refresh.jsx +46 -0
  80. package/src/component/search-bar/index.jsx +3 -0
  81. package/src/component/search-bar/search-bar.jsx +97 -0
  82. package/src/component/search-bar/style.less +52 -0
  83. package/src/component/sign/index.jsx +3 -0
  84. package/src/component/sign/sign.jsx +33 -0
  85. package/src/component/sign/style.less +56 -0
  86. package/src/component/sort-item/index.jsx +3 -0
  87. package/src/component/sort-item/sort-item.jsx +52 -0
  88. package/src/component/sort-item/style.less +52 -0
  89. package/src/component/subscript/index.js +3 -0
  90. package/src/component/subscript/style.less +63 -0
  91. package/src/component/subscript/subscript.jsx +77 -0
  92. package/src/component/tab/index.jsx +6 -0
  93. package/src/component/tab/nav-child.jsx +63 -0
  94. package/src/component/tab/panel.jsx +22 -0
  95. package/src/component/tab/style.less +87 -0
  96. package/src/component/tab/tab.jsx +195 -0
  97. package/src/component/tag/index.jsx +3 -0
  98. package/src/component/tag/style.less +56 -0
  99. package/src/component/tag/tag.jsx +52 -0
  100. package/src/component/toast/content.jsx +31 -0
  101. package/src/component/toast/index.js +3 -0
  102. package/src/component/toast/style.less +50 -0
  103. package/src/component/toast/toast.jsx +62 -0
  104. package/src/component/touchable/index.js +3 -0
  105. package/src/component/touchable/style.less +33 -0
  106. package/src/component/touchable/touchable.jsx +43 -0
  107. package/src/component/uploader/index.jsx +445 -0
  108. package/src/component/uploader/js/get-image-base64.js +31 -0
  109. package/src/component/uploader/js/get-image-detail.js +26 -0
  110. package/src/component/uploader/js/index.js +77 -0
  111. package/src/component/uploader/js/merge-class-name.js +14 -0
  112. package/src/component/uploader/js/old-compress-function.js +64 -0
  113. package/src/component/uploader/js/request.js +62 -0
  114. package/src/component/uploader/js/tools.js +115 -0
  115. package/src/component/uploader/jsx/config.jsx +36 -0
  116. package/src/component/uploader/jsx/img-preview.jsx +41 -0
  117. package/src/component/uploader/jsx/thumbnails.jsx +27 -0
  118. package/src/component/uploader/styles/index.less +158 -0
  119. package/src/index.js +1 -0
  120. package/src/index.jsx +64 -0
  121. package/src/styles/color.less +51 -0
  122. package/src/styles/font.less +14 -0
  123. package/src/styles/format-theme.less +27 -0
  124. package/src/styles/index.less +26 -0
  125. package/src/styles/spacing.less +3 -0
  126. package/src/styles/var.less +3 -0
  127. package/src/tools/create-body-container.js +47 -0
  128. package/src/tools/limit-body-scroll.js +17 -0
  129. package/src/tools/limit-document-scroll.js +12 -0
  130. package/src/tools/merge-class-name.js +14 -0
  131. package/src/tools/object-key-check.js +3 -0
  132. package/src/tools/pinyin.js +6 -0
  133. package/src/tools/proptypes.js +51 -0
  134. package/src/tools/style.less +14 -0
  135. package/test/cases/case-button01.assert.js +6 -0
  136. package/test/cases/case-button01.source.jsx +28 -0
  137. package/test/cases/case-checkbox01.assert.js +6 -0
  138. package/test/cases/case-checkbox01.source.jsx +20 -0
  139. package/test/cases/case-dialog01.assert.js +6 -0
  140. package/test/cases/case-dialog01.source.jsx +45 -0
  141. package/test/cases/case-drawer01.assert.js +6 -0
  142. package/test/cases/case-drawer01.source.jsx +85 -0
  143. package/test/cases/case-icons01.assert.js +6 -0
  144. package/test/cases/case-icons01.source.jsx +25 -0
  145. package/test/cases/case-indexSortList01.assert.js +6 -0
  146. package/test/cases/case-indexSortList01.source.jsx +74 -0
  147. package/test/cases/case-input01.assert.js +6 -0
  148. package/test/cases/case-input01.source.jsx +24 -0
  149. package/test/cases/case-listView01.assert.js +6 -0
  150. package/test/cases/case-listView01.source.jsx +64 -0
  151. package/test/cases/case-multiplePicker01.assert.js +6 -0
  152. package/test/cases/case-multiplePicker01.source.jsx +60 -0
  153. package/test/cases/case-multipleSelector01.assert.js +6 -0
  154. package/test/cases/case-multipleSelector01.source.jsx +49 -0
  155. package/test/cases/case-noticebar01.assert.js +6 -0
  156. package/test/cases/case-noticebar01.source.jsx +21 -0
  157. package/test/cases/case-picker01.assert.js +6 -0
  158. package/test/cases/case-picker01.source.jsx +61 -0
  159. package/test/cases/case-refresh01.assert.js +6 -0
  160. package/test/cases/case-refresh01.source.jsx +33 -0
  161. package/test/cases/case-sign01.assert.js +6 -0
  162. package/test/cases/case-sign01.source.jsx +21 -0
  163. package/test/cases/case-subscript01.assert.js +6 -0
  164. package/test/cases/case-subscript01.source.jsx +30 -0
  165. package/test/cases/case-tab01.assert.js +6 -0
  166. package/test/cases/case-tab01.source.jsx +51 -0
  167. package/test/cases/case-toast01.assert.js +6 -0
  168. package/test/cases/case-toast01.source.jsx +32 -0
  169. package/test/cases/case-uploader01.assert.js +6 -0
  170. package/test/cases/case-uploader01.source.jsx +45 -0
  171. package/test.config.js +25 -0
@@ -0,0 +1,380 @@
1
+ import React, { Component } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import classNames from 'classnames';
4
+
5
+
6
+ import styles from './style.less';
7
+ import PickerItem from './pickerItem';
8
+
9
+
10
+ const PassiveSupported = () => {
11
+ let passiveSupported = false;
12
+
13
+ try {
14
+ const options = Object.defineProperty({}, 'passive', {
15
+ get: () => {
16
+ passiveSupported = true;
17
+ return passiveSupported;
18
+ },
19
+ });
20
+ window.addEventListener('test', null, options);
21
+ } catch (err) { console.warn(err); }
22
+ return passiveSupported;
23
+ };
24
+
25
+
26
+ class Picker extends Component {
27
+ static selectByIndex(selectedIndex, itemHeight, scrollTo) {
28
+ const targetY = selectedIndex * itemHeight;
29
+ scrollTo(targetY);
30
+ }
31
+
32
+ static computeChildIndex(top, itemHeight, childrenLength) {
33
+ const index = Math.round(top / itemHeight);
34
+ return Math.min(index, childrenLength - 1);
35
+ }
36
+
37
+ constructor(props) {
38
+ super(props);
39
+
40
+ this.contentRef = React.createRef();
41
+ this.indicatorRef = React.createRef();
42
+ this.maskRef = React.createRef();
43
+ this.pickerBodyRef = React.createRef();
44
+ this.itemHeight = 0;
45
+ this.scrollValue = null;
46
+
47
+ this.fireValueChange = this.fireValueChange.bind(this);
48
+ this.scrollTo = this.scrollTo.bind(this);
49
+ this.scrollToWithoutAnimation = this.scrollToWithoutAnimation.bind(this);
50
+
51
+ this.scrollHanders = (() => {
52
+ let scrollY = -1;
53
+ let lastY = 0;
54
+ let startY = 0;
55
+ let scrollDisabled = false;
56
+ let isMoving = false;
57
+
58
+ const setTransform = (nodeStyle, value) => {
59
+ Object.assign(nodeStyle, {
60
+ transform: value,
61
+ webkitTransform: value,
62
+ });
63
+ };
64
+
65
+ const setTransition = (nodeStyle, value) => {
66
+ Object.assign(nodeStyle, {
67
+ transition: value,
68
+ webkitTransition: value,
69
+ });
70
+ };
71
+
72
+ const scrollTo = (_x, y, time = 0.3) => {
73
+ if (scrollY !== y) {
74
+ scrollY = y;
75
+ const { noAnimate } = this.props;
76
+ if (time && !noAnimate) {
77
+ setTransition(this.contentRef.current.style, `cubic-bezier(0,0,0.2,1.15) ${time}s`);
78
+ }
79
+ setTransform(this.contentRef.current.style, `translate3d(0,${-y}px,0)`);
80
+ setTimeout(() => {
81
+ this.scrollingComplete();
82
+ if (this.contentRef.current) {
83
+ setTransition(this.contentRef.current.style, '');
84
+ }
85
+ }, +time * 1000);
86
+ }
87
+ };
88
+
89
+ const Velocity = ((minInterval = 30, maxInterval = 100) => {
90
+ let time = 0;
91
+ let currentY = 0;
92
+ let velocity = 0;
93
+ const recorder = {
94
+ record: (y) => {
95
+ const now = +new Date();
96
+ velocity = (y - currentY) / (now - time);
97
+ if (now - time >= minInterval) {
98
+ velocity = now - time <= maxInterval ? velocity : 0;
99
+ currentY = y;
100
+ time = now;
101
+ }
102
+ },
103
+ getVelocity: (y) => {
104
+ if (y !== currentY) {
105
+ recorder.record(y);
106
+ }
107
+ return velocity;
108
+ },
109
+ };
110
+ return recorder;
111
+ })();
112
+
113
+ const onFinish = () => {
114
+ isMoving = false;
115
+ let targetY = scrollY;
116
+ const { children } = this.props;
117
+ const height = (children.length - 1) * this.itemHeight;
118
+
119
+ let time = 0.3;
120
+
121
+ const velocity = Velocity.getVelocity(targetY) * 4;
122
+ if (velocity) {
123
+ targetY = velocity * 40 + targetY;
124
+ time = Math.abs(velocity) * 0.1;
125
+ }
126
+
127
+ if (targetY % this.itemHeight !== 0) {
128
+ targetY = Math.round(targetY / this.itemHeight) * this.itemHeight;
129
+ }
130
+
131
+ if (targetY < 0) {
132
+ targetY = 0;
133
+ } else if (targetY > height) {
134
+ targetY = height;
135
+ }
136
+
137
+ scrollTo(0, targetY, time < 0.3 ? 0.3 : time);
138
+ this.onScrollChange();
139
+ };
140
+
141
+ const onStart = (y) => {
142
+ if (scrollDisabled) {
143
+ return;
144
+ }
145
+
146
+ isMoving = true;
147
+ startY = y;
148
+ lastY = scrollY;
149
+ };
150
+
151
+ const onMove = (y) => {
152
+ if (scrollDisabled || !isMoving) {
153
+ return;
154
+ }
155
+
156
+ scrollY = lastY - y + startY;
157
+ Velocity.record(scrollY);
158
+
159
+ this.onScrollChange();
160
+ setTransform(this.contentRef.current.style, `translate3d(0,${-scrollY}px,0)`);
161
+ };
162
+
163
+ return {
164
+ touchstart: evt => onStart(evt.touches[0].pageY),
165
+ mousedown: evt => onStart(evt.pageY),
166
+ touchmove: (evt) => {
167
+ evt.preventDefault();
168
+ onMove(evt.touches[0].pageY);
169
+ },
170
+ mousemove: (evt) => {
171
+ evt.preventDefault();
172
+ onMove(evt.pageY);
173
+ },
174
+ touchend: () => onFinish(),
175
+ touchcancel: () => onFinish(),
176
+ mouseup: () => onFinish(),
177
+ getValue: () => scrollY,
178
+ scrollTo,
179
+ setDisabled: (disabled = false) => {
180
+ scrollDisabled = disabled;
181
+ },
182
+ };
183
+ }
184
+ )();
185
+ }
186
+
187
+ componentDidMount() {
188
+ const { contentRef, pickerBodyRef, maskRef, indicatorRef } = this;
189
+
190
+ // 计算选项个数
191
+ const bodyHeight = pickerBodyRef.current.getBoundingClientRect().height;
192
+ const itemHeight = indicatorRef.current.getBoundingClientRect().height;
193
+ this.itemHeight = itemHeight;
194
+ let num = Math.floor(bodyHeight / itemHeight);
195
+ if (num % 2 === 0) {
196
+ num--;
197
+ }
198
+ num--;
199
+ num /= 2;
200
+
201
+ // 设置指示器位置
202
+ contentRef.current.style.padding = `${itemHeight * num}px 0`;
203
+ indicatorRef.current.style.top = `${itemHeight * num}px`;
204
+ maskRef.current.style.backgroundSize = `100% ${itemHeight * num}px`;
205
+ const { disabled } = this.props;
206
+ this.scrollHanders.setDisabled(disabled);
207
+
208
+ const passiveSupported = PassiveSupported();
209
+ const willPreventDefault = passiveSupported ? { passive: false } : false;
210
+ const willNotPreventDefault = passiveSupported ? { passive: true } : false;
211
+ Object.keys(this.scrollHanders).forEach((key) => {
212
+ if (key.indexOf('touch') === 0 || key.indexOf('mouse') === 0) {
213
+ const pd = key.indexOf('move') >= 0 ? willPreventDefault : willNotPreventDefault;
214
+ pickerBodyRef.current.addEventListener(key, this.scrollHanders[key], pd);
215
+ }
216
+ });
217
+ const { value } = this.props;
218
+ this.select(value, this.scrollToWithoutAnimation);
219
+ }
220
+
221
+ componentDidUpdate() {
222
+ const { value, noAnimate } = this.props;
223
+ this.select(value, noAnimate ? this.scrollToWithoutAnimation : this.scrollTo);
224
+ }
225
+
226
+
227
+ componentWillUnmount() {
228
+ Object.keys(this.scrollHanders).forEach((key) => {
229
+ if (key.indexOf('touch') === 0 || key.indexOf('mouse') === 0) {
230
+ this.pickerBodyRef.current.removeEventListener(key, this.scrollHanders[key]);
231
+ }
232
+ });
233
+ }
234
+
235
+ onScrollChange() {
236
+ const top = this.scrollHanders.getValue();
237
+ if (top >= 0) {
238
+ const { children: propsChildren } = this.props;
239
+ const children = React.Children.toArray(propsChildren);
240
+ const index = Picker.computeChildIndex(top, this.itemHeight, children.length);
241
+ if (this.scrollValue !== index) {
242
+ this.scrollValue = index;
243
+ const child = children[index];
244
+ const { onScrollChange } = this.props;
245
+ if (child && onScrollChange && onScrollChange instanceof Function) {
246
+ onScrollChange(child.props.value);
247
+ }
248
+ }
249
+ }
250
+ }
251
+
252
+
253
+ scrollTo(top) {
254
+ this.scrollHanders.scrollTo(0, top);
255
+ }
256
+
257
+ scrollToWithoutAnimation(top) {
258
+ this.scrollHanders.scrollTo(0, top, 0);
259
+ }
260
+
261
+ doScrollingComplete(top, itemHeight, fireValueChange) {
262
+ const { children: propsChildren } = this.props;
263
+ const children = React.Children.toArray(propsChildren);
264
+ const index = Picker.computeChildIndex(top, itemHeight, children.length);
265
+ const child = children[index];
266
+ if (child) {
267
+ fireValueChange(child.props.value);
268
+ } else if (console.warn) {
269
+ console.warn('child not find', children, index);
270
+ }
271
+ }
272
+
273
+ fireValueChange(value) {
274
+ if (value !== this.scrollValue) {
275
+ this.scrollValue = value;
276
+ // 变更选中值
277
+ const { onValueChange } = this.props;
278
+ if (onValueChange && onValueChange instanceof Function) {
279
+ onValueChange(value);
280
+ }
281
+ }
282
+ }
283
+
284
+ scrollingComplete() {
285
+ const top = this.scrollHanders.getValue();
286
+ if (top >= 0) {
287
+ this.doScrollingComplete(top, this.itemHeight, this.fireValueChange);
288
+ }
289
+ }
290
+
291
+ select(value, scrollTo) {
292
+ let selectedIndex;
293
+ const { children: propsChildren } = this.props;
294
+ const children = React.Children.toArray(propsChildren);
295
+ if (value === undefined || value === null || value === '') {
296
+ selectedIndex = 0;
297
+ } else {
298
+ selectedIndex = children.findIndex(item => item === value || item.props.value === value);
299
+ if (selectedIndex === -1) {
300
+ selectedIndex = 0;
301
+ }
302
+ }
303
+ Picker.selectByIndex(selectedIndex, this.itemHeight, scrollTo);
304
+ }
305
+
306
+ render() {
307
+ const {
308
+ className,
309
+ children,
310
+ itemStyle,
311
+ itemClassName,
312
+ } = this.props;
313
+
314
+
315
+ // 生成选项
316
+ const map = (item) => {
317
+ const { className: itemClass = '', style, value: itemValue = '' } = item.props;
318
+ return (
319
+ <div
320
+ style={{ ...itemStyle, style }}
321
+ className={classNames(styles['sm-picker-item'], itemClass, itemClassName)}
322
+ key={itemValue}
323
+ >
324
+ {item.children || item.props.children || item.props.value}
325
+ </div>
326
+ );
327
+ };
328
+
329
+ const options = React.Children
330
+ ? React.Children.map(children, map) : [].concat(children).map(map);
331
+
332
+ return (
333
+ <div
334
+ className={classNames(styles['sm-picker-content-body'], className)}
335
+ ref={this.pickerBodyRef}
336
+ >
337
+ <div
338
+ className={styles['sm-picker-content-mask']}
339
+ ref={this.maskRef}
340
+ />
341
+ <div
342
+ className={styles['sm-picker-indicator']}
343
+ ref={this.indicatorRef}
344
+ />
345
+ <div
346
+ className={styles['sm-picker-list']}
347
+ ref={this.contentRef}
348
+ >
349
+ {options}
350
+ </div>
351
+ </div>
352
+ );
353
+ }
354
+ }
355
+
356
+
357
+ Picker.propTypes = {
358
+ value: PropTypes.oneOfType([
359
+ PropTypes.string,
360
+ PropTypes.number,
361
+ ]),
362
+ onValueChange: PropTypes.func,
363
+ onScrollChange: PropTypes.func,
364
+ disabled: PropTypes.bool, // 是否禁用
365
+ noAnimate: PropTypes.bool, // 是否有动画
366
+ children: PropTypes.element,
367
+ className: PropTypes.string,
368
+ itemClassName: PropTypes.string,
369
+ itemStyle: PropTypes.objectOf(PropTypes.any),
370
+ };
371
+
372
+ Picker.defaultProps = {
373
+ disabled: false,
374
+ noAnimate: false,
375
+ };
376
+
377
+ Picker.PickerItem = PickerItem;
378
+
379
+
380
+ export default Picker;
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { getProps } from '../../tools/proptypes';
4
+
5
+ const PickerItem = (props) => {
6
+ const {
7
+ value,
8
+ children,
9
+ ...others
10
+ } = props;
11
+
12
+ return (
13
+ <div
14
+ {...others}
15
+ key={value}
16
+ >
17
+ {children}
18
+ </div>
19
+ );
20
+ };
21
+
22
+
23
+ PickerItem.propTypes = {
24
+ ...getProps(PropTypes, 'children'),
25
+ value: PropTypes.oneOfType([
26
+ PropTypes.string,
27
+ PropTypes.number,
28
+ ]),
29
+ };
30
+
31
+ export default PickerItem;
@@ -0,0 +1,80 @@
1
+ .draw-picker{
2
+ width: 100%;
3
+ overflow: hidden;
4
+ display: block;
5
+
6
+ .sm-picker-header{
7
+ background-color: #fff;
8
+ height: 6vh;
9
+ display: flex;
10
+ align-items: center;
11
+ justify-content: space-between;
12
+
13
+ .header-left{
14
+ font-size: 18px;
15
+ color: #0ae;
16
+ margin-left: 2vw;
17
+ }
18
+ .header-center{
19
+ font-size: 18px;
20
+ color: #0ae;
21
+ }
22
+ .header-right{
23
+ font-size: 18px;
24
+ color: #0ae;
25
+ margin-right: 2vw;
26
+ }
27
+ }
28
+
29
+ .sm-picker{
30
+ width: 100%;
31
+ text-align: center;
32
+ }
33
+ }
34
+
35
+ .sm-picker-content-body {
36
+ background-color: #fff;
37
+ height: calc(100% - 6vh);
38
+ position: relative;
39
+ overflow: hidden;
40
+
41
+ .sm-picker-content-mask {
42
+ background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.6)), linear-gradient(to top, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.6));
43
+ background-repeat: no-repeat;
44
+ background-position: top, bottom;
45
+ height: 100%;
46
+ width: 100%;
47
+ position: absolute;
48
+ top: 0;
49
+ left: 0;
50
+ z-index: 3;
51
+ }
52
+
53
+ .sm-picker-indicator {
54
+ width: 100%;
55
+ height: 34px;
56
+ position: absolute;
57
+ top: 43%;
58
+ left: 0;
59
+ box-sizing: border-box;
60
+ border-top: 1px solid #ddd;
61
+ border-bottom: 1px solid #ddd;
62
+ z-index: 3;
63
+ }
64
+
65
+ .sm-picker-list {
66
+ //height: 100%;
67
+ width: 100%;
68
+ display: flex;
69
+ flex-direction: column;
70
+ justify-content: center;
71
+ align-items: center;
72
+ }
73
+ }
74
+ .sm-picker-item {
75
+ color: #9b9b9b;
76
+ line-height: 34px;
77
+ font-size: 16px;
78
+ padding: 0 10px;
79
+
80
+ }
@@ -0,0 +1,3 @@
1
+ import PullRefresh from './pull-refresh';
2
+
3
+ export default PullRefresh;
@@ -0,0 +1,46 @@
1
+ import React, { Component } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ // import styles from './style.less';
4
+
5
+ class Refresh extends Component {
6
+ constructor(props) {
7
+ super(props);
8
+ this.test = React.createRef();
9
+ }
10
+
11
+ // onTouchStart(e) {
12
+ // console.log('start', e);
13
+ // }
14
+ // onTouchMove(e) {
15
+ // console.log('move', e);
16
+ // }
17
+ onTouchEnd() {
18
+ const { refresh } = this.props;
19
+ refresh();
20
+ // console.log('end', e);
21
+ }
22
+
23
+ render() {
24
+ const { children } = this.props;
25
+ return (
26
+ <div
27
+ ref={this.test}
28
+ // className={styles['sm-refresh']}
29
+ // onTouchStart={this.onTouchStart}
30
+ // onTouchMove={this.onTouchMove}
31
+ // onTouchEnd={this.onTouchEnd}
32
+ onTouchCancel={this.onTouchEnd}
33
+ >
34
+ <div>顶部文字</div>
35
+ {children}
36
+ </div>
37
+ );
38
+ }
39
+ }
40
+
41
+ Refresh.propTypes = {
42
+ children: PropTypes.node,
43
+ refresh: PropTypes.func,
44
+ };
45
+
46
+ export default Refresh;
@@ -0,0 +1,3 @@
1
+ import SearchBar from './search-bar';
2
+
3
+ export default SearchBar;
@@ -0,0 +1,97 @@
1
+ import React, { Component } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import Icon from '../icons/mrp';
4
+ import styles from './style.less';
5
+
6
+ class SearchBar extends Component {
7
+ constructor(props) {
8
+ super(props);
9
+ }
10
+ bindRef = (el) => {
11
+ this.ref = el
12
+ }
13
+ render() {
14
+ const {
15
+ style,
16
+ className,
17
+ showIcon,
18
+ clearable,
19
+ placeholder,
20
+ value,
21
+ onChange,
22
+ onPressEnter,
23
+ leftItem,
24
+ rightItem,
25
+ } = this.props;
26
+ const hasInput = value ? String(value).length : 0;
27
+
28
+ return (
29
+ <div
30
+ style={style}
31
+ className={[styles.searchContainer, className].join(' ')}
32
+ >
33
+ {
34
+ leftItem ? <div className={styles.renderLeft}>{leftItem}</div> : ''
35
+ }
36
+ <div className={styles.inputContainers}>
37
+ {
38
+ showIcon && <Icon name="search" className={styles.searchIcon} />
39
+ }
40
+ <input
41
+ ref={this.bindRef}
42
+ className={styles.input}
43
+ type="search"
44
+ value={value}
45
+ placeholder={placeholder}
46
+ onChange={e => onChange && onChange(e.target.value)}
47
+ onKeyDown={(e) => {
48
+ if (e.keyCode === 13) {
49
+ this.ref.blur();
50
+ onPressEnter(e.target.value);
51
+ }
52
+ }}
53
+ />
54
+ {
55
+ hasInput && clearable
56
+ ? (
57
+ <Icon
58
+ name="delete"
59
+ className={styles.clearIcon}
60
+ onClick={() => {
61
+ onChange('');
62
+ }}
63
+ />
64
+ ) : ''
65
+ }
66
+ </div>
67
+ {
68
+ rightItem ? <div className={styles.renderRight}>{rightItem}</div> : ''
69
+ }
70
+ </div>
71
+ );
72
+ }
73
+ }
74
+
75
+
76
+ SearchBar.propTypes = {
77
+ style: PropTypes.object,
78
+ className: PropTypes.string,
79
+ shape: PropTypes.oneOf(['round', 'square']), // 未实现
80
+ background: PropTypes.string, // 未实现
81
+ showIcon: PropTypes.bool,
82
+ value: PropTypes.any,
83
+ clearable: PropTypes.bool,
84
+ placeholder: PropTypes.string,
85
+ onChange: PropTypes.func,
86
+ leftItem: PropTypes.element,
87
+ rightItem: PropTypes.element,
88
+ onSearch: PropTypes.func,
89
+ onCancel: PropTypes.func,
90
+ };
91
+
92
+ SearchBar.defaultProps = {
93
+ shape: 'square',
94
+ background: '#FFFFFF',
95
+ };
96
+
97
+ export default SearchBar;
@@ -0,0 +1,52 @@
1
+ @import "../../styles/var";
2
+
3
+ .searchContainer{
4
+ display: flex;
5
+ align-items: center;
6
+ //background: @background-color;
7
+ .inputContainers{
8
+ position: relative;
9
+ display: flex;
10
+ flex: 1;
11
+ .searchIcon{
12
+ position: absolute;
13
+ left: 10px;
14
+ top: 50%;
15
+ transform: translateY(-50%);
16
+ font-size: 24px;
17
+ color: @text-color-light;
18
+ }
19
+ .clearIcon{
20
+ position: absolute;
21
+ right: 10px;
22
+ top: 50%;
23
+ transform: translateY(-50%);
24
+ font-size: 20px;
25
+ color: lightgray;
26
+ }
27
+ .input{
28
+ height: 32px;
29
+ background: #F7F9FC;
30
+ border-radius: 16px;
31
+ outline: none;
32
+ box-shadow: none;
33
+ border: none;
34
+ flex: 1;
35
+ padding-left: 36px;
36
+ padding-right: 30px;
37
+ color: @text-color;
38
+ &::-webkit-search-cancel-button {
39
+ display: none;
40
+ visibility: hidden;
41
+ }
42
+ }
43
+ }
44
+ .renderLeft {
45
+ flex-shrink: 0;
46
+ margin-right: 10px;
47
+ }
48
+ .renderRight{
49
+ flex-shrink: 0;
50
+ margin-left: 10px;
51
+ }
52
+ }
@@ -0,0 +1,3 @@
1
+ import Sign from './sign';
2
+
3
+ export default Sign;