@nutui/nutui-react 0.1.0-beta.1 → 0.1.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/README.md +50 -135
  2. package/dist/esm/ActionSheet/style/index.js +1 -0
  3. package/dist/esm/Address/style/index.js +1 -0
  4. package/dist/esm/AnimatingNumbers/style/index.js +1 -0
  5. package/dist/esm/Avatar/style/index.js +1 -0
  6. package/dist/esm/BackTop/style/index.js +1 -0
  7. package/dist/esm/BackTop.js +1 -3
  8. package/dist/esm/Badge/style/index.js +1 -0
  9. package/dist/esm/Barrage/style/index.js +1 -0
  10. package/dist/esm/Button/style/index.js +1 -0
  11. package/dist/esm/Calendar/style/index.js +1 -0
  12. package/dist/esm/Calendar.js +86 -0
  13. package/dist/esm/CalendarItem/style/index.js +1 -0
  14. package/dist/esm/CalendarItem.js +554 -0
  15. package/dist/esm/Cell/style/index.js +1 -0
  16. package/dist/esm/CellGroup/style/index.js +1 -0
  17. package/dist/esm/CellGroup.js +33 -0
  18. package/dist/esm/Checkbox/style/index.js +1 -0
  19. package/dist/esm/CheckboxGroup/style/index.js +1 -0
  20. package/dist/esm/CircleProgress/style/index.js +1 -0
  21. package/dist/esm/Col/style/index.js +1 -0
  22. package/dist/esm/Col.js +60 -0
  23. package/dist/esm/Collapse/style/index.js +1 -0
  24. package/dist/esm/CollapseItem/style/index.js +1 -0
  25. package/dist/esm/CollapseItem.js +142 -0
  26. package/dist/esm/Dialog/style/index.js +1 -0
  27. package/dist/esm/Dialog.js +327 -0
  28. package/dist/esm/Divider/style/index.js +1 -0
  29. package/dist/esm/Drag/style/index.js +1 -0
  30. package/dist/esm/Drag.js +101 -139
  31. package/dist/esm/Elevator/style/index.js +1 -0
  32. package/dist/esm/Elevator.js +3 -6
  33. package/dist/esm/FixedNav/style/index.js +1 -0
  34. package/dist/esm/Icon/style/index.js +1 -0
  35. package/dist/esm/Infiniteloading/style/index.js +1 -0
  36. package/dist/esm/Input/style/index.js +1 -0
  37. package/dist/esm/Input.js +1 -1
  38. package/dist/esm/InputNumber/style/index.js +1 -0
  39. package/dist/esm/Layout/style/index.js +1 -0
  40. package/dist/esm/NavBar/style/index.js +1 -0
  41. package/dist/esm/NoticeBar/style/index.js +1 -0
  42. package/dist/esm/Notify/style/index.js +1 -0
  43. package/dist/esm/Overlay/style/index.js +1 -0
  44. package/dist/esm/Pagination/style/index.js +1 -0
  45. package/dist/esm/Picker/style/index.js +1 -0
  46. package/dist/esm/Picker.js +397 -0
  47. package/dist/esm/Popover/style/index.js +1 -0
  48. package/dist/esm/Popover.js +299 -0
  49. package/dist/esm/Popup/style/index.js +1 -0
  50. package/dist/esm/Popup.js +0 -3
  51. package/dist/esm/Price/style/index.js +1 -0
  52. package/dist/esm/Radio/style/index.js +1 -0
  53. package/dist/esm/RadioGroup/style/index.js +1 -0
  54. package/dist/esm/Range/style/index.js +1 -0
  55. package/dist/esm/Rate/style/index.js +1 -0
  56. package/dist/esm/Row/style/index.js +1 -0
  57. package/dist/esm/Row.js +48 -0
  58. package/dist/esm/ShortPassword/style/index.js +1 -0
  59. package/dist/esm/ShortPassword.js +203 -0
  60. package/dist/esm/Signature/style/index.js +1 -0
  61. package/dist/esm/Step/style/index.js +1 -0
  62. package/dist/esm/Steps/style/index.js +1 -0
  63. package/dist/esm/Swiper/style/index.js +1 -0
  64. package/dist/esm/Swiper.js +517 -0
  65. package/dist/esm/SwiperItem/style/index.js +1 -0
  66. package/dist/esm/SwiperItem.js +64 -0
  67. package/dist/esm/Switch/style/index.js +1 -0
  68. package/dist/esm/Switch.js +85 -0
  69. package/dist/esm/Tabbar/style/index.js +1 -0
  70. package/dist/esm/TabbarItem/style/index.js +1 -0
  71. package/dist/esm/Tag/style/index.js +1 -0
  72. package/dist/esm/TextArea/style/index.js +1 -0
  73. package/dist/esm/Toast/style/index.js +1 -0
  74. package/dist/esm/Uploader/style/index.js +1 -0
  75. package/dist/esm/UserContext-b4181162.js +3 -0
  76. package/dist/esm/UserContext-be8097d2.js +3 -0
  77. package/dist/esm/date-649fe493.js +112 -0
  78. package/dist/esm/nutui-react.es.js +13 -0
  79. package/dist/esm/types/src/packages/calendar/calendar.d.ts +14 -0
  80. package/dist/esm/types/src/packages/calendar/index.d.ts +2 -0
  81. package/dist/esm/types/src/packages/calendaritem/calendaritem.d.ts +17 -0
  82. package/dist/esm/types/src/packages/calendaritem/index.d.ts +2 -0
  83. package/dist/esm/types/src/packages/dialog/Confirm.d.ts +7 -0
  84. package/dist/esm/types/src/packages/dialog/Content.d.ts +10 -0
  85. package/dist/esm/types/src/packages/dialog/DialogWrap.d.ts +11 -0
  86. package/dist/esm/types/src/packages/dialog/DialogWrapper.d.ts +8 -0
  87. package/dist/esm/types/src/packages/dialog/Mask.d.ts +3 -0
  88. package/dist/esm/types/src/packages/dialog/config.d.ts +46 -0
  89. package/dist/esm/types/src/packages/dialog/dialog.d.ts +2 -0
  90. package/dist/esm/types/src/packages/dialog/index.d.ts +2 -0
  91. package/dist/esm/types/src/packages/drag/drag.d.ts +1 -1
  92. package/dist/esm/types/src/packages/nutui.react.build.d.ts +14 -1
  93. package/dist/esm/types/src/packages/nutui.react.d.ts +14 -1
  94. package/dist/esm/types/src/packages/picker/index.d.ts +2 -0
  95. package/dist/esm/types/src/packages/picker/picker.d.ts +19 -0
  96. package/dist/esm/types/src/packages/picker/pickerSlot.d.ts +10 -0
  97. package/dist/esm/types/src/packages/popover/Trigger.d.ts +21 -0
  98. package/dist/esm/types/src/packages/popover/index.d.ts +2 -0
  99. package/dist/esm/types/src/packages/popover/popover.d.ts +13 -0
  100. package/dist/esm/types/src/packages/row/UserContext.d.ts +1 -0
  101. package/dist/esm/types/src/packages/shortpassword/index.d.ts +2 -0
  102. package/dist/esm/types/src/packages/shortpassword/shortpassword.d.ts +21 -0
  103. package/dist/esm/types/src/packages/steps/UserContext.d.ts +1 -0
  104. package/dist/esm/types/src/packages/swiper/UserContext.d.ts +2 -0
  105. package/dist/esm/types/src/packages/swiper/index.d.ts +2 -0
  106. package/dist/esm/types/src/packages/swiper/swiper.d.ts +26 -0
  107. package/dist/esm/types/src/packages/swiperitem/index.d.ts +2 -0
  108. package/dist/esm/types/src/packages/swiperitem/swiperitem.d.ts +7 -0
  109. package/dist/nutui.react.es.js +7931 -1574
  110. package/dist/nutui.react.umd.js +26 -17
  111. package/dist/packages/actionsheet/actionsheet.scss +1 -0
  112. package/dist/packages/address/address.scss +3 -0
  113. package/dist/packages/backtop/backtop.scss +1 -0
  114. package/dist/packages/button/button.scss +1 -1
  115. package/dist/packages/calendar/calendar.scss +199 -0
  116. package/dist/packages/calendaritem/calendaritem.scss +191 -0
  117. package/dist/packages/dialog/dialog.scss +128 -0
  118. package/dist/packages/drag/drag.scss +2 -1
  119. package/dist/packages/fixednav/fixednav.scss +3 -0
  120. package/dist/packages/icon/icon.scss +1 -1
  121. package/dist/packages/picker/picker.scss +104 -0
  122. package/dist/packages/popover/popover.scss +142 -0
  123. package/dist/packages/popup/popup.scss +2 -0
  124. package/dist/packages/shortpassword/shortpassword.scss +115 -0
  125. package/dist/packages/swiper/swiper.scss +45 -0
  126. package/dist/packages/swiperitem/swiperitem.scss +3 -0
  127. package/dist/style.css +1 -1
  128. package/dist/style.es.js +1 -1
  129. package/dist/styles/themes/default.scss +10 -0
  130. package/dist/styles/variables.scss +25 -0
  131. package/package.json +8 -3
