@nutui/nutui-react 1.3.5 → 1.3.6

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 (108) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/esm/ActionSheet.js +15 -25
  3. package/dist/esm/Address.js +151 -221
  4. package/dist/esm/AnimatingNumbers.js +7 -31
  5. package/dist/esm/Audio.js +31 -66
  6. package/dist/esm/Avatar.js +25 -51
  7. package/dist/esm/AvatarGroup.js +2 -9
  8. package/dist/esm/BackTop.js +29 -55
  9. package/dist/esm/Badge.js +9 -20
  10. package/dist/esm/Barrage.js +8 -20
  11. package/dist/esm/Button.js +22 -37
  12. package/dist/esm/Calendar.js +23 -37
  13. package/dist/esm/CalendarItem.js +86 -186
  14. package/dist/esm/Card.js +14 -20
  15. package/dist/esm/Cascader.js +77 -197
  16. package/dist/esm/Cell.js +20 -30
  17. package/dist/esm/CellGroup.js +6 -12
  18. package/dist/esm/Checkbox.js +27 -48
  19. package/dist/esm/CheckboxGroup.js +12 -30
  20. package/dist/esm/CircleProgress.js +11 -28
  21. package/dist/esm/Col.js +11 -22
  22. package/dist/esm/Collapse.js +11 -27
  23. package/dist/esm/CollapseItem.js +33 -47
  24. package/dist/esm/ConfigProvider.js +4 -15
  25. package/dist/esm/CountDown.js +37 -74
  26. package/dist/esm/DatePicker.js +44 -106
  27. package/dist/esm/Dialog.js +31 -89
  28. package/dist/esm/Divider.js +8 -15
  29. package/dist/esm/Drag.js +30 -45
  30. package/dist/esm/Elevator.js +37 -74
  31. package/dist/esm/Empty.js +11 -24
  32. package/dist/esm/FixedNav.js +18 -29
  33. package/dist/esm/Grid.js +13 -28
  34. package/dist/esm/GridItem.js +18 -34
  35. package/dist/esm/ImagePreview.js +36 -71
  36. package/dist/esm/Indicator.js +9 -20
  37. package/dist/esm/Infiniteloading.js +26 -55
  38. package/dist/esm/Input.js +62 -106
  39. package/dist/esm/InputNumber.js +25 -52
  40. package/dist/esm/Layout.js +0 -6
  41. package/dist/esm/Menu.js +24 -46
  42. package/dist/esm/MenuItem.js +29 -52
  43. package/dist/esm/NavBar.js +18 -34
  44. package/dist/esm/NoticeBar.js +54 -102
  45. package/dist/esm/Notify.js +9 -38
  46. package/dist/esm/NumberKeyboard.js +21 -52
  47. package/dist/esm/Pagination.js +38 -71
  48. package/dist/esm/Picker.js +91 -178
  49. package/dist/esm/Popover.js +32 -72
  50. package/dist/esm/Popup.js +40 -72
  51. package/dist/esm/Price.js +7 -24
  52. package/dist/esm/Progress.js +35 -50
  53. package/dist/esm/PullToRefresh.js +28 -83
  54. package/dist/esm/Radio.js +24 -47
  55. package/dist/esm/RadioGroup.js +14 -24
  56. package/dist/esm/Range.js +44 -116
  57. package/dist/esm/Rate.js +21 -39
  58. package/dist/esm/Row.js +7 -16
  59. package/dist/esm/SearchBar.js +47 -68
  60. package/dist/esm/ShortPassword.js +29 -56
  61. package/dist/esm/SideNavBar.js +9 -16
  62. package/dist/esm/SideNavBarItem.js +4 -11
  63. package/dist/esm/Signature.js +13 -43
  64. package/dist/esm/Skeleton.js +13 -23
  65. package/dist/esm/Step.js +12 -28
  66. package/dist/esm/Steps.js +6 -14
  67. package/dist/esm/Sticky.js +24 -52
  68. package/dist/esm/SubSideNavBar.js +7 -22
  69. package/dist/esm/Swipe.js +15 -54
  70. package/dist/esm/Swiper.js +102 -186
  71. package/dist/esm/SwiperItem.js +2 -12
  72. package/dist/esm/Switch.js +13 -27
  73. package/dist/esm/Tabbar.js +13 -25
  74. package/dist/esm/TabbarItem.js +15 -23
  75. package/dist/esm/Table.js +19 -39
  76. package/dist/esm/Tag.js +19 -36
  77. package/dist/esm/TextArea.js +19 -43
  78. package/dist/esm/TimeDetail.js +15 -28
  79. package/dist/esm/TimePannel.js +5 -12
  80. package/dist/esm/TimeSelect.js +35 -59
  81. package/dist/esm/Toast.js +16 -49
  82. package/dist/esm/Uploader.js +57 -152
  83. package/dist/esm/Video.js +8 -19
  84. package/dist/esm/VirtualList.js +84 -118
  85. package/dist/esm/date-710f8c7c.js +9 -33
  86. package/dist/esm/get-scroll-parent-3dcd3f53.js +1 -9
  87. package/dist/esm/icon-8dc4de10.js +11 -21
  88. package/dist/esm/offsetContext-0e3d04b3.js +0 -3
  89. package/dist/esm/overlay-ed3eb37d.js +12 -23
  90. package/dist/esm/render-18227751.js +0 -11
  91. package/dist/esm/tabpane-c957ab14.js +4 -10
  92. package/dist/esm/tabs-0896a61b.js +28 -56
  93. package/dist/esm/types/src/packages/elevator/demo.d.ts +1 -0
  94. package/dist/esm/types/src/packages/searchbar/searchbar.d.ts +2 -0
  95. package/dist/esm/useClientRect-839d18c5.js +0 -5
  96. package/dist/esm/useTouch-a2ea68c6.js +27 -47
  97. package/dist/locales/base.js +1 -1
  98. package/dist/locales/en-US.js +1 -1
  99. package/dist/locales/id-ID.js +1 -1
  100. package/dist/locales/zh-CN.js +1 -1
  101. package/dist/locales/zh-TW.js +1 -1
  102. package/dist/nutui.react.es.js +424 -406
  103. package/dist/nutui.react.umd.js +416 -398
  104. package/dist/packages/searchbar/searchbar.scss +20 -3
  105. package/dist/style.css +1 -1
  106. package/dist/style.es.js +1 -1
  107. package/dist/types/index.d.ts +2 -0
  108. package/package.json +1 -1
