@nutui/nutui-react-taro 3.0.5 → 3.0.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 (204) hide show
  1. package/CHANGELOG.md +59 -1
  2. package/dist/cjs/packages/actionsheet/style/style.css +4 -4
  3. package/dist/cjs/packages/address/style/style.css +4 -4
  4. package/dist/cjs/packages/audio/style/style.css +4 -16
  5. package/dist/cjs/packages/badge/badge.js +4 -3
  6. package/dist/cjs/packages/badge/style/badge.scss +4 -0
  7. package/dist/cjs/packages/badge/style/style.css +9 -6
  8. package/dist/cjs/packages/badge/style/style.harmony.css +3 -0
  9. package/dist/cjs/packages/button/style/button.scss +4 -20
  10. package/dist/cjs/packages/button/style/style.css +4 -16
  11. package/dist/cjs/packages/button/style/style.harmony.css +2 -14
  12. package/dist/cjs/packages/calendar/style/style.css +4 -4
  13. package/dist/cjs/packages/cascader/style/style.css +4 -4
  14. package/dist/cjs/packages/collapse/style/style.css +22 -7
  15. package/dist/cjs/packages/collapseitem/collapseitem.js +63 -77
  16. package/dist/cjs/packages/collapseitem/style/collapseitem.scss +22 -5
  17. package/dist/cjs/packages/collapseitem/style/style.css +22 -7
  18. package/dist/cjs/packages/collapseitem/style/style.harmony.css +22 -7
  19. package/dist/cjs/packages/configprovider/types.d.ts +1 -1
  20. package/dist/cjs/packages/datepicker/style/style.css +7 -4
  21. package/dist/cjs/packages/datepickerview/style/style.css +3 -0
  22. package/dist/cjs/packages/dialog/content.d.ts +11 -3
  23. package/dist/cjs/packages/dialog/content.js +4 -4
  24. package/dist/cjs/packages/dialog/dialog.d.ts +39 -4
  25. package/dist/cjs/packages/dialog/dialog.js +14 -13
  26. package/dist/cjs/packages/dialog/index.d.ts +1 -1
  27. package/dist/cjs/packages/dialog/style/style.css +4 -16
  28. package/dist/cjs/packages/empty/style/style.css +4 -16
  29. package/dist/cjs/packages/fixednav/style/style.css +9 -6
  30. package/dist/cjs/packages/imagepreview/style/style.css +4 -4
  31. package/dist/cjs/packages/indicator/indicator.js +1 -1
  32. package/dist/cjs/packages/lottie/index.js +5 -5
  33. package/dist/cjs/packages/lottie/{mp.js → lottiemp.js} +1 -1
  34. package/dist/cjs/packages/notify/notify.js +44 -13
  35. package/dist/cjs/packages/notify/style/notify.scss +39 -36
  36. package/dist/cjs/packages/notify/style/style.css +36 -31
  37. package/dist/cjs/packages/notify/style/style.harmony.css +36 -31
  38. package/dist/cjs/packages/numberkeyboard/style/style.css +4 -4
  39. package/dist/cjs/packages/picker/style/style.css +7 -4
  40. package/dist/cjs/packages/pickerview/pickerroller.js +7 -2
  41. package/dist/cjs/packages/pickerview/style/pickerview.scss +3 -0
  42. package/dist/cjs/packages/pickerview/style/style.css +3 -0
  43. package/dist/cjs/packages/pickerview/style/style.harmony.css +3 -0
  44. package/dist/cjs/packages/popover/popover.d.ts +0 -7
  45. package/dist/cjs/packages/popover/popover.js +114 -141
  46. package/dist/cjs/packages/popover/style/popover.scss +48 -51
  47. package/dist/cjs/packages/popover/style/style.css +64 -70
  48. package/dist/cjs/packages/popover/style/style.harmony.css +64 -60
  49. package/dist/cjs/packages/popup/style/popup.scss +4 -4
  50. package/dist/cjs/packages/popup/style/style.css +4 -4
  51. package/dist/cjs/packages/popup/style/style.harmony.css +4 -4
  52. package/dist/cjs/packages/resultpage/style/style.css +4 -16
  53. package/dist/cjs/packages/searchbar/searchbar.js +8 -2
  54. package/dist/cjs/packages/shortpassword/style/style.css +4 -4
  55. package/dist/cjs/packages/skeleton/skeleton.js +63 -52
  56. package/dist/cjs/packages/skeleton/style/index.js +0 -1
  57. package/dist/cjs/packages/skeleton/style/skeleton.scss +40 -46
  58. package/dist/cjs/packages/skeleton/style/style.css +32 -175
  59. package/dist/cjs/packages/skeleton/style/style.harmony.css +32 -42
  60. package/dist/cjs/packages/switch/style/style.css +5 -0
  61. package/dist/cjs/packages/switch/style/style.harmony.css +5 -0
  62. package/dist/cjs/packages/switch/style/switch.scss +5 -0
  63. package/dist/cjs/packages/switch/switch.js +22 -11
  64. package/dist/cjs/packages/tabbar/style/style.css +54 -45
  65. package/dist/cjs/packages/tabbar/style/style.harmony.css +24 -18
  66. package/dist/cjs/packages/tabbar/style/tabbar.scss +28 -19
  67. package/dist/cjs/packages/tabbar/tabbar.js +28 -10
  68. package/dist/cjs/packages/tabbaritem/style/style.css +30 -27
  69. package/dist/cjs/packages/tabbaritem/style/style.harmony.css +21 -21
  70. package/dist/cjs/packages/tabbaritem/style/tabbaritem.scss +32 -29
  71. package/dist/cjs/packages/tabbaritem/tabbaritem.js +38 -14
  72. package/dist/cjs/packages/tabpane/tabpane.js +2 -2
  73. package/dist/cjs/packages/timeselect/style/style.css +4 -4
  74. package/dist/cjs/packages/tour/style/style.css +64 -70
  75. package/dist/cjs/packages/tour/tour.js +3 -4
  76. package/dist/cjs/types/spec/badge/base.d.ts +1 -0
  77. package/dist/cjs/types/spec/dialog/base.d.ts +50 -1
  78. package/dist/cjs/types/spec/dialog/base.js +7 -0
  79. package/dist/cjs/types/spec/dialog/h5.d.ts +4 -1
  80. package/dist/cjs/types/spec/dialog/taro.d.ts +8 -2
  81. package/dist/cjs/types/spec/indicator/base.d.ts +1 -1
  82. package/dist/cjs/types/spec/notify/base.d.ts +7 -2
  83. package/dist/cjs/types/spec/popover/base.d.ts +7 -0
  84. package/dist/cjs/types/spec/searchbar/taro.d.ts +10 -7
  85. package/dist/cjs/types/spec/skeleton/base.d.ts +7 -5
  86. package/dist/cjs/types/spec/switch/base.d.ts +3 -2
  87. package/dist/cjs/types/spec/switch/h5.d.ts +1 -1
  88. package/dist/cjs/types/spec/switch/taro.d.ts +1 -4
  89. package/dist/cjs/types/spec/tabbar/base.d.ts +7 -4
  90. package/dist/cjs/utils/get-rect-by-taro.js +10 -0
  91. package/dist/cjs/utils/lru.d.ts +8 -0
  92. package/dist/cjs/utils/lru.js +58 -0
  93. package/dist/es/packages/actionsheet/style/style.css +4 -4
  94. package/dist/es/packages/address/style/style.css +4 -4
  95. package/dist/es/packages/audio/style/style.css +4 -16
  96. package/dist/es/packages/badge/badge.js +4 -3
  97. package/dist/es/packages/badge/style/badge.scss +4 -0
  98. package/dist/es/packages/badge/style/style.css +9 -6
  99. package/dist/es/packages/badge/style/style.harmony.css +3 -0
  100. package/dist/es/packages/button/style/button.scss +4 -20
  101. package/dist/es/packages/button/style/style.css +4 -16
  102. package/dist/es/packages/button/style/style.harmony.css +2 -14
  103. package/dist/es/packages/calendar/style/style.css +4 -4
  104. package/dist/es/packages/cascader/style/style.css +4 -4
  105. package/dist/es/packages/collapse/style/style.css +22 -7
  106. package/dist/es/packages/collapseitem/collapseitem.js +65 -79
  107. package/dist/es/packages/collapseitem/style/collapseitem.scss +22 -5
  108. package/dist/es/packages/collapseitem/style/style.css +22 -7
  109. package/dist/es/packages/collapseitem/style/style.harmony.css +22 -7
  110. package/dist/es/packages/configprovider/types.d.ts +1 -1
  111. package/dist/es/packages/datepicker/style/style.css +7 -4
  112. package/dist/es/packages/datepickerview/style/style.css +3 -0
  113. package/dist/es/packages/dialog/content.d.ts +11 -3
  114. package/dist/es/packages/dialog/content.js +4 -4
  115. package/dist/es/packages/dialog/dialog.d.ts +39 -4
  116. package/dist/es/packages/dialog/dialog.js +14 -13
  117. package/dist/es/packages/dialog/index.d.ts +1 -1
  118. package/dist/es/packages/dialog/style/style.css +4 -16
  119. package/dist/es/packages/empty/style/style.css +4 -16
  120. package/dist/es/packages/fixednav/style/style.css +9 -6
  121. package/dist/es/packages/imagepreview/style/style.css +4 -4
  122. package/dist/es/packages/indicator/indicator.js +1 -1
  123. package/dist/es/packages/lottie/index.js +3 -3
  124. package/dist/es/packages/lottie/{mp.js → lottiemp.js} +1 -1
  125. package/dist/es/packages/notify/notify.js +45 -14
  126. package/dist/es/packages/notify/style/notify.scss +39 -36
  127. package/dist/es/packages/notify/style/style.css +36 -31
  128. package/dist/es/packages/notify/style/style.harmony.css +36 -31
  129. package/dist/es/packages/numberkeyboard/style/style.css +4 -4
  130. package/dist/es/packages/picker/style/style.css +7 -4
  131. package/dist/es/packages/pickerview/pickerroller.js +7 -2
  132. package/dist/es/packages/pickerview/style/pickerview.scss +3 -0
  133. package/dist/es/packages/pickerview/style/style.css +3 -0
  134. package/dist/es/packages/pickerview/style/style.harmony.css +3 -0
  135. package/dist/es/packages/popover/popover.d.ts +0 -7
  136. package/dist/es/packages/popover/popover.js +115 -142
  137. package/dist/es/packages/popover/style/popover.scss +48 -51
  138. package/dist/es/packages/popover/style/style.css +64 -70
  139. package/dist/es/packages/popover/style/style.harmony.css +64 -60
  140. package/dist/es/packages/popup/style/popup.scss +4 -4
  141. package/dist/es/packages/popup/style/style.css +4 -4
  142. package/dist/es/packages/popup/style/style.harmony.css +4 -4
  143. package/dist/es/packages/resultpage/style/style.css +4 -16
  144. package/dist/es/packages/searchbar/searchbar.js +7 -2
  145. package/dist/es/packages/shortpassword/style/style.css +4 -4
  146. package/dist/es/packages/skeleton/skeleton.js +62 -52
  147. package/dist/es/packages/skeleton/style/index.js +0 -1
  148. package/dist/es/packages/skeleton/style/skeleton.scss +40 -46
  149. package/dist/es/packages/skeleton/style/style.css +32 -175
  150. package/dist/es/packages/skeleton/style/style.harmony.css +32 -42
  151. package/dist/es/packages/switch/style/style.css +5 -0
  152. package/dist/es/packages/switch/style/style.harmony.css +5 -0
  153. package/dist/es/packages/switch/style/switch.scss +5 -0
  154. package/dist/es/packages/switch/switch.js +21 -11
  155. package/dist/es/packages/tabbar/style/style.css +54 -45
  156. package/dist/es/packages/tabbar/style/style.harmony.css +24 -18
  157. package/dist/es/packages/tabbar/style/tabbar.scss +28 -19
  158. package/dist/es/packages/tabbar/tabbar.js +27 -10
  159. package/dist/es/packages/tabbaritem/style/style.css +30 -27
  160. package/dist/es/packages/tabbaritem/style/style.harmony.css +21 -21
  161. package/dist/es/packages/tabbaritem/style/tabbaritem.scss +32 -29
  162. package/dist/es/packages/tabbaritem/tabbaritem.js +38 -14
  163. package/dist/es/packages/tabpane/tabpane.js +2 -2
  164. package/dist/es/packages/timeselect/style/style.css +4 -4
  165. package/dist/es/packages/tour/style/style.css +64 -70
  166. package/dist/es/packages/tour/tour.js +3 -4
  167. package/dist/es/types/spec/badge/base.d.ts +4 -0
  168. package/dist/es/types/spec/dialog/base.d.ts +83 -1
  169. package/dist/es/types/spec/dialog/base.js +1 -1
  170. package/dist/es/types/spec/dialog/h5.d.ts +4 -1
  171. package/dist/es/types/spec/dialog/taro.d.ts +8 -2
  172. package/dist/es/types/spec/indicator/base.d.ts +1 -1
  173. package/dist/es/types/spec/notify/base.d.ts +22 -5
  174. package/dist/es/types/spec/popover/base.d.ts +7 -0
  175. package/dist/es/types/spec/searchbar/taro.d.ts +10 -7
  176. package/dist/es/types/spec/skeleton/base.d.ts +19 -14
  177. package/dist/es/types/spec/switch/base.d.ts +6 -2
  178. package/dist/es/types/spec/switch/h5.d.ts +1 -1
  179. package/dist/es/types/spec/switch/taro.d.ts +1 -4
  180. package/dist/es/types/spec/tabbar/base.d.ts +7 -4
  181. package/dist/es/utils/get-rect-by-taro.js +9 -0
  182. package/dist/es/utils/lru.d.ts +8 -0
  183. package/dist/es/utils/lru.js +49 -0
  184. package/dist/nutui.react.umd.js +683 -552
  185. package/dist/style.css +1 -1
  186. package/dist/style.scss +46 -46
  187. package/dist/styles/theme-jmapp.scss +1 -0
  188. package/dist/styles/themes/jmapp.css +1 -1
  189. package/dist/styles/variables-jmapp.scss +237 -50
  190. package/dist/styles/variables-jrkf.scss +25 -14
  191. package/dist/styles/variables.scss +38 -51
  192. package/package.json +1 -1
  193. package/dist/cjs/packages/dialog/types.d.ts +0 -57
  194. package/dist/cjs/packages/dialog/types.js +0 -4
  195. package/dist/cjs/packages/dialog/types.taro.d.ts +0 -10
  196. package/dist/es/packages/dialog/types.d.ts +0 -57
  197. package/dist/es/packages/dialog/types.js +0 -1
  198. package/dist/es/packages/dialog/types.taro.d.ts +0 -10
  199. /package/dist/cjs/packages/lottie/{mp.d.ts → lottiemp.d.ts} +0 -0
  200. /package/dist/cjs/packages/lottie/{web.d.ts → lottieweb.d.ts} +0 -0
  201. /package/dist/cjs/packages/lottie/{web.js → lottieweb.js} +0 -0
  202. /package/dist/es/packages/lottie/{mp.d.ts → lottiemp.d.ts} +0 -0
  203. /package/dist/es/packages/lottie/{web.d.ts → lottieweb.d.ts} +0 -0
  204. /package/dist/es/packages/lottie/{web.js → lottieweb.js} +0 -0
