@nutui/nutui-react-taro 1.5.2-beta.1 → 1.5.2

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 (231) hide show
  1. package/dist/esm/ActionSheet.js +90 -14
  2. package/dist/esm/Address.js +620 -21
  3. package/dist/esm/Animate.js +53 -7
  4. package/dist/esm/AnimatingNumbers.js +125 -7
  5. package/dist/esm/Audio.js +264 -19
  6. package/dist/esm/Avatar.js +130 -11
  7. package/dist/esm/{AvatarContext-c96afdcc.js → AvatarContext-15733596.js} +1 -3
  8. package/dist/esm/AvatarGroup.js +41 -11
  9. package/dist/esm/BackTop.js +138 -10
  10. package/dist/esm/Badge.js +71 -9
  11. package/dist/esm/Barrage.js +97 -8
  12. package/dist/esm/Button.js +108 -9
  13. package/dist/esm/Calendar.js +128 -20
  14. package/dist/esm/CalendarItem.js +674 -12
  15. package/dist/esm/Card.js +61 -11
  16. package/dist/esm/Cascader.js +671 -16
  17. package/dist/esm/Cell.js +101 -9
  18. package/dist/esm/CellGroup.js +2 -5
  19. package/dist/esm/Checkbox.js +5 -7
  20. package/dist/esm/CheckboxGroup.js +111 -8
  21. package/dist/esm/CircleProgress.js +114 -8
  22. package/dist/esm/Col.js +57 -7
  23. package/dist/esm/Collapse.js +97 -7
  24. package/dist/esm/CollapseItem.js +146 -8
  25. package/dist/esm/ConfigProvider.js +187 -8
  26. package/dist/esm/CountDown.js +247 -9
  27. package/dist/esm/DatePicker.js +309 -25
  28. package/dist/esm/Dialog.js +296 -17
  29. package/dist/esm/Divider.js +34 -7
  30. package/dist/esm/Drag.js +118 -7
  31. package/dist/esm/Elevator.js +234 -8
  32. package/dist/esm/Ellipsis.js +176 -10
  33. package/dist/esm/Empty.js +79 -8
  34. package/dist/esm/FixedNav.js +103 -14
  35. package/dist/esm/Form.js +215 -10
  36. package/dist/esm/FormItem.js +3 -10
  37. package/dist/esm/Grid.js +81 -11
  38. package/dist/esm/GridItem.js +123 -13
  39. package/dist/esm/Icon.js +2 -5
  40. package/dist/esm/Image.js +169 -11
  41. package/dist/esm/ImagePreview.js +225 -19
  42. package/dist/esm/Indicator.js +50 -7
  43. package/dist/esm/Infiniteloading.js +215 -14
  44. package/dist/esm/Input.js +362 -12
  45. package/dist/esm/InputNumber.js +275 -9
  46. package/dist/esm/Layout.js +13 -5
  47. package/dist/esm/Menu.js +153 -10
  48. package/dist/esm/MenuItem.js +175 -15
  49. package/dist/esm/NavBar.js +114 -9
  50. package/dist/esm/NoticeBar.js +568 -10
  51. package/dist/esm/Notify.js +234 -8
  52. package/dist/esm/NumberKeyboard.js +247 -17
  53. package/dist/esm/Overlay.js +2 -6
  54. package/dist/esm/Pagination.js +168 -9
  55. package/dist/esm/Picker.js +494 -22
  56. package/dist/esm/Popover.js +223 -12
  57. package/dist/esm/Popup.js +193 -13
  58. package/dist/esm/Price.js +84 -6
  59. package/dist/esm/Progress.js +122 -9
  60. package/dist/esm/PullToRefresh.js +276 -13
  61. package/dist/esm/Radio.js +4 -8
  62. package/dist/esm/RadioGroup.js +120 -7
  63. package/dist/esm/Range.js +406 -15
  64. package/dist/esm/Rate.js +121 -9
  65. package/dist/esm/Row.js +49 -7
  66. package/dist/esm/SearchBar.js +235 -12
  67. package/dist/esm/ShortPassword.js +191 -17
  68. package/dist/esm/SideNavBar.js +57 -19
  69. package/dist/esm/SideNavBarItem.js +24 -5
  70. package/dist/esm/Signature.js +153 -13
  71. package/dist/esm/Skeleton.js +98 -12
  72. package/dist/esm/Step.js +87 -10
  73. package/dist/esm/Steps.js +38 -8
  74. package/dist/esm/Sticky.js +190 -11
  75. package/dist/esm/SubSideNavBar.js +78 -6
  76. package/dist/esm/Swipe.js +230 -10
  77. package/dist/esm/Swiper.js +490 -9
  78. package/dist/esm/SwiperItem.js +36 -8
  79. package/dist/esm/Switch.js +71 -6
  80. package/dist/esm/TabPane.js +2 -5
  81. package/dist/esm/Tabbar.js +68 -6
  82. package/dist/esm/TabbarItem.js +78 -9
  83. package/dist/esm/Table.js +140 -12
  84. package/dist/esm/Tabs.js +5 -8
  85. package/dist/esm/Tag.js +110 -10
  86. package/dist/esm/TextArea.js +148 -9
  87. package/dist/esm/TimeDetail.js +67 -9
  88. package/dist/esm/TimePannel.js +29 -9
  89. package/dist/esm/TimeSelect.js +171 -19
  90. package/dist/esm/Toast.js +268 -7
  91. package/dist/esm/TrendArrow.js +99 -7
  92. package/dist/esm/Uploader.js +566 -17
  93. package/dist/esm/{UserContext-0aac9a82.js → UserContext-101ad4a4.js} +1 -3
  94. package/dist/esm/{UserContext-e402e1a6.js → UserContext-2629d479.js} +1 -3
  95. package/dist/esm/{UserContext-e8176108.js → UserContext-b33bcf21.js} +1 -3
  96. package/dist/esm/Video.js +90 -7
  97. package/dist/esm/VirtualList.js +313 -9
  98. package/dist/esm/WaterMark.js +111 -11
  99. package/dist/esm/{bem-350c1702.js → bem-3b438e61.js} +6 -3
  100. package/dist/esm/cellgroup-fcc72767.js +34 -0
  101. package/dist/esm/checkbox-44e13cd0.js +137 -0
  102. package/dist/esm/date-c7aad4c0.js +97 -0
  103. package/dist/esm/formitem-8a73a5fb.js +157 -0
  104. package/dist/esm/get-scroll-parent-5f85dee8.js +24 -0
  105. package/dist/esm/{grid.taro.context-c2bbfb4f.js → grid.context-2ee27d95.js} +2 -4
  106. package/dist/esm/icon-4ef1581c.js +70 -0
  107. package/dist/esm/index-030b7245.js +11 -0
  108. package/dist/esm/nutui-react.es.js +94 -119
  109. package/dist/esm/offsetContext-3ab00d40.js +16 -0
  110. package/dist/esm/overlay-de6c79d5.js +83 -0
  111. package/dist/esm/radio-9f141e6b.js +118 -0
  112. package/dist/esm/render-bbebb760.js +79 -0
  113. package/dist/esm/tabpane-01075e6c.js +29 -0
  114. package/dist/esm/tabs-e1b4e4b1.js +181 -0
  115. package/dist/esm/typings-f27b58f4.js +8 -0
  116. package/dist/esm/useClientRect-56bb675b.js +39 -0
  117. package/dist/esm/useTouch-cf73a407.js +99 -0
  118. package/dist/locales/base.js +1 -1
  119. package/dist/locales/en-US.js +1 -1
  120. package/dist/locales/id-ID.js +1 -1
  121. package/dist/locales/zh-CN.js +1 -1
  122. package/dist/locales/zh-TW.js +1 -1
  123. package/dist/locales/zh-UG.js +1 -1
  124. package/dist/nutui.react.mjs +15025 -13192
  125. package/dist/nutui.react.umd.js +15004 -13169
  126. package/dist/style.mjs +1 -1
  127. package/dist/types/index.d.ts +183 -176
  128. package/package.json +1 -1
  129. package/dist/esm/actionsheet.taro-e6a51446.js +0 -53
  130. package/dist/esm/address.taro-3a9b6396.js +0 -461
  131. package/dist/esm/animate.taro-fb7986d6.js +0 -40
  132. package/dist/esm/animatingnumbers.taro-03e5d61d.js +0 -104
  133. package/dist/esm/audio.taro-87ec8bf2.js +0 -161
  134. package/dist/esm/avatar.taro-3676f38f.js +0 -103
  135. package/dist/esm/avatargroup-f3574510.js +0 -34
  136. package/dist/esm/backtop.taro-66394a36.js +0 -48
  137. package/dist/esm/badge.taro-a4e59c11.js +0 -52
  138. package/dist/esm/barrage.taro-0495a1b2.js +0 -94
  139. package/dist/esm/button.taro-9244d065.js +0 -100
  140. package/dist/esm/calendar.taro-670842ea.js +0 -65
  141. package/dist/esm/calendaritem.taro-2a603571.js +0 -787
  142. package/dist/esm/can-use-dom-3eeb5af4.js +0 -6
  143. package/dist/esm/card.taro-e4c76dad.js +0 -33
  144. package/dist/esm/cascader.taro-eb1fb011.js +0 -438
  145. package/dist/esm/cell.taro-a10a74d3.js +0 -64
  146. package/dist/esm/cellgroup.taro-abe501bc.js +0 -25
  147. package/dist/esm/checkbox.taro-6120e3e3.js +0 -171
  148. package/dist/esm/circleprogress.taro-79854448.js +0 -109
  149. package/dist/esm/col.taro-53eed3cc.js +0 -41
  150. package/dist/esm/collapse.taro-1a9e4ba2.js +0 -83
  151. package/dist/esm/collapseitem-4d0bc55d.js +0 -83
  152. package/dist/esm/configprovider-67d19d3a.js +0 -19
  153. package/dist/esm/configprovider.taro-8d71eb49.js +0 -42
  154. package/dist/esm/countdown.taro-5b17c607.js +0 -226
  155. package/dist/esm/datepicker.taro-6e9b4b8f.js +0 -275
  156. package/dist/esm/dialog.taro-a3267d29.js +0 -118
  157. package/dist/esm/divider.taro-26d1d8b4.js +0 -35
  158. package/dist/esm/drag.taro-79bb8744.js +0 -110
  159. package/dist/esm/elevator.taro-6019669e.js +0 -178
  160. package/dist/esm/ellipsis.taro-f15f26da.js +0 -241
  161. package/dist/esm/empty.taro-04ae4389.js +0 -62
  162. package/dist/esm/fixednav.taro-1f05acaf.js +0 -53
  163. package/dist/esm/form.taro-0c8e7a39.js +0 -179
  164. package/dist/esm/formitem.taro-190a3326.js +0 -89
  165. package/dist/esm/get-scroll-parent-b4a07e65.js +0 -25
  166. package/dist/esm/grid.taro-3503b82c.js +0 -61
  167. package/dist/esm/griditem.taro-cdb3f119.js +0 -98
  168. package/dist/esm/icon-296a1bec.js +0 -63
  169. package/dist/esm/icon.taro-296a1bec.js +0 -63
  170. package/dist/esm/image.taro-142cf512.js +0 -64
  171. package/dist/esm/imagepreview.taro-c50bb0a3.js +0 -167
  172. package/dist/esm/index-5bcb0ff8.js +0 -7
  173. package/dist/esm/indicator.taro-cba8b010.js +0 -37
  174. package/dist/esm/infiniteloading.taro-183bccbf.js +0 -144
  175. package/dist/esm/input.taro-97af6c96.js +0 -240
  176. package/dist/esm/inputnumber.taro-91f65d17.js +0 -130
  177. package/dist/esm/layout.taro-9046d093.js +0 -11
  178. package/dist/esm/menu.taro-7e4038a1.js +0 -99
  179. package/dist/esm/menuitem.taro-96cc4f15.js +0 -130
  180. package/dist/esm/navbar.taro-777c4705.js +0 -79
  181. package/dist/esm/noticebar.taro-4a23cdee.js +0 -448
  182. package/dist/esm/notify.taro-e17c6f82.js +0 -75
  183. package/dist/esm/numberkeyboard.taro-1bc24744.js +0 -159
  184. package/dist/esm/offsetContext-c2a746fa.js +0 -5
  185. package/dist/esm/overlay.taro-21e87fb1.js +0 -69
  186. package/dist/esm/pagination.taro-715a173b.js +0 -124
  187. package/dist/esm/picker.taro-9ad1b7c5.js +0 -473
  188. package/dist/esm/popover.taro-ad5e76ea.js +0 -156
  189. package/dist/esm/popup.taro-01676bff.js +0 -137
  190. package/dist/esm/price.taro-776ed16e.js +0 -83
  191. package/dist/esm/progress.taro-f0ce38e9.js +0 -90
  192. package/dist/esm/pulltorefresh.taro-a294f656.js +0 -181
  193. package/dist/esm/radio.taro-a6eff96c.js +0 -168
  194. package/dist/esm/range.taro-d8fc7656.js +0 -332
  195. package/dist/esm/rate.taro-6cdf03bd.js +0 -75
  196. package/dist/esm/row.taro-f64d4a13.js +0 -46
  197. package/dist/esm/searchbar.taro-0c25927b.js +0 -152
  198. package/dist/esm/shortpassword.taro-9ee034f7.js +0 -111
  199. package/dist/esm/sidenavbar.taro-c307b35e.js +0 -35
  200. package/dist/esm/sidenavbaritem.taro-5a7965d0.js +0 -12
  201. package/dist/esm/signature.taro-ec4e713b.js +0 -143
  202. package/dist/esm/skeleton.taro-76faf63f.js +0 -62
  203. package/dist/esm/step.taro-b7903e8c.js +0 -59
  204. package/dist/esm/steps.taro-c82d2252.js +0 -30
  205. package/dist/esm/sticky.taro-218bda37.js +0 -138
  206. package/dist/esm/subsidenavbar.taro-69cb9752.js +0 -63
  207. package/dist/esm/supports-passive-c85ef996.js +0 -18
  208. package/dist/esm/swipe.taro-ea35f07f.js +0 -177
  209. package/dist/esm/swiper.taro-7a94e211.js +0 -451
  210. package/dist/esm/swiperitem-c9e3d0d5.js +0 -29
  211. package/dist/esm/switch.taro-34ca8228.js +0 -50
  212. package/dist/esm/tabbar.taro-9acfc2fa.js +0 -59
  213. package/dist/esm/tabbaritem.taro-bf517487.js +0 -58
  214. package/dist/esm/table.taro-91fc0c01.js +0 -93
  215. package/dist/esm/tabpane.taro-4ca340ef.js +0 -23
  216. package/dist/esm/tabs.taro-6a7524a4.js +0 -140
  217. package/dist/esm/tag.taro-23ba0834.js +0 -92
  218. package/dist/esm/textarea.taro-442e7350.js +0 -94
  219. package/dist/esm/timedetail.taro-5b2f2269.js +0 -44
  220. package/dist/esm/timepannel.taro-d6e40180.js +0 -22
  221. package/dist/esm/timeselect.taro-a07036f4.js +0 -133
  222. package/dist/esm/toast.taro-d6c14811.js +0 -109
  223. package/dist/esm/trendarrow.taro-b8c5ccd9.js +0 -73
  224. package/dist/esm/typings-b9828dba.js +0 -9
  225. package/dist/esm/uploader.taro-587e6bf3.js +0 -492
  226. package/dist/esm/useClientRect-1f8ed1fe.js +0 -18
  227. package/dist/esm/useTouch-db24bb5c.js +0 -69
  228. package/dist/esm/video-f1be8a91.js +0 -67
  229. package/dist/esm/virtuallist.taro-f0b0270d.js +0 -214
  230. package/dist/esm/watermark.taro-9ce2ae37.js +0 -114
  231. package/dist/esm/zh-CN-c779e6c1.js +0 -131
