@nutui/nutui-react 2.0.0-alpha.11 → 2.0.0-alpha.12

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.
Files changed (86) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/esm/ActionSheet/style/style.css +1 -1
  3. package/dist/esm/ActionSheet.js +28 -37
  4. package/dist/esm/CountDown/style/style.css +1 -1
  5. package/dist/esm/CountDown.js +20 -15
  6. package/dist/esm/Ellipsis/style/style.css +1 -1
  7. package/dist/esm/SearchBar/style/style.css +1 -1
  8. package/dist/esm/SearchBar.js +33 -87
  9. package/dist/esm/ShortPassword/style/style.css +1 -1
  10. package/dist/esm/ShortPassword.js +65 -133
  11. package/dist/esm/Toast/style/style.css +1 -1
  12. package/dist/esm/Toast.js +86 -102
  13. package/dist/esm/VirtualList/style/style.css +1 -1
  14. package/dist/esm/VirtualList.js +29 -25
  15. package/dist/esm/types/src/packages/actionsheet/actionsheet.d.ts +11 -15
  16. package/dist/esm/types/src/packages/actionsheet/actionsheet.taro.d.ts +11 -15
  17. package/dist/esm/types/src/packages/actionsheet/index.d.ts +1 -0
  18. package/dist/esm/types/src/packages/actionsheet/index.taro.d.ts +1 -0
  19. package/dist/esm/types/src/packages/configprovider/configprovider.d.ts +2 -1
  20. package/dist/esm/types/src/packages/configprovider/configprovider.taro.d.ts +2 -1
  21. package/dist/esm/types/src/packages/configprovider/index.d.ts +1 -0
  22. package/dist/esm/types/src/packages/configprovider/index.taro.d.ts +1 -0
  23. package/dist/esm/types/src/packages/configprovider/types.d.ts +1 -0
  24. package/dist/esm/types/src/packages/countdown/countdown.d.ts +5 -4
  25. package/dist/esm/types/src/packages/countdown/countdown.taro.d.ts +5 -4
  26. package/dist/esm/types/src/packages/countdown/index.d.ts +1 -0
  27. package/dist/esm/types/src/packages/countdown/index.taro.d.ts +1 -0
  28. package/dist/esm/types/src/packages/ellipsis/ellipsis.taro.d.ts +1 -0
  29. package/dist/esm/types/src/packages/searchbar/index.d.ts +1 -0
  30. package/dist/esm/types/src/packages/searchbar/index.taro.d.ts +1 -0
  31. package/dist/esm/types/src/packages/searchbar/searchbar.d.ts +4 -31
  32. package/dist/esm/types/src/packages/searchbar/searchbar.taro.d.ts +4 -31
  33. package/dist/esm/types/src/packages/shortpassword/index.d.ts +1 -0
  34. package/dist/esm/types/src/packages/shortpassword/index.taro.d.ts +1 -0
  35. package/dist/esm/types/src/packages/shortpassword/shortpassword.d.ts +17 -20
  36. package/dist/esm/types/src/packages/shortpassword/shortpassword.taro.d.ts +17 -20
  37. package/dist/esm/types/src/packages/toast/Notification.d.ts +9 -13
  38. package/dist/esm/types/src/packages/toast/index.d.ts +1 -0
  39. package/dist/esm/types/src/packages/toast/index.taro.d.ts +1 -0
  40. package/dist/esm/types/src/packages/toast/toast.d.ts +19 -26
  41. package/dist/esm/types/src/packages/toast/toast.taro.d.ts +9 -11
  42. package/dist/esm/types/src/packages/virtuallist/index.d.ts +1 -0
  43. package/dist/esm/types/src/packages/virtuallist/index.taro.d.ts +1 -0
  44. package/dist/esm/types/src/packages/virtuallist/type.d.ts +0 -18
  45. package/dist/esm/types/src/packages/virtuallist/utils.d.ts +3 -3
  46. package/dist/esm/types/src/packages/virtuallist/virtuallist.d.ts +15 -4
  47. package/dist/esm/types/src/packages/virtuallist/virtuallist.taro.d.ts +13 -14
  48. package/dist/locales/base.js +1 -1
  49. package/dist/locales/en-US.js +1 -1
  50. package/dist/locales/id-ID.js +1 -1
  51. package/dist/locales/tr-TR.js +10 -2
  52. package/dist/locales/zh-CN.js +1 -1
  53. package/dist/locales/zh-TW.js +1 -1
  54. package/dist/locales/zh-UG.js +1 -1
  55. package/dist/nutui.react.es.js +442 -512
  56. package/dist/nutui.react.umd.js +442 -512
  57. package/dist/packages/actionsheet/actionsheet.scss +26 -73
  58. package/dist/packages/countdown/countdown.scss +2 -0
  59. package/dist/packages/ellipsis/ellipsis.scss +4 -0
  60. package/dist/packages/searchbar/searchbar.scss +13 -71
  61. package/dist/packages/shortpassword/shortpassword.scss +1 -88
  62. package/dist/packages/toast/toast.scss +20 -7
  63. package/dist/packages/virtuallist/virtuallist.scss +0 -12
  64. package/dist/style.css +1 -1
  65. package/dist/style.mjs +1 -1
  66. package/dist/styles/variables-jmapp.scss +56 -60
  67. package/dist/styles/variables.scss +30 -53
  68. package/dist/types/packages/actionsheet/actionsheet.d.ts +11 -15
  69. package/dist/types/packages/actionsheet/index.d.ts +1 -0
  70. package/dist/types/packages/configprovider/configprovider.d.ts +2 -1
  71. package/dist/types/packages/configprovider/index.d.ts +1 -0
  72. package/dist/types/packages/configprovider/types.d.ts +1 -0
  73. package/dist/types/packages/countdown/countdown.d.ts +5 -4
  74. package/dist/types/packages/countdown/index.d.ts +1 -0
  75. package/dist/types/packages/searchbar/index.d.ts +1 -0
  76. package/dist/types/packages/searchbar/searchbar.d.ts +4 -31
  77. package/dist/types/packages/shortpassword/index.d.ts +1 -0
  78. package/dist/types/packages/shortpassword/shortpassword.d.ts +17 -20
  79. package/dist/types/packages/toast/Notification.d.ts +9 -13
  80. package/dist/types/packages/toast/index.d.ts +1 -0
  81. package/dist/types/packages/toast/toast.d.ts +19 -26
  82. package/dist/types/packages/virtuallist/index.d.ts +1 -0
  83. package/dist/types/packages/virtuallist/type.d.ts +0 -18
  84. package/dist/types/packages/virtuallist/utils.d.ts +3 -3
  85. package/dist/types/packages/virtuallist/virtuallist.d.ts +15 -4
  86. package/package.json +1 -1
