amis 1.5.6-beta.0 → 1.5.7

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 (229) hide show
  1. package/lib/Root.js +1 -1
  2. package/lib/Root.js.map +2 -2
  3. package/lib/Schema.d.ts +1 -1
  4. package/lib/Schema.js.map +1 -1
  5. package/lib/SchemaRenderer.js +4 -4
  6. package/lib/SchemaRenderer.js.map +2 -2
  7. package/lib/components/AsideNav.d.ts +1 -1
  8. package/lib/components/AsideNav.js.map +1 -1
  9. package/lib/components/Card.d.ts +20 -20
  10. package/lib/components/Card.js +1 -1
  11. package/lib/components/Card.js.map +2 -2
  12. package/lib/components/CodeMirror.d.ts +26 -0
  13. package/lib/components/CodeMirror.js +104 -0
  14. package/lib/components/CodeMirror.js.map +13 -0
  15. package/lib/components/Collapse.d.ts +22 -21
  16. package/lib/components/Collapse.js +5 -7
  17. package/lib/components/Collapse.js.map +2 -2
  18. package/lib/components/CollapseGroup.d.ts +20 -20
  19. package/lib/components/CollapseGroup.js +5 -3
  20. package/lib/components/CollapseGroup.js.map +2 -2
  21. package/lib/components/ColorPicker.d.ts +85 -84
  22. package/lib/components/ColorPicker.js +15 -3
  23. package/lib/components/ColorPicker.js.map +2 -2
  24. package/lib/components/DatePicker.d.ts +84 -84
  25. package/lib/components/DatePicker.js +7 -3
  26. package/lib/components/DatePicker.js.map +2 -2
  27. package/lib/components/DateRangePicker.d.ts +85 -84
  28. package/lib/components/DateRangePicker.js +5 -3
  29. package/lib/components/DateRangePicker.js.map +2 -2
  30. package/lib/components/LocationPicker.d.ts +84 -84
  31. package/lib/components/MonthRangePicker.d.ts +85 -84
  32. package/lib/components/MonthRangePicker.js +5 -3
  33. package/lib/components/MonthRangePicker.js.map +2 -2
  34. package/lib/components/PickerContainer.d.ts +2 -1
  35. package/lib/components/PickerContainer.js +3 -3
  36. package/lib/components/PickerContainer.js.map +2 -2
  37. package/lib/components/PopUp.d.ts +93 -0
  38. package/lib/components/PopUp.js +58 -0
  39. package/lib/components/PopUp.js.map +13 -0
  40. package/lib/components/Rating.d.ts +203 -73
  41. package/lib/components/Rating.js +147 -31
  42. package/lib/components/Rating.js.map +2 -2
  43. package/lib/components/Select.d.ts +237 -237
  44. package/lib/components/Steps.d.ts +1 -0
  45. package/lib/components/Steps.js +5 -3
  46. package/lib/components/Steps.js.map +2 -2
  47. package/lib/components/Tabs.d.ts +20 -20
  48. package/lib/components/TabsTransferPicker.js +1 -1
  49. package/lib/components/TabsTransferPicker.js.map +2 -2
  50. package/lib/components/TransferPicker.d.ts +0 -1
  51. package/lib/components/TransferPicker.js +2 -15
  52. package/lib/components/TransferPicker.js.map +2 -2
  53. package/lib/components/formula/Editor.d.ts +560 -0
  54. package/lib/components/formula/Editor.js +186 -0
  55. package/lib/components/formula/Editor.js.map +13 -0
  56. package/lib/components/formula/FuncList.d.ts +67 -0
  57. package/lib/components/formula/FuncList.js +35 -0
  58. package/lib/components/formula/FuncList.js.map +13 -0
  59. package/lib/components/formula/Picker.d.ts +493 -0
  60. package/lib/components/formula/Picker.js +48 -0
  61. package/lib/components/formula/Picker.js.map +13 -0
  62. package/lib/components/formula/VariableList.d.ts +9 -0
  63. package/lib/components/formula/VariableList.js +15 -0
  64. package/lib/components/formula/VariableList.js.map +13 -0
  65. package/lib/components/formula/plugin.d.ts +18 -0
  66. package/lib/components/formula/plugin.js +136 -0
  67. package/lib/components/formula/plugin.js.map +13 -0
  68. package/lib/components/icons.js +2 -0
  69. package/lib/components/icons.js.map +2 -2
  70. package/lib/components/index.d.ts +2 -1
  71. package/lib/components/index.js +4 -2
  72. package/lib/components/index.js.map +2 -2
  73. package/lib/helper.css +57 -57
  74. package/lib/helper.css.map +1 -1
  75. package/lib/icons/star.js +12 -0
  76. package/lib/index.d.ts +1 -0
  77. package/lib/index.js +2 -1
  78. package/lib/index.js.map +2 -2
  79. package/lib/renderers/CRUD.js +1 -2
  80. package/lib/renderers/CRUD.js.map +2 -2
  81. package/lib/renderers/Collapse.js +8 -2
  82. package/lib/renderers/Collapse.js.map +2 -2
  83. package/lib/renderers/CollapseGroup.js.map +2 -2
  84. package/lib/renderers/Form/InputCity.d.ts +84 -84
  85. package/lib/renderers/Form/InputColor.d.ts +84 -84
  86. package/lib/renderers/Form/InputColor.js +2 -2
  87. package/lib/renderers/Form/InputColor.js.map +2 -2
  88. package/lib/renderers/Form/InputDate.js +2 -2
  89. package/lib/renderers/Form/InputDate.js.map +2 -2
  90. package/lib/renderers/Form/InputDateRange.js +2 -2
  91. package/lib/renderers/Form/InputDateRange.js.map +2 -2
  92. package/lib/renderers/Form/InputFormula.d.ts +35 -0
  93. package/lib/renderers/Form/InputFormula.js +25 -0
  94. package/lib/renderers/Form/InputFormula.js.map +13 -0
  95. package/lib/renderers/Form/InputMonthRange.js +2 -2
  96. package/lib/renderers/Form/InputMonthRange.js.map +2 -2
  97. package/lib/renderers/Form/InputQuarterRange.js +2 -2
  98. package/lib/renderers/Form/InputQuarterRange.js.map +2 -2
  99. package/lib/renderers/Form/InputRating.d.ts +37 -0
  100. package/lib/renderers/Form/InputRating.js +6 -2
  101. package/lib/renderers/Form/InputRating.js.map +2 -2
  102. package/lib/renderers/Form/InputYearRange.js +2 -2
  103. package/lib/renderers/Form/InputYearRange.js.map +2 -2
  104. package/lib/renderers/Form/TreeSelect.d.ts +1 -0
  105. package/lib/renderers/Form/TreeSelect.js +11 -8
  106. package/lib/renderers/Form/TreeSelect.js.map +2 -2
  107. package/lib/renderers/Form/index.js +2 -1
  108. package/lib/renderers/Form/index.js.map +2 -2
  109. package/lib/renderers/Json.js +7 -0
  110. package/lib/renderers/Json.js.map +2 -2
  111. package/lib/renderers/Nav.js +4 -1
  112. package/lib/renderers/Nav.js.map +2 -2
  113. package/lib/renderers/Steps.js +2 -2
  114. package/lib/renderers/Steps.js.map +2 -2
  115. package/lib/renderers/Table/TableRow.js +4 -1
  116. package/lib/renderers/Table/TableRow.js.map +2 -2
  117. package/lib/store/formItem.js +17 -7
  118. package/lib/store/formItem.js.map +2 -2
  119. package/lib/store/table.js +1 -1
  120. package/lib/store/table.js.map +2 -2
  121. package/lib/themes/ang-ie11.css +305 -10
  122. package/lib/themes/ang.css +305 -10
  123. package/lib/themes/ang.css.map +1 -1
  124. package/lib/themes/antd-ie11.css +305 -10
  125. package/lib/themes/antd.css +305 -10
  126. package/lib/themes/antd.css.map +1 -1
  127. package/lib/themes/cxd-ie11.css +307 -11
  128. package/lib/themes/cxd.css +307 -11
  129. package/lib/themes/cxd.css.map +1 -1
  130. package/lib/themes/dark-ie11.css +305 -10
  131. package/lib/themes/dark.css +305 -10
  132. package/lib/themes/dark.css.map +1 -1
  133. package/lib/themes/default.css +307 -11
  134. package/lib/themes/default.css.map +1 -1
  135. package/lib/utils/api.js +2 -2
  136. package/lib/utils/api.js.map +2 -2
  137. package/lib/utils/helper.js +2 -7
  138. package/lib/utils/helper.js.map +2 -2
  139. package/package.json +5 -3
  140. package/schema.json +59 -7
  141. package/scss/_properties.scss +3 -1
  142. package/scss/_variables.scss +1 -1
  143. package/scss/components/_formula.scss +122 -0
  144. package/scss/components/_popup.scss +123 -0
  145. package/scss/components/_steps.scss +60 -0
  146. package/scss/components/form/_color.scss +4 -0
  147. package/scss/components/form/_date-range.scss +4 -0
  148. package/scss/components/form/_date.scss +3 -0
  149. package/scss/components/form/_rating.scss +60 -21
  150. package/scss/components/form/_tree-select.scss +4 -0
  151. package/scss/helper/background/_background-color.scss +1 -1
  152. package/scss/helper/border/_border-color.scss +1 -1
  153. package/scss/helper/typography/_text-color.scss +1 -1
  154. package/scss/themes/_common.scss +2 -0
  155. package/scss/themes/_cxd-variables.scss +3 -1
  156. package/sdk/ang-ie11.css +922 -8
  157. package/sdk/ang.css +926 -10
  158. package/sdk/antd-ie11.css +922 -8
  159. package/sdk/antd.css +926 -10
  160. package/sdk/charts.js +17 -17
  161. package/sdk/codemirror.js +14 -0
  162. package/sdk/color-picker.js +65 -65
  163. package/sdk/cropperjs.js +3 -3
  164. package/sdk/cxd-ie11.css +923 -9
  165. package/sdk/cxd.css +928 -11
  166. package/sdk/dark-ie11.css +922 -8
  167. package/sdk/dark.css +926 -10
  168. package/sdk/exceljs.js +1 -1
  169. package/sdk/helper.css +57 -57
  170. package/sdk/helper.css.map +1 -1
  171. package/sdk/markdown.js +69 -69
  172. package/sdk/papaparse.js +1 -1
  173. package/sdk/renderers/Form/CityDB.js +1 -1
  174. package/sdk/rest.js +18 -18
  175. package/sdk/rich-text.js +62 -62
  176. package/sdk/sdk-ie11.css +923 -9
  177. package/sdk/sdk.css +928 -11
  178. package/sdk/sdk.js +1318 -1208
  179. package/sdk/thirds/hls.js/hls.js +18 -18
  180. package/sdk/thirds/mpegts.js/mpegts.js +2 -2
  181. package/sdk/tinymce.js +57 -57
  182. package/src/Root.tsx +1 -0
  183. package/src/Schema.ts +1 -0
  184. package/src/SchemaRenderer.tsx +4 -0
  185. package/src/components/AsideNav.tsx +1 -1
  186. package/src/components/Card.tsx +2 -2
  187. package/src/components/CodeMirror.tsx +99 -0
  188. package/src/components/Collapse.tsx +22 -14
  189. package/src/components/CollapseGroup.tsx +9 -11
  190. package/src/components/ColorPicker.tsx +45 -3
  191. package/src/components/DatePicker.tsx +33 -3
  192. package/src/components/DateRangePicker.tsx +17 -3
  193. package/src/components/MonthRangePicker.tsx +18 -4
  194. package/src/components/PickerContainer.tsx +10 -6
  195. package/src/components/PopUp.tsx +133 -0
  196. package/src/components/Rating.tsx +235 -47
  197. package/src/components/Steps.tsx +8 -3
  198. package/src/components/TabsTransferPicker.tsx +1 -1
  199. package/src/components/TransferPicker.tsx +1 -11
  200. package/src/components/formula/Editor.tsx +261 -0
  201. package/src/components/formula/FuncList.tsx +82 -0
  202. package/src/components/formula/Picker.tsx +86 -0
  203. package/src/components/formula/VariableList.tsx +49 -0
  204. package/src/components/formula/plugin.ts +177 -0
  205. package/src/components/icons.tsx +2 -0
  206. package/src/components/index.tsx +2 -0
  207. package/src/icons/star.svg +12 -0
  208. package/src/index.tsx +1 -0
  209. package/src/renderers/CRUD.tsx +1 -3
  210. package/src/renderers/Collapse.tsx +27 -27
  211. package/src/renderers/CollapseGroup.tsx +13 -12
  212. package/src/renderers/Form/InputColor.tsx +2 -3
  213. package/src/renderers/Form/InputDate.tsx +2 -0
  214. package/src/renderers/Form/InputDateRange.tsx +2 -0
  215. package/src/renderers/Form/InputFormula.tsx +75 -0
  216. package/src/renderers/Form/InputMonthRange.tsx +2 -0
  217. package/src/renderers/Form/InputQuarterRange.tsx +2 -0
  218. package/src/renderers/Form/InputRating.tsx +66 -3
  219. package/src/renderers/Form/InputYearRange.tsx +2 -0
  220. package/src/renderers/Form/TreeSelect.tsx +82 -63
  221. package/src/renderers/Form/index.tsx +2 -1
  222. package/src/renderers/Json.tsx +5 -0
  223. package/src/renderers/Nav.tsx +4 -1
  224. package/src/renderers/Steps.tsx +4 -2
  225. package/src/renderers/Table/TableRow.tsx +3 -1
  226. package/src/store/formItem.ts +17 -2
  227. package/src/store/table.ts +2 -1
  228. package/src/utils/api.ts +5 -2
  229. package/src/utils/helper.ts +5 -14
