@nutui/nutui-react-taro 4.0.0-beta.3 → 4.0.0-beta.4

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 (63) hide show
  1. package/CHANGELOG.md +13 -6
  2. package/dist/cjs/packages/configprovider/types.d.ts +1 -1
  3. package/dist/cjs/packages/empty/empty.d.ts +4 -11
  4. package/dist/cjs/packages/empty/empty.js +21 -18
  5. package/dist/cjs/packages/empty/index.d.ts +1 -1
  6. package/dist/cjs/packages/empty/style/empty.scss +97 -31
  7. package/dist/cjs/packages/empty/style/style.css +77 -32
  8. package/dist/cjs/packages/empty/style/style.harmony.css +77 -32
  9. package/dist/cjs/packages/empty/style-jmapp/empty.scss +97 -31
  10. package/dist/cjs/packages/empty/style-jmapp/style.css +77 -32
  11. package/dist/cjs/packages/empty/style-jrkf/empty.scss +97 -31
  12. package/dist/cjs/packages/empty/style-jrkf/style.css +77 -32
  13. package/dist/cjs/packages/rate/index.d.ts +1 -1
  14. package/dist/cjs/packages/rate/rate.js +54 -8
  15. package/dist/cjs/packages/rate/style/rate.scss +244 -76
  16. package/dist/cjs/packages/rate/style/style.css +198 -68
  17. package/dist/cjs/packages/rate/style/style.harmony.css +198 -68
  18. package/dist/cjs/packages/rate/style-jmapp/rate.scss +244 -76
  19. package/dist/cjs/packages/rate/style-jmapp/style.css +198 -68
  20. package/dist/cjs/packages/rate/style-jrkf/rate.scss +244 -76
  21. package/dist/cjs/packages/rate/style-jrkf/style.css +198 -68
  22. package/dist/cjs/packages/steps/style/style.css +1 -1
  23. package/dist/cjs/packages/steps/style/style.harmony.css +1 -1
  24. package/dist/cjs/types/spec/empty/base.d.ts +12 -8
  25. package/dist/cjs/types/spec/empty/base.js +28 -1
  26. package/dist/cjs/types/spec/rate/base.d.ts +3 -0
  27. package/dist/es/packages/configprovider/types.d.ts +1 -1
  28. package/dist/es/packages/empty/empty.d.ts +4 -11
  29. package/dist/es/packages/empty/empty.js +21 -18
  30. package/dist/es/packages/empty/index.d.ts +1 -1
  31. package/dist/es/packages/empty/style/empty.scss +97 -31
  32. package/dist/es/packages/empty/style/style.css +77 -32
  33. package/dist/es/packages/empty/style/style.harmony.css +77 -32
  34. package/dist/es/packages/empty/style-jmapp/empty.scss +97 -31
  35. package/dist/es/packages/empty/style-jmapp/style.css +77 -32
  36. package/dist/es/packages/empty/style-jrkf/empty.scss +97 -31
  37. package/dist/es/packages/empty/style-jrkf/style.css +77 -32
  38. package/dist/es/packages/rate/index.d.ts +1 -1
  39. package/dist/es/packages/rate/rate.js +54 -8
  40. package/dist/es/packages/rate/style/rate.scss +244 -76
  41. package/dist/es/packages/rate/style/style.css +198 -68
  42. package/dist/es/packages/rate/style/style.harmony.css +198 -68
  43. package/dist/es/packages/rate/style-jmapp/rate.scss +244 -76
  44. package/dist/es/packages/rate/style-jmapp/style.css +198 -68
  45. package/dist/es/packages/rate/style-jrkf/rate.scss +244 -76
  46. package/dist/es/packages/rate/style-jrkf/style.css +198 -68
  47. package/dist/es/packages/steps/style/style.css +1 -1
  48. package/dist/es/packages/steps/style/style.harmony.css +1 -1
  49. package/dist/es/types/spec/empty/base.d.ts +15 -11
  50. package/dist/es/types/spec/empty/base.js +13 -1
  51. package/dist/es/types/spec/rate/base.d.ts +10 -1
  52. package/dist/nutui.react.umd.js +97 -34
  53. package/dist/style-jmapp.css +1 -1
  54. package/dist/style-jmapp.scss +32 -32
  55. package/dist/style-jrkf.css +1 -1
  56. package/dist/style-jrkf.scss +31 -31
  57. package/dist/style.css +1 -1
  58. package/dist/style.scss +49 -49
  59. package/dist/styles/variables-daojia.scss +25 -12
  60. package/dist/styles/variables-jmapp.scss +42 -17
  61. package/dist/styles/variables-jrkf.scss +24 -20
  62. package/dist/styles/variables.scss +32 -24
  63. package/package.json +1 -1