@@ -2,7 +2,7 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
4
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
- var _excluded = ["title", "description", "tips", "tipsIcon", "iconSize", "visible", "modelValue", "errorMsg", "noButton", "closeOnClickOverlay", "length", "style", "className", "onChange", "onOk", "onTips", "onCancel", "onClose", "onComplete", "autoFocus"];
5
+ var _excluded = ["title", "description", "tips", "visible", "value", "error", "hideFooter", "length", "plain", "style", "className", "closeable", "autoFocus", "onFocus", "onChange", "onConfirm", "onTips", "onCancel", "onClose", "onComplete", "onClickOverlay", "onClickCloseIcon"];
6
6
  function ownKeys(object, enumerableOnly) {
7
7
  var keys = Object.keys(object);
8
8
  if (Object.getOwnPropertySymbols) {
@@ -24,171 +24,103 @@ function _objectSpread(target) {
24
24
  }
25
25
  return target;
26
26
  }
27
- import React__default, { useRef, useState, useEffect } from "react";
27
+ import React__default, { useMemo, useEffect } from "react";
28
28
  import { Tips } from "@nutui/icons-react";
29
- import { c as cn } from "./bem.js";
29
+ import classNames from "classnames";
30
30
  import Popup from "./Popup.js";
31
31
  import { useConfig } from "./ConfigProvider.js";
32
32
  import { C as ComponentDefaults } from "./typings.js";
33
- import "@bem-react/classname";
33
+ import { u as usePropsValue } from "./use-props-value.js";
34
34
  var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
35
- title: "",
36
- description: "",
37
- tips: "",
38
- tipsIcon: null,
39
- iconSize: 11,
35
+ value: "",
40
36
  visible: false,
41
- modelValue: "",
42
- errorMsg: "",
43
- noButton: true,
44
- closeOnClickOverlay: true,
37
+ plain: false,
38
+ hideFooter: true,
45
39
  length: 6,
46
- className: "",
47
- autoFocus: false,
48
- onChange: function onChange(value) {
49
- },
50
- onOk: function onOk(value) {
51
- },
52
- onCancel: function onCancel() {
53
- },
54
- onClose: function onClose() {
55
- },
56
- onTips: function onTips() {
57
- },
58
- onComplete: function onComplete(value) {
59
- }
40
+ autoFocus: false
60
41
  });
