@nutui/nutui-react-taro 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 (125) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/esm/Audio.js +4 -4
  3. package/dist/esm/Calendar.js +4 -4
  4. package/dist/esm/CalendarItem.js +3 -3
  5. package/dist/esm/DatePicker.js +4 -4
  6. package/dist/esm/Drag.js +3 -4
  7. package/dist/esm/Elevator.js +2 -4
  8. package/dist/esm/NoticeBar.js +3 -3
  9. package/dist/esm/Picker.js +3 -3
  10. package/dist/esm/Popover.js +3 -3
  11. package/dist/esm/Range.js +3 -3
  12. package/dist/esm/SearchBar.js +3 -2
  13. package/dist/esm/Signature.js +3 -2
  14. package/dist/esm/Swipe.js +3 -3
  15. package/dist/esm/actionsheet.taro-360d8d34.js +15 -25
  16. package/dist/esm/address.taro-f16cef31.js +151 -219
  17. package/dist/esm/animatingnumbers.taro-6f40a2e9.js +13 -41
  18. package/dist/esm/{audio.taro-29f5568f.js → audio.taro-57d4f0da.js} +33 -60
  19. package/dist/esm/avatar.taro-ec620cdd.js +25 -50
  20. package/dist/esm/avatargroup-5b2584d9.js +2 -9
  21. package/dist/esm/backtop.taro-aa8b2bc5.js +29 -55
  22. package/dist/esm/badge.taro-38684262.js +9 -20
  23. package/dist/esm/barrage.taro-d86c367a.js +8 -21
  24. package/dist/esm/button.taro-a9ebb937.js +22 -37
  25. package/dist/esm/{calendar.taro-438940bd.js → calendar.taro-533b3219.js} +13 -24
  26. package/dist/esm/{calendaritem.taro-11333579.js → calendaritem.taro-fe5dd4bd.js} +71 -183
  27. package/dist/esm/card.taro-1bc35ebe.js +14 -20
  28. package/dist/esm/cascader.taro-77100fb4.js +77 -197
  29. package/dist/esm/cell.taro-a4c3bb7b.js +20 -30
  30. package/dist/esm/cellgroup.taro-8c87bf08.js +6 -12
  31. package/dist/esm/checkbox.taro-104557c1.js +27 -48
  32. package/dist/esm/checkboxgroup.taro-3d380042.js +12 -30
  33. package/dist/esm/circleprogress.taro-3c89a157.js +14 -41
  34. package/dist/esm/col.taro-2a437387.js +11 -22
  35. package/dist/esm/collapse.taro-72e58ba2.js +11 -27
  36. package/dist/esm/collapseitem-75843a5e.js +33 -47
  37. package/dist/esm/configprovider-3e87d67a.js +2 -6
  38. package/dist/esm/configprovider.taro-6c7b3056.js +4 -14
  39. package/dist/esm/countdown.taro-f2d9ffed.js +37 -74
  40. package/dist/esm/{datepicker.taro-1acec61f.js → datepicker.taro-49a4cf0c.js} +43 -104
  41. package/dist/esm/dialog.taro-492e2b9a.js +27 -58
  42. package/dist/esm/divider.taro-5236fe6a.js +8 -15
  43. package/dist/esm/drag.taro-0717c783.js +153 -0
  44. package/dist/esm/{elevator.taro-8e385785.js → elevator.taro-443253ec.js} +99 -124
  45. package/dist/esm/empty.taro-ab9c4f03.js +11 -24
  46. package/dist/esm/fixednav.taro-582322a1.js +16 -27
  47. package/dist/esm/grid.taro-5d75c0ad.js +13 -28
  48. package/dist/esm/griditem.taro-866cd288.js +18 -34
  49. package/dist/esm/icon-8dc4de10.js +11 -21
  50. package/dist/esm/icon.taro-1d0d4fb7.js +11 -21
  51. package/dist/esm/imagepreview.taro-1199e977.js +36 -71
  52. package/dist/esm/indicator.taro-183ea169.js +9 -20
  53. package/dist/esm/infiniteloading.taro-b95e62bf.js +23 -49
  54. package/dist/esm/input.taro-2453d7c4.js +62 -106
  55. package/dist/esm/inputnumber.taro-0cf7c1b7.js +25 -52
  56. package/dist/esm/layout.taro-358f014f.js +0 -6
  57. package/dist/esm/menu.taro-9345dcfd.js +21 -41
  58. package/dist/esm/menuitem.taro-fc0961b7.js +29 -54
  59. package/dist/esm/navbar.taro-c931c078.js +18 -34
  60. package/dist/esm/{noticebar.taro-1fa04a96.js → noticebar.taro-332691f9.js} +55 -107
  61. package/dist/esm/notify.taro-d9c48fae.js +18 -34
  62. package/dist/esm/numberkeyboard.taro-53c350b8.js +21 -52
  63. package/dist/esm/nutui-react.es.js +16 -16
  64. package/dist/esm/offsetContext-0e3d04b3.js +0 -3
  65. package/dist/esm/overlay.taro-be45fed5.js +12 -23
  66. package/dist/esm/pagination.taro-62bbd23f.js +38 -71
  67. package/dist/esm/{picker.taro-6a4dad23.js → picker.taro-f003b725.js} +95 -186
  68. package/dist/esm/{popover.taro-eddd0bd2.js → popover.taro-7e5dff8c.js} +33 -76
  69. package/dist/esm/popup.taro-33d0bbc8.js +40 -72
  70. package/dist/esm/price.taro-97393d8f.js +7 -24
  71. package/dist/esm/progress.taro-623bc807.js +23 -31
  72. package/dist/esm/pulltorefresh.taro-e66c78ad.js +29 -92
  73. package/dist/esm/radio.taro-95d43860.js +24 -47
  74. package/dist/esm/radiogroup.taro-b5dad516.js +14 -24
  75. package/dist/esm/{range.taro-515d37a4.js → range.taro-fc7c0b6a.js} +50 -133
  76. package/dist/esm/rate.taro-69c85081.js +21 -39
  77. package/dist/esm/row.taro-cec13a7e.js +7 -16
  78. package/dist/esm/{searchbar.taro-f134fb96.js → searchbar.taro-0d3c0081.js} +55 -70
  79. package/dist/esm/shortpassword.taro-2e96ca22.js +29 -56
  80. package/dist/esm/sidenavbar.taro-87f056cd.js +9 -16
  81. package/dist/esm/sidenavbaritem.taro-77e077f4.js +4 -11
  82. package/dist/esm/signature.taro-59b3b3ab.js +146 -0
  83. package/dist/esm/skeleton.taro-b9ff84b9.js +13 -23
  84. package/dist/esm/step.taro-f1057500.js +12 -28
  85. package/dist/esm/steps.taro-943f4fbb.js +6 -14
  86. package/dist/esm/sticky.taro-30d4e453.js +0 -7
  87. package/dist/esm/subsidenavbar.taro-2c1fcf16.js +7 -22
  88. package/dist/esm/{swipe.taro-dfb9a049.js → swipe.taro-83bc248f.js} +98 -91
  89. package/dist/esm/swiper.taro-f314d67a.js +110 -196
  90. package/dist/esm/swiperitem-d00e7513.js +2 -12
  91. package/dist/esm/switch.taro-be5eb823.js +13 -27
  92. package/dist/esm/tabbar.taro-da72fa2c.js +13 -25
  93. package/dist/esm/tabbaritem.taro-94cd62c2.js +15 -23
  94. package/dist/esm/table.taro-7ac89a6c.js +19 -39
  95. package/dist/esm/tabpane.taro-95aa185b.js +4 -10
  96. package/dist/esm/tabs.taro-86186dff.js +28 -54
  97. package/dist/esm/tag.taro-95d7f5c2.js +19 -36
  98. package/dist/esm/textarea.taro-388d1f90.js +18 -35
  99. package/dist/esm/timedetail.taro-519808cf.js +15 -28
  100. package/dist/esm/timepannel.taro-9904f6e6.js +5 -12
  101. package/dist/esm/timeselect.taro-73796bfc.js +35 -59
  102. package/dist/esm/toast.taro-86862dff.js +26 -46
  103. package/dist/esm/types/src/packages/elevator/demo.d.ts +1 -0
  104. package/dist/esm/types/src/packages/searchbar/searchbar.d.ts +2 -0
  105. package/dist/esm/types/src/packages/searchbar/searchbar.taro.d.ts +2 -0
  106. package/dist/esm/types/src/packages/signature/signature.taro.d.ts +10 -2
  107. package/dist/esm/uploader.taro-6184abe7.js +52 -144
  108. package/dist/esm/{useClientRect-8b7cc406.js → useClientRect-bf69d7b3.js} +1 -40
  109. package/dist/esm/useTouch-a2ea68c6.js +27 -47
  110. package/dist/esm/video-c1090c92.js +8 -19
  111. package/dist/esm/virtuallist.taro-6858f690.js +84 -118
  112. package/dist/locales/base.js +1 -1
  113. package/dist/locales/en-US.js +1 -1
  114. package/dist/locales/id-ID.js +1 -1
  115. package/dist/locales/zh-CN.js +1 -1
  116. package/dist/locales/zh-TW.js +1 -1
  117. package/dist/nutui.react.es.js +10844 -11362
  118. package/dist/nutui.react.umd.js +10844 -11362
  119. package/dist/packages/searchbar/searchbar.scss +20 -3
  120. package/dist/style.css +1 -1
  121. package/dist/style.es.js +1 -1
  122. package/dist/types/index.d.ts +17 -8
  123. package/package.json +1 -1
  124. package/dist/esm/drag.taro-56e8c87a.js +0 -134
  125. package/dist/esm/signature.taro-a9286cd1.js +0 -178
