@nutui/nutui-react 1.5.1-beta.0 → 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,19 +2,38 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
  import _regeneratorRuntime from "@babel/runtime/regenerator";
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; }
6
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7
- import React__default, { useState, useRef, useEffect } from 'react';
8
- import { useDrag } from '@use-gesture/react';
9
- import { useSpring, animated } from '@react-spring/web';
10
- import { useConfig } from './ConfigProvider.js';
11
- import { c as canUseDom, g as getScrollParent } from './get-scroll-parent-5f85dee8.js';
5
+ function ownKeys(object, enumerableOnly) {
6
+ var keys = Object.keys(object);
7
+ if (Object.getOwnPropertySymbols) {
8
+ var symbols = Object.getOwnPropertySymbols(object);
9
+ enumerableOnly && (symbols = symbols.filter(function(sym) {
10
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
11
+ })), keys.push.apply(keys, symbols);
12
+ }
13
+ return keys;
14
+ }
15
+ function _objectSpread(target) {
16
+ for (var i = 1; i < arguments.length; i++) {
17
+ var source = null != arguments[i] ? arguments[i] : {};
18
+ i % 2 ? ownKeys(Object(source), true).forEach(function(key) {
19
+ _defineProperty(target, key, source[key]);
20
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
21
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
22
+ });
23
+ }
24
+ return target;
25
+ }
26
+ import React__default, { useState, useRef, useEffect } from "react";
27
+ import { useDrag } from "@use-gesture/react";
28
+ import { useSpring, animated } from "@react-spring/web";
29
+ import { useConfig } from "./ConfigProvider.js";
30
+ import { c as canUseDom, g as getScrollParent } from "./get-scroll-parent.js";
12
31
  function bound(position, min, max) {
13
32
  var ret = position;
14
- if (min !== undefined) {
33
+ if (min !== void 0) {
15
34
  ret = Math.max(position, min);
16
35
  }
17
- if (max !== undefined) {
36
+ if (max !== void 0) {
18
37
  ret = Math.min(ret, max);
19
38
  }
20
39
  return ret;
@@ -23,46 +42,49 @@ function rubberband(distance, dimension, constant) {
23
42
  return distance * dimension * constant / (dimension + constant * distance);
24
43
  }
25
44
  function rubberbandIfOutOfBounds(position, min, max, dimension) {
26
- var constant = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0.15;
27
- if (constant === 0) return bound(position, min, max);
28
- if (position < min) return -rubberband(min - position, dimension, constant) + min;
29
- if (position > max) return +rubberband(position - max, dimension, constant) + max;
45
+ var constant = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 0.15;
46
+ if (constant === 0)
47
+ return bound(position, min, max);
48
+ if (position < min)
49
+ return -rubberband(min - position, dimension, constant) + min;
50
+ if (position > max)
51
+ return +rubberband(position - max, dimension, constant) + max;
30
52
  return position;
31
53
  }
32
- var sleep = function sleep(time) {
33
- return new Promise(function (resolve) {
54
+ var sleep = function sleep2(time) {
55
+ return new Promise(function(resolve) {
34
56
  return setTimeout(resolve, time);
35
57
  });
36
58
  };
37
59
  var passiveSupported = false;
38
60
  if (canUseDom) {
39
61
  try {
40
- var opts = Object.defineProperty({}, 'passive', {
62
+ var opts = Object.defineProperty({}, "passive", {
41
63
  get: function get() {
42
64
  passiveSupported = true;
43
65
  }
44
66
  });
45
- window.addEventListener('test-passive-supported', null, opts);
67
+ window.addEventListener("test-passive-supported", null, opts);
46
68
  } catch (e) {
47
69
  console.log(e);
48
70
  }
49
71
  }
50
72
  var defaultProps = {
51
- className: '',
73
+ className: "",
52
74
  style: {},
53
- pullingText: '',
54
- canReleaseText: '',
55
- refreshingText: '',
56
- completeText: '',
75
+ pullingText: "",
76
+ canReleaseText: "",
77
+ refreshingText: "",
78
+ completeText: "",
57
79
  completeDelay: 500,
58
80
  disabled: false,
59
81
  headHeight: 40,
60
82
  threshold: 60,
61
- onRefresh: function onRefresh() {}
83
+ onRefresh: function onRefresh() {
84
+ }
62
85
  };
63
- var PullToRefresh = function PullToRefresh(p) {
64
- var _useConfig = useConfig(),
65
- locale = _useConfig.locale;
86
+ var PullToRefresh = function PullToRefresh2(p) {
87
+ var _useConfig = useConfig(), locale = _useConfig.locale;
66
88
  var props = _objectSpread(_objectSpread(_objectSpread({}, defaultProps), p), {
67
89
  pullingText: p.pullingText || locale.pullToRefresh.pullingText,
68
90
  canReleaseText: p.canReleaseText || locale.pullToRefresh.canReleaseText,
@@ -71,125 +93,123 @@ var PullToRefresh = function PullToRefresh(p) {
71
93
  });
72
94
  var headHeight = props.headHeight;
73
95
  var threshold = props.threshold;
74
- var _useState = useState('pulling'),
75
- _useState2 = _slicedToArray(_useState, 2),
76
- status = _useState2[0],
77
- setStatus = _useState2[1];
78
- var _useSpring = useSpring(function () {
79
- return {
80
- from: {
81
- height: 0
82
- },
83
- config: {
84
- tension: 300,
85
- friction: 30,
86
- clamp: true
87
- }
88
- };
89
- }),
90
- _useSpring2 = _slicedToArray(_useSpring, 2),
91
- springStyles = _useSpring2[0],
92
- api = _useSpring2[1];
96
+ var _useState = useState("pulling"), _useState2 = _slicedToArray(_useState, 2), status = _useState2[0], setStatus = _useState2[1];
97
+ var _useSpring = useSpring(function() {
98
+ return {
99
+ from: {
100
+ height: 0
101
+ },
102
+ config: {
103
+ tension: 300,
104
+ friction: 30,
105
+ clamp: true
106
+ }
107
+ };
108
+ }), _useSpring2 = _slicedToArray(_useSpring, 2), springStyles = _useSpring2[0], api = _useSpring2[1];
93
109
  var elementRef = useRef(null);
94
110
  var pullingRef = useRef(false);
95
- useEffect(function () {
111
+ useEffect(function() {
96
112
  var _elementRef$current;
97
- (_elementRef$current = elementRef.current) === null || _elementRef$current === void 0 ? void 0 : _elementRef$current.addEventListener('touchmove', function () {});
113
+ (_elementRef$current = elementRef.current) === null || _elementRef$current === void 0 ? void 0 : _elementRef$current.addEventListener("touchmove", function() {
114
+ });
98
115
  }, []);
99
116
  function doRefresh() {
100
117
  return _doRefresh.apply(this, arguments);
101
118
  }
102
119
  function _doRefresh() {
103
- _doRefresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
120
+ _doRefresh = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime.mark(function _callee3() {
104
121
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
105
- while (1) switch (_context3.prev = _context3.next) {
106
- case 0:
107
- api.start({
108
- height: headHeight
109
- });
110
- setStatus('refreshing');
111
- _context3.prev = 2;
112
- _context3.next = 5;
113
- return props.onRefresh();
114
- case 5:
115
- setStatus('complete');
116
- _context3.next = 12;
117
- break;
118
- case 8:
119
- _context3.prev = 8;
120
- _context3.t0 = _context3["catch"](2);
121
- api.start({
122
- to: function () {
123
- var _to = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(next) {
124
- return _regeneratorRuntime.wrap(function _callee$(_context) {
125
- while (1) switch (_context.prev = _context.next) {
126
- case 0:
127
- _context.next = 2;
128
- return next({
129
- height: 0
130
- });
131
- case 2:
132
- setStatus('pulling');
133
- case 3:
134
- case "end":
135
- return _context.stop();
136
- }
137
- }, _callee);
138
- }));
139
- function to(_x) {
140
- return _to.apply(this, arguments);
141
- }
142
- return to;
143
- }()
144
- });
145
- throw _context3.t0;
146
- case 12:
147
- if (!(props.completeDelay > 0)) {
148
- _context3.next = 15;
122
+ while (1)
123
+ switch (_context3.prev = _context3.next) {
124
+ case 0:
125
+ api.start({
126
+ height: headHeight
127
+ });
128
+ setStatus("refreshing");
129
+ _context3.prev = 2;
130
+ _context3.next = 5;
131
+ return props.onRefresh();
132
+ case 5:
133
+ setStatus("complete");
134
+ _context3.next = 12;
149
135
  break;
150
- }
151
- _context3.next = 15;
152
- return sleep(props.completeDelay);
153
- case 15:
154
- api.start({
155
- to: function () {
156
- var _to2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(next) {
157
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
158
- while (1) switch (_context2.prev = _context2.next) {
159
- case 0:
160
- _context2.next = 2;
161
- return next({
162
- height: 0
163
- });
164
- case 2:
165
- setStatus('pulling');
166
- case 3:
167
- case "end":
168
- return _context2.stop();
169
- }
170
- }, _callee2);
171
- }));
172
- function to(_x2) {
173
- return _to2.apply(this, arguments);
174
- }
175
- return to;
176
- }()
177
- });
178
- case 16:
179
- case "end":
180
- return _context3.stop();
181
- }
136
+ case 8:
137
+ _context3.prev = 8;
138
+ _context3.t0 = _context3["catch"](2);
139
+ api.start({
140
+ to: function() {
141
+ var _to = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime.mark(function _callee(next) {
142
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
143
+ while (1)
144
+ switch (_context.prev = _context.next) {
145
+ case 0:
146
+ _context.next = 2;
147
+ return next({
148
+ height: 0
149
+ });
150
+ case 2:
151
+ setStatus("pulling");
152
+ case 3:
153
+ case "end":
154
+ return _context.stop();
155
+ }
156
+ }, _callee);
157
+ }));
158
+ function to(_x) {
159
+ return _to.apply(this, arguments);
160
+ }
161
+ return to;
162
+ }()
163
+ });
164
+ throw _context3.t0;
165
+ case 12:
166
+ if (!(props.completeDelay > 0)) {
167
+ _context3.next = 15;
168
+ break;
169
+ }
170
+ _context3.next = 15;
171
+ return sleep(props.completeDelay);
172
+ case 15:
173
+ api.start({
174
+ to: function() {
175
+ var _to2 = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime.mark(function _callee2(next) {
176
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
177
+ while (1)
178
+ switch (_context2.prev = _context2.next) {
179
+ case 0:
180
+ _context2.next = 2;
181
+ return next({
182
+ height: 0
183
+ });
184
+ case 2:
185
+ setStatus("pulling");
186
+ case 3:
187
+ case "end":
188
+ return _context2.stop();
189
+ }
190
+ }, _callee2);
191
+ }));
192
+ function to(_x2) {
193
+ return _to2.apply(this, arguments);
194
+ }
195
+ return to;
196
+ }()
197
+ });
198
+ case 16:
199
+ case "end":
200
+ return _context3.stop();
201
+ }
182
202
  }, _callee3, null, [[2, 8]]);
183
203
  }));
