@uiw/react-notify
Advanced tools
Comparing version
@@ -5,11 +5,23 @@ "use strict"; | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports["default"] = void 0; | ||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2")); | ||
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose")); | ||
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")); | ||
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose")); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")); | ||
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); | ||
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _react = _interopRequireDefault(require("react")); | ||
@@ -26,7 +38,11 @@ | ||
var Container = /*#__PURE__*/function (_React$Component) { | ||
(0, _inheritsLoose2["default"])(Container, _React$Component); | ||
(0, _inherits2["default"])(Container, _React$Component); | ||
var _super = (0, _createSuper2["default"])(Container); | ||
function Container() { | ||
var _this; | ||
(0, _classCallCheck2["default"])(this, Container); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
@@ -36,92 +52,94 @@ args[_key] = arguments[_key]; | ||
_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this; | ||
_this.state = { | ||
_this = _super.call.apply(_super, [this].concat(args)); | ||
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", { | ||
notifys: {} | ||
}; | ||
}); | ||
return _this; | ||
} | ||
var _proto = Container.prototype; | ||
(0, _createClass2["default"])(Container, [{ | ||
key: "create", | ||
value: function create(props) { | ||
var _this2 = this; | ||
_proto.create = function create(props) { | ||
var _this2 = this; | ||
var placement = props.placement, | ||
key = props.key; | ||
var placement = props.placement, | ||
key = props.key; | ||
if (!notifys[placement]) { | ||
notifys[placement] = {}; | ||
} | ||
if (!notifys[placement]) { | ||
notifys[placement] = {}; | ||
} | ||
props.isOpen = false; | ||
notifys[placement][key] = props; | ||
props.isOpen = false; | ||
notifys[placement][key] = props; | ||
if (props.duration) { | ||
timer[key] = setTimeout(function () { | ||
_this2.closed(key, placement); | ||
}, props.duration); | ||
} | ||
if (props.duration) { | ||
timer[key] = setTimeout(function () { | ||
_this2.closed(key, placement); | ||
}, props.duration); | ||
} | ||
this.setState({ | ||
notifys: notifys, | ||
placement: placement | ||
}, function () { | ||
notifys[placement][key].isOpen = true; | ||
this.setState({ | ||
notifys: notifys, | ||
placement: placement | ||
}, function () { | ||
notifys[placement][key].isOpen = true; | ||
_this2.setState({ | ||
notifys: notifys | ||
_this2.setState({ | ||
notifys: notifys | ||
}); | ||
}); | ||
}); | ||
}; | ||
_proto.closed = function closed(key, placement) { | ||
if (!key || !placement || !notifys[placement][key]) { | ||
return; | ||
} | ||
notifys[placement][key].isOpen = false; | ||
var props = notifys[placement][key]; | ||
this.setState({ | ||
notifys: notifys | ||
}, function () { | ||
clearTimeout(timer[key]); | ||
delete timer[key]; | ||
delete notifys[placement][key]; | ||
if (props && props.willUnmount) { | ||
props.willUnmount(props, notifys); | ||
}, { | ||
key: "closed", | ||
value: function closed(key, placement) { | ||
if (!key || !placement || !notifys[placement][key]) { | ||
return; | ||
} | ||
}); | ||
}; | ||
_proto.render = function render() { | ||
var _this3 = this; | ||
notifys[placement][key].isOpen = false; | ||
var props = notifys[placement][key]; | ||
this.setState({ | ||
notifys: notifys | ||
}, function () { | ||
clearTimeout(timer[key]); | ||
delete timer[key]; | ||
delete notifys[placement][key]; | ||
var prefixCls = this.props.prefixCls; | ||
var placement = this.state.placement; | ||
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react["default"].Fragment, { | ||
children: placement && Object.keys(this.state.notifys[placement]).map(function (key) { | ||
var _this3$state$notifys$ = _this3.state.notifys[placement][key], | ||
description = _this3$state$notifys$.description, | ||
isOpen = _this3$state$notifys$.isOpen, | ||
alertProps = (0, _objectWithoutPropertiesLoose2["default"])(_this3$state$notifys$, _excluded); | ||
if (alertProps.type === 'open') { | ||
delete alertProps.type; | ||
if (props && props.willUnmount) { | ||
props.willUnmount(props, notifys); | ||
} | ||
}); | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var _this3 = this; | ||
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactAlert["default"], (0, _extends2["default"])({ | ||
className: prefixCls, | ||
useButton: false, | ||
width: 320 | ||
}, alertProps, { | ||
usePortal: false, | ||
hasBackdrop: false, | ||
isOpen: isOpen, | ||
content: description | ||
}), key); | ||
}) | ||
}); | ||
}; | ||
var prefixCls = this.props.prefixCls; | ||
var placement = this.state.placement; | ||
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react["default"].Fragment, { | ||
children: placement && Object.keys(this.state.notifys[placement]).map(function (key) { | ||
var _this3$state$notifys$ = _this3.state.notifys[placement][key], | ||
description = _this3$state$notifys$.description, | ||
isOpen = _this3$state$notifys$.isOpen, | ||
alertProps = (0, _objectWithoutProperties2["default"])(_this3$state$notifys$, _excluded); | ||
if (alertProps.type === 'open') { | ||
delete alertProps.type; | ||
} | ||
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactAlert["default"], (0, _objectSpread2["default"])((0, _objectSpread2["default"])({ | ||
className: prefixCls, | ||
useButton: false, | ||
width: 320 | ||
}, alertProps), {}, { | ||
usePortal: false, | ||
hasBackdrop: false, | ||
isOpen: isOpen, | ||
content: description | ||
}), key); | ||
}) | ||
}); | ||
} | ||
}]); | ||
return Container; | ||
@@ -131,7 +149,7 @@ }(_react["default"].Component); | ||
exports["default"] = Container; | ||
Container.defaultProps = { | ||
(0, _defineProperty2["default"])(Container, "defaultProps", { | ||
prefixCls: 'w-notify', | ||
placement: 'topRight' | ||
}; | ||
}); | ||
module.exports = exports.default; | ||
//# sourceMappingURL=Container.js.map |
@@ -5,6 +5,8 @@ "use strict"; | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports["default"] = void 0; | ||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2")); | ||
@@ -24,6 +26,4 @@ var _react = _interopRequireDefault(require("react")); | ||
function NotificationCreate(props, type) { | ||
if (type === void 0) { | ||
type = 'open'; | ||
} | ||
function NotificationCreate(props) { | ||
var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'open'; | ||
@@ -85,3 +85,3 @@ if (!props.placement) { | ||
if (notifys[props.placement]) { | ||
notifys[props.placement].create((0, _extends2["default"])({}, props, { | ||
notifys[props.placement].create((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, props), {}, { | ||
duration: props.duration, | ||
@@ -107,7 +107,4 @@ key: (0, _utils.randomid)(), | ||
['open', 'success', 'warning', 'info', 'error'].forEach(function (type) { | ||
NotificationCreate[type] = function (options) { | ||
if (options === void 0) { | ||
options = {}; | ||
} | ||
NotificationCreate[type] = function () { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
return NotificationCreate(options, type); | ||
@@ -114,0 +111,0 @@ }; |
@@ -1,4 +0,3 @@ | ||
import _extends from "@babel/runtime/helpers/esm/extends"; | ||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose"; | ||
import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose"; | ||
import _extends from "@babel/runtime/helpers/extends"; | ||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose"; | ||
var _excluded = ["description", "isOpen"]; | ||
@@ -10,28 +9,16 @@ import React from 'react'; | ||
var timer = {}; | ||
var Container = /*#__PURE__*/function (_React$Component) { | ||
_inheritsLoose(Container, _React$Component); | ||
function Container() { | ||
var _this; | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this; | ||
_this.state = { | ||
export default class Container extends React.Component { | ||
constructor() { | ||
super(...arguments); | ||
this.state = { | ||
notifys: {} | ||
}; | ||
return _this; | ||
} | ||
var _proto = Container.prototype; | ||
create(props) { | ||
var { | ||
placement, | ||
key | ||
} = props; | ||
_proto.create = function create(props) { | ||
var _this2 = this; | ||
var placement = props.placement, | ||
key = props.key; | ||
if (!notifys[placement]) { | ||
@@ -45,4 +32,4 @@ notifys[placement] = {}; | ||
if (props.duration) { | ||
timer[key] = setTimeout(function () { | ||
_this2.closed(key, placement); | ||
timer[key] = setTimeout(() => { | ||
this.closed(key, placement); | ||
}, props.duration); | ||
@@ -52,14 +39,13 @@ } | ||
this.setState({ | ||
notifys: notifys, | ||
placement: placement | ||
}, function () { | ||
notifys, | ||
placement | ||
}, () => { | ||
notifys[placement][key].isOpen = true; | ||
_this2.setState({ | ||
notifys: notifys | ||
this.setState({ | ||
notifys | ||
}); | ||
}); | ||
}; | ||
} | ||
_proto.closed = function closed(key, placement) { | ||
closed(key, placement) { | ||
if (!key || !placement || !notifys[placement][key]) { | ||
@@ -72,4 +58,4 @@ return; | ||
this.setState({ | ||
notifys: notifys | ||
}, function () { | ||
notifys | ||
}, () => { | ||
clearTimeout(timer[key]); | ||
@@ -83,15 +69,19 @@ delete timer[key]; | ||
}); | ||
}; | ||
} | ||
_proto.render = function render() { | ||
var _this3 = this; | ||
var prefixCls = this.props.prefixCls; | ||
var placement = this.state.placement; | ||
render() { | ||
var { | ||
prefixCls | ||
} = this.props; | ||
var { | ||
placement | ||
} = this.state; | ||
return /*#__PURE__*/_jsx(React.Fragment, { | ||
children: placement && Object.keys(this.state.notifys[placement]).map(function (key) { | ||
var _this3$state$notifys$ = _this3.state.notifys[placement][key], | ||
description = _this3$state$notifys$.description, | ||
isOpen = _this3$state$notifys$.isOpen, | ||
alertProps = _objectWithoutPropertiesLoose(_this3$state$notifys$, _excluded); | ||
children: placement && Object.keys(this.state.notifys[placement]).map(key => { | ||
var _this$state$notifys$p = this.state.notifys[placement][key], | ||
{ | ||
description, | ||
isOpen | ||
} = _this$state$notifys$p, | ||
alertProps = _objectWithoutPropertiesLoose(_this$state$notifys$p, _excluded); | ||
@@ -114,7 +104,5 @@ if (alertProps.type === 'open') { | ||
}); | ||
}; | ||
} | ||
return Container; | ||
}(React.Component); | ||
} | ||
Container.defaultProps = { | ||
@@ -124,3 +112,2 @@ prefixCls: 'w-notify', | ||
}; | ||
export { Container as default }; | ||
//# sourceMappingURL=Container.js.map |
@@ -1,2 +0,2 @@ | ||
import _extends from "@babel/runtime/helpers/esm/extends"; | ||
import _extends from "@babel/runtime/helpers/extends"; | ||
import React from 'react'; | ||
@@ -74,3 +74,4 @@ import ReactDOM from 'react-dom'; | ||
key: randomid(), | ||
willUnmount: function willUnmount(nprops, notifysChild) { | ||
willUnmount(nprops, notifysChild) { | ||
if (!nprops) return; | ||
@@ -88,2 +89,3 @@ nprops.onClose && nprops.onClose(); | ||
} | ||
})); | ||
@@ -93,3 +95,3 @@ } | ||
['open', 'success', 'warning', 'info', 'error'].forEach(function (type) { | ||
['open', 'success', 'warning', 'info', 'error'].forEach(type => { | ||
NotificationCreate[type] = function (options) { | ||
@@ -96,0 +98,0 @@ if (options === void 0) { |
{ | ||
"name": "@uiw/react-notify", | ||
"version": "4.9.6", | ||
"version": "4.9.7", | ||
"description": "Notify component", | ||
@@ -47,10 +47,10 @@ "author": "Kenny Wong <wowohoo@qq.com>", | ||
"dependencies": { | ||
"@uiw/react-alert": "^4.9.6", | ||
"@uiw/react-button": "^4.9.6", | ||
"@uiw/react-icon": "^4.9.6", | ||
"@uiw/utils": "^4.9.6" | ||
"@uiw/react-alert": "^4.9.7", | ||
"@uiw/react-button": "^4.9.7", | ||
"@uiw/react-icon": "^4.9.7", | ||
"@uiw/utils": "^4.9.7" | ||
}, | ||
"devDependencies": { | ||
"@babel/runtime": "7.15.3", | ||
"@types/react": "17.0.19", | ||
"@babel/runtime": "7.15.4", | ||
"@types/react": "17.0.20", | ||
"@types/react-dom": "17.0.9", | ||
@@ -57,0 +57,0 @@ "react": "17.0.2", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
66200
0.16%861
1.06%0
-100%Updated
Updated
Updated
Updated