61
42
  var ShortPassword = function ShortPassword2(props) {
62
43
  var _useConfig = useConfig(), locale = _useConfig.locale;
63
- var title = props.title, description = props.description, tips = props.tips, tipsIcon = props.tipsIcon, iconSize = props.iconSize, visible = props.visible, modelValue = props.modelValue, errorMsg = props.errorMsg, noButton = props.noButton, closeOnClickOverlay = props.closeOnClickOverlay, length = props.length, style = props.style, className = props.className, onChange2 = props.onChange, onOk2 = props.onOk, onTips2 = props.onTips, onCancel2 = props.onCancel, onClose2 = props.onClose, onComplete2 = props.onComplete, autoFocus = props.autoFocus, reset = _objectWithoutProperties(props, _excluded);
64
- var b = cn("shortpassword");
65
- var textInput = useRef(null);
66
- var range = function range2(val) {
67
- return Math.min(Math.max(4, val), 6);
44
+ var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props), title = _defaultProps$props.title, description = _defaultProps$props.description, tips = _defaultProps$props.tips, visible = _defaultProps$props.visible, value = _defaultProps$props.value, error = _defaultProps$props.error, hideFooter = _defaultProps$props.hideFooter, length = _defaultProps$props.length, plain = _defaultProps$props.plain, style = _defaultProps$props.style, className = _defaultProps$props.className, closeable = _defaultProps$props.closeable, autoFocus = _defaultProps$props.autoFocus, onFocus = _defaultProps$props.onFocus, onChange = _defaultProps$props.onChange, onConfirm = _defaultProps$props.onConfirm, onTips = _defaultProps$props.onTips, onCancel = _defaultProps$props.onCancel, onClose = _defaultProps$props.onClose, onComplete = _defaultProps$props.onComplete, onClickOverlay = _defaultProps$props.onClickOverlay, onClickCloseIcon = _defaultProps$props.onClickCloseIcon, rest = _objectWithoutProperties(_defaultProps$props, _excluded);
45
+ var classPrefix = "nut-shortpassword";
46
+ var comLen = useMemo(function() {
47
+ return Math.min(Math.max(4, length || 4), 6);
48
+ }, [length]);
49
+ var format = function format2(val) {
50
+ return val.slice(0, comLen);
68
51
  };
69
- var _useState = useState(visible), _useState2 = _slicedToArray(_useState, 2), innerVisible = _useState2[0], setInnerVisible = _useState2[1];
70
- var _useState3 = useState(range(Number(length))), _useState4 = _slicedToArray(_useState3, 2), comLen = _useState4[0], setComLen = _useState4[1];
71
- var _useState5 = useState(""), _useState6 = _slicedToArray(_useState5, 2), inputValue = _useState6[0], setInputValue = _useState6[1];
52
+ var _usePropsValue = usePropsValue({
53
+ value,
54
+ onChange
55
+ }), _usePropsValue2 = _slicedToArray(_usePropsValue, 2), inputValue = _usePropsValue2[0], setInputValue = _usePropsValue2[1];
72
56
  useEffect(function() {
73
- setInnerVisible(visible);
57
+ if (visible && autoFocus) {
58
+ onFocus && onFocus();
59
+ }
74
60
  }, [visible]);
75
61
  useEffect(function() {
76
- if (typeof modelValue !== "undefined") {
77
- setInputValue(modelValue);
78
- }
79
- }, [modelValue]);
80
- var changeValue = function changeValue2(e) {
81
- var inputValue2 = e.target.value;
82
- if (String(inputValue2).length > comLen) {
83
- inputValue2 = inputValue2.slice(0, comLen);
84
- }
85
- setInputValue(inputValue2);
86
- if (String(inputValue2).length === comLen) {
87
- onComplete2 && onComplete2(inputValue2);
88
- }
89
- onChange2 && onChange2(inputValue2);
90
- };
91
- var systemStyle = function systemStyle2() {
92
- var u = navigator.userAgent;
93
- var isAndroid = u.indexOf("Android") > -1 || u.indexOf("Linux") > -1;
94
- var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
95
- var style2 = {};
96
- if (isIOS) {
97
- style2 = {
98
- paddingRight: "1200px"
99
- };
100
- }
101
- if (isAndroid) {
102
- style2 = {
103
- opacity: 0,
104
- zIndex: 10
105
- };
62
+ var val = format(value);
63
+ if (val.length >= comLen) {
64
+ onComplete && onComplete(val);
106
65
  }
107
- return style2;
108
- };
109
- var focus = function focus2() {
110
- if (textInput.current) {
111
- textInput.current.focus();
112
- }
113
- };
66
+ setInputValue(format(value));
67
+ }, [value]);
114
68
  var sure = function sure2() {
115
- onOk2 && onOk2(inputValue);
69
+ onConfirm && onConfirm(inputValue);
116
70
  };