@@ -24,6 +24,7 @@ var _getrect = require("../../utils/taro/get-rect");
24
24
  var _userefs = require("../../hooks/use-refs");
25
25
  var defaultProps = (0, _object_spread_props._)((0, _object_spread._)({}, _typings.ComponentDefaults), {
26
26
  size: 'normal',
27
+ direction: 'horizontal',
27
28
  showScore: false,
28
29
  count: 5,
29
30
  min: 0,
@@ -35,15 +36,29 @@ var defaultProps = (0, _object_spread_props._)((0, _object_spread._)({}, _typing
35
36
  touchable: false
36
37
  });
37
38
  var Rate = function Rate(props) {
38
- var _$_object_spread = (0, _object_spread._)({}, defaultProps, props), className = _$_object_spread.className, style = _$_object_spread.style, size = _$_object_spread.size, showScore = _$_object_spread.showScore, count = _$_object_spread.count, value = _$_object_spread.value, defaultValue = _$_object_spread.defaultValue, min = _$_object_spread.min, checkedIcon = _$_object_spread.checkedIcon, uncheckedIcon = _$_object_spread.uncheckedIcon, disabled = _$_object_spread.disabled, readOnly = _$_object_spread.readOnly, allowHalf = _$_object_spread.allowHalf, touchable = _$_object_spread.touchable, onChange = _$_object_spread.onChange, onTouchEnd = _$_object_spread.onTouchEnd;
39
+ var _$_object_spread = (0, _object_spread._)({}, defaultProps, props), className = _$_object_spread.className, style = _$_object_spread.style, size = _$_object_spread.size, direction = _$_object_spread.direction, label = _$_object_spread.label, showScore = _$_object_spread.showScore, count = _$_object_spread.count, value = _$_object_spread.value, defaultValue = _$_object_spread.defaultValue, min = _$_object_spread.min, checkedIcon = _$_object_spread.checkedIcon, uncheckedIcon = _$_object_spread.uncheckedIcon, disabled = _$_object_spread.disabled, readOnly = _$_object_spread.readOnly, allowHalf = _$_object_spread.allowHalf, touchable = _$_object_spread.touchable, onChange = _$_object_spread.onChange, onTouchEnd = _$_object_spread.onTouchEnd;
39
40
  var classPrefix = 'nut-rate';
40
- var _useState = (0, _sliced_to_array._)((0, _react.useState)([
41
+ var shouldAnimate = direction === 'vertical' || size === 'large';
42
+ var _useState = (0, _sliced_to_array._)((0, _react.useState)(-1), 2), animatingIndex = _useState[0], setAnimatingIndex = _useState[1];
43
+ (0, _react.useEffect)(function() {
44
+ if (animatingIndex >= 0) {
45
+ var timer = setTimeout(function() {
46
+ return setAnimatingIndex(-1);
47
+ }, 300);
48
+ return function() {
49
+ return clearTimeout(timer);
50
+ };
51
+ }
52
+ }, [
53
+ animatingIndex
54
+ ]);
55
+ var _useState1 = (0, _sliced_to_array._)((0, _react.useState)([
41
56
  1,
42
57
  2,
43
58
  3,
44
59
  4,
45
60
  5
46
- ]), 2), countArray = _useState[0], setCountArray = _useState[1];
61
+ ]), 2), countArray = _useState1[0], setCountArray = _useState1[1];
47
62
  var _useRefs = (0, _sliced_to_array._)((0, _userefs.useRefs)(), 2), refs = _useRefs[0], setRefs = _useRefs[1];
48
63
  var rateRects = (0, _react.useRef)([]);
49
64
  var _usePropsValue = (0, _sliced_to_array._)((0, _usepropsvalue.usePropsValue)({
@@ -75,12 +90,18 @@ var Rate = function Rate(props) {
75
90
  value = index;
76
91
  }
77
92
  value = Math.max(value, min);
93
+ if (shouldAnimate && value > score) {
94
+ setAnimatingIndex(index - 1);
95
+ }
78
96
  setScore(value);
79
97
  };
80
98
  var onHalfClick = function onHalfClick(event, n) {
81
99
  event.preventDefault();
82
100
  event.stopPropagation();
83
101
  var value = Math.max(min, n - 0.5);
102
+ if (shouldAnimate && value > score) {
103
+ setAnimatingIndex(n - 1);
104
+ }
84
105
  setScore(value);
85
106
  };
86
107
  var getScoreByPosition = function getScoreByPosition(x) {
@@ -150,8 +171,32 @@ var Rate = function Rate(props) {
150
171
  onTouchEnd && onTouchEnd(e, Math.max(min, val));
151
172
  }
152
173
  };
174
+ var isArrayLabel = Array.isArray(label);
175
+ var renderSingleLabel = function renderSingleLabel() {
176
+ if (label == null || isArrayLabel) return null;
177
+ return /*#__PURE__*/ _react.default.createElement(_components.Text, {
178
+ className: (0, _classnames.default)("".concat(classPrefix, "-label"), "".concat(classPrefix, "-label-").concat(size))
179
+ }, label);
180
+ };
181
+ var renderArrayLabels = function renderArrayLabels() {
182
+ if (!isArrayLabel) return null;
183
+ return /*#__PURE__*/ _react.default.createElement(_components.View, {
184
+ className: (0, _classnames.default)("".concat(classPrefix, "-labels"), "".concat(classPrefix, "-labels-").concat(size))
185
+ }, label.map(function(item, index) {
186
+ return /*#__PURE__*/ _react.default.createElement(_components.Text, {
187
+ className: "".concat(classPrefix, "-labels-item"),
188
+ key: index
189
+ }, item);
190
+ }));
191
+ };
192
+ var renderScore = function renderScore() {
193
+ if (!showScore) return null;
194
+ return /*#__PURE__*/ _react.default.createElement(_components.Text, {
195
+ className: (0, _classnames.default)("".concat(classPrefix, "-score"), "".concat(classPrefix, "-score-").concat(size), (0, _define_property._)({}, "".concat(classPrefix, "-score-disabled"), disabled))
196
+ }, score.toFixed(1));
197
+ };
153
198
  return /*#__PURE__*/ _react.default.createElement(_components.View, {
154
- className: (0, _classnames.default)(classPrefix, {
199
+ className: (0, _classnames.default)(classPrefix, "".concat(classPrefix, "-").concat(direction), {
155
200
  disabled: disabled,
156
201
  readonly: readOnly
157
202
  }, className),
@@ -161,7 +206,10 @@ var Rate = function Rate(props) {
161
206
  onTouchMove: handleTouchMove,
162
207
  onTouchEnd: handleTouchEnd,
163
208
  onTouchCancel: handleTouchEnd
209
+ }, direction === 'horizontal' && renderSingleLabel(), /*#__PURE__*/ _react.default.createElement(_components.View, {
210
+ className: "".concat(classPrefix, "-list")
164
211
  }, countArray.map(function(n, index) {
212
+ var _obj;
165
213
  return /*#__PURE__*/ _react.default.createElement(_components.View, {
166
214
  className: "".concat(classPrefix, "-item ").concat(classPrefix, "-item-").concat(size),
167
215
  key: n,
@@ -170,15 +218,13 @@ var Rate = function Rate(props) {
170
218
  return onClick(event, n);
171
219
  }
172
220
  }, /*#__PURE__*/ _react.default.createElement(_components.View, {
173
- className: (0, _classnames.default)("".concat(classPrefix, "-item-icon"), (0, _define_property._)({}, "".concat(classPrefix, "-item-icon-disabled"), disabled || n > score))
221
+ className: (0, _classnames.default)("".concat(classPrefix, "-item-icon"), (_obj = {}, (0, _define_property._)(_obj, "".concat(classPrefix, "-item-icon-disabled"), disabled || n > score), (0, _define_property._)(_obj, "".concat(classPrefix, "-item-icon-animate"), animatingIndex === index), _obj))
174
222
  }, renderIcon(n)), allowHalf && score > n - 1 && /*#__PURE__*/ _react.default.createElement(_components.View, {
175
223
  className: (0, _classnames.default)("".concat(classPrefix, "-item-half"), "".concat(classPrefix, "-item-icon"), "".concat(classPrefix, "-item-icon-half")),
176
224
  onClick: function onClick(event) {
177
225
  return onHalfClick(event, n);
178
226
  }
179
227
  }, renderIcon(n)));
180
- }), showScore ? /*#__PURE__*/ _react.default.createElement(_components.Text, {
181
- className: (0, _classnames.default)("".concat(classPrefix, "-score"), "".concat(classPrefix, "-score-").concat(size), (0, _define_property._)({}, "".concat(classPrefix, "-score-disabled"), disabled))
182
- }, score.toFixed(1)) : null);
228
+ })), direction === 'horizontal' && renderScore(), direction === 'vertical' && /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, renderScore(), isArrayLabel ? renderArrayLabels() : renderSingleLabel()));
183
229
  };
184
230
  Rate.displayName = 'NutRate';
@@ -14,6 +14,37 @@
14
14
  }
15
15
  }
16
16
 
17
+ &-horizontal {
18
+ flex-direction: row;
19
+ align-items: center;
20
+ }
21
+
22
+ &-vertical {
23
+ flex-direction: column;
24
+ align-items: center;
25
+ }
26
+
27
+ &-list {
28
+ display: flex;
29
+ align-items: center;
30
+ }
31
+
32
+ &-label {
33
+ color: $rate-label-color;
34
+ white-space: nowrap;
35
+ }
36
+
37
+ &-labels {
38
+ display: flex;
39
+ width: 100%;
40
+
41
+ &-item {
42
+ flex: 1;
43
+ text-align: center;
44
+ color: $rate-label-color;
45
+ }
46
+ }
47
+
17
48
  &-item {
18
49
  display: flex;
19
50
  align-items: center;
@@ -33,38 +64,6 @@
33
64
  }
34
65
  }