184
204
  return _doRefresh.apply(this, arguments);
185
205
  }
186
- useDrag(function (state) {
187
- if (status === 'refreshing' || status === 'complete') return;
206
+ useDrag(function(state) {
207
+ if (status === "refreshing" || status === "complete")
208
+ return;
188
209
  var event = state.event;
189
- // 最后一个事件,检查是否可以刷新或是否是开始状态(第一个状态也是最后一个状态)
190
210
  if (state.last) {
191
211
  pullingRef.current = false;
192
- if (status === 'canRelease') {
212
+ if (status === "canRelease") {
193
213
  doRefresh();
194
214
  } else {
195
215
  api.start({
@@ -199,62 +219,64 @@ var PullToRefresh = function PullToRefresh(p) {
199
219
  return;
200
220
  }
201
221
  function getScrollTop(element) {
202
- return 'scrollTop' in element ? element.scrollTop : element.scrollY;
222
+ return "scrollTop" in element ? element.scrollTop : element.scrollY;
203
223
  }
204
- // 手指位置
205
- var _state$movement = _slicedToArray(state.movement, 2),
206
- y = _state$movement[1];
207
- // 第一个事件,并且手指位置大于0
224
+ var _state$movement = _slicedToArray(state.movement, 2), y = _state$movement[1];
208
225
  if (state.first && y > 0) {
209
226
  var target = state.event.target;
210
- if (!target || !(target instanceof Element)) return;
227
+ if (!target || !(target instanceof Element))
228
+ return;
211
229
  var scrollParent = getScrollParent(target);
212
230
  while (true) {
213
- if (!scrollParent) return;
231
+ if (!scrollParent)
232
+ return;
214
233
  var scrollTop = getScrollTop(scrollParent);
215
234
  if (scrollTop > 0) {
216
235
  return;
217
236
  }
218
- // 查找到 window 说明到顶了
219
237
  if (scrollParent instanceof Window) {
220
238
  break;
221
239
  }
222
- // 递归查找
223
240
  scrollParent = getScrollParent(scrollParent.parentNode);
224
241
  }
225
242
  pullingRef.current = true;
226
243
  }
227
- if (!pullingRef.current) return;
244
+ if (!pullingRef.current)
245
+ return;
228
246
  if (event.cancelable) {
229
247
  event.preventDefault();
230
248
  }
231
249
  event.stopPropagation();
232
250
  var height = Math.max(rubberbandIfOutOfBounds(y, 0, 0, headHeight * 5, 0.5), 0);
233
251
  api.start({
234
- height: height
252
+ height
235
253
  });
236
- setStatus(height > threshold ? 'canRelease' : 'pulling');
254
+ setStatus(height > threshold ? "canRelease" : "pulling");
237
255
  }, {
238
256
  pointer: {
239
257
  touch: true
240
258
  },
241
- axis: 'y',
259
+ axis: "y",
242
260
  target: elementRef,
243
261
  enabled: !props.disabled,
244
262
  eventOptions: passiveSupported ? {
245
263
  passive: false
246
264
  } : false
247
265
  });
248
- var renderStatusText = function renderStatusText() {
266
+ var renderStatusText = function renderStatusText2() {
249
267
  if (props.renderText) {
250
268
  var _props$renderText;
251
269
  return (_props$renderText = props.renderText) === null || _props$renderText === void 0 ? void 0 : _props$renderText.call(props, status);
252
270
  }
253
- if (status === 'pulling') return props.pullingText;
254
- if (status === 'canRelease') return props.canReleaseText;
255
- if (status === 'refreshing') return props.refreshingText;
256
- if (status === 'complete') return props.completeText;
257
- return '';
271
+ if (status === "pulling")
272
+ return props.pullingText;
273
+ if (status === "canRelease")
274
+ return props.canReleaseText;
275
+ if (status === "refreshing")
276
+ return props.refreshingText;
277
+ if (status === "complete")
278
+ return props.completeText;
279
+ return "";
258
280
  };
259
281
  return React__default.createElement(animated.div, {
260
282
  ref: elementRef,
@@ -273,5 +295,7 @@ var PullToRefresh = function PullToRefresh(p) {
273
295
  }, props.children));
274
296
  };
275
297
  PullToRefresh.defaultProps = defaultProps;
276
- PullToRefresh.displayName = 'NutPullToRefresh';
277
- export { PullToRefresh as default };
298
+ PullToRefresh.displayName = "NutPullToRefresh";
299
+ export {
300
+ PullToRefresh as default
301
+ };
@@ -1,3 +1,2 @@
1
- import '../../Icon/style'
2
1
  import '../../RadioGroup/style'
3
2
  import '../../../packages/radio/radio.scss'
package/dist/esm/Radio.js CHANGED
@@ -1,6 +1,8 @@
1
- import { R as Radio } from './radio-9f141e6b.js';
2
- import 'react';
3
- import './Icon.js';
4
- import './RadioGroup.js';
5
- import './typings-f27b58f4.js';
6
- export { Radio as default };
1
+ import { R as Radio } from "./radio2.js";
2
+ import "react";
3
+ import "@nutui/icons-react";
4
+ import "./RadioGroup.js";
5
+ import "./typings.js";
6
+ export {
7
+ Radio as default
8
+ };
@@ -1,123 +1,103 @@
1
1
  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
- var _excluded = ["className", "value", "onChange", "textPosition", "direction", "options"],
5
- _excluded2 = ["label", "value", "disabled", "onChange"];
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, useEffect, useCallback } from 'react';
9
- import { R as Radio, a as RadioContext } from './radio-9f141e6b.js';
10
- import { c as cn } from './bem-3b438e61.js';
11
- import './Icon.js';
12
- import './RadioGroup.js';
13
- import './typings-f27b58f4.js';
14
- import '@bem-react/classname';
4
+ var _excluded = ["className", "value", "onChange", "textPosition", "direction", "options"], _excluded2 = ["label", "value", "disabled", "onChange"];
5
+ function ownKeys(object, enumerableOnly) {
6
+ var keys = Object.keys(object);
7
+ if (Object.getOwnPropertySymbols) {
8
+ var symbols = Object.getOwnPropertySymbols(object);
9
+ enumerableOnly && (symbols = symbols.filter(function(sym) {
10
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
11
+ })), keys.push.apply(keys, symbols);
12
+ }
13
+ return keys;
14
+ }
15
+ function _objectSpread(target) {
16
+ for (var i = 1; i < arguments.length; i++) {
17
+ var source = null != arguments[i] ? arguments[i] : {};
18
+ i % 2 ? ownKeys(Object(source), true).forEach(function(key) {
19
+ _defineProperty(target, key, source[key]);
20
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
21
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
22
+ });
23
+ }
24
+ return target;
25
+ }
26
+ import React__default, { useState, useEffect, useCallback } from "react";
27
+ import { R as Radio, a as RadioContext } from "./radio2.js";
28
+ import { c as cn } from "./bem.js";
29
+ import "@nutui/icons-react";
30
+ import "./RadioGroup.js";
31
+ import "./typings.js";
32
+ import "@bem-react/classname";
15
33
  var defaultProps = {
16
34
  value: null,
17
- textPosition: 'right',
18
- onChange: function onChange(value) {},
19
- direction: 'vertical',
35
+ textPosition: "right",
36
+ onChange: function onChange(value) {
37
+ },
38
+ direction: "vertical",
20
39
  options: []
21
40
  };
22
- var RadioGroup = React__default.forwardRef(function (props, ref) {
23
- var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
24
- children = _defaultProps$props.children;
25
- cn('RadioGroup');
26
- var className = props.className,
27
- value = props.value,
28
- _onChange = props.onChange,
29
- textPosition = props.textPosition,
30
- direction = props.direction,
31
- options = props.options,
32
- rest = _objectWithoutProperties(props, _excluded);
33
- var _useState = useState(value),
34
- _useState2 = _slicedToArray(_useState, 2),
35
- val2State = _useState2[0],
36
- setVal2State = _useState2[1];
37
- // useImperativeHandle(ref, () => ({
38
- // toggleAll(state: boolean) {
39
- // console.log(state)
40
- // if (state === false) {
41
- // setInnerValue([])
42
- // } else {
43
- // const childrenLabel: string[] = []
44
- // React.Children.map(children, (child) => {
45
- // const childProps = (child as any).props
46
- // childrenLabel.push(childProps.label || (child as any).children)
47
- // })
48
- // setInnerValue(childrenLabel)
49
- // }
50
- // },
51
- // }))
52
- useEffect(function () {
41
+ var RadioGroup = React__default.forwardRef(function(props, ref) {
42
+ var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props), children = _defaultProps$props.children;
43
+ cn("RadioGroup");
44
+ var className = props.className, value = props.value, _onChange = props.onChange, textPosition = props.textPosition, direction = props.direction, options = props.options, rest = _objectWithoutProperties(props, _excluded);
45
+ var _useState = useState(value), _useState2 = _slicedToArray(_useState, 2), val2State = _useState2[0], setVal2State = _useState2[1];
46
+ useEffect(function() {
53
47
  setVal2State(value);
54
48
  }, [value]);
55
- // function handleChildChange(state: boolean, label: string) {
56
- // if (innerValue) {
57
- // let clippedValue = []
58
- // if (state) {
59
- // clippedValue = [...innerValue, label]
60
- // } else {
61
- // innerValue?.splice(innerValue?.indexOf(label), 1)
62
- // clippedValue = [...innerValue]
63
- // }
64
- // setInnerValue(clippedValue)
65
- // onChange && onChange(clippedValue)
66
- // }
67
- // }
68
49
  function validateChildChecked(child) {
69
- if (val2State === null) return false;
50
+ if (val2State === null)
51
+ return false;
70
52
  return val2State === child.props.value;
71
53
  }
72
- function validateChecked(value) {
73
- if (val2State === null) return false;
74
- return val2State === value;
54
+ function validateChecked(value2) {
55
+ if (val2State === null)
56
+ return false;
57
+ return val2State === value2;
75
58
  }
76
59
  function cloneChildren() {
77
- return React__default.Children.map(children, function (child, index) {
60
+ return React__default.Children.map(children, function(child, index) {
78
61
  var childChecked = validateChildChecked(child);
79
- if (child.type.displayName !== 'NutRadio') {
62
+ if (child.type.displayName !== "NutRadio") {
80
63
  return React__default.cloneElement(child);
81
64
  }
82
65
  return React__default.cloneElement(child, {
83
- textPosition: textPosition,
66
+ textPosition,
84
67
  checked: childChecked
85
68
  // onChange: handleChildChange,
86
69
  });
87
70
  });
88
71
  }
89
-
90
- var renderOptionsChildren = useCallback(function () {
91
- return options === null || options === void 0 ? void 0 : options.map(function (_ref) {
92
- var label = _ref.label,
93
- value = _ref.value,
94
- disabled = _ref.disabled,
95
- onChange = _ref.onChange,
96
- rest = _objectWithoutProperties(_ref, _excluded2);
97
- var childChecked = validateChecked(value);
72
+ var renderOptionsChildren = useCallback(function() {
73
+ return options === null || options === void 0 ? void 0 : options.map(function(_ref) {
74
+ var label = _ref.label, value2 = _ref.value, disabled = _ref.disabled, onChange2 = _ref.onChange, rest2 = _objectWithoutProperties(_ref, _excluded2);
75
+ var childChecked = validateChecked(value2);
98
76
  return React__default.createElement(Radio, _objectSpread(_objectSpread({
99
- key: value === null || value === void 0 ? void 0 : value.toString(),
77
+ key: value2 === null || value2 === void 0 ? void 0 : value2.toString(),
100
78
  children: label,
101
- value: value,
102
- disabled: disabled,
103
- onChange: onChange
104
- }, rest), {}, {
105
- textPosition: textPosition,
79
+ value: value2,
80
+ disabled,
81
+ onChange: onChange2
82
+ }, rest2), {}, {
83
+ textPosition,
106
84
  checked: childChecked
107
85
  }));
108
86
  });
109
87
  }, [val2State, options]);
110
88
  return React__default.createElement(RadioContext.Provider, {
111
89
  value: {
112
- onChange: function onChange(val) {
90
+ onChange: function onChange2(val) {
113
91
  setVal2State(val);
114
92
  _onChange && _onChange(val);
115
93
  }
116
94
  }
117
95
  }, React__default.createElement("div", _objectSpread({
118
- className: "nut-radiogroup nut-radiogroup--".concat(props.direction, " ").concat(className || '')
96
+ className: "nut-radiogroup nut-radiogroup--".concat(props.direction, " ").concat(className || "")
119
97
  }, rest), options !== null && options !== void 0 && options.length ? renderOptionsChildren() : cloneChildren()));
120
98
  });
121
99
  RadioGroup.defaultProps = defaultProps;
122
- RadioGroup.displayName = 'NutRadioGroup';
123
- export { RadioGroup as default };
100
+ RadioGroup.displayName = "NutRadioGroup";
101
+ export {
102
+ RadioGroup as default
103
+ };