117
- var renderIcon = function renderIcon2() {
118
- var size = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "11px";
119
- return React__default.isValidElement(tipsIcon) ? React__default.cloneElement(tipsIcon, _objectSpread(_objectSpread({}, tipsIcon.props), {}, {
120
- width: size,
121
- height: size
122
- })) : React__default.createElement(Tips, {
123
- width: size,
124
- height: size
125
- });
126
- };
127
- return React__default.createElement("div", null, React__default.createElement(Popup, {
71
+ return React__default.createElement(Popup, _objectSpread({
128
72
  style: {
129
73
  padding: "32px 24px 28px 24px",
130
74
  borderRadius: "12px",
131
75
  textAlign: "center"
132
76
  },
133
- visible: innerVisible,
77
+ visible,
134
78
  closeable: true,
135
- "close-on-click-overlay": closeOnClickOverlay,
136
- onClickOverlay: onClose2,
137
- onClickCloseIcon: onClose2
138
- }, React__default.createElement("div", _objectSpread({
139
- className: "".concat(b(), " ").concat(className),
140
- style: _objectSpread({}, style)
141
- }, reset), React__default.createElement("div", {
142
- className: b("title")
79
+ onClickOverlay: onClose,
80
+ onClickCloseIcon: onClose
81
+ }, rest), React__default.createElement("div", {
82
+ className: classNames(className, classPrefix),
83
+ style
84
+ }, React__default.createElement("div", {
85
+ className: "".concat(classPrefix, "__title")
143
86
  }, title || locale.shortpassword.title), React__default.createElement("div", {
144
- className: b("subtitle")
87
+ className: "".concat(classPrefix, "__description")
145
88
  }, description || locale.shortpassword.description), React__default.createElement("div", {
146
- className: b("input")
147
- }, React__default.createElement("input", {
148
- ref: textInput,
149
- className: b("input-real"),
150
- type: "number",
151
- style: systemStyle(),
152
- maxLength: 6,
153
- value: inputValue,
154
- autoFocus,
155
- onChange: function onChange3(e) {
156
- return changeValue(e);
157
- }
158
- }), React__default.createElement("div", {
159
- className: b("input-site")
89
+ className: "".concat(classPrefix, "__input"),
90
+ onClick: onFocus
91
+ }, React__default.createElement("div", {
92
+ className: "".concat(classPrefix, "__input-site")
160
93
  }), React__default.createElement("div", {
161
- className: b("input-fake"),
162
- onClick: function onClick() {
163
- return focus();
164
- }
94
+ className: "".concat(classPrefix, "__input-fake")
165
95
  }, _toConsumableArray(new Array(comLen).keys()).map(function(item, index) {
166
96
  return React__default.createElement("div", {
167
- className: b("input-fake__li"),
97
+ className: "".concat(classPrefix, "__input-fake__li"),
168
98
  key: index
169
- }, String(inputValue).length > index ? React__default.createElement("div", {
170
- className: b("input-fake__li__icon")
171
- }) : null);
99
+ }, inputValue.length > index && React__default.createElement(React__default.Fragment, null, plain ? inputValue[index] : React__default.createElement("div", {
100
+ className: "".concat(classPrefix, "__input-fake__li__icon")
101
+ })));
172
102
  }))), React__default.createElement("div", {
173
- className: b("message")
103
+ className: "".concat(classPrefix, "__message")
174
104
  }, React__default.createElement("div", {
175
- className: b("message__error")
176
- }, errorMsg), tips || locale.shortpassword.tips ? React__default.createElement("div", {
177
- className: b("message__forget")
178
- }, renderIcon(iconSize), React__default.createElement("div", {
179
- className: b("message__forget-tips"),
180
- onClick: onTips2
181
- }, tips || locale.shortpassword.tips)) : null), !noButton ? React__default.createElement("div", {
182
- className: b("footer")
105
+ className: "".concat(classPrefix, "__message__error")
106
+ }, error), React__default.createElement("div", {
107
+ className: "".concat(classPrefix, "__message__forget"),
108
+ onClick: onTips
109
+ }, tips || React__default.createElement(React__default.Fragment, null, React__default.createElement(Tips, {
110
+ width: 11,
111
+ height: 11,
112
+ style: {
113
+ marginRight: "3px"
114
+ }
115
+ }), locale.shortpassword.tips))), !hideFooter && React__default.createElement("div", {
116
+ className: "".concat(classPrefix, "__footer")
183
117
  }, React__default.createElement("div", {
184
- className: b("footer__cancel"),
185
- onClick: onCancel2
118
+ className: "".concat(classPrefix, "__footer__cancel"),
119
+ onClick: onCancel
186
120
  }, locale.cancel), React__default.createElement("div", {
187
- className: b("footer__sure"),
188
- onClick: function onClick() {
189
- return sure();
190
- }
191
- }, locale.confirm)) : null)));
121
+ className: "".concat(classPrefix, "__footer__sure"),
122
+ onClick: sure
123
+ }, locale.confirm))));
192
124
  };
