@nutui/nutui-react 1.5.1 → 2.0.0-alpha.0

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 (234) hide show
  1. package/CHANGELOG.md +1 -35
  2. package/dist/esm/ActionSheet.js +62 -54
  3. package/dist/esm/Address/style/index.js +0 -1
  4. package/dist/esm/Address.js +235 -330
  5. package/dist/esm/Animate.js +43 -32
  6. package/dist/esm/AnimatingNumbers.js +88 -49
  7. package/dist/esm/Audio/style/index.js +0 -1
  8. package/dist/esm/Audio.js +104 -114
  9. package/dist/esm/Avatar.js +65 -78
  10. package/dist/esm/AvatarContext.js +5 -0
  11. package/dist/esm/AvatarGroup.js +46 -27
  12. package/dist/esm/BackTop/style/index.js +1 -1
  13. package/dist/esm/BackTop.js +74 -76
  14. package/dist/esm/Badge.js +57 -54
  15. package/dist/esm/Barrage.js +45 -32
  16. package/dist/esm/Button/style/index.js +1 -1
  17. package/dist/esm/Button.js +66 -87
  18. package/dist/esm/Calendar.js +80 -79
  19. package/dist/esm/CalendarItem.js +199 -231
  20. package/dist/esm/Card.js +44 -37
  21. package/dist/esm/Cascader.js +430 -433
  22. package/dist/esm/Cell/style/index.js +1 -1
  23. package/dist/esm/Cell.js +57 -87
  24. package/dist/esm/CellGroup.js +7 -5
  25. package/dist/esm/Checkbox/style/index.js +0 -1
  26. package/dist/esm/Checkbox.js +11 -8
  27. package/dist/esm/CheckboxGroup.js +78 -71
  28. package/dist/esm/CircleProgress.js +50 -40
  29. package/dist/esm/Col.js +46 -41
  30. package/dist/esm/Collapse.js +44 -44
  31. package/dist/esm/CollapseItem/style/index.js +1 -1
  32. package/dist/esm/CollapseItem.js +64 -104
  33. package/dist/esm/ConfigProvider.js +400 -101
  34. package/dist/esm/CountDown.js +90 -95
  35. package/dist/esm/DatePicker.js +104 -123
  36. package/dist/esm/Dialog.js +98 -104
  37. package/dist/esm/Divider.js +36 -27
  38. package/dist/esm/Drag.js +55 -59
  39. package/dist/esm/Elevator.js +77 -88
  40. package/dist/esm/Ellipsis.js +80 -79
  41. package/dist/esm/Empty.js +50 -44
  42. package/dist/esm/FixedNav/style/index.js +0 -1
  43. package/dist/esm/FixedNav.js +57 -65
  44. package/dist/esm/Form.js +1154 -123
  45. package/dist/esm/FormItem.js +7 -5
  46. package/dist/esm/Grid/style/index.js +1 -1
  47. package/dist/esm/Grid.js +51 -55
  48. package/dist/esm/GridItem.js +7 -124
  49. package/dist/esm/Icon.js +83 -5
  50. package/dist/esm/Image.js +123 -122
  51. package/dist/esm/ImagePreview.js +75 -93
  52. package/dist/esm/Indicator.js +41 -36
  53. package/dist/esm/Infiniteloading/style/index.js +1 -1
  54. package/dist/esm/Infiniteloading.js +77 -93
  55. package/dist/esm/Input/style/index.js +1 -1
  56. package/dist/esm/Input.js +120 -172
  57. package/dist/esm/InputNumber/style/index.js +1 -1
  58. package/dist/esm/InputNumber.js +133 -167
  59. package/dist/esm/Layout.js +27 -6
  60. package/dist/esm/Menu.js +84 -86
  61. package/dist/esm/MenuItem/style/index.js +0 -1
  62. package/dist/esm/MenuItem.js +76 -86
  63. package/dist/esm/NavBar/style/index.js +1 -1
  64. package/dist/esm/NavBar.js +59 -63
  65. package/dist/esm/NoticeBar/style/index.js +1 -1
  66. package/dist/esm/NoticeBar.js +173 -290
  67. package/dist/esm/Notify.js +112 -78
  68. package/dist/esm/NumberKeyboard.js +110 -109
  69. package/dist/esm/Overlay.js +7 -6
  70. package/dist/esm/Pagination.js +94 -135
  71. package/dist/esm/Picker.js +149 -201
  72. package/dist/esm/Popover/style/index.js +0 -1
  73. package/dist/esm/Popover.js +121 -116
  74. package/dist/esm/Popup/style/index.js +0 -1
  75. package/dist/esm/Popup.js +109 -119
  76. package/dist/esm/Price.js +51 -39
  77. package/dist/esm/Progress/style/index.js +1 -1
  78. package/dist/esm/Progress.js +59 -64
  79. package/dist/esm/PullToRefresh.js +173 -149
  80. package/dist/esm/Radio/style/index.js +0 -1
  81. package/dist/esm/Radio.js +8 -6
  82. package/dist/esm/RadioGroup.js +64 -84
  83. package/dist/esm/Range.js +93 -122
  84. package/dist/esm/Rate/style/index.js +1 -1
  85. package/dist/esm/Rate.js +77 -95
  86. package/dist/esm/Row.js +46 -35
  87. package/dist/esm/SearchBar/style/index.js +1 -1
  88. package/dist/esm/SearchBar.js +110 -120
  89. package/dist/esm/ShortPassword/style/index.js +0 -1
  90. package/dist/esm/ShortPassword.js +120 -116
  91. package/dist/esm/SideNavBar.js +39 -27
  92. package/dist/esm/SideNavBarItem.js +31 -14
  93. package/dist/esm/Signature.js +65 -61
  94. package/dist/esm/Skeleton.js +48 -40
  95. package/dist/esm/Step/style/index.js +1 -1
  96. package/dist/esm/Step.js +49 -49
  97. package/dist/esm/Steps.js +37 -23
  98. package/dist/esm/Sticky.js +111 -120
  99. package/dist/esm/SubSideNavBar.js +50 -38
  100. package/dist/esm/Swipe.js +75 -63
  101. package/dist/esm/Swiper.js +171 -206
  102. package/dist/esm/SwiperItem.js +39 -22
  103. package/dist/esm/Switch.js +46 -37
  104. package/dist/esm/TabPane.js +8 -6
  105. package/dist/esm/Tabbar.js +47 -39
  106. package/dist/esm/TabbarItem/style/index.js +1 -1
  107. package/dist/esm/TabbarItem.js +50 -52
  108. package/dist/esm/Table/style/index.js +1 -1
  109. package/dist/esm/Table.js +70 -70
  110. package/dist/esm/Tabs/style/index.js +1 -2
  111. package/dist/esm/Tabs.js +11 -9
  112. package/dist/esm/Tag/style/index.js +1 -1
  113. package/dist/esm/Tag.js +69 -70
  114. package/dist/esm/TextArea.js +70 -64
  115. package/dist/esm/TimeDetail.js +47 -38
  116. package/dist/esm/TimePannel.js +35 -19
  117. package/dist/esm/TimeSelect.js +60 -68
  118. package/dist/esm/Toast/style/index.js +1 -1
  119. package/dist/esm/Toast.js +126 -98
  120. package/dist/esm/TrendArrow/style/index.js +1 -1
  121. package/dist/esm/TrendArrow.js +59 -55
  122. package/dist/esm/Uploader/style/index.js +0 -1
  123. package/dist/esm/Uploader.js +180 -229
  124. package/dist/esm/UserContext.js +5 -0
  125. package/dist/esm/UserContext2.js +5 -0
  126. package/dist/esm/UserContext3.js +5 -0
  127. package/dist/esm/Video.js +49 -39
  128. package/dist/esm/VirtualList.js +111 -146
  129. package/dist/esm/WaterMark.js +57 -60
  130. package/dist/esm/bem.js +10 -0
  131. package/dist/esm/cellgroup2.js +49 -0
  132. package/dist/esm/checkbox2.js +145 -0
  133. package/dist/esm/{date-c7aad4c0.js → date.js} +13 -11
  134. package/dist/esm/{formitem-8a73a5fb.js → formitem2.js} +83 -50
  135. package/dist/esm/get-scroll-parent.js +26 -0
  136. package/dist/esm/griditem2.js +96 -0
  137. package/dist/esm/index.js +14 -0
  138. package/dist/esm/nutui-react.es.js +188 -94
  139. package/dist/esm/offsetContext.js +19 -0
  140. package/dist/esm/overlay2.js +98 -0
  141. package/dist/esm/px-check.js +6 -0
  142. package/dist/esm/radio2.js +129 -0
  143. package/dist/esm/render.js +95 -0
  144. package/dist/esm/tabpane2.js +44 -0
  145. package/dist/esm/tabs2.js +175 -0
  146. package/dist/esm/typings.js +7 -0
  147. package/dist/esm/use-client-rect.js +32 -0
  148. package/dist/esm/use-props-value.js +18 -0
  149. package/dist/esm/use-touch.js +74 -0
  150. package/dist/locales/base.d.ts +2 -2
  151. package/dist/locales/base.js +1 -1
  152. package/dist/locales/en-US.js +3 -3
  153. package/dist/locales/id-ID.js +3 -3
  154. package/dist/locales/zh-CN.js +3 -3
  155. package/dist/locales/zh-TW.js +3 -3
  156. package/dist/locales/zh-UG.js +3 -3
  157. package/dist/nutui.react.mjs +8327 -4829
  158. package/dist/nutui.react.umd.js +8328 -4830
  159. package/dist/packages/actionsheet/actionsheet.scss +10 -2
  160. package/dist/packages/backtop/backtop.scss +0 -8
  161. package/dist/packages/badge/badge.scss +3 -4
  162. package/dist/packages/button/button.scss +80 -93
  163. package/dist/packages/cell/cell.scss +18 -90
  164. package/dist/packages/cellgroup/cellgroup.scss +26 -20
  165. package/dist/packages/collapseitem/collapseitem.scss +0 -1
  166. package/dist/packages/dialog/dialog.scss +1 -1
  167. package/dist/packages/divider/divider.scss +3 -17
  168. package/dist/packages/grid/grid.scss +1 -0
  169. package/dist/packages/griditem/griditem.scss +2 -17
  170. package/dist/packages/icon/icon.scss +0 -132
  171. package/dist/packages/image/image.scss +0 -12
  172. package/dist/packages/indicator/indicator.scss +21 -39
  173. package/dist/packages/infiniteloading/infiniteloading.scss +4 -12
  174. package/dist/packages/input/input.scss +4 -0
  175. package/dist/packages/inputnumber/inputnumber.scss +10 -26
  176. package/dist/packages/menuitem/menuitem.scss +2 -0
  177. package/dist/packages/navbar/navbar.scss +4 -5
  178. package/dist/packages/overlay/overlay.scss +0 -19
  179. package/dist/packages/picker/picker.scss +97 -103
  180. package/dist/packages/progress/progress.scss +0 -1
  181. package/dist/packages/radio/radio.scss +8 -0
  182. package/dist/packages/rate/rate.scss +29 -6
  183. package/dist/packages/searchbar/searchbar.scss +0 -1
  184. package/dist/packages/shortpassword/shortpassword.scss +4 -1
  185. package/dist/packages/step/step.scss +0 -1
  186. package/dist/packages/sticky/sticky.scss +1 -1
  187. package/dist/packages/swiper/swiper.scss +8 -0
  188. package/dist/packages/tabbaritem/tabbaritem.scss +0 -1
  189. package/dist/packages/table/table.scss +0 -1
  190. package/dist/packages/tag/tag.scss +9 -2
  191. package/dist/packages/timedetail/timedetail.scss +9 -3
  192. package/dist/packages/timeselect/timeselect.scss +1 -1
  193. package/dist/packages/toast/toast.scss +0 -1
  194. package/dist/style.css +1 -1
  195. package/dist/style.mjs +1 -1
  196. package/dist/styles/font-jmapp/config.json +175 -0
  197. package/dist/styles/font-jmapp/demo.css +539 -0
  198. package/dist/styles/font-jmapp/demo_index.html +1821 -0
  199. package/dist/styles/font-jmapp/iconfont.css +299 -0
  200. package/dist/styles/font-jmapp/iconfont.eot +0 -0
  201. package/dist/styles/font-jmapp/iconfont.js +68 -0
  202. package/dist/styles/font-jmapp/iconfont.json +506 -0
  203. package/dist/styles/font-jmapp/iconfont.svg +356 -0
  204. package/dist/styles/font-jmapp/iconfont.ttf +0 -0
  205. package/dist/styles/font-jmapp/iconfont.woff +0 -0
  206. package/dist/styles/font-jmapp/iconfont.woff2 +0 -0
  207. package/dist/styles/theme-default.scss +1 -0
  208. package/dist/styles/theme-jmapp.scss +41 -0
  209. package/dist/styles/themes/default.scss +0 -1
  210. package/dist/styles/variables-jmapp.scss +2601 -0
  211. package/dist/styles/variables.scss +49 -73
  212. package/dist/types/index.d.ts +147 -240
  213. package/package.json +23 -154
  214. package/dist/esm/AvatarContext-15733596.js +0 -3
  215. package/dist/esm/Icon/style/index.js +0 -4
  216. package/dist/esm/UserContext-101ad4a4.js +0 -3
  217. package/dist/esm/UserContext-2629d479.js +0 -3
  218. package/dist/esm/UserContext-b33bcf21.js +0 -3
  219. package/dist/esm/bem-3b438e61.js +0 -8
  220. package/dist/esm/cellgroup-fcc72767.js +0 -34
  221. package/dist/esm/checkbox-44e13cd0.js +0 -137
  222. package/dist/esm/get-scroll-parent-5f85dee8.js +0 -24
  223. package/dist/esm/grid.context-2ee27d95.js +0 -6
  224. package/dist/esm/icon-4ef1581c.js +0 -70
  225. package/dist/esm/index-030b7245.js +0 -11
  226. package/dist/esm/offsetContext-3ab00d40.js +0 -16
  227. package/dist/esm/overlay-de6c79d5.js +0 -83
  228. package/dist/esm/radio-9f141e6b.js +0 -118
  229. package/dist/esm/render-bbebb760.js +0 -79
  230. package/dist/esm/tabpane-01075e6c.js +0 -29
  231. package/dist/esm/tabs-e1b4e4b1.js +0 -181
  232. package/dist/esm/typings-f27b58f4.js +0 -8
  233. package/dist/esm/useClientRect-56bb675b.js +0 -39
  234. package/dist/esm/useTouch-cf73a407.js +0 -99
