@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
package/dist/esm/Animate.js
CHANGED
|
@@ -1,9 +1,55 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
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 = ["className", "type", "action", "loop", "onClick", "children"];
|
|
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 } from 'react';
|
|
8
|
+
import classNames from 'classnames';
|
|
9
|
+
import { c as cn } from './bem-3b438e61.js';
|
|
5
10
|
import '@bem-react/classname';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
11
|
+
var defaultProps = {
|
|
12
|
+
type: 'shake',
|
|
13
|
+
action: 'initial',
|
|
14
|
+
loop: false,
|
|
15
|
+
onClick: function onClick(event) {}
|
|
16
|
+
};
|
|
17
|
+
var Animate = function Animate(props) {
|
|
18
|
+
var _classNames;
|
|
19
|
+
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
20
|
+
className = _defaultProps$props.className,
|
|
21
|
+
type = _defaultProps$props.type,
|
|
22
|
+
action = _defaultProps$props.action,
|
|
23
|
+
loop = _defaultProps$props.loop,
|
|
24
|
+
onClick = _defaultProps$props.onClick,
|
|
25
|
+
children = _defaultProps$props.children,
|
|
26
|
+
rest = _objectWithoutProperties(_defaultProps$props, _excluded);
|
|
27
|
+
var _useState = useState(false),
|
|
28
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
29
|
+
clicked = _useState2[0],
|
|
30
|
+
setClicked = _useState2[1];
|
|
31
|
+
var b = cn('animate');
|
|
32
|
+
var classes = classNames((_classNames = {
|
|
33
|
+
'nut-ani-container': true
|
|
34
|
+
}, _defineProperty(_classNames, "".concat(b(''), "-").concat(type), action === 'initial' || clicked ? type : false), _defineProperty(_classNames, "loop", loop), _classNames));
|
|
35
|
+
var cls = classNames(classes, className);
|
|
36
|
+
var handleClick = function handleClick(event) {
|
|
37
|
+
setClicked(true);
|
|
38
|
+
// 如果不是无限循环,清除类名
|
|
39
|
+
if (!loop) {
|
|
40
|
+
setTimeout(function () {
|
|
41
|
+
setClicked(false);
|
|
42
|
+
}, 1000);
|
|
43
|
+
}
|
|
44
|
+
onClick && onClick(event);
|
|
45
|
+
};
|
|
46
|
+
return React__default.createElement("div", {
|
|
47
|
+
className: "nut-animate"
|
|
48
|
+
}, React__default.createElement("div", _objectSpread({
|
|
49
|
+
className: cls,
|
|
50
|
+
onClick: handleClick
|
|
51
|
+
}, rest), children));
|
|
52
|
+
};
|
|
53
|
+
Animate.defaultProps = defaultProps;
|
|
54
|
+
Animate.displayName = 'NutAnimate';
|
|
9
55
|
export { Animate as default };
|
|
@@ -1,9 +1,127 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
8
|
+
var _excluded = ["maxLen", "endNumber", "delaySpeed", "easeSpeed", "className", "thousands"];
|
|
9
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
10
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
11
|
+
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; }
|
|
12
|
+
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; }
|
|
13
|
+
import React__default, { useRef, useMemo, useEffect, Component } from 'react';
|
|
14
|
+
import { c as cn } from './bem-3b438e61.js';
|
|
5
15
|
import '@bem-react/classname';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
16
|
+
var defaultProps$1 = {
|
|
17
|
+
maxLen: 0,
|
|
18
|
+
endNumber: '',
|
|
19
|
+
delaySpeed: 300,
|
|
20
|
+
easeSpeed: 1,
|
|
21
|
+
thousands: false,
|
|
22
|
+
className: ''
|
|
23
|
+
};
|
|
24
|
+
var CountUp = function CountUp(props) {
|
|
25
|
+
var _defaultProps$1$props = _objectSpread(_objectSpread({}, defaultProps$1), props),
|
|
26
|
+
maxLen = _defaultProps$1$props.maxLen,
|
|
27
|
+
endNumber = _defaultProps$1$props.endNumber,
|
|
28
|
+
delaySpeed = _defaultProps$1$props.delaySpeed,
|
|
29
|
+
easeSpeed = _defaultProps$1$props.easeSpeed,
|
|
30
|
+
className = _defaultProps$1$props.className,
|
|
31
|
+
thousands = _defaultProps$1$props.thousands,
|
|
32
|
+
reset = _objectWithoutProperties(_defaultProps$1$props, _excluded);
|
|
33
|
+
var b = cn('countup');
|
|
34
|
+
var countupRef = useRef(null);
|
|
35
|
+
var timerRef = useRef(0);
|
|
36
|
+
var numbers = Array.from({
|
|
37
|
+
length: 10
|
|
38
|
+
}, function (v, i) {
|
|
39
|
+
return i;
|
|
40
|
+
});
|
|
41
|
+
var getShowNumber = function getShowNumber() {
|
|
42
|
+
var splitArr = endNumber.split('.');
|
|
43
|
+
var intNumber = maxLen && splitArr[0].length < maxLen ? (Array(maxLen).join('0') + splitArr[0]).slice(-maxLen) : splitArr[0];
|
|
44
|
+
var currNumber = "".concat(thousands ? intNumber.replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') : intNumber).concat(splitArr[1] ? '.' : '').concat(splitArr[1] || '');
|
|
45
|
+
return currNumber.split('');
|
|
46
|
+
};
|
|
47
|
+
var numerArr = useMemo(getShowNumber, [endNumber, maxLen, thousands]);
|
|
48
|
+
var setNumberTransform = function setNumberTransform() {
|
|
49
|
+
if (countupRef.current) {
|
|
50
|
+
var numberItems = countupRef.current.querySelectorAll('.nut-countup__number');
|
|
51
|
+
var numberFilterArr = numerArr.filter(function (item) {
|
|
52
|
+
return !Number.isNaN(Number(item));
|
|
53
|
+
});
|
|
54
|
+
Object.keys(numberItems).forEach(function (key) {
|
|
55
|
+
var elem = numberItems[Number(key)];
|
|
56
|
+
var idx = Number(numberFilterArr[Number(key)]);
|
|
57
|
+
if ((idx || idx === 0) && elem) {
|
|
58
|
+
// 计算规则:父元素和实际列表高度的百分比,分割成20等份
|
|
59
|
+
var transform = "translate(0, -".concat((idx === 0 ? 10 : idx) * 5, "%)");
|
|
60
|
+
elem.style.transform = transform;
|
|
61
|
+
elem.style.webkitTransform = transform;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
var numberEaseStyle = {
|
|
67
|
+
transition: "transform ".concat(easeSpeed, "s ease-in-out")
|
|
68
|
+
};
|
|
69
|
+
useEffect(function () {
|
|
70
|
+
timerRef.current = window.setTimeout(function () {
|
|
71
|
+
setNumberTransform();
|
|
72
|
+
}, delaySpeed);
|
|
73
|
+
return function () {
|
|
74
|
+
window.clearTimeout(timerRef.current);
|
|
75
|
+
};
|
|
76
|
+
}, [numerArr]);
|
|
77
|
+
return React__default.createElement("div", {
|
|
78
|
+
className: "".concat(b(), " ").concat(className),
|
|
79
|
+
ref: countupRef
|
|
80
|
+
}, React__default.createElement("ul", {
|
|
81
|
+
className: b('list')
|
|
82
|
+
}, numerArr.map(function (item, idx) {
|
|
83
|
+
return React__default.createElement("li", {
|
|
84
|
+
className: "".concat(b('listitem', {
|
|
85
|
+
number: !Number.isNaN(Number(item))
|
|
86
|
+
})),
|
|
87
|
+
key: idx
|
|
88
|
+
}, !Number.isNaN(Number(item)) ? React__default.createElement("span", {
|
|
89
|
+
className: b('number'),
|
|
90
|
+
style: numberEaseStyle
|
|
91
|
+
}, [].concat(numbers, numbers).map(function (number, subidx) {
|
|
92
|
+
return React__default.createElement("span", {
|
|
93
|
+
key: subidx
|
|
94
|
+
}, number);
|
|
95
|
+
})) : React__default.createElement("span", {
|
|
96
|
+
className: b('separator')
|
|
97
|
+
}, item));
|
|
98
|
+
})));
|
|
99
|
+
};
|
|
100
|
+
CountUp.defaultProps = defaultProps$1;
|
|
101
|
+
CountUp.displayName = 'NutCountUp';
|
|
102
|
+
var defaultProps = {};
|
|
103
|
+
var AnimatingNumbers = /*#__PURE__*/function (_Component) {
|
|
104
|
+
_inherits(AnimatingNumbers, _Component);
|
|
105
|
+
var _super = _createSuper(AnimatingNumbers);
|
|
106
|
+
function AnimatingNumbers(props) {
|
|
107
|
+
var _this;
|
|
108
|
+
_classCallCheck(this, AnimatingNumbers);
|
|
109
|
+
_this = _super.call(this, props);
|
|
110
|
+
_this.state = {};
|
|
111
|
+
return _this;
|
|
112
|
+
}
|
|
113
|
+
_createClass(AnimatingNumbers, [{
|
|
114
|
+
key: "render",
|
|
115
|
+
value: function render() {
|
|
116
|
+
return React__default.createElement("div", {
|
|
117
|
+
className: "nut-animatingnumbers"
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}]);
|
|
121
|
+
return AnimatingNumbers;
|
|
122
|
+
}(Component);
|
|
123
|
+
_defineProperty(AnimatingNumbers, "defaultProps", defaultProps);
|
|
124
|
+
_defineProperty(AnimatingNumbers, "displayName", 'NutAnimatingNumbers');
|
|
125
|
+
_defineProperty(AnimatingNumbers, "CountUp", CountUp);
|
|
126
|
+
AnimatingNumbers.CountUp = CountUp;
|
|
9
127
|
export { AnimatingNumbers as default };
|
package/dist/esm/Audio.js
CHANGED
|
@@ -1,21 +1,266 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
+
var _excluded = ["className", "url", "style", "muted", "autoplay", "loop", "preload", "type", "onFastBack", "onForward", "onPause", "onPlayEnd", "onMute", "onCanPlay", "children", "iconClassPrefix", "iconFontClassName"];
|
|
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 Icon from './Icon.js';
|
|
9
|
+
import Range from './Range.js';
|
|
10
|
+
import { c as cn } from './bem-3b438e61.js';
|
|
11
|
+
import Button from './Button.js';
|
|
12
|
+
import { useConfig } from './ConfigProvider.js';
|
|
13
|
+
import { C as ComponentDefaults } from './typings-f27b58f4.js';
|
|
6
14
|
import '@bem-react/classname';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
16
|
+
className: '',
|
|
17
|
+
url: '',
|
|
18
|
+
style: {},
|
|
19
|
+
muted: false,
|
|
20
|
+
autoplay: false,
|
|
21
|
+
loop: false,
|
|
22
|
+
preload: 'auto',
|
|
23
|
+
type: 'progress',
|
|
24
|
+
onFastBack: function onFastBack(e) {},
|
|
25
|
+
onForward: function onForward(e) {},
|
|
26
|
+
onPause: function onPause(e) {},
|
|
27
|
+
onPlayEnd: function onPlayEnd(e) {},
|
|
28
|
+
onMute: function onMute(e) {},
|
|
29
|
+
onCanPlay: function onCanPlay(e) {}
|
|
30
|
+
});
|
|
31
|
+
var Audio = function Audio(props) {
|
|
32
|
+
var _useConfig = useConfig(),
|
|
33
|
+
locale = _useConfig.locale;
|
|
34
|
+
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
35
|
+
className = _defaultProps$props.className,
|
|
36
|
+
url = _defaultProps$props.url,
|
|
37
|
+
style = _defaultProps$props.style,
|
|
38
|
+
muted = _defaultProps$props.muted,
|
|
39
|
+
autoplay = _defaultProps$props.autoplay,
|
|
40
|
+
loop = _defaultProps$props.loop,
|
|
41
|
+
preload = _defaultProps$props.preload,
|
|
42
|
+
type = _defaultProps$props.type,
|
|
43
|
+
onFastBack = _defaultProps$props.onFastBack,
|
|
44
|
+
onForward = _defaultProps$props.onForward,
|
|
45
|
+
onPause = _defaultProps$props.onPause,
|
|
46
|
+
onPlayEnd = _defaultProps$props.onPlayEnd,
|
|
47
|
+
onMute = _defaultProps$props.onMute,
|
|
48
|
+
onCanPlay = _defaultProps$props.onCanPlay,
|
|
49
|
+
children = _defaultProps$props.children,
|
|
50
|
+
iconClassPrefix = _defaultProps$props.iconClassPrefix,
|
|
51
|
+
iconFontClassName = _defaultProps$props.iconFontClassName,
|
|
52
|
+
rest = _objectWithoutProperties(_defaultProps$props, _excluded);
|
|
53
|
+
var _useState = useState(false),
|
|
54
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
55
|
+
playing = _useState2[0],
|
|
56
|
+
setPlaying = _useState2[1];
|
|
57
|
+
var _useState3 = useState(0),
|
|
58
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
59
|
+
percent = _useState4[0],
|
|
60
|
+
setPercent = _useState4[1];
|
|
61
|
+
var _useState5 = useState(false),
|
|
62
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
63
|
+
isCanPlay = _useState6[0],
|
|
64
|
+
setIsCanPlay = _useState6[1];
|
|
65
|
+
var _useState7 = useState('00:00:00'),
|
|
66
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
67
|
+
currentDuration = _useState8[0],
|
|
68
|
+
setCurrentDuration = _useState8[1];
|
|
69
|
+
var AudioRef = useRef(null);
|
|
70
|
+
var statusRef = useRef({
|
|
71
|
+
currentTime: 0,
|
|
72
|
+
currentDuration: '00:00:00',
|
|
73
|
+
percent: 0,
|
|
74
|
+
duration: '00:00:00',
|
|
75
|
+
second: 0,
|
|
76
|
+
hanMuted: props.muted,
|
|
77
|
+
playing: props.autoplay,
|
|
78
|
+
handPlaying: false
|
|
79
|
+
});
|
|
80
|
+
var b = cn('audio');
|
|
81
|
+
var warn = console.warn;
|
|
82
|
+
var handleEnded = function handleEnded(e) {
|
|
83
|
+
if (props.loop) {
|
|
84
|
+
warn(locale.audio.tips || 'onPlayEnd事件在loop=false时才会触发');
|
|
85
|
+
} else {
|
|
86
|
+
props.onPlayEnd && props.onPlayEnd(e);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
function watch() {
|
|
90
|
+
if (AudioRef && AudioRef.current) {
|
|
91
|
+
var current = AudioRef.current;
|
|
92
|
+
current.addEventListener('play', function () {
|
|
93
|
+
setPlaying(true);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
useEffect(function () {
|
|
98
|
+
watch();
|
|
99
|
+
}, []);
|
|
100
|
+
useEffect(function () {}, [currentDuration]);
|
|
101
|
+
var handleStatusChange = function handleStatusChange() {
|
|
102
|
+
setPlaying(!playing);
|
|
103
|
+
if (playing) {
|
|
104
|
+
AudioRef && AudioRef.current && AudioRef.current.pause();
|
|
105
|
+
} else {
|
|
106
|
+
AudioRef && AudioRef.current && AudioRef.current.play();
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
var renderIcon = function renderIcon() {
|
|
110
|
+
return React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
|
|
111
|
+
className: b('icon')
|
|
112
|
+
}, React__default.createElement("div", {
|
|
113
|
+
className: "".concat(b('icon-box'), " ").concat(playing ? b('icon-play') : b('icon-stop')),
|
|
114
|
+
onClick: handleStatusChange
|
|
115
|
+
}, playing ? React__default.createElement(Icon, {
|
|
116
|
+
classPrefix: iconClassPrefix,
|
|
117
|
+
fontClassName: iconFontClassName,
|
|
118
|
+
name: "service",
|
|
119
|
+
className: "nut-icon-loading"
|
|
120
|
+
}) : React__default.createElement(Icon, {
|
|
121
|
+
classPrefix: iconClassPrefix,
|
|
122
|
+
fontClassName: iconFontClassName,
|
|
123
|
+
name: "service"
|
|
124
|
+
}))));
|
|
125
|
+
};
|
|
126
|
+
var handleBack = function handleBack() {
|
|
127
|
+
if (statusRef.current.currentTime > 0 && AudioRef.current) {
|
|
128
|
+
statusRef.current.currentTime--;
|
|
129
|
+
AudioRef.current.currentTime = statusRef.current.currentTime;
|
|
130
|
+
props.onFastBack && props.onFastBack(AudioRef.current);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
var handleForward = function handleForward() {
|
|
134
|
+
if (AudioRef.current) {
|
|
135
|
+
statusRef.current.currentTime++;
|
|
136
|
+
AudioRef.current.currentTime = statusRef.current.currentTime;
|
|
137
|
+
props.onForward && props.onForward(AudioRef.current);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
var handleMute = function handleMute() {
|
|
141
|
+
if (AudioRef.current) {
|
|
142
|
+
AudioRef.current.muted = !AudioRef.current.muted;
|
|
143
|
+
props.onMute && props.onMute(AudioRef.current);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
var handlePause = function handlePause(e) {
|
|
147
|
+
setPlaying(false);
|
|
148
|
+
props.onPause && props.onPause(e);
|
|
149
|
+
};
|
|
150
|
+
var formatSeconds = function formatSeconds(value) {
|
|
151
|
+
if (!value) {
|
|
152
|
+
return '00:00:00';
|
|
153
|
+
}
|
|
154
|
+
var time = parseInt(value);
|
|
155
|
+
var hours = Math.floor(time / 3600);
|
|
156
|
+
var minutes = Math.floor((time - hours * 3600) / 60);
|
|
157
|
+
var seconds = time - hours * 3600 - minutes * 60;
|
|
158
|
+
var result = '';
|
|
159
|
+
result += "".concat("0".concat(hours.toString()).slice(-2), ":");
|
|
160
|
+
result += "".concat("0".concat(minutes.toString()).slice(-2), ":");
|
|
161
|
+
result += "0".concat(seconds.toString()).slice(-2);
|
|
162
|
+
return result;
|
|
163
|
+
};
|
|
164
|
+
var renderProgerss = function renderProgerss() {
|
|
165
|
+
return React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
|
|
166
|
+
className: b('progress')
|
|
167
|
+
}, React__default.createElement("div", {
|
|
168
|
+
className: "time"
|
|
169
|
+
}, currentDuration), React__default.createElement("div", {
|
|
170
|
+
className: b('progress-bar-wrapper')
|
|
171
|
+
}, React__default.createElement(Range, {
|
|
172
|
+
modelValue: percent,
|
|
173
|
+
hiddenTag: true,
|
|
174
|
+
hiddenRange: true,
|
|
175
|
+
"inactive-color": "#cccccc",
|
|
176
|
+
"active-color": "#fa2c19"
|
|
177
|
+
})), React__default.createElement("div", {
|
|
178
|
+
className: "time"
|
|
179
|
+
}, AudioRef.current ? formatSeconds("".concat(statusRef.current.second)) : '00:00:00')), React__default.createElement("div", {
|
|
180
|
+
className: isCanPlay ? 'custom-button-group' : 'custom-button-group-disable'
|
|
181
|
+
}, React__default.createElement(Button, {
|
|
182
|
+
type: "primary",
|
|
183
|
+
size: "small",
|
|
184
|
+
className: "back",
|
|
185
|
+
onClick: handleBack
|
|
186
|
+
}, locale.audio.back || '快退'), React__default.createElement(Button, {
|
|
187
|
+
type: "primary",
|
|
188
|
+
size: "small",
|
|
189
|
+
className: "start",
|
|
190
|
+
onClick: handleStatusChange
|
|
191
|
+
}, playing ? "".concat(locale.audio.pause || '暂停') : "".concat(locale.audio.start || '开始')), React__default.createElement(Button, {
|
|
192
|
+
type: "primary",
|
|
193
|
+
size: "small",
|
|
194
|
+
onClick: handleForward
|
|
195
|
+
}, locale.audio.forward || '快进'), React__default.createElement(Button, {
|
|
196
|
+
type: AudioRef.current && AudioRef.current.muted ? 'default' : 'primary',
|
|
197
|
+
size: "small",
|
|
198
|
+
onClick: handleMute
|
|
199
|
+
}, locale.audio.mute || '静音')));
|
|
200
|
+
};
|
|
201
|
+
var renderNone = function renderNone() {
|
|
202
|
+
return React__default.createElement("div", {
|
|
203
|
+
className: b('none-container'),
|
|
204
|
+
onClick: handleStatusChange
|
|
205
|
+
}, children);
|
|
206
|
+
};
|
|
207
|
+
var renderAudio = function renderAudio() {
|
|
208
|
+
switch (type) {
|
|
209
|
+
case 'icon':
|
|
210
|
+
return renderIcon();
|
|
211
|
+
case 'progress':
|
|
212
|
+
return renderProgerss();
|
|
213
|
+
case 'none':
|
|
214
|
+
return renderNone();
|
|
215
|
+
default:
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
var handleCanplay = function handleCanplay(e) {
|
|
220
|
+
setIsCanPlay(true);
|
|
221
|
+
if (props.autoplay && !playing) {
|
|
222
|
+
AudioRef && AudioRef.current && AudioRef.current.play();
|
|
223
|
+
}
|
|
224
|
+
if (AudioRef.current) {
|
|
225
|
+
statusRef.current.second = AudioRef.current.duration || 0;
|
|
226
|
+
props.onCanPlay && props.onCanPlay(e);
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
var onTimeupdate = function onTimeupdate(e) {
|
|
230
|
+
var time = parseInt(e.target.currentTime);
|
|
231
|
+
var formated = formatSeconds("".concat(time));
|
|
232
|
+
statusRef.current.currentDuration = formated;
|
|
233
|
+
setPercent(time / statusRef.current.second * 100);
|
|
234
|
+
setCurrentDuration(formated);
|
|
235
|
+
statusRef.current.currentTime = time;
|
|
236
|
+
};
|
|
237
|
+
return React__default.createElement("div", _objectSpread({
|
|
238
|
+
className: "".concat(b(), " ").concat(className),
|
|
239
|
+
style: style
|
|
240
|
+
}, rest), renderAudio(), React__default.createElement("audio", {
|
|
241
|
+
className: "audioMain",
|
|
242
|
+
controls: type === 'controls',
|
|
243
|
+
ref: AudioRef,
|
|
244
|
+
src: url,
|
|
245
|
+
muted: muted,
|
|
246
|
+
preload: preload,
|
|
247
|
+
loop: loop,
|
|
248
|
+
onPause: function onPause(e) {
|
|
249
|
+
return handlePause(e);
|
|
250
|
+
},
|
|
251
|
+
onEnded: function onEnded(e) {
|
|
252
|
+
return handleEnded(e);
|
|
253
|
+
},
|
|
254
|
+
onCanPlay: function onCanPlay(e) {
|
|
255
|
+
return handleCanplay(e);
|
|
256
|
+
},
|
|
257
|
+
onTimeUpdate: function onTimeUpdate(e) {
|
|
258
|
+
return onTimeupdate(e);
|
|
259
|
+
}
|
|
260
|
+
}, React__default.createElement("track", {
|
|
261
|
+
kind: "captions"
|
|
262
|
+
})));
|
|
263
|
+
};
|
|
264
|
+
Audio.defaultProps = defaultProps;
|
|
265
|
+
Audio.displayName = 'NutAudio';
|
|
21
266
|
export { Audio as default };
|
package/dist/esm/Avatar.js
CHANGED
|
@@ -1,13 +1,132 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
+
var _excluded = ["children", "prefixCls", "size", "shape", "bgColor", "color", "url", "alt", "icon", "iconSize", "className", "style", "activeAvatar", "onActiveAvatar", "onError", "iconClassPrefix", "iconFontClassName"];
|
|
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, useContext, useEffect } from 'react';
|
|
8
|
+
import classNames from 'classnames';
|
|
9
|
+
import { A as AvatarContext } from './AvatarContext-15733596.js';
|
|
10
|
+
import { c as cn } from './bem-3b438e61.js';
|
|
11
|
+
import Icon from './Icon.js';
|
|
12
|
+
import { C as ComponentDefaults } from './typings-f27b58f4.js';
|
|
7
13
|
import '@bem-react/classname';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
15
|
+
size: '',
|
|
16
|
+
icon: '',
|
|
17
|
+
iconSize: '',
|
|
18
|
+
bgColor: '#eee',
|
|
19
|
+
color: '#666',
|
|
20
|
+
prefixCls: 'nut-avatar',
|
|
21
|
+
url: '',
|
|
22
|
+
alt: ''
|
|
23
|
+
});
|
|
24
|
+
var Avatar = function Avatar(props) {
|
|
25
|
+
var _parent$propAvatarGro, _parent$propAvatarGro2, _classNames, _parent$propAvatarGro3, _parent$propAvatarGro4, _parent$propAvatarGro5, _parent$propAvatarGro6, _parent$propAvatarGro7, _parent$propAvatarGro9, _parent$propAvatarGro10, _parent$propAvatarGro11, _parent$propAvatarGro12, _parent$propAvatarGro13, _parent$propAvatarGro14, _parent$propAvatarGro15;
|
|
26
|
+
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
27
|
+
children = _defaultProps$props.children,
|
|
28
|
+
prefixCls = _defaultProps$props.prefixCls,
|
|
29
|
+
size = _defaultProps$props.size,
|
|
30
|
+
shape = _defaultProps$props.shape,
|
|
31
|
+
bgColor = _defaultProps$props.bgColor,
|
|
32
|
+
color = _defaultProps$props.color,
|
|
33
|
+
url = _defaultProps$props.url,
|
|
34
|
+
alt = _defaultProps$props.alt,
|
|
35
|
+
icon = _defaultProps$props.icon,
|
|
36
|
+
iconSize = _defaultProps$props.iconSize,
|
|
37
|
+
className = _defaultProps$props.className,
|
|
38
|
+
style = _defaultProps$props.style,
|
|
39
|
+
activeAvatar = _defaultProps$props.activeAvatar,
|
|
40
|
+
onActiveAvatar = _defaultProps$props.onActiveAvatar,
|
|
41
|
+
onError = _defaultProps$props.onError,
|
|
42
|
+
iconClassPrefix = _defaultProps$props.iconClassPrefix,
|
|
43
|
+
iconFontClassName = _defaultProps$props.iconFontClassName,
|
|
44
|
+
rest = _objectWithoutProperties(_defaultProps$props, _excluded);
|
|
45
|
+
var _useState = useState(0),
|
|
46
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
47
|
+
maxSum = _useState2[0],
|
|
48
|
+
setMaxSum = _useState2[1]; // avatarGroup里的avatar的个数
|
|
49
|
+
var _useState3 = useState(false),
|
|
50
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
51
|
+
showMax = _useState4[0],
|
|
52
|
+
setShowMax = _useState4[1]; // 是否显示的最大头像个数
|
|
53
|
+
var _useState5 = useState(1),
|
|
54
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
55
|
+
avatarIndex = _useState6[0],
|
|
56
|
+
setAvatarIndex = _useState6[1]; // avatar的索引
|
|
57
|
+
var avatarRef = useRef(null);
|
|
58
|
+
var parent = useContext(AvatarContext);
|
|
59
|
+
var b = cn('avatar');
|
|
60
|
+
var classes = classNames((_classNames = {}, _defineProperty(_classNames, "nut-avatar-".concat(size || (parent === null || parent === void 0 ? void 0 : (_parent$propAvatarGro = parent.propAvatarGroup) === null || _parent$propAvatarGro === void 0 ? void 0 : _parent$propAvatarGro.size) || 'normal'), true), _defineProperty(_classNames, "nut-avatar-".concat(shape || (parent === null || parent === void 0 ? void 0 : (_parent$propAvatarGro2 = parent.propAvatarGroup) === null || _parent$propAvatarGro2 === void 0 ? void 0 : _parent$propAvatarGro2.shape) || 'round'), true), _classNames));
|
|
61
|
+
var cls = classNames(b(''), classes, className);
|
|
62
|
+
var sizeValue = ['large', 'normal', 'small'];
|
|
63
|
+
var styles = _objectSpread({
|
|
64
|
+
width: sizeValue.indexOf(size) > -1 ? '' : "".concat(size, "px"),
|
|
65
|
+
height: sizeValue.indexOf(size) > -1 ? '' : "".concat(size, "px"),
|
|
66
|
+
backgroundColor: "".concat(bgColor),
|
|
67
|
+
color: "".concat(color),
|
|
68
|
+
marginLeft: avatarIndex !== 1 && parent !== null && parent !== void 0 && (_parent$propAvatarGro3 = parent.propAvatarGroup) !== null && _parent$propAvatarGro3 !== void 0 && _parent$propAvatarGro3.span ? "".concat(parent === null || parent === void 0 ? void 0 : (_parent$propAvatarGro4 = parent.propAvatarGroup) === null || _parent$propAvatarGro4 === void 0 ? void 0 : _parent$propAvatarGro4.span, "px") : '',
|
|
69
|
+
zIndex: (parent === null || parent === void 0 ? void 0 : (_parent$propAvatarGro5 = parent.propAvatarGroup) === null || _parent$propAvatarGro5 === void 0 ? void 0 : _parent$propAvatarGro5.zIndex) === 'right' ? "".concat(Math.abs(maxSum - avatarIndex)) : ''
|
|
70
|
+
}, style);
|
|
71
|
+
var maxStyles = {
|
|
72
|
+
backgroundColor: "".concat(parent === null || parent === void 0 ? void 0 : (_parent$propAvatarGro6 = parent.propAvatarGroup) === null || _parent$propAvatarGro6 === void 0 ? void 0 : _parent$propAvatarGro6.maxBgColor),
|
|
73
|
+
color: "".concat(parent === null || parent === void 0 ? void 0 : (_parent$propAvatarGro7 = parent.propAvatarGroup) === null || _parent$propAvatarGro7 === void 0 ? void 0 : _parent$propAvatarGro7.maxColor)
|
|
74
|
+
};
|
|
75
|
+
var iconStyles = icon || '';
|
|
76
|
+
useEffect(function () {
|
|
77
|
+
var _parent$avatarGroupRe;
|
|
78
|
+
var avatarChildren = parent === null || parent === void 0 ? void 0 : (_parent$avatarGroupRe = parent.avatarGroupRef) === null || _parent$avatarGroupRe === void 0 ? void 0 : _parent$avatarGroupRe.current.children;
|
|
79
|
+
if (avatarChildren) {
|
|
80
|
+
avatarLength(avatarChildren);
|
|
81
|
+
}
|
|
82
|
+
}, []);
|
|
83
|
+
var avatarLength = function avatarLength(children) {
|
|
84
|
+
var _avatarRef$current, _avatarRef$current$da, _parent$propAvatarGro8;
|
|
85
|
+
for (var i = 0; i < children.length; i++) {
|
|
86
|
+
if (children[i] && children[i].classList && children[i].classList[0] === 'nut-avatar') {
|
|
87
|
+
children[i].setAttribute('data-index', i + 1);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
var index = Number(avatarRef === null || avatarRef === void 0 ? void 0 : (_avatarRef$current = avatarRef.current) === null || _avatarRef$current === void 0 ? void 0 : (_avatarRef$current$da = _avatarRef$current.dataset) === null || _avatarRef$current$da === void 0 ? void 0 : _avatarRef$current$da.index);
|
|
91
|
+
var maxCount = parent === null || parent === void 0 ? void 0 : (_parent$propAvatarGro8 = parent.propAvatarGroup) === null || _parent$propAvatarGro8 === void 0 ? void 0 : _parent$propAvatarGro8.maxCount;
|
|
92
|
+
setMaxSum(children.length);
|
|
93
|
+
setAvatarIndex(index);
|
|
94
|
+
if (index === children.length && index !== maxCount && children.length > maxCount) {
|
|
95
|
+
setShowMax(true);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
var errorEvent = function errorEvent(e) {
|
|
99
|
+
if (props.onError) {
|
|
100
|
+
props.onError(e);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
var clickAvatar = function clickAvatar(e) {
|
|
104
|
+
activeAvatar && activeAvatar(e);
|
|
105
|
+
onActiveAvatar && onActiveAvatar(e);
|
|
106
|
+
};
|
|
107
|
+
return React__default.createElement(React__default.Fragment, null, (showMax || !(parent !== null && parent !== void 0 && (_parent$propAvatarGro9 = parent.propAvatarGroup) !== null && _parent$propAvatarGro9 !== void 0 && _parent$propAvatarGro9.maxCount) || avatarIndex <= (parent === null || parent === void 0 ? void 0 : (_parent$propAvatarGro10 = parent.propAvatarGroup) === null || _parent$propAvatarGro10 === void 0 ? void 0 : _parent$propAvatarGro10.maxCount)) && React__default.createElement("div", _objectSpread(_objectSpread({
|
|
108
|
+
className: cls
|
|
109
|
+
}, rest), {}, {
|
|
110
|
+
style: !showMax ? styles : maxStyles,
|
|
111
|
+
onClick: clickAvatar,
|
|
112
|
+
ref: avatarRef
|
|
113
|
+
}), (!(parent !== null && parent !== void 0 && (_parent$propAvatarGro11 = parent.propAvatarGroup) !== null && _parent$propAvatarGro11 !== void 0 && _parent$propAvatarGro11.maxCount) || avatarIndex <= (parent === null || parent === void 0 ? void 0 : (_parent$propAvatarGro12 = parent.propAvatarGroup) === null || _parent$propAvatarGro12 === void 0 ? void 0 : _parent$propAvatarGro12.maxCount)) && React__default.createElement(React__default.Fragment, null, url && React__default.createElement("img", {
|
|
114
|
+
className: "avatar-img",
|
|
115
|
+
src: url,
|
|
116
|
+
alt: alt,
|
|
117
|
+
onError: errorEvent
|
|
118
|
+
}), icon && React__default.createElement(Icon, {
|
|
119
|
+
classPrefix: iconClassPrefix,
|
|
120
|
+
fontClassName: iconFontClassName,
|
|
121
|
+
className: "icon",
|
|
122
|
+
name: iconStyles,
|
|
123
|
+
size: iconSize
|
|
124
|
+
}), children && React__default.createElement("span", {
|
|
125
|
+
className: "text"
|
|
126
|
+
}, children)), showMax && React__default.createElement("div", {
|
|
127
|
+
className: "text"
|
|
128
|
+
}, parent !== null && parent !== void 0 && (_parent$propAvatarGro13 = parent.propAvatarGroup) !== null && _parent$propAvatarGro13 !== void 0 && _parent$propAvatarGro13.maxContent ? parent === null || parent === void 0 ? void 0 : (_parent$propAvatarGro14 = parent.propAvatarGroup) === null || _parent$propAvatarGro14 === void 0 ? void 0 : _parent$propAvatarGro14.maxContent : "+ ".concat(avatarIndex - (parent === null || parent === void 0 ? void 0 : (_parent$propAvatarGro15 = parent.propAvatarGroup) === null || _parent$propAvatarGro15 === void 0 ? void 0 : _parent$propAvatarGro15.maxCount)))));
|
|
129
|
+
};
|
|
130
|
+
Avatar.defaultProps = defaultProps;
|
|
131
|
+
Avatar.displayName = 'NutAvatar';
|
|
13
132
|
export { Avatar as default };
|