193
125
  ShortPassword.defaultProps = defaultProps;
194
126
  ShortPassword.displayName = "NutShortPassword";
@@ -1 +1 @@
1
- @keyframes rotation{0%{-webkit-transform:rotate(0deg)}to{-webkit-transform:rotate(360deg)}}.nut-toast{position:fixed;left:0;bottom:150px;width:100%;text-align:center;pointer-events:none;z-index:9999}.nut-toast-small .nut-toast__inner{font-size:var(--nutui-font-size-1, 12px)}.nut-toast-large .nut-toast__inner{font-size:var(--nutui-font-size-3, 16px)}.nut-toast-cover{display:flex;align-items:center;justify-content:center;pointer-events:auto;height:100%;background:var(--nutui-toast-cover-bg-color, var(--nutui-gray-7, rgba(0, 0, 0, .7)))}.nut-toast__inner{display:inline-block;font-size:var(--nutui-toast-text-font-size, 14px);min-width:40%;max-width:65%;text-align:center;padding:var(--nutui-toast-inner-padding, 24px 30px);word-break:break-all;background:var(--nutui-toast-inner-bg-color, var(--nutui-gray-7, rgba(0, 0, 0, .7)));border-radius:var(--nutui-toast-inner-border-radius, 12px);color:var(--nutui-toast-font-color, #fff)}.nut-toast-text{font-size:var(--nutui-toast-text-font-size, 14px)}.nut-toast-text:empty{margin-bottom:-8px}.nut-toast-title{font-size:var(--nutui-toast-title-font-size, 16px)}.nut-toast-title:empty{margin-bottom:-8px}.nut-toast-has-icon .nut-toast__icon-wrapper{width:100%;display:flex;align-items:center;justify-content:center;margin-bottom:8px}.nut-toast-center{top:50%;transform:translateY(-50%)}.nut-toast-loading .nut-toast__inner{display:inline-flex;flex-direction:column;justify-content:center;align-items:center}.nut-toast-loading .nut-toast__icon-wrapper{animation:rotation 2s linear infinite}.toast-fade-enter-active,.toast-fade-leave-active{transition:opacity .3s}.toast-fade-enter-from,.toast-fade-leave-to{opacity:0}
1
+ @keyframes rotation{0%{-webkit-transform:rotate(0deg)}to{-webkit-transform:rotate(360deg)}}.nut-toast{position:fixed;left:0;top:0;width:100%;height:100%;text-align:center;pointer-events:none;z-index:9999}.nut-toast__overlay-default{--nutui-overlay-bg-color: rgba(0, 0, 0, 0)}.nut-toast-small .nut-toast__inner{font-size:var(--nutui-font-size-1, 12px)}.nut-toast-large .nut-toast__inner{font-size:var(--nutui-font-size-3, 16px)}.nut-toast-cover{display:flex;align-items:center;justify-content:center;pointer-events:none;height:100%;background:var(--nutui-toast-cover-bg-color, var(--nutui-gray-7, rgba(0, 0, 0, .7)))}.nut-toast__inner{display:inline-block;font-size:var(--nutui-toast-text-font-size, 14px);min-width:40%;max-width:65%;text-align:var(--nutui-toast-inner-text-align, "center");padding:var(--nutui-toast-inner-padding, 24px 30px);word-break:break-all;background:var(--nutui-toast-inner-bg-color, var(--nutui-gray-7, rgba(0, 0, 0, .7)));border-radius:var(--nutui-toast-inner-border-radius, 12px);color:var(--nutui-toast-font-color, #fff);position:absolute;left:50%;top:var(--nutui-toast-inner-top, 50%);transform:translate(-50%,-50%)}.nut-toast-center{top:var(--nutui-toast-inner-top, 50%)}.nut-toast-bottom{top:var(--nutui-toast-inner-top, 80%)}.nut-toast-top{top:var(--nutui-toast-inner-top, 20%)}.nut-toast-text{font-size:var(--nutui-toast-text-font-size, 14px)}.nut-toast-text:empty{margin-bottom:-8px}.nut-toast-title{font-size:var(--nutui-toast-title-font-size, 16px)}.nut-toast-title:empty{margin-bottom:-8px}.nut-toast-has-icon .nut-toast__icon-wrapper{width:100%;display:flex;align-items:center;justify-content:center;margin-bottom:8px}.nut-toast-loading .nut-toast__inner{display:inline-flex;flex-direction:column;justify-content:center;align-items:center}.nut-toast-loading .nut-toast__icon-wrapper{animation:rotation 2s linear infinite}.toast-fade-enter-active,.toast-fade-leave-active{transition:opacity .3s}.toast-fade-enter-from,.toast-fade-leave-to{opacity:0}
package/dist/esm/Toast.js CHANGED
@@ -56,11 +56,12 @@ function _isNativeReflectConstruct() {
56
56
  }
57
57
  import * as React from "react";
58
58
  import classNames from "classnames";
59
- import { c as cn } from "./bem.js";
60
59
  import { r as render, u as unmount } from "./render.js";
61
- import { Loading } from "@nutui/icons-react";
62
- import "@bem-react/classname";
60
+ import { O as Overlay } from "./overlay2.js";
61
+ import { Issue, Failure, Loading, Check } from "@nutui/icons-react";
62
+ import { C as ComponentDefaults } from "./typings.js";
63
63
  import "react-dom";
64
+ var classPrefix = "nut-toast";
64
65
  var Notification = /* @__PURE__ */ function(_React$PureComponent) {
65
66
  _inherits(Notification2, _React$PureComponent);
66
67
  var _super = _createSuper(Notification2);
@@ -104,11 +105,39 @@ var Notification = /* @__PURE__ */ function(_React$PureComponent) {
104
105
  }, {
105
106
  key: "clickCover",
106
107
  value: function clickCover() {
107
- var closeOnClickOverlay = this.props.closeOnClickOverlay;
108
- if (closeOnClickOverlay) {
108
+ var closeOnOverlayClick = this.props.closeOnOverlayClick;
109
+ if (closeOnOverlayClick) {
109
110
  this.close();
110
111
  }
111
112
  }
113
+ }, {
114
+ key: "renderIcon",
115
+ value: function renderIcon() {
116
+ var icon = this.props.icon;
117
+ if (typeof icon === "string") {
118
+ var iconNode = null;
119
+ switch (icon) {
120
+ case "success":
121
+ iconNode = React.createElement(Check, null);
122
+ break;
123
+ case "loading":
124
+ iconNode = React.createElement(Loading, {
125
+ className: "nut-icon-loading"
126
+ });
127
+ break;
128
+ case "fail":
129
+ iconNode = React.createElement(Failure, null);
130
+ break;
131
+ case "warn":
132
+ iconNode = React.createElement(Issue, null);
133
+ break;
134
+ }
135
+ return React.createElement("p", {
136
+ className: "".concat(classPrefix, "__icon-wrapper")
137
+ }, iconNode);
138
+ }
139
+ return icon;
140
+ }
112
141
  }, {
113
142
  key: "componentDidMount",
114
143
  value: function componentDidMount() {
@@ -122,38 +151,31 @@ var Notification = /* @__PURE__ */ function(_React$PureComponent) {
122
151
  }, {
123
152
  key: "render",
124
153
  value: function render2() {
125
- var _classNames, _this3 = this;
126
- var _this$props = this.props, id = _this$props.id, style = _this$props.style, icon = _this$props.icon, title = _this$props.title, msg = _this$props.msg, bottom = _this$props.bottom, center = _this$props.center, bgColor = _this$props.bgColor, coverColor = _this$props.coverColor, textAlignCenter = _this$props.textAlignCenter, size = _this$props.size, customClass = _this$props.customClass, cover = _this$props.cover, type = _this$props.type;
127
- var toastBem = cn("toast");
128
- var classes = classNames((_classNames = {
129
- "nut-toast-center": center,
130
- "nut-toast-has-icon": icon,
131
- "nut-toast-cover": cover,
132
- "nut-toast-loading": type === "loading"
133
- }, _defineProperty(_classNames, "".concat(customClass), true), _defineProperty(_classNames, "nut-toast-".concat(size), true), _classNames));
134
- return React.createElement(React.Fragment, null, React.createElement("div", {
135
- className: "".concat(toastBem(), " ").concat(classes),
136
- id: "toast-".concat(id),
137
- style: _objectSpread({
138
- bottom: center ? "auto" : "".concat(bottom),
139
- backgroundColor: cover ? coverColor : ""
140
- }, style),
154
+ var _this3 = this;
155
+ var _this$props = this.props, id = _this$props.id, icon = _this$props.icon, title = _this$props.title, content = _this$props.content, position = _this$props.position, size = _this$props.size, closeOnOverlayClick = _this$props.closeOnOverlayClick, style = _this$props.style, className = _this$props.className, contentClassName = _this$props.contentClassName, contentStyle = _this$props.contentStyle;
156
+ var classes = classNames(_defineProperty({
157
+ "nut-toast-has-icon": icon
158
+ }, "nut-toast-".concat(size), true));
159
+ return React.createElement(React.Fragment, null, React.createElement(Overlay, {
160
+ visible: true,
161
+ style,
162
+ className: "".concat(classPrefix, "__overlay-default ").concat(className),
141
163
  onClick: function onClick() {
164
+ console.log("onclick");
142
165
  _this3.clickCover();
143
- }
166
+ },
167
+ closeOnOverlayClick
144
168
  }, React.createElement("div", {
145
- className: toastBem("inner"),
146
- style: {
147
- textAlign: textAlignCenter ? "center" : "left",
148
- backgroundColor: bgColor
149
- }
150
- }, icon ? React.createElement("p", {
151
- className: toastBem("icon-wrapper")
152
- }, icon) : null, title ? React.createElement("div", {
153
- className: "nut-toast-title"
169
+ className: "".concat(classPrefix, " ").concat(classes),
170
+ id: "toast-".concat(id)
171
+ }, React.createElement("div", {
172
+ className: "".concat(classPrefix, "__inner ").concat(classPrefix, "-").concat(position, " ").concat(contentClassName),
173
+ style: contentStyle
174
+ }, this.renderIcon(), title ? React.createElement("div", {
175
+ className: "".concat(classPrefix, "-title")
154
176
  }, title) : null, React.createElement("span", {
155
- className: toastBem("text")
156
- }, msg))));
177
+ className: "".concat(classPrefix, "-text")
178
+ }, content)))));
157
179
  }
158
180
  }]);
159
181
  return Notification2;
@@ -184,29 +206,18 @@ Notification.newInstance = function(properties, callback) {
184
206
  })), element);
185
207
  };
