1 |
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Toast=e():t.Toast=e()}(window,function(){return function(t){var e={};function n(o){if(e[o])return e[o].exports;var i=e[o]={i:o,l:!1,exports:{}};return t[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(o,i,function(e){return t[e]}.bind(null,i));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=1)}([,function(t,e,n){"use strict";n.r(e);n(2);e.default=n(6).default},function(t,e,n){var o=n(3);"string"==typeof o&&(o=[[t.i,o,""]]);var i={insert:"head",singleton:!1};n(5)(o,i);o.locals&&(t.exports=o.locals)},function(t,e,n){(t.exports=n(4)(!1)).push([t.i,":root {\n\t--max-width: 250px;\n}\n\nbody {\n\tpadding: 0;\n\tmargin: 0;\n}\n\n#toasts-container {\n\tposition: fixed;\n\theight: 100vh;\n\tdisplay: flex;\n\tflex-direction: column;\n\ttop: 20px;\n\tleft: 20px;\n}\n\n#toasts-container.position-left {\n\tright: 0;\n\tleft: 20px;\n\talign-items: flex-start;\n}\n\n#toasts-container.position-right {\n\tleft: 0;\n\tright: 20px;\n\talign-items: flex-end;\n}\n\n#toasts-container.position-top {\n\tbottom: 0;\n\ttop: 20px;\n\tjustify-content: flex-start;\n}\n\n#toasts-container.position-bottom {\n\ttop: 0;\n\tmargin-top: -20px;\n\tjustify-content: flex-end;\n}\n\n.toast {\n\tuser-select: none;\n\tz-index: 10000 !important;\n\tborder-radius: 2px;\n\tcursor: pointer;\n\tposition: relative;\n\ttop: 0;\n\theight: auto;\n\tbackground-color: #323232;\n\tcolor: #fff;\n\tpadding: 10px 25px;\n\tfont-size: 1rem;\n\tfont-weight: 300;\n\twidth: var(--max-width);\n\tbox-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12);\n}",""])},function(t,e,n){"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map(function(e){var n=function(t,e){var n=t[1]||"",o=t[3];if(!o)return n;if(e&&"function"==typeof btoa){var i=(a=o,s=btoa(unescape(encodeURIComponent(JSON.stringify(a)))),c="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(s),"/*# ".concat(c," */")),r=o.sources.map(function(t){return"/*# sourceURL=".concat(o.sourceRoot).concat(t," */")});return[n].concat(r).concat([i]).join("\n")}var a,s,c;return[n].join("\n")}(e,t);return e[2]?"@media ".concat(e[2],"{").concat(n,"}"):n}).join("")},e.i=function(t,n){"string"==typeof t&&(t=[[null,t,""]]);for(var o={},i=0;i<this.length;i++){var r=this[i][0];null!=r&&(o[r]=!0)}for(var a=0;a<t.length;a++){var s=t[a];null!=s[0]&&o[s[0]]||(n&&!s[2]?s[2]=n:n&&(s[2]="(".concat(s[2],") and (").concat(n,")")),e.push(s))}},e}},function(t,e,n){"use strict";var o,i={},r=function(){return void 0===o&&(o=Boolean(window&&document&&document.all&&!window.atob)),o},a=function(){var t={};return function(e){if(void 0===t[e]){var n=document.querySelector(e);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}t[e]=n}return t[e]}}();function s(t,e){for(var n=[],o={},i=0;i<t.length;i++){var r=t[i],a=e.base?r[0]+e.base:r[0],s={css:r[1],media:r[2],sourceMap:r[3]};o[a]?o[a].parts.push(s):n.push(o[a]={id:a,parts:[s]})}return n}function c(t,e){for(var n=0;n<t.length;n++){var o=t[n],r=i[o.id],a=0;if(r){for(r.refs++;a<r.parts.length;a++)r.parts[a](o.parts[a]);for(;a<o.parts.length;a++)r.parts.push(v(o.parts[a],e))}else{for(var s=[];a<o.parts.length;a++)s.push(v(o.parts[a],e));i[o.id]={id:o.id,refs:1,parts:s}}}}function u(t){var e=document.createElement("style");if(void 0===t.attributes.nonce){var o=n.nc;o&&(t.attributes.nonce=o)}if(Object.keys(t.attributes).forEach(function(n){e.setAttribute(n,t.attributes[n])}),"function"==typeof t.insert)t.insert(e);else{var i=a(t.insert||"head");if(!i)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.appendChild(e)}return e}var l,f=(l=[],function(t,e){return l[t]=e,l.filter(Boolean).join("\n")});function d(t,e,n,o){var i=n?"":o.css;if(t.styleSheet)t.styleSheet.cssText=f(e,i);else{var r=document.createTextNode(i),a=t.childNodes;a[e]&&t.removeChild(a[e]),a.length?t.insertBefore(r,a[e]):t.appendChild(r)}}var p=null,h=0;function v(t,e){var n,o,i;if(e.singleton){var r=h++;n=p||(p=u(e)),o=d.bind(null,n,r,!1),i=d.bind(null,n,r,!0)}else n=u(e),o=function(t,e,n){var o=n.css,i=n.media,r=n.sourceMap;if(i&&t.setAttribute("media",i),r&&btoa&&(o+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),t.styleSheet)t.styleSheet.cssText=o;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(o))}}.bind(null,n,e),i=function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(n)};return o(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap)return;o(t=e)}else i()}}t.exports=function(t,e){(e=e||{}).attributes="object"==typeof e.attributes?e.attributes:{},e.singleton||"boolean"==typeof e.singleton||(e.singleton=r());var n=s(t,e);return c(n,e),function(t){for(var o=[],r=0;r<n.length;r++){var a=n[r],u=i[a.id];u&&(u.refs--,o.push(u))}t&&c(s(t,e),e);for(var l=0;l<o.length;l++){var f=o[l];if(0===f.refs){for(var d=0;d<f.parts.length;d++)f.parts[d]();delete i[f.id]}}}}},function(t,e,n){"use strict";function o(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}n.r(e),n.d(e,"default",function(){return a}),document.body.style.backgroundColor="#eee";var i=document.getElementById("toasts-container");console.log(i);var r=0,a=function(){function t(e){var n=e.content,o=e.persistant,i=e.timeout;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.identifier="toast-".concat(r),r++,this.visible=!1,this.content=n,this.persistant=o,this.timeout=i,this.persistant||this.startTimer(),this.dragListener()}var e,n,a;return e=t,(n=[{key:"startTimer",value:function(){setTimeout(this.clear.bind(this),this.timeout)}},{key:"display",value:function(){this.visible?this.element.innerHTML=this.content:(i.insertAdjacentHTML("beforeend",'<div class="toast '.concat(this.identifier,'">').concat(this.content,"</div>")),this.find()),this.visible=!0}},{key:"dragListener",value:function(){var t=this;this.element.addEventListener("mousedown",function(e){var n=t.element.getBoundingClientRect().x,o=e.clientX-n,i=function(e){var i=e.pageX,r=1.2-Math.abs(i-o-n)/100;if(r<.15)return t.clear();t.element.style.opacity=r,t.element.style.left="".concat(i-o-n,"px")};window.addEventListener("mousemove",i,!1),window.addEventListener("mouseup",function(){window.removeEventListener("mousemove",i,!1)},!1)},!1)}},{key:"find",value:function(){for(var t=0;t<i.childNodes.length;t++)if(i.childNodes[t].classList.contains(this.identifier))return this.element=i.childNodes[t]}},{key:"clear",value:function(){this.element.remove()}},{key:"content",get:function(){return this._content},set:function(t){this._content=t,this.display()}}])&&o(e.prototype,n),a&&o(e,a),t}()}])});
|