@nutui/nutui-react 0.1.0-beta.1 → 0.1.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 (167) hide show
  1. package/README.md +50 -135
  2. package/dist/esm/ActionSheet/style/index.js +1 -0
  3. package/dist/esm/Address/style/index.js +1 -0
  4. package/dist/esm/AnimatingNumbers/style/index.js +1 -0
  5. package/dist/esm/Avatar/style/index.js +1 -0
  6. package/dist/esm/BackTop/style/index.js +1 -0
  7. package/dist/esm/BackTop.js +1 -3
  8. package/dist/esm/Badge/style/index.js +1 -0
  9. package/dist/esm/Barrage/style/index.js +1 -0
  10. package/dist/esm/Button/style/index.js +1 -0
  11. package/dist/esm/Button.js +110 -4
  12. package/dist/esm/Calendar/style/index.js +1 -0
  13. package/dist/esm/Calendar.js +86 -0
  14. package/dist/esm/CalendarItem/style/index.js +1 -0
  15. package/dist/esm/CalendarItem.js +554 -0
  16. package/dist/esm/Cell/style/index.js +1 -0
  17. package/dist/esm/Cell.js +1 -1
  18. package/dist/esm/CellGroup/style/index.js +1 -0
  19. package/dist/esm/CellGroup.js +33 -0
  20. package/dist/esm/Checkbox/style/index.js +1 -0
  21. package/dist/esm/Checkbox.js +1 -1
  22. package/dist/esm/CheckboxGroup/style/index.js +1 -0
  23. package/dist/esm/CircleProgress/style/index.js +1 -0
  24. package/dist/esm/Col/style/index.js +1 -0
  25. package/dist/esm/Col.js +60 -0
  26. package/dist/esm/Collapse/style/index.js +1 -0
  27. package/dist/esm/CollapseItem/style/index.js +1 -0
  28. package/dist/esm/CollapseItem.js +142 -0
  29. package/dist/esm/Dialog/style/index.js +1 -0
  30. package/dist/esm/Dialog.js +327 -0
  31. package/dist/esm/Divider/style/index.js +1 -0
  32. package/dist/esm/Drag/style/index.js +1 -0
  33. package/dist/esm/Drag.js +83 -140
  34. package/dist/esm/Elevator/style/index.js +1 -0
  35. package/dist/esm/Elevator.js +3 -6
  36. package/dist/esm/FixedNav/style/index.js +1 -0
  37. package/dist/esm/FixedNav.js +2 -2
  38. package/dist/esm/Icon/style/index.js +1 -0
  39. package/dist/esm/Icon.js +70 -4
  40. package/dist/esm/Infiniteloading/style/index.js +1 -0
  41. package/dist/esm/Input/style/index.js +1 -0
  42. package/dist/esm/Input.js +1 -1
  43. package/dist/esm/InputNumber/style/index.js +1 -0
  44. package/dist/esm/Layout/style/index.js +1 -0
  45. package/dist/esm/NavBar/style/index.js +1 -0
  46. package/dist/esm/NavBar.js +1 -1
  47. package/dist/esm/NoticeBar/style/index.js +1 -0
  48. package/dist/esm/NoticeBar.js +1 -1
  49. package/dist/esm/Notify/style/index.js +1 -0
  50. package/dist/esm/Overlay/style/index.js +1 -0
  51. package/dist/esm/Pagination/style/index.js +1 -0
  52. package/dist/esm/Picker/style/index.js +1 -0
  53. package/dist/esm/Picker.js +397 -0
  54. package/dist/esm/Popover/style/index.js +1 -0
  55. package/dist/esm/Popover.js +299 -0
  56. package/dist/esm/Popup/style/index.js +1 -0
  57. package/dist/esm/Popup.js +0 -3
  58. package/dist/esm/Price/style/index.js +1 -0
  59. package/dist/esm/Radio/style/index.js +1 -0
  60. package/dist/esm/Radio.js +2 -3
  61. package/dist/esm/RadioGroup/style/index.js +1 -0
  62. package/dist/esm/Range/style/index.js +1 -0
  63. package/dist/esm/Range.js +1 -4
  64. package/dist/esm/Rate/style/index.js +1 -0
  65. package/dist/esm/Rate.js +1 -1
  66. package/dist/esm/Row/style/index.js +1 -0
  67. package/dist/esm/Row.js +48 -0
  68. package/dist/esm/ShortPassword/style/index.js +1 -0
  69. package/dist/esm/ShortPassword.js +203 -0
  70. package/dist/esm/Signature/style/index.js +1 -0
  71. package/dist/esm/Signature.js +1 -2
  72. package/dist/esm/Step/style/index.js +1 -0
  73. package/dist/esm/Steps/style/index.js +1 -0
  74. package/dist/esm/Swiper/style/index.js +1 -0
  75. package/dist/esm/Swiper.js +517 -0
  76. package/dist/esm/SwiperItem/style/index.js +1 -0
  77. package/dist/esm/SwiperItem.js +64 -0
  78. package/dist/esm/Switch/style/index.js +1 -0
  79. package/dist/esm/Switch.js +85 -0
  80. package/dist/esm/Tabbar/style/index.js +1 -0
  81. package/dist/esm/Tabbar.js +1 -4
  82. package/dist/esm/TabbarItem/style/index.js +1 -0
  83. package/dist/esm/TabbarItem.js +1 -1
  84. package/dist/esm/Tag/style/index.js +1 -0
  85. package/dist/esm/TextArea/style/index.js +1 -0
  86. package/dist/esm/Toast/style/index.js +1 -0
  87. package/dist/esm/Toast.js +294 -7
  88. package/dist/esm/Uploader/style/index.js +1 -0
  89. package/dist/esm/UserContext-b4181162.js +3 -0
  90. package/dist/esm/UserContext-be8097d2.js +3 -0
  91. package/dist/esm/date-649fe493.js +112 -0
  92. package/dist/esm/nutui-react.es.js +28 -15
  93. package/dist/esm/types/src/packages/calendar/calendar.d.ts +14 -0
  94. package/dist/esm/types/src/packages/calendar/index.d.ts +2 -0
  95. package/dist/esm/types/src/packages/calendaritem/calendaritem.d.ts +17 -0
  96. package/dist/esm/types/src/packages/calendaritem/index.d.ts +2 -0
  97. package/dist/esm/types/src/packages/dialog/Confirm.d.ts +7 -0
  98. package/dist/esm/types/src/packages/dialog/Content.d.ts +10 -0
  99. package/dist/esm/types/src/packages/dialog/DialogWrap.d.ts +11 -0
  100. package/dist/esm/types/src/packages/dialog/DialogWrapper.d.ts +8 -0
  101. package/dist/esm/types/src/packages/dialog/Mask.d.ts +3 -0
  102. package/dist/esm/types/src/packages/dialog/config.d.ts +46 -0
  103. package/dist/esm/types/src/packages/dialog/dialog.d.ts +2 -0
  104. package/dist/esm/types/src/packages/dialog/index.d.ts +2 -0
  105. package/dist/esm/types/src/packages/drag/drag.d.ts +1 -1
  106. package/dist/esm/types/src/packages/nutui.react.build.d.ts +29 -16
  107. package/dist/esm/types/src/packages/nutui.react.d.ts +29 -16
  108. package/dist/esm/types/src/packages/picker/index.d.ts +2 -0
  109. package/dist/esm/types/src/packages/picker/picker.d.ts +19 -0
  110. package/dist/esm/types/src/packages/picker/pickerSlot.d.ts +10 -0
  111. package/dist/esm/types/src/packages/popover/Trigger.d.ts +21 -0
  112. package/dist/esm/types/src/packages/popover/index.d.ts +2 -0
  113. package/dist/esm/types/src/packages/popover/popover.d.ts +13 -0
  114. package/dist/esm/types/src/packages/row/UserContext.d.ts +1 -0
  115. package/dist/esm/types/src/packages/shortpassword/index.d.ts +2 -0
  116. package/dist/esm/types/src/packages/shortpassword/shortpassword.d.ts +21 -0
  117. package/dist/esm/types/src/packages/steps/UserContext.d.ts +1 -0
  118. package/dist/esm/types/src/packages/swiper/UserContext.d.ts +2 -0
  119. package/dist/esm/types/src/packages/swiper/index.d.ts +2 -0
  120. package/dist/esm/types/src/packages/swiper/swiper.d.ts +26 -0
  121. package/dist/esm/types/src/packages/swiperitem/index.d.ts +2 -0
  122. package/dist/esm/types/src/packages/swiperitem/swiperitem.d.ts +7 -0
  123. package/dist/nutui.react.es.js +10683 -4344
  124. package/dist/nutui.react.umd.js +26 -17
  125. package/dist/packages/actionsheet/actionsheet.scss +1 -0
  126. package/dist/packages/address/address.scss +3 -0
  127. package/dist/packages/animatingnumbers/animatingnumbers.scss +1 -1
  128. package/dist/packages/backtop/backtop.scss +1 -0
  129. package/dist/packages/button/button.scss +1 -1
  130. package/dist/packages/calendar/calendar.scss +200 -0
  131. package/dist/packages/calendaritem/calendaritem.scss +191 -0
  132. package/dist/packages/cell/cell.scss +2 -0
  133. package/dist/packages/checkbox/checkbox.scss +1 -1
  134. package/dist/packages/collapse/collapse.scss +1 -1
  135. package/dist/packages/collapseitem/collapseitem.scss +2 -0
  136. package/dist/packages/dialog/dialog.scss +129 -0
  137. package/dist/packages/drag/drag.scss +2 -1
  138. package/dist/packages/fixednav/fixednav.scss +5 -0
  139. package/dist/packages/icon/icon.scss +1 -1
  140. package/dist/packages/infiniteloading/infiniteloading.scss +1 -0
  141. package/dist/packages/input/input.scss +1 -0
  142. package/dist/packages/inputnumber/inputnumber.scss +1 -0
  143. package/dist/packages/navbar/navbar.scss +2 -0
  144. package/dist/packages/noticebar/noticebar.scss +2 -0
  145. package/dist/packages/picker/picker.scss +104 -0
  146. package/dist/packages/popover/popover.scss +142 -0
  147. package/dist/packages/popup/popup.scss +2 -0
  148. package/dist/packages/radio/radio.scss +2 -0
  149. package/dist/packages/range/range.scss +1 -0
  150. package/dist/packages/rate/rate.scss +2 -0
  151. package/dist/packages/shortpassword/shortpassword.scss +115 -0
  152. package/dist/packages/signature/signature.scss +1 -0
  153. package/dist/packages/step/step.scss +1 -0
  154. package/dist/packages/swiper/swiper.scss +45 -0
  155. package/dist/packages/swiperitem/swiperitem.scss +3 -0
  156. package/dist/packages/tabbaritem/{tabbarItem.scss → tabbaritem.scss} +2 -0
  157. package/dist/packages/tag/tag.scss +1 -0
  158. package/dist/packages/toast/toast.scss +2 -0
  159. package/dist/packages/uploader/uploader.scss +2 -0
  160. package/dist/style.css +1 -1
  161. package/dist/style.es.js +1 -1
  162. package/dist/styles/themes/default.scss +26 -16
  163. package/dist/styles/variables.scss +25 -0
  164. package/package.json +16 -5
  165. package/dist/esm/button-345fb015.js +0 -110
  166. package/dist/esm/icon-63c0d58f.js +0 -70
  167. package/dist/esm/toast-420b65b7.js +0 -294
