@nutui/nutui-react-taro 3.0.18-cpp.beta.1 → 3.0.19-cpp-beta.0

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 (83) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/packages/actionsheet/style/style.harmony.css +0 -3
  3. package/dist/cjs/packages/address/style/style.harmony.css +0 -3
  4. package/dist/cjs/packages/calendar/style/style.harmony.css +0 -3
  5. package/dist/cjs/packages/cascader/style/style.harmony.css +0 -3
  6. package/dist/cjs/packages/datepicker/style/style.harmony.css +0 -3
  7. package/dist/cjs/packages/ellipsis/ellipsis.js +1 -1
  8. package/dist/cjs/packages/imagepreview/style/style.harmony.css +0 -3
  9. package/dist/cjs/packages/input/input.js +14 -5
  10. package/dist/cjs/packages/noticebar/style/noticebar.scss +6 -0
  11. package/dist/cjs/packages/noticebar/style/style.css +6 -0
  12. package/dist/cjs/packages/noticebar/style/style.harmony.css +6 -0
  13. package/dist/cjs/packages/noticebar/style-jmapp/noticebar.scss +6 -0
  14. package/dist/cjs/packages/noticebar/style-jmapp/style.css +6 -0
  15. package/dist/cjs/packages/noticebar/style-jrkf/noticebar.scss +6 -0
  16. package/dist/cjs/packages/noticebar/style-jrkf/style.css +6 -0
  17. package/dist/cjs/packages/numberkeyboard/style/style.harmony.css +0 -3
  18. package/dist/cjs/packages/picker/style/style.harmony.css +0 -3
  19. package/dist/cjs/packages/popover/style/style.harmony.css +0 -3
  20. package/dist/cjs/packages/popup/popup.d.ts +1 -1
  21. package/dist/cjs/packages/popup/popup.js +108 -21
  22. package/dist/cjs/packages/popup/style/popup.scss +0 -5
  23. package/dist/cjs/packages/popup/style/style.css +0 -3
  24. package/dist/cjs/packages/popup/style/style.harmony.css +0 -3
  25. package/dist/cjs/packages/popup/style-jmapp/popup.scss +0 -5
  26. package/dist/cjs/packages/popup/style-jmapp/style.css +0 -3
  27. package/dist/cjs/packages/popup/style-jrkf/popup.scss +0 -5
  28. package/dist/cjs/packages/popup/style-jrkf/style.css +0 -3
  29. package/dist/cjs/packages/price/price.js +43 -15
  30. package/dist/cjs/packages/shortpassword/style/style.harmony.css +0 -3
  31. package/dist/cjs/packages/swiper/swiper.js +1 -2
  32. package/dist/cjs/packages/timeselect/style/style.harmony.css +0 -3
  33. package/dist/cjs/packages/tour/style/style.harmony.css +0 -3
  34. package/dist/cjs/types/spec/popup/base.d.ts +6 -0
  35. package/dist/cjs/types/spec/price/base.d.ts +8 -2
  36. package/dist/cjs/types/spec/price/base.js +12 -0
  37. package/dist/cjs/utils/taro/get-rect.d.ts +1 -0
  38. package/dist/cjs/utils/taro/get-rect.js +36 -0
  39. package/dist/es/packages/actionsheet/style/style.harmony.css +0 -3
  40. package/dist/es/packages/address/style/style.harmony.css +0 -3
  41. package/dist/es/packages/calendar/style/style.harmony.css +0 -3
  42. package/dist/es/packages/cascader/style/style.harmony.css +0 -3
  43. package/dist/es/packages/datepicker/style/style.harmony.css +0 -3
  44. package/dist/es/packages/ellipsis/ellipsis.js +2 -2
  45. package/dist/es/packages/imagepreview/style/style.harmony.css +0 -3
  46. package/dist/es/packages/input/input.js +14 -5
  47. package/dist/es/packages/noticebar/style/noticebar.scss +6 -0
  48. package/dist/es/packages/noticebar/style/style.css +6 -0
  49. package/dist/es/packages/noticebar/style/style.harmony.css +6 -0
  50. package/dist/es/packages/noticebar/style-jmapp/noticebar.scss +6 -0
  51. package/dist/es/packages/noticebar/style-jmapp/style.css +6 -0
  52. package/dist/es/packages/noticebar/style-jrkf/noticebar.scss +6 -0
  53. package/dist/es/packages/noticebar/style-jrkf/style.css +6 -0
  54. package/dist/es/packages/numberkeyboard/style/style.harmony.css +0 -3
  55. package/dist/es/packages/picker/style/style.harmony.css +0 -3
  56. package/dist/es/packages/popover/style/style.harmony.css +0 -3
  57. package/dist/es/packages/popup/popup.d.ts +1 -1
  58. package/dist/es/packages/popup/popup.js +109 -22
  59. package/dist/es/packages/popup/style/popup.scss +0 -5
  60. package/dist/es/packages/popup/style/style.css +0 -3
  61. package/dist/es/packages/popup/style/style.harmony.css +0 -3
  62. package/dist/es/packages/popup/style-jmapp/popup.scss +0 -5
  63. package/dist/es/packages/popup/style-jmapp/style.css +0 -3
  64. package/dist/es/packages/popup/style-jrkf/popup.scss +0 -5
  65. package/dist/es/packages/popup/style-jrkf/style.css +0 -3
  66. package/dist/es/packages/price/price.js +42 -15
  67. package/dist/es/packages/shortpassword/style/style.harmony.css +0 -3
  68. package/dist/es/packages/swiper/swiper.js +1 -2
  69. package/dist/es/packages/timeselect/style/style.harmony.css +0 -3
  70. package/dist/es/packages/tour/style/style.harmony.css +0 -3
  71. package/dist/es/types/spec/popup/base.d.ts +24 -0
  72. package/dist/es/types/spec/price/base.d.ts +17 -5
  73. package/dist/es/types/spec/price/base.js +6 -1
  74. package/dist/es/utils/taro/get-rect.d.ts +1 -0
  75. package/dist/es/utils/taro/get-rect.js +34 -0
  76. package/dist/nutui.react.umd.js +229 -70
  77. package/dist/style-jmapp.css +1 -1
  78. package/dist/style-jmapp.scss +27 -27
  79. package/dist/style-jrkf.css +1 -1
  80. package/dist/style-jrkf.scss +35 -35
  81. package/dist/style.css +1 -1
  82. package/dist/style.scss +31 -31
  83. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ # v3.0.18