@@ -0,0 +1,133 @@
1
+ /**
2
+ * @file PopUp
3
+ * @description
4
+ * @author fex
5
+ */
6
+
7
+ import React from 'react';
8
+ import {ClassNamesFn, themeable} from '../theme';
9
+ import Transition, {
10
+ ENTERED,
11
+ EXITING,
12
+ EXITED,
13
+ ENTERING
14
+ } from 'react-transition-group/Transition';
15
+ import Portal from 'react-overlays/Portal';
16
+ import { Icon } from './icons';
17
+
18
+
19
+ export interface PopUpPorps {
20
+ className?: string;
21
+ style?: {
22
+ [styleName: string]: string;
23
+ };
24
+ overlay?: boolean;
25
+ onHide?: () => void;
26
+ classPrefix: string;
27
+ classnames: ClassNamesFn;
28
+ [propName: string]: any;
29
+ isShow?: boolean;
30
+ container?: any;
31
+ hideClose?: boolean;
32
+ placement?: 'left' | 'center' | 'right';
33
+ }
34
+
35
+ const fadeStyles: {
36
+ [propName: string]: string;
37
+ } = {
38
+ [ENTERED]: '',
39
+ [EXITING]: 'out',
40
+ [EXITED]: '',
41
+ [ENTERING]: 'in'
42
+ };
43
+ export class PopUp extends React.PureComponent<PopUpPorps> {
44
+ static defaultProps = {
45
+ className: '',
46
+ overlay: true,
47
+ isShow: false,
48
+ container: document.body,
49
+ hideClose: false,
50
+ };
51
+
52
+ componentDidMount() {
53
+
54
+ }
55
+ handleClick(e: React.MouseEvent) {
56
+ e.stopPropagation();
57
+ }
58
+
59
+ render() {
60
+ const {
61
+ style,
62
+ children,
63
+ overlay,
64
+ onHide,
65
+ classPrefix: ns,
66
+ classnames: cx,
67
+ className,
68
+ isShow,
69
+ container,
70
+ hideClose,
71
+ placement='center',
72
+ ...rest
73
+ } = this.props;
74
+
75
+ const outerStyle: any = {
76
+ ...style,
77
+ };
78
+ delete outerStyle.top;
79
+ return (
80
+ <Portal container={container}>
81
+ <Transition
82
+ mountOnEnter
83
+ unmountOnExit
84
+ in={isShow}
85
+ timeout={500}
86
+ appear
87
+ >
88
+ {(status: string) => {
89
+ return (
90
+ <div
91
+ className={cx(
92
+ `${ns}PopUp`,
93
+ className,
94
+ fadeStyles[status]
95
+ )}
96
+ style={outerStyle}
97
+ {...rest}
98
+ onClick={this.handleClick}
99
+ >
100
+ {overlay && (
101
+ <div className={`${ns}PopUp-overlay`} onClick={onHide}/>
102
+ )}
103
+ <div className={cx(
104
+ `${ns}PopUp-inner`
105
+ )}
106
+ >
107
+ {
108
+ !hideClose && (
109
+ <div className={cx(`${ns}PopUp-closeWrap`, 'text-right')}>
110
+ <Icon
111
+ icon="close"
112
+ className={cx('icon', `${ns}PopUp-close`)}
113
+ onClick={onHide}
114
+ />
115
+ </div>
116
+ )
117
+ }
118
+ <div
119
+ className={cx(`${ns}PopUp-content`, `justify-${placement}`)}
120
+ >
121
+ {children}
122
+ </div>
123
+ </div>
124
+ </div>
125
+ )
126
+ }}
127
+ </Transition>
128
+ </Portal>
129
+ )
130
+ }
131
+ }
132
+
133
+ export default themeable(PopUp);
@@ -8,22 +8,33 @@ import React from 'react';
8
8
  import cx from 'classnames';
