@nutui/nutui-react-taro 1.5.2 → 1.5.3-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -1
- package/dist/esm/ActionSheet.js +14 -90
- package/dist/esm/Address.js +21 -620
- package/dist/esm/Animate.js +7 -53
- package/dist/esm/AnimatingNumbers.js +7 -125
- package/dist/esm/Audio.js +19 -264
- package/dist/esm/Avatar.js +11 -130
- package/dist/esm/{AvatarContext-15733596.js → AvatarContext-c96afdcc.js} +3 -1
- package/dist/esm/AvatarGroup.js +11 -41
- package/dist/esm/BackTop.js +10 -138
- package/dist/esm/Badge.js +9 -71
- package/dist/esm/Barrage.js +8 -97
- package/dist/esm/Button.js +9 -108
- package/dist/esm/Calendar.js +20 -128
- package/dist/esm/CalendarItem.js +12 -674
- package/dist/esm/Card.js +11 -61
- package/dist/esm/Cascader.js +16 -671
- package/dist/esm/Cell.js +9 -101
- package/dist/esm/CellGroup.js +5 -2
- package/dist/esm/Checkbox.js +7 -5
- package/dist/esm/CheckboxGroup.js +8 -111
- package/dist/esm/CircleProgress.js +8 -114
- package/dist/esm/Col.js +7 -57
- package/dist/esm/Collapse.js +7 -97
- package/dist/esm/CollapseItem.js +8 -146
- package/dist/esm/ConfigProvider.js +8 -187
- package/dist/esm/CountDown.js +9 -247
- package/dist/esm/DatePicker.js +25 -309
- package/dist/esm/Dialog.js +17 -296
- package/dist/esm/Divider.js +7 -34
- package/dist/esm/Drag.js +7 -118
- package/dist/esm/Elevator.js +8 -234
- package/dist/esm/Ellipsis.js +10 -176
- package/dist/esm/Empty.js +8 -79
- package/dist/esm/FixedNav.js +14 -103
- package/dist/esm/Form.js +10 -215
- package/dist/esm/FormItem.js +10 -3
- package/dist/esm/Grid.js +11 -81
- package/dist/esm/GridItem.js +13 -123
- package/dist/esm/Icon.js +5 -2
- package/dist/esm/Image.js +11 -169
- package/dist/esm/ImagePreview.js +19 -225
- package/dist/esm/Indicator.js +7 -50
- package/dist/esm/Infiniteloading.js +14 -215
- package/dist/esm/Input.js +12 -362
- package/dist/esm/InputNumber.js +9 -275
- package/dist/esm/Layout.js +5 -13
- package/dist/esm/Menu.js +10 -153
- package/dist/esm/MenuItem.js +15 -175
- package/dist/esm/NavBar.js +9 -114
- package/dist/esm/NoticeBar.js +10 -568
- package/dist/esm/Notify.js +8 -234
- package/dist/esm/NumberKeyboard.js +17 -247
- package/dist/esm/Overlay.js +6 -2
- package/dist/esm/Pagination.js +9 -168
- package/dist/esm/Picker.js +22 -494
- package/dist/esm/Popover.js +12 -223
- package/dist/esm/Popup.js +13 -193
- package/dist/esm/Price.js +6 -84
- package/dist/esm/Progress.js +9 -122
- package/dist/esm/PullToRefresh.js +13 -276
- package/dist/esm/Radio.js +8 -4
- package/dist/esm/RadioGroup.js +7 -120
- package/dist/esm/Range.js +15 -406
- package/dist/esm/Rate.js +9 -121
- package/dist/esm/Row.js +7 -49
- package/dist/esm/SearchBar.js +12 -235
- package/dist/esm/ShortPassword.js +17 -191
- package/dist/esm/SideNavBar.js +19 -57
- package/dist/esm/SideNavBarItem.js +5 -24
- package/dist/esm/Signature.js +13 -153
- package/dist/esm/Skeleton.js +12 -98
- package/dist/esm/Step.js +10 -87
- package/dist/esm/Steps.js +8 -38
- package/dist/esm/Sticky.js +11 -190
- package/dist/esm/SubSideNavBar.js +6 -78
- package/dist/esm/Swipe.js +10 -230
- package/dist/esm/Swiper.js +9 -490
- package/dist/esm/SwiperItem.js +8 -36
- package/dist/esm/Switch.js +6 -71
- package/dist/esm/TabPane.js +5 -2
- package/dist/esm/Tabbar.js +6 -68
- package/dist/esm/TabbarItem.js +9 -78
- package/dist/esm/Table.js +12 -140
- package/dist/esm/Tabs.js +8 -5
- package/dist/esm/Tag.js +10 -110
- package/dist/esm/TextArea.js +9 -148
- package/dist/esm/TimeDetail.js +9 -67
- package/dist/esm/TimePannel.js +9 -29
- package/dist/esm/TimeSelect.js +19 -171
- package/dist/esm/Toast.js +7 -268
- package/dist/esm/TrendArrow.js +7 -99
- package/dist/esm/Uploader.js +17 -566
- package/dist/esm/{UserContext-101ad4a4.js → UserContext-0aac9a82.js} +3 -1
- package/dist/esm/{UserContext-2629d479.js → UserContext-e402e1a6.js} +3 -1
- package/dist/esm/{UserContext-b33bcf21.js → UserContext-e8176108.js} +3 -1
- package/dist/esm/Video.js +7 -90
- package/dist/esm/VirtualList.js +9 -313
- package/dist/esm/WaterMark.js +11 -111
- package/dist/esm/actionsheet.taro-e6a51446.js +53 -0
- package/dist/esm/address.taro-3a9b6396.js +461 -0
- package/dist/esm/animate.taro-fb7986d6.js +40 -0
- package/dist/esm/animatingnumbers.taro-03e5d61d.js +104 -0
- package/dist/esm/audio.taro-87ec8bf2.js +161 -0
- package/dist/esm/avatar.taro-3676f38f.js +103 -0
- package/dist/esm/avatargroup-f3574510.js +34 -0
- package/dist/esm/backtop.taro-66394a36.js +48 -0
- package/dist/esm/badge.taro-a4e59c11.js +52 -0
- package/dist/esm/barrage.taro-0495a1b2.js +94 -0
- package/dist/esm/{bem-3b438e61.js → bem-350c1702.js} +3 -6
- package/dist/esm/button.taro-9244d065.js +100 -0
- package/dist/esm/calendar.taro-670842ea.js +65 -0
- package/dist/esm/calendaritem.taro-2a603571.js +787 -0
- package/dist/esm/can-use-dom-3eeb5af4.js +6 -0
- package/dist/esm/card.taro-e4c76dad.js +33 -0
- package/dist/esm/cascader.taro-a5553aa5.js +437 -0
- package/dist/esm/cell.taro-a10a74d3.js +64 -0
- package/dist/esm/cellgroup.taro-abe501bc.js +25 -0
- package/dist/esm/checkbox.taro-6120e3e3.js +171 -0
- package/dist/esm/circleprogress.taro-79854448.js +109 -0
- package/dist/esm/col.taro-53eed3cc.js +41 -0
- package/dist/esm/collapse.taro-1a9e4ba2.js +83 -0
- package/dist/esm/collapseitem-4d0bc55d.js +83 -0
- package/dist/esm/configprovider-67d19d3a.js +19 -0
- package/dist/esm/configprovider.taro-8d71eb49.js +42 -0
- package/dist/esm/countdown.taro-5b17c607.js +226 -0
- package/dist/esm/datepicker.taro-477ad357.js +275 -0
- package/dist/esm/dialog.taro-a3267d29.js +118 -0
- package/dist/esm/divider.taro-26d1d8b4.js +35 -0
- package/dist/esm/drag.taro-79bb8744.js +110 -0
- package/dist/esm/elevator.taro-6019669e.js +178 -0
- package/dist/esm/ellipsis.taro-f15f26da.js +241 -0
- package/dist/esm/empty.taro-04ae4389.js +62 -0
- package/dist/esm/fixednav.taro-1f05acaf.js +53 -0
- package/dist/esm/form.taro-0b399b30.js +178 -0
- package/dist/esm/formitem.taro-190a3326.js +89 -0
- package/dist/esm/get-scroll-parent-b4a07e65.js +25 -0
- package/dist/esm/grid.taro-3503b82c.js +61 -0
- package/dist/esm/{grid.context-2ee27d95.js → grid.taro.context-c2bbfb4f.js} +4 -2
- package/dist/esm/griditem.taro-cdb3f119.js +98 -0
- package/dist/esm/icon-296a1bec.js +63 -0
- package/dist/esm/icon.taro-296a1bec.js +63 -0
- package/dist/esm/image.taro-142cf512.js +64 -0
- package/dist/esm/imagepreview.taro-c50bb0a3.js +167 -0
- package/dist/esm/index-5bcb0ff8.js +7 -0
- package/dist/esm/indicator.taro-cba8b010.js +37 -0
- package/dist/esm/infiniteloading.taro-183bccbf.js +144 -0
- package/dist/esm/input.taro-97af6c96.js +240 -0
- package/dist/esm/inputnumber.taro-91f65d17.js +130 -0
- package/dist/esm/layout.taro-9046d093.js +11 -0
- package/dist/esm/menu.taro-7e4038a1.js +99 -0
- package/dist/esm/menuitem.taro-96cc4f15.js +130 -0
- package/dist/esm/navbar.taro-777c4705.js +79 -0
- package/dist/esm/noticebar.taro-4a23cdee.js +448 -0
- package/dist/esm/notify.taro-e17c6f82.js +75 -0
- package/dist/esm/numberkeyboard.taro-1bc24744.js +159 -0
- package/dist/esm/nutui-react.es.js +119 -94
- package/dist/esm/offsetContext-c2a746fa.js +5 -0
- package/dist/esm/overlay.taro-21e87fb1.js +69 -0
- package/dist/esm/pagination.taro-715a173b.js +124 -0
- package/dist/esm/picker.taro-0073eeaa.js +472 -0
- package/dist/esm/popover.taro-ad5e76ea.js +156 -0
- package/dist/esm/popup.taro-01676bff.js +137 -0
- package/dist/esm/price.taro-776ed16e.js +83 -0
- package/dist/esm/progress.taro-f0ce38e9.js +90 -0
- package/dist/esm/pulltorefresh.taro-a294f656.js +181 -0
- package/dist/esm/radio.taro-a6eff96c.js +168 -0
- package/dist/esm/range.taro-d8fc7656.js +332 -0
- package/dist/esm/rate.taro-6cdf03bd.js +75 -0
- package/dist/esm/row.taro-f64d4a13.js +46 -0
- package/dist/esm/searchbar.taro-0c25927b.js +152 -0
- package/dist/esm/shortpassword.taro-9ee034f7.js +111 -0
- package/dist/esm/sidenavbar.taro-c307b35e.js +35 -0
- package/dist/esm/sidenavbaritem.taro-5a7965d0.js +12 -0
- package/dist/esm/signature.taro-ec4e713b.js +143 -0
- package/dist/esm/skeleton.taro-76faf63f.js +62 -0
- package/dist/esm/step.taro-b7903e8c.js +59 -0
- package/dist/esm/steps.taro-c82d2252.js +30 -0
- package/dist/esm/sticky.taro-218bda37.js +138 -0
- package/dist/esm/subsidenavbar.taro-69cb9752.js +63 -0
- package/dist/esm/supports-passive-c85ef996.js +18 -0
- package/dist/esm/swipe.taro-ea35f07f.js +177 -0
- package/dist/esm/swiper.taro-7a94e211.js +451 -0
- package/dist/esm/swiperitem-c9e3d0d5.js +29 -0
- package/dist/esm/switch.taro-34ca8228.js +50 -0
- package/dist/esm/tabbar.taro-9acfc2fa.js +59 -0
- package/dist/esm/tabbaritem.taro-bf517487.js +58 -0
- package/dist/esm/table.taro-91fc0c01.js +93 -0
- package/dist/esm/tabpane.taro-4ca340ef.js +23 -0
- package/dist/esm/tabs.taro-6a7524a4.js +140 -0
- package/dist/esm/tag.taro-23ba0834.js +92 -0
- package/dist/esm/textarea.taro-442e7350.js +94 -0
- package/dist/esm/timedetail.taro-5b2f2269.js +44 -0
- package/dist/esm/timepannel.taro-d6e40180.js +22 -0
- package/dist/esm/timeselect.taro-a07036f4.js +133 -0
- package/dist/esm/toast.taro-d6c14811.js +109 -0
- package/dist/esm/trendarrow.taro-b8c5ccd9.js +73 -0
- package/dist/esm/typings-b9828dba.js +9 -0
- package/dist/esm/uploader.taro-587e6bf3.js +492 -0
- package/dist/esm/useClientRect-1f8ed1fe.js +18 -0
- package/dist/esm/useTouch-db24bb5c.js +69 -0
- package/dist/esm/video-f1be8a91.js +67 -0
- package/dist/esm/virtuallist.taro-f0b0270d.js +214 -0
- package/dist/esm/watermark.taro-9ce2ae37.js +114 -0
- package/dist/esm/zh-CN-c779e6c1.js +131 -0
- package/dist/locales/base.js +1 -1
- package/dist/locales/en-US.js +1 -1
- package/dist/locales/id-ID.js +1 -1
- package/dist/locales/zh-CN.js +1 -1
- package/dist/locales/zh-TW.js +1 -1
- package/dist/locales/zh-UG.js +1 -1
- package/dist/nutui.react.mjs +13028 -14863
- package/dist/nutui.react.umd.js +13027 -14864
- package/dist/style.mjs +1 -1
- package/dist/types/index.d.ts +176 -183
- package/package.json +1 -1
- package/dist/esm/cellgroup-fcc72767.js +0 -34
- package/dist/esm/checkbox-44e13cd0.js +0 -137
- package/dist/esm/date-c7aad4c0.js +0 -97
- package/dist/esm/formitem-8a73a5fb.js +0 -157
- package/dist/esm/get-scroll-parent-5f85dee8.js +0 -24
- package/dist/esm/icon-4ef1581c.js +0 -70
- package/dist/esm/index-030b7245.js +0 -11
- package/dist/esm/offsetContext-3ab00d40.js +0 -16
- package/dist/esm/overlay-de6c79d5.js +0 -83
- package/dist/esm/radio-9f141e6b.js +0 -118
- package/dist/esm/render-bbebb760.js +0 -79
- package/dist/esm/tabpane-01075e6c.js +0 -29
- package/dist/esm/tabs-e1b4e4b1.js +0 -181
- package/dist/esm/typings-f27b58f4.js +0 -8
- package/dist/esm/useClientRect-56bb675b.js +0 -39
- package/dist/esm/useTouch-cf73a407.js +0 -99
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import React__default, { useState, useRef } from 'react';
|
|
2
|
+
import { createInnerAudioContext } from '@tarojs/taro';
|
|
3
|
+
import { I as Icon } from './icon.taro-296a1bec.js';
|
|
4
|
+
import { R as Range } from './range.taro-d8fc7656.js';
|
|
5
|
+
import { B as Button } from './button.taro-9244d065.js';
|
|
6
|
+
import { c as cn } from './bem-350c1702.js';
|
|
7
|
+
import { u as useConfig } from './configprovider.taro-8d71eb49.js';
|
|
8
|
+
import { C as ComponentDefaults } from './typings-b9828dba.js';
|
|
9
|
+
|
|
10
|
+
const b = cn('audio');
|
|
11
|
+
const warn = console.warn;
|
|
12
|
+
const defaultProps = {
|
|
13
|
+
...ComponentDefaults,
|
|
14
|
+
className: '',
|
|
15
|
+
url: '',
|
|
16
|
+
style: {},
|
|
17
|
+
autoplay: false,
|
|
18
|
+
loop: false,
|
|
19
|
+
type: 'progress',
|
|
20
|
+
onFastBack: (ctx) => { },
|
|
21
|
+
onForward: (ctx) => { },
|
|
22
|
+
onPause: (ctx) => { },
|
|
23
|
+
onPlay: (ctx) => { },
|
|
24
|
+
onPlayEnd: (ctx) => { },
|
|
25
|
+
onCanPlay: (ctx) => { },
|
|
26
|
+
};
|
|
27
|
+
const Audio = (props) => {
|
|
28
|
+
const { locale } = useConfig();
|
|
29
|
+
const { className, url, style, autoplay, loop, type, onFastBack, onForward, onPause, onPlay, onPlayEnd, onCanPlay, children, iconClassPrefix, iconFontClassName, ...rest } = {
|
|
30
|
+
...defaultProps,
|
|
31
|
+
...props,
|
|
32
|
+
};
|
|
33
|
+
const [playing, setPlaying] = useState(false);
|
|
34
|
+
const [totalSeconds, setTotalSeconds] = useState(0);
|
|
35
|
+
const [percent, setPercent] = useState(0);
|
|
36
|
+
const [isCanPlay, setIsCanPlay] = useState(false);
|
|
37
|
+
const [currentDuration, setCurrentDuration] = useState('00:00:00');
|
|
38
|
+
const statusRef = useRef({
|
|
39
|
+
currentTime: 0,
|
|
40
|
+
currentDuration: '00:00:00',
|
|
41
|
+
percent: 0,
|
|
42
|
+
});
|
|
43
|
+
const audioRef = useRef(createInnerAudioContext());
|
|
44
|
+
const audioCtx = audioRef.current;
|
|
45
|
+
audioCtx.src = url;
|
|
46
|
+
audioCtx.autoplay = autoplay || false;
|
|
47
|
+
audioCtx.loop = loop || false;
|
|
48
|
+
audioCtx.onPause(() => {
|
|
49
|
+
props.onPause && props.onPause(audioCtx);
|
|
50
|
+
});
|
|
51
|
+
audioCtx.onEnded(() => {
|
|
52
|
+
if (props.loop) {
|
|
53
|
+
warn(locale.audio.tips || 'onPlayEnd事件在loop=false时才会触发');
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
props.onPlayEnd && props.onPlayEnd(audioCtx);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
audioCtx.onPlay(() => {
|
|
60
|
+
const { duration } = audioCtx;
|
|
61
|
+
setTotalSeconds(Math.floor(duration));
|
|
62
|
+
props.onPlay && props.onPlay(audioCtx);
|
|
63
|
+
});
|
|
64
|
+
audioCtx.onCanplay(() => {
|
|
65
|
+
const intervalID = setInterval(function () {
|
|
66
|
+
if (audioCtx.duration !== 0) {
|
|
67
|
+
setTotalSeconds(audioCtx.duration);
|
|
68
|
+
clearInterval(intervalID);
|
|
69
|
+
}
|
|
70
|
+
}, 500);
|
|
71
|
+
setIsCanPlay(true);
|
|
72
|
+
props.onCanPlay && props.onCanPlay(audioCtx);
|
|
73
|
+
});
|
|
74
|
+
audioCtx.onTimeUpdate(() => {
|
|
75
|
+
const time = parseInt(`${audioCtx.currentTime}`);
|
|
76
|
+
const formated = formatSeconds(`${time}`);
|
|
77
|
+
statusRef.current.currentDuration = formated;
|
|
78
|
+
setPercent((time / totalSeconds) * 100);
|
|
79
|
+
setCurrentDuration(formatSeconds(audioCtx.currentTime.toString()));
|
|
80
|
+
});
|
|
81
|
+
audioCtx.onError((res) => {
|
|
82
|
+
console.log('code', res.errCode);
|
|
83
|
+
console.log('message', res.errMsg);
|
|
84
|
+
});
|
|
85
|
+
function formatSeconds(value) {
|
|
86
|
+
if (!value) {
|
|
87
|
+
return '00:00:00';
|
|
88
|
+
}
|
|
89
|
+
const time = parseInt(value);
|
|
90
|
+
const hours = Math.floor(time / 3600);
|
|
91
|
+
const minutes = Math.floor((time - hours * 3600) / 60);
|
|
92
|
+
const secondss = time - hours * 3600 - minutes * 60;
|
|
93
|
+
let result = '';
|
|
94
|
+
result += `${`0${hours.toString()}`.slice(-2)}:`;
|
|
95
|
+
result += `${`0${minutes.toString()}`.slice(-2)}:`;
|
|
96
|
+
result += `0${secondss.toString()}`.slice(-2);
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
const handleBack = () => {
|
|
100
|
+
const currentTime = Math.floor(audioCtx.currentTime);
|
|
101
|
+
statusRef.current.currentTime = Math.max(currentTime - 1, 0);
|
|
102
|
+
setCurrentDuration(formatSeconds(statusRef.current.currentTime.toString()));
|
|
103
|
+
audioCtx.seek(statusRef.current.currentTime);
|
|
104
|
+
props.onFastBack && props.onFastBack(audioCtx);
|
|
105
|
+
};
|
|
106
|
+
const handleForward = () => {
|
|
107
|
+
const currentTime = Math.floor(audioCtx.currentTime);
|
|
108
|
+
statusRef.current.currentTime = Math.min(currentTime + 1, audioCtx.duration);
|
|
109
|
+
setCurrentDuration(formatSeconds(statusRef.current.currentTime.toString()));
|
|
110
|
+
audioCtx.seek(statusRef.current.currentTime);
|
|
111
|
+
props.onForward && props.onForward(audioCtx);
|
|
112
|
+
};
|
|
113
|
+
const handleStatusChange = () => {
|
|
114
|
+
setPlaying(!playing);
|
|
115
|
+
if (!playing) {
|
|
116
|
+
audioCtx.play();
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
audioCtx.pause();
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
const renderIcon = () => {
|
|
123
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
124
|
+
React__default.createElement("div", { className: b('icon') },
|
|
125
|
+
React__default.createElement("div", { className: `${b('icon-box')} ${playing ? b('icon-play') : b('icon-stop')}`, onClick: handleStatusChange }, playing ? (React__default.createElement(Icon, { classPrefix: iconClassPrefix, fontClassName: iconFontClassName, name: "service", className: "nut-icon-loading" })) : (React__default.createElement(Icon, { classPrefix: iconClassPrefix, fontClassName: iconFontClassName, name: "service" }))))));
|
|
126
|
+
};
|
|
127
|
+
const renderProgerss = () => {
|
|
128
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
129
|
+
React__default.createElement("div", { className: b('progress') },
|
|
130
|
+
React__default.createElement("div", { className: "time" }, currentDuration),
|
|
131
|
+
React__default.createElement("div", { className: b('progress-bar-wrapper') },
|
|
132
|
+
React__default.createElement(Range, { modelValue: percent, hiddenTag: true, hiddenRange: true, "inactive-color": "#cccccc", "active-color": "#fa2c19" })),
|
|
133
|
+
React__default.createElement("div", { className: "time" }, formatSeconds(`${totalSeconds}`) || '00:00:00')),
|
|
134
|
+
React__default.createElement("div", { className: isCanPlay ? 'custom-button-group' : 'custom-button-group-disable' },
|
|
135
|
+
React__default.createElement(Button, { type: "primary", size: "small", className: "back", onClick: handleBack }, locale.audio.back || '快退'),
|
|
136
|
+
React__default.createElement(Button, { type: "primary", size: "small", className: "start", onClick: handleStatusChange }, playing
|
|
137
|
+
? `${locale.audio.pause || '暂停'}`
|
|
138
|
+
: `${locale.audio.start || '开始'}`),
|
|
139
|
+
React__default.createElement(Button, { type: "primary", size: "small", onClick: handleForward }, locale.audio.forward || '快进'))));
|
|
140
|
+
};
|
|
141
|
+
const renderNone = () => {
|
|
142
|
+
return (React__default.createElement("div", { className: b('none-container'), onClick: handleStatusChange }, children));
|
|
143
|
+
};
|
|
144
|
+
const renderAudio = () => {
|
|
145
|
+
switch (type) {
|
|
146
|
+
case 'icon':
|
|
147
|
+
return renderIcon();
|
|
148
|
+
case 'progress':
|
|
149
|
+
return renderProgerss();
|
|
150
|
+
case 'none':
|
|
151
|
+
return renderNone();
|
|
152
|
+
default:
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
return (React__default.createElement("div", { className: `${b()} ${className}`, style: style, ...rest }, renderAudio()));
|
|
157
|
+
};
|
|
158
|
+
Audio.defaultProps = defaultProps;
|
|
159
|
+
Audio.displayName = 'NutAudio';
|
|
160
|
+
|
|
161
|
+
export { Audio as A };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import React__default, { useState, useRef, useContext, useEffect } from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { Image } from '@tarojs/components';
|
|
4
|
+
import { A as AvatarContext } from './AvatarContext-c96afdcc.js';
|
|
5
|
+
import { c as cn } from './bem-350c1702.js';
|
|
6
|
+
import { I as Icon } from './icon.taro-296a1bec.js';
|
|
7
|
+
import { C as ComponentDefaults } from './typings-b9828dba.js';
|
|
8
|
+
|
|
9
|
+
const defaultProps = {
|
|
10
|
+
...ComponentDefaults,
|
|
11
|
+
size: '',
|
|
12
|
+
icon: '',
|
|
13
|
+
iconSize: '',
|
|
14
|
+
bgColor: '#eee',
|
|
15
|
+
color: '#666',
|
|
16
|
+
prefixCls: 'nut-avatar',
|
|
17
|
+
url: '',
|
|
18
|
+
};
|
|
19
|
+
const Avatar = (props) => {
|
|
20
|
+
const { children, prefixCls, size, shape, bgColor, color, url, icon, iconSize, className, style, activeAvatar, onActiveAvatar, onError, iconClassPrefix, iconFontClassName, ...rest } = {
|
|
21
|
+
...defaultProps,
|
|
22
|
+
...props,
|
|
23
|
+
};
|
|
24
|
+
const [maxSum, setMaxSum] = useState(0); // avatarGroup里的avatar的个数
|
|
25
|
+
const [showMax, setShowMax] = useState(false); // 是否显示的最大头像个数
|
|
26
|
+
const [avatarIndex, setAvatarIndex] = useState(1); // avatar的索引
|
|
27
|
+
const avatarRef = useRef(null);
|
|
28
|
+
const parent = useContext(AvatarContext);
|
|
29
|
+
const b = cn('avatar');
|
|
30
|
+
const classes = classNames({
|
|
31
|
+
[`nut-avatar-${size || parent?.propAvatarGroup?.size || 'normal'}`]: true,
|
|
32
|
+
[`nut-avatar-${shape || parent?.propAvatarGroup?.shape || 'round'}`]: true,
|
|
33
|
+
});
|
|
34
|
+
const cls = classNames(b(''), classes, className);
|
|
35
|
+
const sizeValue = ['large', 'normal', 'small'];
|
|
36
|
+
const styles = {
|
|
37
|
+
width: sizeValue.indexOf(size) > -1 ? '' : `${size}px`,
|
|
38
|
+
height: sizeValue.indexOf(size) > -1 ? '' : `${size}px`,
|
|
39
|
+
backgroundColor: `${bgColor}`,
|
|
40
|
+
color: `${color}`,
|
|
41
|
+
marginLeft: avatarIndex !== 1 && parent?.propAvatarGroup?.span
|
|
42
|
+
? `${parent?.propAvatarGroup?.span}px`
|
|
43
|
+
: '',
|
|
44
|
+
zIndex: parent?.propAvatarGroup?.zIndex === 'right'
|
|
45
|
+
? `${Math.abs(maxSum - avatarIndex)}`
|
|
46
|
+
: '',
|
|
47
|
+
...style,
|
|
48
|
+
};
|
|
49
|
+
const maxStyles = {
|
|
50
|
+
backgroundColor: `${parent?.propAvatarGroup?.maxBgColor}`,
|
|
51
|
+
color: `${parent?.propAvatarGroup?.maxColor}`,
|
|
52
|
+
};
|
|
53
|
+
const iconStyles = icon || '';
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
const avatarChildren = parent?.avatarGroupRef?.current.children;
|
|
56
|
+
if (avatarChildren) {
|
|
57
|
+
avatarLength(avatarChildren);
|
|
58
|
+
}
|
|
59
|
+
}, []);
|
|
60
|
+
const avatarLength = (children) => {
|
|
61
|
+
for (let i = 0; i < children.length; i++) {
|
|
62
|
+
if (children[i] &&
|
|
63
|
+
children[i].classList &&
|
|
64
|
+
(children[i].classList[0] === 'nut-avatar' ||
|
|
65
|
+
children[i].classList.values().next().value === 'nut-avatar')) {
|
|
66
|
+
children[i].setAttribute('data-index', i + 1);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const index = avatarRef?.current?.dataset?.index;
|
|
70
|
+
const maxCount = parent?.propAvatarGroup?.maxCount;
|
|
71
|
+
setMaxSum(children.length);
|
|
72
|
+
setAvatarIndex(index);
|
|
73
|
+
if (index === children.length &&
|
|
74
|
+
index !== maxCount &&
|
|
75
|
+
children.length > maxCount) {
|
|
76
|
+
setShowMax(true);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const errorEvent = (e) => {
|
|
80
|
+
if (props.onError) {
|
|
81
|
+
props.onError(e);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const clickAvatar = (e) => {
|
|
85
|
+
activeAvatar && activeAvatar(e);
|
|
86
|
+
onActiveAvatar && onActiveAvatar(e);
|
|
87
|
+
};
|
|
88
|
+
return (React__default.createElement(React__default.Fragment, null, (showMax ||
|
|
89
|
+
!parent?.propAvatarGroup?.maxCount ||
|
|
90
|
+
avatarIndex <= parent?.propAvatarGroup?.maxCount) && (React__default.createElement("div", { className: cls, ...rest, style: !showMax ? styles : maxStyles, onClick: clickAvatar, ref: avatarRef },
|
|
91
|
+
(!parent?.propAvatarGroup?.maxCount ||
|
|
92
|
+
avatarIndex <= parent?.propAvatarGroup?.maxCount) && (React__default.createElement(React__default.Fragment, null,
|
|
93
|
+
url && (React__default.createElement(Image, { className: "avatar-img", src: url, onError: errorEvent })),
|
|
94
|
+
icon && (React__default.createElement(Icon, { classPrefix: iconClassPrefix, fontClassName: iconFontClassName, className: "icon", name: iconStyles, size: iconSize })),
|
|
95
|
+
children && React__default.createElement("span", { className: "text" }, children))),
|
|
96
|
+
showMax && (React__default.createElement("div", { className: "text" }, parent?.propAvatarGroup?.maxContent
|
|
97
|
+
? parent?.propAvatarGroup?.maxContent
|
|
98
|
+
: `+ ${avatarIndex - parent?.propAvatarGroup?.maxCount}`))))));
|
|
99
|
+
};
|
|
100
|
+
Avatar.defaultProps = defaultProps;
|
|
101
|
+
Avatar.displayName = 'NutAvatar';
|
|
102
|
+
|
|
103
|
+
export { Avatar as A };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React__default, { useRef } from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { A as AvatarContext } from './AvatarContext-c96afdcc.js';
|
|
4
|
+
import { c as cn } from './bem-350c1702.js';
|
|
5
|
+
import { u as useConfig } from './configprovider-67d19d3a.js';
|
|
6
|
+
|
|
7
|
+
const defaultProps = {
|
|
8
|
+
maxContent: '',
|
|
9
|
+
maxCount: '',
|
|
10
|
+
maxBgColor: '#eee',
|
|
11
|
+
maxColor: '#666',
|
|
12
|
+
size: '',
|
|
13
|
+
shape: '',
|
|
14
|
+
span: '-8',
|
|
15
|
+
zIndex: 'left',
|
|
16
|
+
};
|
|
17
|
+
const AvatarGroup = (props) => {
|
|
18
|
+
useConfig();
|
|
19
|
+
const propAvatarGroup = { ...defaultProps, ...props };
|
|
20
|
+
const { className, style, children } = propAvatarGroup;
|
|
21
|
+
const avatarGroupRef = useRef(null);
|
|
22
|
+
const b = cn('avatar-group');
|
|
23
|
+
const cls = classNames(b(''), className);
|
|
24
|
+
const parentAvatar = {
|
|
25
|
+
propAvatarGroup,
|
|
26
|
+
avatarGroupRef,
|
|
27
|
+
};
|
|
28
|
+
return (React__default.createElement(AvatarContext.Provider, { value: parentAvatar },
|
|
29
|
+
React__default.createElement("div", { className: cls, style: style, ref: avatarGroupRef }, children)));
|
|
30
|
+
};
|
|
31
|
+
AvatarGroup.defaultProps = defaultProps;
|
|
32
|
+
AvatarGroup.displayName = 'NutAvatarGroup';
|
|
33
|
+
|
|
34
|
+
export { AvatarGroup as A };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React__default, { useState } from 'react';
|
|
2
|
+
import { usePageScroll, pageScrollTo } from '@tarojs/taro';
|
|
3
|
+
import { I as Icon } from './icon.taro-296a1bec.js';
|
|
4
|
+
import { C as ComponentDefaults } from './typings-b9828dba.js';
|
|
5
|
+
|
|
6
|
+
const defaultProps = {
|
|
7
|
+
...ComponentDefaults,
|
|
8
|
+
bottom: 20,
|
|
9
|
+
right: 10,
|
|
10
|
+
elId: 'body',
|
|
11
|
+
distance: 200,
|
|
12
|
+
zIndex: 10,
|
|
13
|
+
isAnimation: true,
|
|
14
|
+
duration: 1000,
|
|
15
|
+
};
|
|
16
|
+
const BackTop = (props) => {
|
|
17
|
+
const { children, bottom, right, elId, distance, zIndex, isAnimation, className, duration, style, onClick, iconClassPrefix, iconFontClassName, } = {
|
|
18
|
+
...defaultProps,
|
|
19
|
+
...props,
|
|
20
|
+
};
|
|
21
|
+
const [backTop, SetBackTop] = useState(false);
|
|
22
|
+
// 监听用户滑动页面事件
|
|
23
|
+
usePageScroll((res) => {
|
|
24
|
+
const { scrollTop } = res;
|
|
25
|
+
scrollTop >= distance ? SetBackTop(true) : SetBackTop(false);
|
|
26
|
+
});
|
|
27
|
+
// 返回顶部点击事件
|
|
28
|
+
const goTop = (e) => {
|
|
29
|
+
onClick && onClick(e);
|
|
30
|
+
pageScrollTo({
|
|
31
|
+
scrollTop: 0,
|
|
32
|
+
duration: isAnimation && duration > 0 ? duration : 0,
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
const backTopClass = {
|
|
36
|
+
right: `${right}px`,
|
|
37
|
+
bottom: `${bottom}px`,
|
|
38
|
+
zIndex,
|
|
39
|
+
};
|
|
40
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
41
|
+
React__default.createElement("div", { className: `nut-backtop ${backTop ? 'show' : ''} ${className || ''}`, style: { ...backTopClass, ...style }, onClick: (e) => {
|
|
42
|
+
goTop(e);
|
|
43
|
+
} }, children || (React__default.createElement(Icon, { classPrefix: iconClassPrefix, fontClassName: iconFontClassName, size: "19px", className: "nut-backtop-main", name: "top" })))));
|
|
44
|
+
};
|
|
45
|
+
BackTop.defaultProps = defaultProps;
|
|
46
|
+
BackTop.displayName = 'NutBackTop';
|
|
47
|
+
|
|
48
|
+
export { BackTop as B };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { I as Icon } from './icon.taro-296a1bec.js';
|
|
4
|
+
import { c as cn } from './bem-350c1702.js';
|
|
5
|
+
import { C as ComponentDefaults } from './typings-b9828dba.js';
|
|
6
|
+
|
|
7
|
+
const b = cn('badge');
|
|
8
|
+
const defaultProps = {
|
|
9
|
+
...ComponentDefaults,
|
|
10
|
+
className: '',
|
|
11
|
+
value: '',
|
|
12
|
+
dot: false,
|
|
13
|
+
max: 10000,
|
|
14
|
+
top: '0',
|
|
15
|
+
right: '0',
|
|
16
|
+
zIndex: '0',
|
|
17
|
+
color: '',
|
|
18
|
+
icons: '',
|
|
19
|
+
};
|
|
20
|
+
const Badge = (props) => {
|
|
21
|
+
const { className, style, children, dot, top, right, zIndex, color, icons, iconClassPrefix, iconFontClassName, } = {
|
|
22
|
+
...defaultProps,
|
|
23
|
+
...props,
|
|
24
|
+
};
|
|
25
|
+
function content() {
|
|
26
|
+
if (dot)
|
|
27
|
+
return undefined;
|
|
28
|
+
const { value } = props;
|
|
29
|
+
const { max } = props;
|
|
30
|
+
if (typeof value === 'number' && typeof max === 'number') {
|
|
31
|
+
return max < value ? `${max}+` : value;
|
|
32
|
+
}
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
const getStyle = () => {
|
|
36
|
+
const style = {};
|
|
37
|
+
style.top = `${Number(top) || parseFloat(top) || 0}px`;
|
|
38
|
+
style.right = `${Number(right) || parseFloat(right) || 0}px`;
|
|
39
|
+
style.zIndex = zIndex;
|
|
40
|
+
style.background = color;
|
|
41
|
+
return style;
|
|
42
|
+
};
|
|
43
|
+
return (React__default.createElement("div", { className: classNames(b(), className), style: style },
|
|
44
|
+
icons !== '' && (React__default.createElement("div", { className: "slot-icons" },
|
|
45
|
+
React__default.createElement(Icon, { classPrefix: iconClassPrefix, fontClassName: iconFontClassName, className: "_icon", name: icons, color: "#ffffff", size: "12" }))),
|
|
46
|
+
React__default.createElement("div", null, children),
|
|
47
|
+
React__default.createElement("div", { className: classNames({ 'is-dot': dot }, b('content'), 'sup'), style: getStyle() }, content())));
|
|
48
|
+
};
|
|
49
|
+
Badge.defaultProps = defaultProps;
|
|
50
|
+
Badge.displayName = 'NutBadge';
|
|
51
|
+
|
|
52
|
+
export { Badge as B };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import React__default, { useState, useRef, useImperativeHandle, useEffect } from 'react';
|
|
2
|
+
import { createSelectorQuery } from '@tarojs/taro';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { c as cn } from './bem-350c1702.js';
|
|
5
|
+
|
|
6
|
+
const defaultProps = {
|
|
7
|
+
barrageList: [],
|
|
8
|
+
frequency: 500,
|
|
9
|
+
loop: true,
|
|
10
|
+
speeds: 3000,
|
|
11
|
+
rows: 3,
|
|
12
|
+
top: 10,
|
|
13
|
+
};
|
|
14
|
+
const InternalBarrage = (props, ref) => {
|
|
15
|
+
const { className, frequency, loop, barrageList, speeds, rows, top, ...restProps } = {
|
|
16
|
+
...defaultProps,
|
|
17
|
+
...props,
|
|
18
|
+
};
|
|
19
|
+
const [styleList, setStyleList] = useState([]);
|
|
20
|
+
const [baItemList, setBaItemList] = useState(barrageList);
|
|
21
|
+
const barrageListSet = useRef(barrageList);
|
|
22
|
+
const barrageBody = useRef(null);
|
|
23
|
+
const barrageContainer = useRef(null);
|
|
24
|
+
const timeId = useRef(new Date().getTime());
|
|
25
|
+
const timer = useRef(0);
|
|
26
|
+
useRef(0);
|
|
27
|
+
const b = cn('barrage');
|
|
28
|
+
const classes = classNames(className, b(''), {
|
|
29
|
+
[`nut-barrage__body${timeId.current}`]: true,
|
|
30
|
+
});
|
|
31
|
+
useImperativeHandle(ref, () => ({
|
|
32
|
+
add: (word) => {
|
|
33
|
+
barrageListSet.current = [...barrageListSet.current, word];
|
|
34
|
+
run();
|
|
35
|
+
},
|
|
36
|
+
}));
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
barrageListSet.current = [...barrageList];
|
|
39
|
+
run();
|
|
40
|
+
return () => {
|
|
41
|
+
clearInterval(timer.current);
|
|
42
|
+
};
|
|
43
|
+
}, [barrageList]);
|
|
44
|
+
const run = () => {
|
|
45
|
+
setBaItemList(barrageListSet.current);
|
|
46
|
+
barrageListSet.current.forEach((item, index) => {
|
|
47
|
+
getNode(index);
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
const getNode = (index) => {
|
|
51
|
+
const query = createSelectorQuery();
|
|
52
|
+
setTimeout(() => {
|
|
53
|
+
let width = 100;
|
|
54
|
+
query
|
|
55
|
+
.select('.nut-barrage__body' + timeId.current)
|
|
56
|
+
.boundingClientRect((rec) => {
|
|
57
|
+
width = (Array.isArray(rec) ? rec[0].width : rec.width) || 300;
|
|
58
|
+
});
|
|
59
|
+
query
|
|
60
|
+
.select('.nut-barrage__item' + index)
|
|
61
|
+
.boundingClientRect((recs) => {
|
|
62
|
+
let height = Array.isArray(recs) ? recs[0].width : recs.width;
|
|
63
|
+
let nodeTop = (index % rows) * (height + top) + 20 + 'px';
|
|
64
|
+
styleInfo(index, nodeTop, width);
|
|
65
|
+
})
|
|
66
|
+
.exec();
|
|
67
|
+
}, 500);
|
|
68
|
+
};
|
|
69
|
+
const styleInfo = (index, nodeTop, width) => {
|
|
70
|
+
let timeIndex = index - rows > 0 ? index - rows : 0;
|
|
71
|
+
let list = styleList;
|
|
72
|
+
let time = list[timeIndex] ? Number(list[timeIndex]['--time']) : 0;
|
|
73
|
+
// // distance.value = '-' + (speeds / 1000) * 200 + '%';
|
|
74
|
+
let obj = {
|
|
75
|
+
top: nodeTop,
|
|
76
|
+
'--time': `${frequency * index + time}`,
|
|
77
|
+
animationDuration: `${speeds}ms`,
|
|
78
|
+
animationIterationCount: `${loop ? 'infinite' : 1}`,
|
|
79
|
+
animationDelay: `${frequency * index + time}ms`,
|
|
80
|
+
'--move-distance': `-${width}px`,
|
|
81
|
+
};
|
|
82
|
+
list.push(obj);
|
|
83
|
+
setStyleList([...list]);
|
|
84
|
+
};
|
|
85
|
+
return (React__default.createElement("div", { className: classes, ref: barrageBody, ...restProps },
|
|
86
|
+
React__default.createElement("div", { ref: barrageContainer, className: "bContainer" }, baItemList.map((item, index) => {
|
|
87
|
+
return (React__default.createElement("div", { className: `barrage-item nut-barrage__item${index} move`, style: styleList[index] }, item.length > 8 ? item.substr(0, 8) + '...' : item));
|
|
88
|
+
}))));
|
|
89
|
+
};
|
|
90
|
+
const Barrage = React__default.forwardRef(InternalBarrage);
|
|
91
|
+
Barrage.defaultProps = defaultProps;
|
|
92
|
+
Barrage.displayName = 'NutBarrage';
|
|
93
|
+
|
|
94
|
+
export { Barrage as B };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import React__default, { useCallback, useState, useEffect } from 'react';
|
|
2
|
+
import { I as Icon } from './icon.taro-296a1bec.js';
|
|
3
|
+
import { C as ComponentDefaults } from './typings-b9828dba.js';
|
|
4
|
+
|
|
5
|
+
const defaultProps = {
|
|
6
|
+
...ComponentDefaults,
|
|
7
|
+
className: '',
|
|
8
|
+
color: '',
|
|
9
|
+
shape: 'round',
|
|
10
|
+
plain: false,
|
|
11
|
+
loading: false,
|
|
12
|
+
disabled: false,
|
|
13
|
+
type: 'default',
|
|
14
|
+
size: 'normal',
|
|
15
|
+
block: false,
|
|
16
|
+
icon: '',
|
|
17
|
+
iconSize: '16',
|
|
18
|
+
style: {},
|
|
19
|
+
children: undefined,
|
|
20
|
+
onClick: (e) => { },
|
|
21
|
+
};
|
|
22
|
+
const Button = (props) => {
|
|
23
|
+
const { color, shape, plain, loading, disabled, type, size, block, icon, iconSize, children, onClick, className, style, iconClassPrefix, iconFontClassName, ...rest } = {
|
|
24
|
+
...defaultProps,
|
|
25
|
+
...props,
|
|
26
|
+
};
|
|
27
|
+
const getStyle = useCallback(() => {
|
|
28
|
+
const style = {};
|
|
29
|
+
if (color) {
|
|
30
|
+
if (plain) {
|
|
31
|
+
style.color = color;
|
|
32
|
+
style.background = '#fff';
|
|
33
|
+
if (!color?.includes('gradient')) {
|
|
34
|
+
style.borderColor = color;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
style.color = '#fff';
|
|
39
|
+
style.background = color;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return style;
|
|
43
|
+
}, [color, plain]);
|
|
44
|
+
const classes = useCallback(() => {
|
|
45
|
+
const prefixCls = 'nut-button';
|
|
46
|
+
return [
|
|
47
|
+
prefixCls,
|
|
48
|
+
`${type ? `${prefixCls}--${type}` : ''}`,
|
|
49
|
+
`${size ? `${prefixCls}--${size}` : ''}`,
|
|
50
|
+
`${shape ? `${prefixCls}--${shape}` : ''}`,
|
|
51
|
+
`${plain ? `${prefixCls}--plain` : ''}`,
|
|
52
|
+
`${block ? `${prefixCls}--block` : ''}`,
|
|
53
|
+
`${disabled ? `${prefixCls}--disabled` : ''}`,
|
|
54
|
+
`${loading ? `${prefixCls}--loading` : ''}`,
|
|
55
|
+
]
|
|
56
|
+
.filter(Boolean)
|
|
57
|
+
.join(' ');
|
|
58
|
+
}, [block, disabled, loading, plain, shape, size, type]);
|
|
59
|
+
const [btnName, setBtnName] = useState(classes());
|
|
60
|
+
const [btnStyle, setBtnStyle] = useState(getStyle());
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
setBtnName(classes());
|
|
63
|
+
setBtnStyle(getStyle());
|
|
64
|
+
}, [
|
|
65
|
+
className,
|
|
66
|
+
color,
|
|
67
|
+
shape,
|
|
68
|
+
plain,
|
|
69
|
+
loading,
|
|
70
|
+
disabled,
|
|
71
|
+
style,
|
|
72
|
+
type,
|
|
73
|
+
size,
|
|
74
|
+
block,
|
|
75
|
+
icon,
|
|
76
|
+
iconSize,
|
|
77
|
+
children,
|
|
78
|
+
onClick,
|
|
79
|
+
classes,
|
|
80
|
+
getStyle,
|
|
81
|
+
]);
|
|
82
|
+
const handleClick = (e) => {
|
|
83
|
+
if (!loading && !disabled && onClick) {
|
|
84
|
+
onClick(e);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
return (
|
|
88
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
89
|
+
// @ts-ignore
|
|
90
|
+
// eslint-disable-next-line react/button-has-type
|
|
91
|
+
React__default.createElement("button", { className: `${btnName} ${className}`, style: { ...btnStyle, ...style }, ...rest, onClick: (e) => handleClick(e) },
|
|
92
|
+
React__default.createElement("div", { className: "nut-button__warp" },
|
|
93
|
+
loading && (React__default.createElement(Icon, { classPrefix: iconClassPrefix, fontClassName: iconFontClassName, name: "loading" })),
|
|
94
|
+
!loading && icon ? (React__default.createElement(Icon, { classPrefix: iconClassPrefix, fontClassName: iconFontClassName, name: icon, size: iconSize })) : (''),
|
|
95
|
+
children && (React__default.createElement("div", { className: icon || loading ? 'text' : '' }, children)))));
|
|
96
|
+
};
|
|
97
|
+
Button.defaultProps = defaultProps;
|
|
98
|
+
Button.displayName = 'NutButton';
|
|
99
|
+
|
|
100
|
+
export { Button as B };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React__default, { useRef } from 'react';
|
|
2
|
+
import { P as Popup } from './popup.taro-01676bff.js';
|
|
3
|
+
import { U as Utils, C as CalendarItem } from './calendaritem.taro-2a603571.js';
|
|
4
|
+
import { u as useConfig } from './configprovider.taro-8d71eb49.js';
|
|
5
|
+
|
|
6
|
+
const defaultProps = {
|
|
7
|
+
type: 'one',
|
|
8
|
+
isAutoBackFill: false,
|
|
9
|
+
poppable: true,
|
|
10
|
+
visible: false,
|
|
11
|
+
title: '',
|
|
12
|
+
defaultValue: '',
|
|
13
|
+
startDate: Utils.getDay(0),
|
|
14
|
+
endDate: Utils.getDay(365),
|
|
15
|
+
showToday: true,
|
|
16
|
+
startText: '',
|
|
17
|
+
endText: '',
|
|
18
|
+
confirmText: '',
|
|
19
|
+
showTitle: true,
|
|
20
|
+
showSubTitle: true,
|
|
21
|
+
toDateAnimation: true,
|
|
22
|
+
onBtn: undefined,
|
|
23
|
+
onDay: undefined,
|
|
24
|
+
onTopInfo: undefined,
|
|
25
|
+
onBottomInfo: undefined,
|
|
26
|
+
onClose: () => { },
|
|
27
|
+
onChoose: (param) => { },
|
|
28
|
+
onSelected: (data) => { },
|
|
29
|
+
onYearMonthChange: (param) => { },
|
|
30
|
+
};
|
|
31
|
+
const Calendar = React__default.forwardRef((props, ref) => {
|
|
32
|
+
const { locale } = useConfig();
|
|
33
|
+
const { children, poppable, visible, type, isAutoBackFill, title, defaultValue, startDate, endDate, showToday, startText, endText, confirmText, showTitle, showSubTitle, toDateAnimation, onBtn, onDay, onTopInfo, onBottomInfo, onClose, onChoose, onSelected, onYearMonthChange, } = { ...defaultProps, ...props };
|
|
34
|
+
const calendarRef = useRef(null);
|
|
35
|
+
const close = () => {
|
|
36
|
+
onClose && onClose();
|
|
37
|
+
};
|
|
38
|
+
const choose = (param) => {
|
|
39
|
+
close();
|
|
40
|
+
onChoose && onChoose(param);
|
|
41
|
+
};
|
|
42
|
+
const closePopup = () => {
|
|
43
|
+
close();
|
|
44
|
+
};
|
|
45
|
+
const select = (param) => {
|
|
46
|
+
onSelected && onSelected(param);
|
|
47
|
+
};
|
|
48
|
+
const scrollToDate = (date) => {
|
|
49
|
+
calendarRef.current?.scrollToDate(date);
|
|
50
|
+
};
|
|
51
|
+
const yearMonthChange = (param) => {
|
|
52
|
+
onYearMonthChange && onYearMonthChange(param);
|
|
53
|
+
};
|
|
54
|
+
React__default.useImperativeHandle(ref, () => ({
|
|
55
|
+
scrollToDate,
|
|
56
|
+
}));
|
|
57
|
+
const renderItem = () => {
|
|
58
|
+
return (React__default.createElement(CalendarItem, { ref: calendarRef, type: type, isAutoBackFill: isAutoBackFill, poppable: poppable, title: title || locale.calendaritem.title, defaultValue: defaultValue, startDate: startDate, endDate: endDate, showToday: showToday, startText: startText || locale.calendaritem.start, endText: endText || locale.calendaritem.end, confirmText: confirmText || locale.calendaritem.confirm, showTitle: showTitle, showSubTitle: showSubTitle, toDateAnimation: toDateAnimation, onBtn: onBtn, onDay: onDay, onTopInfo: onTopInfo, onBottomInfo: onBottomInfo, onChoose: choose, onSelected: select, onYearMonthChange: yearMonthChange }));
|
|
59
|
+
};
|
|
60
|
+
return (React__default.createElement(React__default.Fragment, null, poppable ? (React__default.createElement(Popup, { visible: visible, position: "bottom", round: true, duration: 0.5, closeable: true, destroyOnClose: true, onClickOverlay: closePopup, onClickCloseIcon: closePopup, style: { height: '85vh' } }, renderItem())) : (renderItem())));
|
|
61
|
+
});
|
|
62
|
+
Calendar.defaultProps = defaultProps;
|
|
63
|
+
Calendar.displayName = 'NutCalendar';
|
|
64
|
+
|
|
65
|
+
export { Calendar as C };
|