@@ -0,0 +1,517 @@
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
+ var _excluded = ["children", "direction", "className", "pageContent", "onChange", "initPage", "paginationColor", "paginationVisible", "touchable", "isPreventDefault", "isStopPropagation", "autoPlay"];
5
+
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
+
8
+ 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; }
9
+
10
+ import React__default, { useRef, useState, useEffect } from 'react';
11
+ import { D as DataContext } from './UserContext-b4181162.js';
12
+ import { c as cn } from './bem-893ad28d.js';
13
+ import classNames from 'classnames';
14
+ import '@bem-react/classname';
15
+ var defaultProps = {
16
+ width: window.innerWidth,
17
+ height: 0,
18
+ duration: 500,
19
+ initPage: 0,
20
+ autoPlay: 0,
21
+ direction: 'horizontal',
22
+ paginationColor: '#fff',
23
+ paginationVisible: false,
24
+ loop: true,
25
+ touchable: true,
26
+ isPreventDefault: true,
27
+ isStopPropagation: true,
28
+ className: ''
29
+ };
30
+ var DISTANCE = 5;
31
+ var Swiper = React__default.forwardRef(function (props, ref) {
32
+ var _classNames, _classNames2;
33
+
34
+ var propSwiper = _objectSpread(_objectSpread({}, defaultProps), props);
35
+
36
+ var children = propSwiper.children,
37
+ direction = propSwiper.direction,
38
+ className = propSwiper.className,
39
+ pageContent = propSwiper.pageContent,
40
+ onChange = propSwiper.onChange,
41
+ initPage = propSwiper.initPage,
42
+ paginationColor = propSwiper.paginationColor,
43
+ paginationVisible = propSwiper.paginationVisible,
44
+ touchable = propSwiper.touchable,
45
+ isPreventDefault = propSwiper.isPreventDefault,
46
+ isStopPropagation = propSwiper.isStopPropagation,
47
+ autoPlay = propSwiper.autoPlay,
48
+ rest = _objectWithoutProperties(propSwiper, _excluded);
49
+
50
+ var container = useRef(null);
51
+ var innerRef = useRef(null);
52
+
53
+ var _swiper = useRef({
54
+ moving: false,
55
+ autoplayTimer: null,
56
+ width: 0,
57
+ height: 0,
58
+ offset: 0,
59
+ size: 0
60
+ });
61
+
62
+ var childsRefs = [];
63
+ var isVertical = direction === 'vertical';
64
+
65
+ var _useState = useState(null),
66
+ _useState2 = _slicedToArray(_useState, 2),
67
+ rect = _useState2[0],
68
+ setRect = _useState2[1];
69
+
70
+ var _useState3 = useState(0),
71
+ _useState4 = _slicedToArray(_useState3, 2),
72
+ active = _useState4[0],
73
+ setActive = _useState4[1];
74
+
75
+ var _useState5 = useState(0),
76
+ _useState6 = _slicedToArray(_useState5, 2),
77
+ width = _useState6[0],
78
+ setWidth = _useState6[1];
79
+
80
+ var _useState7 = useState(0),
81
+ _useState8 = _slicedToArray(_useState7, 2),
82
+ height = _useState8[0],
83
+ setHeight = _useState8[1];
84
+
85
+ var _useState9 = useState(0),
86
+ _useState10 = _slicedToArray(_useState9, 2),
87
+ offset = _useState10[0],
88
+ setOffset = _useState10[1];
89
+
90
+ var _useState11 = useState(false),
91
+ _useState12 = _slicedToArray(_useState11, 2),
92
+ ready = _useState12[0],
93
+ setReady = _useState12[1];
94
+
95
+ var size = isVertical ? height : width;
96
+
97
+ var _useState13 = useState({
98
+ startX: 0,
99
+ startY: 0,
100
+ deltaX: 0,
101
+ deltaY: 0,
102
+ offsetX: 0,
103
+ offsetY: 0,
104
+ stateDirection: '',
105
+ delta: 0,
106
+ touchTime: 0
107
+ }),
108
+ _useState14 = _slicedToArray(_useState13, 2),
109
+ touch = _useState14[0],
110
+ setTouch = _useState14[1];
111
+
112
+ var _useState15 = useState([]),
113
+ _useState16 = _slicedToArray(_useState15, 2),
114
+ childs = _useState16[0],
115
+ setChilds = _useState16[1];
116
+
117
+ useState('');
118
+ var childCount = children.length;
119
+
120
+ for (var i = 0; i < childCount; i++) {
121
+ childsRefs.push(useRef(null));
122
+ }
123
+
124
+ var trackSize = childCount * Number(size);
125
+
126
+ var getChildren = function getChildren() {
127
+ var childs = [];
128
+ React__default.Children.toArray(children).forEach(function (child, index) {
129
+ if (child.type && child.type.displayName === 'NutSwiperItem') {
130
+ childs.push(React__default.cloneElement(child, {
131
+ ref: childsRefs[index],
132
+ key: 'item_' + index
133
+ }));
134
+ }
135
+ });
136
+ return childs;
137
+ }; // 父组件参数传入子组件item
138
+
139
+
140
+ var parent = {
141
+ propSwiper: propSwiper,
142
+ size: size
143
+ };
144
+
145
+ var minOffset = function () {
146
+ if (rect) {
147
+ var base = isVertical ? rect.height : rect.width;
148
+ return base - Number(size) * childCount;
149
+ }
150
+
151
+ return 0;
152
+ }(); // 清除定时器
153
+
154
+
155
+ var stopAutoPlay = function stopAutoPlay() {
156
+ clearTimeout(_swiper.current.autoplayTimer);
157
+ _swiper.current.autoplayTimer = null;
158
+ }; // 定时轮播
159
+
160
+
161
+ var autoplay = function autoplay() {
162
+ if (propSwiper.autoPlay <= 0 || childCount <= 1) return;
163
+ stopAutoPlay();
164
+ _swiper.current.autoplayTimer = setTimeout(function () {
165
+ next();
166
+ autoplay();
167
+ }, Number(propSwiper.autoPlay));
168
+ }; // 重置首尾位置信息
169
+
170
+
171
+ var resettPosition = function resettPosition() {
172
+ _swiper.current.moving = true;
173
+
174
+ if (active <= -1) {
175
+ move({
176
+ pace: childCount
177
+ });
178
+ }
179
+
180
+ if (active >= childCount) {
181
+ move({
182
+ pace: -childCount
183
+ });
184
+ }
185
+ }; // 上一页
186
+
187
+
188
+ var prev = function prev() {
189
+ resettPosition();
190
+ touchReset();
191
+ requestFrame(function () {
192
+ requestFrame(function () {
193
+ _swiper.current.moving = false;
194
+ move({
195
+ pace: -1,
196
+ isEmit: true
197
+ });
198
+ });
199
+ });
200
+ }; // 下一页
201
+
202
+
203
+ var next = function next() {
204
+ resettPosition();
205
+ touchReset();
206
+ requestFrame(function () {
207
+ requestFrame(function () {
208
+ _swiper.current.moving = false;
209
+ move({
210
+ pace: 1,
211
+ isEmit: true
212
+ });
213
+ });
214
+ });
215
+ }; // 前往指定页
216
+
217
+
218
+ var to = function to(index) {
219
+ resettPosition();
220
+ touchReset();
221
+ requestFrame(function () {
222
+ requestFrame(function () {
223
+ _swiper.current.moving = false;
224
+ var targetIndex;
225
+
226
+ if (props.loop && childCount === index) {
227
+ targetIndex = active === 0 ? 0 : index;
228
+ } else {
229
+ targetIndex = index % childCount;
230
+ }
231
+
232
+ move({
233
+ pace: targetIndex - active,
234
+ isEmit: true
235
+ });
236
+ });
237
+ });
238
+ }; // 切换方法
239
+
240
+
241
+ var move = function move(_ref) {
242
+ var _ref$pace = _ref.pace,
243
+ pace = _ref$pace === void 0 ? 0 : _ref$pace,
244
+ _ref$offset = _ref.offset,
245
+ offset = _ref$offset === void 0 ? 0 : _ref$offset,
246
+ _ref$isEmit = _ref.isEmit,
247
+ isEmit = _ref$isEmit === void 0 ? false : _ref$isEmit,
248
+ _ref$movingStatus = _ref.movingStatus,
249
+ movingStatus = _ref$movingStatus === void 0 ? false : _ref$movingStatus;
250
+ if (childCount <= 1) return;
251
+ var targetActive = getActive(pace); // 父级容器偏移量
252
+
253
+ var targetOffset = getOffset(targetActive, offset); // 如果循环,调整开头结尾图片位置
254
+
255
+ if (props.loop) {
256
+ if (Array.isArray(children) && children[0] && targetOffset !== minOffset) {
257
+ var rightBound = targetOffset < minOffset;
258
+ childsRefs[0].current.changeOffset(rightBound ? trackSize : 0);
259
+ }
260
+
261
+ if (Array.isArray(children) && children[childCount - 1] && targetOffset !== 0) {
262
+ var leftBound = targetOffset > 0;
263
+ childsRefs[childCount - 1].current.changeOffset(leftBound ? -trackSize : 0);
264
+ }
265
+ }
266
+
267
+ if (isEmit && active !== targetActive) {
268
+ props.onChange && props.onChange((targetActive + childCount) % childCount);
269
+ }
270
+
271
+ active = targetActive;
272
+ offset = targetOffset;
273
+ setActive(targetActive);
274
+ setOffset(targetOffset);
275
+ getStyle(targetOffset);
276
+ }; // 确定当前active 元素
277
+
278
+
279
+ var getActive = function getActive(pace) {
280
+ if (pace) {
281
+ var _active = active + pace;
282
+
283
+ if (props.loop) {
284
+ return range(_active, -1, childCount);
285
+ }
286
+
287
+ return range(_active, 0, childCount - 1);
288
+ }
289
+
290
+ return active;
291
+ }; // 计算位移
292
+
293
+
294
+ var getOffset = function getOffset(active) {
295
+ var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
296
+ var currentPosition = active * Number(size);
297
+
298
+ if (!props.loop) {
299
+ currentPosition = Math.min(currentPosition, -minOffset);
300
+ }
301
+
302
+ var targetOffset = offset - currentPosition;
303
+
304
+ if (!props.loop) {
305
+ targetOffset = range(targetOffset, minOffset, 0);
306
+ }
307
+
308
+ return targetOffset;
309
+ }; // 浏览器 帧 事件
310
+
311
+
312
+ var requestFrame = function requestFrame(fn) {
313
+ window.requestAnimationFrame.call(window, fn);
314
+ }; // 取值 方法
315
+
316
+
317
+ var range = function range(num, min, max) {
318
+ return Math.min(Math.max(num, min), max);
319
+ };
320
+
321
+ var getDirection = function getDirection(x, y) {
322
+ if (x > y && x > DISTANCE) return 'horizontal';
323
+ if (y > x && y > DISTANCE) return 'vertical';
324
+ return '';
325
+ }; // 重置 全部位移信息
326
+
327
+
328
+ var touchReset = function touchReset() {
329
+ touch.startX = 0;
330
+ touch.startY = 0;
331
+ touch.deltaX = 0;
332
+ touch.deltaY = 0;
333
+ touch.offsetX = 0;
334
+ touch.offsetY = 0;
335
+ touch.delta = 0;
336
+ touch.stateDirection = '';
337
+ touch.touchTime = 0;
338
+ }; // 触摸事件开始
339
+
340
+
341
+ var touchStart = function touchStart(e) {
342
+ touchReset();
343
+ touch.startX = e.touches[0].clientX;
344
+ touch.startY = e.touches[0].clientY;
345
+ }; // 触摸事件移动
346
+
347
+
348
+ var touchMove = function touchMove(e) {
349
+ touch.deltaX = e.touches[0].clientX - touch.startX;
350
+ touch.deltaY = e.touches[0].clientY - touch.startY;
351
+ touch.offsetX = Math.abs(touch.deltaX);
352
+ touch.offsetY = Math.abs(touch.deltaY);
353
+ touch.delta = isVertical ? touch.deltaY : touch.deltaX;
354
+
355
+ if (!touch.stateDirection) {
356
+ touch.stateDirection = getDirection(touch.offsetX, touch.offsetY);
357
+ }
358
+ };
359
+
360
+ var b = cn('swiper');
361
+ var classes = classNames(b(''));
362
+ var contentClass = classNames((_classNames = {}, _defineProperty(_classNames, "".concat(b('inner')), true), _defineProperty(_classNames, "".concat(b('vertical')), isVertical), _classNames));
363
+
364
+ var getStyle = function getStyle() {
365
+ var moveOffset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : offset;
366
+ var target = innerRef.current;
367
+ target.style.transform = "translate3D".concat(!isVertical ? "(".concat(moveOffset, "px,0,0)") : "(0,".concat(moveOffset, "px,0)"));
368
+ target.style.transitionDuration = "".concat(_swiper.current.moving ? 0 : props.duration, "ms");
369
+ target.style[isVertical ? 'height' : 'width'] = "".concat(Number(size) * childCount, "px");
370
+ target.style[isVertical ? 'width' : 'height'] = "".concat(isVertical ? width : height, "px");
371
+ };
372
+
373
+ var onTouchStart = function onTouchStart(e) {
374
+ if (props.isPreventDefault) e.preventDefault();
375
+ if (props.isStopPropagation) e.stopPropagation();
376
+ if (!props.touchable) return;
377
+ touchStart(e);
378
+ touch.touchTime = Date.now();
379
+ stopAutoPlay();
380
+ resettPosition();
381
+ };
382
+
383
+ var onTouchMove = function onTouchMove(e) {
384
+ if (props.touchable && _swiper.current.moving) {
385
+ touchMove(e);
386
+
387
+ if (touch.stateDirection === props.direction) {
388
+ move({
389
+ offset: touch.delta
390
+ });
391
+ }
392
+ }
393
+ };
394
+
395
+ var onTouchEnd = function onTouchEnd(e) {
396
+ if (!props.touchable || !_swiper.current.moving) return;
397
+ var speed = touch.delta / (Date.now() - touch.touchTime);
398
+ var isShouldMove = Math.abs(speed) > 0.3 || Math.abs(touch.delta) > +(size / 2).toFixed(2);
399
+ var pace = 0;
400
+ _swiper.current.moving = false;
401
+
402
+ if (isShouldMove && touch.stateDirection === props.direction) {
403
+ var _offset = isVertical ? touch.offsetY : touch.offsetX;
404
+
405
+ if (props.loop) {
406
+ pace = _offset > 0 ? touch.delta > 0 ? -1 : 1 : 0;
407
+ } else {
408
+ pace = -Math[touch.delta > 0 ? 'ceil' : 'floor'](touch.delta / size);
409
+ }
410
+
411
+ move({
412
+ pace: pace,
413
+ isEmit: true
414
+ });
415
+ } else if (touch.delta) {
416
+ move({
417
+ pace: 0
418
+ });
419
+ } else {
420
+ getStyle();
421
+ }
422
+
423
+ autoplay();
424
+ };
425
+
426
+ useEffect(function () {
427
+ _swiper.current.activePagination = (active + childCount) % childCount;
428
+ }, [active]);
429
+
430
+ var init = function init() {
431
+ var active = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : +propSwiper.initPage;
432
+ var rect = container.current.getBoundingClientRect();
433
+
434
+ var _active = Math.max(Math.min(childCount - 1, active), 0);
435
+
436
+ var _width = propSwiper.width ? +propSwiper.width : rect.width;
437
+
438
+ var _height = propSwiper.height ? +propSwiper.height : rect.height;
439
+
440
+ size = isVertical ? _height : _width;
441
+ trackSize = childCount * Number(size);
442
+ var targetOffset = getOffset(_active);
443
+ _swiper.current.moving = true;
444
+
445
+ if (ready) {
446
+ _swiper.current.moving = false;
447
+ }
448
+
449
+ setRect(rect);
450
+ setActive(_active);
451
+ setWidth(_width);
452
+ setHeight(_height);
453
+ setOffset(targetOffset);
454
+ setReady(true);
455
+ };
456
+
457
+ useEffect(function () {
458
+ if (ready) {
459
+ getStyle();
460
+ }
461
+ }, [isVertical, width, height, offset, ready]);
462
+ useEffect(function () {
463
+ if (ready) {
464
+ stopAutoPlay();
465
+ autoplay();
466
+ }
467
+
468
+ return function () {
469
+ setReady(false);
470
+ };
471
+ }, [ready]);
472
+ useEffect(function () {
473
+ setChilds(getChildren());
474
+ }, [children]);
475
+ useEffect(function () {
476
+ init();
477
+ }, [propSwiper.initPage]);
478
+ useEffect(function () {
479
+ var target = container.current;
480
+ target.addEventListener('touchstart', onTouchStart, false);
481
+ target.addEventListener('touchmove', onTouchMove, false);
482
+ target.addEventListener('touchend', onTouchEnd, false);
483
+ return function () {
484
+ target.removeEventListener('touchstart', onTouchStart, false);
485
+ target.removeEventListener('touchmove', onTouchMove, false);
486
+ target.removeEventListener('touchend', onTouchEnd, false);
487
+ };
488
+ });
489
+ React__default.useImperativeHandle(ref, function () {
490
+ return {
491
+ to: to,
492
+ next: next,
493
+ prev: prev
494
+ };
495
+ });
496
+ return React__default.createElement(DataContext.Provider, {
497
+ value: parent
498
+ }, React__default.createElement("div", _objectSpread({
499
+ className: "".concat(classes, " ").concat(className),
500
+ ref: container
501
+ }, rest), React__default.createElement("div", {
502
+ className: contentClass,
503
+ ref: innerRef
504
+ }, childs), propSwiper.paginationVisible && !('pageContent' in propSwiper) ? React__default.createElement("div", {
505
+ className: classNames((_classNames2 = {}, _defineProperty(_classNames2, "".concat(b('pagination')), true), _defineProperty(_classNames2, "".concat(b('pagination-vertical')), isVertical), _classNames2))
506
+ }, childs.map(function (item, index) {
507
+ return React__default.createElement("i", {
508
+ style: {
509
+ backgroundColor: (active + childCount) % childCount === index ? propSwiper.paginationColor : '#ddd'
510
+ },
511
+ key: index
512
+ });
513
+ })) : React__default.createElement("div", null, pageContent)));
514
+ });
515
+ Swiper.defaultProps = defaultProps;
516
+ Swiper.displayName = 'NutSwiper';
517
+ export { Swiper as default };
@@ -0,0 +1 @@
1
+ import '../../../packages/swiperitem/swiperitem.scss'
@@ -0,0 +1,64 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+
4
+ 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; }
5
+
6
+ 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; }
7
+
8
+ import React__default, { useContext, useState, useImperativeHandle } from 'react';
9
+ import { D as DataContext } from './UserContext-b4181162.js';
10
+ import { c as cn } from './bem-893ad28d.js';
11
+ import classNames from 'classnames';
12
+ import '@bem-react/classname';
13
+ var defaultProps = {
14
+ direction: 'horizontal'
15
+ };
16
+ var SwiperItem = React__default.forwardRef(function (props, ref) {
17
+ var _props = _objectSpread(_objectSpread({}, defaultProps), props);
18
+
19
+ var children = _props.children,
20
+ direction = _props.direction,
21
+ size = _props.size;
22
+ var parent = useContext(DataContext);
23
+
24
+ var _useState = useState(0),
25
+ _useState2 = _slicedToArray(_useState, 2),
26
+ offset = _useState2[0],
27
+ setOffset = _useState2[1];
28
+
29
+ var b = cn('swiper-item');
30
+ var classes = classNames(b(''));
31
+ useImperativeHandle(ref, function () {
32
+ return {
33
+ changeOffset: function changeOffset(num) {
34
+ setOffset(num);
35
+ }
36
+ };
37
+ });
38
+
39
+ var style = function style() {
40
+ var style = {};
41
+
42
+ var _direction = (parent === null || parent === void 0 ? void 0 : parent.propSwiper.direction) || direction;
43
+
44
+ var _size = (parent === null || parent === void 0 ? void 0 : parent.size) || size;
45
+
46
+ if (_size) {
47
+ style[_direction === 'horizontal' ? 'width' : 'height'] = "".concat(_size, "px");
48
+ }
49
+
50
+ if (offset) {
51
+ style['transform'] = "translate3D".concat(_direction === 'horizontal' ? "(".concat(offset, "px,0,0)") : "(0,".concat(offset, "px,0)"));
52
+ }
53
+
54
+ return style;
55
+ };
56
+
57
+ return React__default.createElement("div", {
58
+ className: classes,
59
+ style: style()
60
+ }, children);
61
+ });
62
+ SwiperItem.defaultProps = defaultProps;
63
+ SwiperItem.displayName = 'NutSwiperItem';
64
+ export { SwiperItem as default };
@@ -0,0 +1 @@
1
+ import '../../../packages/switch/switch.scss'
@@ -0,0 +1,85 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+
4
+ 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; }
5
+
6
+ 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; }
7
+
8
+ import React__default, { useState, useEffect } from 'react';
9
+ import { c as cn } from './bem-893ad28d.js';
10
+ import '@bem-react/classname';
11
+ var defaultProps = {
12
+ isAsync: false,
13
+ checked: false,
14
+ disable: false,
15
+ activeColor: '',
16
+ inactiveColor: '',
17
+ activeText: '',
18
+ inactiveText: '',
19
+ className: ''
20
+ };
21
+
22
+ var Switch = function Switch(props) {
23
+ var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
24
+ isAsync = _defaultProps$props.isAsync,
25
+ checked = _defaultProps$props.checked,
26
+ disable = _defaultProps$props.disable,
27
+ activeColor = _defaultProps$props.activeColor,
28
+ inactiveColor = _defaultProps$props.inactiveColor,
29
+ activeText = _defaultProps$props.activeText,
30
+ inactiveText = _defaultProps$props.inactiveText,
31
+ change = _defaultProps$props.change,
32
+ className = _defaultProps$props.className,
33
+ style = _defaultProps$props.style;
34
+
35
+ var _useState = useState(false),
36
+ _useState2 = _slicedToArray(_useState, 2),
37
+ value = _useState2[0],
38
+ setValue = _useState2[1];
39
+
40
+ var b = cn('switch');
41
+ useEffect(function () {
42
+ setValue(checked);
43
+ }, [checked]);
44
+
45
+ var classes = function classes() {
46
+ return "".concat(b(), " ").concat(value ? 'switch-open' : 'switch-close', " ").concat(disable ? "".concat(b(), "-disable") : '', " ", "".concat(b(), "-base"), " ").concat(className);
47
+ };
48
+
49
+ var styles = function styles() {
50
+ var myStyle = Object.assign({}, {
51
+ backgroundColor: value ? activeColor : inactiveColor
52
+ }, style || {});
53
+ return myStyle;
54
+ };
55
+
56
+ var _onClick = function onClick(event) {
57
+ if (disable) return;
58
+
59
+ if (!isAsync) {
60
+ setValue(!value);
61
+ }
62
+
63
+ change && change(!value, event);
64
+ };
65
+
66
+ return React__default.createElement("div", {
67
+ className: classes(),
68
+ onClick: function onClick(e) {
69
+ return _onClick(e);
70
+ },
71
+ style: styles()
72
+ }, React__default.createElement("div", {
73
+ className: "switch-button"
74
+ }, !value && React__default.createElement("div", {
75
+ className: "close-line"
76
+ }), activeText && React__default.createElement(React__default.Fragment, null, value ? React__default.createElement("div", {
77
+ className: "".concat(b('label'), " open")
78
+ }, activeText) : React__default.createElement("div", {
79
+ className: "".concat(b('label'), " close")
80
+ }, inactiveText))));
81
+ };
82
+
83
+ Switch.defaultProps = defaultProps;
84
+ Switch.displayName = 'NutSwitch';
85
+ export { Switch as default };
@@ -0,0 +1 @@
1
+ import '../../../packages/tabbar/tabbar.scss'
@@ -7,7 +7,6 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
7
7
 
8
8
  import React__default, { useState } from 'react';
9
9
  import { c as cn } from './bem-893ad28d.js';
10
- import TabbarItem from './TabbarItem.js';
11
10
  import '@bem-react/classname';
12
11
  var defaultProps = {
13
12
  visible: 0,
@@ -65,10 +64,8 @@ var Tabbar = function Tabbar(props) {
65
64
 
66
65
  return React__default.cloneElement(child, childProps);
67
66
  }));
68
- }; //@ts-ignore todo...
69
-
67
+ };
70
68
 
71
- Tabbar.TabbarItem = TabbarItem;
72
69
  Tabbar.defaultProps = defaultProps;
73
70
  Tabbar.displayName = 'NutTabbar';
74
71
  export { Tabbar as default };
@@ -0,0 +1 @@
1
+ import '../../../packages/tabbaritem/tabbaritem.scss'