186
208
  var messageInstance = null;
187
- var options = {
188
- msg: "",
209
+ var options = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
189
210
  id: "",
190
- style: {},
191
- duration: 1.5,
192
- center: true,
193
- type: "text",
211
+ duration: 2,
212
+ position: "center",
194
213
  title: "",
195
- customClass: "",
196
- bottom: "30px",
197
214
  size: "base",
198
215
  icon: null,
199
- iconSize: "20",
200
- textAlignCenter: true,
201
- loadingRotate: true,
202
- bgColor: "rgba(0, 0, 0, .8)",
203
216
  onClose: function onClose() {
204
217
  },
205
- cover: false,
206
- coverColor: "rgba(0, 0, 0, 0)",
207
- closeOnClickOverlay: false
208
- // 是否点击遮罩可关闭
209
- };
218
+ closeOnOverlayClick: false,
219
+ contentClassName: ""
220
+ });
210
221
  function getInstance(props, callback) {
211
222
  if (messageInstance) {
212
223
  messageInstance.destroy();
@@ -221,6 +232,7 @@ function notice(opts) {
221
232
  if (messageInstance) {
222
233
  messageInstance.destroy();
223
234
  messageInstance = null;
235
+ opts.onClose && opts.onClose();
224
236
  }
225
237
  }
226
238
  var opts2 = _objectSpread(_objectSpread(_objectSpread({}, options), opts), {}, {
@@ -235,59 +247,31 @@ var errorMsg = function errorMsg2(msg) {
235
247
  console.warn("[NutUI Toast]: msg cannot be null");
236
248
  }
237
249
  };
250
+ function show(option) {
251
+ if (typeof option === "string") {
252
+ errorMsg(option);
253
+ return notice({
254
+ content: option
255
+ });
256
+ }
257
+ errorMsg(option.content);
258
+ return notice(_objectSpread({}, option));
259
+ }
260
+ function config(config2) {
261
+ if (config2.duration !== void 0) {
262
+ options.duration = config2.duration;
263
+ }
264
+ if (config2.position !== void 0) {
265
+ options.position = config2.position;
266
+ }
267
+ if (config2.closeOnOverlayClick !== void 0) {
268
+ options.closeOnOverlayClick = config2.closeOnOverlayClick;
269
+ }
270
+ }
238
271
  var Toast = {
239
- text: function text(msg) {
240
- var option = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
241
- errorMsg(msg);
242
- return notice(_objectSpread({
243
- msg,
244
- type: "text"
245
- }, option));
246
- },
247
- success: function success(msg) {
248
- var option = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
249
- errorMsg(msg);
250
- return notice(_objectSpread({
251
- msg,
252
- icon: "success",
253
- type: "success"
254
- }, option));
255
- },
256
- fail: function fail(msg) {
257
- var option = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
258
- errorMsg(msg);
259
- return notice(_objectSpread({
260
- msg,
261
- icon: "failure",
262
- type: "fail"
263
- }, option));
264
- },
265
- loading: function loading(msg) {
266
- var option = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
267
- errorMsg(msg);
268
- return notice(_objectSpread({
269
- msg,
270
- icon: React.createElement(Loading, null),
271
- type: "loading"
272
- }, option));
273
- },
274
- warn: function warn(msg) {
275
- var option = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
276
- errorMsg(msg);
277
- return notice(_objectSpread({
278
- msg,
279
- icon: "tips",
280
- type: "warn"
281
- }, option));
282
- },
283
- customIcon: function customIcon(msg) {
284
- var option = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
285
- errorMsg(msg);
286
- return notice(_objectSpread({
287
- msg
288
- }, option));
289
- },
290
- hide: function hide() {
272
+ show,
273
+ config,
274
+ clear: function clear() {
291
275
  if (messageInstance) {
292
276
  messageInstance.destroy();
293
277
  messageInstance = null;
@@ -1 +1 @@
1
- .nut-theme-dark .nut-virtualList-demo-box li{background-color:#141414;color:#e6e6e6}.nut-theme-dark .nut-virtualList-demo-box .nut-vertical-items li{box-shadow:0 1px 6px #141414}.nut-horizontal-items{float:left}.nut-horizontal-items li{display:block;float:left;background:var(--nutui-gray-6, #ffffff);padding:10px;margin-right:20px}.nut-horizontal-items:after{content:"";display:block;visibility:hidden;clear:both}.nut-vertical-items li{display:block;background:var(--nutui-gray-6, #ffffff);border-radius:7px;box-shadow:0 1px 6px #edeef1;margin-top:20px;padding:14px 15px;font-size:13px;line-height:18px;font-family:PingFangSC;font-weight:500;color:var(--nutui-gray-1, #1a1a1a)}.nut-virtualList-demo-item{height:100px}.nut-virtualList-box{overflow:auto}.nut-virtualList-demo-box .heigh1{height:500px}.nut-virtualList-demo-box.hideScrollbar .nut-virtualList-box::-webkit-scrollbar{width:0px;height:0px}.nut-virtuallist{width:100%;overflow:scroll;position:relative;-webkit-overflow-scrolling:touch}.nut-virtuallist-phantom{position:absolute;left:0;top:0;right:0;z-index:-1}.nut-virtuallist-container{left:0;right:0;top:0;position:absolute}.nut-virtuallist-item{overflow:hidden;margin:var(--nutui-list-item-margin, 0 0 10px 0)}
1
+ .nut-horizontal-items{float:left}.nut-horizontal-items li{display:block;float:left;background:var(--nutui-gray-6, #ffffff);padding:10px;margin-right:20px}.nut-horizontal-items:after{content:"";display:block;visibility:hidden;clear:both}.nut-vertical-items li{display:block;background:var(--nutui-gray-6, #ffffff);border-radius:7px;box-shadow:0 1px 6px #edeef1;margin-top:20px;padding:14px 15px;font-size:13px;line-height:18px;font-family:PingFangSC;font-weight:500;color:var(--nutui-gray-1, #1a1a1a)}.nut-virtualList-demo-item{height:100px}.nut-virtualList-box{overflow:auto}.nut-virtualList-demo-box .heigh1{height:500px}.nut-virtualList-demo-box.hideScrollbar .nut-virtualList-box::-webkit-scrollbar{width:0px;height:0px}.nut-virtuallist{width:100%;overflow:scroll;position:relative;-webkit-overflow-scrolling:touch}.nut-virtuallist-phantom{position:absolute;left:0;top:0;right:0;z-index:-1}.nut-virtuallist-container{left:0;right:0;top:0;position:absolute}.nut-virtuallist-item{overflow:hidden;margin:var(--nutui-list-item-margin, 0 0 10px 0)}