@nutui/nutui-react-taro 3.0.14 → 3.0.16

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 (90) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/cjs/packages/button/style/button.scss +3 -0
  3. package/dist/cjs/packages/button/style/style.css +3 -3
  4. package/dist/cjs/packages/button/style/style.harmony.css +12 -0
  5. package/dist/cjs/packages/button/style-jmapp/button.scss +3 -0
  6. package/dist/cjs/packages/button/style-jmapp/style.css +3 -3
  7. package/dist/cjs/packages/button/style-jrkf/button.scss +3 -0
  8. package/dist/cjs/packages/button/style-jrkf/style.css +3 -3
  9. package/dist/cjs/packages/calendarcard/calendarcard.js +10 -4
  10. package/dist/cjs/packages/calendaritem/calendaritem.d.ts +1 -1
  11. package/dist/cjs/packages/calendaritem/calendaritem.js +3 -3
  12. package/dist/cjs/packages/configprovider/types.d.ts +1 -1
  13. package/dist/cjs/packages/datepicker/utils.js +22 -37
  14. package/dist/cjs/packages/dialog/dialog.js +2 -7
  15. package/dist/cjs/packages/formitem/formitem.js +2 -2
  16. package/dist/cjs/packages/formitem/style/formitem.scss +14 -15
  17. package/dist/cjs/packages/formitem/style/style.css +9 -11
  18. package/dist/cjs/packages/formitem/style/style.harmony.css +8 -10
  19. package/dist/cjs/packages/formitem/style-jmapp/formitem.scss +14 -15
  20. package/dist/cjs/packages/formitem/style-jmapp/style.css +8 -10
  21. package/dist/cjs/packages/formitem/style-jrkf/formitem.scss +14 -15
  22. package/dist/cjs/packages/formitem/style-jrkf/style.css +8 -10
  23. package/dist/cjs/packages/imagepreview/imagepreview.js +25 -4
  24. package/dist/cjs/packages/noticebar/noticebar.js +66 -42
  25. package/dist/cjs/packages/overlay/style/overlay.scss +0 -1
  26. package/dist/cjs/packages/overlay/style/style.css +0 -1
  27. package/dist/cjs/packages/overlay/style/style.harmony.css +0 -1
  28. package/dist/cjs/packages/overlay/style-jmapp/overlay.scss +0 -1
  29. package/dist/cjs/packages/overlay/style-jmapp/style.css +0 -1
  30. package/dist/cjs/packages/overlay/style-jrkf/overlay.scss +0 -1
  31. package/dist/cjs/packages/overlay/style-jrkf/style.css +0 -1
  32. package/dist/cjs/packages/pickerview/pickerroller.js +9 -1
  33. package/dist/cjs/packages/swiper/index.d.ts +1 -1
  34. package/dist/cjs/packages/swiper/swiper.js +6 -0
  35. package/dist/cjs/types/spec/calendar/base.d.ts +3 -1
  36. package/dist/cjs/types/spec/calendarcard/base.d.ts +1 -0
  37. package/dist/cjs/types/spec/datepicker/base.d.ts +1 -1
  38. package/dist/cjs/types/spec/imagepreview/h5.d.ts +4 -1
  39. package/dist/cjs/types/spec/imagepreview/taro.d.ts +4 -1
  40. package/dist/cjs/utils/date.d.ts +2 -2
  41. package/dist/cjs/utils/date.js +2 -2
  42. package/dist/es/packages/button/style/button.scss +3 -0
  43. package/dist/es/packages/button/style/style.css +3 -3
  44. package/dist/es/packages/button/style/style.harmony.css +12 -0
  45. package/dist/es/packages/button/style-jmapp/button.scss +3 -0
  46. package/dist/es/packages/button/style-jmapp/style.css +3 -3
  47. package/dist/es/packages/button/style-jrkf/button.scss +3 -0
  48. package/dist/es/packages/button/style-jrkf/style.css +3 -3
  49. package/dist/es/packages/calendarcard/calendarcard.js +11 -5
  50. package/dist/es/packages/calendaritem/calendaritem.d.ts +1 -1
  51. package/dist/es/packages/calendaritem/calendaritem.js +3 -3
  52. package/dist/es/packages/configprovider/types.d.ts +1 -1
  53. package/dist/es/packages/datepicker/utils.js +22 -37
  54. package/dist/es/packages/dialog/dialog.js +2 -7
  55. package/dist/es/packages/formitem/formitem.js +2 -2
  56. package/dist/es/packages/formitem/style/formitem.scss +14 -15
  57. package/dist/es/packages/formitem/style/style.css +9 -11
  58. package/dist/es/packages/formitem/style/style.harmony.css +8 -10
  59. package/dist/es/packages/formitem/style-jmapp/formitem.scss +14 -15
  60. package/dist/es/packages/formitem/style-jmapp/style.css +8 -10
  61. package/dist/es/packages/formitem/style-jrkf/formitem.scss +14 -15
  62. package/dist/es/packages/formitem/style-jrkf/style.css +8 -10
  63. package/dist/es/packages/imagepreview/imagepreview.js +25 -4
  64. package/dist/es/packages/noticebar/noticebar.js +67 -43
  65. package/dist/es/packages/overlay/style/overlay.scss +0 -1
  66. package/dist/es/packages/overlay/style/style.css +0 -1
  67. package/dist/es/packages/overlay/style/style.harmony.css +0 -1
  68. package/dist/es/packages/overlay/style-jmapp/overlay.scss +0 -1
  69. package/dist/es/packages/overlay/style-jmapp/style.css +0 -1
  70. package/dist/es/packages/overlay/style-jrkf/overlay.scss +0 -1
  71. package/dist/es/packages/overlay/style-jrkf/style.css +0 -1
  72. package/dist/es/packages/pickerview/pickerroller.js +9 -1
  73. package/dist/es/packages/swiper/index.d.ts +1 -1
  74. package/dist/es/packages/swiper/swiper.js +7 -1
  75. package/dist/es/types/spec/calendar/base.d.ts +3 -1
  76. package/dist/es/types/spec/calendarcard/base.d.ts +4 -0
  77. package/dist/es/types/spec/datepicker/base.d.ts +1 -1
  78. package/dist/es/types/spec/imagepreview/h5.d.ts +4 -1
  79. package/dist/es/types/spec/imagepreview/taro.d.ts +4 -1
  80. package/dist/es/utils/date.d.ts +2 -2
  81. package/dist/es/utils/date.js +2 -2
  82. package/dist/nutui.react.umd.js +145 -101
  83. package/dist/style-jmapp.css +1 -1
  84. package/dist/style-jmapp.scss +40 -40
  85. package/dist/style-jrkf.css +1 -1
  86. package/dist/style-jrkf.scss +41 -41
  87. package/dist/style.css +1 -1
  88. package/dist/style.scss +37 -37
  89. package/dist/styles/variables.scss +1 -2
  90. package/package.json +1 -1