@@ -2,94 +2,82 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
4
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
5
- var _excluded = ["isVisible", "title", "listData", "defaultValueData", "onConfirm", "onClose", "onCloseUpdate", "onChange", "className", "style", "threeDimensional", "swipeDuration"];
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, { useState, useRef, useEffect, useImperativeHandle } from 'react';
9
- import Popup from './Popup.js';
10
- import { u as useTouch } from './useTouch-cf73a407.js';
11
- import { useConfig } from './ConfigProvider.js';
12
- import { c as cn } from './bem-3b438e61.js';
13
- import '@bem-react/classname';
14
- var InternalPickerSlot = function InternalPickerSlot(props, ref) {
15
- var _props$keyIndex = props.keyIndex,
16
- keyIndex = _props$keyIndex === void 0 ? 0 : _props$keyIndex,
17
- defaultValue = props.defaultValue,
18
- _props$listData = props.listData,
19
- listData = _props$listData === void 0 ? [] : _props$listData,
20
- _props$threeDimension = props.threeDimensional,
21
- threeDimensional = _props$threeDimension === void 0 ? true : _props$threeDimension,
22
- _props$swipeDuration = props.swipeDuration,
23
- swipeDuration = _props$swipeDuration === void 0 ? 1000 : _props$swipeDuration,
24
- chooseItem = props.chooseItem;
5
+ var _excluded = ["visible", "title", "listData", "defaultValueData", "onConfirm", "onClose", "onCloseUpdate", "onChange", "className", "style", "threeDimensional", "swipeDuration"];
6
+ function ownKeys(object, enumerableOnly) {
7
+ var keys = Object.keys(object);
8
+ if (Object.getOwnPropertySymbols) {
9
+ var symbols = Object.getOwnPropertySymbols(object);
10
+ enumerableOnly && (symbols = symbols.filter(function(sym) {
11
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
12
+ })), keys.push.apply(keys, symbols);
13
+ }
14
+ return keys;
15
+ }
16
+ function _objectSpread(target) {
17
+ for (var i = 1; i < arguments.length; i++) {
18
+ var source = null != arguments[i] ? arguments[i] : {};
19
+ i % 2 ? ownKeys(Object(source), true).forEach(function(key) {
20
+ _defineProperty(target, key, source[key]);
21
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
22
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
23
+ });
24
+ }
25
+ return target;
26
+ }
27
+ import React__default, { useState, useRef, useEffect, useImperativeHandle } from "react";
28
+ import Popup from "./Popup.js";
29
+ import { u as useTouch } from "./use-touch.js";
30
+ import { useConfig } from "./ConfigProvider.js";
31
+ import { c as cn } from "./bem.js";
32
+ import "@bem-react/classname";
33
+ var InternalPickerSlot = function InternalPickerSlot2(props, ref) {
34
+ var _props$keyIndex = props.keyIndex, keyIndex = _props$keyIndex === void 0 ? 0 : _props$keyIndex, defaultValue = props.defaultValue, _props$listData = props.listData, listData = _props$listData === void 0 ? [] : _props$listData, _props$threeDimension = props.threeDimensional, threeDimensional = _props$threeDimension === void 0 ? true : _props$threeDimension, _props$swipeDuration = props.swipeDuration, swipeDuration = _props$swipeDuration === void 0 ? 1e3 : _props$swipeDuration, chooseItem = props.chooseItem;
25
35
  var touch = useTouch();
26
36
  var DEFAULT_DURATION = 200;
27
- // 触发惯性滑动条件:
28
- // 在手指离开屏幕时,如果和上一次 move 时的间隔小于 `MOMENTUM_TIME` 且 move
29
- // 距离大于 `MOMENTUM_DISTANCE` 时,执行惯性滑动
30
37
  var INERTIA_TIME = 300;
31
38
  var INERTIA_DISTANCE = 15;
32
- var _useState = useState(1),
33
- _useState2 = _slicedToArray(_useState, 2),
34
- currIndex = _useState2[0],
35
- setCurrIndex = _useState2[1];
39
+ var _useState = useState(1), _useState2 = _slicedToArray(_useState, 2), currIndex = _useState2[0], setCurrIndex = _useState2[1];
36
40
  var lineSpacing = 36;
37
- var _useState3 = useState(0),
38
- _useState4 = _slicedToArray(_useState3, 2),
39
- touchTime = _useState4[0],
40
- setTouchTime = _useState4[1];
41
- var _useState5 = useState('0deg'),
42
- _useState6 = _slicedToArray(_useState5, 2),
43
- touchDeg = _useState6[0],
44
- setTouchDeg = _useState6[1];
41
+ var _useState3 = useState(0), _useState4 = _slicedToArray(_useState3, 2), touchTime = _useState4[0], setTouchTime = _useState4[1];
42
+ var _useState5 = useState("0deg"), _useState6 = _slicedToArray(_useState5, 2), touchDeg = _useState6[0], setTouchDeg = _useState6[1];
45
43
  var rotation = 20;
46
44
  var moving = useRef(false);
47
45
  var timer;
46
+ useRef(null);
48
47
  var rollerRef = useRef(null);
49
48
  var pickerSlotRef = useRef(null);
50
- var _useState7 = useState(0),
51
- _useState8 = _slicedToArray(_useState7, 2),
52
- startTime = _useState8[0],
53
- setStartTime = _useState8[1];
54
- var _useState9 = useState(0),
55
- _useState10 = _slicedToArray(_useState9, 2),
56
- startY = _useState10[0],
57
- setStartY = _useState10[1];
49
+ var _useState7 = useState(0), _useState8 = _slicedToArray(_useState7, 2), startTime = _useState8[0], setStartTime = _useState8[1];
50
+ var _useState9 = useState(0), _useState10 = _slicedToArray(_useState9, 2), startY = _useState10[0], setStartY = _useState10[1];
58
51
  var transformY = useRef(0);
59
- var _useState11 = useState(0),
60
- _useState12 = _slicedToArray(_useState11, 2),
61
- scrollDistance = _useState12[0],
62
- setScrollDistance = _useState12[1];
63
- var isHidden = function isHidden(index) {
52
+ var _useState11 = useState(0), _useState12 = _slicedToArray(_useState11, 2), scrollDistance = _useState12[0], setScrollDistance = _useState12[1];
53
+ var isHidden = function isHidden2(index) {
64
54
  if (index >= currIndex + 8 || index <= currIndex - 8) {
65
55
  return true;
66
56
  }
67
57
  return false;
68
58
  };
69
- var setTransform = function setTransform() {
70
- var translateY = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
71
- var type = arguments.length > 1 ? arguments[1] : undefined;
72
- var time = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_DURATION;
73
- var deg = arguments.length > 3 ? arguments[3] : undefined;
59
+ var setTransform = function setTransform2() {
60
+ var translateY = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
61
+ var type = arguments.length > 1 ? arguments[1] : void 0;
62
+ var time = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : DEFAULT_DURATION;
63
+ var deg = arguments.length > 3 ? arguments[3] : void 0;
74
64
  var nTime = time;
75
- if (type !== 'end') {
65
+ if (type !== "end") {
76
66
  nTime = 0;
77
67
  }
78
68
  setTouchTime(nTime);
79
69
  setTouchDeg(deg);
80
70
  setScrollDistance(translateY);
81
71
  };
82
- var setMove = function setMove(move, type, time) {
72
+ var setMove = function setMove2(move, type, time) {
83
73
  var updateMove = move + transformY.current;
84
- if (type === 'end') {
85
- // 限定滚动距离
74
+ if (type === "end") {
86
75
  if (updateMove > 0) {
87
76
  updateMove = 0;
88
77
  }
89
78
  if (updateMove < -(listData.length - 1) * lineSpacing) {
90
79
  updateMove = -(listData.length - 1) * lineSpacing;
91
80
  }
92
- // 设置滚动距离为lineSpacing的倍数值
93
81
  var endMove = Math.round(updateMove / lineSpacing) * lineSpacing;
94
82
  var deg = "".concat((Math.abs(Math.round(endMove / lineSpacing)) + 1) * rotation, "deg");
95
83
  setTransform(endMove, type, time, deg);
@@ -97,27 +85,25 @@ var InternalPickerSlot = function InternalPickerSlot(props, ref) {
97
85
  } else {
98
86
  var _deg = 0;
99
87
  var currentDeg = (-updateMove / lineSpacing + 1) * rotation;
100
- // picker 滚动的最大角度
101
88
  var maxDeg = (listData.length + 1) * rotation;
102
89
  var minDeg = 0;
103
90
  _deg = Math.min(Math.max(currentDeg, minDeg), maxDeg);
104
91
  if (minDeg < _deg && _deg < maxDeg) {
105
- setTransform(updateMove, '', undefined, "".concat(_deg, "deg"));
92
+ setTransform(updateMove, "", void 0, "".concat(_deg, "deg"));
106
93
  setCurrIndex(Math.abs(Math.round(updateMove / lineSpacing)) + 1);
107
94
  }
108
95
  }
109
96
  };
110
- var setChooseValue = function setChooseValue(move) {
97
+ var setChooseValue = function setChooseValue2(move) {
111
98
  chooseItem && chooseItem(listData === null || listData === void 0 ? void 0 : listData[Math.round(-move / lineSpacing)], keyIndex);
112
99
  };
113
- // 开始滚动
114
- var touchStart = function touchStart(event) {
100
+ var touchStart = function touchStart2(event) {
115
101
  touch.start(event);
116
102
  setStartY(touch.deltaY);
117
103
  setStartTime(Date.now());
118
104
  transformY.current = scrollDistance;
119
105
  };
120
- var touchMove = function touchMove(event) {
106
+ var touchMove = function touchMove2(event) {
121
107
  touch.move(event);
122
108
  if (touch.isVertical) {
123
109
  moving.current = true;
@@ -126,37 +112,32 @@ var InternalPickerSlot = function InternalPickerSlot(props, ref) {
126
112
  var move = touch.deltaY - startY;
127
113
  setMove(move);
128
114
  };
129
- var touchEnd = function touchEnd(event) {
130
- if (!moving.current) return;
115
+ var touchEnd = function touchEnd2(event) {
116
+ if (!moving.current)
117
+ return;
131
118
  var move = touch.deltaY - startY;
132
119
  var moveTime = Date.now() - startTime;
133
- // 区分是否为惯性滚动
134
120
  if (moveTime <= INERTIA_TIME && Math.abs(move) > INERTIA_DISTANCE) {
135
- // 惯性滚动
136
121
  var distance = momentum(move, moveTime);
137
- setMove(distance, 'end', +swipeDuration);
122
+ setMove(distance, "end", +swipeDuration);
138
123
  } else {
139
- setMove(move, 'end');
124
+ setMove(move, "end");
140
125
  }
141
- setTimeout(function () {
142
- // moving.current = false
126
+ setTimeout(function() {
143
127
  touch.reset();
144
128
  }, 0);
145
129
  };
146
- // 惯性滚动 距离
147
- var momentum = function momentum(distance, duration) {
130
+ var momentum = function momentum2(distance, duration) {
148
131
  var nDistance = distance;
149
- // 惯性滚动的速度
150
132
  var speed = Math.abs(nDistance / duration);
151
- // 惯性滚动的距离
152
- nDistance = speed / 0.003 * (nDistance < 0 ? -1 : 1);
133
+ nDistance = speed / 3e-3 * (nDistance < 0 ? -1 : 1);
153
134
  return nDistance;
154
135
  };
155
- var modifyStatus = function modifyStatus(type, val) {
136
+ var modifyStatus = function modifyStatus2(type, val) {
156
137
  var value = val || defaultValue;
157
138
  var index = -1;
158
139
  if (value) {
159
- listData.some(function (item, idx) {
140
+ listData.some(function(item, idx) {
160
141
  if (item.value === value) {
161
142
  index = idx;
162
143
  return true;
@@ -164,7 +145,7 @@ var InternalPickerSlot = function InternalPickerSlot(props, ref) {
164
145
  return false;
165
146
  });
166
147
  } else {
167
- listData.forEach(function (item, i) {
148
+ listData.forEach(function(item, i) {
168
149
  if (item.value === defaultValue) {
169
150
  index = i;
170
151
  }
@@ -175,45 +156,42 @@ var InternalPickerSlot = function InternalPickerSlot(props, ref) {
175
156
  type && setChooseValue(-move);
176
157
  setMove(-move);
177
158
  };
178
- // 惯性滚动结束
179
- var stopMomentum = function stopMomentum() {
159
+ var stopMomentum = function stopMomentum2() {
180
160
  moving.current = false;
181
161
  setTouchTime(0);
182
162
  setChooseValue(scrollDistance);
183
163
  };
184
- // 阻止默认事件
185
- var preventDefault = function preventDefault(event, isStopPropagation) {
186
- /* istanbul ignore else */
187
- if (typeof event.cancelable !== 'boolean' || event.cancelable) {
164
+ var preventDefault = function preventDefault2(event, isStopPropagation) {
165
+ if (typeof event.cancelable !== "boolean" || event.cancelable) {
188
166
  event.preventDefault();
189
167
  }
190
168
  if (isStopPropagation) {
191
169
  event.stopPropagation();
192
170
  }
193
171
  };
194
- var touchRollerStyle = function touchRollerStyle() {
172
+ var touchRollerStyle = function touchRollerStyle2() {
195
173
  return {
196
174
  transition: "transform ".concat(touchTime, "ms cubic-bezier(0.17, 0.89, 0.45, 1)"),
197
175
  transform: "rotate3d(1, 0, 0, ".concat(touchDeg, ")")
198
176
  };
199
177
  };
200
- var touchTileStyle = function touchTileStyle() {
178
+ var touchTileStyle = function touchTileStyle2() {
201
179
  return {
202
180
  transition: "transform ".concat(touchTime, "ms cubic-bezier(0.17, 0.89, 0.45, 1)"),
203
181
  transform: "translate3d(0, ".concat(scrollDistance, "px, 0)")
204
182
  };
205
183
  };
206
- useEffect(function () {
184
+ useEffect(function() {
207
185
  setScrollDistance(0);
208
186
  transformY.current = 0;
209
187
  modifyStatus(false);
210
- return function () {
188
+ return function() {
211
189
  clearTimeout(timer);
212
190
  };
213
191
  }, [listData]);
214
- useImperativeHandle(ref, function () {
192
+ useImperativeHandle(ref, function() {
215
193
  return {
216
- stopMomentum: stopMomentum,
194
+ stopMomentum,
217
195
  moving: moving.current
218
196
  };
219
197
  });
@@ -228,15 +206,15 @@ var InternalPickerSlot = function InternalPickerSlot(props, ref) {
228
206
  ref: rollerRef,
229
207
  style: threeDimensional ? touchRollerStyle() : touchTileStyle(),
230
208
  onTransitionEnd: stopMomentum
231
- }, threeDimensional && listData.map(function (item, index) {
209
+ }, threeDimensional && listData.map(function(item, index) {
232
210
  return React__default.createElement("div", {
233
- className: "nut-picker-roller-item ".concat(isHidden(index + 1) && 'nut-picker-roller-item-hidden'),
211
+ className: "nut-picker-roller-item ".concat(isHidden(index + 1) && "nut-picker-roller-item-hidden"),
234
212
  style: {
235
213
  transform: "rotate3d(1, 0, 0, ".concat(-rotation * (index + 1), "deg) translate3d(0px, 0px, 104px)")
236
214
  },
237
215
  key: item.value ? item.value : index
238
216
  }, React__default.createElement(React__default.Fragment, null, item.text ? item.text : item));
239
- }), !threeDimensional && listData.map(function (item, index) {
217
+ }), !threeDimensional && listData.map(function(item, index) {
240
218
  return React__default.createElement("div", {
241
219
  className: "nut-picker-roller-item-title",
242
220
  key: item.value ? item.value : index
@@ -248,83 +226,56 @@ var InternalPickerSlot = function InternalPickerSlot(props, ref) {
248
226
  }));
249
227
  };
250
228
  var PickerSlot = React__default.forwardRef(InternalPickerSlot);
229
+ var PickerSlot$1 = PickerSlot;
251
230
  function useRefs() {
252
231
  var refs = React__default.useRef([]);
253
- var setRefs = React__default.useCallback(function (index) {
254
- return function (el) {
255
- if (el) refs.current[index] = el;
232
+ var setRefs = React__default.useCallback(function(index) {
233
+ return function(el) {
234
+ if (el)
235
+ refs.current[index] = el;
256
236
  };
257
237
  }, []);
258
- var reset = React__default.useCallback(function () {
238
+ var reset = React__default.useCallback(function() {
259
239
  refs.current = [];
260
240
  }, []);
261
241
  return [refs.current, setRefs, reset];
262
242
  }
263
- var InternalPicker = function InternalPicker(props, ref) {
264
- var _useConfig = useConfig(),
265
- locale = _useConfig.locale;
266
- var isVisible = props.isVisible,
267
- title = props.title,
268
- _props$listData2 = props.listData,
269
- listData = _props$listData2 === void 0 ? [] : _props$listData2,
270
- defaultValueData = props.defaultValueData,
271
- onConfirm = props.onConfirm,
272
- onClose = props.onClose,
273
- onCloseUpdate = props.onCloseUpdate,
274
- onChange = props.onChange,
275
- className = props.className,
276
- style = props.style,
277
- threeDimensional = props.threeDimensional,
278
- swipeDuration = props.swipeDuration,
279
- rest = _objectWithoutProperties(props, _excluded);
280
- var _useState13 = useState([]),
281
- _useState14 = _slicedToArray(_useState13, 2),
282
- chooseValueData = _useState14[0],
283
- setchooseValueData = _useState14[1]; // 选择的数据的 value 值, 每一条数据的 value 值
284
- var _useState15 = useState(0),
285
- _useState16 = _slicedToArray(_useState15, 2),
286
- columnIndex = _useState16[0],
287
- setcolumnIndex = _useState16[1]; // 选中列
243
+ var InternalPicker = function InternalPicker2(props, ref) {
244
+ var _useConfig = useConfig(), locale = _useConfig.locale;
245
+ var visible = props.visible, title = props.title, _props$listData2 = props.listData, listData = _props$listData2 === void 0 ? [] : _props$listData2, defaultValueData = props.defaultValueData, onConfirm = props.onConfirm, onClose = props.onClose, onCloseUpdate = props.onCloseUpdate, onChange = props.onChange, className = props.className, style = props.style, threeDimensional = props.threeDimensional, swipeDuration = props.swipeDuration, rest = _objectWithoutProperties(props, _excluded);
246
+ var _useState13 = useState([]), _useState14 = _slicedToArray(_useState13, 2), chooseValueData = _useState14[0], setchooseValueData = _useState14[1];
247
+ var _useState15 = useState(0), _useState16 = _slicedToArray(_useState15, 2), columnIndex = _useState16[0], setcolumnIndex = _useState16[1];
288
248
  var pickerRef = useRef(null);
289
- var _useRefs = useRefs(),
290
- _useRefs2 = _slicedToArray(_useRefs, 2),
291
- refs = _useRefs2[0],
292
- setRefs = _useRefs2[1];
293
- var _useState17 = useState([]),
294
- _useState18 = _slicedToArray(_useState17, 2),
295
- columnsList = _useState18[0],
296
- setColumnsList = _useState18[1]; // 格式化后每一列的数据
297
- var b = cn('picker');
249
+ var _useRefs = useRefs(), _useRefs2 = _slicedToArray(_useRefs, 2), refs = _useRefs2[0], setRefs = _useRefs2[1];
250
+ var _useState17 = useState([]), _useState18 = _slicedToArray(_useState17, 2), columnsList = _useState18[0], setColumnsList = _useState18[1];
251
+ var b = cn("picker");
298
252
  var isConfirmEvent = useRef(false);
299
- // 默认值修改
300
- useEffect(function () {
253
+ useEffect(function() {
301
254
  if (defaultValueData && defaultValueData.length !== 0 && defaultValueData.toString() !== chooseValueData.toString()) {
302
255
  var data = _toConsumableArray(defaultValueData);
303
256
  setchooseValueData(data);
304
257
  setColumnsList(normalListData());
305
258
  }
306
259
  }, [defaultValueData]);
307
- // 选中值进行修改
308
- useEffect(function () {
260
+ useEffect(function() {
309
261
  onChange && onChange(columnIndex, chooseValueData, selectedOptions());
310
262
  if (isConfirmEvent.current) {
311
263
  isConfirmEvent.current = false;
312
264
  onConfirm && onConfirm(chooseValueData, selectedOptions());
313
265
  }
314
266
  }, [chooseValueData]);
315
- // 列表格式修改
316
- useEffect(function () {
267
+ useEffect(function() {
317
268
  init();
318
269
  }, [listData]);
319
- var closeActionSheet = function closeActionSheet() {
270
+ var closeActionSheet = function closeActionSheet2() {
320
271
  onClose && onClose(chooseValueData, selectedOptions());
321
272
  onCloseUpdate && onCloseUpdate(chooseValueData, selectedOptions(), pickerRef);
322
273
  };
323
- // 点击确定
324
- var confirm = function confirm() {
274
+ var confirm = function confirm2() {
325
275
  var movings = false;
326
- refs.forEach(function (_ref) {
327
- if (_ref.moving) movings = true;
276
+ refs.forEach(function(_ref) {
277
+ if (_ref.moving)
278
+ movings = true;
328
279
  _ref.stopMomentum();
329
280
  });
330
281
  if (movings) {
@@ -333,15 +284,15 @@ var InternalPicker = function InternalPicker(props, ref) {
333
284
  onConfirm && onConfirm(chooseValueData, selectedOptions());
334
285
  }
335
286
  onClose && onClose(chooseValueData, selectedOptions());
336
- setTimeout(function () {
287
+ setTimeout(function() {
337
288
  isConfirmEvent.current = false;
338
289
  }, 0);
339
290
  };
340
- var selectedOptions = function selectedOptions() {
291
+ var selectedOptions = function selectedOptions2() {
341
292
  var optins = [];
342
- columnsList.map(function (column, index) {
293
+ columnsList.map(function(column, index) {
343
294
  var currOptions = [];
344
- currOptions = column.filter(function (item) {
295
+ currOptions = column.filter(function(item) {
345
296
  return item.value === chooseValueData[index];
346
297
  });
347
298
  if (currOptions[0]) {
@@ -353,15 +304,13 @@ var InternalPicker = function InternalPicker(props, ref) {
353
304
  });
354
305
  return optins;
355
306
  };
356
- // 选择每一列的数据
357
- var _chooseItem = function chooseItem(option, columnIndex) {
307
+ var _chooseItem = function chooseItem(option, columnIndex2) {
358
308
  if (option && Object.keys(option).length) {
359
- // 是否移动后是否与之前有差异
360
- if (chooseValueData[columnIndex] !== option.value) {
361
- if (columnsType() === 'cascade') {
362
- chooseValueData[columnIndex] = option.value ? option.value : '';
309
+ if (chooseValueData[columnIndex2] !== option.value) {
310
+ if (columnsType() === "cascade") {
311
+ chooseValueData[columnIndex2] = option.value ? option.value : "";
363
312
  setchooseValueData(_toConsumableArray(chooseValueData));
364
- var index = columnIndex;
313
+ var index = columnIndex2;
365
314
  var cursor = option;
366
315
  while (cursor && cursor.children && cursor.children[0]) {
367
316
  chooseValueData[index + 1] = cursor.children[0].value;
@@ -370,67 +319,63 @@ var InternalPicker = function InternalPicker(props, ref) {
370
319
  var cc = cursor.children[0];
371
320
  cursor = cc;
372
321
  }
373
- // 当前改变列的下一列 children 值为空
374
322
  if (cursor && cursor.children) {
375
- chooseValueData[index + 1] = '';
323
+ chooseValueData[index + 1] = "";
376
324
  setchooseValueData(_toConsumableArray(chooseValueData));
377
325
  }
378
326
  setColumnsList(normalListData());
379
327
  } else {
380
- setchooseValueData(function (data) {
328
+ setchooseValueData(function(data) {
381
329
  var cdata = _toConsumableArray(data);
382
- cdata[columnIndex] = Object.prototype.hasOwnProperty.call(option, 'value') ? option.value : '';
330
+ cdata[columnIndex2] = Object.prototype.hasOwnProperty.call(option, "value") ? option.value : "";
383
331
  return cdata;
384
332
  });
385
333
  }
386
- setcolumnIndex(columnIndex);
334
+ setcolumnIndex(columnIndex2);
387
335
  }
388
336
  }
389
337
  };
390
- // 传入的数据格式化
391
- var normalListData = function normalListData() {
338
+ var normalListData = function normalListData2() {
392
339
  var type = columnsType();
393
340
  switch (type) {
394
- case 'multiple':
341
+ case "multiple":
395
342
  return listData;
396
- case 'cascade':
397
- // 级联数据处理
343
+ case "cascade":
398
344
  return formatCascade(listData, chooseValueData);
399
345
  default:
400
346
  return [listData];
401
347
  }
402
348
  };
403
- // 每一列的类型
404
- var columnsType = function columnsType() {
349
+ var columnsType = function columnsType2() {
405
350
  var firstColumn = listData[0];
406
351
  if (firstColumn) {
407
352
  if (Array.isArray(firstColumn)) {
408
- return 'multiple';
353
+ return "multiple";
409
354
  }
410
- if ('children' in firstColumn) {
411
- return 'cascade';
355
+ if ("children" in firstColumn) {
356
+ return "cascade";
412
357
  }
413
358
  }
414
- return 'single';
359
+ return "single";
415
360
  };
416
- // 级联数据格式化
417
- var formatCascade = function formatCascade(columns, defaultValues) {
361
+ var formatCascade = function formatCascade2(columns, defaultValues) {
418
362
  var formatted = [];
419
363
  var cursor = {
420
- text: '',
421
- value: '',
364
+ text: "",
365
+ value: "",
422
366
  children: columns
423
367
  };
424
- var columnIndex = 0;
425
- var _loop = function _loop() {
368
+ var columnIndex2 = 0;
369
+ var _loop = function _loop2() {
426
370
  var options = cursor.children;
427
- var value = defaultValues[columnIndex];
428
- var index = options.findIndex(function (columnItem) {
371
+ var value = defaultValues[columnIndex2];
372
+ var index = options.findIndex(function(columnItem) {
429
373
  return columnItem.value === value;
430
374
  });
431
- if (index === -1) index = 0;
375
+ if (index === -1)
376
+ index = 0;
432
377
  cursor = cursor.children[index];
433
- columnIndex++;
378
+ columnIndex2++;
434
379
  formatted.push(options);
435
380
  };
436
381
  while (cursor && cursor.children) {
@@ -438,11 +383,11 @@ var InternalPicker = function InternalPicker(props, ref) {
438
383
  }
439
384
  return formatted;
440
385
  };
441
- var init = function init() {
386
+ var init = function init2() {
442
387
  var data = [];
443
388
  var normalData = normalListData();
444
389
  setColumnsList(normalData);
445
- normalData.length > 0 && normalData.map(function (item) {
390
+ normalData.length > 0 && normalData.map(function(item) {
446
391
  item[0] && data.push(item[0].value);
447
392
  return item;
448
393
  });
@@ -450,47 +395,50 @@ var InternalPicker = function InternalPicker(props, ref) {
450
395
  setchooseValueData([].concat(data));
451
396
  }
452
397
  };
453
- var renderToolbar = function renderToolbar() {
398
+ var renderToolbar = function renderToolbar2() {
454
399
  return React__default.createElement("div", {
455
- className: b('control')
400
+ className: b("control")
456
401
  }, React__default.createElement("span", {
457
- className: b('cancel-btn'),
402
+ className: b("cancel-btn"),
458
403
  onClick: function onClick() {
459
404
  return closeActionSheet();
460
405
  }
461
406
  }, locale.cancel), React__default.createElement("div", {
462
- className: b('title')
463
- }, title || ''), React__default.createElement("span", {
464
- className: b('confirm-btn'),
407
+ className: b("title")
408
+ }, title || ""), React__default.createElement("span", {
409
+ className: b("confirm-btn"),
465
410
  onClick: confirm
466
411
  }, locale.confirm));
467
412
  };
468
413
  return React__default.createElement(Popup, {
469
- visible: isVisible,
414
+ visible,
470
415
  position: "bottom",
471
- onClose: function onClose() {
416
+ onClose: function onClose2() {
472
417
  closeActionSheet();
473
418
  }
474
419
  }, React__default.createElement("div", _objectSpread({
475
- className: "".concat(b(), " ").concat(className || ''),
476
- style: style
420
+ className: "".concat(b(), " ").concat(className || ""),
421
+ style
477
422
  }, rest), renderToolbar(), React__default.createElement("div", {
478
- className: b('panel'),
423
+ className: b("panel"),
479
424
  ref: pickerRef
480
- }, columnsList === null || columnsList === void 0 ? void 0 : columnsList.map(function (item, index) {
481
- return React__default.createElement(PickerSlot, {
425
+ }, columnsList === null || columnsList === void 0 ? void 0 : columnsList.map(function(item, index) {
426
+ return React__default.createElement(PickerSlot$1, {
482
427
  ref: setRefs(index),
483
428
  defaultValue: chooseValueData === null || chooseValueData === void 0 ? void 0 : chooseValueData[index],
484
429
  listData: item,
485
- threeDimensional: threeDimensional,
486
- chooseItem: function chooseItem(value, index) {
487
- return _chooseItem(value, index);
430
+ threeDimensional,
431
+ chooseItem: function chooseItem(value, index2) {
432
+ return _chooseItem(value, index2);
488
433
  },
489
- swipeDuration: swipeDuration,
434
+ swipeDuration,
490
435
  key: index,
491
436
  keyIndex: index
492
437
  });
493
438
  }))));
494
439
  };
495
440
  var Picker = React__default.forwardRef(InternalPicker);
496
- export { Picker as default };
441
+ var Picker$1 = Picker;
442
+ export {
443
+ Picker$1 as default
444
+ };
@@ -1,3 +1,2 @@
1
- import '../../Icon/style'
2
1
  import '../../Overlay/style'
3
2
  import '../../../packages/popover/popover.scss'