package/dist/esm/Drag.js CHANGED
@@ -1,17 +1,20 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
1
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["attract", "direction", "boundary", "children", "className"];
4
+ var _excluded = ["attract", "direction", "boundary", "children", "className", "style"];
4
5
 
5
6
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
7
 
7
8
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
9
 
9
- import React__default, { useRef, useEffect } from 'react';
10
+ import React__default, { useState, useRef, useEffect } from 'react';
10
11
  import { c as cn } from './bem-893ad28d.js';
12
+ import { useDrag } from '@use-gesture/react';
13
+ import { useSpring, animated } from '@react-spring/web';
11
14
  import '@bem-react/classname';
12
15
  var defaultProps = {
13
16
  attract: false,
14
- direction: 'all',
17
+ direction: undefined,
15
18
  boundary: {
16
19
  top: 0,
17
20
  left: 0,
@@ -28,163 +31,122 @@ var Drag = function Drag(props) {
28
31
  boundary = _defaultProps$props.boundary,
29
32
  children = _defaultProps$props.children,
30
33
  className = _defaultProps$props.className,
34
+ style = _defaultProps$props.style,
31
35
  reset = _objectWithoutProperties(_defaultProps$props, _excluded);
32
36
 
33
37
  var b = cn('drag');
34
- var elWidth = useRef(0);
35
- var elHeight = useRef(0);
36
- var screenWidth = useRef(0);
37
- var screenHeight = useRef(0);
38
- var startTop = useRef(0);
39
- var startLeft = useRef(0);
40
- useRef(0);
41
- useRef(0);
42
- var xPum = useRef(0);
43
- var yPum = useRef(0);
44
- var position = useRef({
45
- x: 0,
46
- y: 0
38
+
39
+ var _useState = useState(boundary),
40
+ _useState2 = _slicedToArray(_useState, 2),
41
+ boundaryState = _useState2[0],
42
+ setBoundaryState = _useState2[1];
43
+
44
+ var myDrag = useRef(null);
45
+
46
+ var _useSpring = useSpring(function () {
47
+ return {
48
+ x: 0,
49
+ y: 0
50
+ };
51
+ }),
52
+ _useSpring2 = _slicedToArray(_useSpring, 2),
53
+ currstyle = _useSpring2[0],
54
+ api = _useSpring2[1];
55
+
56
+ var screen = useRef({
57
+ clientWidth: 0,
58
+ clientHeight: 0
47
59
  });
48
- useRef({
49
- top: 0,
50
- left: 0,
51
- right: 0,
52
- bottom: 0
60
+ var element = useRef({
61
+ offsetWidth: 0,
62
+ offsetHeight: 0
53
63
  });
54
- var myDrag = useRef(null);
55
64
 
56
65
  var getInfo = function getInfo() {
57
66
  var el = myDrag.current;
58
67
 
59
68
  if (el) {
60
- var domElem = document.documentElement;
61
- elWidth.current = el.offsetWidth;
62
- elHeight.current = el.offsetHeight;
63
- screenWidth.current = domElem.clientWidth;
64
- screenHeight.current = domElem.clientHeight;
65
- }
66
- };
67
-
68
- var goLeft = function goLeft(target) {
69
- if (boundary.left) {
70
- if (+target.style.left.split('px')[0] > boundary.left) {
71
- target.style.left = +target.style.left.split('px')[0] - 10 + 'px';
72
- window.requestAnimationFrame(function () {
73
- goLeft(target);
74
- });
75
- } else {
76
- target.style.left = "".concat(boundary.left, "px");
77
- }
78
- } else {
79
- if (+target.style.left.split('px')[0] > 10) {
80
- target.style.left = +target.style.left.split('px')[0] - 10 + 'px';
81
- window.requestAnimationFrame(function () {
82
- goLeft(target);
83
- });
84
- } else {
85
- target.style.left = '0px';
86
- }
87
- }
88
- };
89
-
90
- var goRight = function goRight(target, rightLocation) {
91
- if (rightLocation - parseInt(target.style.left.split('px')[0]) > 10) {
92
- target.style.left = parseInt(target.style.left.split('px')[0]) + 10 + 'px';
93
- window.requestAnimationFrame(function () {
94
- goRight(target, rightLocation);
69
+ var offsetWidth = el.offsetWidth,
70
+ offsetHeight = el.offsetHeight,
71
+ offsetTop = el.offsetTop,
72
+ offsetLeft = el.offsetLeft;
73
+ var _document$documentEle = document.documentElement,
74
+ clientWidth = _document$documentEle.clientWidth,
75
+ clientHeight = _document$documentEle.clientHeight;
76
+ var top = boundary.top,
77
+ left = boundary.left,
78
+ bottom = boundary.bottom,
79
+ right = boundary.right;
80
+ element.current = {
81
+ offsetWidth: offsetWidth,
82
+ offsetHeight: offsetHeight
83
+ };
84
+ screen.current = {
85
+ clientWidth: clientWidth,
86
+ clientHeight: clientHeight
87
+ };
88
+ setBoundaryState({
89
+ top: -offsetTop + top,
90
+ left: -offsetLeft + left,
91
+ bottom: clientHeight - offsetHeight - offsetTop - bottom,
92
+ right: clientWidth - offsetWidth - offsetLeft - right
95
93
  });
96
- } else {
97
- target.style.left = rightLocation + 'px';
98
- }
99
- };
100
-
101
- var touchMove = function touchMove(e) {
102
- e.preventDefault();
103
- var target = e.currentTarget;
104
-
105
- if (e.targetTouches.length === 1) {
106
- var touch = e.targetTouches[0];
107
- var x = touch.clientX - position.current.x;
108
- var y = touch.clientY - position.current.y;
109
- xPum.current = startLeft.current + x;
110
- yPum.current = startTop.current + y;
111
- var rightLocation = screenWidth.current - elWidth.current - boundary.right;
112
-
113
- if (Math.abs(xPum.current) > rightLocation) {
114
- xPum.current = rightLocation;
115
- } else if (xPum.current <= boundary.left) {
116
- xPum.current = boundary.left;
117
- }
118
-
119
- if (yPum.current < boundary.top) {
120
- yPum.current = boundary.top;
121
- } else if (yPum.current > screenHeight.current - elHeight.current - boundary.bottom) {
122
- yPum.current = screenHeight.current - elHeight.current - boundary.bottom;
123
- }
124
-
125
- if (props.direction != 'y') {
126
- target.style.left = "".concat(xPum.current, "px");
127
- }
128
-
129
- if (props.direction != 'x') {
130
- target.style.top = "".concat(yPum.current, "px");
131
- }
132
94
  }
133
95
  };
134
96
 
135
- var touchEnd = function touchEnd(e) {
136
- var target = e.currentTarget;
137
- var touch = e.changedTouches[0];
138
- var currX = touch.clientX;
139
- var rightLocation = screenWidth.current - elWidth.current - boundary.right;
140
-
141
- if (currX > rightLocation) {
142
- currX = rightLocation;
143
- } else if (currX < boundary.left) {
144
- currX = boundary.left;
145
- } else {
146
- currX = currX < screenWidth.current / 2 ? boundary.left : rightLocation;
147
- }
148
-
149
- if (props.direction != 'y' && props.attract) {
150
- if (currX < screenWidth.current / 2) {
151
- window.requestAnimationFrame(function () {
152
- goLeft(target);
153
- });
154
- } else {
155
- window.requestAnimationFrame(function () {
156
- goRight(target, rightLocation);
157
- });
97
+ var bind = useDrag(function (_ref) {
98
+ var down = _ref.down,
99
+ last = _ref.last,
100
+ _ref$offset = _slicedToArray(_ref.offset, 2),
101
+ x = _ref$offset[0],
102
+ y = _ref$offset[1];
103
+
104
+ api.start({
105
+ x: x,
106
+ y: y,
107
+ immediate: down
108
+ });
109
+
110
+ if (last) {
111
+ if (props.direction != 'y' && props.attract) {
112
+ if (x < (screen.current.clientWidth - element.current.offsetWidth) / 2) {
113
+ console.log(x);
114
+ window.requestAnimationFrame(function () {
115
+ api.start({
116
+ x: boundaryState.left,
117
+ y: y,
118
+ immediate: down
119
+ });
120
+ });
121
+ } else {
122
+ window.requestAnimationFrame(function () {
123
+ api.start({
124
+ x: screen.current.clientWidth - element.current.offsetWidth + boundaryState.left,
125
+ y: y,
126
+ immediate: down
127
+ });
128
+ });
129
+ }
158
130
  }
159
131
  }
160
- };
161
-
162
- var touchStart = function touchStart(e) {
163
- var target = e.currentTarget;
164
- var touches = e.touches[0];
165
- startTop.current = target.offsetTop;
166
- startLeft.current = target.offsetLeft;
167
- position.current = {
168
- x: touches.clientX,
169
- y: touches.clientY
170
- };
171
- target.removeEventListener('touchmove', touchMove, false);
172
- target.removeEventListener('touchend', touchEnd, false);
173
- target.addEventListener('touchmove', touchMove, false);
174
- target.addEventListener('touchend', touchEnd, false);
175
- };
176
-
132
+ }, {
133
+ from: function from() {
134
+ return [currstyle.x.get(), currstyle.y.get()];
135
+ },
136
+ axis: direction,
137
+ bounds: boundaryState
138
+ });
177
139
  useEffect(function () {
178
140
  getInfo();
179
- }, []);
141
+ }, [myDrag]);
180
142
  return React__default.createElement("div", _objectSpread(_objectSpread({
143
+ style: style,
181
144
  className: "".concat(b(), " ").concat(className)
182
145
  }, reset), {}, {
183
- ref: myDrag,
184
- onTouchStart: function onTouchStart(event) {
185
- return touchStart(event);
186
- }
187
- }), children);
146
+ ref: myDrag
147
+ }), React__default.createElement(animated.div, _objectSpread({
148
+ style: currstyle
149
+ }, bind()), children));
188
150
  };
189
151
 
190
152
  Drag.defaultProps = defaultProps;
@@ -0,0 +1 @@
1
+ import '../../../packages/elevator/elevator.scss'
@@ -120,13 +120,7 @@ var Elevator = function Elevator(props) {
120
120
  });
121
121
  scrollTo(index);
122
122
  var target = e.currentTarget;
123
- target.removeEventListener('touchmove', function () {
124
- return touchMove(e);
125
- }, false);
126
123
  target.removeEventListener('touchend', touchEnd, false);
127
- target.addEventListener('touchmove', function () {
128
- return touchMove(e);
129
- }, false);
130
124
  target.addEventListener('touchend', touchEnd, false);
131
125
  };
132
126
 
@@ -185,6 +179,9 @@ var Elevator = function Elevator(props) {
185
179
  className: b('bars'),
186
180
  onTouchStart: function onTouchStart(event) {
187
181
  return touchStart(event);
182
+ },
183
+ onTouchMove: function onTouchMove(event) {
184
+ return touchMove(event);
188
185
  }
189
186
  }, React__default.createElement("div", {
190
187
  className: b('bars__inner')
@@ -0,0 +1 @@
1
+ import '../../../packages/fixednav/fixednav.scss'
@@ -0,0 +1 @@
1
+ import '../../../packages/icon/icon.scss'
@@ -0,0 +1 @@
1
+ import '../../../packages/infiniteloading/infiniteloading.scss'
@@ -0,0 +1 @@
1
+ import '../../../packages/input/input.scss'
package/dist/esm/Input.js CHANGED
@@ -7,7 +7,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
7
7
 
8
8
  import React__default, { useState, useEffect } from 'react';
9
9
  import { c as cn } from './bem-893ad28d.js';
10
- import { I as Icon } from './icon-63c0d58f.js';
10
+ import Icon from './Icon.js';
11
11
  import '@bem-react/classname';
12
12
 
13
13
  function trimExtraChar(value, _char, regExp) {
@@ -0,0 +1 @@
1
+ import '../../../packages/inputnumber/inputnumber.scss'
@@ -0,0 +1 @@
1
+ import '../../../packages/layout/layout.scss'
@@ -0,0 +1 @@
1
+ import '../../../packages/navbar/navbar.scss'
@@ -0,0 +1 @@
1
+ import '../../../packages/noticebar/noticebar.scss'
@@ -0,0 +1 @@
1
+ import '../../../packages/notify/notify.scss'
@@ -0,0 +1 @@
1
+ import '../../../packages/overlay/overlay.scss'
@@ -0,0 +1 @@
1
+ import '../../../packages/pagination/pagination.scss'
@@ -0,0 +1 @@
1
+ import '../../../packages/picker/picker.scss'