@@ -65,8 +65,6 @@ export var BaseDialog = function(props) {
65
65
  var handleCancel = function(e) {
66
66
  e.stopPropagation();
67
67
  if (!(beforeCancel === null || beforeCancel === void 0 ? void 0 : beforeCancel())) return;
68
- if (!(beforeClose === null || beforeClose === void 0 ? void 0 : beforeClose())) return;
69
- onClose();
70
68
  onCancel();
71
69
  };
72
70
  var handleOk = /*#__PURE__*/ function() {
@@ -152,24 +150,21 @@ export var BaseDialog = function(props) {
152
150
  };
153
151
  var renderCloseIcon = function() {
154
152
  if (!closeIcon) return null;
155
- var handleCancel = function() {
156
- if (!(beforeCancel === null || beforeCancel === void 0 ? void 0 : beforeCancel())) return;
153
+ var handleClose = function() {
157
154
  if (!(beforeClose === null || beforeClose === void 0 ? void 0 : beforeClose())) return;
158
155
  onClose();
159
- onCancel();
160
156
  };
161
157
  var _obj;
162
158
  var closeClasses = classNames((_obj = {}, _define_property(_obj, "".concat(classPrefix, "-close"), true), _define_property(_obj, "".concat(classPrefix, "-close-").concat(closeIconPosition), true), _obj));
163
159
  var systomIcon = closeIconPosition !== 'bottom' ? /*#__PURE__*/ React.createElement(Close, null) : /*#__PURE__*/ React.createElement(Failure, null);
164
160
  return /*#__PURE__*/ React.createElement(View, {
165
161
  className: closeClasses,
166
- onClick: handleCancel
162
+ onClick: handleClose
167
163
  }, /*#__PURE__*/ React.isValidElement(closeIcon) ? closeIcon : systomIcon);
168
164
  };
169
165
  var onHandleClickOverlay = function(e) {
170
166
  if (closeOnOverlayClick && visible && e.target === e.currentTarget) {
171
167
  var closed = onOverlayClick && onOverlayClick(e);
172
- closed && onClose();
173
168
  closed && onCancel();
174
169
  }
175
170
  };
@@ -126,11 +126,11 @@ export var FormItem = /*#__PURE__*/ function(_superClass) {
126
126
  var item = name ? _this.context.formInstance.errors[name] : [];
127
127
  var starPosition = _this.context.formInstance.starPosition;
128
128
  var renderStar = (required || requiredInRules) && /*#__PURE__*/ React.createElement(Text, {
129
- className: "nut-form-item-label-required required"
129
+ className: "nut-form-item-label-".concat(starPosition, "-required required")
130
130
  }, "*");
131
131
  var renderLabel = /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Text, {
132
132
  className: "nut-form-item-labeltxt"
133
- }, starPosition === 'left' ? renderStar : null, label), starPosition === 'right' ? renderStar : null);
133
+ }, starPosition === 'left' ? renderStar : null, label, starPosition === 'right' ? renderStar : null));
134
134
  return /*#__PURE__*/ React.createElement(Cell, {
135
135
  className: "".concat(_this.getClassNameWithDirection('nut-form-item'), " ").concat(className),
136
136
  style: style,
@@ -18,19 +18,25 @@
18
18
  word-wrap: break-word;
19
19
  text-align: $form-item-label-text-align;
20
20
  line-height: unset;
21
- }
22
21
 
23
- &-label-required {
24
- color: $form-item-required-color;
25
- margin-right: $form-item-required-margin-right;
26
- display: block;
27
- position: absolute;
28
- left: -10px;
22
+ &-left-required {
23
+ color: $form-item-required-color;
24
+ margin-right: $form-item-required-margin-right;
25
+ position: absolute;
26
+ left: -10px;
27
+ }
28
+
29
+ &-right-required {
30
+ color: $form-item-required-color;
31
+ margin-left: $form-item-required-margin-right;
32
+ position: absolute;
33
+ right: -10px;
34
+ }
29
35
  }
30
36
 
31
37
  .nut-form-item-labeltxt {
32
38
  position: relative;
33
- font-size: 12px;
39
+ font-size: $form-item-label-font-size;
34
40
  }
35
41
 
36
42
  &-body {
@@ -136,13 +142,6 @@
136
142
  white-space: nowrap;
137
143
  }
138
144
 
139
- .nut-form-item-label-left-required {
140
- display: block;
141
- line-height: 1.5;
142
- position: absolute;
143
- left: 0.1em;
144
- }
145
-
146
145
  .nut-form-item-top {
147
146
  flex-direction: column;
148
147
  align-items: flex-start;
@@ -13,7 +13,7 @@
13
13
  .nut-form-item-label {
14
14
  display: flex;
15
15
  flex-direction: row;
16
- font-size: var(--nutui-form-item-label-font-size, var(--nutui-font-size-base, 14px));
16
+ font-size: var(--nutui-form-item-label-font-size, var(--nutui-font-size-s, 12px));
17
17
  font-weight: normal;
18
18
  width: var(--nutui-form-item-label-width, 90px);
19
19
  margin-right: var(--nutui-form-item-label-margin-right, 10px);
@@ -22,16 +22,21 @@
22
22
  text-align: var(--nutui-form-item-label-text-align, left);
23
23
  line-height: unset;
24
24
  }
25
- .nut-form-item-label-required {
25
+ .nut-form-item-label-left-required {
26
26
  color: var(--nutui-form-item-required-color, var(--nutui-color-primary, #ff0f23));
27
27
  margin-right: var(--nutui-form-item-required-margin-right, 4px);
28
- display: block;
29
28
  position: absolute;
30
29
  left: -10px;
31
30
  }
31
+ .nut-form-item-label-right-required {
32
+ color: var(--nutui-form-item-required-color, var(--nutui-color-primary, #ff0f23));
33
+ margin-left: var(--nutui-form-item-required-margin-right, 4px);
34
+ position: absolute;
35
+ right: -10px;
36
+ }
32
37
  .nut-form-item .nut-form-item-labeltxt {
33
38
  position: relative;
34
- font-size: 12px;
39
+ font-size: var(--nutui-form-item-label-font-size, var(--nutui-font-size-s, 12px));
35
40
  }
36
41
  .nut-form-item-body {
37
42
  flex: 1;
@@ -121,13 +126,6 @@
121
126
  white-space: nowrap;
122
127
  }
123
128
 
124
- .nut-form-item-label-left-required {
125
- display: block;
126
- line-height: 1.5;
127
- position: absolute;
128
- left: 0.1em;
129
- }
130
-
131
129
  .nut-form-item-top {
132
130
  flex-direction: column;
133
131
  align-items: flex-start;
@@ -13,7 +13,7 @@
13
13
  .nut-form-item-label {
14
14
  display: flex;
15
15
  flex-direction: row;
16
- font-size: 14px;
16
+ font-size: 12px;
17
17
  font-weight: normal;
18
18
  width: 90px;
19
19
  margin-right: 10px;
@@ -22,13 +22,18 @@
22
22
  text-align: left;
23
23
  line-height: unset;
24
24
  }
25
- .nut-form-item-label-required {
25
+ .nut-form-item-label-left-required {
26
26
  color: #ff0f23;
27
27
  margin-right: 4px;
28
- display: block;
29
28
  position: absolute;
30
29
  left: -10px;
31
30
  }
31
+ .nut-form-item-label-right-required {
32
+ color: #ff0f23;
33
+ margin-left: 4px;
34
+ position: absolute;
35
+ right: -10px;
36
+ }
32
37
  .nut-form-item .nut-form-item-labeltxt {
33
38
  position: relative;
34
39
  font-size: 12px;
@@ -129,13 +134,6 @@
129
134
  white-space: nowrap;
130
135
  }
131
136
 
132
- .nut-form-item-label-left-required {
133
- display: block;
134
- line-height: 1.5;
135
- position: absolute;
136
- left: 0.1em;
137
- }
138
-
139
137
  .nut-form-item-top {
140
138
  flex-direction: column;
141
139
  align-items: flex-start;
@@ -18,19 +18,25 @@
18
18
  word-wrap: break-word;
19
19
  text-align: $form-item-label-text-align;
20
20
  line-height: unset;
21
- }
22
21
 
23
- &-label-required {
24
- color: $form-item-required-color;
25
- margin-right: $form-item-required-margin-right;
26
- display: block;
27
- position: absolute;
28
- left: -10px;
22
+ &-left-required {
23
+ color: $form-item-required-color;
24
+ margin-right: $form-item-required-margin-right;
25
+ position: absolute;
26
+ left: -10px;
27
+ }
28
+
29
+ &-right-required {
30
+ color: $form-item-required-color;
31
+ margin-left: $form-item-required-margin-right;
32
+ position: absolute;
33
+ right: -10px;
34
+ }
29
35
  }
30
36
 
31
37
  .nut-form-item-labeltxt {
32
38
  position: relative;
33
- font-size: 12px;
39
+ font-size: $form-item-label-font-size;
34
40
  }
35
41
 
36
42
  &-body {
@@ -136,13 +142,6 @@
136
142
  white-space: nowrap;
137
143
  }
138
144
 
139
- .nut-form-item-label-left-required {
140
- display: block;
141
- line-height: 1.5;
142
- position: absolute;
143
- left: 0.1em;
144
- }
145
-
146
145
  .nut-form-item-top {
147
146
  flex-direction: column;
148
147
  align-items: flex-start;
@@ -22,16 +22,21 @@
22
22
  text-align: var(--nutui-form-item-label-text-align, left);
23
23
  line-height: unset;
24
24
  }
25
- .nut-form-item-label-required {
25
+ .nut-form-item-label-left-required {
26
26
  color: var(--nutui-form-item-required-color, var(--nutui-color-danger));
27
27
  margin-right: var(--nutui-form-item-required-margin-right, 4px);
28
- display: block;
29
28
  position: absolute;
30
29
  left: -10px;
31
30
  }
31
+ .nut-form-item-label-right-required {
32
+ color: var(--nutui-form-item-required-color, var(--nutui-color-danger));
33
+ margin-left: var(--nutui-form-item-required-margin-right, 4px);
34
+ position: absolute;
35
+ right: -10px;
36
+ }
32
37
  .nut-form-item .nut-form-item-labeltxt {
33
38
  position: relative;
34
- font-size: 12px;
39
+ font-size: var(--nutui-form-item-label-font-size, var(--nutui-font-text));
35
40
  }
36
41
  .nut-form-item-body {
37
42
  flex: 1;
@@ -121,13 +126,6 @@
121
126
  white-space: nowrap;
122
127
  }
123
128
 
124
- .nut-form-item-label-left-required {
125
- display: block;
126
- line-height: 1.5;
127
- position: absolute;
128
- left: 0.1em;
129
- }
130
-
131
129
  .nut-form-item-top {
132
130
  flex-direction: column;
133
131
  align-items: flex-start;
@@ -18,19 +18,25 @@
18
18
  word-wrap: break-word;
19
19
  text-align: $form-item-label-text-align;
20
20
  line-height: unset;
21
- }
22
21
 
23
- &-label-required {
24
- color: $form-item-required-color;
25
- margin-right: $form-item-required-margin-right;
26
- display: block;
27
- position: absolute;
28
- left: -10px;
22
+ &-left-required {
23
+ color: $form-item-required-color;
24
+ margin-right: $form-item-required-margin-right;
25
+ position: absolute;
26
+ left: -10px;
27
+ }
28
+
29
+ &-right-required {
30
+ color: $form-item-required-color;
31
+ margin-left: $form-item-required-margin-right;
32
+ position: absolute;
33
+ right: -10px;
34
+ }
29
35
  }
30
36
 
31
37
  .nut-form-item-labeltxt {
32
38
  position: relative;
33
- font-size: 12px;
39
+ font-size: $form-item-label-font-size;
34
40
  }
35
41
 
36
42
  &-body {
@@ -136,13 +142,6 @@
136
142
  white-space: nowrap;
137
143
  }
138
144
 
139
- .nut-form-item-label-left-required {
140
- display: block;
141
- line-height: 1.5;
142
- position: absolute;
143
- left: 0.1em;
144
- }
145
-
146
145
  .nut-form-item-top {
147
146
  flex-direction: column;
148
147
  align-items: flex-start;
@@ -22,16 +22,21 @@
22
22
  text-align: var(--nutui-form-item-label-text-align, left);
23
23
  line-height: unset;
24
24
  }
25
- .nut-form-item-label-required {
25
+ .nut-form-item-label-left-required {
26
26
  color: var(--nutui-form-item-required-color, var(--nutui-color-danger));
27
27
  margin-right: var(--nutui-form-item-required-margin-right, 4px);
28
- display: block;
29
28
  position: absolute;
30
29
  left: -10px;
31
30
  }
31
+ .nut-form-item-label-right-required {
32
+ color: var(--nutui-form-item-required-color, var(--nutui-color-danger));
33
+ margin-left: var(--nutui-form-item-required-margin-right, 4px);
34
+ position: absolute;
35
+ right: -10px;
36
+ }
32
37
  .nut-form-item .nut-form-item-labeltxt {
33
38
  position: relative;
34
- font-size: 12px;
39
+ font-size: var(--nutui-form-item-label-font-size, var(--nutui-font-text));
35
40
  }
36
41
  .nut-form-item-body {
37
42
  flex: 1;
@@ -121,13 +126,6 @@
121
126
  white-space: nowrap;
122
127
  }
123
128
 
124
- .nut-form-item-label-left-required {
125
- display: block;
126
- line-height: 1.5;
127
- position: absolute;
128
- left: 0.1em;
129
- }
130
-
131
129
  .nut-form-item-top {
132
130
  flex-direction: column;
133
131
  align-items: flex-start;
@@ -1,5 +1,6 @@
1
1
  import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
2
2
  import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
3
+ import { _ as _object_without_properties } from "@swc/helpers/_/_object_without_properties";
3
4
  import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
4
5
  import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
5
6
  import React, { useEffect, useRef, useState } from "react";
@@ -13,6 +14,7 @@ import Swiper from "../swiper/index";
13
14
  import SwiperItem from "../swiperitem/index";
14
15
  import { ComponentDefaults } from "../../utils/typings";
15
16
  import { usePropsValue } from "../../hooks/use-props-value";
17
+ import { mergeProps } from "../../utils";
16
18
  var defaultProps = _object_spread_props(_object_spread({}, ComponentDefaults), {
17
19
  images: [],
18
20
  videos: [],
@@ -30,7 +32,26 @@ var defaultProps = _object_spread_props(_object_spread({}, ComponentDefaults), {
30
32
  onClose: function() {}
31
33
  });
32
34
  export var ImagePreview = function(props) {
33
- var _$_object_spread = _object_spread({}, defaultProps, props), value = _$_object_spread.value, className = _$_object_spread.className, style = _$_object_spread.style, images = _$_object_spread.images, videos = _$_object_spread.videos, visible = _$_object_spread.visible, defaultValue = _$_object_spread.defaultValue, indicatorColor = _$_object_spread.indicatorColor, pagination = _$_object_spread.pagination, indicator = _$_object_spread.indicator, autoPlay = _$_object_spread.autoPlay, closeOnContentClick = _$_object_spread.closeOnContentClick, closeIcon = _$_object_spread.closeIcon, closeIconPosition = _$_object_spread.closeIconPosition, showMenuByLongpress = _$_object_spread.showMenuByLongpress, onClose = _$_object_spread.onClose, onChange = _$_object_spread.onChange;
35
+ var _mergeProps = mergeProps(defaultProps, props), value = _mergeProps.value, className = _mergeProps.className, style = _mergeProps.style, images = _mergeProps.images, videos = _mergeProps.videos, visible = _mergeProps.visible, defaultValue = _mergeProps.defaultValue, indicatorColor = _mergeProps.indicatorColor, pagination = _mergeProps.pagination, indicator = _mergeProps.indicator, autoPlay = _mergeProps.autoPlay, loop = _mergeProps.loop, closeOnContentClick = _mergeProps.closeOnContentClick, closeIcon = _mergeProps.closeIcon, closeIconPosition = _mergeProps.closeIconPosition, showMenuByLongpress = _mergeProps.showMenuByLongpress, onClose = _mergeProps.onClose, onChange = _mergeProps.onChange, rest = _object_without_properties(_mergeProps, [
36
+ "value",
37
+ "className",
38
+ "style",
39
+ "images",
40
+ "videos",
41
+ "visible",
42
+ "defaultValue",
43
+ "indicatorColor",
44
+ "pagination",
45
+ "indicator",
46
+ "autoPlay",
47
+ "loop",
48
+ "closeOnContentClick",
49
+ "closeIcon",
50
+ "closeIconPosition",
51
+ "showMenuByLongpress",
52
+ "onClose",
53
+ "onChange"
54
+ ]);
34
55
  var classPrefix = 'nut-imagepreview';
35
56
  var ref = useRef(null);
36
57
  var _usePropsValue = _sliced_to_array(usePropsValue({
@@ -171,9 +192,10 @@ export var ImagePreview = function(props) {
171
192
  onTouchEnd: onTouchEnd,
172
193
  onTouchCancel: onTouchEnd
173
194
  }, /*#__PURE__*/ React.createElement(Swiper, {
174
- autoPlay: autoPlay,
195
+ autoplay: autoPlay,
196
+ loop: loop,
197
+ direction: "horizontal",
175
198
  className: "".concat(classPrefix, "-swiper"),
176
- loop: true,
177
199
  height: "100%",
178
200
  style: {
179
201
  display: showPop ? 'block' : 'none',
@@ -181,7 +203,6 @@ export var ImagePreview = function(props) {
181
203
  width: '100%',
182
204
  height: '100%'
183
205
  },
184
- direction: "horizontal",
185
206
  onChange: function(e) {
186
207
  return slideChangeEnd(e.detail.current);
187
208
  },
@@ -3,8 +3,9 @@ import { _ as _define_property } from "@swc/helpers/_/_define_property";
3
3
  import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
4
4
  import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
5
5
  import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
6
+ import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
6
7
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
7
- import React, { useEffect, useMemo, useRef, useState } from "react";
8
+ import React, { useEffect, useMemo, useRef, useState, useCallback } from "react";
8
9
  import { View } from "@tarojs/components";
9
10
  import { Close, Notice } from "@nutui/icons-react-taro";
10
11
  import classNames from "classnames";
@@ -47,9 +48,10 @@ export var NoticeBar = function(props) {
47
48
  var _useState8 = _sliced_to_array(useState(null), 2), isCanScroll = _useState8[0], SetIsCanScroll = _useState8[1];
48
49
  var isVertical = direction === 'vertical';
49
50
  var _useState9 = _sliced_to_array(useState(null), 2), rect = _useState9[0], setRect = _useState9[1];
50
- var active = 0;
51
+ var activeRef = useRef(0);
51
52
  var _useState10 = _sliced_to_array(useState(false), 2), ready = _useState10[0], setReady = _useState10[1];
52
53
  var container = useRef(null);
54
+ var _useState11 = _sliced_to_array(useState(false), 2), isContainerReady = _useState11[0], setIsContainerReady = _useState11[1];
53
55
  var innerRef = useRef(null);
54
56
  var swiperRef = useRef({
55
57
  moving: false,
@@ -59,8 +61,8 @@ export var NoticeBar = function(props) {
59
61
  offset: 0,
60
62
  size: 0
61
63
  });
62
- var _useState11 = _sliced_to_array(useState([]), 2), childOffset = _useState11[0], setChildOffset = _useState11[1];
63
- var _useState12 = _sliced_to_array(useState(0), 2), offset = _useState12[0], setOffset = _useState12[1];
64
+ var _useState12 = _sliced_to_array(useState([]), 2), childOffset = _useState12[0], setChildOffset = _useState12[1];
65
+ var _useState13 = _sliced_to_array(useState(0), 2), offset = _useState13[0], setOffset = _useState13[1];
64
66
  var _useMemo = useMemo(function() {
65
67
  var childCount = 0;
66
68
  var childs = React.Children.map(children, function(child) {
@@ -100,7 +102,9 @@ export var NoticeBar = function(props) {
100
102
  // 销毁事件
101
103
  clearInterval(timer);
102
104
  };
103
- }, []);
105
+ }, [
106
+ childs
107
+ ]);
104
108
  useEffect(function() {
105
109
  initScrollWrap(content);
106
110
  }, [
@@ -219,7 +223,7 @@ export var NoticeBar = function(props) {
219
223
  };
220
224
  // 垂直自定义滚动方式
221
225
  var init = function() {
222
- var active = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : +0;
226
+ var activeIndex = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
223
227
  if (!(container === null || container === void 0 ? void 0 : container.current)) return;
224
228
  setTimeout(/*#__PURE__*/ _async_to_generator(function() {
225
229
  var rects, _active, _height, targetOffset;
@@ -232,17 +236,18 @@ export var NoticeBar = function(props) {
232
236
  ];
233
237
  case 1:
234
238
  rects = _state.sent();
235
- _active = Math.max(Math.min(childCount - 1, active), 0);
239
+ _active = Math.max(Math.min(childCount - 1, activeIndex), 0);
236
240
  _height = rects === null || rects === void 0 ? void 0 : rects.height;
237
241
  trackSize = childCount * Number(_height);
238
242
  targetOffset = getOffset(_active);
239
- swiperRef.current.moving = true;
240
- if (ready) {
241
- swiperRef.current.moving = false;
242
- }
243
- active = _active;
243
+ activeRef.current = _active;
244
244
  setRect(rects);
245
245
  setOffset(targetOffset);
246
+ setChildOffset(new Array(childCount).fill(0));
247
+ // 关闭动画并立即设置样式
248
+ swiperRef.current.moving = true;
249
+ setStyle(targetOffset, rects);
250
+ swiperRef.current.moving = false;
246
251
  setReady(true);
247
252
  return [
248
253
  2
@@ -253,7 +258,6 @@ export var NoticeBar = function(props) {
253
258
  };
254
259
  useEffect(function() {
255
260
  if (ready) {
256
- stopAutoPlay();
257
261
  autoplay();
258
262
  }
259
263
  return function() {
@@ -263,18 +267,19 @@ export var NoticeBar = function(props) {
263
267
  ready
264
268
  ]);
265
269
  useEffect(function() {
266
- if (isVertical && children) {
267
- init();
270
+ if (isVertical && children && isContainerReady) {
268
271
  stopAutoPlay();
269
- autoplay();
272
+ setReady(false);
273
+ init();
270
274
  }
271
275
  }, [
272
276
  children,
273
- container === null || container === void 0 ? void 0 : container.current
277
+ isContainerReady
274
278
  ]);
275
279
  // 清除定时器
276
280
  var stopAutoPlay = function() {
277
281
  clearTimeout(swiperRef.current.autoplayTimer);
282
+ swiperRef.current.moving = false;
278
283
  swiperRef.current.autoplayTimer = null;
279
284
  };
280
285
  // 定时轮播
@@ -293,23 +298,26 @@ export var NoticeBar = function(props) {
293
298
  var targetActive = getActive(pace);
294
299
  // 父级容器偏移量
295
300
  var targetOffset = getOffset(targetActive, offset);
296
- // 如果循环,调整开头结尾图片位置
297
- if (Array.isArray(children) && children[0] && targetOffset !== minOffset) {
298
- var rightBound = targetOffset < minOffset;
299
- childOffset[0] = rightBound ? trackSize : 0;
300
- }
301
- if (Array.isArray(children) && children[childCount - 1] && targetOffset !== 0) {
302
- var leftBound = targetOffset > 0;
303
- childOffset[childCount - 1] = leftBound ? -trackSize : 0;
304
- }
305
- setChildOffset(childOffset);
306
- active = targetActive;
301
+ // 循环滚动,调整开头结尾图片位置
302
+ setChildOffset(function(prevChildOffset) {
303
+ var newChildOffset = _to_consumable_array(prevChildOffset);
304
+ if (Array.isArray(children) && children[0] && targetOffset !== minOffset) {
305
+ var rightBound = targetOffset < minOffset;
306
+ newChildOffset[0] = rightBound ? trackSize : 0;
307
+ }
308
+ if (Array.isArray(children) && children[childCount - 1] && targetOffset !== 0) {
309
+ var leftBound = targetOffset > 0;
310
+ newChildOffset[childCount - 1] = leftBound ? -trackSize : 0;
311
+ }
312
+ return newChildOffset;
313
+ });
314
+ activeRef.current = targetActive;
307
315
  setOffset(targetOffset);
308
- getStyle(targetOffset);
316
+ setStyle(targetOffset);
309
317
  };
310
318
  // 下一页
311
319
  var next = function() {
312
- resettPosition();
320
+ resetPosition();
313
321
  requestFrame(function() {
314
322
  requestFrame(function() {
315
323
  swiperRef.current.moving = false;
@@ -322,18 +330,18 @@ export var NoticeBar = function(props) {
322
330
  var handleItemClick = function(event, value) {
323
331
  onItemClick && onItemClick(event, value);
324
332
  };
325
- var getStyle = function() {
326
- var moveOffset = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : offset;
333
+ var setStyle = function() {
334
+ var moveOffset = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : offset, currentRect = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : rect;
327
335
  var target = innerRef.current;
328
336
  if (!target) {
329
337
  return;
330
338
  }
331
339
  var _offset = 0;
332
- // 容器高度-元素高度
333
- var val = ((rect === null || rect === void 0 ? void 0 : rect.height) || 0) - height;
334
- _offset = moveOffset + Number(active === childCount - 1 && val / 2);
340
+ var containerHeight = (currentRect === null || currentRect === void 0 ? void 0 : currentRect.height) || height;
341
+ var val = containerHeight - Number(height);
342
+ _offset = moveOffset + Number(activeRef.current === childCount - 1 && val / 2);
335
343
  target.style.transitionDuration = "".concat(swiperRef.current.moving ? 0 : duration, "ms");
336
- target.style.height = "".concat(Number(height) * childCount, "px");
344
+ target.style.height = "".concat(Number(height) * (childCount + 1), "px");
337
345
  target.style.transform = "translate3D(0,".concat(_offset, "px,0)");
338
346
  };
339
347
  // 无缝滚动第一个元素位移控制
@@ -351,11 +359,12 @@ export var NoticeBar = function(props) {
351
359
  };
352
360
  // 确定当前active 元素
353
361
  var getActive = function(pace) {
362
+ var currentActive = activeRef.current;
354
363
  if (pace) {
355
- var _active = active + pace;
364
+ var _active = currentActive + pace;
356
365
  return range(_active, -1, childCount);
357
366
  }
358
- return active;
367
+ return currentActive;
359
368
  };
360
369
  // 计算位移
361
370
  var getOffset = function(active) {
@@ -373,14 +382,15 @@ export var NoticeBar = function(props) {
373
382
  return Math.min(Math.max(num, min), max);
374
383
  };
375
384
  // 重置首尾位置信息
376
- var resettPosition = function() {
385
+ var resetPosition = function() {
386
+ var currentActive = activeRef.current;
377
387
  swiperRef.current.moving = true;
378
- if (active <= -1) {
388
+ if (currentActive <= -1) {
379
389
  move({
380
390
  pace: childCount
381
391
  });
382
392
  }
383
- if (active >= childCount) {
393
+ if (currentActive >= childCount) {
384
394
  move({
385
395
  pace: -childCount
386
396
  });
@@ -394,6 +404,20 @@ export var NoticeBar = function(props) {
394
404
  stopAutoPlay();
395
405
  };
396
406
  }, []);
407
+ var hasVerticalContent = useMemo(function() {
408
+ if (!isVertical) return false;
409
+ if (children) return (childs === null || childs === void 0 ? void 0 : childs.length) > 0;
410
+ return (list === null || list === void 0 ? void 0 : list.length) > 0;
411
+ }, [
412
+ isVertical,
413
+ childs,
414
+ list,
415
+ children
416
+ ]);
417
+ var containerRefCallback = useCallback(function(ref) {
418
+ container.current = ref;
419
+ setIsContainerReady(true);
420
+ }, []);
397
421
  return (
398
422
  /*#__PURE__*/ React.createElement(View, {
399
423
  className: cls,
@@ -419,10 +443,10 @@ export var NoticeBar = function(props) {
419
443
  onClick: onClickIcon
420
444
  }, rightIcon || /*#__PURE__*/ React.createElement(Close, {
421
445
  size: 12
422
- })) : null) : null, showNoticeBar && scrollList.current.length > 0 && isVertical ? /*#__PURE__*/ React.createElement(View, {
446
+ })) : null) : null, showNoticeBar && hasVerticalContent && isVertical ? /*#__PURE__*/ React.createElement(View, {
423
447
  className: "nut-noticebar-vertical",
424
448
  style: barStyle,
425
- ref: container,
449
+ ref: containerRefCallback,
426
450
  onClick: handleClick
427
451
  }, leftIcon ? /*#__PURE__*/ React.createElement(View, {
428
452
  className: "nut-noticebar-box-left-icon"