35
66
 
36
- &-normal {
37
- margin-left: $rate-item-margin;
38
- .nut-icon {
39
- height: $rate-icon-size;
40
- width: $rate-icon-size;
41
- }
42
- }
43
-
44
- &-large {
45
- margin-left: calc($rate-item-margin * 2);
46
- .nut-icon {
47
- height: calc($rate-icon-size + scale-px(8px));
48
- width: calc($rate-icon-size + scale-px(8px));
49
- }
50
- }
51
-
52
- &-small {
53
- margin-left: calc($rate-item-margin / 2);
54
- .nut-icon {
55
- height: calc($rate-icon-size - scale-px(4px));
56
- width: calc($rate-icon-size - scale-px(4px));
57
- }
58
- }
59
-
60
- &-normal,
61
- &-large,
62
- &-small {
63
- &:first-child {
64
- margin-left: 0;
65
- }
66
- }
67
-
68
67
  &-icon {
69
68
  display: flex;
70
69
  align-items: center;
@@ -93,6 +92,10 @@
93
92
  left: auto;
94
93
  transform: none;
95
94
  }
95
+
96
+ &-animate {
97
+ animation: nut-rate-bounce 0.3s ease-in-out;
98
+ }
96
99
  }
97
100
  }
98
101
 
@@ -107,85 +110,250 @@
107
110
  color: $rate-font-color;