@@ -19,14 +19,15 @@ var _sliced_to_array = require("@swc/helpers/_/_sliced_to_array");
19
19
  var _ts_generator = require("@swc/helpers/_/_ts_generator");
20
20
  var _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
21
21
  var _classnames = /*#__PURE__*/ _interop_require_default._(require("classnames"));
22
- var _taro = /*#__PURE__*/ _interop_require_wildcard._(require("@tarojs/taro"));
22
+ var _taro = require("@tarojs/taro");
23
23
  var _components = require("@tarojs/components");
24
24
  var _iconsreacttaro = require("@nutui/icons-react-taro");
25
25
  var _index = /*#__PURE__*/ _interop_require_default._(require("../popup/index"));
26
26
  var _getrectbytaro = require("../../utils/get-rect-by-taro");
27
27
  var _typings = require("../../utils/typings");
28
- var _useclientrect = require("../../hooks/use-client-rect");
29
28
  var _index1 = require("../configprovider/index");
29
+ var _pxtransform = /*#__PURE__*/ _interop_require_default._(require("../../utils/px-transform"));
30
+ var _useuuid = /*#__PURE__*/ _interop_require_default._(require("../../hooks/use-uuid"));
30
31
  var defaultProps = (0, _object_spread_props._)((0, _object_spread._)({}, _typings.ComponentDefaults), {
31
32
  list: [],
32
33
  theme: 'light',
@@ -38,7 +39,6 @@ var defaultProps = (0, _object_spread_props._)((0, _object_spread._)({}, _typing
38
39
  ],
39
40
  arrowOffset: 0,
40
41
  targetId: '',
41
- className: '',
42
42
  showArrow: true,
43
43
  closeOnOutsideClick: true,
44
44
  closeOnActionClick: true,
@@ -73,129 +73,100 @@ var Popover = function Popover(props) {
73
73
  var popoverRef = (0, _react.useRef)(null);
74
74
  var popoverContentRef = (0, _react.useRef)(null);
75
75
  var _useState = (0, _sliced_to_array._)((0, _react.useState)(false), 2), showPopup = _useState[0], setShowPopup = _useState[1];
76
- var _useState1 = (0, _sliced_to_array._)((0, _react.useState)(0), 2), elWidth = _useState1[0], setElWidth = _useState1[1];
77
- var _useState2 = (0, _sliced_to_array._)((0, _react.useState)(0), 2), elHeight = _useState2[0], setElHeight = _useState2[1];
78
- var _useState3 = (0, _sliced_to_array._)((0, _react.useState)(), 2), rootPosition = _useState3[0], setRootPosition = _useState3[1];
76
+ var _useState1 = (0, _sliced_to_array._)((0, _react.useState)(0), 2), popWidth = _useState1[0], setPopWidth = _useState1[1];
77
+ var _useState2 = (0, _sliced_to_array._)((0, _react.useState)(0), 2), popHeight = _useState2[0], setPopHeight = _useState2[1];
78
+ var _useState3 = (0, _sliced_to_array._)((0, _react.useState)(), 2), wrapperPosition = _useState3[0], setWrapperPosition = _useState3[1];
79
79
  (0, _react.useEffect)(function() {
80
80
  setShowPopup(visible);
81
81
  if (visible) {
82
- setTimeout(function() {
83
- getContentWidth();
84
- }, 0);
82
+ getWrapperPosition();
85
83
  }
86
84
  }, [
87
85
  visible
88
86
  ]);
89
- var getContentWidth = /*#__PURE__*/ function() {
87
+ var uid = (0, _useuuid.default)();
88
+ var popoverId = "popover-".concat(uid);
89
+ var getWrapperPosition = /*#__PURE__*/ function() {
90
90
  var _ref = (0, _async_to_generator._)(function() {
91
- var rect;
92
91
  return (0, _ts_generator._)(this, function(_state) {
93
- (0, _taro.createSelectorQuery)().selectViewport().scrollOffset(/*#__PURE__*/ function() {
94
- var _ref = (0, _async_to_generator._)(function(res) {
95
- var distance;
96
- return (0, _ts_generator._)(this, function(_state) {
97
- switch(_state.label){
98
- case 0:
99
- distance = res.scrollTop;
100
- if (!targetId) return [
101
- 3,
102
- 4
103
- ];
104
- if (!(_taro.default.getEnv() === _taro.default.ENV_TYPE.WEB)) return [
105
- 3,
106
- 1
107
- ];
108
- rect = (0, _useclientrect.getRect)(document.querySelector("#".concat(targetId)));
109
- return [
110
- 3,
111
- 3
112
- ];
113
- case 1:
114
- return [
115
- 4,
116
- getRectTaro(targetId)
117
- ];
118
- case 2:
119
- rect = _state.sent();
120
- _state.label = 3;
121
- case 3:
122
- return [
123
- 3,
124
- 6
125
- ];
126
- case 4:
127
- return [
128
- 4,
129
- (0, _getrectbytaro.getRectByTaro)(popoverRef.current)
130
- ];
131
- case 5:
132
- rect = _state.sent();
133
- _state.label = 6;
134
- case 6:
135
- setRootPosition({
136
- width: rect.width,
137
- height: rect.height,
138
- left: rtl ? rect.right : rect.left,
139
- top: rect.top + distance,
140
- right: rtl ? rect.left : rect.right
141
- });
142
- return [
143
- 2
144
- ];
145
- }
146
- });
92
+ (0, _taro.nextTick)(/*#__PURE__*/ (0, _async_to_generator._)(function() {
93
+ var rect, _tmp, width, height, right, left, top;
94
+ return (0, _ts_generator._)(this, function(_state) {
95
+ switch(_state.label){
96
+ case 0:
97
+ if (!targetId) return [
98
+ 3,
99
+ 2
100
+ ];
101
+ return [
102
+ 4,
103
+ (0, _getrectbytaro.getRectByTaro)(document.querySelector("#".concat(targetId)), targetId)
104
+ ];
105
+ case 1:
106
+ _tmp = _state.sent();
107
+ return [
108
+ 3,
109
+ 4
110
+ ];
111
+ case 2:
112
+ return [
113
+ 4,
114
+ (0, _getrectbytaro.getRectByTaro)(popoverRef.current, popoverId)
115
+ ];
116
+ case 3:
117
+ _tmp = _state.sent();
118
+ _state.label = 4;
119
+ case 4:
120
+ rect = _tmp;
121
+ width = rect.width, height = rect.height, right = rect.right, left = rect.left, top = rect.top;
122
+ setWrapperPosition({
123
+ width: width,
124
+ height: height,
125
+ left: rtl ? right : left,
126
+ top: top,
127
+ right: rtl ? left : right
128
+ });
129
+ getPopoverContentW();
130
+ return [
131
+ 2
132
+ ];
133
+ }
147
134
  });
148
- return function(res) {
149
- return _ref.apply(this, arguments);
150
- };
151
- }()).exec();
152
- setTimeout(function() {
153
- getPopoverContentW();
154
- }, 300);
135
+ }));
155
136
  return [
156
137
  2
157
138
  ];
158
139
  });
159
140
  });
160
- return function getContentWidth() {
161
- return _ref.apply(this, arguments);
162
- };
163
- }();
164
- var getRectTaro = /*#__PURE__*/ function() {
165
- var _ref = (0, _async_to_generator._)(function(targetId) {
166
- return (0, _ts_generator._)(this, function(_state) {
167
- return [
168
- 2,
169
- new Promise(function(resolve) {
170
- (0, _taro.createSelectorQuery)().select("#".concat(targetId)).boundingClientRect().exec(function(res) {
171
- resolve(res[0]);
172
- });
173
- })
174
- ];
175
- });
176
- });
177
- return function getRectTaro(targetId) {
141
+ return function getWrapperPosition() {
178
142
  return _ref.apply(this, arguments);
179
143
  };
180
144
  }();
181
145
  var getPopoverContentW = /*#__PURE__*/ function() {
182
146
  var _ref = (0, _async_to_generator._)(function() {
183
- var rectContent;
184
147
  return (0, _ts_generator._)(this, function(_state) {
185
- switch(_state.label){
186
- case 0:
187
- return [
188
- 4,
189
- (0, _getrectbytaro.getRectByTaro)(popoverContentRef.current)
190
- ];
191
- case 1:
192
- rectContent = _state.sent();
193
- setElWidth(rectContent.width);
194
- setElHeight(rectContent.height);
195
- return [
196
- 2
197
- ];
198
- }
148
+ (0, _taro.nextTick)(/*#__PURE__*/ (0, _async_to_generator._)(function() {
149
+ var rectContent;
150
+ return (0, _ts_generator._)(this, function(_state) {
151
+ switch(_state.label){
152
+ case 0:
153
+ return [
154
+ 4,
155
+ (0, _getrectbytaro.getRectByTaro)(popoverContentRef.current)
156
+ ];
157
+ case 1:
158
+ rectContent = _state.sent();
159
+ setPopWidth(rectContent.width);
160
+ setPopHeight(rectContent.height);
161
+ return [
162
+ 2
163
+ ];
164
+ }
165
+ });
166
+ }));
167
+ return [
168
+ 2
169
+ ];
199
170
  });
200
171
  });
201
172
  return function getPopoverContentW() {
@@ -204,23 +175,23 @@ var Popover = function Popover(props) {
204
175
  }();
205
176
  var clickAway = function clickAway() {
206
177
  if (closeOnOutsideClick) {
207
- onClick && onClick();
208
- onClose && onClose();
178
+ onClick === null || onClick === void 0 ? void 0 : onClick();
179
+ onClose === null || onClose === void 0 ? void 0 : onClose();
209
180
  }
210
181
  };
211
- var _obj;
212
- var classes = (0, _classnames.default)((_obj = {}, (0, _define_property._)(_obj, "".concat(classPrefix), true), (0, _define_property._)(_obj, "".concat(classPrefix, "-").concat(theme), theme === 'dark'), _obj), className);
182
+ var classes = (0, _classnames.default)(classPrefix, (0, _define_property._)({}, "".concat(classPrefix, "-").concat(theme), theme === 'dark'), className);
213
183
  var popoverArrow = function popoverArrow() {
214
184
  var prefixCls = 'nut-popover-arrow';
215
- return "".concat(prefixCls, " ").concat(prefixCls, "-").concat(location.split('-')[0], " ").concat(prefixCls, "-").concat(location);
185
+ var direction = location.split('-')[0];
186
+ return "".concat(prefixCls, " ").concat(prefixCls, "-").concat(direction, " ").concat(prefixCls, "-").concat(location);
216
187
  };
217
- var getRootPosition = function getRootPosition() {
188
+ var getPopoverPosition = function getPopoverPosition() {
218
189
  var styles = {};
219
- if (!rootPosition) {
190
+ if (!wrapperPosition) {
220
191
  styles.visibility = 'hidden';
221
192
  return styles;
222
193
  }
223
- var width = rootPosition.width, height = rootPosition.height, left = rootPosition.left, top = rootPosition.top, right = rootPosition.right;
194
+ var width = wrapperPosition.width, height = wrapperPosition.height, left = wrapperPosition.left, top = wrapperPosition.top, right = wrapperPosition.right;
224
195
  var direction = location.split('-')[0];
225
196
  var skew = location.split('-')[1];
226
197
  var cross = 0;
@@ -236,36 +207,36 @@ var Popover = function Popover(props) {
236
207
  'bottom',
237
208
  'top'
238
209
  ].includes(direction)) {
239
- var h = direction === 'bottom' ? height + cross : -(elHeight + cross);
240
- styles.top = "".concat(top + h, "px");
210
+ var h = direction === 'bottom' ? height + cross : -(popHeight + cross);
211
+ styles.top = (0, _pxtransform.default)(top + h);
241
212
  if (!skew) {
242
- styles[dir] = "".concat(-(elWidth - width) / 2 + rootPosition[dir] + parallel, "px");
213
+ styles[dir] = (0, _pxtransform.default)(-(popWidth - width) / 2 + wrapperPosition[dir] + parallel);
243
214
  }
244
- if (skew === 'start') {
245
- styles.left = "".concat(left + parallel, "px");
215
+ if (skew === 'left') {
216
+ styles.left = (0, _pxtransform.default)(left + parallel);
246
217
  }
247
- if (skew === 'end') {
248
- styles.left = "".concat(right + parallel, "px");
218
+ if (skew === 'right') {
219
+ styles.left = (0, _pxtransform.default)(right + parallel);
249
220
  }
250
221
  }
251
222
  if ([
252
223
  'left',
253
224
  'right'
254
225
  ].includes(direction)) {
255
- var contentW = direction === 'left' ? -(elWidth + cross) : width + cross;
256
- styles.left = "".concat(left + contentW, "px");
226
+ var contentW = direction === 'left' ? -(popWidth + cross) : width + cross;
227
+ styles.left = (0, _pxtransform.default)(left + contentW);
257
228
  if (!skew) {
258
- styles.top = "".concat(top - elHeight / 2 + height / 2 - 4 + parallel, "px");
229
+ styles.top = (0, _pxtransform.default)(top - popHeight / 2 + height / 2 - 4 + parallel);
259
230
  }
260
- if (skew === 'start') {
261
- styles.top = "".concat(top + parallel, "px");
231
+ if (skew === 'top') {
232
+ styles.top = (0, _pxtransform.default)(top + parallel);
262
233
  }
263
- if (skew === 'end') {
264
- styles.top = "".concat(top + height + parallel, "px");
234
+ if (skew === 'bottom') {
235
+ styles.top = (0, _pxtransform.default)(top + height + parallel);
265
236
  }
266
237
  }
267
238
  }
268
- styles.visibility = elWidth === 0 ? 'hidden' : 'initial';
239
+ styles.visibility = popWidth === 0 ? 'hidden' : 'initial';
269
240
  return styles;
270
241
  };
271
242
  var popoverArrowStyle = function popoverArrowStyle() {
@@ -283,10 +254,10 @@ var Popover = function Popover(props) {
283
254
  if (!skew) {
284
255
  styles[dir] = "calc(50% + ".concat(arrowOffset, "px)");
285
256
  }
286
- if (skew === 'start') {
257
+ if (skew === 'left') {
287
258
  styles[dir] = "".concat(base + arrowOffset, "px");
288
259
  }
289
- if (skew === 'end') {
260
+ if (skew === 'right') {
290
261
  styles[dir2] = "".concat(base - arrowOffset, "px");
291
262
  }
292
263
  }
@@ -297,10 +268,10 @@ var Popover = function Popover(props) {
297
268
  if (!skew) {
298
269
  styles.top = "calc(50% - ".concat(arrowOffset, "px)");
299
270
  }
300
- if (skew === 'start') {
271
+ if (skew === 'top') {
301
272
  styles.top = "".concat(base - arrowOffset, "px");
302
273
  }
303
- if (skew === 'end') {
274
+ if (skew === 'bottom') {
304
275
  styles.bottom = "".concat(base + arrowOffset, "px");
305
276
  }
306
277
  }
@@ -319,6 +290,7 @@ var Popover = function Popover(props) {
319
290
  return /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, !targetId && /*#__PURE__*/ _react.default.createElement(_components.View, {
320
291
  className: "nut-popover-wrapper",
321
292
  ref: popoverRef,
293
+ id: popoverId,
322
294
  onClick: function onClick() {
323
295
  var _props_onClick;
324
296
  props === null || props === void 0 ? void 0 : (_props_onClick = props.onClick) === null || _props_onClick === void 0 ? void 0 : _props_onClick.call(props);
@@ -331,7 +303,7 @@ var Popover = function Popover(props) {
331
303
  style: style
332
304
  }, Array.isArray(children) ? children[0] : children), /*#__PURE__*/ _react.default.createElement(_components.View, {
333
305
  className: classes,
334
- style: getRootPosition()
306
+ style: (0, _object_spread._)({}, getPopoverPosition(), style)
335
307
  }, /*#__PURE__*/ _react.default.createElement(_index.default, (0, _object_spread._)({
336
308
  className: "nut-popover-content nut-popover-content-".concat(location),
337
309
  position: "none",
@@ -346,22 +318,23 @@ var Popover = function Popover(props) {
346
318
  }, /*#__PURE__*/ _react.default.createElement(_iconsreacttaro.ArrowRadius, {
347
319
  width: 8,
348
320
  height: 4
349
- })), Array.isArray(children) ? children[1] : '', list.map(function(item, index) {
321
+ })), Array.isArray(children) ? children[1] : null, list.map(function(item, index) {
322
+ var _item_action;
350
323
  return /*#__PURE__*/ _react.default.createElement(_components.View, {
351
324
  className: (0, _classnames.default)({
352
- 'nut-popover-menu-item': true,
353
- 'nut-popover-menu-disabled': item.disabled
325
+ 'nut-popover-item': true,
326
+ 'nut-popover-item-disabled': item.disabled
354
327
  }, item.className),
355
328
  key: item.key || index,
356
329
  onClick: function onClick() {
357
330
  return handleSelect(item, index);
358
331
  }
359
332
  }, item.icon && /*#__PURE__*/ _react.default.createElement(_components.View, {
360
- className: "nut-popover-menu-item-icon"
361
- }, item.icon), /*#__PURE__*/ _react.default.createElement(_components.View, {
362
- className: "nut-popover-menu-item-name"
363
- }, item.name), item.action && item.action.icon && /*#__PURE__*/ _react.default.createElement(_components.View, {
364
- className: "nut-popover-menu-item-action-icon",
333
+ className: "nut-popover-item-icon"
334
+ }, item.icon), /*#__PURE__*/ _react.default.createElement(_components.Text, {
335
+ className: "nut-popover-item-name"
336
+ }, item.name), ((_item_action = item.action) === null || _item_action === void 0 ? void 0 : _item_action.icon) && /*#__PURE__*/ _react.default.createElement(_components.View, {
337
+ className: "nut-popover-item-action-icon",
365
338
  onClick: function onClick(e) {
366
339
  var _item_action_onClick, _item_action;
367
340
  return (_item_action = item.action) === null || _item_action === void 0 ? void 0 : (_item_action_onClick = _item_action.onClick) === null || _item_action_onClick === void 0 ? void 0 : _item_action_onClick.call(_item_action, e);
@@ -30,13 +30,14 @@
30
30
  transform: rotate(90deg) translateY(-50%);
31
31
  }
32
32
 
33
- &.nut-popover-arrow-left-start {
33
+ &.nut-popover-arrow-left-top {
34
34
  top: 16px;
35
35
  right: -8px;
36
36
  transform: rotate(90deg) translateY(0%);
37
37
  }
38
38
 
39
- &.nut-popover-arrow-left-end {
39
+ &.nut-popover-arrow-left-bottom {
40
+ top: auto;
40
41
  bottom: 16px;
41
42
  right: -8px;
42
43
  transform: rotate(90deg) translateY(0%);
@@ -51,13 +52,13 @@
51
52
  transform: rotate(-90deg) translateY(-50%);
52
53
  }
53
54
 
54
- &.nut-popover-arrow-right-start {
55
+ &.nut-popover-arrow-right-top {
55
56
  top: 16px;
56
57
  left: -8px;
57
58
  transform: rotate(-90deg) translateY(0%);
58
59
  }
59
60
 
60
- &.nut-popover-arrow-right-end {
61
+ &.nut-popover-arrow-right-bottom {
61
62
  bottom: 16px;
62
63
  left: -8px;
63
64
  transform: rotate(-90deg) translateY(0%);
@@ -75,13 +76,16 @@
75
76
  max-height: initial;
76
77
  overflow-y: initial;
77
78
 
78
- .nut-popover-menu-item {
79
+ &-group {
80
+ padding: 0 $popover-padding;
81
+ }
82
+
83
+ .nut-popover-item {
79
84
  display: flex;
80
85
  align-items: center;
81
86
  justify-content: center;
82
- padding: 0 $popover-menu-item-padding;
83
87
  border-bottom: 1px solid $popover-divider-color;
84
- max-width: $popover-menu-item-width;
88
+ max-width: $popover-item-width;
85
89
  word-wrap: break-word;
86
90
 
87
91
  &:last-child {
@@ -89,48 +93,42 @@
89
93
  border-bottom: none;
90
94
  }
91
95
 
92
- &-icon {
96
+ &-icon,
97
+ &-action-icon {
93
98
  display: flex;
94
99
  justify-content: center;
95
100
  align-items: center;
96
- width: 12px;
97
- height: 12px;
98
- font-size: 12px;
101
+ width: $font-size-s;
102
+ height: $font-size-s;
103
+ font-size: $font-size-s;
99
104
  .nut-icon {
100
- width: 12px;
101
- height: 12px;
102
- font-size: 12px;
105
+ width: $font-size-s;
106
+ height: $font-size-s;
107
+ font-size: $font-size-s;
103
108
  }
104
109
  }
105
110
 
111
+ &-icon {
112
+ margin-right: $spacing-xxs;
113
+ }
114
+
106
115
  &-name {
107
116
  width: calc(100% - 34px);
108
117
  word-break: keep-all;
109
- margin: 0 8px 0 4px;
110
118
  flex: 1;
111
119
  }
112
120
 
113
121
  &-action-icon {
114
- display: flex;
115
- justify-content: center;
116
- align-items: center;
117
- width: 12px;
118
- height: 12px;
119
- font-size: 12px;
120
122
  color: $color-text;
121
- .nut-icon {
122
- width: 12px;
123
- height: 12px;
124
- font-size: 12px;
125
- }
123
+ margin-left: $spacing-base;
126
124
  }
127
125
 
128
- &.nut-popover-menu-disabled {
126
+ &.nut-popover-item-disabled {
129
127
  color: $popover-disable-color;
130
128
  cursor: not-allowed;
131
129
  }
132
130
 
133
- &.nut-popover-menu-taroitem {
131
+ &.nut-popover-taroitem {
134
132
  display: flex;
135
133
  }
136
134
  }
@@ -143,18 +141,18 @@
143
141
  }
144
142
  }
145
143
 
146
- &-top-end {
144
+ &-top-right {
147
145
  right: 0;
148
- .nut-popover-arrow-top-end {
146
+ .nut-popover-arrow-top-right {
149
147
  right: 16px;
150
148
  bottom: -3.5px;
151
149
  transform: rotate(180deg) translateX(0%);
152
150
  }
153
151
  }
154
152
 
155
- &-top-start {
153
+ &-top-left {
156
154
  left: 0;
157
- .nut-popover-arrow-top-start {
155
+ .nut-popover-arrow-top-left {
158
156
  left: 16px;
159
157
  bottom: -3.5px;
160
158
  transform: rotate(180deg) translateX(0%);
@@ -168,35 +166,35 @@
168
166
  }
169
167
  }
170
168
 
171
- &-bottom-end {
169
+ &-bottom-right {
172
170
  right: 0;
173
- .nut-popover-arrow-bottom-end {
171
+ .nut-popover-arrow-bottom-right {
174
172
  right: 16px;
175
173
  transform: translateX(0%);
176
174
  }
177
175
  }
178
176
 
179
- &-bottom-start {
177
+ &-bottom-left {
180
178
  left: 0;
181
- .nut-popover-arrow-bottom-start {
179
+ .nut-popover-arrow-bottom-left {
182
180
  left: 16px;
183
181
  transform: translateX(0%);
184
182
  }
185
183
  }
186
184
 
187
- &-left-end {
185
+ &-left-bottom {
188
186
  bottom: 0;
189
187
  }
190
188
 
191
- &-left-start {
189
+ &-left-top {
192
190
  top: 0;
193
191
  }
194
192
 
195
- &-right-end {
193
+ &-right-bottom {
196
194
  bottom: 0;
197
195
  }
198
196
 
199
- &-right-start {
197
+ &-right-top {
200
198
  top: 0;
201
199
  }
202
200
  }
@@ -215,7 +213,7 @@
215
213
  .nut-popover-content {
216
214
  background: $popover-text-color !important;
217
215
  color: $popover-content-background-color !important;
218
- .nut-popover-menu-item {
216
+ .nut-popover-item {
219
217
  &-action-icon {
220
218
  color: rgba(255, 255, 255, 0.8);
221
219
  }
@@ -226,7 +224,7 @@
226
224
  [dir='rtl'] .nut-popover,
227
225
  .nut-rtl .nut-popover {
228
226
  .nut-popover-content {
229
- .nut-popover-menu-item {
227
+ .nut-popover-item {
230
228
  &-name {
231
229
  margin-left: 0;
232
230
  margin-right: 4px;
@@ -234,7 +232,6 @@
234
232
 
235
233
  &-action-icon {
236
234
  right: auto;
237
- left: $popover-menu-item-padding;
238
235
  }
239
236
  }
240
237
  &-top {
@@ -244,21 +241,21 @@
244
241
  transform: translateX(50%);
245
242
  }
246
243
  }
247
- &-top-end {
244
+ &-top-right {
248
245
  right: auto;
249
246
  left: 0;
250
247
 
251
- .nut-popover-arrow-top-end {
248
+ .nut-popover-arrow-top-right {
252
249
  right: auto;
253
250
  left: 16px;
254
251
  }
255
252
  }
256
253
 
257
- &-top-start {
254
+ &-top-left {
258
255
  left: auto;
259
256
  right: 0;
260
257
 
261
- .nut-popover-arrow-top-start {
258
+ .nut-popover-arrow-top-left {
262
259
  left: auto;
263
260
  right: 16px;
264
261
  }
@@ -271,22 +268,22 @@
271
268
  transform: translateX(50%);
272
269
  }
273
270
  }
274
- &-bottom-end {
271
+ &-bottom-right {
275
272
  right: auto;
276
273
 
277
274
  left: 0;
278
275
 
279
- .nut-popover-arrow-bottom-end {
276
+ .nut-popover-arrow-bottom-right {
280
277
  right: auto;
281
278
  left: 16px;
282
279
  }
283
280
  }
284
281
 
285
- &-bottom-start {
282
+ &-bottom-left {
286
283
  left: auto;
287
284
  right: 0;
288
285
 
289
- .nut-popover-arrow-bottom-start {
286
+ .nut-popover-arrow-bottom-left {
290
287
  left: auto;
291
288
  right: 16px;
292
289
  }