@uiw/react-notify
Advanced tools
Comparing version 5.0.0-bate-1 to 5.0.0-bate-10
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"]; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,43 +8,25 @@ value: true | ||
exports["default"] = void 0; | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2")); | ||
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")); | ||
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")); | ||
var _style = require("./style"); | ||
var _jsxRuntime = require("react/jsx-runtime"); | ||
var _excluded = ["description", "isOpen"]; | ||
var notifys = {}; | ||
var timer = {}; | ||
var Container = /*#__PURE__*/function (_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++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this = _super.call.apply(_super, [this].concat(args)); | ||
@@ -57,3 +38,2 @@ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", { | ||
} | ||
(0, _createClass2["default"])(Container, [{ | ||
@@ -63,13 +43,9 @@ key: "create", | ||
var _this2 = this; | ||
var placement = props.placement, | ||
key = props.key; | ||
key = props.key; | ||
if (!notifys[placement]) { | ||
notifys[placement] = {}; | ||
} | ||
props.isOpen = false; | ||
notifys[placement][key] = props; | ||
if (props.duration) { | ||
@@ -80,3 +56,2 @@ timer[key] = setTimeout(function () { | ||
} | ||
this.setState({ | ||
@@ -87,3 +62,2 @@ notifys: notifys, | ||
notifys[placement][key].isOpen = true; | ||
_this2.setState({ | ||
@@ -100,3 +74,2 @@ notifys: notifys | ||
} | ||
notifys[placement][key].isOpen = false; | ||
@@ -110,3 +83,2 @@ var props = notifys[placement][key]; | ||
delete notifys[placement][key]; | ||
if (props && props.willUnmount) { | ||
@@ -121,3 +93,2 @@ props.willUnmount(props, notifys); | ||
var _this3 = this; | ||
var prefixCls = this.props.prefixCls; | ||
@@ -128,10 +99,8 @@ var placement = this.state.placement; | ||
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); | ||
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)(_style.NotifyStyleAlertBase, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({ | ||
@@ -153,3 +122,2 @@ className: prefixCls, | ||
}(_react["default"].Component); | ||
exports["default"] = Container; | ||
@@ -156,0 +124,0 @@ (0, _defineProperty2["default"])(Container, "defaultProps", { |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"]; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,45 +8,43 @@ value: true | ||
exports["default"] = void 0; | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2")); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _reactDom = _interopRequireDefault(require("react-dom")); | ||
var _utils = require("@uiw/utils"); | ||
var _Container = _interopRequireDefault(require("./Container")); | ||
var _CircleCheck = require("@uiw/icons/lib/CircleCheck"); | ||
var _Warning = require("@uiw/icons/lib/Warning"); | ||
var _Information = require("@uiw/icons/lib/Information"); | ||
var _CircleClose = require("@uiw/icons/lib/CircleClose"); | ||
var _reactIcon = require("@uiw/react-icon"); | ||
var _jsxRuntime = require("react/jsx-runtime"); | ||
var notifys = {}; | ||
var notifysDom = {}; | ||
function NotificationCreate(props) { | ||
var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'open'; | ||
if (!props.placement) { | ||
props.placement = 'topRight'; | ||
} | ||
props.type = type; | ||
if (!props.icon && props.icon !== null) { | ||
switch (props.type) { | ||
case 'success': | ||
props.icon = 'circle-check'; | ||
props.icon = /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIcon.IconStyleBase, { | ||
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CircleCheck.CircleCheck, {}) | ||
}); | ||
break; | ||
case 'warning': | ||
props.icon = 'warning'; | ||
props.icon = /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIcon.IconStyleBase, { | ||
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Warning.Warning, {}) | ||
}); | ||
break; | ||
case 'info': | ||
props.icon = 'information'; | ||
props.icon = /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIcon.IconStyleBase, { | ||
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Information.Information, {}) | ||
}); | ||
break; | ||
case 'error': | ||
props.icon = 'circle-close'; | ||
props.icon = /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIcon.IconStyleBase, { | ||
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CircleClose.CircleClose, {}) | ||
}); | ||
break; | ||
default: | ||
@@ -57,3 +54,2 @@ break; | ||
} | ||
switch (props.type) { | ||
@@ -63,11 +59,8 @@ case 'info': | ||
break; | ||
case 'error': | ||
props.type = 'danger'; | ||
break; | ||
default: | ||
break; | ||
} | ||
if (props.placement && !notifys[props.placement]) { | ||
@@ -80,7 +73,5 @@ var div = document.createElement('div'); | ||
} | ||
if (props.duration !== null) { | ||
props.duration = (props.duration || 4.5) * 1000; | ||
} | ||
if (notifys[props.placement]) { | ||
@@ -94,6 +85,4 @@ notifys[props.placement].create((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, props), {}, { | ||
var keys = Object.keys(notifysChild[props.placement]); | ||
if (keys.length === 0 && notifys[props.placement]) { | ||
delete notifys[props.placement]; | ||
if (notifysDom[props.placement]) { | ||
@@ -107,3 +96,2 @@ document.body.removeChild(notifysDom[props.placement]); | ||
} | ||
['open', 'success', 'warning', 'info', 'error'].forEach(function (type) { | ||
@@ -110,0 +98,0 @@ NotificationCreate[type] = function () { |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"]; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"]; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -11,21 +9,11 @@ value: true | ||
exports.NotifyStyleBase = exports.NotifyStyleAlertBase = exports.NotifyGlobalStyle = void 0; | ||
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral")); | ||
var _styledComponents = _interopRequireWildcard(require("styled-components")); | ||
var _reactAlert = _interopRequireDefault(require("@uiw/react-alert")); | ||
var _reactModal = require("@uiw/react-modal"); | ||
var _reactIcon = require("@uiw/react-icon"); | ||
var _reactButton = require("@uiw/react-button"); | ||
var _reactOverlay = require("@uiw/react-overlay"); | ||
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8; | ||
var NotifyStyleBase = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])([""]))); | ||
exports.NotifyStyleBase = NotifyStyleBase; | ||
@@ -32,0 +20,0 @@ var NotifyGlobalStyle = (0, _styledComponents.createGlobalStyle)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n .w-notify-warpper {\n position: fixed;\n padding: 5px;\n z-index: 999;\n &.topLeft {\n top: 0;\n left: 0;\n }\n &.topRight {\n top: 0;\n right: 0;\n }\n &.bottomLeft {\n bottom: 0;\n left: 0;\n }\n &.bottomRight {\n bottom: 0;\n right: 0;\n }\n }\n "]))); |
@@ -17,3 +17,2 @@ import _extends from "@babel/runtime/helpers/extends"; | ||
} | ||
create(props) { | ||
@@ -24,10 +23,7 @@ var { | ||
} = props; | ||
if (!notifys[placement]) { | ||
notifys[placement] = {}; | ||
} | ||
props.isOpen = false; | ||
notifys[placement][key] = props; | ||
if (props.duration) { | ||
@@ -38,3 +34,2 @@ timer[key] = setTimeout(() => { | ||
} | ||
this.setState({ | ||
@@ -50,3 +45,2 @@ notifys, | ||
} | ||
closed(key, placement) { | ||
@@ -56,3 +50,2 @@ if (!key || !placement || !notifys[placement][key]) { | ||
} | ||
notifys[placement][key].isOpen = false; | ||
@@ -66,3 +59,2 @@ var props = notifys[placement][key]; | ||
delete notifys[placement][key]; | ||
if (props && props.willUnmount) { | ||
@@ -73,3 +65,2 @@ props.willUnmount(props, notifys); | ||
} | ||
render() { | ||
@@ -85,12 +76,10 @@ var { | ||
var _this$state$notifys$p = this.state.notifys[placement][key], | ||
{ | ||
description, | ||
isOpen | ||
} = _this$state$notifys$p, | ||
alertProps = _objectWithoutPropertiesLoose(_this$state$notifys$p, _excluded); | ||
{ | ||
description, | ||
isOpen | ||
} = _this$state$notifys$p, | ||
alertProps = _objectWithoutPropertiesLoose(_this$state$notifys$p, _excluded); | ||
if (alertProps.type === 'open') { | ||
delete alertProps.type; | ||
} | ||
return /*#__PURE__*/_jsx(NotifyStyleAlertBase, _extends({ | ||
@@ -109,3 +98,2 @@ className: prefixCls, | ||
} | ||
} | ||
@@ -112,0 +100,0 @@ Container.defaultProps = { |
@@ -6,6 +6,10 @@ import _extends from "@babel/runtime/helpers/extends"; | ||
import Container from './Container'; | ||
import { CircleCheck } from '@uiw/icons/lib/CircleCheck'; | ||
import { Warning } from '@uiw/icons/lib/Warning'; | ||
import { Information } from '@uiw/icons/lib/Information'; | ||
import { CircleClose } from '@uiw/icons/lib/CircleClose'; | ||
import { IconStyleBase } from '@uiw/react-icon'; | ||
import { jsx as _jsx } from "react/jsx-runtime"; | ||
var notifys = {}; | ||
var notifysDom = {}; | ||
function NotificationCreate(props, type) { | ||
@@ -15,27 +19,28 @@ if (type === void 0) { | ||
} | ||
if (!props.placement) { | ||
props.placement = 'topRight'; | ||
} | ||
props.type = type; | ||
if (!props.icon && props.icon !== null) { | ||
switch (props.type) { | ||
case 'success': | ||
props.icon = 'circle-check'; | ||
props.icon = /*#__PURE__*/_jsx(IconStyleBase, { | ||
children: /*#__PURE__*/_jsx(CircleCheck, {}) | ||
}); | ||
break; | ||
case 'warning': | ||
props.icon = 'warning'; | ||
props.icon = /*#__PURE__*/_jsx(IconStyleBase, { | ||
children: /*#__PURE__*/_jsx(Warning, {}) | ||
}); | ||
break; | ||
case 'info': | ||
props.icon = 'information'; | ||
props.icon = /*#__PURE__*/_jsx(IconStyleBase, { | ||
children: /*#__PURE__*/_jsx(Information, {}) | ||
}); | ||
break; | ||
case 'error': | ||
props.icon = 'circle-close'; | ||
props.icon = /*#__PURE__*/_jsx(IconStyleBase, { | ||
children: /*#__PURE__*/_jsx(CircleClose, {}) | ||
}); | ||
break; | ||
default: | ||
@@ -45,3 +50,2 @@ break; | ||
} | ||
switch (props.type) { | ||
@@ -51,11 +55,8 @@ case 'info': | ||
break; | ||
case 'error': | ||
props.type = 'danger'; | ||
break; | ||
default: | ||
break; | ||
} | ||
if (props.placement && !notifys[props.placement]) { | ||
@@ -68,7 +69,5 @@ var div = document.createElement('div'); | ||
} | ||
if (props.duration !== null) { | ||
props.duration = (props.duration || 4.5) * 1000; | ||
} | ||
if (notifys[props.placement]) { | ||
@@ -78,3 +77,2 @@ notifys[props.placement].create(_extends({}, props, { | ||
key: randomid(), | ||
willUnmount(nprops, notifysChild) { | ||
@@ -84,6 +82,4 @@ if (!nprops) return; | ||
var keys = Object.keys(notifysChild[props.placement]); | ||
if (keys.length === 0 && notifys[props.placement]) { | ||
delete notifys[props.placement]; | ||
if (notifysDom[props.placement]) { | ||
@@ -94,7 +90,5 @@ document.body.removeChild(notifysDom[props.placement]); | ||
} | ||
})); | ||
} | ||
} | ||
['open', 'success', 'warning', 'info', 'error'].forEach(type => { | ||
@@ -105,3 +99,2 @@ NotificationCreate[type] = function (options) { | ||
} | ||
return NotificationCreate(options, type); | ||
@@ -108,0 +101,0 @@ }; |
import _taggedTemplateLiteralLoose from "@babel/runtime/helpers/taggedTemplateLiteralLoose"; | ||
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8; | ||
import styled, { createGlobalStyle, css } from 'styled-components'; | ||
@@ -6,0 +4,0 @@ import Alert from '@uiw/react-alert'; |
{ | ||
"name": "@uiw/react-notify", | ||
"version": "5.0.0-bate-1", | ||
"version": "5.0.0-bate-10", | ||
"description": "Notify component", | ||
@@ -48,9 +48,9 @@ "author": "Kenny Wong <wowohoo@qq.com>", | ||
"dependencies": { | ||
"@uiw/react-alert": "^5.0.0-bate-1", | ||
"@uiw/react-button": "^5.0.0-bate-1", | ||
"@uiw/react-icon": "^5.0.0-bate-1", | ||
"@uiw/react-modal": "^5.0.0-bate-1", | ||
"@uiw/react-overlay": "^5.0.0-bate-1", | ||
"@uiw/utils": "^5.0.0-bate-1" | ||
"@uiw/react-alert": "^5.0.0-bate-10", | ||
"@uiw/react-button": "^5.0.0-bate-10", | ||
"@uiw/react-icon": "^5.0.0-bate-10", | ||
"@uiw/react-modal": "^5.0.0-bate-10", | ||
"@uiw/react-overlay": "^5.0.0-bate-10", | ||
"@uiw/utils": "^5.0.0-bate-10" | ||
} | ||
} |
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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
79958
907