@@ -2,19 +2,16 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
4
  var _excluded = ["sourceData", "ItemRender", "itemEqualSize", "itemSize", "horizontal", "overscan", "key", "handleScroll", "className", "containerSize"];
5
-
6
5
  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
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; }
9
-
10
7
  import React__default, { useRef, useState, useEffect, useCallback } from 'react';
11
- import { useConfig } from './ConfigProvider.js'; // 缓存列表初始化信息
8
+ import { useConfig } from './ConfigProvider.js';
12
9
 
10
+ // 缓存列表初始化信息
13
11
  var initPositinoCache = function initPositinoCache(reaItemSize) {
14
12
  var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
15
13
  var index = 0;
16
14
  var positions = Array(length);
17
-
18
15
  while (index < length) {
19
16
  positions[index] = {
20
17
  index: index,
@@ -27,25 +24,20 @@ var initPositinoCache = function initPositinoCache(reaItemSize) {
27
24
  };
28
25
  index++;
29
26
  }
30
-
31
27
  return positions;
32
- }; // 获取列表总高度
33
-
34
-
28
+ };
29
+ // 获取列表总高度
35
30
  var getListTotalSize = function getListTotalSize(positions, horizontal) {
36
31
  var index = positions.length - 1;
37
32
  var size = 0;
38
-
39
33
  if (index < 0) {
40
34
  size = 0;
41
35
  } else {
42
36
  size = horizontal ? positions[index].right : positions[index].bottom;
43
37
  }
44
-
45
38
  return size;
46
- }; // 通过二分法找到 scrollOffset 对应的值
47
-
48
-
39
+ };
40
+ // 通过二分法找到 scrollOffset 对应的值
49
41
  var binarySearch = function binarySearch(positionsList) {
50
42
  var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
51
43
  var horizontal = arguments.length > 2 ? arguments[2] : undefined;
@@ -53,74 +45,63 @@ var binarySearch = function binarySearch(positionsList) {
53
45
  var end = positionsList.length - 1;
54
46
  var tempIndex = null;
55
47
  var key = horizontal ? 'right' : 'bottom';
56
-
57
48
  while (start <= end) {
58
49
  var midIndex = Math.floor((start + end) / 2);
59
- var midValue = positionsList[midIndex][key]; // 相等则直接返回(因为是bottom, 因此startIndex应该是下一个节点)
60
-
50
+ var midValue = positionsList[midIndex][key];
51
+ // 相等则直接返回(因为是bottom, 因此startIndex应该是下一个节点)
61
52
  if (midValue === value) {
62
53
  return midIndex + 1;
63
- } // 中间值 < 传入值,则说明 value对应的节点 大于 start, start往后移动一位
64
-
65
-
54
+ }
55
+ // 中间值 < 传入值,则说明 value对应的节点 大于 start, start往后移动一位
66
56
  if (midValue < value) {
67
57
  start = midIndex + 1;
68
- } // 中间值 > 传入值,则说明 value 在 中间值之前,end 节点移动到 mid - 1
58
+ }
59
+ // 中间值 > 传入值,则说明 value 在 中间值之前,end 节点移动到 mid - 1
69
60
  else if (midValue > value) {
70
61
  // tempIndex存放最靠近值为value的所有
71
62
  if (tempIndex === null || tempIndex > midIndex) {
72
63
  tempIndex = midIndex;
73
64
  }
74
-
75
65
  end = midIndex - 1;
76
66
  }
77
67
  }
