@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,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
获取元素的大小及其相对于视口的位置,等价于 Element.getBoundingClientRect。
|
|
3
|
-
width 宽度 number
|
|
4
|
-
height 高度 number
|
|
5
|
-
top 顶部与视图窗口左上角的距离 number
|
|
6
|
-
left 左侧与视图窗口左上角的距离 number
|
|
7
|
-
right 右侧与视图窗口左上角的距离 number
|
|
8
|
-
bottom 底部与视图窗口左上角的距离 number
|
|
9
|
-
*/
|
|
10
|
-
const getRectByTaro = async (element) => {
|
|
11
|
-
if (element) {
|
|
12
|
-
const res = await element.getBoundingClientRect();
|
|
13
|
-
return res;
|
|
14
|
-
}
|
|
15
|
-
return Promise.resolve({});
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export { getRectByTaro as g };
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
|
|
3
|
-
const MIN_DISTANCE = 10;
|
|
4
|
-
function getDirection(x, y) {
|
|
5
|
-
if (x > y && x > MIN_DISTANCE) {
|
|
6
|
-
return 'horizontal';
|
|
7
|
-
}
|
|
8
|
-
if (y > x && y > MIN_DISTANCE) {
|
|
9
|
-
return 'vertical';
|
|
10
|
-
}
|
|
11
|
-
return '';
|
|
12
|
-
}
|
|
13
|
-
function useTouch() {
|
|
14
|
-
const [startX, SetStartX] = useState(0);
|
|
15
|
-
const [startY, SetStartY] = useState(0);
|
|
16
|
-
const [moveX, SetMoveX] = useState(0);
|
|
17
|
-
const [moveY, SetMoveY] = useState(0);
|
|
18
|
-
const [deltaX, SetDeltaX] = useState(0);
|
|
19
|
-
const [deltaY, SetDeltaY] = useState(0);
|
|
20
|
-
const [offsetX, SetOffsetX] = useState(0);
|
|
21
|
-
const [offsetY, SetOffsetY] = useState(0);
|
|
22
|
-
const [direction, SetDirection] = useState('');
|
|
23
|
-
const isVertical = () => direction === 'vertical';
|
|
24
|
-
const isHorizontal = () => direction === 'horizontal';
|
|
25
|
-
const reset = () => {
|
|
26
|
-
SetDeltaX(0);
|
|
27
|
-
SetDeltaY(0);
|
|
28
|
-
SetOffsetX(0);
|
|
29
|
-
SetOffsetY(0);
|
|
30
|
-
SetDirection('');
|
|
31
|
-
};
|
|
32
|
-
const start = ((event) => {
|
|
33
|
-
reset();
|
|
34
|
-
SetStartX(event.touches[0].clientX);
|
|
35
|
-
SetStartY(event.touches[0].clientY);
|
|
36
|
-
});
|
|
37
|
-
const move = ((event) => {
|
|
38
|
-
const touch = event.touches[0];
|
|
39
|
-
const dX = touch.clientX - startX;
|
|
40
|
-
const dY = touch.clientY - startY;
|
|
41
|
-
SetDeltaX(dX);
|
|
42
|
-
SetDeltaY(dY);
|
|
43
|
-
SetMoveX(touch.clientX);
|
|
44
|
-
SetMoveY(touch.clientY);
|
|
45
|
-
SetOffsetX(Math.abs(dX));
|
|
46
|
-
SetOffsetY(Math.abs(dY));
|
|
47
|
-
if (!direction) {
|
|
48
|
-
SetDirection(getDirection(offsetX, offsetY));
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
return {
|
|
52
|
-
move,
|
|
53
|
-
start,
|
|
54
|
-
reset,
|
|
55
|
-
startX,
|
|
56
|
-
startY,
|
|
57
|
-
moveX,
|
|
58
|
-
moveY,
|
|
59
|
-
deltaX,
|
|
60
|
-
deltaY,
|
|
61
|
-
offsetX,
|
|
62
|
-
offsetY,
|
|
63
|
-
direction,
|
|
64
|
-
isVertical,
|
|
65
|
-
isHorizontal,
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export { useTouch as u };
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import React__default, { useRef, useEffect } from 'react';
|
|
2
|
-
import classNames from 'classnames';
|
|
3
|
-
import { c as cn } from './bem-350c1702.js';
|
|
4
|
-
|
|
5
|
-
const defaultProps = {
|
|
6
|
-
source: {
|
|
7
|
-
type: {},
|
|
8
|
-
src: '',
|
|
9
|
-
},
|
|
10
|
-
options: {
|
|
11
|
-
controls: true,
|
|
12
|
-
muted: false,
|
|
13
|
-
autoplay: false,
|
|
14
|
-
poster: '',
|
|
15
|
-
playsinline: false,
|
|
16
|
-
loop: false,
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
const Video = (props) => {
|
|
20
|
-
const { children, source, options, className, play, pause, playend, onPlayFuc, onPauseFuc, onPlayend, ...restProps } = {
|
|
21
|
-
...defaultProps,
|
|
22
|
-
...props,
|
|
23
|
-
};
|
|
24
|
-
const rootRef = useRef(null);
|
|
25
|
-
const b = cn('video');
|
|
26
|
-
const classes = classNames(className, b(''));
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
init();
|
|
29
|
-
}, []);
|
|
30
|
-
const init = () => {
|
|
31
|
-
if (rootRef.current) {
|
|
32
|
-
const videoRef = rootRef.current;
|
|
33
|
-
if (options.autoplay) {
|
|
34
|
-
setTimeout(() => {
|
|
35
|
-
videoRef.play();
|
|
36
|
-
}, 200);
|
|
37
|
-
}
|
|
38
|
-
if (options.playsinline) {
|
|
39
|
-
videoRef.setAttribute('playsinline', String(options.playsinline));
|
|
40
|
-
videoRef.setAttribute('webkit-playsinline', String(options.playsinline));
|
|
41
|
-
videoRef.setAttribute('x5-video-player-type', 'h5-page');
|
|
42
|
-
videoRef.setAttribute('x5-video-player-fullscreen', 'false');
|
|
43
|
-
}
|
|
44
|
-
videoRef.addEventListener('play', () => {
|
|
45
|
-
onPlayFuc && onPlayFuc(videoRef);
|
|
46
|
-
play && play(videoRef);
|
|
47
|
-
});
|
|
48
|
-
videoRef.addEventListener('pause', () => {
|
|
49
|
-
onPauseFuc && onPauseFuc(videoRef);
|
|
50
|
-
pause && pause(videoRef);
|
|
51
|
-
});
|
|
52
|
-
videoRef.addEventListener('ended', () => {
|
|
53
|
-
videoRef.currentTime = 0;
|
|
54
|
-
onPlayend && onPlayend(videoRef);
|
|
55
|
-
playend && playend(videoRef);
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
return (React__default.createElement("div", { className: classes, ...restProps },
|
|
60
|
-
React__default.createElement("video", { className: "nut-video-player", muted: options.muted, autoPlay: options.autoplay, loop: options.loop, poster: options.poster, controls: options.controls, ref: rootRef, src: source.src },
|
|
61
|
-
React__default.createElement("source", { src: source.src, type: source.type }),
|
|
62
|
-
React__default.createElement("track", { kind: "captions" }))));
|
|
63
|
-
};
|
|
64
|
-
Video.defaultProps = defaultProps;
|
|
65
|
-
Video.displayName = 'NutVideo';
|
|
66
|
-
|
|
67
|
-
export { Video as V };
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
import React__default, { useState, useRef, useEffect, useCallback } from 'react';
|
|
2
|
-
import { ScrollView } from '@tarojs/components';
|
|
3
|
-
import { getSystemInfoSync } from '@tarojs/taro';
|
|
4
|
-
import { u as useConfig } from './configprovider.taro-8d71eb49.js';
|
|
5
|
-
|
|
6
|
-
// 缓存列表初始化信息
|
|
7
|
-
const initPositinoCache = (reaItemSize, length = 0) => {
|
|
8
|
-
let index = 0;
|
|
9
|
-
const positions = Array(length);
|
|
10
|
-
while (index < length) {
|
|
11
|
-
positions[index] = {
|
|
12
|
-
index,
|
|
13
|
-
height: reaItemSize,
|
|
14
|
-
width: reaItemSize,
|
|
15
|
-
top: index * reaItemSize,
|
|
16
|
-
bottom: (index + 1) * reaItemSize,
|
|
17
|
-
left: index * reaItemSize,
|
|
18
|
-
right: (index + 1) * reaItemSize,
|
|
19
|
-
};
|
|
20
|
-
index++;
|
|
21
|
-
}
|
|
22
|
-
return positions;
|
|
23
|
-
};
|
|
24
|
-
// 通过二分法找到 scrollOffset 对应的值
|
|
25
|
-
const binarySearch = (positionsList, value = 0, horizontal) => {
|
|
26
|
-
let start = 0;
|
|
27
|
-
let end = positionsList.length - 1;
|
|
28
|
-
let tempIndex = null;
|
|
29
|
-
const key = horizontal ? 'right' : 'bottom';
|
|
30
|
-
while (start <= end) {
|
|
31
|
-
const midIndex = Math.floor((start + end) / 2);
|
|
32
|
-
const midValue = positionsList[midIndex][key];
|
|
33
|
-
// 相等则直接返回(因为是bottom, 因此startIndex应该是下一个节点)
|
|
34
|
-
if (midValue === value) {
|
|
35
|
-
return midIndex + 1;
|
|
36
|
-
}
|
|
37
|
-
// 中间值 < 传入值,则说明 value对应的节点 大于 start, start往后移动一位
|
|
38
|
-
if (midValue < value) {
|
|
39
|
-
start = midIndex + 1;
|
|
40
|
-
}
|
|
41
|
-
// 中间值 > 传入值,则说明 value 在 中间值之前,end 节点移动到 mid - 1
|
|
42
|
-
else if (midValue > value) {
|
|
43
|
-
// tempIndex存放最靠近值为value的所有
|
|
44
|
-
if (tempIndex === null || tempIndex > midIndex) {
|
|
45
|
-
tempIndex = midIndex;
|
|
46
|
-
}
|
|
47
|
-
end = midIndex - 1;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
tempIndex = tempIndex || 0;
|
|
51
|
-
return tempIndex;
|
|
52
|
-
};
|
|
53
|
-
// 更新Item大小
|
|
54
|
-
const updateItemSize = (positions, items, sizeKey) => {
|
|
55
|
-
const newPos = positions.concat();
|
|
56
|
-
Array.from(items).forEach((item) => {
|
|
57
|
-
const index = Number(item.getAttribute('data-index'));
|
|
58
|
-
const styleVal = item.getAttribute('style');
|
|
59
|
-
if (styleVal && styleVal.includes('none'))
|
|
60
|
-
return;
|
|
61
|
-
const nowSize = item.getBoundingClientRect()[sizeKey];
|
|
62
|
-
const oldSize = positions[index][sizeKey];
|
|
63
|
-
// 存在差值, 更新该节点以后所有的节点
|
|
64
|
-
const dValue = oldSize - nowSize;
|
|
65
|
-
if (dValue) {
|
|
66
|
-
if (sizeKey === 'width') {
|
|
67
|
-
newPos[index].right -= dValue;
|
|
68
|
-
newPos[index][sizeKey] = nowSize;
|
|
69
|
-
for (let k = index + 1; k < positions.length; k++) {
|
|
70
|
-
newPos[k].left = positions[k - 1].right;
|
|
71
|
-
newPos[k].right -= dValue;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
else if (sizeKey === 'height') {
|
|
75
|
-
newPos[index].bottom -= dValue;
|
|
76
|
-
newPos[index][sizeKey] = nowSize;
|
|
77
|
-
for (let k = index + 1; k < positions.length; k++) {
|
|
78
|
-
newPos[k].top = positions[k - 1].bottom;
|
|
79
|
-
newPos[k].bottom -= dValue;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
const defaultProps = {
|
|
87
|
-
sourceData: [],
|
|
88
|
-
itemSize: 66,
|
|
89
|
-
itemEqualSize: true,
|
|
90
|
-
overscan: 2,
|
|
91
|
-
};
|
|
92
|
-
const clientHeight = getSystemInfoSync().windowHeight - 5 || 667;
|
|
93
|
-
getSystemInfoSync().windowWidth || 375;
|
|
94
|
-
const VirtualList = (props) => {
|
|
95
|
-
const { sourceData = [], ItemRender, itemSize = 66, itemEqualSize = true, overscan = 2, key, onScroll, className, containerSize = clientHeight, ...rest } = props;
|
|
96
|
-
// const sizeKey = horizontal ? 'width' : 'height'
|
|
97
|
-
// const scrollKey = horizontal ? 'scrollLeft' : 'scrollTop'
|
|
98
|
-
// const offsetKey = horizontal ? 'left' : 'top'
|
|
99
|
-
const [startOffset, setStartOffset] = useState(0);
|
|
100
|
-
const [start, setStart] = useState(0);
|
|
101
|
-
const [list, setList] = useState(sourceData.slice());
|
|
102
|
-
useConfig();
|
|
103
|
-
// 虚拟列表容器ref
|
|
104
|
-
const scrollRef = useRef(null);
|
|
105
|
-
// 虚拟列表显示区域ref
|
|
106
|
-
const itemsRef = useRef(null);
|
|
107
|
-
const firstItemRef = useRef(null);
|
|
108
|
-
// 列表位置信息
|
|
109
|
-
const [positions, setPositions] = useState([
|
|
110
|
-
{
|
|
111
|
-
index: 0,
|
|
112
|
-
left: 0,
|
|
113
|
-
top: 0,
|
|
114
|
-
bottom: 0,
|
|
115
|
-
width: 0,
|
|
116
|
-
height: 0,
|
|
117
|
-
right: 0,
|
|
118
|
-
},
|
|
119
|
-
]);
|
|
120
|
-
const [offSetSize, setOffSetSize] = useState(containerSize || 0);
|
|
121
|
-
const [options, setOptions] = useState({
|
|
122
|
-
startOffset: 0,
|
|
123
|
-
startIndex: 0,
|
|
124
|
-
overStart: 0,
|
|
125
|
-
endIndex: 10, // 可视区域结束索引
|
|
126
|
-
});
|
|
127
|
-
useEffect(() => {
|
|
128
|
-
if (sourceData.length) {
|
|
129
|
-
setList(sourceData.slice());
|
|
130
|
-
}
|
|
131
|
-
}, [sourceData]);
|
|
132
|
-
// 初始计算可视区域展示数量
|
|
133
|
-
useEffect(() => {
|
|
134
|
-
setPositions((options) => {
|
|
135
|
-
return { ...options, endIndex: visibleCount() };
|
|
136
|
-
});
|
|
137
|
-
}, [itemSize, overscan, offSetSize]);
|
|
138
|
-
useEffect(() => {
|
|
139
|
-
if (containerSize)
|
|
140
|
-
return;
|
|
141
|
-
setOffSetSize(getContainerHeight());
|
|
142
|
-
}, [containerSize]);
|
|
143
|
-
useEffect(() => {
|
|
144
|
-
const pos = initPositinoCache(itemSize, sourceData.length);
|
|
145
|
-
setPositions(pos);
|
|
146
|
-
}, [itemSize, sourceData]);
|
|
147
|
-
// 可视区域总高度
|
|
148
|
-
const getContainerHeight = () => {
|
|
149
|
-
// 初始首页列表高度
|
|
150
|
-
const initH = itemSize * sourceData.length;
|
|
151
|
-
// 未设置containerSize高度,判断首页高度小于设备高度时,滚动容器高度为首页数据高度,减5为分页触发的偏移量
|
|
152
|
-
return initH < clientHeight
|
|
153
|
-
? initH + overscan * itemSize - 5
|
|
154
|
-
: Math.min(containerSize, clientHeight); // Math.min(containerSize, clientHeight)
|
|
155
|
-
};
|
|
156
|
-
// 可视区域条数
|
|
157
|
-
const visibleCount = () => {
|
|
158
|
-
return Math.ceil(getContainerHeight() / itemSize) + overscan;
|
|
159
|
-
};
|
|
160
|
-
const end = () => {
|
|
161
|
-
return start + visibleCount();
|
|
162
|
-
};
|
|
163
|
-
const listHeight = () => {
|
|
164
|
-
return list.length * itemSize;
|
|
165
|
-
};
|
|
166
|
-
const visibleData = () => {
|
|
167
|
-
return list.slice(start, Math.min(end(), list.length));
|
|
168
|
-
};
|
|
169
|
-
const updateTotalSize = useCallback(() => {
|
|
170
|
-
if (!itemsRef.current)
|
|
171
|
-
return;
|
|
172
|
-
const items = itemsRef.current.children;
|
|
173
|
-
if (!items.length)
|
|
174
|
-
return;
|
|
175
|
-
// 更新缓存
|
|
176
|
-
updateItemSize(positions, items, 'height');
|
|
177
|
-
}, [positions]);
|
|
178
|
-
// 滚动监听
|
|
179
|
-
const listScroll = (e) => {
|
|
180
|
-
const scrollTop = e.detail ? e.detail.scrollTop : e.target.scrollTop;
|
|
181
|
-
const scrollSize = Math.floor(scrollTop);
|
|
182
|
-
const startIndex = binarySearch(positions, scrollSize, false);
|
|
183
|
-
const overStart = startIndex - overscan > -1 ? startIndex - overscan : 0;
|
|
184
|
-
const endIndex = end();
|
|
185
|
-
if (!itemEqualSize) {
|
|
186
|
-
updateTotalSize();
|
|
187
|
-
}
|
|
188
|
-
setStart(Math.floor(scrollTop / itemSize));
|
|
189
|
-
setOptions({ startOffset, startIndex, overStart, endIndex });
|
|
190
|
-
if (end() > list.length - 1) {
|
|
191
|
-
onScroll && onScroll();
|
|
192
|
-
}
|
|
193
|
-
setStartOffset(scrollTop - (scrollTop % itemSize));
|
|
194
|
-
};
|
|
195
|
-
return (React__default.createElement("div", { className: className ? `${className} nut-virtualList-box` : 'nut-virtualList-box', ...rest, style: {
|
|
196
|
-
height: containerSize ? `${offSetSize}px` : '',
|
|
197
|
-
} },
|
|
198
|
-
React__default.createElement(ScrollView, { scrollTop: 0, scrollY: true, ref: scrollRef, className: "nut-virtuallist", style: {
|
|
199
|
-
height: `${getContainerHeight()}px`,
|
|
200
|
-
}, onScroll: listScroll },
|
|
201
|
-
React__default.createElement("div", { className: "nut-virtuallist-phantom", style: { height: `${listHeight()}px` } }),
|
|
202
|
-
React__default.createElement("div", { className: "nut-virtuallist-container", ref: itemsRef, style: { transform: `translate3d(0, ${startOffset}px, 0)` } }, visibleData().map((data, index) => {
|
|
203
|
-
const { overStart } = options;
|
|
204
|
-
const dataIndex = overStart + index;
|
|
205
|
-
key && data[key] ? data[key] : dataIndex;
|
|
206
|
-
return (React__default.createElement("div", { ref: dataIndex === 0 ? firstItemRef : null, "data-index": `${dataIndex}`, className: "nut-virtuallist-item", key: `${data}`, style: {
|
|
207
|
-
height: `${itemEqualSize ? `${itemSize}px` : 'auto'}`,
|
|
208
|
-
} }, ItemRender ? (React__default.createElement(ItemRender, { data: data, index: `${index}` })) : (data)));
|
|
209
|
-
})))));
|
|
210
|
-
};
|
|
211
|
-
VirtualList.defaultProps = defaultProps;
|
|
212
|
-
VirtualList.displayName = 'NutVirtualList';
|
|
213
|
-
|
|
214
|
-
export { VirtualList as V };
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import React__default, { useState, useEffect } from 'react';
|
|
2
|
-
import { getSystemInfo, createOffscreenCanvas } from '@tarojs/taro';
|
|
3
|
-
import classNames from 'classnames';
|
|
4
|
-
import { u as useConfig } from './configprovider-67d19d3a.js';
|
|
5
|
-
import { c as cn } from './bem-350c1702.js';
|
|
6
|
-
|
|
7
|
-
const defaultProps = {
|
|
8
|
-
content: '',
|
|
9
|
-
fullPage: true,
|
|
10
|
-
zIndex: 2000,
|
|
11
|
-
gapX: 24,
|
|
12
|
-
gapY: 48,
|
|
13
|
-
width: 120,
|
|
14
|
-
height: 64,
|
|
15
|
-
image: '',
|
|
16
|
-
imageWidth: 120,
|
|
17
|
-
imageHeight: 64,
|
|
18
|
-
rotate: -22,
|
|
19
|
-
fontColor: 'rgba(0,0,0,.15)',
|
|
20
|
-
fontStyle: 'normal',
|
|
21
|
-
fontFamily: 'PingFang SC',
|
|
22
|
-
fontWeight: 'normal',
|
|
23
|
-
fontSize: 14,
|
|
24
|
-
};
|
|
25
|
-
const WaterMark = (props) => {
|
|
26
|
-
const { locale } = useConfig();
|
|
27
|
-
const { content, fullPage, zIndex, className, gapX, gapY, width, height, image, imageWidth, imageHeight, rotate, fontColor, fontStyle, fontFamily, fontWeight, fontSize, style, children, } = {
|
|
28
|
-
...defaultProps,
|
|
29
|
-
...props,
|
|
30
|
-
};
|
|
31
|
-
const [base64Url, setBase64Url] = useState('');
|
|
32
|
-
const b = cn('watermark');
|
|
33
|
-
const classes = classNames({
|
|
34
|
-
[`${b('')}`]: true,
|
|
35
|
-
[`${b('')}-full-page`]: fullPage,
|
|
36
|
-
});
|
|
37
|
-
const cls = classNames(classes, className);
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
init();
|
|
40
|
-
}, []);
|
|
41
|
-
const init = () => {
|
|
42
|
-
let ratio = 1;
|
|
43
|
-
getSystemInfo().then((res) => {
|
|
44
|
-
ratio = res.pixelRatio;
|
|
45
|
-
const canvasWidth = `${(gapX + width) * ratio}px`;
|
|
46
|
-
const canvasHeight = `${(gapY + height) * ratio}px`;
|
|
47
|
-
const markWidth = width * ratio;
|
|
48
|
-
const markHeight = height * ratio;
|
|
49
|
-
let ctx;
|
|
50
|
-
let canvas;
|
|
51
|
-
if (process.env.TARO_ENV === 'h5') {
|
|
52
|
-
canvas = document.createElement('canvas');
|
|
53
|
-
ctx = canvas.getContext('2d');
|
|
54
|
-
canvas.setAttribute('width', canvasWidth);
|
|
55
|
-
canvas.setAttribute('height', canvasHeight);
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
canvas = createOffscreenCanvas({
|
|
59
|
-
type: '2d',
|
|
60
|
-
width: Number(canvasWidth),
|
|
61
|
-
height: Number(canvasHeight),
|
|
62
|
-
});
|
|
63
|
-
ctx = canvas.getContext('2d');
|
|
64
|
-
}
|
|
65
|
-
if (ctx) {
|
|
66
|
-
if (image) {
|
|
67
|
-
ctx.translate(markWidth / 2, markHeight / 2);
|
|
68
|
-
ctx.rotate((Math.PI / 180) * Number(rotate));
|
|
69
|
-
let img;
|
|
70
|
-
if (process.env.TARO_ENV === 'h5') {
|
|
71
|
-
img = new Image();
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
img = canvas.createImage();
|
|
75
|
-
}
|
|
76
|
-
img.crossOrigin = 'anonymous';
|
|
77
|
-
img.referrerPolicy = 'no-referrer';
|
|
78
|
-
img.src = image;
|
|
79
|
-
img.onload = () => {
|
|
80
|
-
ctx.drawImage(img, (-imageWidth * ratio) / 2, (-imageHeight * ratio) / 2, imageWidth * ratio, imageHeight * ratio);
|
|
81
|
-
ctx.restore();
|
|
82
|
-
setBase64Url(canvas.toDataURL());
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
else if (content) {
|
|
86
|
-
ctx.textBaseline = 'middle'; // 设置或返回在绘制文本时使用的当前文本基线。(正中)
|
|
87
|
-
ctx.textAlign = 'center'; // 设置或返回文本内容的当前对齐方式。
|
|
88
|
-
// 文字绕中间旋转
|
|
89
|
-
ctx.translate(markWidth / 2, markHeight / 2);
|
|
90
|
-
ctx.rotate((Math.PI / 180) * Number(rotate));
|
|
91
|
-
const markSize = Number(fontSize) * ratio;
|
|
92
|
-
ctx.font = `${fontStyle} normal ${fontWeight} ${markSize}px/${markHeight}px ${fontFamily}`;
|
|
93
|
-
ctx.fillStyle = fontColor;
|
|
94
|
-
ctx.fillText(content, 0, 0); // 在画布上绘制"被填充的"文本。
|
|
95
|
-
ctx.restore(); // 返回之前保存过的路径状态和属性。
|
|
96
|
-
setBase64Url(canvas.toDataURL());
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
throw new Error(locale.watermark.errorCanvasTips);
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
};
|
|
104
|
-
return (React__default.createElement("div", { className: cls, style: {
|
|
105
|
-
zIndex,
|
|
106
|
-
backgroundSize: `${gapX + width}px`,
|
|
107
|
-
backgroundImage: `url('${base64Url}')`,
|
|
108
|
-
...style,
|
|
109
|
-
} }));
|
|
110
|
-
};
|
|
111
|
-
WaterMark.defaultProps = defaultProps;
|
|
112
|
-
WaterMark.displayName = 'NutWaterMark';
|
|
113
|
-
|
|
114
|
-
export { WaterMark as W };
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
const zhCN = {
|
|
2
|
-
save: '保存',
|
|
3
|
-
confirm: '确认',
|
|
4
|
-
cancel: '取消',
|
|
5
|
-
done: '完成',
|
|
6
|
-
noData: '暂无数据',
|
|
7
|
-
placeholder: '请输入内容',
|
|
8
|
-
select: '请选择',
|
|
9
|
-
video: {
|
|
10
|
-
errorTip: '视频加载失败',
|
|
11
|
-
clickRetry: '点击重试',
|
|
12
|
-
},
|
|
13
|
-
fixednav: {
|
|
14
|
-
activeText: '收起导航',
|
|
15
|
-
unActiveText: '快速导航',
|
|
16
|
-
},
|
|
17
|
-
infiniteloading: {
|
|
18
|
-
pullRefreshText: '松开刷新',
|
|
19
|
-
loadText: '加载中……',
|
|
20
|
-
loadMoreText: '哎呀,这里是底部了啦',
|
|
21
|
-
},
|
|
22
|
-
pagination: {
|
|
23
|
-
prev: '上一页',
|
|
24
|
-
next: '下一页',
|
|
25
|
-
},
|
|
26
|
-
range: {
|
|
27
|
-
rangeText: '不在该区间内',
|
|
28
|
-
},
|
|
29
|
-
calendaritem: {
|
|
30
|
-
weekdays: ['日', '一', '二', '三', '四', '五', '六'],
|
|
31
|
-
end: '结束',
|
|
32
|
-
start: '开始',
|
|
33
|
-
confirm: '确认',
|
|
34
|
-
title: '日历选择',
|
|
35
|
-
monthTitle: (year, month) => `${year}年${month}月`,
|
|
36
|
-
today: '今天',
|
|
37
|
-
loadPreviousMonth: '加载上一个月',
|
|
38
|
-
noEarlierMonth: '没有更早月份',
|
|
39
|
-
},
|
|
40
|
-
shortpassword: {
|
|
41
|
-
title: '请输入密码',
|
|
42
|
-
desc: '您使用了虚拟资产,请进行验证',
|
|
43
|
-
tips: '忘记密码',
|
|
44
|
-
},
|
|
45
|
-
uploader: {
|
|
46
|
-
ready: '准备完成',
|
|
47
|
-
readyUpload: '准备上传',
|
|
48
|
-
waitingUpload: '等待上传',
|
|
49
|
-
uploading: '上传中...',
|
|
50
|
-
success: '上传成功',
|
|
51
|
-
error: '上传失败',
|
|
52
|
-
deleteWord: '用户阻止了删除!',
|
|
53
|
-
},
|
|
54
|
-
countdown: {
|
|
55
|
-
day: '天',
|
|
56
|
-
hour: '时',
|
|
57
|
-
minute: '分',
|
|
58
|
-
second: '秒',
|
|
59
|
-
},
|
|
60
|
-
address: {
|
|
61
|
-
selectRegion: '请选择所在地区',
|
|
62
|
-
deliveryTo: '配送至',
|
|
63
|
-
chooseAnotherAddress: '选择其他地址',
|
|
64
|
-
},
|
|
65
|
-
signature: {
|
|
66
|
-
reSign: '重签',
|
|
67
|
-
unSupportTpl: '对不起,当前浏览器不支持Canvas,无法使用本控件!',
|
|
68
|
-
},
|
|
69
|
-
ecard: {
|
|
70
|
-
chooseText: '请选择电子卡面值',
|
|
71
|
-
otherValueText: '其他面值',
|
|
72
|
-
placeholder: '请输入1-5000整数',
|
|
73
|
-
},
|
|
74
|
-
timeselect: {
|
|
75
|
-
pickupTime: '取件时间',
|
|
76
|
-
},
|
|
77
|
-
sku: {
|
|
78
|
-
buyNow: '立即购买',
|
|
79
|
-
buyNumber: '购买数量',
|
|
80
|
-
addToCard: '加入购物车',
|
|
81
|
-
},
|
|
82
|
-
skuheader: {
|
|
83
|
-
skuId: '商品编号',
|
|
84
|
-
},
|
|
85
|
-
addresslist: {
|
|
86
|
-
addAddress: '新建地址',
|
|
87
|
-
},
|
|
88
|
-
comment: {
|
|
89
|
-
complaintsText: '我要投诉',
|
|
90
|
-
additionalReview: (day) => `购买${day}天后追评`,
|
|
91
|
-
additionalImages: (length) => `${length}张追评图片`,
|
|
92
|
-
},
|
|
93
|
-
searchbar: {
|
|
94
|
-
basePlaceholder: '上京东,购好物',
|
|
95
|
-
text: '文本',
|
|
96
|
-
test: '测试',
|
|
97
|
-
title1: '基础用法',
|
|
98
|
-
title2: '搜索框形状及最大长度',
|
|
99
|
-
title3: '搜索框内外背景设置',
|
|
100
|
-
title4: '搜索框文本设置',
|
|
101
|
-
title5: '自定义图标设置',
|
|
102
|
-
title6: '数据改变监听',
|
|
103
|
-
},
|
|
104
|
-
audio: {
|
|
105
|
-
back: '快退',
|
|
106
|
-
forward: '快进',
|
|
107
|
-
pause: '暂停',
|
|
108
|
-
start: '开始',
|
|
109
|
-
mute: '静音',
|
|
110
|
-
tips: 'onPlayEnd事件在loop=false时才会触发',
|
|
111
|
-
},
|
|
112
|
-
datepicker: {
|
|
113
|
-
year: '年',
|
|
114
|
-
month: '月',
|
|
115
|
-
day: '日',
|
|
116
|
-
hour: '时',
|
|
117
|
-
min: '分',
|
|
118
|
-
seconds: '秒',
|
|
119
|
-
},
|
|
120
|
-
pullToRefresh: {
|
|
121
|
-
pullingText: '下拉刷新',
|
|
122
|
-
canReleaseText: '松开刷新',
|
|
123
|
-
refreshingText: '加载中...',
|
|
124
|
-
completeText: '刷新成功',
|
|
125
|
-
},
|
|
126
|
-
watermark: {
|
|
127
|
-
errorCanvasTips: '当前环境不支持Canvas',
|
|
128
|
-
},
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
export { zhCN as z };
|