@nutui/nutui-react-taro 1.3.5 → 1.3.7
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 +14 -0
- package/dist/esm/Audio.js +4 -4
- package/dist/esm/Calendar.js +4 -4
- package/dist/esm/CalendarItem.js +3 -3
- package/dist/esm/DatePicker.js +4 -4
- package/dist/esm/Drag.js +3 -4
- package/dist/esm/Elevator.js +2 -4
- package/dist/esm/Menu.js +2 -2
- package/dist/esm/MenuItem.js +2 -2
- package/dist/esm/NoticeBar.js +3 -3
- package/dist/esm/Picker.js +3 -3
- package/dist/esm/Popover.js +3 -3
- package/dist/esm/Range.js +3 -3
- package/dist/esm/SearchBar.js +3 -2
- package/dist/esm/Signature.js +3 -2
- package/dist/esm/Swipe.js +3 -3
- package/dist/esm/actionsheet.taro-360d8d34.js +15 -25
- package/dist/esm/address.taro-f16cef31.js +151 -219
- package/dist/esm/animatingnumbers.taro-6f40a2e9.js +13 -41
- package/dist/esm/{audio.taro-29f5568f.js → audio.taro-57d4f0da.js} +33 -60
- package/dist/esm/avatar.taro-ec620cdd.js +25 -50
- package/dist/esm/avatargroup-5b2584d9.js +2 -9
- package/dist/esm/backtop.taro-aa8b2bc5.js +29 -55
- package/dist/esm/badge.taro-38684262.js +9 -20
- package/dist/esm/barrage.taro-d86c367a.js +8 -21
- package/dist/esm/button.taro-a9ebb937.js +22 -37
- package/dist/esm/{calendar.taro-438940bd.js → calendar.taro-533b3219.js} +13 -24
- package/dist/esm/{calendaritem.taro-11333579.js → calendaritem.taro-fe5dd4bd.js} +71 -183
- package/dist/esm/card.taro-1bc35ebe.js +14 -20
- package/dist/esm/cascader.taro-77100fb4.js +77 -197
- package/dist/esm/cell.taro-a4c3bb7b.js +20 -30
- package/dist/esm/cellgroup.taro-8c87bf08.js +6 -12
- package/dist/esm/checkbox.taro-104557c1.js +27 -48
- package/dist/esm/checkboxgroup.taro-3d380042.js +12 -30
- package/dist/esm/circleprogress.taro-3c89a157.js +14 -41
- package/dist/esm/col.taro-2a437387.js +11 -22
- package/dist/esm/collapse.taro-72e58ba2.js +11 -27
- package/dist/esm/collapseitem-75843a5e.js +33 -47
- package/dist/esm/configprovider-3e87d67a.js +2 -6
- package/dist/esm/configprovider.taro-6c7b3056.js +4 -14
- package/dist/esm/countdown.taro-f2d9ffed.js +37 -74
- package/dist/esm/{datepicker.taro-1acec61f.js → datepicker.taro-49a4cf0c.js} +43 -104
- package/dist/esm/dialog.taro-492e2b9a.js +27 -58
- package/dist/esm/divider.taro-5236fe6a.js +8 -15
- package/dist/esm/drag.taro-0717c783.js +153 -0
- package/dist/esm/{elevator.taro-8e385785.js → elevator.taro-443253ec.js} +99 -124
- package/dist/esm/empty.taro-ab9c4f03.js +11 -24
- package/dist/esm/fixednav.taro-582322a1.js +16 -27
- package/dist/esm/grid.taro-5d75c0ad.js +13 -28
- package/dist/esm/griditem.taro-866cd288.js +18 -34
- package/dist/esm/icon-8dc4de10.js +11 -21
- package/dist/esm/icon.taro-1d0d4fb7.js +11 -21
- package/dist/esm/imagepreview.taro-1199e977.js +36 -71
- package/dist/esm/indicator.taro-183ea169.js +9 -20
- package/dist/esm/infiniteloading.taro-b95e62bf.js +23 -49
- package/dist/esm/input.taro-2453d7c4.js +62 -106
- package/dist/esm/inputnumber.taro-0cf7c1b7.js +25 -52
- package/dist/esm/layout.taro-358f014f.js +0 -6
- package/dist/esm/{menu.taro-9345dcfd.js → menu.taro-f8ca86db.js} +24 -42
- package/dist/esm/{menuitem.taro-fc0961b7.js → menuitem.taro-7bf564c9.js} +32 -57
- package/dist/esm/navbar.taro-c931c078.js +18 -34
- package/dist/esm/{noticebar.taro-1fa04a96.js → noticebar.taro-332691f9.js} +55 -107
- package/dist/esm/notify.taro-d9c48fae.js +18 -34
- package/dist/esm/numberkeyboard.taro-53c350b8.js +21 -52
- package/dist/esm/nutui-react.es.js +18 -18
- package/dist/esm/offsetContext-0e3d04b3.js +0 -3
- package/dist/esm/overlay.taro-be45fed5.js +12 -23
- package/dist/esm/pagination.taro-62bbd23f.js +38 -71
- package/dist/esm/{picker.taro-6a4dad23.js → picker.taro-f003b725.js} +95 -186
- package/dist/esm/{popover.taro-eddd0bd2.js → popover.taro-7e5dff8c.js} +33 -76
- package/dist/esm/popup.taro-33d0bbc8.js +40 -72
- package/dist/esm/price.taro-97393d8f.js +7 -24
- package/dist/esm/progress.taro-623bc807.js +23 -31
- package/dist/esm/pulltorefresh.taro-e66c78ad.js +29 -92
- package/dist/esm/radio.taro-95d43860.js +24 -47
- package/dist/esm/radiogroup.taro-b5dad516.js +14 -24
- package/dist/esm/{range.taro-515d37a4.js → range.taro-fc7c0b6a.js} +50 -133
- package/dist/esm/rate.taro-69c85081.js +21 -39
- package/dist/esm/row.taro-cec13a7e.js +7 -16
- package/dist/esm/{searchbar.taro-f134fb96.js → searchbar.taro-0d3c0081.js} +55 -70
- package/dist/esm/shortpassword.taro-2e96ca22.js +29 -56
- package/dist/esm/sidenavbar.taro-87f056cd.js +9 -16
- package/dist/esm/sidenavbaritem.taro-77e077f4.js +4 -11
- package/dist/esm/signature.taro-59b3b3ab.js +146 -0
- package/dist/esm/skeleton.taro-b9ff84b9.js +13 -23
- package/dist/esm/step.taro-f1057500.js +12 -28
- package/dist/esm/steps.taro-943f4fbb.js +6 -14
- package/dist/esm/sticky.taro-30d4e453.js +0 -7
- package/dist/esm/subsidenavbar.taro-2c1fcf16.js +7 -22
- package/dist/esm/{swipe.taro-dfb9a049.js → swipe.taro-83bc248f.js} +98 -91
- package/dist/esm/swiper.taro-f314d67a.js +110 -196
- package/dist/esm/swiperitem-d00e7513.js +2 -12
- package/dist/esm/switch.taro-be5eb823.js +13 -27
- package/dist/esm/tabbar.taro-da72fa2c.js +13 -25
- package/dist/esm/tabbaritem.taro-94cd62c2.js +15 -23
- package/dist/esm/table.taro-7ac89a6c.js +19 -39
- package/dist/esm/tabpane.taro-95aa185b.js +4 -10
- package/dist/esm/tabs.taro-86186dff.js +28 -54
- package/dist/esm/tag.taro-95d7f5c2.js +19 -36
- package/dist/esm/textarea.taro-388d1f90.js +18 -35
- package/dist/esm/timedetail.taro-519808cf.js +15 -28
- package/dist/esm/timepannel.taro-9904f6e6.js +5 -12
- package/dist/esm/timeselect.taro-73796bfc.js +35 -59
- package/dist/esm/toast.taro-86862dff.js +26 -46
- 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/types/src/packages/searchbar/searchbar.taro.d.ts +2 -0
- package/dist/esm/types/src/packages/signature/signature.taro.d.ts +10 -2
- package/dist/esm/uploader.taro-6184abe7.js +52 -144
- package/dist/esm/{useClientRect-8b7cc406.js → useClientRect-bf69d7b3.js} +1 -40
- package/dist/esm/useTouch-a2ea68c6.js +27 -47
- package/dist/esm/video-c1090c92.js +8 -19
- package/dist/esm/virtuallist.taro-6858f690.js +84 -118
- 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 +10848 -11365
- package/dist/nutui.react.umd.js +10840 -11357
- package/dist/packages/menu/menu.scss +4 -0
- package/dist/packages/menuitem/menuitem.scss +27 -2
- 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 +17 -8
- package/package.json +1 -1
- package/dist/esm/drag.taro-56e8c87a.js +0 -134
- package/dist/esm/signature.taro-a9286cd1.js +0 -178
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["attract", "direction", "boundary", "children", "className", "style"];
|
|
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 Taro, { eventCenter, getCurrentInstance } from '@tarojs/taro';
|
|
9
|
+
import { c as cn } from './bem-893ad28d.js';
|
|
10
|
+
var defaultProps = {
|
|
11
|
+
attract: false,
|
|
12
|
+
direction: undefined,
|
|
13
|
+
boundary: {
|
|
14
|
+
top: 0,
|
|
15
|
+
left: 0,
|
|
16
|
+
right: 0,
|
|
17
|
+
bottom: 0
|
|
18
|
+
},
|
|
19
|
+
className: 'myDrag'
|
|
20
|
+
};
|
|
21
|
+
var Drag = function Drag(props) {
|
|
22
|
+
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
23
|
+
attract = _defaultProps$props.attract,
|
|
24
|
+
direction = _defaultProps$props.direction,
|
|
25
|
+
boundary = _defaultProps$props.boundary,
|
|
26
|
+
children = _defaultProps$props.children,
|
|
27
|
+
className = _defaultProps$props.className,
|
|
28
|
+
style = _defaultProps$props.style,
|
|
29
|
+
reset = _objectWithoutProperties(_defaultProps$props, _excluded);
|
|
30
|
+
var b = cn('drag');
|
|
31
|
+
var _useState = useState(boundary),
|
|
32
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
33
|
+
boundaryState = _useState2[0],
|
|
34
|
+
setBoundaryState = _useState2[1];
|
|
35
|
+
var myDrag = useRef(null);
|
|
36
|
+
var dragRef = useRef(null);
|
|
37
|
+
var _useState3 = useState({}),
|
|
38
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
39
|
+
currstyle = _useState4[0],
|
|
40
|
+
setCurrStyle = _useState4[1];
|
|
41
|
+
var timer = useRef(0);
|
|
42
|
+
var axisCache = useRef({
|
|
43
|
+
x: 0,
|
|
44
|
+
y: 0
|
|
45
|
+
});
|
|
46
|
+
var transformCache = useRef({
|
|
47
|
+
x: 0,
|
|
48
|
+
y: 0
|
|
49
|
+
});
|
|
50
|
+
var translateX = useRef(0);
|
|
51
|
+
var translateY = useRef(0);
|
|
52
|
+
var middleLine = useRef(0);
|
|
53
|
+
var getInfo = function getInfo() {
|
|
54
|
+
var el = myDrag.current;
|
|
55
|
+
if (el) {
|
|
56
|
+
var top = boundary.top,
|
|
57
|
+
left = boundary.left,
|
|
58
|
+
bottom = boundary.bottom,
|
|
59
|
+
right = boundary.right;
|
|
60
|
+
var _Taro$getSystemInfoSy = Taro.getSystemInfoSync(),
|
|
61
|
+
screenWidth = _Taro$getSystemInfoSy.screenWidth,
|
|
62
|
+
windowHeight = _Taro$getSystemInfoSy.windowHeight;
|
|
63
|
+
Taro.createSelectorQuery().select(".".concat(className)).boundingClientRect(function (rec) {
|
|
64
|
+
// console.log(rec.height, rec.width)
|
|
65
|
+
setBoundaryState({
|
|
66
|
+
top: -rec.top + top,
|
|
67
|
+
left: -rec.left + left,
|
|
68
|
+
bottom: windowHeight - rec.height - rec.top - bottom,
|
|
69
|
+
right: screenWidth - rec.width - rec.left - right
|
|
70
|
+
});
|
|
71
|
+
middleLine.current = screenWidth - rec.width - rec.left - (screenWidth - rec.width) / 2;
|
|
72
|
+
}).exec();
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
var touchStart = function touchStart(e) {
|
|
76
|
+
e.currentTarget;
|
|
77
|
+
var touches = e.touches[0];
|
|
78
|
+
axisCache.current = {
|
|
79
|
+
x: touches.clientX,
|
|
80
|
+
y: touches.clientY
|
|
81
|
+
};
|
|
82
|
+
transformCache.current = {
|
|
83
|
+
x: translateX.current,
|
|
84
|
+
y: translateY.current
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
var touchMove = function touchMove(e) {
|
|
88
|
+
e.preventDefault();
|
|
89
|
+
if (e.touches.length === 1 && dragRef.current) {
|
|
90
|
+
var touch = e.touches[0];
|
|
91
|
+
var x = touch.clientX - axisCache.current.x;
|
|
92
|
+
var y = touch.clientY - axisCache.current.y;
|
|
93
|
+
translateX.current = x + transformCache.current.x;
|
|
94
|
+
translateY.current = y + transformCache.current.y;
|
|
95
|
+
// 边界判断
|
|
96
|
+
if (translateX.current < boundaryState.left) {
|
|
97
|
+
translateX.current = boundaryState.left;
|
|
98
|
+
} else if (translateX.current > boundaryState.right) {
|
|
99
|
+
translateX.current = boundaryState.right;
|
|
100
|
+
}
|
|
101
|
+
if (translateY.current < boundaryState.top) {
|
|
102
|
+
translateY.current = boundaryState.top;
|
|
103
|
+
} else if (translateY.current > boundaryState.bottom) {
|
|
104
|
+
translateY.current = boundaryState.bottom;
|
|
105
|
+
}
|
|
106
|
+
var transform = "translate3d(".concat(props.direction !== 'y' ? translateX.current : 0, "px, ").concat(props.direction !== 'x' ? translateY.current : 0, "px, 0px)");
|
|
107
|
+
setCurrStyle({
|
|
108
|
+
transform: transform
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
var touchEnd = function touchEnd(e) {
|
|
113
|
+
if (props.direction !== 'y' && props.attract && dragRef.current) {
|
|
114
|
+
if (translateX.current < middleLine.current) {
|
|
115
|
+
translateX.current = boundaryState.left;
|
|
116
|
+
} else {
|
|
117
|
+
translateX.current = boundaryState.right;
|
|
118
|
+
}
|
|
119
|
+
var transform = "translate3d(".concat(translateX.current, "px, ").concat(props.direction !== 'x' ? translateY.current : 0, "px, 0px)");
|
|
120
|
+
setCurrStyle({
|
|
121
|
+
transform: transform
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
useEffect(function () {
|
|
126
|
+
eventCenter.once(getCurrentInstance().router.onReady, function () {
|
|
127
|
+
timer.current = setTimeout(function () {
|
|
128
|
+
getInfo();
|
|
129
|
+
}, 200);
|
|
130
|
+
});
|
|
131
|
+
return function () {
|
|
132
|
+
clearTimeout(timer.current);
|
|
133
|
+
};
|
|
134
|
+
}, []);
|
|
135
|
+
return React__default.createElement("div", _objectSpread(_objectSpread({
|
|
136
|
+
style: style,
|
|
137
|
+
className: "".concat(b(), " ").concat(className)
|
|
138
|
+
}, reset), {}, {
|
|
139
|
+
ref: myDrag
|
|
140
|
+
}), React__default.createElement("div", {
|
|
141
|
+
onTouchStart: function onTouchStart(event) {
|
|
142
|
+
return touchStart(event);
|
|
143
|
+
},
|
|
144
|
+
ref: dragRef,
|
|
145
|
+
onTouchMove: touchMove,
|
|
146
|
+
onTouchEnd: touchEnd,
|
|
147
|
+
// eslint-disable-next-line react/no-unknown-property
|
|
148
|
+
style: currstyle
|
|
149
|
+
}, children));
|
|
150
|
+
};
|
|
151
|
+
Drag.defaultProps = defaultProps;
|
|
152
|
+
Drag.displayName = 'NutDrag';
|
|
153
|
+
export { Drag as D };
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
1
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
5
|
var _excluded = ["height", "acceptKey", "indexList", "isSticky", "spaceHeight", "titleHeight", "className", "onClickItem", "onClickIndex", "children"];
|
|
5
|
-
|
|
6
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
|
-
|
|
8
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; }
|
|
9
|
-
|
|
10
8
|
import React__default, { createContext, useRef, useState, useEffect } from 'react';
|
|
11
|
-
import { useGesture } from '@use-gesture/react';
|
|
12
|
-
import { animated } from '@react-spring/web';
|
|
13
9
|
import Taro from '@tarojs/taro';
|
|
14
10
|
import { c as cn } from './bem-893ad28d.js';
|
|
15
11
|
var elevatorContext = createContext({});
|
|
@@ -20,23 +16,21 @@ var defaultProps = {
|
|
|
20
16
|
isSticky: false,
|
|
21
17
|
spaceHeight: 23,
|
|
22
18
|
titleHeight: 35,
|
|
23
|
-
className: ''
|
|
19
|
+
className: 'weapp-elevator'
|
|
24
20
|
};
|
|
25
|
-
|
|
26
21
|
var Elevator = function Elevator(props) {
|
|
27
22
|
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
23
|
+
height = _defaultProps$props.height,
|
|
24
|
+
acceptKey = _defaultProps$props.acceptKey,
|
|
25
|
+
indexList = _defaultProps$props.indexList,
|
|
26
|
+
isSticky = _defaultProps$props.isSticky,
|
|
27
|
+
spaceHeight = _defaultProps$props.spaceHeight,
|
|
28
|
+
titleHeight = _defaultProps$props.titleHeight,
|
|
29
|
+
className = _defaultProps$props.className,
|
|
30
|
+
onClickItem = _defaultProps$props.onClickItem,
|
|
31
|
+
onClickIndex = _defaultProps$props.onClickIndex,
|
|
32
|
+
children = _defaultProps$props.children,
|
|
33
|
+
rest = _objectWithoutProperties(_defaultProps$props, _excluded);
|
|
40
34
|
var b = cn('elevator');
|
|
41
35
|
var listview = useRef(null);
|
|
42
36
|
var initData = {
|
|
@@ -51,186 +45,161 @@ var Elevator = function Elevator(props) {
|
|
|
51
45
|
y1: 0,
|
|
52
46
|
y2: 0
|
|
53
47
|
});
|
|
54
|
-
|
|
55
48
|
var _useState = useState(0),
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
49
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
50
|
+
scrollY = _useState2[0],
|
|
51
|
+
setScrollY = _useState2[1];
|
|
60
52
|
var _useState3 = useState({}),
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
53
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
54
|
+
currentData = _useState4[0],
|
|
55
|
+
setCurrentData = _useState4[1];
|
|
65
56
|
var _useState5 = useState(''),
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
57
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
58
|
+
currentKey = _useState6[0],
|
|
59
|
+
setCurrentKey = _useState6[1];
|
|
70
60
|
var _useState7 = useState(0),
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
61
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
62
|
+
currentIndex = _useState8[0],
|
|
63
|
+
setCurrentIndex = _useState8[1];
|
|
75
64
|
var _useState9 = useState(0),
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
65
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
66
|
+
codeIndex = _useState10[0],
|
|
67
|
+
setCodeIndex = _useState10[1];
|
|
80
68
|
var _useState11 = useState(false),
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
var
|
|
86
|
-
|
|
69
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
70
|
+
scrollStart = _useState12[0],
|
|
71
|
+
setScrollStart = _useState12[1];
|
|
72
|
+
var state = useRef(initData);
|
|
73
|
+
var _useState13 = useState(0),
|
|
74
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
75
|
+
scrollTop = _useState14[0],
|
|
76
|
+
setScrollTop = _useState14[1];
|
|
77
|
+
// 重置滚动参数
|
|
87
78
|
var resetScrollState = function resetScrollState() {
|
|
88
79
|
setScrollStart(false);
|
|
89
80
|
};
|
|
90
|
-
|
|
91
81
|
var clientHeight = function clientHeight() {
|
|
92
82
|
return listview.current ? listview.current.clientHeight : 0;
|
|
93
83
|
};
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
84
|
+
var getData = function getData(el) {
|
|
85
|
+
if (!el.dataset.index) {
|
|
86
|
+
return '0';
|
|
87
|
+
}
|
|
88
|
+
return el.dataset.index;
|
|
98
89
|
};
|
|
99
|
-
|
|
100
90
|
var calculateHeight = function calculateHeight() {
|
|
101
91
|
var height = 0;
|
|
102
92
|
state.current.listHeight.push(height);
|
|
103
|
-
|
|
104
93
|
for (var i = 0; i < state.current.listGroup.length; i++) {
|
|
105
|
-
var
|
|
106
|
-
|
|
107
|
-
|
|
94
|
+
var query = Taro.createSelectorQuery();
|
|
95
|
+
query.selectAll(".".concat(className, " .elevator__item__").concat(i)).boundingClientRect();
|
|
96
|
+
// eslint-disable-next-line no-loop-func
|
|
97
|
+
query.exec(function (res) {
|
|
98
|
+
height += res[0].height;
|
|
99
|
+
state.current.listHeight.push(height);
|
|
100
|
+
});
|
|
108
101
|
}
|
|
109
102
|
};
|
|
110
|
-
|
|
111
103
|
var scrollTo = function scrollTo(index) {
|
|
112
104
|
if (!index && index !== 0) {
|
|
113
105
|
return;
|
|
114
106
|
}
|
|
115
|
-
|
|
116
107
|
if (!state.current.listHeight.length) {
|
|
117
108
|
calculateHeight();
|
|
118
109
|
}
|
|
119
|
-
|
|
120
110
|
var cacheIndex = index;
|
|
121
|
-
|
|
122
111
|
if (index < 0) {
|
|
123
112
|
cacheIndex = 0;
|
|
124
113
|
}
|
|
125
|
-
|
|
126
114
|
if (index > state.current.listHeight.length - 2) {
|
|
127
115
|
cacheIndex = state.current.listHeight.length - 2;
|
|
128
116
|
}
|
|
129
|
-
|
|
130
117
|
setCodeIndex(cacheIndex);
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
118
|
+
setScrollTop(state.current.listHeight[cacheIndex]);
|
|
119
|
+
};
|
|
120
|
+
var touchMove = function touchMove(e) {
|
|
121
|
+
var firstTouch = e.touches[0];
|
|
122
|
+
touchState.current.y2 = firstTouch.pageY;
|
|
123
|
+
var delta = (touchState.current.y2 - touchState.current.y1) / spaceHeight || 0;
|
|
124
|
+
var cacheIndex = state.current.anchorIndex + Math.floor(delta);
|
|
125
|
+
setCodeIndex(cacheIndex);
|
|
126
|
+
scrollTo(cacheIndex);
|
|
127
|
+
};
|
|
128
|
+
var touchEnd = function touchEnd() {
|
|
129
|
+
resetScrollState();
|
|
130
|
+
};
|
|
131
|
+
var touchStart = function touchStart(e) {
|
|
132
|
+
setScrollStart(true);
|
|
133
|
+
var index = Number(getData(e.target));
|
|
134
|
+
var firstTouch = e.touches[0];
|
|
135
|
+
touchState.current.y1 = firstTouch.pageY;
|
|
136
|
+
state.current.anchorIndex = +index;
|
|
137
|
+
setCodeIndex(function (codeIndex) {
|
|
138
|
+
// console.log(codeIndex + index, 'touchStart')
|
|
139
|
+
return codeIndex + index;
|
|
140
|
+
});
|
|
141
|
+
scrollTo(index);
|
|
135
142
|
};
|
|
136
|
-
|
|
137
|
-
var bind = useGesture({
|
|
138
|
-
onDragStart: function onDragStart(_ref) {
|
|
139
|
-
var target = _ref.target,
|
|
140
|
-
offset = _ref.offset;
|
|
141
|
-
setScrollStart(true);
|
|
142
|
-
var index = Number(getData(target, 'index'));
|
|
143
|
-
touchState.current.y1 = offset[1];
|
|
144
|
-
state.current.anchorIndex = +index;
|
|
145
|
-
setCodeIndex(function (codeIndex) {
|
|
146
|
-
return codeIndex + index;
|
|
147
|
-
});
|
|
148
|
-
scrollTo(index);
|
|
149
|
-
},
|
|
150
|
-
onDragEnd: function onDragEnd(_ref2) {
|
|
151
|
-
var offset = _ref2.offset;
|
|
152
|
-
touchState.current.y2 = offset[1];
|
|
153
|
-
var delta = (touchState.current.y2 - touchState.current.y1) / spaceHeight || 0; // delta 是一个浮点数, 需要四舍五入一下, 否则页面会找不到最终计算后的index
|
|
154
|
-
|
|
155
|
-
var cacheIndex = state.current.anchorIndex + Math.ceil(delta);
|
|
156
|
-
setCodeIndex(cacheIndex);
|
|
157
|
-
scrollTo(cacheIndex);
|
|
158
|
-
resetScrollState();
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
|
|
162
143
|
var handleClickItem = function handleClickItem(key, item) {
|
|
163
144
|
onClickItem && onClickItem(key, item);
|
|
164
145
|
setCurrentData(item);
|
|
165
146
|
setCurrentKey(key);
|
|
166
147
|
};
|
|
167
|
-
|
|
168
148
|
var handleClickIndex = function handleClickIndex(key) {
|
|
169
149
|
onClickIndex && onClickIndex(key);
|
|
170
150
|
};
|
|
171
|
-
|
|
172
151
|
var setListGroup = function setListGroup() {
|
|
152
|
+
console.log(Taro.createSelectorQuery().selectAll(".".concat(className)));
|
|
173
153
|
if (listview.current) {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
});
|
|
154
|
+
Taro.createSelectorQuery().selectAll(".".concat(className, " .nut-elevator__list__item")).node(function (el) {
|
|
155
|
+
console.log(el, 'el');
|
|
156
|
+
state.current.listGroup = _toConsumableArray(Object.keys(el));
|
|
157
|
+
calculateHeight();
|
|
158
|
+
}).exec();
|
|
181
159
|
}
|
|
182
160
|
};
|
|
183
|
-
|
|
184
161
|
var listViewScroll = function listViewScroll(e) {
|
|
185
162
|
var listHeight = state.current.listHeight;
|
|
186
|
-
|
|
187
163
|
if (!listHeight.length) {
|
|
188
164
|
calculateHeight();
|
|
189
165
|
}
|
|
190
|
-
|
|
191
166
|
var target = e.target;
|
|
192
167
|
var scrollTop = target.scrollTop;
|
|
193
|
-
state.current.scrollY = scrollTop;
|
|
168
|
+
state.current.scrollY = Math.floor(scrollTop);
|
|
194
169
|
setScrollY(scrollTop);
|
|
195
|
-
|
|
196
170
|
for (var i = 0; i < listHeight.length - 1; i++) {
|
|
197
171
|
var height1 = listHeight[i];
|
|
198
172
|
var height2 = listHeight[i + 1];
|
|
199
|
-
|
|
200
173
|
if (state.current.scrollY >= height1 && state.current.scrollY < height2) {
|
|
201
174
|
setCurrentIndex(i);
|
|
202
175
|
state.current.diff = height2 - state.current.scrollY;
|
|
203
176
|
return;
|
|
204
177
|
}
|
|
205
178
|
}
|
|
206
|
-
|
|
207
179
|
setCurrentIndex(listHeight.length - 2);
|
|
208
180
|
};
|
|
209
|
-
|
|
210
181
|
useEffect(function () {
|
|
211
182
|
if (listview.current) {
|
|
212
183
|
setListGroup();
|
|
213
|
-
listview.current.addEventListener('scroll', listViewScroll);
|
|
214
184
|
}
|
|
215
185
|
}, [listview]);
|
|
216
186
|
useEffect(function () {
|
|
217
187
|
var _state$current = state.current,
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
188
|
+
listHeight = _state$current.listHeight,
|
|
189
|
+
diff = _state$current.diff,
|
|
190
|
+
scrollY = _state$current.scrollY;
|
|
221
191
|
var fixedTop = diff > 0 && diff < titleHeight ? diff - titleHeight : 0;
|
|
222
|
-
|
|
223
192
|
if (scrollY + clientHeight() === listHeight[listHeight.length - 1]) {
|
|
224
193
|
if (fixedTop !== 0) {
|
|
225
194
|
fixedTop = 0;
|
|
226
195
|
}
|
|
227
196
|
}
|
|
228
|
-
|
|
229
197
|
if (state.current.fixedTop === fixedTop) return;
|
|
230
198
|
state.current.fixedTop = fixedTop;
|
|
231
199
|
}, [state.current.diff, titleHeight]);
|
|
200
|
+
console.log(currentIndex, 'currentIndex');
|
|
232
201
|
return React__default.createElement("div", _objectSpread({
|
|
233
|
-
className: "".concat(b(), " ").concat(className)
|
|
202
|
+
className: "".concat(b(), " ").concat(className, " ")
|
|
234
203
|
}, rest), isSticky && scrollY > 0 ? React__default.createElement("div", {
|
|
235
204
|
className: b('list__fixed')
|
|
236
205
|
}, React__default.createElement("span", {
|
|
@@ -268,17 +237,24 @@ var Elevator = function Elevator(props) {
|
|
|
268
237
|
})
|
|
269
238
|
}, indexList[codeIndex][acceptKey]) : null, React__default.createElement("div", {
|
|
270
239
|
className: b('bars')
|
|
271
|
-
}, React__default.createElement(
|
|
272
|
-
className: b('bars__inner')
|
|
273
|
-
|
|
240
|
+
}, React__default.createElement("div", {
|
|
241
|
+
className: b('bars__inner'),
|
|
242
|
+
onTouchStart: function onTouchStart(event) {
|
|
243
|
+
return touchStart(event);
|
|
244
|
+
},
|
|
245
|
+
onTouchMove: function onTouchMove(event) {
|
|
246
|
+
return touchMove(event);
|
|
247
|
+
},
|
|
248
|
+
onTouchEnd: touchEnd,
|
|
274
249
|
style: {
|
|
275
250
|
touchAction: 'pan-y'
|
|
276
|
-
}
|
|
277
|
-
|
|
251
|
+
},
|
|
252
|
+
onScroll: listViewScroll
|
|
253
|
+
}, indexList.map(function (item, index) {
|
|
278
254
|
return React__default.createElement("div", {
|
|
279
|
-
className: b('bars__inner__item', {
|
|
255
|
+
className: "".concat(b('bars__inner__item', {
|
|
280
256
|
active: item[acceptKey] === indexList[currentIndex][acceptKey]
|
|
281
|
-
}),
|
|
257
|
+
}), " elevator__item__").concat(index),
|
|
282
258
|
"data-index": index,
|
|
283
259
|
key: index,
|
|
284
260
|
onClick: function onClick() {
|
|
@@ -287,7 +263,6 @@ var Elevator = function Elevator(props) {
|
|
|
287
263
|
}, item[acceptKey]);
|
|
288
264
|
}))));
|
|
289
265
|
};
|
|
290
|
-
|
|
291
266
|
Elevator.defaultProps = defaultProps;
|
|
292
267
|
Elevator.displayName = 'NutElevator';
|
|
293
268
|
export { Elevator as E };
|
|
@@ -2,18 +2,15 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
4
|
var _excluded = ["image", "imageSize", "description", "children", "className"];
|
|
5
|
-
|
|
6
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; }
|
|
7
|
-
|
|
8
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; }
|
|
9
|
-
|
|
10
7
|
import React__default, { useState, useEffect } from 'react';
|
|
11
8
|
import { c as cn } from './bem-893ad28d.js';
|
|
12
9
|
import { u as useConfig } from './configprovider.taro-6c7b3056.js';
|
|
10
|
+
|
|
13
11
|
/**
|
|
14
12
|
* 内置图片地址
|
|
15
13
|
*/
|
|
16
|
-
|
|
17
14
|
var defaultStatus = {
|
|
18
15
|
empty: 'https://static-ftcms.jd.com/p/files/61a9e3183985005b3958672b.png',
|
|
19
16
|
error: 'https://ftcms.jd.com/p/files/61a9e33ee7dcdbcc0ce62736.png',
|
|
@@ -25,29 +22,23 @@ var defaultProps = {
|
|
|
25
22
|
imageSize: '',
|
|
26
23
|
className: ''
|
|
27
24
|
};
|
|
28
|
-
|
|
29
25
|
var Empty = function Empty(props) {
|
|
30
26
|
var _useConfig = useConfig(),
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
locale = _useConfig.locale;
|
|
33
28
|
defaultProps.description = locale.noData || defaultProps.description;
|
|
34
|
-
|
|
35
29
|
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
30
|
+
image = _defaultProps$props.image,
|
|
31
|
+
imageSize = _defaultProps$props.imageSize,
|
|
32
|
+
description = _defaultProps$props.description,
|
|
33
|
+
children = _defaultProps$props.children,
|
|
34
|
+
className = _defaultProps$props.className,
|
|
35
|
+
rest = _objectWithoutProperties(_defaultProps$props, _excluded);
|
|
43
36
|
var _useState = useState({}),
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
37
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
38
|
+
imgStyle = _useState2[0],
|
|
39
|
+
setImgStyle = _useState2[1];
|
|
48
40
|
var b = cn('empty');
|
|
49
41
|
var imageNode = image;
|
|
50
|
-
|
|
51
42
|
if (typeof image === 'string') {
|
|
52
43
|
var isHttpUrl = image.startsWith('https://') || image.startsWith('http://') || image.startsWith('//');
|
|
53
44
|
var imageUrl = isHttpUrl ? image : defaultStatus[image];
|
|
@@ -57,20 +48,17 @@ var Empty = function Empty(props) {
|
|
|
57
48
|
alt: "empty"
|
|
58
49
|
});
|
|
59
50
|
}
|
|
60
|
-
|
|
61
51
|
useEffect(function () {
|
|
62
52
|
setImgStyle(function () {
|
|
63
53
|
if (!imageSize) {
|
|
64
54
|
return {};
|
|
65
55
|
}
|
|
66
|
-
|
|
67
56
|
if (typeof imageSize === 'number') {
|
|
68
57
|
return {
|
|
69
58
|
width: "".concat(imageSize, "px"),
|
|
70
59
|
height: "".concat(imageSize, "px")
|
|
71
60
|
};
|
|
72
61
|
}
|
|
73
|
-
|
|
74
62
|
return {
|
|
75
63
|
width: imageSize,
|
|
76
64
|
height: imageSize
|
|
@@ -88,7 +76,6 @@ var Empty = function Empty(props) {
|
|
|
88
76
|
description: description
|
|
89
77
|
}, children));
|
|
90
78
|
};
|
|
91
|
-
|
|
92
79
|
Empty.defaultProps = defaultProps;
|
|
93
80
|
Empty.displayName = 'NutEmpty';
|
|
94
81
|
export { Empty as E };
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
var _excluded = ["fixednavClass", "overlay", "visible", "navList", "activeText", "unActiveText", "position", "onChange", "onSelected", "type", "slotList", "slotBtn", "iconClassPrefix", "iconFontClassName"];
|
|
4
|
-
|
|
5
4
|
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
5
|
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
6
|
import React__default from 'react';
|
|
10
7
|
import classNames from 'classnames';
|
|
11
8
|
import { I as Icon } from './icon.taro-1d0d4fb7.js';
|
|
@@ -13,7 +10,6 @@ import { O as Overlay } from './overlay.taro-be45fed5.js';
|
|
|
13
10
|
import { c as cn } from './bem-893ad28d.js';
|
|
14
11
|
import { u as useConfig } from './configprovider.taro-6c7b3056.js';
|
|
15
12
|
import { C as ComponentDefaults } from './typings-1c5f2628.js';
|
|
16
|
-
|
|
17
13
|
var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
18
14
|
fixednavClass: 'nut-fixednav',
|
|
19
15
|
activeText: '',
|
|
@@ -24,42 +20,36 @@ var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
|
24
20
|
bottom: 'auto'
|
|
25
21
|
}
|
|
26
22
|
});
|
|
27
|
-
|
|
28
23
|
var FixedNav = function FixedNav(props) {
|
|
29
24
|
var _useConfig = useConfig(),
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
locale = _useConfig.locale;
|
|
32
26
|
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
27
|
+
fixednavClass = _defaultProps$props.fixednavClass,
|
|
28
|
+
overlay = _defaultProps$props.overlay,
|
|
29
|
+
visible = _defaultProps$props.visible,
|
|
30
|
+
navList = _defaultProps$props.navList,
|
|
31
|
+
activeText = _defaultProps$props.activeText,
|
|
32
|
+
unActiveText = _defaultProps$props.unActiveText,
|
|
33
|
+
position = _defaultProps$props.position,
|
|
34
|
+
onChange = _defaultProps$props.onChange,
|
|
35
|
+
onSelected = _defaultProps$props.onSelected,
|
|
36
|
+
type = _defaultProps$props.type,
|
|
37
|
+
slotList = _defaultProps$props.slotList,
|
|
38
|
+
slotBtn = _defaultProps$props.slotBtn,
|
|
39
|
+
iconClassPrefix = _defaultProps$props.iconClassPrefix,
|
|
40
|
+
iconFontClassName = _defaultProps$props.iconFontClassName,
|
|
41
|
+
rest = _objectWithoutProperties(_defaultProps$props, _excluded);
|
|
49
42
|
var b = cn('fixednav');
|
|
50
43
|
var classes = classNames({
|
|
51
44
|
active: visible
|
|
52
45
|
}, type, fixednavClass, b(''));
|
|
53
|
-
|
|
54
46
|
var onSelectCb = function onSelectCb(event, item) {
|
|
55
47
|
onSelected(item, event);
|
|
56
48
|
};
|
|
57
|
-
|
|
58
49
|
var onUpdateValue = function onUpdateValue() {
|
|
59
50
|
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !visible;
|
|
60
51
|
onChange(value);
|
|
61
52
|
};
|
|
62
|
-
|
|
63
53
|
return React__default.createElement("div", _objectSpread({
|
|
64
54
|
className: classes,
|
|
65
55
|
style: position
|
|
@@ -102,7 +92,6 @@ var FixedNav = function FixedNav(props) {
|
|
|
102
92
|
className: "text"
|
|
103
93
|
}, visible ? activeText || locale.fixednav.activeText : unActiveText || locale.fixednav.unActiveText))));
|
|
104
94
|
};
|
|
105
|
-
|
|
106
95
|
FixedNav.defaultProps = defaultProps;
|
|
107
96
|
FixedNav.displayName = 'NutFixedNav';
|
|
108
97
|
export { FixedNav as F };
|