@nutui/nutui-react-taro 1.5.2-beta.1 → 1.5.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.
- package/dist/esm/ActionSheet.js +90 -14
- package/dist/esm/Address.js +620 -21
- package/dist/esm/Animate.js +53 -7
- package/dist/esm/AnimatingNumbers.js +125 -7
- package/dist/esm/Audio.js +264 -19
- package/dist/esm/Avatar.js +130 -11
- package/dist/esm/{AvatarContext-c96afdcc.js → AvatarContext-15733596.js} +1 -3
- package/dist/esm/AvatarGroup.js +41 -11
- package/dist/esm/BackTop.js +138 -10
- package/dist/esm/Badge.js +71 -9
- package/dist/esm/Barrage.js +97 -8
- package/dist/esm/Button.js +108 -9
- package/dist/esm/Calendar.js +128 -20
- package/dist/esm/CalendarItem.js +674 -12
- package/dist/esm/Card.js +61 -11
- package/dist/esm/Cascader.js +671 -16
- package/dist/esm/Cell.js +101 -9
- package/dist/esm/CellGroup.js +2 -5
- package/dist/esm/Checkbox.js +5 -7
- package/dist/esm/CheckboxGroup.js +111 -8
- package/dist/esm/CircleProgress.js +114 -8
- package/dist/esm/Col.js +57 -7
- package/dist/esm/Collapse.js +97 -7
- package/dist/esm/CollapseItem.js +146 -8
- package/dist/esm/ConfigProvider.js +187 -8
- package/dist/esm/CountDown.js +247 -9
- package/dist/esm/DatePicker.js +309 -25
- package/dist/esm/Dialog.js +296 -17
- package/dist/esm/Divider.js +34 -7
- package/dist/esm/Drag.js +118 -7
- package/dist/esm/Elevator.js +234 -8
- package/dist/esm/Ellipsis.js +176 -10
- package/dist/esm/Empty.js +79 -8
- package/dist/esm/FixedNav.js +103 -14
- package/dist/esm/Form.js +215 -10
- package/dist/esm/FormItem.js +3 -10
- package/dist/esm/Grid.js +81 -11
- package/dist/esm/GridItem.js +123 -13
- package/dist/esm/Icon.js +2 -5
- package/dist/esm/Image.js +169 -11
- package/dist/esm/ImagePreview.js +225 -19
- package/dist/esm/Indicator.js +50 -7
- package/dist/esm/Infiniteloading.js +215 -14
- package/dist/esm/Input.js +362 -12
- package/dist/esm/InputNumber.js +275 -9
- package/dist/esm/Layout.js +13 -5
- package/dist/esm/Menu.js +153 -10
- package/dist/esm/MenuItem.js +175 -15
- package/dist/esm/NavBar.js +114 -9
- package/dist/esm/NoticeBar.js +568 -10
- package/dist/esm/Notify.js +234 -8
- package/dist/esm/NumberKeyboard.js +247 -17
- package/dist/esm/Overlay.js +2 -6
- package/dist/esm/Pagination.js +168 -9
- package/dist/esm/Picker.js +494 -22
- package/dist/esm/Popover.js +223 -12
- package/dist/esm/Popup.js +193 -13
- package/dist/esm/Price.js +84 -6
- package/dist/esm/Progress.js +122 -9
- package/dist/esm/PullToRefresh.js +276 -13
- package/dist/esm/Radio.js +4 -8
- package/dist/esm/RadioGroup.js +120 -7
- package/dist/esm/Range.js +406 -15
- package/dist/esm/Rate.js +121 -9
- package/dist/esm/Row.js +49 -7
- package/dist/esm/SearchBar.js +235 -12
- package/dist/esm/ShortPassword.js +191 -17
- package/dist/esm/SideNavBar.js +57 -19
- package/dist/esm/SideNavBarItem.js +24 -5
- package/dist/esm/Signature.js +153 -13
- package/dist/esm/Skeleton.js +98 -12
- package/dist/esm/Step.js +87 -10
- package/dist/esm/Steps.js +38 -8
- package/dist/esm/Sticky.js +190 -11
- package/dist/esm/SubSideNavBar.js +78 -6
- package/dist/esm/Swipe.js +230 -10
- package/dist/esm/Swiper.js +490 -9
- package/dist/esm/SwiperItem.js +36 -8
- package/dist/esm/Switch.js +71 -6
- package/dist/esm/TabPane.js +2 -5
- package/dist/esm/Tabbar.js +68 -6
- package/dist/esm/TabbarItem.js +78 -9
- package/dist/esm/Table.js +140 -12
- package/dist/esm/Tabs.js +5 -8
- package/dist/esm/Tag.js +110 -10
- package/dist/esm/TextArea.js +148 -9
- package/dist/esm/TimeDetail.js +67 -9
- package/dist/esm/TimePannel.js +29 -9
- package/dist/esm/TimeSelect.js +171 -19
- package/dist/esm/Toast.js +268 -7
- package/dist/esm/TrendArrow.js +99 -7
- package/dist/esm/Uploader.js +566 -17
- package/dist/esm/{UserContext-0aac9a82.js → UserContext-101ad4a4.js} +1 -3
- package/dist/esm/{UserContext-e402e1a6.js → UserContext-2629d479.js} +1 -3
- package/dist/esm/{UserContext-e8176108.js → UserContext-b33bcf21.js} +1 -3
- package/dist/esm/Video.js +90 -7
- package/dist/esm/VirtualList.js +313 -9
- package/dist/esm/WaterMark.js +111 -11
- package/dist/esm/{bem-350c1702.js → bem-3b438e61.js} +6 -3
- package/dist/esm/cellgroup-fcc72767.js +34 -0
- package/dist/esm/checkbox-44e13cd0.js +137 -0
- package/dist/esm/date-c7aad4c0.js +97 -0
- package/dist/esm/formitem-8a73a5fb.js +157 -0
- package/dist/esm/get-scroll-parent-5f85dee8.js +24 -0
- package/dist/esm/{grid.taro.context-c2bbfb4f.js → grid.context-2ee27d95.js} +2 -4
- package/dist/esm/icon-4ef1581c.js +70 -0
- package/dist/esm/index-030b7245.js +11 -0
- package/dist/esm/nutui-react.es.js +94 -119
- package/dist/esm/offsetContext-3ab00d40.js +16 -0
- package/dist/esm/overlay-de6c79d5.js +83 -0
- package/dist/esm/radio-9f141e6b.js +118 -0
- package/dist/esm/render-bbebb760.js +79 -0
- package/dist/esm/tabpane-01075e6c.js +29 -0
- package/dist/esm/tabs-e1b4e4b1.js +181 -0
- package/dist/esm/typings-f27b58f4.js +8 -0
- package/dist/esm/useClientRect-56bb675b.js +39 -0
- package/dist/esm/useTouch-cf73a407.js +99 -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 +15025 -13192
- package/dist/nutui.react.umd.js +15004 -13169
- package/dist/style.mjs +1 -1
- package/dist/types/index.d.ts +183 -176
- package/package.json +1 -1
- package/dist/esm/actionsheet.taro-e6a51446.js +0 -53
- package/dist/esm/address.taro-3a9b6396.js +0 -461
- package/dist/esm/animate.taro-fb7986d6.js +0 -40
- package/dist/esm/animatingnumbers.taro-03e5d61d.js +0 -104
- package/dist/esm/audio.taro-87ec8bf2.js +0 -161
- package/dist/esm/avatar.taro-3676f38f.js +0 -103
- package/dist/esm/avatargroup-f3574510.js +0 -34
- package/dist/esm/backtop.taro-66394a36.js +0 -48
- package/dist/esm/badge.taro-a4e59c11.js +0 -52
- package/dist/esm/barrage.taro-0495a1b2.js +0 -94
- package/dist/esm/button.taro-9244d065.js +0 -100
- package/dist/esm/calendar.taro-670842ea.js +0 -65
- package/dist/esm/calendaritem.taro-2a603571.js +0 -787
- package/dist/esm/can-use-dom-3eeb5af4.js +0 -6
- package/dist/esm/card.taro-e4c76dad.js +0 -33
- package/dist/esm/cascader.taro-eb1fb011.js +0 -438
- package/dist/esm/cell.taro-a10a74d3.js +0 -64
- package/dist/esm/cellgroup.taro-abe501bc.js +0 -25
- package/dist/esm/checkbox.taro-6120e3e3.js +0 -171
- package/dist/esm/circleprogress.taro-79854448.js +0 -109
- package/dist/esm/col.taro-53eed3cc.js +0 -41
- package/dist/esm/collapse.taro-1a9e4ba2.js +0 -83
- package/dist/esm/collapseitem-4d0bc55d.js +0 -83
- package/dist/esm/configprovider-67d19d3a.js +0 -19
- package/dist/esm/configprovider.taro-8d71eb49.js +0 -42
- package/dist/esm/countdown.taro-5b17c607.js +0 -226
- package/dist/esm/datepicker.taro-6e9b4b8f.js +0 -275
- package/dist/esm/dialog.taro-a3267d29.js +0 -118
- package/dist/esm/divider.taro-26d1d8b4.js +0 -35
- package/dist/esm/drag.taro-79bb8744.js +0 -110
- package/dist/esm/elevator.taro-6019669e.js +0 -178
- package/dist/esm/ellipsis.taro-f15f26da.js +0 -241
- package/dist/esm/empty.taro-04ae4389.js +0 -62
- package/dist/esm/fixednav.taro-1f05acaf.js +0 -53
- package/dist/esm/form.taro-0c8e7a39.js +0 -179
- package/dist/esm/formitem.taro-190a3326.js +0 -89
- package/dist/esm/get-scroll-parent-b4a07e65.js +0 -25
- package/dist/esm/grid.taro-3503b82c.js +0 -61
- package/dist/esm/griditem.taro-cdb3f119.js +0 -98
- package/dist/esm/icon-296a1bec.js +0 -63
- package/dist/esm/icon.taro-296a1bec.js +0 -63
- package/dist/esm/image.taro-142cf512.js +0 -64
- package/dist/esm/imagepreview.taro-c50bb0a3.js +0 -167
- package/dist/esm/index-5bcb0ff8.js +0 -7
- package/dist/esm/indicator.taro-cba8b010.js +0 -37
- package/dist/esm/infiniteloading.taro-183bccbf.js +0 -144
- package/dist/esm/input.taro-97af6c96.js +0 -240
- package/dist/esm/inputnumber.taro-91f65d17.js +0 -130
- package/dist/esm/layout.taro-9046d093.js +0 -11
- package/dist/esm/menu.taro-7e4038a1.js +0 -99
- package/dist/esm/menuitem.taro-96cc4f15.js +0 -130
- package/dist/esm/navbar.taro-777c4705.js +0 -79
- package/dist/esm/noticebar.taro-4a23cdee.js +0 -448
- package/dist/esm/notify.taro-e17c6f82.js +0 -75
- package/dist/esm/numberkeyboard.taro-1bc24744.js +0 -159
- package/dist/esm/offsetContext-c2a746fa.js +0 -5
- package/dist/esm/overlay.taro-21e87fb1.js +0 -69
- package/dist/esm/pagination.taro-715a173b.js +0 -124
- package/dist/esm/picker.taro-9ad1b7c5.js +0 -473
- package/dist/esm/popover.taro-ad5e76ea.js +0 -156
- package/dist/esm/popup.taro-01676bff.js +0 -137
- package/dist/esm/price.taro-776ed16e.js +0 -83
- package/dist/esm/progress.taro-f0ce38e9.js +0 -90
- package/dist/esm/pulltorefresh.taro-a294f656.js +0 -181
- package/dist/esm/radio.taro-a6eff96c.js +0 -168
- package/dist/esm/range.taro-d8fc7656.js +0 -332
- package/dist/esm/rate.taro-6cdf03bd.js +0 -75
- package/dist/esm/row.taro-f64d4a13.js +0 -46
- package/dist/esm/searchbar.taro-0c25927b.js +0 -152
- package/dist/esm/shortpassword.taro-9ee034f7.js +0 -111
- package/dist/esm/sidenavbar.taro-c307b35e.js +0 -35
- package/dist/esm/sidenavbaritem.taro-5a7965d0.js +0 -12
- package/dist/esm/signature.taro-ec4e713b.js +0 -143
- package/dist/esm/skeleton.taro-76faf63f.js +0 -62
- package/dist/esm/step.taro-b7903e8c.js +0 -59
- package/dist/esm/steps.taro-c82d2252.js +0 -30
- package/dist/esm/sticky.taro-218bda37.js +0 -138
- package/dist/esm/subsidenavbar.taro-69cb9752.js +0 -63
- package/dist/esm/supports-passive-c85ef996.js +0 -18
- package/dist/esm/swipe.taro-ea35f07f.js +0 -177
- package/dist/esm/swiper.taro-7a94e211.js +0 -451
- package/dist/esm/swiperitem-c9e3d0d5.js +0 -29
- package/dist/esm/switch.taro-34ca8228.js +0 -50
- package/dist/esm/tabbar.taro-9acfc2fa.js +0 -59
- package/dist/esm/tabbaritem.taro-bf517487.js +0 -58
- package/dist/esm/table.taro-91fc0c01.js +0 -93
- package/dist/esm/tabpane.taro-4ca340ef.js +0 -23
- package/dist/esm/tabs.taro-6a7524a4.js +0 -140
- package/dist/esm/tag.taro-23ba0834.js +0 -92
- package/dist/esm/textarea.taro-442e7350.js +0 -94
- package/dist/esm/timedetail.taro-5b2f2269.js +0 -44
- package/dist/esm/timepannel.taro-d6e40180.js +0 -22
- package/dist/esm/timeselect.taro-a07036f4.js +0 -133
- package/dist/esm/toast.taro-d6c14811.js +0 -109
- package/dist/esm/trendarrow.taro-b8c5ccd9.js +0 -73
- package/dist/esm/typings-b9828dba.js +0 -9
- package/dist/esm/uploader.taro-587e6bf3.js +0 -492
- package/dist/esm/useClientRect-1f8ed1fe.js +0 -18
- package/dist/esm/useTouch-db24bb5c.js +0 -69
- package/dist/esm/video-f1be8a91.js +0 -67
- package/dist/esm/virtuallist.taro-f0b0270d.js +0 -214
- package/dist/esm/watermark.taro-9ce2ae37.js +0 -114
- package/dist/esm/zh-CN-c779e6c1.js +0 -131
|
@@ -1,14 +1,277 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import '
|
|
8
|
-
import '
|
|
9
|
-
import '
|
|
10
|
-
import './
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
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';
|
|
12
|
+
function bound(position, min, max) {
|
|
13
|
+
var ret = position;
|
|
14
|
+
if (min !== undefined) {
|
|
15
|
+
ret = Math.max(position, min);
|
|
16
|
+
}
|
|
17
|
+
if (max !== undefined) {
|
|
18
|
+
ret = Math.min(ret, max);
|
|
19
|
+
}
|
|
20
|
+
return ret;
|
|
21
|
+
}
|
|
22
|
+
function rubberband(distance, dimension, constant) {
|
|
23
|
+
return distance * dimension * constant / (dimension + constant * distance);
|
|
24
|
+
}
|
|
25
|
+
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;
|
|
30
|
+
return position;
|
|
31
|
+
}
|
|
32
|
+
var sleep = function sleep(time) {
|
|
33
|
+
return new Promise(function (resolve) {
|
|
34
|
+
return setTimeout(resolve, time);
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
var passiveSupported = false;
|
|
38
|
+
if (canUseDom) {
|
|
39
|
+
try {
|
|
40
|
+
var opts = Object.defineProperty({}, 'passive', {
|
|
41
|
+
get: function get() {
|
|
42
|
+
passiveSupported = true;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
window.addEventListener('test-passive-supported', null, opts);
|
|
46
|
+
} catch (e) {
|
|
47
|
+
console.log(e);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
var defaultProps = {
|
|
51
|
+
className: '',
|
|
52
|
+
style: {},
|
|
53
|
+
pullingText: '',
|
|
54
|
+
canReleaseText: '',
|
|
55
|
+
refreshingText: '',
|
|
56
|
+
completeText: '',
|
|
57
|
+
completeDelay: 500,
|
|
58
|
+
disabled: false,
|
|
59
|
+
headHeight: 40,
|
|
60
|
+
threshold: 60,
|
|
61
|
+
onRefresh: function onRefresh() {}
|
|
62
|
+
};
|
|
63
|
+
var PullToRefresh = function PullToRefresh(p) {
|
|
64
|
+
var _useConfig = useConfig(),
|
|
65
|
+
locale = _useConfig.locale;
|
|
66
|
+
var props = _objectSpread(_objectSpread(_objectSpread({}, defaultProps), p), {
|
|
67
|
+
pullingText: p.pullingText || locale.pullToRefresh.pullingText,
|
|
68
|
+
canReleaseText: p.canReleaseText || locale.pullToRefresh.canReleaseText,
|
|
69
|
+
refreshingText: p.refreshingText || locale.pullToRefresh.refreshingText,
|
|
70
|
+
completeText: p.completeText || locale.pullToRefresh.completeText
|
|
71
|
+
});
|
|
72
|
+
var headHeight = props.headHeight;
|
|
73
|
+
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];
|
|
93
|
+
var elementRef = useRef(null);
|
|
94
|
+
var pullingRef = useRef(false);
|
|
95
|
+
useEffect(function () {
|
|
96
|
+
var _elementRef$current;
|
|
97
|
+
(_elementRef$current = elementRef.current) === null || _elementRef$current === void 0 ? void 0 : _elementRef$current.addEventListener('touchmove', function () {});
|
|
98
|
+
}, []);
|
|
99
|
+
function doRefresh() {
|
|
100
|
+
return _doRefresh.apply(this, arguments);
|
|
101
|
+
}
|
|
102
|
+
function _doRefresh() {
|
|
103
|
+
_doRefresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
104
|
+
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;
|
|
149
|
+
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
|
+
}
|
|
182
|
+
}, _callee3, null, [[2, 8]]);
|
|
183
|
+
}));
|
|
184
|
+
return _doRefresh.apply(this, arguments);
|
|
185
|
+
}
|
|
186
|
+
useDrag(function (state) {
|
|
187
|
+
if (status === 'refreshing' || status === 'complete') return;
|
|
188
|
+
var event = state.event;
|
|
189
|
+
// 最后一个事件,检查是否可以刷新或是否是开始状态(第一个状态也是最后一个状态)
|
|
190
|
+
if (state.last) {
|
|
191
|
+
pullingRef.current = false;
|
|
192
|
+
if (status === 'canRelease') {
|
|
193
|
+
doRefresh();
|
|
194
|
+
} else {
|
|
195
|
+
api.start({
|
|
196
|
+
height: 0
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
function getScrollTop(element) {
|
|
202
|
+
return 'scrollTop' in element ? element.scrollTop : element.scrollY;
|
|
203
|
+
}
|
|
204
|
+
// 手指位置
|
|
205
|
+
var _state$movement = _slicedToArray(state.movement, 2),
|
|
206
|
+
y = _state$movement[1];
|
|
207
|
+
// 第一个事件,并且手指位置大于0
|
|
208
|
+
if (state.first && y > 0) {
|
|
209
|
+
var target = state.event.target;
|
|
210
|
+
if (!target || !(target instanceof Element)) return;
|
|
211
|
+
var scrollParent = getScrollParent(target);
|
|
212
|
+
while (true) {
|
|
213
|
+
if (!scrollParent) return;
|
|
214
|
+
var scrollTop = getScrollTop(scrollParent);
|
|
215
|
+
if (scrollTop > 0) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
// 查找到 window 说明到顶了
|
|
219
|
+
if (scrollParent instanceof Window) {
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
// 递归查找
|
|
223
|
+
scrollParent = getScrollParent(scrollParent.parentNode);
|
|
224
|
+
}
|
|
225
|
+
pullingRef.current = true;
|
|
226
|
+
}
|
|
227
|
+
if (!pullingRef.current) return;
|
|
228
|
+
if (event.cancelable) {
|
|
229
|
+
event.preventDefault();
|
|
230
|
+
}
|
|
231
|
+
event.stopPropagation();
|
|
232
|
+
var height = Math.max(rubberbandIfOutOfBounds(y, 0, 0, headHeight * 5, 0.5), 0);
|
|
233
|
+
api.start({
|
|
234
|
+
height: height
|
|
235
|
+
});
|
|
236
|
+
setStatus(height > threshold ? 'canRelease' : 'pulling');
|
|
237
|
+
}, {
|
|
238
|
+
pointer: {
|
|
239
|
+
touch: true
|
|
240
|
+
},
|
|
241
|
+
axis: 'y',
|
|
242
|
+
target: elementRef,
|
|
243
|
+
enabled: !props.disabled,
|
|
244
|
+
eventOptions: passiveSupported ? {
|
|
245
|
+
passive: false
|
|
246
|
+
} : false
|
|
247
|
+
});
|
|
248
|
+
var renderStatusText = function renderStatusText() {
|
|
249
|
+
if (props.renderText) {
|
|
250
|
+
var _props$renderText;
|
|
251
|
+
return (_props$renderText = props.renderText) === null || _props$renderText === void 0 ? void 0 : _props$renderText.call(props, status);
|
|
252
|
+
}
|
|
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 '';
|
|
258
|
+
};
|
|
259
|
+
return React__default.createElement(animated.div, {
|
|
260
|
+
ref: elementRef,
|
|
261
|
+
className: "nut-pulltorefresh ".concat(props.className),
|
|
262
|
+
style: props.style
|
|
263
|
+
}, React__default.createElement(animated.div, {
|
|
264
|
+
style: springStyles,
|
|
265
|
+
className: "nut-pulltorefresh-head"
|
|
266
|
+
}, React__default.createElement("div", {
|
|
267
|
+
className: "nut-pulltorefresh-head-content",
|
|
268
|
+
style: {
|
|
269
|
+
height: headHeight
|
|
270
|
+
}
|
|
271
|
+
}, renderStatusText())), React__default.createElement("div", {
|
|
272
|
+
className: "nut-pulltorefresh-content"
|
|
273
|
+
}, props.children));
|
|
274
|
+
};
|
|
275
|
+
PullToRefresh.defaultProps = defaultProps;
|
|
276
|
+
PullToRefresh.displayName = 'NutPullToRefresh';
|
|
14
277
|
export { PullToRefresh as default };
|
package/dist/esm/Radio.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import { R as Radio } from './radio
|
|
1
|
+
import { R as Radio } from './radio-9f141e6b.js';
|
|
2
2
|
import 'react';
|
|
3
|
-
import './
|
|
4
|
-
import './
|
|
5
|
-
import '
|
|
6
|
-
import './typings-b9828dba.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
import './Icon.js';
|
|
4
|
+
import './RadioGroup.js';
|
|
5
|
+
import './typings-f27b58f4.js';
|
|
10
6
|
export { Radio as default };
|
package/dist/esm/RadioGroup.js
CHANGED
|
@@ -1,10 +1,123 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
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';
|
|
5
14
|
import '@bem-react/classname';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
15
|
+
var defaultProps = {
|
|
16
|
+
value: null,
|
|
17
|
+
textPosition: 'right',
|
|
18
|
+
onChange: function onChange(value) {},
|
|
19
|
+
direction: 'vertical',
|
|
20
|
+
options: []
|
|
21
|
+
};
|
|
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 () {
|
|
53
|
+
setVal2State(value);
|
|
54
|
+
}, [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
|
+
function validateChildChecked(child) {
|
|
69
|
+
if (val2State === null) return false;
|
|
70
|
+
return val2State === child.props.value;
|
|
71
|
+
}
|
|
72
|
+
function validateChecked(value) {
|
|
73
|
+
if (val2State === null) return false;
|
|
74
|
+
return val2State === value;
|
|
75
|
+
}
|
|
76
|
+
function cloneChildren() {
|
|
77
|
+
return React__default.Children.map(children, function (child, index) {
|
|
78
|
+
var childChecked = validateChildChecked(child);
|
|
79
|
+
if (child.type.displayName !== 'NutRadio') {
|
|
80
|
+
return React__default.cloneElement(child);
|
|
81
|
+
}
|
|
82
|
+
return React__default.cloneElement(child, {
|
|
83
|
+
textPosition: textPosition,
|
|
84
|
+
checked: childChecked
|
|
85
|
+
// onChange: handleChildChange,
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
}
|
|
9
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);
|
|
98
|
+
return React__default.createElement(Radio, _objectSpread(_objectSpread({
|
|
99
|
+
key: value === null || value === void 0 ? void 0 : value.toString(),
|
|
100
|
+
children: label,
|
|
101
|
+
value: value,
|
|
102
|
+
disabled: disabled,
|
|
103
|
+
onChange: onChange
|
|
104
|
+
}, rest), {}, {
|
|
105
|
+
textPosition: textPosition,
|
|
106
|
+
checked: childChecked
|
|
107
|
+
}));
|
|
108
|
+
});
|
|
109
|
+
}, [val2State, options]);
|
|
110
|
+
return React__default.createElement(RadioContext.Provider, {
|
|
111
|
+
value: {
|
|
112
|
+
onChange: function onChange(val) {
|
|
113
|
+
setVal2State(val);
|
|
114
|
+
_onChange && _onChange(val);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}, React__default.createElement("div", _objectSpread({
|
|
118
|
+
className: "nut-radiogroup nut-radiogroup--".concat(props.direction, " ").concat(className || '')
|
|
119
|
+
}, rest), options !== null && options !== void 0 && options.length ? renderOptionsChildren() : cloneChildren()));
|
|
120
|
+
});
|
|
121
|
+
RadioGroup.defaultProps = defaultProps;
|
|
122
|
+
RadioGroup.displayName = 'NutRadioGroup';
|
|
10
123
|
export { RadioGroup as default };
|