@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.
@@ -1,4 +1,110 @@
1
- import { B as Button } from './button-345fb015.js';
2
- export { B as default } from './button-345fb015.js';
3
- import 'react';
4
- import './Icon.js';
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 default };
package/dist/esm/Cell.js CHANGED
@@ -9,7 +9,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
9
9
  import React__default from 'react';
10
10
  import { useHistory } from 'react-router-dom';
11
11
  import { c as cn } from './bem-893ad28d.js';
12
- import { I as Icon } from './icon-63c0d58f.js';
12
+ import Icon from './Icon.js';
13
13
  import '@bem-react/classname';
14
14
  var defaultProps = {
15
15
  title: '',
package/dist/esm/Drag.js CHANGED
@@ -53,14 +53,7 @@ var Drag = function Drag(props) {
53
53
  currstyle = _useSpring2[0],
54
54
  api = _useSpring2[1];
55
55
 
56
- var screen = useRef({
57
- clientWidth: 0,
58
- clientHeight: 0
59
- });
60
- var element = useRef({
61
- offsetWidth: 0,
62
- offsetHeight: 0
63
- });
56
+ var middleLine = useRef(0);
64
57
 
65
58
  var getInfo = function getInfo() {
66
59
  var el = myDrag.current;
@@ -77,20 +70,13 @@ var Drag = function Drag(props) {
77
70
  left = boundary.left,
78
71
  bottom = boundary.bottom,
79
72
  right = boundary.right;
80
- element.current = {
81
- offsetWidth: offsetWidth,
82
- offsetHeight: offsetHeight
83
- };
84
- screen.current = {
85
- clientWidth: clientWidth,
86
- clientHeight: clientHeight
87
- };
88
73
  setBoundaryState({
89
74
  top: -offsetTop + top,
90
75
  left: -offsetLeft + left,
91
76
  bottom: clientHeight - offsetHeight - offsetTop - bottom,
92
77
  right: clientWidth - offsetWidth - offsetLeft - right
93
78
  });
79
+ middleLine.current = clientWidth - offsetWidth - offsetLeft - (clientWidth - offsetWidth) / 2;
94
80
  }
95
81
  };
96
82
 
@@ -109,22 +95,17 @@ var Drag = function Drag(props) {
109
95
 
110
96
  if (last) {
111
97
  if (props.direction != 'y' && props.attract) {
112
- if (x < (screen.current.clientWidth - element.current.offsetWidth) / 2) {
113
- console.log(x);
114
- window.requestAnimationFrame(function () {
115
- api.start({
116
- x: boundaryState.left,
117
- y: y,
118
- immediate: down
119
- });
98
+ if (x < middleLine.current) {
99
+ api.start({
100
+ x: boundaryState.left,
101
+ y: y,
102
+ immediate: down
120
103
  });
121
104
  } else {
122
- window.requestAnimationFrame(function () {
123
- api.start({
124
- x: screen.current.clientWidth - element.current.offsetWidth + boundaryState.left,
125
- y: y,
126
- immediate: down
127
- });
105
+ api.start({
106
+ x: boundaryState.right,
107
+ y: y,
108
+ immediate: down
128
109
  });
129
110
  }
130
111
  }
@@ -7,10 +7,10 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
7
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
8
 
9
9
  import React__default from 'react';
10
- import { I as Icon } from './icon-63c0d58f.js';
10
+ import Icon from './Icon.js';
11
+ import Overlay from './Overlay.js';
11
12
  import { c as cn } from './bem-893ad28d.js';
12
13
  import classNames from 'classnames';
13
- import { O as Overlay } from './overlay-418bcf84.js';
14
14
  import '@bem-react/classname';
15
15
  var defaultProps = {
16
16
  fixednavClass: 'nut-fixednav',
package/dist/esm/Icon.js CHANGED
@@ -1,5 +1,71 @@
1
- import { I as Icon } from './icon-63c0d58f.js';
2
- export { I as default } from './icon-63c0d58f.js';
3
- import 'react';
4
- import './bem-893ad28d.js';
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';
5
11
  import '@bem-react/classname';
12
+ var defaultProps = {
13
+ name: '',
14
+ size: '',
15
+ classPrefix: 'nutui-iconfont',
16
+ color: '',
17
+ tag: 'i',
18
+ click: function click(e) {},
19
+ className: ''
20
+ };
21
+
22
+ function pxCheck(value) {
23
+ return Number.isNaN(Number(value)) ? String(value) : "".concat(value, "px");
24
+ }
25
+
26
+ var Icon = function Icon(props) {
27
+ var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
28
+ name = _defaultProps$props.name,
29
+ size = _defaultProps$props.size,
30
+ classPrefix = _defaultProps$props.classPrefix,
31
+ color = _defaultProps$props.color,
32
+ tag = _defaultProps$props.tag,
33
+ children = _defaultProps$props.children,
34
+ className = _defaultProps$props.className,
35
+ style = _defaultProps$props.style,
36
+ click = _defaultProps$props.click,
37
+ rest = _objectWithoutProperties(_defaultProps$props, _excluded);
38
+
39
+ var isImage = name ? name.indexOf('/') !== -1 : false;
40
+ var type = isImage ? 'img' : tag;
41
+ var b = cn('icon');
42
+
43
+ var handleClick = function handleClick(e) {
44
+ if (props.click) {
45
+ props.click(e);
46
+ }
47
+ };
48
+
49
+ var hasSrc = function hasSrc() {
50
+ if (isImage) return {
51
+ src: name
52
+ };
53
+ return {};
54
+ };
55
+
56
+ return React__default.createElement(type, _objectSpread(_objectSpread({
57
+ className: isImage ? "".concat(className || '', " ").concat(b('img')) : "".concat(className || '', " ").concat(b(null, [classPrefix]), " nut-icon-").concat(name, " "),
58
+ style: _objectSpread({
59
+ color: color,
60
+ fontSize: pxCheck(size),
61
+ width: pxCheck(size),
62
+ height: pxCheck(size)
63
+ }, style)
64
+ }, rest), {}, {
65
+ onClick: handleClick
66
+ }, hasSrc()), children);
67
+ };
68
+
69
+ Icon.defaultProps = defaultProps;
70
+ Icon.displayName = 'NutIcon';
71
+ export { Icon as default };
package/dist/esm/Range.js CHANGED
@@ -7,11 +7,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
7
7
 
8
8
  import React__default, { useState, useRef, useEffect } from 'react';
9
9
  import { c as cn } from './bem-893ad28d.js';
10
- import { T as Toast } from './toast-420b65b7.js';
10
+ import Toast from './Toast.js';
11
11
  import '@bem-react/classname';
12
- import 'react-dom';
13
- import './icon-63c0d58f.js';
14
- import 'classnames';
15
12
  var MIN_DISTANCE = 10;
16
13
 
17
14
  function getDirection(x, y) {
@@ -8,9 +8,8 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
8
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
9
 
10
10
  import React__default, { useRef, useState, useEffect } from 'react';
11
- import { B as Button } from './button-345fb015.js';
11
+ import Button from './Button.js';
12
12
  import { c as cn } from './bem-893ad28d.js';
13
- import './Icon.js';
14
13
  import '@bem-react/classname';
15
14
  var defaultProps = {
16
15
  type: 'png',
package/dist/esm/Toast.js CHANGED
@@ -1,8 +1,295 @@
1
- import { T as Toast } from './toast-420b65b7.js';
2
- export { T as default } from './toast-420b65b7.js';
3
- import 'react';
4
- import 'react-dom';
5
- import './bem-893ad28d.js';
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 Icon from './Icon.js';
21
+ import classNames from 'classnames';
6
22
  import '@bem-react/classname';
7
- import './icon-63c0d58f.js';
8
- import 'classnames';
23
+
24
+ var Notification = /*#__PURE__*/function (_React$PureComponent) {
25
+ _inherits(Notification, _React$PureComponent);
26
+
27
+ var _super = _createSuper(Notification);
28
+
29
+ function Notification(props) {
30
+ var _this;
31
+
32
+ _classCallCheck(this, Notification);
33
+
34
+ _this = _super.call(this, props);
35
+
36
+ _defineProperty(_assertThisInitialized(_this), "closeTimer", void 0);
37
+
38
+ _this.close = _this.close.bind(_assertThisInitialized(_this));
39
+ _this.startCloseTimer = _this.startCloseTimer.bind(_assertThisInitialized(_this));
40
+ _this.clearCloseTimer = _this.clearCloseTimer.bind(_assertThisInitialized(_this));
41
+ _this.close = _this.close.bind(_assertThisInitialized(_this));
42
+ _this.clickCover = _this.clickCover.bind(_assertThisInitialized(_this));
43
+ _this.state = {
44
+ show: true
45
+ };
46
+ return _this;
47
+ }
48
+
49
+ _createClass(Notification, [{
50
+ key: "close",
51
+ value: function close() {
52
+ this.setState({
53
+ show: false
54
+ });
55
+ this.clearCloseTimer();
56
+ this.props.onClose();
57
+ }
58
+ }, {
59
+ key: "startCloseTimer",
60
+ value: function startCloseTimer() {
61
+ var _this2 = this;
62
+
63
+ var duration = this.props.duration;
64
+
65
+ if (duration) {
66
+ this.closeTimer = window.setTimeout(function () {
67
+ _this2.close();
68
+ }, duration * 1000);
69
+ }
70
+ }
71
+ }, {
72
+ key: "clearCloseTimer",
73
+ value: function clearCloseTimer() {
74
+ if (this.closeTimer) {
75
+ clearTimeout(this.closeTimer);
76
+ this.closeTimer = -1;
77
+ }
78
+ }
79
+ }, {
80
+ key: "clickCover",
81
+ value: function clickCover() {
82
+ var closeOnClickOverlay = this.props.closeOnClickOverlay;
83
+
84
+ if (closeOnClickOverlay) {
85
+ this.close();
86
+ }
87
+ }
88
+ }, {
89
+ key: "componentDidMount",
90
+ value: function componentDidMount() {
91
+ this.startCloseTimer();
92
+ }
93
+ }, {
94
+ key: "componentWillUnmount",
95
+ value: function componentWillUnmount() {
96
+ this.clearCloseTimer();
97
+ }
98
+ }, {
99
+ key: "render",
100
+ value: function render() {
101
+ var _classNames,
102
+ _this3 = this;
103
+
104
+ var _this$props = this.props,
105
+ style = _this$props.style,
106
+ icon = _this$props.icon,
107
+ msg = _this$props.msg,
108
+ bottom = _this$props.bottom,
109
+ center = _this$props.center,
110
+ bgColor = _this$props.bgColor,
111
+ coverColor = _this$props.coverColor,
112
+ textAlignCenter = _this$props.textAlignCenter,
113
+ size = _this$props.size,
114
+ customClass = _this$props.customClass,
115
+ cover = _this$props.cover,
116
+ type = _this$props.type;
117
+ this.state;
118
+ var toastBem = cn('toast');
119
+ 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));
120
+ return React.createElement(React.Fragment, null, React.createElement("div", {
121
+ className: "".concat(toastBem(), " ").concat(classes),
122
+ style: {
123
+ bottom: center ? 'auto' : bottom + 'px',
124
+ backgroundColor: cover ? coverColor : ''
125
+ },
126
+ onClick: function onClick() {
127
+ _this3.clickCover();
128
+ }
129
+ }, React.createElement("div", {
130
+ className: toastBem('inner'),
131
+ style: {
132
+ textAlign: textAlignCenter ? 'center' : 'left',
133
+ backgroundColor: bgColor
134
+ }
135
+ }, icon ? React.createElement("p", {
136
+ className: toastBem('icon-wrapper')
137
+ }, React.createElement(Icon, {
138
+ name: icon ? icon : '',
139
+ size: "20"
140
+ })) : null, React.createElement("span", {
141
+ className: toastBem('text')
142
+ }, msg))));
143
+ }
144
+ }]);
145
+
146
+ return Notification;
147
+ }(React.PureComponent);
148
+
149
+ _defineProperty(Notification, "newInstance", void 0);
150
+
151
+ Notification.newInstance = function (properties, callback) {
152
+ var element = document.createElement('div');
153
+
154
+ if (properties.id) {
155
+ element.setAttribute('id', "".concat(properties.id));
156
+ }
157
+
158
+ document.body.appendChild(element);
159
+ var called = false;
160
+
161
+ function ref(instance) {
162
+ if (called) {
163
+ return;
164
+ }
165
+
166
+ called = true;
167
+ callback({
168
+ component: instance,
169
+ destroy: function destroy() {
170
+ ReactDOM.unmountComponentAtNode(element);
171
+ element && element.parentNode && element.parentNode.removeChild(element);
172
+ }
173
+ });
174
+ }
175
+
176
+ ReactDOM.render(React.createElement(Notification, _objectSpread(_objectSpread({}, properties), {}, {
177
+ ref: ref
178
+ })), element);
179
+ };
180
+
181
+ var messageInstance = null;
182
+ var options = {
183
+ msg: '',
184
+ id: '',
185
+ duration: 1.5,
186
+ center: true,
187
+ type: 'text',
188
+ customClass: '',
189
+ bottom: 30,
190
+ size: 'base',
191
+ icon: '',
192
+ textAlignCenter: true,
193
+ loadingRotate: true,
194
+ bgColor: 'rgba(0, 0, 0, .8)',
195
+ onClose: function onClose() {},
196
+ cover: false,
197
+ coverColor: 'rgba(0, 0, 0, 0)',
198
+ closeOnClickOverlay: false // 是否点击遮罩可关闭
199
+
200
+ };
201
+
202
+ function getInstance(props, callback) {
203
+ if (messageInstance) {
204
+ messageInstance.destroy();
205
+ messageInstance = null;
206
+ }
207
+
208
+ Notification.newInstance(props, function (notification) {
209
+ return callback && callback(notification);
210
+ });
211
+ }
212
+
213
+ function notice(opts) {
214
+ function close() {
215
+ if (messageInstance) {
216
+ messageInstance.destroy();
217
+ messageInstance = null;
218
+ }
219
+ }
220
+
221
+ opts = _objectSpread(_objectSpread(_objectSpread({}, options), opts), {}, {
222
+ onClose: close
223
+ });
224
+ getInstance(opts, function (notification) {
225
+ messageInstance = notification;
226
+ });
227
+ }
228
+
229
+ var errorMsg = function errorMsg(msg) {
230
+ if (!msg) {
231
+ console.warn('[NutUI Toast]: msg不能为空');
232
+ return;
233
+ }
234
+ };
235
+
236
+ var Toast = {
237
+ text: function text(msg) {
238
+ var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
239
+ errorMsg(msg);
240
+ return notice(_objectSpread({
241
+ msg: msg,
242
+ type: 'text'
243
+ }, option));
244
+ },
245
+ success: function success(msg) {
246
+ var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
247
+ errorMsg(msg);
248
+ return notice(_objectSpread({
249
+ msg: msg,
250
+ icon: 'success',
251
+ type: 'success'
252
+ }, option));
253
+ },
254
+ fail: function fail(msg) {
255
+ var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
256
+ errorMsg(msg);
257
+ return notice(_objectSpread({
258
+ msg: msg,
259
+ icon: 'failure',
260
+ type: 'fail'
261
+ }, option));
262
+ },
263
+ loading: function loading(msg) {
264
+ var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
265
+ errorMsg(msg);
266
+ return notice(_objectSpread({
267
+ msg: msg,
268
+ icon: 'loading',
269
+ type: 'loading'
270
+ }, option));
271
+ },
272
+ warn: function warn(msg) {
273
+ var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
274
+ errorMsg(msg);
275
+ return notice(_objectSpread({
276
+ msg: msg,
277
+ icon: 'tips',
278
+ type: 'warn'
279
+ }, option));
280
+ },
281
+ customIcon: function customIcon(msg) {
282
+ var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
283
+ errorMsg(msg);
284
+ return notice(_objectSpread({
285
+ msg: msg
286
+ }, option));
287
+ },
288
+ hide: function hide() {
289
+ if (messageInstance) {
290
+ messageInstance.destroy();
291
+ messageInstance = null;
292
+ }
293
+ }
294
+ };
295
+ export { Toast as default };