@nutui/nutui-react 0.1.1 → 0.1.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/Button.js +110 -4
- package/dist/esm/Cell.js +1 -1
- package/dist/esm/Drag.js +11 -30
- package/dist/esm/FixedNav.js +2 -2
- package/dist/esm/Icon.js +70 -4
- package/dist/esm/Range.js +1 -4
- package/dist/esm/Signature.js +1 -2
- package/dist/esm/Toast.js +294 -7
- package/dist/esm/nutui-react.es.js +22 -22
- package/dist/esm/types/src/packages/nutui.react.build.d.ts +23 -23
- package/dist/esm/types/src/packages/nutui.react.d.ts +23 -23
- package/dist/nutui.react.es.js +10429 -10448
- package/dist/nutui.react.umd.js +21 -21
- package/dist/packages/cell/cell.scss +2 -0
- package/dist/packages/dialog/dialog.scss +1 -0
- package/dist/packages/fixednav/fixednav.scss +2 -0
- package/dist/packages/infiniteloading/infiniteloading.scss +1 -0
- package/dist/packages/input/input.scss +1 -0
- package/dist/packages/inputnumber/inputnumber.scss +1 -0
- package/dist/packages/range/range.scss +1 -0
- package/dist/packages/signature/signature.scss +1 -0
- package/dist/packages/step/step.scss +1 -0
- package/dist/packages/tag/tag.scss +1 -0
- package/dist/packages/toast/toast.scss +2 -0
- package/dist/packages/uploader/uploader.scss +2 -0
- package/dist/style.css +1 -1
- package/dist/style.es.js +1 -1
- package/dist/styles/themes/default.scss +22 -22
- package/package.json +2 -1
- package/dist/esm/button-345fb015.js +0 -110
- package/dist/esm/icon-63c0d58f.js +0 -70
- package/dist/esm/toast-420b65b7.js +0 -294
package/dist/style.es.js
CHANGED
|
@@ -10,47 +10,47 @@
|
|
|
10
10
|
@import '../../packages/layout/layout.scss';
|
|
11
11
|
@import '../../packages/row/row.scss';
|
|
12
12
|
@import '../../packages/col/col.scss';
|
|
13
|
-
@import '../../packages/drag/drag.scss';
|
|
14
|
-
@import '../../packages/collapse/collapse.scss';
|
|
15
13
|
@import '../../packages/toast/toast.scss';
|
|
16
|
-
@import '../../packages/
|
|
17
|
-
@import '../../packages/range/range.scss';
|
|
18
|
-
@import '../../packages/infiniteloading/infiniteloading.scss';
|
|
19
|
-
@import '../../packages/steps/steps.scss';
|
|
20
|
-
@import '../../packages/step/step.scss';
|
|
21
|
-
@import '../../packages/circleprogress/circleprogress.scss';
|
|
14
|
+
@import '../../packages/dialog/dialog.scss';
|
|
22
15
|
@import '../../packages/popup/popup.scss';
|
|
23
16
|
@import '../../packages/actionsheet/actionsheet.scss';
|
|
17
|
+
@import '../../packages/picker/picker.scss';
|
|
18
|
+
@import '../../packages/infiniteloading/infiniteloading.scss';
|
|
19
|
+
@import '../../packages/popover/popover.scss';
|
|
20
|
+
@import '../../packages/collapse/collapse.scss';
|
|
21
|
+
@import '../../packages/collapseitem/collapseitem.scss';
|
|
22
|
+
@import '../../packages/range/range.scss';
|
|
23
|
+
@import '../../packages/circleprogress/circleprogress.scss';
|
|
24
24
|
@import '../../packages/noticebar/noticebar.scss';
|
|
25
25
|
@import '../../packages/notify/notify.scss';
|
|
26
|
-
@import '../../packages/dialog/dialog.scss';
|
|
27
26
|
@import '../../packages/switch/switch.scss';
|
|
28
|
-
@import '../../packages/collapseitem/collapseitem.scss';
|
|
29
|
-
@import '../../packages/swiper/swiper.scss';
|
|
30
|
-
@import '../../packages/swiperitem/swiperitem.scss';
|
|
31
27
|
@import '../../packages/navbar/navbar.scss';
|
|
32
28
|
@import '../../packages/tabbar/tabbar.scss';
|
|
33
29
|
@import '../../packages/tabbaritem/tabbaritem.scss';
|
|
34
|
-
@import '../../packages/inputnumber/inputnumber.scss';
|
|
35
30
|
@import '../../packages/elevator/elevator.scss';
|
|
36
31
|
@import '../../packages/fixednav/fixednav.scss';
|
|
37
32
|
@import '../../packages/pagination/pagination.scss';
|
|
33
|
+
@import '../../packages/steps/steps.scss';
|
|
34
|
+
@import '../../packages/step/step.scss';
|
|
35
|
+
@import '../../packages/swiper/swiper.scss';
|
|
36
|
+
@import '../../packages/swiperitem/swiperitem.scss';
|
|
37
|
+
@import '../../packages/backtop/backtop.scss';
|
|
38
38
|
@import '../../packages/rate/rate.scss';
|
|
39
|
-
@import '../../packages/uploader/uploader.scss';
|
|
40
39
|
@import '../../packages/input/input.scss';
|
|
41
40
|
@import '../../packages/textarea/textarea.scss';
|
|
41
|
+
@import '../../packages/inputnumber/inputnumber.scss';
|
|
42
|
+
@import '../../packages/shortpassword/shortpassword.scss';
|
|
43
|
+
@import '../../packages/radio/radio.scss';
|
|
44
|
+
@import '../../packages/radiogroup/radiogroup.scss';
|
|
42
45
|
@import '../../packages/checkbox/checkbox.scss';
|
|
43
46
|
@import '../../packages/checkboxgroup/checkboxgroup.scss';
|
|
44
47
|
@import '../../packages/tag/tag.scss';
|
|
45
|
-
@import '../../packages/popover/popover.scss';
|
|
46
48
|
@import '../../packages/badge/badge.scss';
|
|
47
|
-
@import '../../packages/
|
|
48
|
-
@import '../../packages/radio/radio.scss';
|
|
49
|
-
@import '../../packages/radiogroup/radiogroup.scss';
|
|
50
|
-
@import '../../packages/shortpassword/shortpassword.scss';
|
|
49
|
+
@import '../../packages/uploader/uploader.scss';
|
|
51
50
|
@import '../../packages/calendar/calendar.scss';
|
|
52
51
|
@import '../../packages/calendaritem/calendaritem.scss';
|
|
53
|
-
@import '../../packages/picker/picker.scss';
|
|
54
|
-
@import '../../packages/signature/signature.scss';
|
|
55
|
-
@import '../../packages/barrage/barrage.scss';
|
|
56
52
|
@import '../../packages/address/address.scss';
|
|
53
|
+
@import '../../packages/barrage/barrage.scss';
|
|
54
|
+
@import '../../packages/signature/signature.scss';
|
|
55
|
+
@import '../../packages/drag/drag.scss';
|
|
56
|
+
@import '../../packages/animatingnumbers/animatingnumbers.scss';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nutui/nutui-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"style": "dist/style.css",
|
|
5
5
|
"main": "dist/nutui.react.umd.js",
|
|
6
6
|
"module": "dist/esm/nutui-react.es.js",
|
|
@@ -109,6 +109,7 @@
|
|
|
109
109
|
"husky": "^6.0.0",
|
|
110
110
|
"inquirer": "^8.0.0",
|
|
111
111
|
"lint-staged": "^11.0.0",
|
|
112
|
+
"lzutf8": "^0.6.0",
|
|
112
113
|
"map-stream": "0.0.7",
|
|
113
114
|
"marked": "^2.0.3",
|
|
114
115
|
"postcss-import": "^14.0.2",
|
|
@@ -1,110 +0,0 @@
|
|
|
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 = ["color", "shape", "plain", "loading", "disabled", "type", "size", "block", "icon", "children", "onClick", "className", "style"];
|
|
5
|
-
|
|
6
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
7
|
-
|
|
8
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
9
|
-
|
|
10
|
-
import React__default, { useState, useEffect } from 'react';
|
|
11
|
-
import Icon from './Icon.js';
|
|
12
|
-
var defaultProps = {
|
|
13
|
-
className: '',
|
|
14
|
-
color: '',
|
|
15
|
-
shape: 'round',
|
|
16
|
-
plain: false,
|
|
17
|
-
loading: false,
|
|
18
|
-
disabled: false,
|
|
19
|
-
type: 'default',
|
|
20
|
-
size: 'normal',
|
|
21
|
-
block: false,
|
|
22
|
-
icon: '',
|
|
23
|
-
style: {},
|
|
24
|
-
children: undefined,
|
|
25
|
-
onClick: function onClick(e) {}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
var Button = function Button(props) {
|
|
29
|
-
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
30
|
-
color = _defaultProps$props.color,
|
|
31
|
-
shape = _defaultProps$props.shape,
|
|
32
|
-
plain = _defaultProps$props.plain,
|
|
33
|
-
loading = _defaultProps$props.loading,
|
|
34
|
-
disabled = _defaultProps$props.disabled,
|
|
35
|
-
type = _defaultProps$props.type,
|
|
36
|
-
size = _defaultProps$props.size,
|
|
37
|
-
block = _defaultProps$props.block,
|
|
38
|
-
icon = _defaultProps$props.icon,
|
|
39
|
-
children = _defaultProps$props.children,
|
|
40
|
-
onClick = _defaultProps$props.onClick,
|
|
41
|
-
className = _defaultProps$props.className,
|
|
42
|
-
style = _defaultProps$props.style,
|
|
43
|
-
rest = _objectWithoutProperties(_defaultProps$props, _excluded);
|
|
44
|
-
|
|
45
|
-
var _useState = useState(''),
|
|
46
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
47
|
-
btnName = _useState2[0],
|
|
48
|
-
setBtnName = _useState2[1];
|
|
49
|
-
|
|
50
|
-
var _useState3 = useState({}),
|
|
51
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
52
|
-
btnStyle = _useState4[0],
|
|
53
|
-
setBtnStyle = _useState4[1];
|
|
54
|
-
|
|
55
|
-
useEffect(function () {
|
|
56
|
-
setBtnName(classes());
|
|
57
|
-
setBtnStyle(getStyle());
|
|
58
|
-
}, [className, color, shape, plain, loading, disabled, style, type, size, block, icon, children, onClick]);
|
|
59
|
-
|
|
60
|
-
var classes = function classes() {
|
|
61
|
-
var prefixCls = 'nut-button';
|
|
62
|
-
return "".concat(prefixCls, " ").concat(type ? "".concat(prefixCls, "--").concat(type) : '', "\n ").concat(size ? "".concat(prefixCls, "--").concat(size) : '', "\n ").concat(shape ? "".concat(prefixCls, "--").concat(shape) : '', "\n ").concat(plain ? "".concat(prefixCls, "--plain") : '', "\n ").concat(block ? "".concat(prefixCls, "--block") : '', "\n ").concat(disabled ? "".concat(prefixCls, "--disabled") : '', "\n ").concat(loading ? "".concat(prefixCls, "--loading") : '');
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
var handleClick = function handleClick(e) {
|
|
66
|
-
if (!loading && !disabled && onClick) {
|
|
67
|
-
onClick(e);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
var getStyle = function getStyle() {
|
|
72
|
-
var style = {};
|
|
73
|
-
|
|
74
|
-
if (color) {
|
|
75
|
-
if (plain) {
|
|
76
|
-
style.color = color;
|
|
77
|
-
style.background = '#fff';
|
|
78
|
-
|
|
79
|
-
if (!(color !== null && color !== void 0 && color.includes('gradient'))) {
|
|
80
|
-
style.borderColor = color;
|
|
81
|
-
}
|
|
82
|
-
} else {
|
|
83
|
-
style.color = '#fff';
|
|
84
|
-
style.background = color;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return style;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
return React__default.createElement("div", _objectSpread(_objectSpread({
|
|
92
|
-
className: "".concat(btnName, " ").concat(className),
|
|
93
|
-
style: _objectSpread(_objectSpread({}, btnStyle), style)
|
|
94
|
-
}, rest), {}, {
|
|
95
|
-
onClick: function onClick(e) {
|
|
96
|
-
return handleClick(e);
|
|
97
|
-
}
|
|
98
|
-
}), React__default.createElement("div", {
|
|
99
|
-
className: "nut-button__warp",
|
|
100
|
-
style: getStyle()
|
|
101
|
-
}, loading && React__default.createElement(Icon, {
|
|
102
|
-
name: "loading"
|
|
103
|
-
}), !loading && icon ? React__default.createElement(Icon, {
|
|
104
|
-
name: icon
|
|
105
|
-
}) : '', children));
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
Button.defaultProps = defaultProps;
|
|
109
|
-
Button.displayName = 'NutButton';
|
|
110
|
-
export { Button as B };
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["name", "size", "classPrefix", "color", "tag", "children", "className", "style", "click"];
|
|
4
|
-
|
|
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
|
-
|
|
7
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
8
|
-
|
|
9
|
-
import React__default from 'react';
|
|
10
|
-
import { c as cn } from './bem-893ad28d.js';
|
|
11
|
-
var defaultProps = {
|
|
12
|
-
name: '',
|
|
13
|
-
size: '',
|
|
14
|
-
classPrefix: 'nutui-iconfont',
|
|
15
|
-
color: '',
|
|
16
|
-
tag: 'i',
|
|
17
|
-
click: function click(e) {},
|
|
18
|
-
className: ''
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
function pxCheck(value) {
|
|
22
|
-
return Number.isNaN(Number(value)) ? String(value) : "".concat(value, "px");
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
var Icon = function Icon(props) {
|
|
26
|
-
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
27
|
-
name = _defaultProps$props.name,
|
|
28
|
-
size = _defaultProps$props.size,
|
|
29
|
-
classPrefix = _defaultProps$props.classPrefix,
|
|
30
|
-
color = _defaultProps$props.color,
|
|
31
|
-
tag = _defaultProps$props.tag,
|
|
32
|
-
children = _defaultProps$props.children,
|
|
33
|
-
className = _defaultProps$props.className,
|
|
34
|
-
style = _defaultProps$props.style,
|
|
35
|
-
click = _defaultProps$props.click,
|
|
36
|
-
rest = _objectWithoutProperties(_defaultProps$props, _excluded);
|
|
37
|
-
|
|
38
|
-
var isImage = name ? name.indexOf('/') !== -1 : false;
|
|
39
|
-
var type = isImage ? 'img' : tag;
|
|
40
|
-
var b = cn('icon');
|
|
41
|
-
|
|
42
|
-
var handleClick = function handleClick(e) {
|
|
43
|
-
if (props.click) {
|
|
44
|
-
props.click(e);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
var hasSrc = function hasSrc() {
|
|
49
|
-
if (isImage) return {
|
|
50
|
-
src: name
|
|
51
|
-
};
|
|
52
|
-
return {};
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
return React__default.createElement(type, _objectSpread(_objectSpread({
|
|
56
|
-
className: isImage ? "".concat(className || '', " ").concat(b('img')) : "".concat(className || '', " ").concat(b(null, [classPrefix]), " nut-icon-").concat(name, " "),
|
|
57
|
-
style: _objectSpread({
|
|
58
|
-
color: color,
|
|
59
|
-
fontSize: pxCheck(size),
|
|
60
|
-
width: pxCheck(size),
|
|
61
|
-
height: pxCheck(size)
|
|
62
|
-
}, style)
|
|
63
|
-
}, rest), {}, {
|
|
64
|
-
onClick: handleClick
|
|
65
|
-
}, hasSrc()), children);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
Icon.defaultProps = defaultProps;
|
|
69
|
-
Icon.displayName = 'NutIcon';
|
|
70
|
-
export { Icon as I };
|
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
-
|
|
9
|
-
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; }
|
|
10
|
-
|
|
11
|
-
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; }
|
|
12
|
-
|
|
13
|
-
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); }; }
|
|
14
|
-
|
|
15
|
-
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; } }
|
|
16
|
-
|
|
17
|
-
import * as React from 'react';
|
|
18
|
-
import * as ReactDOM from 'react-dom';
|
|
19
|
-
import { c as cn } from './bem-893ad28d.js';
|
|
20
|
-
import { I as Icon } from './icon-63c0d58f.js';
|
|
21
|
-
import classNames from 'classnames';
|
|
22
|
-
|
|
23
|
-
var Notification = /*#__PURE__*/function (_React$PureComponent) {
|
|
24
|
-
_inherits(Notification, _React$PureComponent);
|
|
25
|
-
|
|
26
|
-
var _super = _createSuper(Notification);
|
|
27
|
-
|
|
28
|
-
function Notification(props) {
|
|
29
|
-
var _this;
|
|
30
|
-
|
|
31
|
-
_classCallCheck(this, Notification);
|
|
32
|
-
|
|
33
|
-
_this = _super.call(this, props);
|
|
34
|
-
|
|
35
|
-
_defineProperty(_assertThisInitialized(_this), "closeTimer", void 0);
|
|
36
|
-
|
|
37
|
-
_this.close = _this.close.bind(_assertThisInitialized(_this));
|
|
38
|
-
_this.startCloseTimer = _this.startCloseTimer.bind(_assertThisInitialized(_this));
|
|
39
|
-
_this.clearCloseTimer = _this.clearCloseTimer.bind(_assertThisInitialized(_this));
|
|
40
|
-
_this.close = _this.close.bind(_assertThisInitialized(_this));
|
|
41
|
-
_this.clickCover = _this.clickCover.bind(_assertThisInitialized(_this));
|
|
42
|
-
_this.state = {
|
|
43
|
-
show: true
|
|
44
|
-
};
|
|
45
|
-
return _this;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
_createClass(Notification, [{
|
|
49
|
-
key: "close",
|
|
50
|
-
value: function close() {
|
|
51
|
-
this.setState({
|
|
52
|
-
show: false
|
|
53
|
-
});
|
|
54
|
-
this.clearCloseTimer();
|
|
55
|
-
this.props.onClose();
|
|
56
|
-
}
|
|
57
|
-
}, {
|
|
58
|
-
key: "startCloseTimer",
|
|
59
|
-
value: function startCloseTimer() {
|
|
60
|
-
var _this2 = this;
|
|
61
|
-
|
|
62
|
-
var duration = this.props.duration;
|
|
63
|
-
|
|
64
|
-
if (duration) {
|
|
65
|
-
this.closeTimer = window.setTimeout(function () {
|
|
66
|
-
_this2.close();
|
|
67
|
-
}, duration * 1000);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}, {
|
|
71
|
-
key: "clearCloseTimer",
|
|
72
|
-
value: function clearCloseTimer() {
|
|
73
|
-
if (this.closeTimer) {
|
|
74
|
-
clearTimeout(this.closeTimer);
|
|
75
|
-
this.closeTimer = -1;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}, {
|
|
79
|
-
key: "clickCover",
|
|
80
|
-
value: function clickCover() {
|
|
81
|
-
var closeOnClickOverlay = this.props.closeOnClickOverlay;
|
|
82
|
-
|
|
83
|
-
if (closeOnClickOverlay) {
|
|
84
|
-
this.close();
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}, {
|
|
88
|
-
key: "componentDidMount",
|
|
89
|
-
value: function componentDidMount() {
|
|
90
|
-
this.startCloseTimer();
|
|
91
|
-
}
|
|
92
|
-
}, {
|
|
93
|
-
key: "componentWillUnmount",
|
|
94
|
-
value: function componentWillUnmount() {
|
|
95
|
-
this.clearCloseTimer();
|
|
96
|
-
}
|
|
97
|
-
}, {
|
|
98
|
-
key: "render",
|
|
99
|
-
value: function render() {
|
|
100
|
-
var _classNames,
|
|
101
|
-
_this3 = this;
|
|
102
|
-
|
|
103
|
-
var _this$props = this.props,
|
|
104
|
-
style = _this$props.style,
|
|
105
|
-
icon = _this$props.icon,
|
|
106
|
-
msg = _this$props.msg,
|
|
107
|
-
bottom = _this$props.bottom,
|
|
108
|
-
center = _this$props.center,
|
|
109
|
-
bgColor = _this$props.bgColor,
|
|
110
|
-
coverColor = _this$props.coverColor,
|
|
111
|
-
textAlignCenter = _this$props.textAlignCenter,
|
|
112
|
-
size = _this$props.size,
|
|
113
|
-
customClass = _this$props.customClass,
|
|
114
|
-
cover = _this$props.cover,
|
|
115
|
-
type = _this$props.type;
|
|
116
|
-
this.state;
|
|
117
|
-
var toastBem = cn('toast');
|
|
118
|
-
var classes = classNames((_classNames = {}, _defineProperty(_classNames, 'nut-toast-center', center), _defineProperty(_classNames, 'nut-toast-has-icon', icon), _defineProperty(_classNames, 'nut-toast-cover', cover), _defineProperty(_classNames, 'nut-toast-loading', type === 'loading'), _defineProperty(_classNames, "customClass", customClass), _defineProperty(_classNames, 'nut-toast-' + size, true), _classNames));
|
|
119
|
-
return React.createElement(React.Fragment, null, React.createElement("div", {
|
|
120
|
-
className: "".concat(toastBem(), " ").concat(classes),
|
|
121
|
-
style: {
|
|
122
|
-
bottom: center ? 'auto' : bottom + 'px',
|
|
123
|
-
backgroundColor: cover ? coverColor : ''
|
|
124
|
-
},
|
|
125
|
-
onClick: function onClick() {
|
|
126
|
-
_this3.clickCover();
|
|
127
|
-
}
|
|
128
|
-
}, React.createElement("div", {
|
|
129
|
-
className: toastBem('inner'),
|
|
130
|
-
style: {
|
|
131
|
-
textAlign: textAlignCenter ? 'center' : 'left',
|
|
132
|
-
backgroundColor: bgColor
|
|
133
|
-
}
|
|
134
|
-
}, icon ? React.createElement("p", {
|
|
135
|
-
className: toastBem('icon-wrapper')
|
|
136
|
-
}, React.createElement(Icon, {
|
|
137
|
-
name: icon ? icon : '',
|
|
138
|
-
size: "20"
|
|
139
|
-
})) : null, React.createElement("span", {
|
|
140
|
-
className: toastBem('text')
|
|
141
|
-
}, msg))));
|
|
142
|
-
}
|
|
143
|
-
}]);
|
|
144
|
-
|
|
145
|
-
return Notification;
|
|
146
|
-
}(React.PureComponent);
|
|
147
|
-
|
|
148
|
-
_defineProperty(Notification, "newInstance", void 0);
|
|
149
|
-
|
|
150
|
-
Notification.newInstance = function (properties, callback) {
|
|
151
|
-
var element = document.createElement('div');
|
|
152
|
-
|
|
153
|
-
if (properties.id) {
|
|
154
|
-
element.setAttribute('id', "".concat(properties.id));
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
document.body.appendChild(element);
|
|
158
|
-
var called = false;
|
|
159
|
-
|
|
160
|
-
function ref(instance) {
|
|
161
|
-
if (called) {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
called = true;
|
|
166
|
-
callback({
|
|
167
|
-
component: instance,
|
|
168
|
-
destroy: function destroy() {
|
|
169
|
-
ReactDOM.unmountComponentAtNode(element);
|
|
170
|
-
element && element.parentNode && element.parentNode.removeChild(element);
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
ReactDOM.render(React.createElement(Notification, _objectSpread(_objectSpread({}, properties), {}, {
|
|
176
|
-
ref: ref
|
|
177
|
-
})), element);
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
var messageInstance = null;
|
|
181
|
-
var options = {
|
|
182
|
-
msg: '',
|
|
183
|
-
id: '',
|
|
184
|
-
duration: 1.5,
|
|
185
|
-
center: true,
|
|
186
|
-
type: 'text',
|
|
187
|
-
customClass: '',
|
|
188
|
-
bottom: 30,
|
|
189
|
-
size: 'base',
|
|
190
|
-
icon: '',
|
|
191
|
-
textAlignCenter: true,
|
|
192
|
-
loadingRotate: true,
|
|
193
|
-
bgColor: 'rgba(0, 0, 0, .8)',
|
|
194
|
-
onClose: function onClose() {},
|
|
195
|
-
cover: false,
|
|
196
|
-
coverColor: 'rgba(0, 0, 0, 0)',
|
|
197
|
-
closeOnClickOverlay: false // 是否点击遮罩可关闭
|
|
198
|
-
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
function getInstance(props, callback) {
|
|
202
|
-
if (messageInstance) {
|
|
203
|
-
messageInstance.destroy();
|
|
204
|
-
messageInstance = null;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
Notification.newInstance(props, function (notification) {
|
|
208
|
-
return callback && callback(notification);
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
function notice(opts) {
|
|
213
|
-
function close() {
|
|
214
|
-
if (messageInstance) {
|
|
215
|
-
messageInstance.destroy();
|
|
216
|
-
messageInstance = null;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
opts = _objectSpread(_objectSpread(_objectSpread({}, options), opts), {}, {
|
|
221
|
-
onClose: close
|
|
222
|
-
});
|
|
223
|
-
getInstance(opts, function (notification) {
|
|
224
|
-
messageInstance = notification;
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
var errorMsg = function errorMsg(msg) {
|
|
229
|
-
if (!msg) {
|
|
230
|
-
console.warn('[NutUI Toast]: msg不能为空');
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
var Toast = {
|
|
236
|
-
text: function text(msg) {
|
|
237
|
-
var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
238
|
-
errorMsg(msg);
|
|
239
|
-
return notice(_objectSpread({
|
|
240
|
-
msg: msg,
|
|
241
|
-
type: 'text'
|
|
242
|
-
}, option));
|
|
243
|
-
},
|
|
244
|
-
success: function success(msg) {
|
|
245
|
-
var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
246
|
-
errorMsg(msg);
|
|
247
|
-
return notice(_objectSpread({
|
|
248
|
-
msg: msg,
|
|
249
|
-
icon: 'success',
|
|
250
|
-
type: 'success'
|
|
251
|
-
}, option));
|
|
252
|
-
},
|
|
253
|
-
fail: function fail(msg) {
|
|
254
|
-
var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
255
|
-
errorMsg(msg);
|
|
256
|
-
return notice(_objectSpread({
|
|
257
|
-
msg: msg,
|
|
258
|
-
icon: 'failure',
|
|
259
|
-
type: 'fail'
|
|
260
|
-
}, option));
|
|
261
|
-
},
|
|
262
|
-
loading: function loading(msg) {
|
|
263
|
-
var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
264
|
-
errorMsg(msg);
|
|
265
|
-
return notice(_objectSpread({
|
|
266
|
-
msg: msg,
|
|
267
|
-
icon: 'loading',
|
|
268
|
-
type: 'loading'
|
|
269
|
-
}, option));
|
|
270
|
-
},
|
|
271
|
-
warn: function warn(msg) {
|
|
272
|
-
var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
273
|
-
errorMsg(msg);
|
|
274
|
-
return notice(_objectSpread({
|
|
275
|
-
msg: msg,
|
|
276
|
-
icon: 'tips',
|
|
277
|
-
type: 'warn'
|
|
278
|
-
}, option));
|
|
279
|
-
},
|
|
280
|
-
customIcon: function customIcon(msg) {
|
|
281
|
-
var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
282
|
-
errorMsg(msg);
|
|
283
|
-
return notice(_objectSpread({
|
|
284
|
-
msg: msg
|
|
285
|
-
}, option));
|
|
286
|
-
},
|
|
287
|
-
hide: function hide() {
|
|
288
|
-
if (messageInstance) {
|
|
289
|
-
messageInstance.destroy();
|
|
290
|
-
messageInstance = null;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
};
|
|
294
|
-
export { Toast as T };
|