9
9
  import {ClassNamesFn, themeable} from '../theme';
10
10
 
11
+ import {isObject} from '../utils/helper';
12
+ import {Icon} from './icons';
13
+
14
+ export type textPositionType = 'left' | 'right';
15
+
11
16
  interface RatingProps {
12
17
  id?: string;
13
18
  key?: string | number;
14
19
  style?: React.CSSProperties;
15
20
  count: number;
16
21
  half: boolean;
17
- char: string;
18
- size: number;
22
+ char: string | React.ReactNode;
19
23
  className?: string;
20
- onChange?: (value: any) => void;
24
+ charClassName?: string;
25
+ textClassName?: string;
26
+ onChange?: (value: number) => void;
27
+ onHoverChange?: (value: number) => void;
21
28
  value: number;
22
- containerClass: string;
29
+ containerClass?: string;
23
30
  readOnly: boolean;
24
31
  classPrefix: string;
25
32
  disabled?: boolean;
26
33
  allowClear?: boolean;
34
+ inactiveColor?: string;
35
+ colors?: string | {[propName: string]: string};
36
+ texts?: {[propName: string]: string};
37
+ textPosition?: textPositionType;
27
38
  classnames: ClassNamesFn;
28
39
  }
29
40
 
@@ -35,13 +46,22 @@ export class Rating extends React.Component<RatingProps, any> {
35
46
  allowClear: true,
36
47
  value: 0,
37
48
  count: 5,
38
- char: '★',
39
- size: 24
49
+ char: <Icon icon="star" className="icon" />,
50
+ colors: {
51
+ '2': '#abadb1',
52
+ '3': '#787b81',
53
+ '5': '#ffa900'
54
+ },
55
+ textPosition: 'right' as textPositionType
40
56
  };