2
+
3
+ `2025-08-15`
4
+
5
+ - 🏡 chore: 升级icon库 (#3330)
6
+ - 🏡 chore: 发布taro下的样式按需插件
7
+ - 📖 docs: 更新介绍部分内容 (#3324)
8
+ - :sparkles: feat: Ellipsis校验越界不走缓存配置 (#3329)
9
+ - :sparkles: feat(price): 支持自定义颜色&数据原样输出 (#3328)
10
+ - :sparkles: feat(notify): 支持promise调用notice (#3319)
11
+ - :bug: fix(noticebar): 适配鸿蒙样式修复 (#3332)
12
+ - :bug: Fix icons svg (#3331)
13
+
1
14
  # v3.0.17
2
15
 
3
16
  `2025-08-01`
@@ -134,9 +134,6 @@
134
134
  .nut-popup-center.nut-popup-round {
135
135
  border-radius: var(--nutui-popup-border-radius, var(--nutui-radius-xl, 12px));
136
136
  }
137
- .nut-popup-bottom, .nut-popup-top {
138
- max-height: 87%;
139
- }
140
137
  .nut-popup-bottom {
141
138
  bottom: 0;
142
139
  left: 0;
@@ -277,9 +277,6 @@
277
277
  .nut-popup-center.nut-popup-round {
278
278
  border-radius: var(--nutui-popup-border-radius, var(--nutui-radius-xl, 12px));
279
279
  }
280
- .nut-popup-bottom, .nut-popup-top {
281
- max-height: 87%;
282
- }
283
280
  .nut-popup-bottom {
284
281
  bottom: 0;
285
282
  left: 0;
@@ -134,9 +134,6 @@
134
134
  .nut-popup-center.nut-popup-round {
135
135
  border-radius: var(--nutui-popup-border-radius, var(--nutui-radius-xl, 12px));
136
136
  }
137
- .nut-popup-bottom, .nut-popup-top {
138
- max-height: 87%;
139
- }
140
137
  .nut-popup-bottom {
141
138
  bottom: 0;
142
139
  left: 0;
@@ -134,9 +134,6 @@
134
134
  .nut-popup-center.nut-popup-round {
135
135
  border-radius: var(--nutui-popup-border-radius, var(--nutui-radius-xl, 12px));
136
136
  }
137
- .nut-popup-bottom, .nut-popup-top {
138
- max-height: 87%;
139
- }
140
137
  .nut-popup-bottom {
141
138
  bottom: 0;
142
139
  left: 0;
@@ -134,9 +134,6 @@
134
134
  .nut-popup-center.nut-popup-round {
135
135
  border-radius: var(--nutui-popup-border-radius, var(--nutui-radius-xl, 12px));
136
136
  }
137
- .nut-popup-bottom, .nut-popup-top {
138
- max-height: 87%;
139
- }
140
137
  .nut-popup-bottom {
141
138
  bottom: 0;
142
139
  left: 0;
@@ -229,7 +229,7 @@ var Ellipsis = function Ellipsis(props) {
229
229
  case 0:
230
230
  return [
231
231
  4,
232
- (0, _getrect.getRectInMultiPlatform)(rootContain.current)
232
+ (0, _getrect.getRectInMultiPlatformWithoutCache)(rootContain.current)
233
233
  ];
234
234
  case 1:
235
235
  refe = _state.sent();
@@ -134,9 +134,6 @@
134
134
  .nut-popup-center.nut-popup-round {
135
135
  border-radius: var(--nutui-popup-border-radius, var(--nutui-radius-xl, 12px));
136
136
  }
137
- .nut-popup-bottom, .nut-popup-top {
138
- max-height: 87%;
139
- }
140
137
  .nut-popup-bottom {
141
138
  bottom: 0;
142
139
  left: 0;
@@ -75,18 +75,27 @@ var Input = /*#__PURE__*/ (0, _react.forwardRef)(function(props, ref) {
75
75
  }), 2), value = _usePropsValue[0], setValue = _usePropsValue[1];
76
76
  var inputRef = (0, _react.useRef)(null);
77
77
  var _useState = (0, _sliced_to_array._)((0, _react.useState)(false), 2), active = _useState[0], setActive = _useState[1];
78
+ // 兼容H5和小程序获取原生input标签
79
+ var getNativeInput = function getNativeInput() {
80
+ if (_taro.default.getEnv() === 'WEB') {
81
+ var taroInputCoreEl = inputRef.current;
82
+ var inputEl = taroInputCoreEl.querySelector('input');
83
+ return inputEl;
84
+ }
85
+ return inputRef.current;
86
+ };
78
87
  (0, _react.useImperativeHandle)(ref, function() {
79
88
  return {
80
89
  clear: function clear() {
81
90
  setValue('');
82
91
  },
83
92
  focus: function focus() {
84
- var _inputRef_current;
85
- (_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.focus();
93
+ var nativeInput = getNativeInput();
94
+ nativeInput === null || nativeInput === void 0 ? void 0 : nativeInput.focus();
86
95
  },
87
96
  blur: function blur() {
88
- var _inputRef_current;
89
- (_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.blur();
97
+ var nativeInput = getNativeInput();
98
+ nativeInput === null || nativeInput === void 0 ? void 0 : nativeInput.blur();
90
99
  },
91
100
  get nativeElement () {
92
101
  return inputRef.current;
@@ -174,7 +183,7 @@ var Input = /*#__PURE__*/ (0, _react.forwardRef)(function(props, ref) {
174
183
  maxlength: maxLength,
175
184
  placeholder: placeholder === undefined ? locale.placeholder : placeholder,
176
185
  placeholderClass: "".concat(classPrefix, "-placeholder"),
177
- disabled: disabled || readOnly,
186
+ disabled: disabled,
178
187
  value: value,
179
188
  focus: autoFocus || focus,
180
189
  confirmType: confirmType,
@@ -51,6 +51,9 @@
51
51
  min-width: $noticebar-left-icon-width;
52
52
  margin-right: $noticebar-icon-gap;
53
53
  background-size: 100% 100%;
54
+ .nut-icon {
55
+ color: $noticebar-color;
56
+ }
54
57
  }
55
58
 
56
59
  &-right-icon {
@@ -63,12 +66,14 @@
63
66
  .nut-icon {
64
67
  width: 12px;
65
68
  height: 12px;
69
+ color: $noticebar-color;
66
70
  }
67
71
  }
68
72
 
69
73
  &-wrap {
70
74
  display: flex;
71
75
  flex: 1;
76
+ align-items: center;
72
77
  height: $noticebar-line-height;
73
78
  line-height: $noticebar-line-height;
74
79
  overflow: hidden;
@@ -77,6 +82,7 @@
77
82
  .nut-noticebar-box-wrap-content {
78
83
  position: absolute;
79
84
  white-space: nowrap;
85
+ color: $noticebar-color;
80
86
 
81
87
  &.nut-ellipsis {
82
88
  max-width: 100%;
@@ -45,6 +45,9 @@
45
45
  margin-right: var(--nutui-noticebar-icon-gap, 4px);
46
46
  background-size: 100% 100%;
47
47
  }
48
+ .nut-noticebar .nut-noticebar-box-left-icon .nut-icon {
49
+ color: var(--nutui-noticebar-color, #d9500b);
50
+ }
48
51
  .nut-noticebar .nut-noticebar-box-right-icon {
49
52
  display: flex;
50
53
  align-items: center;
@@ -55,10 +58,12 @@
55
58
  .nut-noticebar .nut-noticebar-box-right-icon .nut-icon {
56
59
  width: 12px;
57
60
  height: 12px;
61
+ color: var(--nutui-noticebar-color, #d9500b);
58
62
  }
59
63
  .nut-noticebar .nut-noticebar-box-wrap {
60
64
  display: flex;
61
65
  flex: 1;
66
+ align-items: center;
62
67
  height: var(--nutui-noticebar-line-height, 24px);
63
68
  line-height: var(--nutui-noticebar-line-height, 24px);
64
69
  overflow: hidden;
@@ -67,6 +72,7 @@
67
72
  .nut-noticebar .nut-noticebar-box-wrap .nut-noticebar-box-wrap-content {
68
73
  position: absolute;
69
74
  white-space: nowrap;
75
+ color: var(--nutui-noticebar-color, #d9500b);
70
76
  }
71
77
  .nut-noticebar .nut-noticebar-box-wrap .nut-noticebar-box-wrap-content.nut-ellipsis {
72
78
  max-width: 100%;
@@ -45,6 +45,9 @@
45
45
  margin-right: var(--nutui-noticebar-icon-gap, 4px);
46
46
  background-size: 100% 100%;
47
47
  }
48
+ .nut-noticebar .nut-noticebar-box-left-icon .nut-icon {
49
+ color: var(--nutui-noticebar-color, #d9500b);
50
+ }
48
51
  .nut-noticebar .nut-noticebar-box-right-icon {
49
52
  display: flex;
50
53
  align-items: center;
@@ -55,10 +58,12 @@
55
58
  .nut-noticebar .nut-noticebar-box-right-icon .nut-icon {
56
59
  width: 12px;
57
60
  height: 12px;
61
+ color: var(--nutui-noticebar-color, #d9500b);
58
62
  }
59
63
  .nut-noticebar .nut-noticebar-box-wrap {
60
64
  display: flex;
61
65
  flex: 1;
66
+ align-items: center;
62
67
  height: var(--nutui-noticebar-line-height, 24px);
63
68
  line-height: var(--nutui-noticebar-line-height, 24px);
64
69
  overflow: hidden;
@@ -67,6 +72,7 @@
67
72
  .nut-noticebar .nut-noticebar-box-wrap .nut-noticebar-box-wrap-content {
68
73
  position: absolute;
69
74
  white-space: nowrap;
75
+ color: var(--nutui-noticebar-color, #d9500b);
70
76
  }
71
77
  .nut-noticebar .nut-noticebar-box-wrap .nut-noticebar-box-wrap-content.nut-ellipsis {
72
78
  max-width: 100%;
@@ -51,6 +51,9 @@
51
51
  min-width: $noticebar-left-icon-width;
52
52
  margin-right: $noticebar-icon-gap;
53
53
  background-size: 100% 100%;
54
+ .nut-icon {
55
+ color: $noticebar-color;
56
+ }
54
57
  }
55
58
 
56
59
  &-right-icon {
@@ -63,12 +66,14 @@
63
66
  .nut-icon {
64
67
  width: 12px;
65
68
  height: 12px;
69
+ color: $noticebar-color;
66
70
  }
67
71
  }
68
72
 
69
73
  &-wrap {
70
74
  display: flex;
71
75
  flex: 1;
76
+ align-items: center;
72
77
  height: $noticebar-line-height;
73
78
  line-height: $noticebar-line-height;
74
79
  overflow: hidden;
@@ -77,6 +82,7 @@
77
82
  .nut-noticebar-box-wrap-content {
78
83
  position: absolute;
79
84
  white-space: nowrap;
85
+ color: $noticebar-color;
80
86
 
81
87
  &.nut-ellipsis {
82
88
  max-width: 100%;
@@ -45,6 +45,9 @@
45
45
  margin-right: var(--nutui-noticebar-icon-gap, 4px);
46
46
  background-size: 100% 100%;
47
47
  }
48
+ .nut-noticebar .nut-noticebar-box-left-icon .nut-icon {
49
+ color: var(--nutui-noticebar-color, #d9500b);
50
+ }
48
51
  .nut-noticebar .nut-noticebar-box-right-icon {
49
52
  display: flex;
50
53
  align-items: center;
@@ -55,10 +58,12 @@
55
58
  .nut-noticebar .nut-noticebar-box-right-icon .nut-icon {
56
59
  width: 12px;
57
60
  height: 12px;
61
+ color: var(--nutui-noticebar-color, #d9500b);
58
62
  }
59
63
  .nut-noticebar .nut-noticebar-box-wrap {
60
64
  display: flex;
61
65
  flex: 1;
66
+ align-items: center;
62
67
  height: var(--nutui-noticebar-line-height, 24px);
63
68
  line-height: var(--nutui-noticebar-line-height, 24px);
64
69
  overflow: hidden;
@@ -67,6 +72,7 @@
67
72
  .nut-noticebar .nut-noticebar-box-wrap .nut-noticebar-box-wrap-content {
68
73
  position: absolute;
69
74
  white-space: nowrap;
75
+ color: var(--nutui-noticebar-color, #d9500b);
70
76
  }
71
77
  .nut-noticebar .nut-noticebar-box-wrap .nut-noticebar-box-wrap-content.nut-ellipsis {
72
78
  max-width: 100%;
@@ -51,6 +51,9 @@
51
51
  min-width: $noticebar-left-icon-width;
52
52
  margin-right: $noticebar-icon-gap;
53
53
  background-size: 100% 100%;
54
+ .nut-icon {
55
+ color: $noticebar-color;
56
+ }
54
57
  }
55
58
 
56
59
  &-right-icon {
@@ -63,12 +66,14 @@
63
66
  .nut-icon {
64
67
  width: 12px;
65
68
  height: 12px;
69
+ color: $noticebar-color;
66
70
  }
67
71
  }
68
72
 
69
73
  &-wrap {
70
74
  display: flex;
71
75
  flex: 1;
76
+ align-items: center;
72
77
  height: $noticebar-line-height;
73
78
  line-height: $noticebar-line-height;
74
79
  overflow: hidden;
@@ -77,6 +82,7 @@
77
82
  .nut-noticebar-box-wrap-content {
78
83
  position: absolute;
79
84
  white-space: nowrap;
85
+ color: $noticebar-color;
80
86
 
81
87
  &.nut-ellipsis {
82
88
  max-width: 100%;
@@ -45,6 +45,9 @@
45
45
  margin-right: var(--nutui-noticebar-icon-gap, 4px);
46
46
  background-size: 100% 100%;
47
47
  }
48
+ .nut-noticebar .nut-noticebar-box-left-icon .nut-icon {
49
+ color: var(--nutui-noticebar-color, #d9500b);
50
+ }
48
51
  .nut-noticebar .nut-noticebar-box-right-icon {
49
52
  display: flex;
50
53
  align-items: center;
@@ -55,10 +58,12 @@
55
58
  .nut-noticebar .nut-noticebar-box-right-icon .nut-icon {
56
59
  width: 12px;
57
60
  height: 12px;
61
+ color: var(--nutui-noticebar-color, #d9500b);
58
62
  }
59
63
  .nut-noticebar .nut-noticebar-box-wrap {
60
64
  display: flex;
61
65
  flex: 1;
66
+ align-items: center;
62
67
  height: var(--nutui-noticebar-line-height, 24px);
63
68
  line-height: var(--nutui-noticebar-line-height, 24px);
64
69
  overflow: hidden;
@@ -67,6 +72,7 @@
67
72
  .nut-noticebar .nut-noticebar-box-wrap .nut-noticebar-box-wrap-content {
68
73
  position: absolute;
69
74
  white-space: nowrap;
75
+ color: var(--nutui-noticebar-color, #d9500b);
70
76
  }
71
77
  .nut-noticebar .nut-noticebar-box-wrap .nut-noticebar-box-wrap-content.nut-ellipsis {
72
78
  max-width: 100%;
@@ -134,9 +134,6 @@
134
134
  .nut-popup-center.nut-popup-round {
135
135
  border-radius: var(--nutui-popup-border-radius, var(--nutui-radius-xl, 12px));
136
136
  }
137
- .nut-popup-bottom, .nut-popup-top {
138
- max-height: 87%;
139
- }
140
137
  .nut-popup-bottom {
141
138
  bottom: 0;
142
139
  left: 0;
@@ -134,9 +134,6 @@
134
134
  .nut-popup-center.nut-popup-round {
135
135
  border-radius: var(--nutui-popup-border-radius, var(--nutui-radius-xl, 12px));
136
136
  }
137
- .nut-popup-bottom, .nut-popup-top {
138
- max-height: 87%;
139
- }
140
137
  .nut-popup-bottom {
141
138
  bottom: 0;
142
139
  left: 0;
@@ -134,9 +134,6 @@
134
134
  .nut-popup-center.nut-popup-round {
135
135
  border-radius: var(--nutui-popup-border-radius, var(--nutui-radius-xl, 12px));
136
136
  }
137
- .nut-popup-bottom, .nut-popup-top {
138
- max-height: 87%;
139
- }
140
137
  .nut-popup-bottom {
141
138
  bottom: 0;
142
139
  left: 0;
@@ -1,3 +1,3 @@
1
1
  import React, { FunctionComponent } from 'react';
2
2
  import { TaroPopupProps } from "../../types";
3
- export declare const Popup: FunctionComponent<Partial<TaroPopupProps> & Omit<React.HTMLAttributes<HTMLDivElement>, 'onClick' | 'title'>>;
3
+ export declare const Popup: FunctionComponent<Partial<TaroPopupProps> & Omit<React.HTMLAttributes<HTMLDivElement>, 'onClick' | 'title' | 'onTouchStart' | 'onTouchMove' | 'onTouchEnd'>>;
@@ -10,19 +10,23 @@ Object.defineProperty(exports, "Popup", {
10
10
  });
11
11
  var _interop_require_default = require("@swc/helpers/_/_interop_require_default");
12
12
  var _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
13
+ var _async_to_generator = require("@swc/helpers/_/_async_to_generator");
13
14
  var _define_property = require("@swc/helpers/_/_define_property");
14
15
  var _object_spread = require("@swc/helpers/_/_object_spread");
15
16
  var _object_spread_props = require("@swc/helpers/_/_object_spread_props");
16
17
  var _sliced_to_array = require("@swc/helpers/_/_sliced_to_array");
18
+ var _ts_generator = require("@swc/helpers/_/_ts_generator");
17
19
  var _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
18
20
  var _reactdom = require("react-dom");
19
21
  var _classnames = /*#__PURE__*/ _interop_require_default._(require("classnames"));
20
22
  var _iconsreacttaro = require("@nutui/icons-react-taro");
21
23
  var _components = require("@tarojs/components");
24
+ var _getrect = require("../../utils/taro/get-rect");
22
25
  var _overlay = require("../overlay/overlay");
23
26
  var _index = /*#__PURE__*/ _interop_require_default._(require("../overlay/index"));
24
27
  var _uselockscoll = require("../../hooks/taro/use-lock-scoll");
25
28
  var _platform = require("../../utils/taro/platform");
29
+ var _pxtransform = require("../../utils/taro/px-transform");
26
30
  var defaultProps = (0, _object_spread_props._)((0, _object_spread._)({}, _overlay.defaultOverlayProps), {
27
31
  position: 'center',
28
32
  transition: '',
@@ -35,6 +39,8 @@ var defaultProps = (0, _object_spread_props._)((0, _object_spread._)({}, _overla
35
39
  portal: null,
36
40
  overlay: true,
37
41
  round: false,
42
+ resizable: false,
43
+ minHeight: '',
38
44
  onOpen: function onOpen() {},
39
45
  onClose: function onClose() {},
40
46
  onOverlayClick: function onOverlayClick() {
@@ -42,29 +48,51 @@ var defaultProps = (0, _object_spread_props._)((0, _object_spread._)({}, _overla
42
48
  },
43
49
  onCloseIconClick: function onCloseIconClick() {
44
50
  return true;
45
- }
51
+ },
52
+ onTouchStart: function onTouchStart() {},
53
+ onTouchMove: function onTouchMove() {},
54
+ onTouchEnd: function onTouchEnd() {}
46
55
  });
47
56
  // 默认1000,参看variables
48
57
  var _zIndex = 1100;
49
58
  var Popup = function Popup(props) {
50
- var _$_object_spread = (0, _object_spread._)({}, defaultProps, props), children = _$_object_spread.children, visible = _$_object_spread.visible, overlay = _$_object_spread.overlay, closeOnOverlayClick = _$_object_spread.closeOnOverlayClick, overlayStyle = _$_object_spread.overlayStyle, overlayClassName = _$_object_spread.overlayClassName, zIndex = _$_object_spread.zIndex, lockScroll = _$_object_spread.lockScroll, duration = _$_object_spread.duration, closeable = _$_object_spread.closeable, closeIconPosition = _$_object_spread.closeIconPosition, closeIcon = _$_object_spread.closeIcon, left = _$_object_spread.left, title = _$_object_spread.title, description = _$_object_spread.description, style = _$_object_spread.style, transition = _$_object_spread.transition, round = _$_object_spread.round, position = _$_object_spread.position, className = _$_object_spread.className, destroyOnClose = _$_object_spread.destroyOnClose, portal = _$_object_spread.portal, onOpen = _$_object_spread.onOpen, onClose = _$_object_spread.onClose, onOverlayClick = _$_object_spread.onOverlayClick, onCloseIconClick = _$_object_spread.onCloseIconClick, afterShow = _$_object_spread.afterShow, afterClose = _$_object_spread.afterClose, onClick = _$_object_spread.onClick;
59
+ var _$_object_spread = (0, _object_spread._)({}, defaultProps, props), children = _$_object_spread.children, visible = _$_object_spread.visible, overlay = _$_object_spread.overlay, closeOnOverlayClick = _$_object_spread.closeOnOverlayClick, overlayStyle = _$_object_spread.overlayStyle, overlayClassName = _$_object_spread.overlayClassName, zIndex = _$_object_spread.zIndex, lockScroll = _$_object_spread.lockScroll, duration = _$_object_spread.duration, closeable = _$_object_spread.closeable, closeIconPosition = _$_object_spread.closeIconPosition, closeIcon = _$_object_spread.closeIcon, left = _$_object_spread.left, title = _$_object_spread.title, top = _$_object_spread.top, description = _$_object_spread.description, style = _$_object_spread.style, transition = _$_object_spread.transition, round = _$_object_spread.round, position = _$_object_spread.position, className = _$_object_spread.className, destroyOnClose = _$_object_spread.destroyOnClose, portal = _$_object_spread.portal, resizable = _$_object_spread.resizable, minHeight = _$_object_spread.minHeight, onOpen = _$_object_spread.onOpen, onClose = _$_object_spread.onClose, onOverlayClick = _$_object_spread.onOverlayClick, onCloseIconClick = _$_object_spread.onCloseIconClick, afterShow = _$_object_spread.afterShow, afterClose = _$_object_spread.afterClose, onClick = _$_object_spread.onClick, onTouchStart = _$_object_spread.onTouchStart, onTouchMove = _$_object_spread.onTouchMove, onTouchEnd = _$_object_spread.onTouchEnd;
51
60
  var innerIndex = zIndex || _zIndex;
52
61
  var _useState = (0, _sliced_to_array._)((0, _react.useState)(innerIndex), 2), index = _useState[0], setIndex = _useState[1];
53
62
  var _useState1 = (0, _sliced_to_array._)((0, _react.useState)(visible), 2), innerVisible = _useState1[0], setInnerVisible = _useState1[1];
54
63
  var _useState2 = (0, _sliced_to_array._)((0, _react.useState)(true), 2), showChildren = _useState2[0], setShowChildren = _useState2[1];
55
64
  var _useState3 = (0, _sliced_to_array._)((0, _react.useState)(''), 2), transitionName = _useState3[0], setTransitionName = _useState3[1];
56
- var refObject = (0, _uselockscoll.useLockScrollTaro)(innerVisible && lockScroll);
65
+ var nodeRef = (0, _uselockscoll.useLockScrollTaro)(innerVisible && lockScroll);
66
+ var rootRect = (0, _react.useRef)(null);
67
+ var touchStartRef = (0, _react.useRef)(0);
68
+ var touchMoveDistanceRef = (0, _react.useRef)(0);
69
+ var heightRef = (0, _react.useRef)(0);
70
+ var defaultHeightRef = (0, _react.useRef)(0);
71
+ var isTouching = (0, _react.useRef)(false);
57
72
  var classPrefix = 'nut-popup';
58
73
  var overlayStyles = (0, _object_spread._)({}, overlayStyle);
59
74
  var contentZIndex = (0, _platform.harmony)() ? index + 1 : index // 解决harmony层级问题
60
75
  ;
61
76
  var popStyles = (0, _object_spread._)({
62
- zIndex: contentZIndex
77
+ zIndex: contentZIndex,
78
+ minHeight: minHeight
63
79
  }, style);
64
80
  var _obj;
65
81
  var popClassName = (0, _classnames.default)(classPrefix, (_obj = {}, (0, _define_property._)(_obj, "".concat(classPrefix, "-round"), round || position === 'bottom'), (0, _define_property._)(_obj, "".concat(classPrefix, "-").concat(position), true), _obj), className);
82
+ var _useState4 = (0, _sliced_to_array._)((0, _react.useState)(''), 2), popupHeight = _useState4[0], setPopupHeight = _useState4[1];
83
+ var resizeStyles = function resizeStyles() {
84
+ if (popupHeight !== '') {
85
+ return {
86
+ height: popupHeight
87
+ };
88
+ }
89
+ };
66
90
  var open = function open() {
67
91
  if (!innerVisible) {
92
+ // 当高度改变后,再次打开时,将高度置为初始高度
93
+ if (position === 'bottom' && resizable && nodeRef.current && heightRef.current) {
94
+ setPopupHeight((0, _pxtransform.pxTransform)(defaultHeightRef.current));
95
+ }
68
96
  setInnerVisible(true);
69
97
  setIndex(++innerIndex);
70
98
  }
@@ -118,19 +146,87 @@ var Popup = function Popup(props) {
118
146
  return renderCloseIcon();
119
147
  }
120
148
  };
149
+ var handleTouchStart = /*#__PURE__*/ function() {
150
+ var _ref = (0, _async_to_generator._)(function(event) {
151
+ var _nodeRef_current, _rootRect_current, e, rect;
152
+ return (0, _ts_generator._)(this, function(_state) {
153
+ switch(_state.label){
154
+ case 0:
155
+ if (position !== 'bottom' || !resizable || !nodeRef.current) return [
156
+ 2
157
+ ];
158
+ e = event;
159
+ // 开始touch,记录下touch的pageY,用以判断是向上滑动还是向下滑动
160
+ touchStartRef.current = e.touches[0].pageY;
161
+ // 标记开始滑动
162
+ isTouching.current = true;
163
+ return [
164
+ 4,
165
+ (0, _getrect.getRectInMultiPlatformWithoutCache)(nodeRef.current)
166
+ ];
167
+ case 1:
168
+ rect = _state.sent();
169
+ rootRect.current = rect;
170
+ heightRef.current = ((_nodeRef_current = nodeRef.current) === null || _nodeRef_current === void 0 ? void 0 : _nodeRef_current.offsetHeight) || ((_rootRect_current = rootRect.current) === null || _rootRect_current === void 0 ? void 0 : _rootRect_current.height) || 0;
171
+ if (!defaultHeightRef.current) defaultHeightRef.current = heightRef.current;
172
+ onTouchStart === null || onTouchStart === void 0 ? void 0 : onTouchStart(heightRef.current, e);
173
+ return [
174
+ 2
175
+ ];
176
+ }
177
+ });
178
+ });
179
+ return function handleTouchStart(event) {
180
+ return _ref.apply(this, arguments);
181
+ };
182
+ }();
183
+ var handleTouchMove = function handleTouchMove(event) {
184
+ if (position !== 'bottom' || !resizable || !nodeRef.current || !rootRect.current) return;
185
+ var e = event;
186
+ e.stopPropagation();
187
+ // 计算位移:move过程中,当前的pageY 与 start值比较
188
+ touchMoveDistanceRef.current = e.touches[0].pageY - touchStartRef.current;
189
+ var handleMove = function handleMove() {
190
+ var min = typeof minHeight === 'number' ? minHeight : parseInt(String(minHeight || 0), 10) || 0;
191
+ var currentHeight = Math.max(min, heightRef.current - touchMoveDistanceRef.current);
192
+ setPopupHeight((0, _pxtransform.pxTransform)(currentHeight));
193
+ if (touchMoveDistanceRef.current > 0 && isTouching.current) {
194
+ // 向下滑动
195
+ onTouchMove === null || onTouchMove === void 0 ? void 0 : onTouchMove(currentHeight, e, 'down');
196
+ } else {
197
+ // 向上滑动
198
+ onTouchMove === null || onTouchMove === void 0 ? void 0 : onTouchMove(currentHeight, e, 'up');
199
+ }
200
+ };
201
+ requestAnimationFrame(handleMove);
202
+ };
203
+ var handleTouchEnd = function handleTouchEnd(event) {
204
+ if (position !== 'bottom' || !resizable || !nodeRef.current || !rootRect.current) return;
205
+ var e = event;
206
+ isTouching.current = false;
207
+ var min = typeof minHeight === 'number' ? minHeight : parseInt(String(minHeight || 0), 10) || 0;
208
+ var currentHeight = Math.max(min, heightRef.current - touchMoveDistanceRef.current);
209
+ onTouchEnd === null || onTouchEnd === void 0 ? void 0 : onTouchEnd(currentHeight, e);
210
+ };
121
211
  var renderPop = function renderPop() {
122
212
  return /*#__PURE__*/ _react.default.createElement(_components.View, {
123
- ref: refObject,
124
- style: (0, _object_spread_props._)((0, _object_spread._)({}, popStyles), {
213
+ ref: nodeRef,
214
+ style: (0, _object_spread._)((0, _object_spread_props._)((0, _object_spread._)({}, popStyles), {
125
215
  display: innerVisible ? 'block' : 'none'
126
- }),
216
+ }), resizeStyles()),
127
217
  className: popClassName,
128
218
  onClick: onClick,
129
- catchMove: lockScroll
130
- }, renderTitle(), showChildren ? children : null);
219
+ catchMove: lockScroll,
220
+ onTouchStart: handleTouchStart,
221
+ onTouchMove: handleTouchMove,
222
+ onTouchEnd: handleTouchEnd,
223
+ onTouchCancel: handleTouchEnd
224
+ }, top, renderTitle(), showChildren ? children : null);
225
+ };
226
+ // const renderPop = () => {
131
227
  // return (
132
228
  // <CSSTransition
133
- // nodeRef={refObject}
229
+ // nodeRef={nodeRef}
134
230
  // classNames={transitionName}
135
231
  // mountOnEnter
136
232
  // unmountOnExit={destroyOnClose}
@@ -139,19 +235,10 @@ var Popup = function Popup(props) {
139
235
  // onEntered={afterShow}
140
236
  // onExited={afterClose}
141
237
  // >
142
- // <View
143
- // ref={refObject}
144
- // style={popStyles}
145
- // className={popClassName}
146
- // onClick={onClick}
147
- // catchMove={lockScroll}
148
- // >
149
- // {renderTitle()}
150
- // {showChildren ? children : null}
151
- // </View>
238
+ // {renderContent()}
152
239
  // </CSSTransition>
153
240
  // )
154
- };
241
+ // }
155
242
  var renderNode = function renderNode() {
156
243
  return /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, overlay ? /*#__PURE__*/ _react.default.createElement(_index.default, {
157
244
  zIndex: index,
@@ -88,11 +88,6 @@
88
88
  }
89
89
  }
90
90
 
91
- &-bottom,
92
- &-top {
93
- max-height: 87%;
94
- }
95
-
96
91
  &-bottom {
97
92
  bottom: 0;
98
93
  left: 0;
@@ -80,9 +80,6 @@
80
80
  .nut-popup-center.nut-popup-round {
81
81
  border-radius: var(--nutui-popup-border-radius, var(--nutui-radius-xl, 12px));
82
82
  }
83
- .nut-popup-bottom, .nut-popup-top {
84
- max-height: 87%;
85
- }
86
83
  .nut-popup-bottom {
87
84
  bottom: 0;
88
85
  left: 0;
@@ -134,9 +134,6 @@
134
134
  .nut-popup-center.nut-popup-round {
135
135
  border-radius: var(--nutui-popup-border-radius, var(--nutui-radius-xl, 12px));
136
136
  }
137
- .nut-popup-bottom, .nut-popup-top {
138
- max-height: 87%;
139
- }
140
137
  .nut-popup-bottom {
141
138
  bottom: 0;
142
139
  left: 0;
@@ -88,11 +88,6 @@
88
88
  }
89
89
  }
90
90
 
91
- &-bottom,
92
- &-top {
93
- max-height: 87%;
94
- }
95
-
96
91
  &-bottom {
97
92
  bottom: 0;
98
93
  left: 0;
@@ -80,9 +80,6 @@
80
80
  .nut-popup-center.nut-popup-round {
81
81
  border-radius: var(--nutui-popup-border-radius, 12px);
82
82
  }
83
- .nut-popup-bottom, .nut-popup-top {
84
- max-height: 87%;
85
- }
86
83
  .nut-popup-bottom {
87
84
  bottom: 0;
88
85
  left: 0;