@@ -16,7 +16,7 @@ export { N as NavBar } from './navbar.taro-c931c078.js';
16
16
  export { F as FixedNav } from './fixednav.taro-582322a1.js';
17
17
  export { T as Tabbar } from './tabbar.taro-da72fa2c.js';
18
18
  export { T as TabbarItem } from './tabbaritem.taro-94cd62c2.js';
19
- export { E as Elevator } from './elevator.taro-8e385785.js';
19
+ export { E as Elevator } from './elevator.taro-443253ec.js';
20
20
  export { P as Pagination } from './pagination.taro-62bbd23f.js';
21
21
  export { T as Tabs } from './tabs.taro-86186dff.js';
22
22
  export { T as TabPane } from './tabpane.taro-95aa185b.js';
@@ -26,36 +26,36 @@ export { S as SubSideNavBar } from './subsidenavbar.taro-2c1fcf16.js';
26
26
  export { S as SideNavBarItem } from './sidenavbaritem.taro-77e077f4.js';
27
27
  export { M as Menu } from './menu.taro-9345dcfd.js';
28
28
  export { M as MenuItem } from './menuitem.taro-fc0961b7.js';
29
- export { R as Range } from './range.taro-515d37a4.js';
30
- export { C as Calendar } from './calendar.taro-438940bd.js';
29
+ export { R as Range } from './range.taro-fc7c0b6a.js';
30
+ export { C as Calendar } from './calendar.taro-533b3219.js';
31
31
  export { C as Checkbox } from './checkbox.taro-104557c1.js';