41
57
 
58
+ starsNode: Record<string, any>;
59
+
42
60
  constructor(props: RatingProps) {
43
61
  super(props);
44
62
 
63
+ this.starsNode = {};
64
+
45
65
  this.state = {
46
66
  value: props.value || 0,
47
67
  stars: [],
@@ -49,7 +69,10 @@ export class Rating extends React.Component<RatingProps, any> {
49
69
  halfStar: {
50
70
  at: Math.floor(props.value),
51
71
  hidden: props.half && props.value % 1 < 0.5
52
- }
72
+ },
73
+ showColor: '',
74
+ showText: null,
75
+ hoverValue: null
53
76
  };
54
77
 
55
78
  this.getRate = this.getRate.bind(this);
@@ -58,6 +81,8 @@ export class Rating extends React.Component<RatingProps, any> {
58
81
  this.mouseOver = this.mouseOver.bind(this);
59
82
  this.mouseLeave = this.mouseLeave.bind(this);
60
83
  this.handleClick = this.handleClick.bind(this);
84
+ this.saveRef = this.saveRef.bind(this);
85
+ this.handleStarMouseLeave = this.handleStarMouseLeave.bind(this);
61
86
  }
62
87
 
63
88
  componentDidMount() {
@@ -65,6 +90,8 @@ export class Rating extends React.Component<RatingProps, any> {
65
90
  this.setState({
66
91
  stars: this.getStars(value)
67
92
  });
93
+
94
+ this.getShowColorAndText(value);
68
95
  }
69
96
 
70
97
  componentDidUpdate(prevProps: RatingProps) {
@@ -82,6 +109,55 @@ export class Rating extends React.Component<RatingProps, any> {
82
109
  }
83
110
  }
84
111
 
112
+ sortKeys(map: {[propName: number]: string}) {
113
+ return Object.keys(map).sort(
114
+ (a: number | string, b: number | string) => Number(a) - Number(b)
115
+ );
116
+ }
117
+
118
+ getShowColorAndText(value: number) {
119
+ const {colors, texts, half} = this.props;
120
+
121
+ if (!value)
122
+ return this.setState({
123
+ showText: null
124
+ });
125
+
126
+ // 对 value 取整
127
+ if (half) {
128
+ value = Math.floor(Number(value) * 2) / 2;
129
+ } else {
130
+ value = Math.floor(value);
131
+ }
132
+
133
+ if (colors && typeof colors !== 'string') {
134
+ const keys: string[] = this.sortKeys(colors);
135
+ const showKey = keys.filter(item => Number(item) < value).length;
136
+
137
+ const showColor = keys[showKey] !== undefined && colors[keys[showKey]];
138
+ showColor &&
139
+ this.setState({
140
+ showColor
141
+ });
142
+ } else if (colors && typeof colors === 'string') {
143
+ this.setState({
144
+ showColor: colors
145
+ });
146
+ }
147
+
148
+ if (texts && isObject(texts)) {
149
+ const keys: string[] = this.sortKeys(texts);
150
+ const showKey = keys.filter(item => Number(item) < value).length;
151
+ const showText =
152
+ keys[showKey] !== undefined &&
153
+ texts[keys[showKey] as keyof typeof texts];
154
+ showText &&
155
+ this.setState({
156
+ showText
157
+ });
158
+ }
159
+ }
160
+
85
161
  getRate() {
86
162
  let stars;
87
163
  const {value} = this.state;
@@ -108,14 +184,28 @@ export class Rating extends React.Component<RatingProps, any> {
108
184
  return stars;
109
185
  }
110
186
 
111
- mouseOver(event: React.ChangeEvent<any>) {
187
+ saveRef(index: number) {
188
+ return (node: React.ReactNode) => {
189
+ this.starsNode[String(index)] = node;
190
+ };
191
+ }
192
+
193
+ mouseOver(event: React.ChangeEvent<any>, index: number) {
112
194
  const {isClear} = this.state;
113
195
  if (isClear) return;
114
- let {readOnly, size, half} = this.props;
196
+
197
+ const {readOnly, half} = this.props;
198
+
115
199
  if (readOnly) return;
116
- let index = Number(event.target.getAttribute('data-index'));
200
+
117
201
  if (half) {
118
- const isAtHalf = this.moreThanHalf(event, size);
202
+ const isAtHalf = this.moreThanHalf(event, index);
203
+
204
+ const tmpValue = isAtHalf ? index + 1 : index + 0.5;
205
+
206
+ this.getShowColorAndText(tmpValue);
207
+ this.onHoverChange(tmpValue);
208
+
119
209
  if (isAtHalf) index = index + 1;
120
210
  this.setState({
121
211
  halfStar: {
@@ -125,24 +215,43 @@ export class Rating extends React.Component<RatingProps, any> {
125
215
  });
126
216
  } else {
127
217
  index = index + 1;
218
+ this.onHoverChange(index);
219
+ this.getShowColorAndText(index);
128
220
  }
129
221
  this.setState({
130
222
  stars: this.getStars(index)
131
223
  });
132
224
  }
133
225
 
134
- moreThanHalf(event: any, size: number) {
135
- let {target} = event;
136
- let mouseAt = event.clientX - target.getBoundingClientRect().left;
137
- mouseAt = Math.round(Math.abs(mouseAt));
138
- return mouseAt > size / 2;
226
+ onHoverChange(value: number) {
227
+ const {onHoverChange} = this.props;
228
+ const {hoverValue} = this.state;
229
+
230
+ if (!hoverValue || (hoverValue && hoverValue !== value)) {
231
+ this.setState({
232
+ hoverValue: value
233
+ });
234
+ onHoverChange && onHoverChange(value);
235
+ }
236
+ }
237
+
238
+ moreThanHalf(event: any, index: number) {
239
+ const star = this.starsNode[index];
240
+ const leftPos = star.getBoundingClientRect().left;
241
+
242
+ return event.clientX - leftPos > star.clientWidth / 2;
139
243
  }
140
244
 
141
245
  mouseLeave() {
142
246
  const {value, isClear} = this.state;
143
247
  const {half, readOnly} = this.props;
144
248
  if (readOnly) return;
145
- if (isClear) return this.setState({isClear: false});
249
+ if (isClear)
250
+ return this.setState({
251
+ isClear: false,
252
+ hoverValue: null
253
+ });
254
+
146
255
  if (half) {
147
256
  this.setState({
148
257
  halfStar: {
@@ -152,18 +261,39 @@ export class Rating extends React.Component<RatingProps, any> {
152
261
  });
153
262
  }
154
263
  this.setState({
155
- stars: this.getStars()
264
+ stars: this.getStars(),
265
+ hoverValue: null
156
266
  });
267
+ this.getShowColorAndText(value);
157
268
  }
158
269
 
159
- handleClick(event: React.ChangeEvent<any>) {
160
- const {half, readOnly, onChange, size, allowClear} = this.props;
270
+ handleStarMouseLeave(event: any, index: number) {
271
+ const star = this.starsNode[index];
272
+ const leftSideX = star.getBoundingClientRect().left;
273
+ const {isClear} = this.state;
274
+
275
+ if (isClear) return this.setState({isClear: false});
276
+
277
+ // leave star from left side
278
+ if (event.clientX <= leftSideX) {
279
+ this.getShowColorAndText(index);
280
+ this.setState({
281
+ stars: this.getStars(index),
282
+ halfStar: {
283
+ at: index,
284
+ hidden: true
285
+ }
286
+ });
287
+ }
288
+ }
289
+
290
+ handleClick(event: React.ChangeEvent<any>, index: number) {
291
+ const {half, readOnly, onChange, allowClear} = this.props;
161
292
  if (readOnly) return;
162
- let index = Number(event.target.getAttribute('data-index'));
163
293
 
164
294
  let value;
165
295
  if (half) {
166
- const isAtHalf = this.moreThanHalf(event, size);
296
+ const isAtHalf = this.moreThanHalf(event, index);
167
297
  if (isAtHalf) index = index + 1;
168
298
  value = isAtHalf ? index : index + 0.5;
169
299
  this.setState({
@@ -183,41 +313,99 @@ export class Rating extends React.Component<RatingProps, any> {
183
313
  stars: this.getStars(index),
184
314
  isClear
185
315
  });
316
+
317
+ this.getShowColorAndText(value);
318
+
186
319
  onChange && onChange(value);
187
320
  }
188
321
 
189
322
  renderStars() {
190
- const {halfStar, stars} = this.state;
191
- const {char, half, disabled, readOnly, classnames: cx} = this.props;
192
- return stars.map((star: any, i: number) => {
193
- let className = cx('Rating', {
194
- 'Rating-half': half && !halfStar.hidden && halfStar.at === i,
195
- 'is-active': star.active,
196
- 'is-disabled': readOnly || disabled
197
- });
323
+ const {halfStar, stars, showColor} = this.state;
324
+ const {
325
+ inactiveColor,
326
+ char,
327
+ half,
328
+ disabled,
329
+ readOnly,
330
+ charClassName,
331
+ classnames: cx
332
+ } = this.props;
198
333
 
199
- return (
200
- <span
201
- className={className}
202
- key={i}
203
- data-index={i}
204
- data-forhalf={char}
205
- onMouseOver={this.mouseOver}
206
- onMouseMove={this.mouseOver}
207
- onMouseLeave={this.mouseLeave}
208
- onClick={this.handleClick}
209
- >
210
- {char}
211
- </span>
212
- );
213
- });
334
+ return (
335
+ <ul onMouseLeave={this.mouseLeave}>
336
+ {stars.map((star: any, i: number) => {
337
+ const isThisHalf = half && !halfStar.hidden && halfStar.at === i;
338
+
339
+ return (
340
+ <li
341
+ ref={this.saveRef(i)}
342
+ className={cx('Rating-star', charClassName, {
343
+ 'is-half': isThisHalf,
344
+ 'is-active': star.active,
345
+ 'is-disabled': readOnly || disabled
346
+ })}
347
+ key={i}
348
+ style={{
349
+ color: star.active ? showColor : inactiveColor
350
+ }}
351
+ onMouseOver={e => this.mouseOver(e, i)}
352
+ onMouseMove={e => this.mouseOver(e, i)}
353
+ onClick={e => this.handleClick(e, i)}
354
+ onMouseLeave={e => this.handleStarMouseLeave(e, i)}
355
+ >
356
+ {isThisHalf && (
357
+ <div
358
+ className={cx('Rating-star-half')}
359
+ style={{
360
+ color: showColor
361
+ }}
362
+ >
363
+ {char}
364
+ </div>
365
+ )}
366
+ {char}
367
+ </li>
368
+ );
369
+ })}
370
+ </ul>
371
+ );
372
+ }
373
+
374
+ renderText() {
375
+ const {showText} = this.state;
376
+ const {textClassName, textPosition, classnames: cx} = this.props;
377
+
378
+ if (!showText) return null;
379
+
380
+ return (
381
+ <span
382
+ className={cx('Rating-text', textClassName, {
383
+ [`Rating-text--${textPosition === 'left' ? 'left' : 'right'}`]:
384
+ textPosition
385
+ })}
386
+ >
387
+ {showText}
388
+ </span>
389
+ );
214
390
  }
215
391
 
216
392
  render() {
217
- let {className} = this.props;
393
+ const {className, textPosition, classnames: cx} = this.props;
218
394
 
219
395
  return (
220
- <div className={cx(className ? className : '')}>{this.renderStars()}</div>
396
+ <div className={cx('Rating', className)}>
397
+ {textPosition === 'left' ? (
398
+ <>
399
+ {this.renderText()}
400
+ {this.renderStars()}
401
+ </>
402
+ ) : (
403
+ <>
404
+ {this.renderStars()}
405
+ {this.renderText()}
406
+ </>
407
+ )}
408
+ </div>
221
409
  );
222
410
  }
223
411
  }
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import {themeable, ThemeProps} from '../theme';
3
3
  import {Icon} from './icons';
4
4
  import {BaseSchema} from '../Schema';
5
+ import { isMobile } from '../utils/helper';
5
6
 
6
7
  export enum StepStatus {
7
8
  wait = 'wait',
@@ -78,6 +79,7 @@ export interface StepsProps extends ThemeProps {
78
79
  [propName: string]: StepStatus;
79
80
  };
80
81
  mode?: 'horizontal' | 'vertical';
82
+ useMobileUI?: boolean;
81
83
  }
82
84
 
83
85
  export function Steps(props: StepsProps) {
@@ -87,7 +89,8 @@ export function Steps(props: StepsProps) {
87
89
  className,
88
90
  current,
89
91
  status,
90
- mode = 'horizontal'
92
+ mode = 'horizontal',
93
+ useMobileUI
91
94
  } = props;
92
95
  const FINISH_ICON = 'check';
93
96
  const ERROR_ICON = 'close';
@@ -122,8 +125,9 @@ export function Steps(props: StepsProps) {
122
125
  };
123
126
  }
124
127
 
128
+ const mobileUI = useMobileUI && isMobile();
125
129
  return (
126
- <ul className={cx('Steps', `Steps--${mode}`, className)}>
130
+ <ul className={cx('Steps', `Steps--${mode}`, mobileUI ? 'Steps-mobile' : '', className)}>
127
131
  {stepsRow.map((step, i) => {
128
132
  const {stepStatus, icon} = getStepStatus(step, i);
129
133
 
@@ -133,7 +137,8 @@ export function Steps(props: StepsProps) {
133
137
  className={cx('StepsItem', `is-${stepStatus}`, step.className)}
134
138
  >
135
139
  <div className={cx('StepsItem-container')}>
136
- <div className={cx('StepsItem-containerIcon')}>
140
+ <div className={cx('StepsItem-containerIcon',
141
+ i < current && 'is-success')}>
137
142
  <span className={cx('StepsItem-icon')}>
138
143
  {icon ? <Icon icon={icon} className="icon" /> : i + 1}
139
144
  </span>
@@ -44,7 +44,7 @@ export class TransferPicker extends React.Component<TabsTransferPickerProps> {
44
44
  return (
45
45
  <PickerContainer
46
46
  title={__('Select.placeholder')}
47
- popOverRender={({onClose, value, onChange}) => {
47
+ bodyRender={({onClose, value, onChange}) => {
48
48
  return <TabsTransfer {...rest} value={value} onChange={onChange} />;
49
49
  }}
50
50
  value={value}
@@ -19,18 +19,9 @@ export interface TransferPickerProps extends Omit<TransferProps, 'itemRender'> {
19
19
  }
20
20
 
21
21
  export class TransferPicker extends React.Component<TransferPickerProps> {
22
- @autobind
23
- handleClose() {
24
- this.setState({
25
- inputValue: '',
26
- searchResult: null
27
- });
28
- }
29
-
30
22
  @autobind
31
23
  handleConfirm(value: any) {
32
24
  this.props.onChange?.(value);
33
- this.handleClose();
34
25
  }
35
26
 
36
27
  render() {
@@ -49,12 +40,11 @@ export class TransferPicker extends React.Component<TransferPickerProps> {
49
40
  return (
50
41
  <PickerContainer
51
42
  title={__('Select.placeholder')}
52
- popOverRender={({onClose, value, onChange}) => {
43
+ bodyRender={({onClose, value, onChange}) => {
53
44
  return <Transfer {...rest} value={value} onChange={onChange} />;
54
45
  }}
55
46
  value={value}
56
47
  onConfirm={this.handleConfirm}
57
- onCancel={this.handleClose}
58
48
  size={size}
59
49
  >
60
50
  {({onClick, isOpened}) => (