78
-
79
68
  tempIndex = tempIndex || 0;
80
69
  return tempIndex;
81
70
  };
82
-
83
71
  var getEndIndex = function getEndIndex(_ref) {
84
72
  var sourceData = _ref.sourceData,
85
- startIndex = _ref.startIndex,
86
- visibleCount = _ref.visibleCount,
87
- _ref$itemEqualSize = _ref.itemEqualSize,
88
- itemEqualSize = _ref$itemEqualSize === void 0 ? true : _ref$itemEqualSize,
89
- positions = _ref.positions,
90
- offSetSize = _ref.offSetSize,
91
- overscan = _ref.overscan,
92
- _ref$sizeKey = _ref.sizeKey,
93
- sizeKey = _ref$sizeKey === void 0 ? 'width' : _ref$sizeKey;
73
+ startIndex = _ref.startIndex,
74
+ visibleCount = _ref.visibleCount,
75
+ _ref$itemEqualSize = _ref.itemEqualSize,
76
+ itemEqualSize = _ref$itemEqualSize === void 0 ? true : _ref$itemEqualSize,
77
+ positions = _ref.positions,
78
+ offSetSize = _ref.offSetSize,
79
+ overscan = _ref.overscan,
80
+ _ref$sizeKey = _ref.sizeKey,
81
+ sizeKey = _ref$sizeKey === void 0 ? 'width' : _ref$sizeKey;
94
82
  var dataLength = sourceData.length;
95
83
  var tempIndex = null;
96
-
97
84
  if (itemEqualSize) {
98
85
  var endIndex = startIndex + visibleCount;
99
86
  tempIndex = dataLength > 0 ? Math.min(dataLength, endIndex) : endIndex;
100
87
  } else {
101
88
  var sizeNum = 0;
102
-
103
89
  for (var i = startIndex; i < dataLength; i++) {
104
90
  sizeNum += positions[i][sizeKey] || 0;
105
-
106
91
  if (sizeNum > offSetSize) {
107
92
  var _endIndex = i + overscan;
108
-
109
93
  tempIndex = dataLength > 0 ? Math.min(dataLength, _endIndex) : _endIndex;
110
94
  break;
111
95
  }
112
96
  }
113
-
114
97
  if (sizeNum < offSetSize) {
115
98
  tempIndex = dataLength;
116
99
  }
117
100
  }
118
-
119
101
  tempIndex = tempIndex || 0;
120
102
  return tempIndex;
121
- }; // 更新Item大小
122
-
123
-
103
+ };
104
+ // 更新Item大小
124
105
  var updateItemSize = function updateItemSize(positions, items, sizeKey) {
125
106
  var newPos = positions.concat();
126
107
  Array.from(items).forEach(function (item) {
@@ -128,15 +109,13 @@ var updateItemSize = function updateItemSize(positions, items, sizeKey) {
128
109
  var styleVal = item.getAttribute('style');
129
110
  if (styleVal && styleVal.includes('none')) return;
130
111
  var nowSize = item.getBoundingClientRect()[sizeKey];
131
- var oldSize = positions[index][sizeKey]; // 存在差值, 更新该节点以后所有的节点
132
-
112
+ var oldSize = positions[index][sizeKey];
113
+ // 存在差值, 更新该节点以后所有的节点
133
114
  var dValue = oldSize - nowSize;
134
-
135
115
  if (dValue) {
136
116
  if (sizeKey === 'width') {
137
117
  newPos[index].right -= dValue;
138
118
  newPos[index][sizeKey] = nowSize;
139
-
140
119
  for (var k = index + 1; k < positions.length; k++) {
141
120
  newPos[k].left = positions[k - 1].right;
142
121
  newPos[k].right -= dValue;
@@ -144,7 +123,6 @@ var updateItemSize = function updateItemSize(positions, items, sizeKey) {
144
123
  } else if (sizeKey === 'height') {
145
124
  newPos[index].bottom -= dValue;
146
125
  newPos[index][sizeKey] = nowSize;
147
-
148
126
  for (var _k = index + 1; _k < positions.length; _k++) {
149
127
  newPos[_k].top = positions[_k - 1].bottom;
150
128
  newPos[_k].bottom -= dValue;
@@ -153,79 +131,70 @@ var updateItemSize = function updateItemSize(positions, items, sizeKey) {
153
131
  }
154
132
  });
155
133
  };
156
-
157
134
  var defaultProps = {};
158
-
159
135
  var VirtualList = function VirtualList(props) {
160
136
  var _props$sourceData = props.sourceData,
161
- sourceData = _props$sourceData === void 0 ? [] : _props$sourceData,
162
- ItemRender = props.ItemRender,
163
- _props$itemEqualSize = props.itemEqualSize,
164
- itemEqualSize = _props$itemEqualSize === void 0 ? true : _props$itemEqualSize,
165
- _props$itemSize = props.itemSize,
166
- itemSize = _props$itemSize === void 0 ? 200 : _props$itemSize,
167
- _props$horizontal = props.horizontal,
168
- horizontal = _props$horizontal === void 0 ? false : _props$horizontal,
169
- _props$overscan = props.overscan,
170
- overscan = _props$overscan === void 0 ? 2 : _props$overscan,
171
- key = props.key,
172
- handleScroll = props.handleScroll,
173
- className = props.className,
174
- containerSize = props.containerSize,
175
- rest = _objectWithoutProperties(props, _excluded);
176
-
137
+ sourceData = _props$sourceData === void 0 ? [] : _props$sourceData,
138
+ ItemRender = props.ItemRender,
139
+ _props$itemEqualSize = props.itemEqualSize,
140
+ itemEqualSize = _props$itemEqualSize === void 0 ? true : _props$itemEqualSize,
141
+ _props$itemSize = props.itemSize,
142
+ itemSize = _props$itemSize === void 0 ? 200 : _props$itemSize,
143
+ _props$horizontal = props.horizontal,
144
+ horizontal = _props$horizontal === void 0 ? false : _props$horizontal,
145
+ _props$overscan = props.overscan,
146
+ overscan = _props$overscan === void 0 ? 2 : _props$overscan,
147
+ key = props.key,
148
+ handleScroll = props.handleScroll,
149
+ className = props.className,
150
+ containerSize = props.containerSize,
151
+ rest = _objectWithoutProperties(props, _excluded);
177
152
  var sizeKey = horizontal ? 'width' : 'height';
178
153
  var scrollKey = horizontal ? 'scrollLeft' : 'scrollTop';
179
154
  var offsetKey = horizontal ? 'left' : 'top';
180
- useConfig(); // 虚拟列表容器ref
181
-
182
- var scrollRef = useRef(null); // 虚拟列表显示区域ref
183
-
155
+ useConfig();
156
+ // 虚拟列表容器ref
157
+ var scrollRef = useRef(null);
158
+ // 虚拟列表显示区域ref
184
159
  var itemsRef = useRef(null);
185
- var firstItemRef = useRef(null); // 列表位置信息
186
-
160
+ var firstItemRef = useRef(null);
161
+ // 列表位置信息
187
162
  var _useState = useState([{
188
- index: 0,
189
- left: 0,
190
- top: 0,
191
- bottom: 0,
192
- width: 0,
193
- height: 0,
194
- right: 0
195
- }]),
196
- _useState2 = _slicedToArray(_useState, 2),
197
- positions = _useState2[0],
198
- setPositions = _useState2[1]; // 列表总大小
199
-
200
-
163
+ index: 0,
164
+ left: 0,
165
+ top: 0,
166
+ bottom: 0,
167
+ width: 0,
168
+ height: 0,
169
+ right: 0
170
+ }]),
171
+ _useState2 = _slicedToArray(_useState, 2),
172
+ positions = _useState2[0],
173
+ setPositions = _useState2[1];
174
+ // 列表总大小
201
175
  var _useState3 = useState(99999999),
202
- _useState4 = _slicedToArray(_useState3, 2),
203
- listTotalSize = _useState4[0],
204
- setListTotalSize = _useState4[1]; // 可视区域条数
205
-
206
-
176
+ _useState4 = _slicedToArray(_useState3, 2),
177
+ listTotalSize = _useState4[0],
178
+ setListTotalSize = _useState4[1];
179
+ // 可视区域条数
207
180
  var _useState5 = useState(0),
208
- _useState6 = _slicedToArray(_useState5, 2),
209
- visibleCount = _useState6[0],
210
- setVisibleCount = _useState6[1];
211
-
181
+ _useState6 = _slicedToArray(_useState5, 2),
182
+ visibleCount = _useState6[0],
183
+ setVisibleCount = _useState6[1];
212
184
  var _useState7 = useState(containerSize || 0),
213
- _useState8 = _slicedToArray(_useState7, 2),
214
- offSetSize = _useState8[0],
215
- setOffSetSize = _useState8[1];
216
-
185
+ _useState8 = _slicedToArray(_useState7, 2),
186
+ offSetSize = _useState8[0],
187
+ setOffSetSize = _useState8[1];
217
188
  var _useState9 = useState({
218
- startOffset: 0,
219
- startIndex: 0,
220
- overStart: 0,
221
- endIndex: 10 // 可视区域结束索引
222
-
223
- }),
224
- _useState10 = _slicedToArray(_useState9, 2),
225
- options = _useState10[0],
226
- setOptions = _useState10[1]; // 列表位置信息
227
-
228
-
189
+ startOffset: 0,
190
+ startIndex: 0,
191
+ overStart: 0,
192
+ endIndex: 10 // 可视区域结束索引
193
+ }),
194
+ _useState10 = _slicedToArray(_useState9, 2),
195
+ options = _useState10[0],
196
+ setOptions = _useState10[1];
197
+ // 列表位置信息
229
198
  useEffect(function () {
230
199
  var pos = initPositinoCache(itemSize, sourceData.length);
231
200
  setPositions(pos);
@@ -234,7 +203,6 @@ var VirtualList = function VirtualList(props) {
234
203
  }, [sourceData, itemSize, horizontal]);
235
204
  var getElement = useCallback(function () {
236
205
  var _scrollRef$current;
237
-
238
206
  return ((_scrollRef$current = scrollRef.current) === null || _scrollRef$current === void 0 ? void 0 : _scrollRef$current.parentElement) || document.body;
239
207
  }, []);
240
208
  useEffect(function () {
@@ -256,8 +224,8 @@ var VirtualList = function VirtualList(props) {
256
224
  var updateTotalSize = useCallback(function () {
257
225
  if (!itemsRef.current) return;
258
226
  var items = itemsRef.current.children;
259
- if (!items.length) return; // 更新缓存
260
-
227
+ if (!items.length) return;
228
+ // 更新缓存
261
229
  updateItemSize(positions, items, sizeKey);
262
230
  var totalSize = getListTotalSize(positions, horizontal);
263
231
  setListTotalSize(totalSize);
@@ -266,12 +234,11 @@ var VirtualList = function VirtualList(props) {
266
234
  requestAnimationFrame(function (e) {
267
235
  var scrollSize = getElement()[scrollKey];
268
236
  var startIndex = binarySearch(positions, scrollSize, horizontal);
269
- var overStart = startIndex - overscan > -1 ? startIndex - overscan : 0; // const offSetSize = horizontal ? getElement().offsetWidth : getElement().offsetHeight
270
-
237
+ var overStart = startIndex - overscan > -1 ? startIndex - overscan : 0;
238
+ // const offSetSize = horizontal ? getElement().offsetWidth : getElement().offsetHeight
271
239
  if (!itemEqualSize) {
272
240
  updateTotalSize();
273
241
  }
274
-
275
242
  var endIndex = getEndIndex({
276
243
  sourceData: sourceData,
277
244
  startIndex: startIndex,
@@ -288,8 +255,8 @@ var VirtualList = function VirtualList(props) {
288
255
  startIndex: startIndex,
289
256
  overStart: overStart,
290
257
  endIndex: endIndex
291
- }); // 无限下滑
292
-
258
+ });
259
+ // 无限下滑
293
260
  if (endIndex > sourceData.length - 1) {
294
261
  handleScroll && handleScroll();
295
262
  }
@@ -320,7 +287,7 @@ var VirtualList = function VirtualList(props) {
320
287
  }
321
288
  }, sourceData.slice(options.overStart, options.endIndex).map(function (data, index) {
322
289
  var startIndex = options.startIndex,
323
- overStart = options.overStart;
290
+ overStart = options.overStart;
324
291
  var dataIndex = overStart + index;
325
292
  var styleVal = dataIndex < startIndex ? 'none' : 'block';
326
293
  var keyVal = key && data[key] ? data[key] : dataIndex;
@@ -338,7 +305,6 @@ var VirtualList = function VirtualList(props) {
338
305
  }) : data);
339
306
  }))));
340
307
  };
341
-
342
308
  VirtualList.defaultProps = defaultProps;
343
309
  VirtualList.displayName = 'NutVirtualList';
344
310
  export { VirtualList as default };
@@ -2,110 +2,86 @@ var Utils = {
2
2
  /**
3
3
  * 是否为闫年
4
4
  * @return {Boolse} true|false
5
- */
6
- isLeapYear: function isLeapYear(y) {
5
+ */isLeapYear: function isLeapYear(y) {
7
6
  return y % 4 == 0 && y % 100 != 0 || y % 400 == 0;
8
7
  },
9
-
10
8
  /**
11
9
  * 返回星期数
12
10
  * @return {String}
13
- */
14
- getWhatDay: function getWhatDay(year, month, day) {
11
+ */getWhatDay: function getWhatDay(year, month, day) {
15
12
  var date = new Date("".concat(year, "/").concat(month, "/").concat(day));
16
13
  var index = date.getDay();
17
14
  var dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
18
15
  return dayNames[index];
19
16
  },
20
-
21
17
  /**
22
18
  * 返回星期数
23
19
  * @return {Number}
24
- */
25
- getMonthPreDay: function getMonthPreDay(year, month) {
20
+ */getMonthPreDay: function getMonthPreDay(year, month) {
26
21
  var date = new Date("".concat(year, "/").concat(month, "/01"));
27
22
  var day = date.getDay();
28
-
29
23
  if (day == 0) {
30
24
  day = 7;
31
25
  }
32
-
33
26
  return day;
34
27
  },
35
-
36
28
  /**
37
29
  * 返回月份天数
38
30
  * @return {Number}
39
- */
40
- getMonthDays: function getMonthDays(year, month) {
31
+ */getMonthDays: function getMonthDays(year, month) {
41
32
  if (/^0/.test(month)) {
42
33
  month = month.split('')[1];
43
34
  }
44
-
45
35
  return [0, 31, this.isLeapYear(Number(year)) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
46
36
  },
47
-
48
37
  /**
49
38
  * 补齐数字位数
50
39
  * @return {string}
51
- */
52
- getNumTwoBit: function getNumTwoBit(n) {
40
+ */getNumTwoBit: function getNumTwoBit(n) {
53
41
  n = Number(n);
54
42
  return (n > 9 ? '' : '0') + n;
55
43
  },
56
-
57
44
  /**
58
45
  * 日期对象转成字符串
59
46
  * @return {string}
60
- */
61
- date2Str: function date2Str(date, split) {
47
+ */date2Str: function date2Str(date, split) {
62
48
  split = split || '-';
63
49
  var y = date.getFullYear();
64
50
  var m = this.getNumTwoBit(date.getMonth() + 1);
65
51
  var d = this.getNumTwoBit(date.getDate());
66
52
  return [y, m, d].join(split);
67
53
  },
68
-
69
54
  /**
70
55
  * 返回日期格式字符串
71
56
  * @param {Number} 0返回今天的日期、1返回明天的日期,2返回后天得日期,依次类推
72
57
  * @return {string} '2014-12-31'
73
- */
74
- getDay: function getDay(i) {
58
+ */getDay: function getDay(i) {
75
59
  i = i || 0;
76
60
  var date = new Date();
77
61
  var diff = i * (1000 * 60 * 60 * 24);
78
62
  date = new Date(date.getTime() + diff);
79
63
  return this.date2Str(date);
80
64
  },
81
-
82
65
  /**
83
66
  * 时间比较
84
67
  * @return {Boolean}
85
- */
86
- compareDate: function compareDate(date1, date2) {
68
+ */compareDate: function compareDate(date1, date2) {
87
69
  var startTime = new Date(date1.replace('-', '/').replace('-', '/'));
88
70
  var endTime = new Date(date2.replace('-', '/').replace('-', '/'));
89
-
90
71
  if (startTime >= endTime) {
91
72
  return false;
92
73
  }
93
-
94
74
  return true;
95
75
  },
96
-
97
76
  /**
98
77
  * 时间是否相等
99
78
  * @return {Boolean}
100
- */
101
- isEqual: function isEqual(date1, date2) {
79
+ */isEqual: function isEqual(date1, date2) {
102
80
  var startTime = new Date(date1).getTime();
103
81
  var endTime = new Date(date2).getTime();
104
-
105
82
  if (startTime == endTime) {
106
83
  return true;
107
84
  }
108
-
109
85
  return false;
110
86
  }
111
87
  };
@@ -1,32 +1,24 @@
1
1
  var canUseDom = !!(typeof window !== 'undefined' && typeof document !== 'undefined' && window.document && window.document.createElement);
2
2
  var defaultRoot = canUseDom ? window : undefined;
3
3
  var overflowStylePatterns = ['scroll', 'auto', 'overlay'];
4
-
5
4
  function isElement(node) {
6
5
  var ELEMENT_NODE_TYPE = 1;
7
6
  return node.nodeType === ELEMENT_NODE_TYPE;
8
7
  }
9
-
10
8
  function getScrollParent(el) {
11
9
  var root = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultRoot;
12
10
  var node = el;
13
-
14
11
  while (node && node !== root && isElement(node)) {
15
12
  if (node === document.body) {
16
13
  return root;
17
14
  }
18
-
19
15
  var _window$getComputedSt = window.getComputedStyle(node),
20
- overflowY = _window$getComputedSt.overflowY;
21
-
16
+ overflowY = _window$getComputedSt.overflowY;
22
17
  if (overflowStylePatterns.includes(overflowY) && node.scrollHeight > node.clientHeight) {
23
18
  return node;
24
19
  }
25
-
26
20
  node = node.parentNode;
27
21
  }
28
-
29
22
  return root;
30
23
  }
31
-
32
24
  export { canUseDom as c, getScrollParent as g };
@@ -1,11 +1,8 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  var _excluded = ["name", "size", "classPrefix", "color", "tag", "children", "className", "fontClassName", "style", "onClick"];
4
-
5
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; }
6
-
7
5
  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
-
9
6
  import React__default from 'react';
10
7
  import { c as cn } from './bem-893ad28d.js';
11
8
  var defaultProps = {
@@ -18,42 +15,36 @@ var defaultProps = {
18
15
  onClick: function onClick(e) {},
19
16
  className: ''
20
17
  };
21
-
22
18
  function pxCheck(value) {
23
19
  return Number.isNaN(Number(value)) ? String(value) : "".concat(value, "px");
24
20
  }
25
-
26
21
  function Icon(props) {
27
22
  var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
28
- name = _defaultProps$props.name,
29
- size = _defaultProps$props.size,
30
- classPrefix = _defaultProps$props.classPrefix,
31
- color = _defaultProps$props.color,
32
- tag = _defaultProps$props.tag,
33
- children = _defaultProps$props.children,
34
- className = _defaultProps$props.className,
35
- fontClassName = _defaultProps$props.fontClassName,
36
- style = _defaultProps$props.style,
37
- onClick = _defaultProps$props.onClick,
38
- rest = _objectWithoutProperties(_defaultProps$props, _excluded);
39
-
23
+ name = _defaultProps$props.name,
24
+ size = _defaultProps$props.size,
25
+ classPrefix = _defaultProps$props.classPrefix,
26
+ color = _defaultProps$props.color,
27
+ tag = _defaultProps$props.tag,
28
+ children = _defaultProps$props.children,
29
+ className = _defaultProps$props.className,
30
+ fontClassName = _defaultProps$props.fontClassName,
31
+ style = _defaultProps$props.style,
32
+ onClick = _defaultProps$props.onClick,
33
+ rest = _objectWithoutProperties(_defaultProps$props, _excluded);
40
34
  var isImage = name ? name.indexOf('/') !== -1 : false;
41
35
  var type = isImage ? 'img' : tag;
42
36
  var b = cn('icon');
43
-
44
37
  var handleClick = function handleClick(e) {
45
38
  if (onClick) {
46
39
  onClick(e);
47
40
  }
48
41
  };
49
-
50
42
  var hasSrc = function hasSrc() {
51
43
  if (isImage) return {
52
44
  src: name
53
45
  };
54
46
  return {};
55
47
  };
56
-
57
48
  return React__default.createElement(type, _objectSpread(_objectSpread({
58
49
  className: isImage ? "".concat(b('img'), " ").concat(className || '', " ") : "".concat(fontClassName, " ").concat(b(null), " ").concat(classPrefix, "-").concat(name, " ").concat(className || ''),
59
50
  style: _objectSpread({
@@ -66,7 +57,6 @@ function Icon(props) {
66
57
  onClick: handleClick
67
58
  }, hasSrc()), children);
68
59
  }
69
-
70
60
  Icon.defaultProps = defaultProps;
71
61
  Icon.displayName = 'NutIcon';
72
62
  export { Icon as I };
@@ -1,5 +1,4 @@
1
1
  import { createContext } from 'react';
2
-
3
2
  var handleClick = function handleClick(e) {
4
3
  e.stopPropagation();
5
4
  var isIcon = e.target.className.includes('arrow-icon');
@@ -8,12 +7,10 @@ var handleClick = function handleClick(e) {
8
7
  var isShow = currentClass.includes('nutShow');
9
8
  var arrowIcon = e.currentTarget.querySelector('.arrow-icon');
10
9
  var iconClass = arrowIcon.className;
11
-
12
10
  if (isTitle) {
13
11
  e.currentTarget.className = isShow ? currentClass.replace('nutShow', 'nutHide') : currentClass.replace('nutHide', 'nutShow');
14
12
  arrowIcon.className = isShow ? iconClass.replace('arrow-down', 'arrow-up') : iconClass.replace('arrow-up', 'arrow-down');
15
13
  }
16
14
  };
17
-
18
15
  var OffsetContext = createContext(20);
19
16
  export { OffsetContext as O, handleClick as h };