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\ttop: 20px;\n\tright: 20px;\n}\n\n#toasts-content {\n\tdisplay: flex;\n\tflex-direction: column;\n}\n\n#toasts-container.position-left {\n\tright: unset;\n\tleft: 20px;\n\talign-items: flex-start;\n}\n\n#toasts-container.position-right {\n\tleft: unset;\n\tright: 20px;\n\talign-items: flex-end;\n}\n\n#toasts-container.position-top {\n\tbottom: unset;\n\ttop: 20px;\n\tjustify-content: flex-start;\n}\n\n#toasts-container.position-bottom {\n\ttop: unset;\n\tbottom: 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}\n\n.toast:not(:first-of-type) {\n\tmargin-top: 5px;\n}\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=(s=o,a=btoa(unescape(encodeURIComponent(JSON.stringify(s)))),c="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(a),"/*# ".concat(c," */")),r=o.sources.map((function(t){return"/*# sourceURL=".concat(o.sourceRoot).concat(t," */")}));return[n].concat(r).concat([i]).join("\n")}var s,a,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 s=0;s<t.length;s++){var a=t[s];null!=a[0]&&o[a[0]]||(n&&!a[2]?a[2]=n:n&&(a[2]="(".concat(a[2],") and (").concat(n,")")),e.push(a))}},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},s=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 a(t,e){for(var n=[],o={},i=0;i<t.length;i++){var r=t[i],s=e.base?r[0]+e.base:r[0],a={css:r[1],media:r[2],sourceMap:r[3]};o[s]?o[s].parts.push(a):n.push(o[s]={id:s,parts:[a]})}return n}function c(t,e){for(var n=0;n<t.length;n++){var o=t[n],r=i[o.id],s=0;if(r){for(r.refs++;s<r.parts.length;s++)r.parts[s](o.parts[s]);for(;s<o.parts.length;s++)r.parts.push(m(o.parts[s],e))}else{for(var a=[];s<o.parts.length;s++)a.push(m(o.parts[s],e));i[o.id]={id:o.id,refs:1,parts:a}}}}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=s(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),s=t.childNodes;s[e]&&t.removeChild(s[e]),s.length?t.insertBefore(r,s[e]):t.appendChild(r)}}function p(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))}}var h=null,v=0;function m(t,e){var n,o,i;if(e.singleton){var r=v++;n=h||(h=u(e)),o=d.bind(null,n,r,!1),i=d.bind(null,n,r,!0)}else n=u(e),o=p.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=a(t,e);return c(n,e),function(t){for(var o=[],r=0;r<n.length;r++){var s=n[r],u=i[s.id];u&&(u.refs--,o.push(u))}t&&c(a(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 s})),document.body.style.backgroundColor="#eee";var i=document.getElementById("toasts-content"),r=0,s=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,s;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;t.element.style.opacity=r,t.element.style.left="".concat(i-o-n,"px")};window.addEventListener("mousemove",i,!1),window.addEventListener("mouseup",(function(){t.handleInputLoss(),window.removeEventListener("mousemove",i,!1)}),!1)}),!1),this.element.addEventListener("touchstart",(function(e){var n=t.element.getBoundingClientRect().x,o=e.touches[0].clientX-n,i=function(e){var i=e.touches;if(1===i.length){var r=i[0].pageX,s=1.2-Math.abs(r-o-n)/100;t.element.style.opacity=s,t.element.style.left="".concat(r-o-n,"px")}};window.addEventListener("touchmove",i,!1),window.addEventListener("touchend",(function(){t.handleInputLoss(),window.removeEventListener("touchmove",i,!1)}),!1)}),!1)}},{key:"handleInputLoss",value:function(){var t=this;if(this.element.style.opacity<.15)return this.clear();this.element.style.opacity=1,this.element.style.left=0,this.element.style.transition="opacity .2s linear, left .2s linear",setTimeout((function(){t.element.style.transition=null}),200)}},{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),s&&o(e,s),t}()}])}));
|