32
32
  export { C as CheckboxGroup } from './checkboxgroup.taro-3d380042.js';
33
- export { D as DatePicker } from './datepicker.taro-1acec61f.js';
33
+ export { D as DatePicker } from './datepicker.taro-49a4cf0c.js';
34
34
  export { I as InputNumber } from './inputnumber.taro-0cf7c1b7.js';
35
35
  export { I as Input } from './input.taro-2453d7c4.js';
36
36
  export { R as Radio } from './radio.taro-95d43860.js';
37
37
  export { R as RadioGroup } from './radiogroup.taro-b5dad516.js';
38
38
  export { R as Rate } from './rate.taro-69c85081.js';
39
- export { C as CalendarItem } from './calendaritem.taro-11333579.js';
40
- export { P as Picker } from './picker.taro-6a4dad23.js';
39
+ export { C as CalendarItem } from './calendaritem.taro-fe5dd4bd.js';
40
+ export { P as Picker } from './picker.taro-f003b725.js';
41
41
  export { S as ShortPassword } from './shortpassword.taro-2e96ca22.js';
42
42
  export { T as TextArea } from './textarea.taro-388d1f90.js';
43
43
  export { U as Uploader } from './uploader.taro-6184abe7.js';
44
44
  export { C as Cascader } from './cascader.taro-77100fb4.js';