@@ -1,11 +1,492 @@
1
- import { S as Swiper } from './swiper.taro-7a94e211.js';
2
- import 'react';
3
- import 'classnames';
4
- import '@tarojs/taro';
5
- import './UserContext-e8176108.js';
6
- import './bem-350c1702.js';
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
+ import _typeof from "@babel/runtime/helpers/typeof";
5
+ var _excluded = ["children", "direction", "className", "pageContent", "onChange", "initPage", "paginationColor", "paginationVisible", "touchable", "isPreventDefault", "isStopPropagation", "autoPlay", "isCenter", "paginationBgColor"];
6
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
+ import React__default, { useRef, useState, useMemo, useEffect } from 'react';
9
+ import classNames from 'classnames';
10
+ import { D as DataContext } from './UserContext-2629d479.js';
11
+ import { c as cn } from './bem-3b438e61.js';
12
+ import { g as getRect } from './useClientRect-56bb675b.js';
7
13
  import '@bem-react/classname';
8
-
9
-
10
-
14
+ var defaultProps = {
15
+ width: (typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object' ? window.innerWidth : 375,
16
+ height: 0,
17
+ duration: 500,
18
+ initPage: 0,
19
+ autoPlay: 0,
20
+ direction: 'horizontal',
21
+ paginationColor: '#fff',
22
+ paginationBgColor: '#ddd',
23
+ paginationVisible: false,
24
+ loop: true,
25
+ touchable: true,
26
+ isPreventDefault: true,
27
+ isStopPropagation: true,
28
+ isCenter: false,
29
+ className: ''
30
+ };
31
+ var DISTANCE = 5;
32
+ var Swiper = React__default.forwardRef(function (props, ref) {
33
+ var _classNames, _classNames2;
34
+ var propSwiper = _objectSpread(_objectSpread({}, defaultProps), props);
35
+ var children = propSwiper.children,
36
+ direction = propSwiper.direction,
37
+ className = propSwiper.className,
38
+ pageContent = propSwiper.pageContent,
39
+ onChange = propSwiper.onChange,
40
+ initPage = propSwiper.initPage,
41
+ paginationColor = propSwiper.paginationColor,
42
+ paginationVisible = propSwiper.paginationVisible,
43
+ touchable = propSwiper.touchable,
44
+ isPreventDefault = propSwiper.isPreventDefault,
45
+ isStopPropagation = propSwiper.isStopPropagation,
46
+ autoPlay = propSwiper.autoPlay,
47
+ isCenter = propSwiper.isCenter,
48
+ paginationBgColor = propSwiper.paginationBgColor,
49
+ rest = _objectWithoutProperties(propSwiper, _excluded);
50
+ var container = useRef(null);
51
+ var innerRef = useRef(null);
52
+ var _swiper = useRef({
53
+ moving: false,
54
+ autoplayTimer: null,
55
+ width: 0,
56
+ height: 0,
57
+ offset: 0,
58
+ size: 0
59
+ });
60
+ var isVertical = direction === 'vertical';
61
+ var _useState = useState(null),
62
+ _useState2 = _slicedToArray(_useState, 2),
63
+ rect = _useState2[0],
64
+ setRect = _useState2[1];
65
+ // eslint-disable-next-line prefer-const
66
+ var _useState3 = useState(0),
67
+ _useState4 = _slicedToArray(_useState3, 2),
68
+ active = _useState4[0],
69
+ setActive = _useState4[1];
70
+ var _useState5 = useState(0),
71
+ _useState6 = _slicedToArray(_useState5, 2),
72
+ width = _useState6[0],
73
+ setWidth = _useState6[1];
74
+ var _useState7 = useState(0),
75
+ _useState8 = _slicedToArray(_useState7, 2),
76
+ height = _useState8[0],
77
+ setHeight = _useState8[1];
78
+ var _useState9 = useState(0),
79
+ _useState10 = _slicedToArray(_useState9, 2),
80
+ offset = _useState10[0],
81
+ setOffset = _useState10[1];
82
+ var _useState11 = useState([]),
83
+ _useState12 = _slicedToArray(_useState11, 2),
84
+ childOffset = _useState12[0],
85
+ setChildOffset = _useState12[1];
86
+ var _useState13 = useState(false),
87
+ _useState14 = _slicedToArray(_useState13, 2),
88
+ ready = _useState14[0],
89
+ setReady = _useState14[1];
90
+ var size = isVertical ? height : width;
91
+ var _useState15 = useState({
92
+ startX: 0,
93
+ startY: 0,
94
+ deltaX: 0,
95
+ deltaY: 0,
96
+ offsetX: 0,
97
+ offsetY: 0,
98
+ stateDirection: '',
99
+ delta: 0,
100
+ touchTime: 0
101
+ }),
102
+ _useState16 = _slicedToArray(_useState15, 2),
103
+ touch = _useState16[0],
104
+ setTouch = _useState16[1];
105
+ var _useMemo = useMemo(function () {
106
+ var childCount = 0;
107
+ var childs = React__default.Children.map(props.children, function (child) {
108
+ if (!React__default.isValidElement(child)) return null;
109
+ childCount++;
110
+ return child;
111
+ });
112
+ return {
113
+ childs: childs,
114
+ childCount: childCount
115
+ };
116
+ }, [props.children]),
117
+ childs = _useMemo.childs,
118
+ childCount = _useMemo.childCount;
119
+ var trackSize = childCount * Number(size);
120
+ // 父组件参数传入子组件item
121
+ var parent = {
122
+ propSwiper: propSwiper,
123
+ size: size
124
+ };
125
+ var minOffset = function () {
126
+ if (rect) {
127
+ var base = isVertical ? rect.height : rect.width;
128
+ return base - Number(size) * childCount;
129
+ }
130
+ return 0;
131
+ }();
132
+ // 清除定时器
133
+ var stopAutoPlay = function stopAutoPlay() {
134
+ clearTimeout(_swiper.current.autoplayTimer);
135
+ _swiper.current.autoplayTimer = null;
136
+ };
137
+ // 定时轮播
138
+ var autoplay = function autoplay() {
139
+ if (propSwiper.autoPlay <= 0 || childCount <= 1) return;
140
+ stopAutoPlay();
141
+ _swiper.current.autoplayTimer = setTimeout(function () {
142
+ next();
143
+ autoplay();
144
+ }, Number(propSwiper.autoPlay));
145
+ };
146
+ // 重置首尾位置信息
147
+ var resettPosition = function resettPosition() {
148
+ _swiper.current.moving = true;
149
+ if (active <= -1) {
150
+ move({
151
+ pace: childCount
152
+ });
153
+ }
154
+ if (active >= childCount) {
155
+ move({
156
+ pace: -childCount
157
+ });
158
+ }
159
+ };
160
+ // 上一页
161
+ var prev = function prev() {
162
+ resettPosition();
163
+ touchReset();
164
+ requestFrame(function () {
165
+ requestFrame(function () {
166
+ _swiper.current.moving = false;
167
+ move({
168
+ pace: -1,
169
+ isEmit: true
170
+ });
171
+ });
172
+ });
173
+ };
174
+ // 下一页
175
+ var next = function next() {
176
+ resettPosition();
177
+ touchReset();
178
+ requestFrame(function () {
179
+ requestFrame(function () {
180
+ _swiper.current.moving = false;
181
+ move({
182
+ pace: 1,
183
+ isEmit: true
184
+ });
185
+ });
186
+ });
187
+ };
188
+ // 前往指定页
189
+ var to = function to(index) {
190
+ resettPosition();
191
+ touchReset();
192
+ requestFrame(function () {
193
+ requestFrame(function () {
194
+ _swiper.current.moving = false;
195
+ var targetIndex;
196
+ if (props.loop && childCount === index) {
197
+ targetIndex = active === 0 ? 0 : index;
198
+ } else {
199
+ targetIndex = index % childCount;
200
+ }
201
+ move({
202
+ pace: targetIndex - active,
203
+ isEmit: true
204
+ });
205
+ });
206
+ });
207
+ };
208
+ var resize = function resize() {
209
+ init(active);
210
+ };
211
+ // 切换方法
212
+ var move = function move(_ref) {
213
+ var _ref$pace = _ref.pace,
214
+ pace = _ref$pace === void 0 ? 0 : _ref$pace,
215
+ _ref$offset = _ref.offset,
216
+ offset = _ref$offset === void 0 ? 0 : _ref$offset,
217
+ _ref$isEmit = _ref.isEmit,
218
+ isEmit = _ref$isEmit === void 0 ? false : _ref$isEmit,
219
+ _ref$movingStatus = _ref.movingStatus,
220
+ movingStatus = _ref$movingStatus === void 0 ? false : _ref$movingStatus;
221
+ if (childCount <= 1) return;
222
+ var targetActive = getActive(pace);
223
+ // 父级容器偏移量
224
+ var targetOffset = getOffset(targetActive, offset);
225
+ // 如果循环,调整开头结尾图片位置
226
+ if (props.loop) {
227
+ if (Array.isArray(children) && children[0] && targetOffset !== minOffset) {
228
+ var rightBound = targetOffset < minOffset;
229
+ childOffset[0] = rightBound ? trackSize : 0;
230
+ }
231
+ if (Array.isArray(children) && children[childCount - 1] && targetOffset !== 0) {
232
+ var leftBound = targetOffset > 0;
233
+ childOffset[childCount - 1] = leftBound ? -trackSize : 0;
234
+ }
235
+ setChildOffset(childOffset);
236
+ }
237
+ if (isEmit && active !== targetActive) {
238
+ props.onChange && props.onChange((targetActive + childCount) % childCount);
239
+ }
240
+ active = targetActive;
241
+ setActive(targetActive);
242
+ setOffset(targetOffset);
243
+ getStyle(targetOffset);
244
+ };
245
+ // 确定当前active 元素
246
+ var getActive = function getActive(pace) {
247
+ if (pace) {
248
+ var _active = active + pace;
249
+ if (props.loop) {
250
+ return range(_active, -1, childCount);
251
+ }
252
+ return range(_active, 0, childCount - 1);
253
+ }
254
+ return active;
255
+ };
256
+ // 计算位移
257
+ var getOffset = function getOffset(active) {
258
+ var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
259
+ var currentPosition = active * Number(size);
260
+ if (!props.loop) {
261
+ currentPosition = Math.min(currentPosition, -minOffset);
262
+ }
263
+ var targetOffset = offset - currentPosition;
264
+ if (!props.loop) {
265
+ targetOffset = range(targetOffset, minOffset, 0);
266
+ }
267
+ return targetOffset;
268
+ };
269
+ // 浏览器 帧 事件
270
+ var requestFrame = function requestFrame(fn) {
271
+ window.requestAnimationFrame.call(window, fn);
272
+ };
273
+ // 取值 方法
274
+ var range = function range(num, min, max) {
275
+ return Math.min(Math.max(num, min), max);
276
+ };
277
+ var getDirection = function getDirection(x, y) {
278
+ if (x > y && x > DISTANCE) return 'horizontal';
279
+ if (y > x && y > DISTANCE) return 'vertical';
280
+ return '';
281
+ };
282
+ // 重置 全部位移信息
283
+ var touchReset = function touchReset() {
284
+ touch.startX = 0;
285
+ touch.startY = 0;
286
+ touch.deltaX = 0;
287
+ touch.deltaY = 0;
288
+ touch.offsetX = 0;
289
+ touch.offsetY = 0;
290
+ touch.delta = 0;
291
+ touch.stateDirection = '';
292
+ touch.touchTime = 0;
293
+ };
294
+ // 触摸事件开始
295
+ var touchStart = function touchStart(e) {
296
+ touchReset();
297
+ touch.startX = e.touches[0].clientX;
298
+ touch.startY = e.touches[0].clientY;
299
+ };
300
+ // 触摸事件移动
301
+ var touchMove = function touchMove(e) {
302
+ touch.deltaX = e.touches[0].clientX - touch.startX;
303
+ touch.deltaY = e.touches[0].clientY - touch.startY;
304
+ touch.offsetX = Math.abs(touch.deltaX);
305
+ touch.offsetY = Math.abs(touch.deltaY);
306
+ touch.delta = isVertical ? touch.deltaY : touch.deltaX;
307
+ if (!touch.stateDirection) {
308
+ touch.stateDirection = getDirection(touch.offsetX, touch.offsetY);
309
+ }
310
+ };
311
+ var b = cn('swiper');
312
+ var classes = classNames(b(''));
313
+ var contentClass = classNames((_classNames = {}, _defineProperty(_classNames, "".concat(b('inner')), true), _defineProperty(_classNames, "".concat(b('vertical')), isVertical), _classNames));
314
+ var getStyle = function getStyle() {
315
+ var moveOffset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : offset;
316
+ var target = innerRef.current;
317
+ var _offset = 0;
318
+ if (!isCenter) {
319
+ _offset = moveOffset;
320
+ } else {
321
+ var _size = isVertical ? height : width;
322
+ var val = isVertical ? rect.height - _size : rect.width - _size;
323
+ _offset = moveOffset + (active === childCount - 1 && !props.loop ? -val / 2 : val / 2);
324
+ }
325
+ target.style.transitionDuration = "".concat(_swiper.current.moving ? 0 : props.duration, "ms");
326
+ target.style[isVertical ? 'height' : 'width'] = "".concat(Number(size) * childCount, "px");
327
+ target.style[isVertical ? 'width' : 'height'] = "".concat(isVertical ? width : height, "px");
328
+ target.style.transform = "translate3D".concat(!isVertical ? "(".concat(_offset, "px,0,0)") : "(0,".concat(_offset, "px,0)"));
329
+ };
330
+ var onTouchStart = function onTouchStart(e) {
331
+ if (props.isPreventDefault) e.preventDefault();
332
+ if (props.isStopPropagation) e.stopPropagation();
333
+ if (!props.touchable) return;
334
+ touchStart(e);
335
+ touch.touchTime = Date.now();
336
+ stopAutoPlay();
337
+ resettPosition();
338
+ };
339
+ var onTouchMove = function onTouchMove(e) {
340
+ if (props.touchable && _swiper.current.moving) {
341
+ touchMove(e);
342
+ if (touch.stateDirection === props.direction) {
343
+ move({
344
+ offset: touch.delta
345
+ });
346
+ }
347
+ }
348
+ };
349
+ var onTouchEnd = function onTouchEnd(e) {
350
+ if (!props.touchable || !_swiper.current.moving) return;
351
+ var speed = touch.delta / (Date.now() - touch.touchTime);
352
+ var isShouldMove = Math.abs(speed) > 0.3 || Math.abs(touch.delta) > +(size / 2).toFixed(2);
353
+ var pace = 0;
354
+ _swiper.current.moving = false;
355
+ if (isShouldMove && touch.stateDirection === props.direction) {
356
+ var _offset2 = isVertical ? touch.offsetY : touch.offsetX;
357
+ if (props.loop) {
358
+ if (_offset2 > 0) {
359
+ pace = touch.delta > 0 ? -1 : 1;
360
+ } else {
361
+ pace = 0;
362
+ }
363
+ } else {
364
+ pace = -Math[touch.delta > 0 ? 'ceil' : 'floor'](touch.delta / size);
365
+ }
366
+ move({
367
+ pace: pace,
368
+ isEmit: true
369
+ });
370
+ } else if (touch.delta) {
371
+ move({
372
+ pace: 0
373
+ });
374
+ } else {
375
+ getStyle();
376
+ }
377
+ autoplay();
378
+ };
379
+ useEffect(function () {
380
+ _swiper.current.activePagination = (active + childCount) % childCount;
381
+ }, [active]);
382
+ var init = function init() {
383
+ var active = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : +propSwiper.initPage;
384
+ var rect = getRect(container === null || container === void 0 ? void 0 : container.current);
385
+ var _active = Math.max(Math.min(childCount - 1, active), 0);
386
+ var _width = propSwiper.width ? +propSwiper.width : rect.width;
387
+ var _height = propSwiper.height ? +propSwiper.height : rect.height;
388
+ size = isVertical ? _height : _width;
389
+ trackSize = childCount * Number(size);
390
+ var targetOffset = getOffset(_active);
391
+ _swiper.current.moving = true;
392
+ if (ready) {
393
+ _swiper.current.moving = false;
394
+ }
395
+ setRect(rect);
396
+ setActive(_active);
397
+ setWidth(_width);
398
+ setHeight(_height);
399
+ setOffset(targetOffset);
400
+ setReady(true);
401
+ };
402
+ useEffect(function () {
403
+ if (ready) {
404
+ getStyle();
405
+ }
406
+ }, [isVertical, width, height, offset, ready]);
407
+ useEffect(function () {
408
+ if (ready) {
409
+ stopAutoPlay();
410
+ autoplay();
411
+ }
412
+ return function () {
413
+ setReady(false);
414
+ };
415
+ }, [ready]);
416
+ useEffect(function () {
417
+ stopAutoPlay();
418
+ autoplay();
419
+ }, [children]);
420
+ useEffect(function () {
421
+ init();
422
+ }, [propSwiper.initPage]);
423
+ useEffect(function () {
424
+ var target = container.current;
425
+ target.addEventListener('touchstart', onTouchStart, false);
426
+ target.addEventListener('touchmove', onTouchMove, false);
427
+ target.addEventListener('touchend', onTouchEnd, false);
428
+ return function () {
429
+ target.removeEventListener('touchstart', onTouchStart, false);
430
+ target.removeEventListener('touchmove', onTouchMove, false);
431
+ target.removeEventListener('touchend', onTouchEnd, false);
432
+ };
433
+ });
434
+ useEffect(function () {
435
+ return function () {
436
+ stopAutoPlay();
437
+ };
438
+ }, []);
439
+ var itemStyle = function itemStyle(index) {
440
+ var style = {};
441
+ var _direction = propSwiper.direction || direction;
442
+ var _size = size;
443
+ if (_size) {
444
+ style[_direction === 'horizontal' ? 'width' : 'height'] = "".concat(_size, "px");
445
+ }
446
+ var offset = childOffset[index];
447
+ if (offset) {
448
+ style.transform = "translate3D".concat(_direction === 'horizontal' ? "(".concat(offset, "px,0,0)") : "(0,".concat(offset, "px,0)"));
449
+ }
450
+ return style;
451
+ };
452
+ React__default.useImperativeHandle(ref, function () {
453
+ return {
454
+ to: to,
455
+ next: next,
456
+ prev: prev,
457
+ resize: resize
458
+ };
459
+ });
460
+ return React__default.createElement(DataContext.Provider, {
461
+ value: parent
462
+ }, React__default.createElement("div", _objectSpread({
463
+ className: "".concat(classes, " ").concat(className),
464
+ ref: container
465
+ }, rest), React__default.createElement("div", {
466
+ className: contentClass,
467
+ ref: innerRef
468
+ }, React__default.Children.map(childs, function (child, index) {
469
+ return React__default.createElement("div", {
470
+ className: b('item-wrapper'),
471
+ style: itemStyle(index),
472
+ key: index
473
+ }, child);
474
+ })), propSwiper.paginationVisible && !('pageContent' in propSwiper) ? React__default.createElement("div", {
475
+ className: classNames((_classNames2 = {}, _defineProperty(_classNames2, "".concat(b('pagination')), true), _defineProperty(_classNames2, "".concat(b('pagination-vertical')), isVertical), _classNames2))
476
+ }, React__default.Children.map(childs, function (item, index) {
477
+ return React__default.createElement("i", {
478
+ style: (active + childCount) % childCount === index ? {
479
+ backgroundColor: propSwiper.paginationColor
480
+ } : {
481
+ backgroundColor: propSwiper.paginationBgColor
482
+ },
483
+ className: classNames({
484
+ active: (active + childCount) % childCount === index
485
+ }),
486
+ key: index
487
+ });
488
+ })) : React__default.createElement("div", null, pageContent)));
489
+ });
490
+ Swiper.defaultProps = defaultProps;
491
+ Swiper.displayName = 'NutSwiper';
11
492
  export { Swiper as default };
@@ -1,10 +1,38 @@
1
- import { S as SwiperItem } from './swiperitem-c9e3d0d5.js';
2
- import 'react';
3
- import 'classnames';
4
- import './UserContext-e8176108.js';
5
- import './bem-350c1702.js';
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+ import React__default, { useContext } from 'react';
5
+ import classNames from 'classnames';
6
+ import { D as DataContext } from './UserContext-2629d479.js';
7
+ import { c as cn } from './bem-3b438e61.js';
6
8
  import '@bem-react/classname';
7
-
8
-
9
-
9
+ var defaultProps = {
10
+ direction: 'horizontal'
11
+ };
12
+ var SwiperItem = React__default.forwardRef(function (props, ref) {
13
+ var _props = _objectSpread(_objectSpread({}, defaultProps), props);
14
+ var className = _props.className,
15
+ style = _props.style,
16
+ children = _props.children,
17
+ direction = _props.direction,
18
+ size = _props.size;
19
+ var parent = useContext(DataContext);
20
+ var b = cn('swiper-item');
21
+ var classes = classNames(b(''), className);
22
+ var getStyle = function getStyle() {
23
+ var style = {};
24
+ var _direction = (parent === null || parent === void 0 ? void 0 : parent.propSwiper.direction) || direction;
25
+ var _size = (parent === null || parent === void 0 ? void 0 : parent.size) || size;
26
+ if (_size) {
27
+ style[_direction === 'horizontal' ? 'width' : 'height'] = "".concat(_size, "px");
28
+ }
29
+ return style;
30
+ };
31
+ return React__default.createElement("div", {
32
+ className: classes,
33
+ style: _objectSpread(_objectSpread({}, style), getStyle())
34
+ }, children);
35
+ });
36
+ SwiperItem.defaultProps = defaultProps;
37
+ SwiperItem.displayName = 'NutSwiperItem';
10
38
  export { SwiperItem as default };
@@ -1,8 +1,73 @@
1
- import { S as Switch } from './switch.taro-34ca8228.js';
2
- import 'react';
3
- import './bem-350c1702.js';
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
5
+ import React__default, { useState, useEffect } from 'react';
6
+ import { c as cn } from './bem-3b438e61.js';
7
+ import { C as ComponentDefaults } from './typings-f27b58f4.js';
4
8
  import '@bem-react/classname';
5
-
6
-
7
-
9
+ var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
10
+ isAsync: false,
11
+ checked: false,
12
+ disable: false,
13
+ activeColor: '',
14
+ inactiveColor: '',
15
+ activeText: '',
16
+ inactiveText: '',
17
+ className: ''
18
+ });
19
+ var Switch = function Switch(props) {
20
+ var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
21
+ isAsync = _defaultProps$props.isAsync,
22
+ checked = _defaultProps$props.checked,
23
+ disable = _defaultProps$props.disable,
24
+ activeColor = _defaultProps$props.activeColor,
25
+ inactiveColor = _defaultProps$props.inactiveColor,
26
+ activeText = _defaultProps$props.activeText,
27
+ inactiveText = _defaultProps$props.inactiveText,
28
+ onChange = _defaultProps$props.onChange,
29
+ className = _defaultProps$props.className,
30
+ style = _defaultProps$props.style;
31
+ var _useState = useState(false),
32
+ _useState2 = _slicedToArray(_useState, 2),
33
+ value = _useState2[0],
34
+ setValue = _useState2[1];
35
+ var b = cn('switch');
36
+ useEffect(function () {
37
+ setValue(checked);
38
+ }, [checked]);
39
+ var classes = function classes() {
40
+ return "".concat(b(), " ").concat(value ? 'switch-open' : 'switch-close', " ").concat(disable ? "".concat(b(), "-disable") : '', " ", "".concat(b(), "-base"), " ").concat(className);
41
+ };
42
+ var styles = function styles() {
43
+ var myStyle = _objectSpread({
44
+ backgroundColor: value ? activeColor : inactiveColor
45
+ }, style || {});
46
+ return myStyle;
47
+ };
48
+ var _onClick = function onClick(event) {
49
+ if (disable) return;
50
+ if (!isAsync) {
51
+ setValue(!value);
52
+ }
53
+ onChange && onChange(!value, event);
54
+ };
55
+ return React__default.createElement("div", {
56
+ className: classes(),
57
+ onClick: function onClick(e) {
58
+ return _onClick(e);
59
+ },
60
+ style: styles()
61
+ }, React__default.createElement("div", {
62
+ className: "switch-button"
63
+ }, !value && React__default.createElement("div", {
64
+ className: "close-line"
65
+ }), activeText && React__default.createElement(React__default.Fragment, null, value ? React__default.createElement("div", {
66
+ className: "".concat(b('label'), " open")
67
+ }, activeText) : React__default.createElement("div", {
68
+ className: "".concat(b('label'), " close")
69
+ }, inactiveText))));
70
+ };
71
+ Switch.defaultProps = defaultProps;
72
+ Switch.displayName = 'NutSwitch';
8
73
  export { Switch as default };
@@ -1,9 +1,6 @@
1
- import { T as TabPane } from './tabpane.taro-4ca340ef.js';
1
+ import { T as TabPane } from './tabpane-01075e6c.js';
2
2
  import 'react';
3
3
  import 'classnames';
4
- import './bem-350c1702.js';
4
+ import './bem-3b438e61.js';
5
5
  import '@bem-react/classname';
6
-
7
-
8
-
9
6
  export { TabPane as default };