@nutui/nutui-react-taro 1.5.2 → 1.5.3-beta.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.
- package/CHANGELOG.md +0 -1
- package/dist/esm/ActionSheet.js +14 -90
- package/dist/esm/Address.js +21 -620
- package/dist/esm/Animate.js +7 -53
- package/dist/esm/AnimatingNumbers.js +7 -125
- package/dist/esm/Audio.js +19 -264
- package/dist/esm/Avatar.js +11 -130
- package/dist/esm/{AvatarContext-15733596.js → AvatarContext-c96afdcc.js} +3 -1
- package/dist/esm/AvatarGroup.js +11 -41
- package/dist/esm/BackTop.js +10 -138
- package/dist/esm/Badge.js +9 -71
- package/dist/esm/Barrage.js +8 -97
- package/dist/esm/Button.js +9 -108
- package/dist/esm/Calendar.js +20 -128
- package/dist/esm/CalendarItem.js +12 -674
- package/dist/esm/Card.js +11 -61
- package/dist/esm/Cascader.js +16 -671
- package/dist/esm/Cell.js +9 -101
- package/dist/esm/CellGroup.js +5 -2
- package/dist/esm/Checkbox.js +7 -5
- package/dist/esm/CheckboxGroup.js +8 -111
- package/dist/esm/CircleProgress.js +8 -114
- package/dist/esm/Col.js +7 -57
- package/dist/esm/Collapse.js +7 -97
- package/dist/esm/CollapseItem.js +8 -146
- package/dist/esm/ConfigProvider.js +8 -187
- package/dist/esm/CountDown.js +9 -247
- package/dist/esm/DatePicker.js +25 -309
- package/dist/esm/Dialog.js +17 -296
- package/dist/esm/Divider.js +7 -34
- package/dist/esm/Drag.js +7 -118
- package/dist/esm/Elevator.js +8 -234
- package/dist/esm/Ellipsis.js +10 -176
- package/dist/esm/Empty.js +8 -79
- package/dist/esm/FixedNav.js +14 -103
- package/dist/esm/Form.js +10 -215
- package/dist/esm/FormItem.js +10 -3
- package/dist/esm/Grid.js +11 -81
- package/dist/esm/GridItem.js +13 -123
- package/dist/esm/Icon.js +5 -2
- package/dist/esm/Image.js +11 -169
- package/dist/esm/ImagePreview.js +19 -225
- package/dist/esm/Indicator.js +7 -50
- package/dist/esm/Infiniteloading.js +14 -215
- package/dist/esm/Input.js +12 -362
- package/dist/esm/InputNumber.js +9 -275
- package/dist/esm/Layout.js +5 -13
- package/dist/esm/Menu.js +10 -153
- package/dist/esm/MenuItem.js +15 -175
- package/dist/esm/NavBar.js +9 -114
- package/dist/esm/NoticeBar.js +10 -568
- package/dist/esm/Notify.js +8 -234
- package/dist/esm/NumberKeyboard.js +17 -247
- package/dist/esm/Overlay.js +6 -2
- package/dist/esm/Pagination.js +9 -168
- package/dist/esm/Picker.js +22 -494
- package/dist/esm/Popover.js +12 -223
- package/dist/esm/Popup.js +13 -193
- package/dist/esm/Price.js +6 -84
- package/dist/esm/Progress.js +9 -122
- package/dist/esm/PullToRefresh.js +13 -276
- package/dist/esm/Radio.js +8 -4
- package/dist/esm/RadioGroup.js +7 -120
- package/dist/esm/Range.js +15 -406
- package/dist/esm/Rate.js +9 -121
- package/dist/esm/Row.js +7 -49
- package/dist/esm/SearchBar.js +12 -235
- package/dist/esm/ShortPassword.js +17 -191
- package/dist/esm/SideNavBar.js +19 -57
- package/dist/esm/SideNavBarItem.js +5 -24
- package/dist/esm/Signature.js +13 -153
- package/dist/esm/Skeleton.js +12 -98
- package/dist/esm/Step.js +10 -87
- package/dist/esm/Steps.js +8 -38
- package/dist/esm/Sticky.js +11 -190
- package/dist/esm/SubSideNavBar.js +6 -78
- package/dist/esm/Swipe.js +10 -230
- package/dist/esm/Swiper.js +9 -490
- package/dist/esm/SwiperItem.js +8 -36
- package/dist/esm/Switch.js +6 -71
- package/dist/esm/TabPane.js +5 -2
- package/dist/esm/Tabbar.js +6 -68
- package/dist/esm/TabbarItem.js +9 -78
- package/dist/esm/Table.js +12 -140
- package/dist/esm/Tabs.js +8 -5
- package/dist/esm/Tag.js +10 -110
- package/dist/esm/TextArea.js +9 -148
- package/dist/esm/TimeDetail.js +9 -67
- package/dist/esm/TimePannel.js +9 -29
- package/dist/esm/TimeSelect.js +19 -171
- package/dist/esm/Toast.js +7 -268
- package/dist/esm/TrendArrow.js +7 -99
- package/dist/esm/Uploader.js +17 -566
- package/dist/esm/{UserContext-101ad4a4.js → UserContext-0aac9a82.js} +3 -1
- package/dist/esm/{UserContext-2629d479.js → UserContext-e402e1a6.js} +3 -1
- package/dist/esm/{UserContext-b33bcf21.js → UserContext-e8176108.js} +3 -1
- package/dist/esm/Video.js +7 -90
- package/dist/esm/VirtualList.js +9 -313
- package/dist/esm/WaterMark.js +11 -111
- package/dist/esm/actionsheet.taro-e6a51446.js +53 -0
- package/dist/esm/address.taro-3a9b6396.js +461 -0
- package/dist/esm/animate.taro-fb7986d6.js +40 -0
- package/dist/esm/animatingnumbers.taro-03e5d61d.js +104 -0
- package/dist/esm/audio.taro-87ec8bf2.js +161 -0
- package/dist/esm/avatar.taro-3676f38f.js +103 -0
- package/dist/esm/avatargroup-f3574510.js +34 -0
- package/dist/esm/backtop.taro-66394a36.js +48 -0
- package/dist/esm/badge.taro-a4e59c11.js +52 -0
- package/dist/esm/barrage.taro-0495a1b2.js +94 -0
- package/dist/esm/{bem-3b438e61.js → bem-350c1702.js} +3 -6
- package/dist/esm/button.taro-9244d065.js +100 -0
- package/dist/esm/calendar.taro-670842ea.js +65 -0
- package/dist/esm/calendaritem.taro-2a603571.js +787 -0
- package/dist/esm/can-use-dom-3eeb5af4.js +6 -0
- package/dist/esm/card.taro-e4c76dad.js +33 -0
- package/dist/esm/cascader.taro-eb1fb011.js +438 -0
- package/dist/esm/cell.taro-a10a74d3.js +64 -0
- package/dist/esm/cellgroup.taro-abe501bc.js +25 -0
- package/dist/esm/checkbox.taro-6120e3e3.js +171 -0
- package/dist/esm/circleprogress.taro-79854448.js +109 -0
- package/dist/esm/col.taro-53eed3cc.js +41 -0
- package/dist/esm/collapse.taro-1a9e4ba2.js +83 -0
- package/dist/esm/collapseitem-4d0bc55d.js +83 -0
- package/dist/esm/configprovider-67d19d3a.js +19 -0
- package/dist/esm/configprovider.taro-8d71eb49.js +42 -0
- package/dist/esm/countdown.taro-5b17c607.js +226 -0
- package/dist/esm/datepicker.taro-6e9b4b8f.js +275 -0
- package/dist/esm/dialog.taro-a3267d29.js +118 -0
- package/dist/esm/divider.taro-26d1d8b4.js +35 -0
- package/dist/esm/drag.taro-79bb8744.js +110 -0
- package/dist/esm/elevator.taro-6019669e.js +178 -0
- package/dist/esm/ellipsis.taro-f15f26da.js +241 -0
- package/dist/esm/empty.taro-04ae4389.js +62 -0
- package/dist/esm/fixednav.taro-1f05acaf.js +53 -0
- package/dist/esm/form.taro-0c8e7a39.js +179 -0
- package/dist/esm/formitem.taro-190a3326.js +89 -0
- package/dist/esm/get-scroll-parent-b4a07e65.js +25 -0
- package/dist/esm/grid.taro-3503b82c.js +61 -0
- package/dist/esm/{grid.context-2ee27d95.js → grid.taro.context-c2bbfb4f.js} +4 -2
- package/dist/esm/griditem.taro-cdb3f119.js +98 -0
- package/dist/esm/icon-296a1bec.js +63 -0
- package/dist/esm/icon.taro-296a1bec.js +63 -0
- package/dist/esm/image.taro-142cf512.js +64 -0
- package/dist/esm/imagepreview.taro-c50bb0a3.js +167 -0
- package/dist/esm/index-5bcb0ff8.js +7 -0
- package/dist/esm/indicator.taro-cba8b010.js +37 -0
- package/dist/esm/infiniteloading.taro-183bccbf.js +144 -0
- package/dist/esm/input.taro-97af6c96.js +240 -0
- package/dist/esm/inputnumber.taro-91f65d17.js +130 -0
- package/dist/esm/layout.taro-9046d093.js +11 -0
- package/dist/esm/menu.taro-7e4038a1.js +99 -0
- package/dist/esm/menuitem.taro-96cc4f15.js +130 -0
- package/dist/esm/navbar.taro-777c4705.js +79 -0
- package/dist/esm/noticebar.taro-4a23cdee.js +448 -0
- package/dist/esm/notify.taro-e17c6f82.js +75 -0
- package/dist/esm/numberkeyboard.taro-1bc24744.js +159 -0
- package/dist/esm/nutui-react.es.js +119 -94
- package/dist/esm/offsetContext-c2a746fa.js +5 -0
- package/dist/esm/overlay.taro-21e87fb1.js +69 -0
- package/dist/esm/pagination.taro-715a173b.js +124 -0
- package/dist/esm/picker.taro-9ad1b7c5.js +473 -0
- package/dist/esm/popover.taro-ad5e76ea.js +156 -0
- package/dist/esm/popup.taro-01676bff.js +137 -0
- package/dist/esm/price.taro-776ed16e.js +83 -0
- package/dist/esm/progress.taro-f0ce38e9.js +90 -0
- package/dist/esm/pulltorefresh.taro-a294f656.js +181 -0
- package/dist/esm/radio.taro-a6eff96c.js +168 -0
- package/dist/esm/range.taro-d8fc7656.js +332 -0
- package/dist/esm/rate.taro-6cdf03bd.js +75 -0
- package/dist/esm/row.taro-f64d4a13.js +46 -0
- package/dist/esm/searchbar.taro-0c25927b.js +152 -0
- package/dist/esm/shortpassword.taro-9ee034f7.js +111 -0
- package/dist/esm/sidenavbar.taro-c307b35e.js +35 -0
- package/dist/esm/sidenavbaritem.taro-5a7965d0.js +12 -0
- package/dist/esm/signature.taro-ec4e713b.js +143 -0
- package/dist/esm/skeleton.taro-76faf63f.js +62 -0
- package/dist/esm/step.taro-b7903e8c.js +59 -0
- package/dist/esm/steps.taro-c82d2252.js +30 -0
- package/dist/esm/sticky.taro-218bda37.js +138 -0
- package/dist/esm/subsidenavbar.taro-69cb9752.js +63 -0
- package/dist/esm/supports-passive-c85ef996.js +18 -0
- package/dist/esm/swipe.taro-ea35f07f.js +177 -0
- package/dist/esm/swiper.taro-7a94e211.js +451 -0
- package/dist/esm/swiperitem-c9e3d0d5.js +29 -0
- package/dist/esm/switch.taro-34ca8228.js +50 -0
- package/dist/esm/tabbar.taro-9acfc2fa.js +59 -0
- package/dist/esm/tabbaritem.taro-bf517487.js +58 -0
- package/dist/esm/table.taro-91fc0c01.js +93 -0
- package/dist/esm/tabpane.taro-4ca340ef.js +23 -0
- package/dist/esm/tabs.taro-6a7524a4.js +140 -0
- package/dist/esm/tag.taro-23ba0834.js +92 -0
- package/dist/esm/textarea.taro-442e7350.js +94 -0
- package/dist/esm/timedetail.taro-5b2f2269.js +44 -0
- package/dist/esm/timepannel.taro-d6e40180.js +22 -0
- package/dist/esm/timeselect.taro-a07036f4.js +133 -0
- package/dist/esm/toast.taro-d6c14811.js +109 -0
- package/dist/esm/trendarrow.taro-b8c5ccd9.js +73 -0
- package/dist/esm/typings-b9828dba.js +9 -0
- package/dist/esm/uploader.taro-587e6bf3.js +492 -0
- package/dist/esm/useClientRect-1f8ed1fe.js +18 -0
- package/dist/esm/useTouch-db24bb5c.js +69 -0
- package/dist/esm/video-f1be8a91.js +67 -0
- package/dist/esm/virtuallist.taro-f0b0270d.js +214 -0
- package/dist/esm/watermark.taro-9ce2ae37.js +114 -0
- package/dist/esm/zh-CN-c779e6c1.js +131 -0
- 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/locales/zh-UG.js +1 -1
- package/dist/nutui.react.mjs +13030 -14863
- package/dist/nutui.react.umd.js +13029 -14864
- package/dist/style.mjs +1 -1
- package/dist/types/index.d.ts +176 -183
- package/package.json +1 -1
- package/dist/esm/cellgroup-fcc72767.js +0 -34
- package/dist/esm/checkbox-44e13cd0.js +0 -137
- package/dist/esm/date-c7aad4c0.js +0 -97
- package/dist/esm/formitem-8a73a5fb.js +0 -157
- package/dist/esm/get-scroll-parent-5f85dee8.js +0 -24
- package/dist/esm/icon-4ef1581c.js +0 -70
- package/dist/esm/index-030b7245.js +0 -11
- package/dist/esm/offsetContext-3ab00d40.js +0 -16
- package/dist/esm/overlay-de6c79d5.js +0 -83
- package/dist/esm/radio-9f141e6b.js +0 -118
- package/dist/esm/render-bbebb760.js +0 -79
- package/dist/esm/tabpane-01075e6c.js +0 -29
- package/dist/esm/tabs-e1b4e4b1.js +0 -181
- package/dist/esm/typings-f27b58f4.js +0 -8
- package/dist/esm/useClientRect-56bb675b.js +0 -39
- package/dist/esm/useTouch-cf73a407.js +0 -99
|
@@ -1,79 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import { O as OffsetContext, h as handleClick } from './offsetContext-3ab00d40.js';
|
|
8
|
-
var defaultProps = {
|
|
9
|
-
open: true
|
|
10
|
-
};
|
|
11
|
-
var SubSideNavBar = function SubSideNavBar(props) {
|
|
12
|
-
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
13
|
-
title = _defaultProps$props.title,
|
|
14
|
-
ikey = _defaultProps$props.ikey,
|
|
15
|
-
children = _defaultProps$props.children,
|
|
16
|
-
onClick = _defaultProps$props.onClick,
|
|
17
|
-
open = _defaultProps$props.open,
|
|
18
|
-
rest = _objectWithoutProperties(_defaultProps$props, _excluded);
|
|
19
|
-
// const offset = props.offset ? Number(props.offset) : 20
|
|
20
|
-
var offset = useContext(OffsetContext);
|
|
21
|
-
console.log('offset>>>>>>>', offset);
|
|
22
|
-
var listRef = useRef(null);
|
|
23
|
-
var setListLevel = useCallback(function (nodeList) {
|
|
24
|
-
var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
25
|
-
var titleClass = nodeList[0].className;
|
|
26
|
-
if (titleClass.includes('nut-subsidenavbar__title')) {
|
|
27
|
-
// const left = 15 + offset * level
|
|
28
|
-
var left = offset * (level + 1);
|
|
29
|
-
nodeList[0].style.paddingLeft = "".concat(left, "px");
|
|
30
|
-
}
|
|
31
|
-
var childNodes = nodeList[1] && nodeList[1].children && Array.from(nodeList[1].children).filter(function (item) {
|
|
32
|
-
return item.nodeType !== 3 && item.nodeType !== 8;
|
|
33
|
-
});
|
|
34
|
-
childNodes.forEach(function (item) {
|
|
35
|
-
var itemClass = item.className;
|
|
36
|
-
if (itemClass.includes('nut-subsidenavbar__item')) {
|
|
37
|
-
// const left = 15 + offset * (level + 1)
|
|
38
|
-
var _left = offset * (level + 2);
|
|
39
|
-
item.style.paddingLeft = "".concat(_left, "px");
|
|
40
|
-
}
|
|
41
|
-
if (itemClass.includes('nut-subsidenavbar__list')) {
|
|
42
|
-
var _level = item.getAttribute('level') ? Number(item.getAttribute('level')) : 1;
|
|
43
|
-
_level += 1;
|
|
44
|
-
item.setAttribute('level', _level.toString());
|
|
45
|
-
item.children && setListLevel(item.children, _level);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}, [offset]);
|
|
49
|
-
var clickFn = function clickFn(e) {
|
|
50
|
-
handleClick(e);
|
|
51
|
-
var currentClass = e.currentTarget.className;
|
|
52
|
-
var isShow = currentClass.includes('nutShow');
|
|
53
|
-
onClick && onClick({
|
|
54
|
-
title: title,
|
|
55
|
-
ikey: ikey,
|
|
56
|
-
isShow: isShow
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
useEffect(function () {
|
|
60
|
-
var _listRef$current, _listRef$current2;
|
|
61
|
-
var childNodes = (_listRef$current = listRef.current) === null || _listRef$current === void 0 ? void 0 : _listRef$current.children;
|
|
62
|
-
(_listRef$current2 = listRef.current) === null || _listRef$current2 === void 0 ? void 0 : _listRef$current2.setAttribute('level', '1');
|
|
63
|
-
childNodes && setListLevel(childNodes);
|
|
64
|
-
}, [setListLevel]);
|
|
65
|
-
var divClass = open ? 'nut-subsidenavbar__list nutShow' : 'nut-subsidenavbar__list nutHide';
|
|
66
|
-
var iconClass = open ? 'arrow-icon arrow-down' : 'arrow-icon arrow-up';
|
|
67
|
-
return React__default.createElement("div", _objectSpread({
|
|
68
|
-
className: divClass,
|
|
69
|
-
ref: listRef,
|
|
70
|
-
onClick: clickFn
|
|
71
|
-
}, rest), React__default.createElement("div", {
|
|
72
|
-
className: "nut-subsidenavbar__title border-bt"
|
|
73
|
-
}, title, " ", React__default.createElement("i", {
|
|
74
|
-
className: iconClass
|
|
75
|
-
})), React__default.createElement("div", {
|
|
76
|
-
className: "nut-subsidenavbar__content"
|
|
77
|
-
}, children));
|
|
78
|
-
};
|
|
1
|
+
import { S as SubSideNavBar } from './subsidenavbar.taro-69cb9752.js';
|
|
2
|
+
import 'react';
|
|
3
|
+
import './offsetContext-c2a746fa.js';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
79
7
|
export { SubSideNavBar as default };
|
package/dist/esm/Swipe.js
CHANGED
|
@@ -1,232 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import classNames from 'classnames';
|
|
7
|
-
import { c as cn } from './bem-3b438e61.js';
|
|
8
|
-
import { u as useTouch } from './useTouch-cf73a407.js';
|
|
9
|
-
import { g as getRect } from './useClientRect-56bb675b.js';
|
|
1
|
+
import { S as Swipe } from './swipe.taro-ea35f07f.js';
|
|
2
|
+
import 'react';
|
|
3
|
+
import 'classnames';
|
|
4
|
+
import '@tarojs/taro';
|
|
5
|
+
import './bem-350c1702.js';
|
|
10
6
|
import '@bem-react/classname';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
event.stopPropagation();
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
var defaultProps = {
|
|
20
|
-
name: '',
|
|
21
|
-
leftWidth: 0,
|
|
22
|
-
rightWidth: 0
|
|
23
|
-
};
|
|
24
|
-
var Swipe = forwardRef(function (props, instanceRef) {
|
|
25
|
-
var swipeBem = cn('swipe');
|
|
26
|
-
var touch = useTouch();
|
|
27
|
-
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
28
|
-
children = _defaultProps$props.children,
|
|
29
|
-
className = _defaultProps$props.className,
|
|
30
|
-
style = _defaultProps$props.style;
|
|
31
|
-
var root = useRef();
|
|
32
|
-
var opened = useRef(false);
|
|
33
|
-
var lockClick = useRef(false);
|
|
34
|
-
var startOffset = useRef(0);
|
|
35
|
-
var _useState = useState({
|
|
36
|
-
offset: 0,
|
|
37
|
-
dragging: false
|
|
38
|
-
}),
|
|
39
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
40
|
-
state = _useState2[0],
|
|
41
|
-
setState = _useState2[1];
|
|
42
|
-
var _useState3 = useState({
|
|
43
|
-
left: 0,
|
|
44
|
-
right: 0
|
|
45
|
-
}),
|
|
46
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
47
|
-
actionWidth = _useState4[0],
|
|
48
|
-
setActionWidth = _useState4[1];
|
|
49
|
-
var wrapperStyle = {
|
|
50
|
-
transform: "translate3d(".concat(state.offset, "px, 0, 0)"),
|
|
51
|
-
transitionDuration: state.dragging ? '0s' : '.6s'
|
|
52
|
-
};
|
|
53
|
-
var leftWidth = useMemo(function () {
|
|
54
|
-
return props.leftWidth ? props.leftWidth : actionWidth.left;
|
|
55
|
-
}, [props.leftWidth, actionWidth.left]);
|
|
56
|
-
var rightWidth = useMemo(function () {
|
|
57
|
-
return props.rightWidth ? props.rightWidth : actionWidth.right;
|
|
58
|
-
}, [props.rightWidth, actionWidth.right]);
|
|
59
|
-
var _onTouchStart = function onTouchStart(event) {
|
|
60
|
-
if (!props.disabled) {
|
|
61
|
-
startOffset.current = state.offset;
|
|
62
|
-
touch.start(event);
|
|
63
|
-
props.onTouchStart && props.onTouchStart(event);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
var _onTouchMove = function onTouchMove(event) {
|
|
67
|
-
if (props.disabled) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
touch.move(event);
|
|
71
|
-
props.onTouchMove && props.onTouchMove(event);
|
|
72
|
-
if (touch.isHorizontal()) {
|
|
73
|
-
lockClick.current = true;
|
|
74
|
-
var newState = _objectSpread(_objectSpread({}, state), {}, {
|
|
75
|
-
dragging: true
|
|
76
|
-
});
|
|
77
|
-
var isEdge = !opened || touch.deltaX * startOffset.current < 0;
|
|
78
|
-
if (isEdge) {
|
|
79
|
-
preventDefault(event, true);
|
|
80
|
-
}
|
|
81
|
-
newState.offset = rangeCalculation(touch.deltaX + startOffset.current, -rightWidth, leftWidth);
|
|
82
|
-
setState(newState);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
var _onTouchEnd = function onTouchEnd(event) {
|
|
86
|
-
if (state.dragging) {
|
|
87
|
-
setState(function (v) {
|
|
88
|
-
return _objectSpread(_objectSpread({}, v), {}, {
|
|
89
|
-
dragging: false
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
toggle(state.offset > 0 ? 'left' : 'right');
|
|
93
|
-
setTimeout(function () {
|
|
94
|
-
lockClick.current = false;
|
|
95
|
-
}, 0);
|
|
96
|
-
props.onTouchEnd && props.onTouchEnd(event);
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
var toggle = function toggle(side) {
|
|
100
|
-
var offset = Math.abs(state.offset);
|
|
101
|
-
var base = 0.3;
|
|
102
|
-
var baseNum = opened ? 1 - base : base;
|
|
103
|
-
var width = side === 'left' ? leftWidth : rightWidth;
|
|
104
|
-
if (width && offset > Number(width) * baseNum) {
|
|
105
|
-
open(side);
|
|
106
|
-
} else {
|
|
107
|
-
_close(side);
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
var open = function open(side) {
|
|
111
|
-
var _props$onOpen;
|
|
112
|
-
opened.current = true;
|
|
113
|
-
var offset = side === 'left' ? leftWidth : -rightWidth;
|
|
114
|
-
var name = props.name;
|
|
115
|
-
(_props$onOpen = props.onOpen) === null || _props$onOpen === void 0 ? void 0 : _props$onOpen.call(props, {
|
|
116
|
-
name: name,
|
|
117
|
-
position: side
|
|
118
|
-
});
|
|
119
|
-
setState(function (v) {
|
|
120
|
-
return _objectSpread(_objectSpread({}, v), {}, {
|
|
121
|
-
offset: Number(offset) || 0
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
};
|
|
125
|
-
var _close = function close(position) {
|
|
126
|
-
if (opened.current) {
|
|
127
|
-
var _props$onClose;
|
|
128
|
-
opened.current = false;
|
|
129
|
-
(_props$onClose = props.onClose) === null || _props$onClose === void 0 ? void 0 : _props$onClose.call(props, {
|
|
130
|
-
name: props.name,
|
|
131
|
-
position: position || 'left'
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
setState(function (v) {
|
|
135
|
-
return _objectSpread(_objectSpread({}, v), {}, {
|
|
136
|
-
offset: 0
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
};
|
|
140
|
-
var rangeCalculation = function rangeCalculation(num, min, max) {
|
|
141
|
-
return Math.min(Math.max(Number(num), Number(min)), Number(max));
|
|
142
|
-
};
|
|
143
|
-
var getNodeWidth = function getNodeWidth(node) {
|
|
144
|
-
if (node) {
|
|
145
|
-
var ele = getRect(node);
|
|
146
|
-
return ele.width;
|
|
147
|
-
}
|
|
148
|
-
return 0;
|
|
149
|
-
};
|
|
150
|
-
var leftRef = useCallback(function (node) {
|
|
151
|
-
if (node !== null) {
|
|
152
|
-
setActionWidth(function (v) {
|
|
153
|
-
return _objectSpread(_objectSpread({}, v), {}, {
|
|
154
|
-
left: getNodeWidth(node)
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
}, [props.leftAction]);
|
|
159
|
-
var rightRef = useCallback(function (node) {
|
|
160
|
-
if (node !== null) {
|
|
161
|
-
setActionWidth(function (v) {
|
|
162
|
-
return _objectSpread(_objectSpread({}, v), {}, {
|
|
163
|
-
right: getNodeWidth(node)
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
}, [props.rightAction]);
|
|
168
|
-
var renderActionContent = function renderActionContent(side, measuredRef) {
|
|
169
|
-
if (props["".concat(side, "Action")]) {
|
|
170
|
-
return React__default.createElement("div", {
|
|
171
|
-
ref: measuredRef,
|
|
172
|
-
className: "".concat(swipeBem(side)),
|
|
173
|
-
onClick: function onClick(e) {
|
|
174
|
-
return handleOperate(e, side);
|
|
175
|
-
}
|
|
176
|
-
}, props["".concat(side, "Action")]);
|
|
177
|
-
}
|
|
178
|
-
return null;
|
|
179
|
-
};
|
|
180
|
-
var handleOperate = function handleOperate(event, position) {
|
|
181
|
-
event.stopPropagation();
|
|
182
|
-
if (props.beforeClose) {
|
|
183
|
-
props.beforeClose(position);
|
|
184
|
-
} else {
|
|
185
|
-
props.onActionClick && props.onActionClick(event, position);
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
useImperativeHandle(instanceRef, function () {
|
|
189
|
-
return {
|
|
190
|
-
open: open,
|
|
191
|
-
close: function close() {
|
|
192
|
-
return _close();
|
|
193
|
-
}
|
|
194
|
-
};
|
|
195
|
-
});
|
|
196
|
-
useEffect(function () {
|
|
197
|
-
var handler = function handler(event) {
|
|
198
|
-
var targets = [root];
|
|
199
|
-
if (targets.some(function (targetItem) {
|
|
200
|
-
var targetElement = targetItem.current || targetItem;
|
|
201
|
-
return !targetElement || (targetElement === null || targetElement === void 0 ? void 0 : targetElement.contains(event.target));
|
|
202
|
-
})) {
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
_close();
|
|
206
|
-
};
|
|
207
|
-
document.addEventListener('touchstart', handler);
|
|
208
|
-
return function () {
|
|
209
|
-
document.removeEventListener('touchstart', handler);
|
|
210
|
-
};
|
|
211
|
-
}, []);
|
|
212
|
-
return React__default.createElement("div", {
|
|
213
|
-
ref: root,
|
|
214
|
-
className: classNames(swipeBem(), className),
|
|
215
|
-
onTouchStart: function onTouchStart(e) {
|
|
216
|
-
return _onTouchStart(e);
|
|
217
|
-
},
|
|
218
|
-
onTouchMove: function onTouchMove(e) {
|
|
219
|
-
return _onTouchMove(e);
|
|
220
|
-
},
|
|
221
|
-
onTouchEnd: function onTouchEnd(e) {
|
|
222
|
-
return _onTouchEnd(e);
|
|
223
|
-
},
|
|
224
|
-
style: style
|
|
225
|
-
}, React__default.createElement("div", {
|
|
226
|
-
className: "".concat(swipeBem('wrapper')),
|
|
227
|
-
style: wrapperStyle
|
|
228
|
-
}, renderActionContent('left', leftRef), children, renderActionContent('right', rightRef)));
|
|
229
|
-
});
|
|
230
|
-
Swipe.defaultProps = defaultProps;
|
|
231
|
-
Swipe.displayName = 'NutSwipe';
|
|
7
|
+
import './useTouch-db24bb5c.js';
|
|
8
|
+
import './useClientRect-1f8ed1fe.js';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
232
12
|
export { Swipe as default };
|