45
- export { S as SearchBar } from './searchbar.taro-f134fb96.js';
45
+ export { S as SearchBar } from './searchbar.taro-0d3c0081.js';
46
46
  export { N as NumberKeyboard } from './numberkeyboard.taro-53c350b8.js';
47
47
  export { A as ActionSheet } from './actionsheet.taro-360d8d34.js';
48
48
  export { B as BackTop } from './backtop.taro-aa8b2bc5.js';
49
- export { D as Drag } from './drag.taro-56e8c87a.js';
49
+ export { D as Drag } from './drag.taro-0717c783.js';
50
50
  export { D as Dialog } from './dialog.taro-492e2b9a.js';
51
51
  export { I as Infiniteloading } from './infiniteloading.taro-b95e62bf.js';
52
52
  export { N as Notify } from './notify.taro-d9c48fae.js';
53
53
  export { S as Switch } from './switch.taro-be5eb823.js';
54
54
  export { T as Toast } from './toast.taro-86862dff.js';
55
- export { S as Swipe } from './swipe.taro-dfb9a049.js';
55
+ export { S as Swipe } from './swipe.taro-83bc248f.js';
56
56
  export { P as PullToRefresh } from './pulltorefresh.taro-e66c78ad.js';
57
57
  export { C as CircleProgress } from './circleprogress.taro-3c89a157.js';
58
- export { N as NoticeBar } from './noticebar.taro-1fa04a96.js';
58
+ export { N as NoticeBar } from './noticebar.taro-332691f9.js';
59
59
  export { S as Steps } from './steps.taro-943f4fbb.js';
60
60
  export { S as Step } from './step.taro-f1057500.js';
61
61
  export { S as Swiper } from './swiper.taro-f314d67a.js';
@@ -65,7 +65,7 @@ export { A as AvatarGroup } from './avatargroup-5b2584d9.js';
65
65
  export { P as Price } from './price.taro-97393d8f.js';
66
66
  export { B as Badge } from './badge.taro-38684262.js';
67
67
  export { T as Tag } from './tag.taro-95d7f5c2.js';
68
- export { P as Popover } from './popover.taro-eddd0bd2.js';
68
+ export { P as Popover } from './popover.taro-7e5dff8c.js';
69
69
  export { S as Skeleton } from './skeleton.taro-b9ff84b9.js';
70
70
  export { C as CountDown } from './countdown.taro-f2d9ffed.js';
71
71
  export { C as Collapse } from './collapse.taro-72e58ba2.js';
@@ -76,11 +76,11 @@ export { V as VirtualList } from './virtuallist.taro-6858f690.js';
76
76
  export { T as Table } from './table.taro-7ac89a6c.js';
77
77
  export { V as Video } from './video-c1090c92.js';
78
78
  export { P as Progress } from './progress.taro-623bc807.js';
79
- export { A as Audio } from './audio.taro-29f5568f.js';
79
+ export { A as Audio } from './audio.taro-57d4f0da.js';
80
80
  export { I as ImagePreview } from './imagepreview.taro-1199e977.js';
81
81
  export { A as Address } from './address.taro-f16cef31.js';
82
82
  export { B as Barrage } from './barrage.taro-d86c367a.js';
83
- export { S as Signature } from './signature.taro-a9286cd1.js';
83
+ export { S as Signature } from './signature.taro-59b3b3ab.js';
84
84
  export { C as Card } from './card.taro-1bc35ebe.js';
85
85
  export { T as TimePannel } from './timepannel.taro-9904f6e6.js';
86
86
  export { T as TimeDetail } from './timedetail.taro-519808cf.js';
@@ -97,13 +97,13 @@ import 'react-transition-group';
97
97
  import './zh-CN-14165629.js';
98
98
  import './UserContext-be8097d2.js';
99
99
  import './configprovider-3e87d67a.js';
100
- import '@use-gesture/react';
101
- import '@react-spring/web';
102
100
  import './offsetContext-0e3d04b3.js';
103
101
  import './useTouch-a2ea68c6.js';
