@nutui/nutui-react 1.3.5-beta.1 → 1.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/esm/ActionSheet.js +15 -25
- package/dist/esm/Address.js +151 -221
- package/dist/esm/AnimatingNumbers.js +7 -31
- package/dist/esm/Audio.js +31 -66
- package/dist/esm/Avatar.js +25 -51
- package/dist/esm/AvatarGroup.js +2 -9
- package/dist/esm/BackTop.js +29 -55
- package/dist/esm/Badge.js +9 -20
- package/dist/esm/Barrage.js +8 -20
- package/dist/esm/Button.js +22 -37
- package/dist/esm/Calendar.js +23 -37
- package/dist/esm/CalendarItem.js +86 -186
- package/dist/esm/Card.js +14 -20
- package/dist/esm/Cascader.js +77 -197
- package/dist/esm/Cell.js +20 -30
- package/dist/esm/CellGroup.js +6 -12
- package/dist/esm/Checkbox.js +27 -48
- package/dist/esm/CheckboxGroup.js +12 -30
- package/dist/esm/CircleProgress.js +11 -28
- package/dist/esm/Col.js +11 -22
- package/dist/esm/Collapse.js +11 -27
- package/dist/esm/CollapseItem.js +33 -47
- package/dist/esm/ConfigProvider.js +4 -15
- package/dist/esm/CountDown.js +37 -74
- package/dist/esm/DatePicker.js +44 -106
- package/dist/esm/Dialog.js +31 -89
- package/dist/esm/Divider.js +8 -15
- package/dist/esm/Drag.js +30 -45
- package/dist/esm/Elevator.js +37 -74
- package/dist/esm/Empty.js +11 -24
- package/dist/esm/FixedNav.js +18 -29
- package/dist/esm/Grid.js +13 -28
- package/dist/esm/GridItem.js +18 -34
- package/dist/esm/ImagePreview.js +36 -71
- package/dist/esm/Indicator.js +9 -20
- package/dist/esm/Infiniteloading.js +26 -55
- package/dist/esm/Input.js +62 -106
- package/dist/esm/InputNumber.js +25 -52
- package/dist/esm/Layout.js +0 -6
- package/dist/esm/Menu.js +24 -46
- package/dist/esm/MenuItem.js +29 -52
- package/dist/esm/NavBar.js +18 -34
- package/dist/esm/NoticeBar.js +54 -102
- package/dist/esm/Notify.js +9 -38
- package/dist/esm/NumberKeyboard.js +21 -52
- package/dist/esm/Pagination.js +38 -71
- package/dist/esm/Picker.js +91 -178
- package/dist/esm/Popover.js +32 -72
- package/dist/esm/Popup.js +40 -72
- package/dist/esm/Price.js +7 -24
- package/dist/esm/Progress.js +35 -50
- package/dist/esm/PullToRefresh.js +28 -83
- package/dist/esm/Radio.js +24 -47
- package/dist/esm/RadioGroup.js +14 -24
- package/dist/esm/Range.js +44 -116
- package/dist/esm/Rate.js +21 -39
- package/dist/esm/Row.js +7 -16
- package/dist/esm/SearchBar.js +47 -68
- package/dist/esm/ShortPassword.js +29 -56
- package/dist/esm/SideNavBar.js +9 -16
- package/dist/esm/SideNavBarItem.js +4 -11
- package/dist/esm/Signature.js +13 -43
- package/dist/esm/Skeleton.js +13 -23
- package/dist/esm/Step.js +12 -28
- package/dist/esm/Steps.js +6 -14
- package/dist/esm/Sticky.js +24 -52
- package/dist/esm/SubSideNavBar.js +7 -22
- package/dist/esm/Swipe.js +15 -54
- package/dist/esm/Swiper.js +102 -186
- package/dist/esm/SwiperItem.js +2 -12
- package/dist/esm/Switch.js +13 -27
- package/dist/esm/Tabbar.js +13 -25
- package/dist/esm/TabbarItem.js +15 -23
- package/dist/esm/Table.js +19 -39
- package/dist/esm/Tag.js +19 -36
- package/dist/esm/TextArea.js +19 -43
- package/dist/esm/TimeDetail.js +15 -28
- package/dist/esm/TimePannel.js +5 -12
- package/dist/esm/TimeSelect.js +35 -59
- package/dist/esm/Toast.js +16 -49
- package/dist/esm/Uploader.js +57 -152
- package/dist/esm/Video.js +8 -19
- package/dist/esm/VirtualList.js +84 -118
- package/dist/esm/date-710f8c7c.js +9 -33
- package/dist/esm/get-scroll-parent-3dcd3f53.js +1 -9
- package/dist/esm/icon-8dc4de10.js +11 -21
- package/dist/esm/offsetContext-0e3d04b3.js +0 -3
- package/dist/esm/overlay-ed3eb37d.js +12 -23
- package/dist/esm/render-18227751.js +0 -11
- package/dist/esm/tabpane-c957ab14.js +4 -10
- package/dist/esm/tabs-0896a61b.js +28 -56
- package/dist/esm/types/src/packages/elevator/demo.d.ts +1 -0
- package/dist/esm/types/src/packages/searchbar/searchbar.d.ts +2 -0
- package/dist/esm/useClientRect-839d18c5.js +0 -5
- package/dist/esm/useTouch-a2ea68c6.js +27 -47
- package/dist/locales/base.js +1 -1
- package/dist/locales/en-US.js +1 -1
- package/dist/locales/id-ID.js +1 -1
- package/dist/locales/zh-CN.js +1 -1
- package/dist/locales/zh-TW.js +1 -1
- package/dist/nutui.react.es.js +424 -406
- package/dist/nutui.react.umd.js +416 -398
- package/dist/packages/searchbar/searchbar.scss +20 -3
- package/dist/style.css +1 -1
- package/dist/style.es.js +1 -1
- package/dist/types/index.d.ts +2 -0
- package/package.json +1 -1
package/dist/esm/Swipe.js
CHANGED
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
|
|
4
3
|
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; }
|
|
5
|
-
|
|
6
4
|
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
|
-
|
|
8
5
|
import React__default, { forwardRef, useRef, useState, useMemo, useCallback, useImperativeHandle, useEffect } from 'react';
|
|
9
6
|
import { c as cn } from './bem-893ad28d.js';
|
|
10
7
|
import { u as useTouch } from './useTouch-a2ea68c6.js';
|
|
11
8
|
import { g as getRect } from './useClientRect-839d18c5.js';
|
|
12
9
|
import '@bem-react/classname';
|
|
13
|
-
|
|
14
10
|
function preventDefault(event, isStopPropagation) {
|
|
15
11
|
if (typeof event.cancelable !== 'boolean' || event.cancelable) {
|
|
16
12
|
event.preventDefault();
|
|
17
13
|
}
|
|
18
|
-
|
|
19
14
|
if (isStopPropagation) {
|
|
20
15
|
event.stopPropagation();
|
|
21
16
|
}
|
|
22
17
|
}
|
|
23
|
-
|
|
24
18
|
var defaultProps = {
|
|
25
19
|
name: '',
|
|
26
20
|
leftWidth: 0,
|
|
@@ -29,33 +23,28 @@ var defaultProps = {
|
|
|
29
23
|
var Swipe = forwardRef(function (props, instanceRef) {
|
|
30
24
|
var swipeBem = cn('swipe');
|
|
31
25
|
var touch = useTouch();
|
|
32
|
-
|
|
33
26
|
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
children = _defaultProps$props.children,
|
|
28
|
+
className = _defaultProps$props.className,
|
|
29
|
+
style = _defaultProps$props.style;
|
|
38
30
|
var root = useRef();
|
|
39
31
|
var opened = useRef(false);
|
|
40
32
|
var lockClick = useRef(false);
|
|
41
33
|
var startOffset = useRef(0);
|
|
42
|
-
|
|
43
34
|
var _useState = useState({
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
35
|
+
offset: 0,
|
|
36
|
+
dragging: false
|
|
37
|
+
}),
|
|
38
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
39
|
+
state = _useState2[0],
|
|
40
|
+
setState = _useState2[1];
|
|
51
41
|
var _useState3 = useState({
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
42
|
+
left: 0,
|
|
43
|
+
right: 0
|
|
44
|
+
}),
|
|
45
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
46
|
+
actionWidth = _useState4[0],
|
|
47
|
+
setActionWidth = _useState4[1];
|
|
59
48
|
var wrapperStyle = {
|
|
60
49
|
transform: "translate3d(".concat(state.offset, "px, 0, 0)"),
|
|
61
50
|
transitionDuration: state.dragging ? '0s' : '.6s'
|
|
@@ -66,39 +55,30 @@ var Swipe = forwardRef(function (props, instanceRef) {
|
|
|
66
55
|
var rightWidth = useMemo(function () {
|
|
67
56
|
return props.rightWidth ? props.rightWidth : actionWidth.right;
|
|
68
57
|
}, [props.rightWidth, actionWidth.right]);
|
|
69
|
-
|
|
70
58
|
var _onTouchStart = function onTouchStart(event) {
|
|
71
59
|
if (!props.disabled) {
|
|
72
60
|
startOffset.current = state.offset;
|
|
73
61
|
touch.start(event);
|
|
74
62
|
}
|
|
75
63
|
};
|
|
76
|
-
|
|
77
64
|
var _onTouchMove = function onTouchMove(event) {
|
|
78
65
|
if (props.disabled) {
|
|
79
66
|
return;
|
|
80
67
|
}
|
|
81
|
-
|
|
82
68
|
touch.move(event);
|
|
83
|
-
|
|
84
69
|
if (touch.isHorizontal()) {
|
|
85
70
|
lockClick.current = true;
|
|
86
|
-
|
|
87
71
|
var newState = _objectSpread(_objectSpread({}, state), {}, {
|
|
88
72
|
dragging: true
|
|
89
73
|
});
|
|
90
|
-
|
|
91
74
|
var isEdge = !opened || touch.deltaX * startOffset.current < 0;
|
|
92
|
-
|
|
93
75
|
if (isEdge) {
|
|
94
76
|
preventDefault(event, true);
|
|
95
77
|
}
|
|
96
|
-
|
|
97
78
|
newState.offset = rangeCalculation(touch.deltaX + startOffset.current, -rightWidth, leftWidth);
|
|
98
79
|
setState(newState);
|
|
99
80
|
}
|
|
100
81
|
};
|
|
101
|
-
|
|
102
82
|
var onTouchEnd = function onTouchEnd() {
|
|
103
83
|
if (state.dragging) {
|
|
104
84
|
setState(function (v) {
|
|
@@ -112,23 +92,19 @@ var Swipe = forwardRef(function (props, instanceRef) {
|
|
|
112
92
|
}, 0);
|
|
113
93
|
}
|
|
114
94
|
};
|
|
115
|
-
|
|
116
95
|
var toggle = function toggle(side) {
|
|
117
96
|
var offset = Math.abs(state.offset);
|
|
118
97
|
var base = 0.3;
|
|
119
98
|
var baseNum = opened ? 1 - base : base;
|
|
120
99
|
var width = side === 'left' ? leftWidth : rightWidth;
|
|
121
|
-
|
|
122
100
|
if (width && offset > Number(width) * baseNum) {
|
|
123
101
|
open(side);
|
|
124
102
|
} else {
|
|
125
103
|
_close(side);
|
|
126
104
|
}
|
|
127
105
|
};
|
|
128
|
-
|
|
129
106
|
var open = function open(side) {
|
|
130
107
|
var _props$onOpen;
|
|
131
|
-
|
|
132
108
|
opened.current = true;
|
|
133
109
|
var offset = side === 'left' ? leftWidth : -rightWidth;
|
|
134
110
|
var name = props.name;
|
|
@@ -142,38 +118,31 @@ var Swipe = forwardRef(function (props, instanceRef) {
|
|
|
142
118
|
});
|
|
143
119
|
});
|
|
144
120
|
};
|
|
145
|
-
|
|
146
121
|
var _close = function close(position) {
|
|
147
122
|
if (opened.current) {
|
|
148
123
|
var _props$onClose;
|
|
149
|
-
|
|
150
124
|
opened.current = false;
|
|
151
125
|
(_props$onClose = props.onClose) === null || _props$onClose === void 0 ? void 0 : _props$onClose.call(props, {
|
|
152
126
|
name: props.name,
|
|
153
127
|
position: position || 'left'
|
|
154
128
|
});
|
|
155
129
|
}
|
|
156
|
-
|
|
157
130
|
setState(function (v) {
|
|
158
131
|
return _objectSpread(_objectSpread({}, v), {}, {
|
|
159
132
|
offset: 0
|
|
160
133
|
});
|
|
161
134
|
});
|
|
162
135
|
};
|
|
163
|
-
|
|
164
136
|
var rangeCalculation = function rangeCalculation(num, min, max) {
|
|
165
137
|
return Math.min(Math.max(Number(num), Number(min)), Number(max));
|
|
166
138
|
};
|
|
167
|
-
|
|
168
139
|
var getNodeWidth = function getNodeWidth(node) {
|
|
169
140
|
if (node) {
|
|
170
141
|
var ele = getRect(node);
|
|
171
142
|
return ele.width;
|
|
172
143
|
}
|
|
173
|
-
|
|
174
144
|
return 0;
|
|
175
145
|
};
|
|
176
|
-
|
|
177
146
|
var leftRef = useCallback(function (node) {
|
|
178
147
|
if (node !== null) {
|
|
179
148
|
setActionWidth(function (v) {
|
|
@@ -192,7 +161,6 @@ var Swipe = forwardRef(function (props, instanceRef) {
|
|
|
192
161
|
});
|
|
193
162
|
}
|
|
194
163
|
}, [props.rightAction]);
|
|
195
|
-
|
|
196
164
|
var renderActionContent = function renderActionContent(side, measuredRef) {
|
|
197
165
|
if (props["".concat(side, "Action")]) {
|
|
198
166
|
return React__default.createElement("div", {
|
|
@@ -203,20 +171,16 @@ var Swipe = forwardRef(function (props, instanceRef) {
|
|
|
203
171
|
}
|
|
204
172
|
}, props["".concat(side, "Action")]);
|
|
205
173
|
}
|
|
206
|
-
|
|
207
174
|
return null;
|
|
208
175
|
};
|
|
209
|
-
|
|
210
176
|
var handleOperate = function handleOperate(event, position) {
|
|
211
177
|
event.stopPropagation();
|
|
212
|
-
|
|
213
178
|
if (props.beforeClose) {
|
|
214
179
|
props.beforeClose(position);
|
|
215
180
|
} else {
|
|
216
181
|
props.onActionClick && props.onActionClick(event, position);
|
|
217
182
|
}
|
|
218
183
|
};
|
|
219
|
-
|
|
220
184
|
useImperativeHandle(instanceRef, function () {
|
|
221
185
|
return {
|
|
222
186
|
open: open,
|
|
@@ -228,17 +192,14 @@ var Swipe = forwardRef(function (props, instanceRef) {
|
|
|
228
192
|
useEffect(function () {
|
|
229
193
|
var handler = function handler(event) {
|
|
230
194
|
var targets = [root];
|
|
231
|
-
|
|
232
195
|
if (targets.some(function (targetItem) {
|
|
233
196
|
var targetElement = targetItem.current || targetItem;
|
|
234
197
|
return !targetElement || (targetElement === null || targetElement === void 0 ? void 0 : targetElement.contains(event.target));
|
|
235
198
|
})) {
|
|
236
199
|
return;
|
|
237
200
|
}
|
|
238
|
-
|
|
239
201
|
_close();
|
|
240
202
|
};
|
|
241
|
-
|
|
242
203
|
document.addEventListener('touchstart', handler);
|
|
243
204
|
return function () {
|
|
244
205
|
document.removeEventListener('touchstart', handler);
|