Skip to content

Commit c6f5c07

Browse files
committed
refactor: keep dist
1 parent ba0a11b commit c6f5c07

1 file changed

Lines changed: 257 additions & 0 deletions

File tree

dist/index.js

Lines changed: 257 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,257 @@
1+
"use strict";
2+
3+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4+
5+
Object.defineProperty(exports, "__esModule", {
6+
value: true
7+
});
8+
exports["default"] = void 0;
9+
10+
var _react = _interopRequireDefault(require("react"));
11+
12+
var _reactstrap = require("reactstrap");
13+
14+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15+
16+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
17+
18+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
19+
20+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
21+
22+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
23+
24+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
25+
26+
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); }; }
27+
28+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
29+
30+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
31+
32+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
33+
34+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
35+
36+
var NotificationAlert = /*#__PURE__*/function (_React$Component) {
37+
_inherits(NotificationAlert, _React$Component);
38+
39+
var _super = _createSuper(NotificationAlert);
40+
41+
function NotificationAlert(props) {
42+
var _this;
43+
44+
_classCallCheck(this, NotificationAlert);
45+
46+
_this = _super.call(this, props);
47+
_this.state = {
48+
notifyTL: [],
49+
notifyTC: [],
50+
notifyTR: [],
51+
notifyBL: [],
52+
notifyBC: [],
53+
notifyBR: [],
54+
notifyID: []
55+
};
56+
_this.onDismiss = _this.onDismiss.bind(_assertThisInitialized(_this));
57+
_this.notificationAlert = _this.notificationAlert.bind(_assertThisInitialized(_this));
58+
_this.refNotification = /*#__PURE__*/_react["default"].createRef();
59+
return _this;
60+
} // to stop the warning of calling setState of unmounted component
61+
62+
63+
_createClass(NotificationAlert, [{
64+
key: "componentWillUnmount",
65+
value: function componentWillUnmount() {
66+
for (var i = 0; i < this.state.notifyID.length; i++) {
67+
window.clearTimeout(this.state.notifyID[i]);
68+
}
69+
}
70+
}, {
71+
key: "onDismiss",
72+
value: function onDismiss(nNumber, place, noAnimate) {
73+
var notify = [];
74+
var sNotify = this.state["notify" + place.toUpperCase()];
75+
var dNotify;
76+
77+
for (var i = 0; i < sNotify.length; i++) {
78+
if (sNotify[i].key !== nNumber + "") {
79+
if (sNotify[i].props.className.indexOf("fadeOutUp") !== -1) {
80+
dNotify = /*#__PURE__*/_react["default"].cloneElement(sNotify[i]);
81+
} else {
82+
if (noAnimate === undefined) {
83+
var animation;
84+
85+
if (place.indexOf("b") !== -1) {
86+
animation = sNotify[i].key > nNumber + "" ? " animated moveDown" : "";
87+
} else {
88+
animation = sNotify[i].key > nNumber + "" ? " animated moveUp" : "";
89+
}
90+
91+
dNotify = /*#__PURE__*/_react["default"].cloneElement(sNotify[i], {
92+
className: "alert-with-icon" + animation
93+
});
94+
} else {
95+
dNotify = /*#__PURE__*/_react["default"].cloneElement(sNotify[i], {
96+
className: "alert-with-icon"
97+
});
98+
}
99+
}
100+
101+
notify.push(dNotify);
102+
} else {
103+
if (noAnimate === undefined) {
104+
dNotify = /*#__PURE__*/_react["default"].cloneElement(sNotify[i], {
105+
className: "alert-with-icon animated fadeOutUp"
106+
});
107+
notify.push(dNotify);
108+
}
109+
}
110+
}
111+
112+
if (noAnimate === undefined) {
113+
var id = setTimeout(function () {
114+
this.onDismiss(nNumber, place, "noAnimate");
115+
}.bind(this), 800);
116+
this.setState({
117+
notifyID: [id].concat(this.state.notifyID)
118+
});
119+
}
120+
121+
sNotify = {};
122+
sNotify["notify" + place.toUpperCase()] = notify;
123+
this.setState(sNotify);
124+
}
125+
}, {
126+
key: "notificationAlert",
127+
value: function notificationAlert(options) {
128+
var _this2 = this;
129+
130+
var notify = this.state["notify" + options.place.toUpperCase()];
131+
var nNumber = notify.length;
132+
133+
if (notify.length > 0) {
134+
if (options.place.indexOf("b") !== -1) {
135+
nNumber = parseInt(notify[0].key, 10) + 1;
136+
} else {
137+
nNumber = parseInt(notify[notify.length - 1].key, 10) + 1;
138+
}
139+
}
140+
141+
var toggle;
142+
143+
if (options.closeButton !== false) {
144+
toggle = function toggle() {
145+
return _this2.onDismiss(nNumber, options.place);
146+
};
147+
}
148+
149+
var notification = /*#__PURE__*/_react["default"].createElement(_reactstrap.Alert, {
150+
color: options.type,
151+
className: "alert-with-icon animated fadeInDown",
152+
toggle: toggle,
153+
key: nNumber
154+
}, options.icon !== undefined ? /*#__PURE__*/_react["default"].createElement("span", {
155+
"data-notify": "icon",
156+
className: options.icon
157+
}) : null, /*#__PURE__*/_react["default"].createElement("span", {
158+
"data-notify": "message"
159+
}, options.message));
160+
161+
if (options.place.indexOf("b") !== -1) {
162+
notify.unshift(notification);
163+
} else {
164+
notify.push(notification);
165+
}
166+
167+
var sNotify = {};
168+
sNotify["notify" + options.place.toUpperCase()] = notify; // aici pui notify[notify.length-1].key
169+
170+
if (options.autoDismiss > 0) {
171+
var id = setTimeout(function () {
172+
this.onDismiss(nNumber, options.place);
173+
}.bind(this), options.autoDismiss * 1000 + (notify.length - 1) * 1000);
174+
this.setState({
175+
notifyID: [id].concat(this.state.notifyID)
176+
});
177+
}
178+
179+
this.setState(sNotify);
180+
}
181+
}, {
182+
key: "showAllNotifications",
183+
value: function showAllNotifications(place) {
184+
if (this.state["notify" + place.toUpperCase()].length > 0) {
185+
var style = {
186+
display: "inline-block",
187+
margin: "0px auto",
188+
position: "fixed",
189+
transition: "all 0.5s ease-in-out",
190+
zIndex: "1031"
191+
};
192+
193+
if (place.indexOf("t") !== -1) {
194+
style["top"] = "20px";
195+
196+
switch (place) {
197+
case "tl":
198+
style["left"] = "20px";
199+
break;
200+
201+
case "tc":
202+
style["left"] = "0px";
203+
style["right"] = "0px";
204+
break;
205+
206+
case "tr":
207+
style["right"] = "20px";
208+
break;
209+
210+
default:
211+
break;
212+
}
213+
} else {
214+
style["bottom"] = "20px";
215+
216+
switch (place) {
217+
case "bl":
218+
style["left"] = "20px";
219+
break;
220+
221+
case "bc":
222+
style["left"] = "0px";
223+
style["right"] = "0px";
224+
break;
225+
226+
case "br":
227+
style["right"] = "20px";
228+
break;
229+
230+
default:
231+
break;
232+
}
233+
}
234+
235+
return /*#__PURE__*/_react["default"].createElement(_reactstrap.Col, {
236+
xs: 11,
237+
sm: 4,
238+
style: style
239+
}, this.state["notify" + place.toUpperCase()].map(function (prop, key) {
240+
return prop;
241+
}));
242+
}
243+
}
244+
}, {
245+
key: "render",
246+
value: function render() {
247+
return /*#__PURE__*/_react["default"].createElement("div", {
248+
ref: this.refNotification
249+
}, this.showAllNotifications("tl"), this.showAllNotifications("tc"), this.showAllNotifications("tr"), this.showAllNotifications("bl"), this.showAllNotifications("bc"), this.showAllNotifications("br"));
250+
}
251+
}]);
252+
253+
return NotificationAlert;
254+
}(_react["default"].Component);
255+
256+
var _default = NotificationAlert;
257+
exports["default"] = _default;

0 commit comments

Comments
 (0)