108
111
  font-family: 'JDZH-Regular';
109
112
 
110
- &-normal {
111
- padding-left: $rate-item-margin;
112
- font-size: $rate-font-size;
113
+ &-disabled {
114
+ color: $rate-icon-inactive-color;
115
+ }
116
+ }
117
+
118
+ // horizontal layout
119
+ &-horizontal {
120
+ .nut-rate-item {
121
+ margin-left: $rate-item-margin;
122
+ &:first-child {
123
+ margin-left: 0;
124
+ }
125
+ }
126
+
127
+ // 12DP - star gap 2px
128
+ .nut-rate-item-small {
129
+ margin-left: scale-px(2px);
130
+ &:first-child {
131
+ margin-left: 0;
132
+ }
133
+ .nut-icon {
134
+ height: scale-font-px(12px);
135
+ width: scale-font-px(12px);
136
+ }
137
+ }
138
+
139
+ .nut-rate-item-normal {
140
+ .nut-icon {
141
+ height: scale-font-px(16px);
142
+ width: scale-font-px(16px);
143
+ }
144
+ }
145
+
146
+ .nut-rate-item-large {
147
+ .nut-icon {
148
+ height: scale-font-px(20px);
149
+ width: scale-font-px(20px);
150
+ }
151
+ }
152
+
153
+ .nut-rate-label-small {
154
+ font-size: $font-size-s;
155
+ margin-right: scale-px(4px);
156
+ }
157
+
158
+ .nut-rate-label-normal {
159
+ font-size: $font-size-s;
160
+ margin-right: scale-px(12px);
161
+ }
162
+
163
+ .nut-rate-label-large {
164
+ font-size: $font-size-base;
165
+ margin-right: scale-px(12px);
166
+ }
167
+
168
+ .nut-rate-score-small {
169
+ padding-left: scale-px(4px);
170
+ font-size: $font-size-s;
113
171
  line-height: $line-height-s;
114
172
  }
115
173
 
116
- &-large {
117
- font-size: $rate-font-size-large;
118
- line-height: $line-height-xl;
119
- padding-left: calc($rate-item-margin * 2);
174
+ .nut-rate-score-normal {
175
+ padding-left: scale-px(12px);
176
+ font-size: $font-size-s;
177
+ line-height: $line-height-s;
120
178
  }
121
179
 
122
- &-small {
123
- font-size: $rate-font-size-small;
124
- line-height: $line-height-xxs;
125
- padding-left: calc($rate-item-margin / 2);
180
+ .nut-rate-score-large {
181
+ padding-left: scale-px(12px);
182
+ font-size: $font-size-base;
183
+ line-height: $line-height-base;
126
184
  }
185
+ }
127
186
 
128
- &-disabled {
129
- color: $rate-icon-inactive-color;
187
+ // vertical layout
188
+ &-vertical {
189
+ .nut-rate-list {
190
+ justify-content: center;
191
+ width: 100%;
192
+ }
193
+
194
+ .nut-rate-item {
195
+ margin-left: $rate-item-margin;
196
+ &:first-child {
197
+ margin-left: 0;
198
+ }
199
+ }
200
+
201
+ .nut-rate-item-small,
202
+ .nut-rate-item-normal {
203
+ .nut-icon {
204
+ height: scale-font-px(20px);
205
+ width: scale-font-px(20px);
206
+ }
207
+ }
208
+
209
+ .nut-rate-item-large {
210
+ flex: 1;
211
+ justify-content: center;
212
+
213
+ .nut-icon {
214
+ height: scale-font-px(28px);
215
+ width: scale-font-px(28px);
216
+ }
217
+ }
218
+
219
+ .nut-rate-label-small,
220
+ .nut-rate-label-normal {
221
+ font-size: $font-size-xs;
222
+ margin-top: scale-px(6px);
223
+ }
224
+
225
+ .nut-rate-label-large {
226
+ font-size: $font-size-s;
227
+ margin-top: scale-px(8px);
228
+ }
229
+
230
+ .nut-rate-labels {
231
+ width: 100%;
232
+ }
233
+
234
+ .nut-rate-labels-small,
235
+ .nut-rate-labels-normal {
236
+ margin-top: scale-px(6px);
237
+
238
+ .nut-rate-labels-item {
239
+ font-size: $font-size-xs;
240
+ }
241
+ }
242
+
243
+ .nut-rate-labels-large {
244
+ margin-top: scale-px(8px);
245
+
246
+ .nut-rate-labels-item {
247
+ font-size: $font-size-s;
248
+ }
249
+ }
250
+
251
+ .nut-rate-score-small,
252
+ .nut-rate-score-normal {
253
+ font-size: $font-size-xs;
254
+ line-height: $line-height-xs;
255
+ margin-top: scale-px(6px);
256
+ }
257
+
258
+ .nut-rate-score-large {
259
+ font-size: $font-size-s;
260
+ line-height: $line-height-s;
261
+ margin-top: scale-px(8px);
130
262
  }
131
263
  }
132
264
  }
133
265
 
266
+ @keyframes nut-rate-bounce {
267
+ 0% {
268
+ transform: scale(1);
269
+ }
270
+ 50% {
271
+ transform: scale(1.25);
272
+ }
273
+ 100% {
274
+ transform: scale(1);
275
+ }
276
+ }
277
+
134
278
  [dir='rtl'] .nut-rate,
135
279
  .nut-rtl .nut-rate {
136
- &-item {
137
- margin-left: 0;
138
- &:first-child {
280
+ &-horizontal {
281
+ .nut-rate-item {
282
+ margin-left: 0;
283
+ margin-right: $rate-item-margin;
284
+
285
+ &:first-child {
286
+ margin-right: 0;
287
+ }
288
+ }
289
+
290
+ .nut-rate-item-small {
291
+ margin-left: 0;
292
+ margin-right: scale-px(2px);
293
+
294
+ &:first-child {
295
+ margin-right: 0;
296
+ }
297
+ }
298
+
299
+ .nut-rate-label {
139
300
  margin-right: 0;
140
301
  }
141
302
 
142
- &-normal {
143
- margin-right: $rate-item-margin;
303
+ .nut-rate-label-small {
304
+ margin-left: scale-px(4px);
144
305
  }
145
306
 
146
- &-large {
147
- margin-right: calc($rate-item-margin * 2);
307
+ .nut-rate-label-normal {
308
+ margin-left: scale-px(12px);
148
309
  }
149
310
 
150
- &-small {
151
- margin-right: calc($rate-item-margin - scale-px(2px));
311
+ .nut-rate-label-large {
312
+ margin-left: scale-px(12px);
152
313
  }
153
314
 
154
- &:last-child {
155
- margin-left: 0;
315
+ .nut-rate-score {
316
+ padding-left: 0;
156
317
  }
157
318
 
158
- &-half {
159
- left: auto;
160
- right: 0;
319
+ .nut-rate-score-small {
320
+ padding-right: scale-px(4px);
161
321
  }
162
322
 
163
- &-icon {
164
- &.nut-rate-item-icon.nut-rate-item-icon-half {
165
- left: auto;
166
- right: 0;
167
- }
323
+ .nut-rate-score-normal {
324
+ padding-right: scale-px(12px);
325
+ }
168
326
 
169
- &.nut-rate-item-icon::before {
170
- left: auto;
171
- right: auto;
172
- }
327
+ .nut-rate-score-large {
328
+ padding-right: scale-px(12px);
173
329
  }
174
330
  }
175
331
 
176
- &-score {
177
- padding-left: 0;
332
+ &-vertical {
333
+ .nut-rate-item {
334
+ margin-left: 0;
335
+ margin-right: $rate-item-margin;
178
336
 
179
- &-large {
180
- padding-right: calc($rate-item-margin * 2);
337
+ &:first-child {
338
+ margin-right: 0;
339
+ }
181
340
  }
341
+ }
182
342
 
183
- &-normal {
184
- padding-right: $rate-item-margin;
343
+ &-item-half {
344
+ left: auto;
345
+ right: 0;
346
+ }
347
+
348
+ &-item-icon {
349
+ &.nut-rate-item-icon.nut-rate-item-icon-half {
350
+ left: auto;
351
+ right: 0;
185
352
  }
186
353
 
187
- &-small {
188
- padding-right: calc($rate-item-margin - scale-px(2px));
354
+ &.nut-rate-item-icon::before {
355
+ left: auto;
356
+ right: auto;
189
357
  }
190
358
  }
191
359
  }