104
- import './useClientRect-8b7cc406.js';
102
+ import './useClientRect-bf69d7b3.js';
105
103
  import './icon-8dc4de10.js';
106
104
  import '@tarojs/components';
105
+ import '@use-gesture/react';
106
+ import '@react-spring/web';
107
107
  import './UserContext-68f62e66.js';
108
108
  import './UserContext-b4181162.js';
109
109
  import './AvatarContext-7153ad2b.js';
@@ -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 };
@@ -2,11 +2,8 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
4
  var _excluded = ["children", "zIndex", "duration", "overlayClass", "closeOnClickOverlay", "visible", "lockScroll", "overlayStyle"];
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, { useState, useRef, useEffect } from 'react';
11
8
  import classNames from 'classnames';
12
9
  import { c as cn } from './bem-893ad28d.js';
@@ -19,24 +16,21 @@ var defaultOverlayProps = {
19
16
  lockScroll: true,
20
17
  overlayStyle: {}
21
18
  };
22
-
23
19
  var Overlay = function Overlay(props) {
24
20
  var _defaultOverlayProps$ = _objectSpread(_objectSpread({}, defaultOverlayProps), props),
25
- children = _defaultOverlayProps$.children,
26
- zIndex = _defaultOverlayProps$.zIndex,
27
- duration = _defaultOverlayProps$.duration,
28
- overlayClass = _defaultOverlayProps$.overlayClass,
29
- closeOnClickOverlay = _defaultOverlayProps$.closeOnClickOverlay,
30
- visible = _defaultOverlayProps$.visible,
31
- lockScroll = _defaultOverlayProps$.lockScroll,
32
- overlayStyle = _defaultOverlayProps$.overlayStyle,
33
- rest = _objectWithoutProperties(_defaultOverlayProps$, _excluded);
34
-
21
+ children = _defaultOverlayProps$.children,
22
+ zIndex = _defaultOverlayProps$.zIndex,
23
+ duration = _defaultOverlayProps$.duration,
24
+ overlayClass = _defaultOverlayProps$.overlayClass,
25
+ closeOnClickOverlay = _defaultOverlayProps$.closeOnClickOverlay,
26
+ visible = _defaultOverlayProps$.visible,
27
+ lockScroll = _defaultOverlayProps$.lockScroll,
28
+ overlayStyle = _defaultOverlayProps$.overlayStyle,
29
+ rest = _objectWithoutProperties(_defaultOverlayProps$, _excluded);
35
30
  var _useState = useState(visible),
36
- _useState2 = _slicedToArray(_useState, 2),
37
- show = _useState2[0],
38
- setShow = _useState2[1];
39
-
31
+ _useState2 = _slicedToArray(_useState, 2),
32
+ show = _useState2[0],
33
+ setShow = _useState2[1];
40
34
  var renderRef = useRef(true);
41
35
  var intervalRef = useRef(0);
42
36
  useEffect(function () {
@@ -56,12 +50,10 @@ var Overlay = function Overlay(props) {
56
50
  'first-render': renderRef.current && !visible,
57
51
  'hidden-render': !visible
58
52
  }, overlayClass, b(''));
59
-
60
53
  var styles = _objectSpread({
61
54
  zIndex: zIndex,
62
55
  animationDuration: "".concat(props.duration, "s")
63
56
  }, overlayStyle);
64
-
65
57
  var lock = function lock() {
66
58
  if (lockScroll && visible) {
67
59
  document.body.classList.add('nut-overflow-hidden');
@@ -69,7 +61,6 @@ var Overlay = function Overlay(props) {
69
61
  document.body.classList.remove('nut-overflow-hidden');
70
62
  }
71
63
  };
72
-
73
64
  var handleClick = function handleClick(e) {
74
65
  if (closeOnClickOverlay) {
75
66
  props.onClick && props.onClick(e);
@@ -80,7 +71,6 @@ var Overlay = function Overlay(props) {
80
71
  intervalRef.current = id;
81
72
  }
82
73
  };
83
-
84
74
  return React__default.createElement(React__default.Fragment, null, React__default.createElement("div", _objectSpread(_objectSpread({
85
75
  className: classes,
86
76
  style: styles
@@ -88,7 +78,6 @@ var Overlay = function Overlay(props) {
88
78
  onClick: handleClick
89
79
  }), children));
90
80
  };
91
-
92
81
  Overlay.defaultProps = defaultOverlayProps;
93
82
  Overlay.displayName = 'NutOverlay';
94
83
  export { Overlay as O, defaultOverlayProps as d };
@@ -2,11 +2,8 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
  var _excluded = ["modelValue", "mode", "prevText", "nextText", "pageCount", "totalItems", "itemsPerPage", "showPageSize", "onChange", "updatecurrent", "forceEllipses", "pageNodeRender", "defaultValue", "className"];
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, { useState, useEffect } from 'react';
11
8
  import { u as useConfig } from './configprovider.taro-6c7b3056.js';
12
9
  import { c as cn } from './bem-893ad28d.js';
@@ -25,119 +22,96 @@ var defaultProps = {
25
22
  return item.text;
26
23
  }
27
24
  };
28
-
29
25
  var Pagination = function Pagination(props) {
30
26
  var _useConfig = useConfig(),
31
- locale = _useConfig.locale;
32
-
27
+ locale = _useConfig.locale;
33
28
  _objectSpread(_objectSpread({}, defaultProps), props);
34
-
35
29
  var modelValue = props.modelValue,
36
- mode = props.mode,
37
- prevText = props.prevText,
38
- nextText = props.nextText,
39
- pageCount = props.pageCount,
40
- totalItems = props.totalItems,
41
- itemsPerPage = props.itemsPerPage,
42
- showPageSize = props.showPageSize,
43
- onChange = props.onChange,
44
- updatecurrent = props.updatecurrent,
45
- forceEllipses = props.forceEllipses,
46
- pageNodeRender = props.pageNodeRender,
47
- defaultValue = props.defaultValue,
48
- className = props.className,
49
- rest = _objectWithoutProperties(props, _excluded);
50
-
30
+ mode = props.mode,
31
+ prevText = props.prevText,
32
+ nextText = props.nextText,
33
+ pageCount = props.pageCount,
34
+ totalItems = props.totalItems,
35
+ itemsPerPage = props.itemsPerPage,
36
+ showPageSize = props.showPageSize,
37
+ onChange = props.onChange,
38
+ updatecurrent = props.updatecurrent,
39
+ forceEllipses = props.forceEllipses,
40
+ pageNodeRender = props.pageNodeRender,
41
+ defaultValue = props.defaultValue,
42
+ className = props.className,
43
+ rest = _objectWithoutProperties(props, _excluded);
51
44
  var _useState = useState(1),
52
- _useState2 = _slicedToArray(_useState, 2),
53
- currentPage = _useState2[0],
54
- setCurrent = _useState2[1];
55
-
45
+ _useState2 = _slicedToArray(_useState, 2),
46
+ currentPage = _useState2[0],
47
+ setCurrent = _useState2[1];
56
48
  var _useState3 = useState([]),
57
- _useState4 = _slicedToArray(_useState3, 2),
58
- pages = _useState4[0],
59
- setPages = _useState4[1];
60
-
49
+ _useState4 = _slicedToArray(_useState3, 2),
50
+ pages = _useState4[0],
51
+ setPages = _useState4[1];
61
52
  var _useState5 = useState(Number(pageCount)),
62
- _useState6 = _slicedToArray(_useState5, 2),
63
- countRef = _useState6[0],
64
- setCountRef = _useState6[1];
65
-
66
- var paginationBem = cn('pagination'); // 计算页面的数量
67
-
53
+ _useState6 = _slicedToArray(_useState5, 2),
54
+ countRef = _useState6[0],
55
+ setCountRef = _useState6[1];
56
+ var paginationBem = cn('pagination');
57
+ // 计算页面的数量
68
58
  var computedCountRef = function computedCountRef() {
69
59
  var num = Number(pageCount) || Math.ceil(Number(totalItems) / Number(itemsPerPage));
70
60
  return Number.isNaN(num) ? 1 : Math.max(1, num);
71
- }; // 生成pages数组,用来遍历
72
-
73
-
61
+ };
62
+ // 生成pages数组,用来遍历
74
63
  var computedPages = function computedPages(_currentPage, _countRef) {
75
64
  if (mode === 'simple') return [];
76
65
  var items = [];
77
66
  var pageCount = _countRef || countRef; // 总的页面数量
78
-
79
67
  var pageSize = Number(showPageSize); // 展示的页面个数
80
-
81
68
  var _current = _currentPage || Number(currentPage); // 当前页
82
-
83
-
84
69
  var startPage = 1;
85
70
  var endPage = pageCount;
86
71
  var partialShow = pageCount > pageSize;
87
-
88
72
  if (partialShow) {
89
73
  // 选中的page在展示的page中间
90
74
  startPage = Math.max(_current - Math.floor(pageSize / 2), 1);
91
75
  endPage = startPage + pageSize - 1;
92
-
93
76
  if (endPage > pageCount) {
94
77
  endPage = pageCount;
95
78
  startPage = endPage - pageSize + 1;
96
79
  }
97
- } // 遍历生成数组
98
-
99
-
80
+ }
81
+ // 遍历生成数组
100
82
  for (var i = startPage; i <= endPage; i++) {
101
83
  var page = setPage(i, i, _current === i);
102
84
  items.push(page);
103
- } // 判断是否有折叠
104
-
105
-
85
+ }
86
+ // 判断是否有折叠
106
87
  if (partialShow && pageSize > 0 && forceEllipses) {
107
88
  if (startPage > 1) {
108
89
  var prevPage = setPage(startPage - 1, '...');
109
90
  items.unshift(prevPage);
110
91
  }
111
-
112
92
  if (endPage < pageCount) {
113
93
  var nextPage = setPage(endPage + 1, '...');
114
94
  items.push(nextPage);
115
95
  }
116
96
  }
117
-
118
97
  return items;
119
- }; // 点击选择page
120
-
121
-
98
+ };
99
+ // 点击选择page
122
100
  var selectPage = function selectPage(curPage, isSelect) {
123
- if (curPage > countRef || curPage < 1) return; // 是否传入modelValue
124
-
101
+ if (curPage > countRef || curPage < 1) return;
102
+ // 是否传入modelValue
125
103
  if (!('modelValue' in props)) {
126
104
  setCurrent(Number(curPage));
127
-
128
105
  if (curPage !== currentPage) {
129
106
  setPages(computedPages(curPage));
130
107
  }
131
108
  }
132
-
133
109
  if (curPage !== currentPage) {
134
110
  updatecurrent && updatecurrent(curPage);
135
111
  }
136
-
137
112
  if (isSelect) onChange && onChange(curPage);
138
- }; // set page 对象
139
-
140
-
113
+ };
114
+ // set page 对象
141
115
  var setPage = function setPage(number, text, active) {
142
116
  return {
143
117
  number: number,
@@ -145,29 +119,23 @@ var Pagination = function Pagination(props) {
145
119
  active: active
146
120
  };
147
121
  };
148
-
149
122
  useEffect(function () {
150
123
  // 初始化 判断是否传入值 计算 当前页,总页数,生成子节点
151
124
  var currentValue = props.defaultValue || 1;
152
-
153
125
  if ('modelValue' in props) {
154
126
  currentValue = Number(props.modelValue);
155
127
  }
156
-
157
128
  var pageCount = computedCountRef();
158
129
  setCountRef(pageCount);
159
130
  setPages(computedPages(currentValue, pageCount));
160
131
  }, []);
161
-
162
132
  if ('modelValue' in props) {
163
133
  var current = props.modelValue ? Number(props.modelValue) : 1;
164
-
165
134
  if (current !== currentPage) {
166
135
  setCurrent(current);
167
136
  setPages(computedPages(Number(current)));
168
137
  }
169
138
  }
170
-
171
139
  return React__default.createElement("div", _objectSpread({
172
140
  className: "".concat(paginationBem(''), " ").concat(className)
173
141
  }, rest), React__default.createElement("div", {
@@ -196,7 +164,6 @@ var Pagination = function Pagination(props) {
196
164
  }
197
165
  }, nextText || locale.pagination.next));
198
166
  };
199
-
200
167
  Pagination.defaultProps = defaultProps;
201
168
  Pagination.displayName = 'NutPagination';
202
169
  export { Pagination as P };