Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

toasters

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

toasters - npm Package Compare versions

Comparing version 2.2.3 to 2.3.0

2

dist/toasters.js

@@ -1,1 +0,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(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},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 i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(i,o,function(e){return t[e]}.bind(null,o));return i},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 i=n(3),o=n(4);"string"==typeof(o=o.__esModule?o.default:o)&&(o=[[t.i,o,""]]);var r={insert:"head",singleton:!1};i(o,r);t.exports=o.locals||{}},function(t,e,n){"use strict";var i,o=function(){return void 0===i&&(i=Boolean(window&&document&&document.all&&!window.atob)),i},r=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]}}(),s=[];function a(t){for(var e=-1,n=0;n<s.length;n++)if(s[n].identifier===t){e=n;break}return e}function c(t,e){for(var n={},i=[],o=0;o<t.length;o++){var r=t[o],c=e.base?r[0]+e.base:r[0],l=n[c]||0,u="".concat(c," ").concat(l);n[c]=l+1;var f=a(u),d={css:r[1],media:r[2],sourceMap:r[3]};-1!==f?(s[f].references++,s[f].updater(d)):s.push({identifier:u,updater:v(d,e),references:1}),i.push(u)}return i}function l(t){var e=document.createElement("style"),i=t.attributes||{};if(void 0===i.nonce){var o=n.nc;o&&(i.nonce=o)}if(Object.keys(i).forEach((function(t){e.setAttribute(t,i[t])})),"function"==typeof t.insert)t.insert(e);else{var s=r(t.insert||"head");if(!s)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");s.appendChild(e)}return e}var u,f=(u=[],function(t,e){return u[t]=e,u.filter(Boolean).join("\n")});function d(t,e,n,i){var o=n?"":i.media?"@media ".concat(i.media," {").concat(i.css,"}"):i.css;if(t.styleSheet)t.styleSheet.cssText=f(e,o);else{var r=document.createTextNode(o),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 i=n.css,o=n.media,r=n.sourceMap;if(o?t.setAttribute("media",o):t.removeAttribute("media"),r&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),t.styleSheet)t.styleSheet.cssText=i;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(i))}}var h=null,m=0;function v(t,e){var n,i,o;if(e.singleton){var r=m++;n=h||(h=l(e)),i=d.bind(null,n,r,!1),o=d.bind(null,n,r,!0)}else n=l(e),i=p.bind(null,n,e),o=function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(n)};return i(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap)return;i(t=e)}else o()}}t.exports=function(t,e){(e=e||{}).singleton||"boolean"==typeof e.singleton||(e.singleton=o());var n=c(t=t||[],e);return function(t){if(t=t||[],"[object Array]"===Object.prototype.toString.call(t)){for(var i=0;i<n.length;i++){var o=a(n[i]);s[o].references--}for(var r=c(t,e),l=0;l<n.length;l++){var u=a(n[l]);0===s[u].references&&(s[u].updater(),s.splice(u,1))}n=r}}}},function(t,e,n){(e=n(5)(!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.night-mode .toast {\n\tbackground-color: rgb(51, 51, 51) !important;\n\tcolor: #fff !important;\n\tborder: 0 !important;\n}\n\n.toast {\n\tdisplay: flex;\n justify-content: space-between;\n\talign-items: unset;\n\tuser-select: none;\n\tz-index: 10000 !important;\n\tcursor: pointer;\n\ttop: 0;\n\theight: auto;\n\tpadding: 10px 10px 10px 25px;\n\tfont-size: 1rem;\n\tfont-weight: 300;\n\twidth: var(--max-width);\n\tposition: relative;\n border: 1px solid rgb(195, 193, 195);\n box-shadow: 0 14px 28px rgb(0 0 0 / 25%), 0 10px 10px rgb(0 0 0 / 22%);\n background-color: #fff;\n\tborder-radius: .25rem;\n line-height: 1.4;\n\tfont-family: sans-serif;\n}\n\n.toast:not(:first-of-type) {\n\tmargin-top: 5px;\n}\n\n\n.close-icon {\n\tmin-width: 8px;\n\theight: 8px;\n\tpadding: 8px;\n\tposition: relative;\n\tmargin-left: 5px;\n\topacity: 0.6;\n\tborder-radius: 100%;\n\tbackground-color: rgb(34, 34, 34);\n}\n\n.close-icon:hover {\n\topacity: 1;\n}\n\n.close-icon:before, .close-icon:after {\n\tposition: absolute;\n\tleft: 11px;\n\tcontent: ' ';\n\theight: 8px;\n\twidth: 2px;\n\tbackground-color: rgb(245, 245, 245);\n}\n\n.close-icon:before {\n\ttransform: rotate(45deg);\n}\n\n.close-icon:after {\n\ttransform: rotate(-45deg);\n}\n",""]),t.exports=e},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]||"",i=t[3];if(!i)return n;if(e&&"function"==typeof btoa){var o=(s=i,a=btoa(unescape(encodeURIComponent(JSON.stringify(s)))),c="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(a),"/*# ".concat(c," */")),r=i.sources.map((function(t){return"/*# sourceURL=".concat(i.sourceRoot||"").concat(t," */")}));return[n].concat(r).concat([o]).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,i){"string"==typeof t&&(t=[[null,t,""]]);var o={};if(i)for(var r=0;r<this.length;r++){var s=this[r][0];null!=s&&(o[s]=!0)}for(var a=0;a<t.length;a++){var c=[].concat(t[a]);i&&o[c[0]]||(n&&(c[2]?c[2]="".concat(n," and ").concat(c[2]):c[2]=n),e.push(c))}},e}},function(t,e,n){"use strict";function i(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}n.r(e),n.d(e,"default",(function(){return s}));var o=document.getElementById("toasts-content"),r=0,s=function(){function t(e){var n=e.content,i=e.persistent,o=e.interactable,s=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.persistent=void 0!==i&&i,this.timeout=s||6e3,this.interactable=void 0===o||o,this.content=n,this.persistent||this.startTimer(),this.interactable&&this.dragListener()}var e,n,s;return e=t,(n=[{key:"content",get:function(){return this._content},set:function(t){var e=this;if(this._content=t,this.visible?this.element.innerHTML=this.content:(o.insertAdjacentHTML("beforeend",'<div class="toast '.concat(this.identifier,'">').concat(this.content,"</div>")),this.find()),this.interactable){var n=document.createElement("span");n.classList.add("close-icon"),this.element.appendChild(n),this.element.children[0].addEventListener("click",(function(){return e.destroy()}),!1)}this.visible=!0}},{key:"startTimer",value:function(){setTimeout(this.destroy.bind(this),this.timeout)}},{key:"dragListener",value:function(){var t=this;this.element.addEventListener("mousedown",(function(e){var n=t.element.getBoundingClientRect().x,i=e.clientX-n,o=function(e){var o=e.pageX,r=1.2-Math.abs(o-i-n)/100;t.element.style.opacity=r,t.element.style.left="".concat(o-i-n,"px")};window.addEventListener("mousemove",o,!1),window.addEventListener("mouseup",(function(){t.handleInputLoss(),window.removeEventListener("mousemove",o,!1)}),!1)}),!1),this.element.addEventListener("touchstart",(function(e){var n=t.element.getBoundingClientRect().x,i=e.touches[0].clientX-n,o=function(e){var o=e.touches;if(1===o.length){var r=o[0].pageX,s=1.2-Math.abs(r-i-n)/100;t.element.style.opacity=s,t.element.style.left="".concat(r-i-n,"px")}};window.addEventListener("touchmove",o,!1),window.addEventListener("touchend",(function(){t.handleInputLoss(),window.removeEventListener("touchmove",o,!1)}),!1)}),!1)}},{key:"handleInputLoss",value:function(){var t=this;if(this.element.style.opacity&&this.element.style.opacity<.15)return this.destroy();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<o.childNodes.length;t++)if(o.childNodes[t].classList.contains(this.identifier))return this.element=o.childNodes[t]}},{key:"destroy",value:function(){this.element.remove()}},{key:"show",value:function(){this.visible||(this.element.style.display="block",this.visible=!0)}},{key:"hide",value:function(){this.visible&&(this.element.style.display="none",this.visible=!1)}}])&&i(e.prototype,n),s&&i(e,s),t}()}])}));
!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),i=n(4);"string"==typeof(i=i.__esModule?i.default:i)&&(i=[[t.i,i,""]]);var r={insert:"head",singleton:!1};o(i,r);t.exports=i.locals||{}},function(t,e,n){"use strict";var o,i=function(){return void 0===o&&(o=Boolean(window&&document&&document.all&&!window.atob)),o},r=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]}}(),s=[];function a(t){for(var e=-1,n=0;n<s.length;n++)if(s[n].identifier===t){e=n;break}return e}function c(t,e){for(var n={},o=[],i=0;i<t.length;i++){var r=t[i],c=e.base?r[0]+e.base:r[0],l=n[c]||0,u="".concat(c," ").concat(l);n[c]=l+1;var f=a(u),d={css:r[1],media:r[2],sourceMap:r[3]};-1!==f?(s[f].references++,s[f].updater(d)):s.push({identifier:u,updater:m(d,e),references:1}),o.push(u)}return o}function l(t){var e=document.createElement("style"),o=t.attributes||{};if(void 0===o.nonce){var i=n.nc;i&&(o.nonce=i)}if(Object.keys(o).forEach((function(t){e.setAttribute(t,o[t])})),"function"==typeof t.insert)t.insert(e);else{var s=r(t.insert||"head");if(!s)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");s.appendChild(e)}return e}var u,f=(u=[],function(t,e){return u[t]=e,u.filter(Boolean).join("\n")});function d(t,e,n,o){var i=n?"":o.media?"@media ".concat(o.media," {").concat(o.css,"}"):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):t.removeAttribute("media"),r&&"undefined"!=typeof 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=l(e)),o=d.bind(null,n,r,!1),i=d.bind(null,n,r,!0)}else n=l(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||{}).singleton||"boolean"==typeof e.singleton||(e.singleton=i());var n=c(t=t||[],e);return function(t){if(t=t||[],"[object Array]"===Object.prototype.toString.call(t)){for(var o=0;o<n.length;o++){var i=a(n[o]);s[i].references--}for(var r=c(t,e),l=0;l<n.length;l++){var u=a(n[l]);0===s[u].references&&(s[u].updater(),s.splice(u,1))}n=r}}}},function(t,e,n){(e=n(5)(!1)).push([t.i,":root {\n\t--max-width: 250px;\n}\n\nbody, * {\n\tpadding: 0;\n\tmargin: 0;\n\tbox-sizing: border-box;\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.night-mode .toast {\n\tbackground-color: rgb(51, 51, 51) !important;\n\tcolor: #fff !important;\n\tborder: 0 !important;\n}\n\n.toast {\n\tdisplay: flex;\n justify-content: space-between;\n\talign-items: unset;\n\tuser-select: none;\n\tz-index: 10000 !important;\n\tcursor: pointer;\n\ttop: 0;\n\theight: auto;\n\tpadding: 10px 25px 10px 25px;\n\tfont-size: 1rem;\n\tfont-weight: 300;\n\twidth: var(--max-width);\n\tposition: relative;\n border: 1px solid rgb(195, 193, 195);\n box-shadow: 0 14px 28px rgb(0 0 0 / 25%), 0 10px 10px rgb(0 0 0 / 22%);\n background-color: #fff;\n\tborder-radius: .25rem;\n line-height: 1.4;\n\tfont-family: sans-serif;\n}\n\n.toast * {\n\tbox-sizing: border-box;\n}\n\n.toast:not(:first-of-type) {\n\tmargin-top: 5px;\n}\n\n.close-icon {\n\tmin-width: 10px;\n\theight: 10px;\n\tpadding: 10px;\n\tposition: relative;\n\tmargin-left: 5px;\n\tmargin-right: -15px;\n\topacity: 0.6;\n\tborder-radius: 100%;\n\tbackground-color: rgb(34, 34, 34);\n}\n\n.close-icon:hover {\n\topacity: 1;\n}\n\n.close-icon:before, .close-icon:after {\n\tposition: absolute;\n\tleft: 9.25px;\n top: 5px;\n\tcontent: ' ';\n\theight: 10px;\n\twidth: 2px;\n\tbackground-color: rgb(245, 245, 245);\n}\n\n.close-icon:before {\n\ttransform: rotate(45deg);\n}\n\n.close-icon:after {\n\ttransform: rotate(-45deg);\n}\n",""]),t.exports=e},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,o){"string"==typeof t&&(t=[[null,t,""]]);var i={};if(o)for(var r=0;r<this.length;r++){var s=this[r][0];null!=s&&(i[s]=!0)}for(var a=0;a<t.length;a++){var c=[].concat(t[a]);o&&i[c[0]]||(n&&(c[2]?c[2]="".concat(n," and ").concat(c[2]):c[2]=n),e.push(c))}},e}},function(t,e,n){"use strict";function o(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,o)}return n}function i(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?o(Object(n),!0).forEach((function(e){r(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function s(t){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function c(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 f}));var l=document.getElementById("toasts-content"),u=0,f=function(){function t(){a(this,t);var e={};"object"===s(arguments.length<=0?void 0:arguments[0])?e=arguments.length<=0?void 0:arguments[0]:"string"==typeof(arguments.length<=0?void 0:arguments[0])&&"object"===s(arguments.length<=1?void 0:arguments[1])?e=i(i({},arguments.length<=1?void 0:arguments[1]),{},{content:arguments.length<=0?void 0:arguments[0]}):"string"==typeof(arguments.length<=0?void 0:arguments[0])&&(e.content=arguments.length<=0?void 0:arguments[0]),this.identifier="toast-".concat(u),u++,this.persistent=void 0!==e.persistent&&e.persistent,this.timeout=e.timeout?e.timeout:6e3,this.interactable=void 0===e.interactable||e.interactable,this.content=e.content,this.visible=void 0===e.visible||e.visible,this.persistent||this.startTimer(),this.interactable&&this.dragListener()}var e,n,o;return e=t,(n=[{key:"visible",get:function(){return this._visible},set:function(t){this._visible=t,this.visible?this.show():this.hide()}},{key:"content",get:function(){return this._content},set:function(t){var e=this;if(this._content=t,this.visible?this.element.innerHTML=this.content:(l.insertAdjacentHTML("beforeend",'<div class="toast '.concat(this.identifier,'">').concat(this.content,"</div>")),this.find()),this.interactable){var n=document.createElement("span");n.classList.add("close-icon"),this.element.appendChild(n),this.element.children[0].addEventListener("click",(function(){return e.destroy()}),!1)}}},{key:"startTimer",value:function(){setTimeout(this.destroy.bind(this),this.timeout)}},{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&&this.element.style.opacity<.15)return this.destroy();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<l.childNodes.length;t++)if(l.childNodes[t].classList.contains(this.identifier))return this.element=l.childNodes[t]}},{key:"destroy",value:function(){this.element.remove()}},{key:"show",value:function(){this.element.style.display="flex",this.visible||(this.visible=!0)}},{key:"hide",value:function(){this.element.style.display="none",this.visible&&(this.visible=!1)}}])&&c(e.prototype,n),o&&c(e,o),t}()}])}));
import Toast from "../dist/toasters.js";
const TestNotification = new Toast({
content: "persistent",
// const TestNotification = new Toast({
// content: "persistent",
// persistent: true,
// interactable: false
// });
const TestNotification1 = new Toast("Hello world 1 asdsad asds", { persistent: true });
const TestNotification2 = new Toast({
content: "Hello World test 2",
persistent: true,

@@ -9,10 +18,2 @@ interactable: false

// const TestNotification2 = new Toast({
// content: "2",
// persistent: true,
// interactable: true
// });
// TestNotification2.hide();
// setTimeout(() => {

@@ -22,6 +23,8 @@ // TestNotification2.show();

const TestNotification3 = new Toast({
content: "lorem ispum lorem hello my name is lorem ispum lorem ispum lorem ispum lorem ispum ",
interactable: true
});
// setTimeout(() => {
// TestNotification2.visible = false;
// }, 4000);
const TestNotification3 = new Toast("lorem ispum lorem hello lorem ispum lorem ispum lorem ispum lorem ispum ", { interactable: false });

@@ -27,3 +27,3 @@ {

},
"version": "2.2.3"
"version": "2.3.0"
}

@@ -26,9 +26,13 @@ # toasters

new Toast(options);
// example
new Toast({
content: "Hello World",
persistent: true
interactable: false
});
// or
new Toast("Hello World");
// or
new Toast("Hello World", { persistent: true, timeout: 9000 });
```

@@ -48,2 +52,3 @@

| **`timeout`** | Number | `6000` | How long till the toast disappears. *Note: will be ignored if the toast is persistent.* |
| **`visible`** | Boolean | `true` | If the toast will be visible when instantiated. |

@@ -50,0 +55,0 @@ ## Potential future additions

@@ -7,13 +7,19 @@ const container = document.getElementById("toasts-content");

// should add type checking
constructor({ content, persistent, interactable, timeout }) {
constructor(...args) {
let options = {};
if (typeof args[0] === "object") options = args[0];
else if (typeof args[0] === "string" && typeof args[1] === "object") options = { ...args[1], content: args[0] };
else if (typeof args[0] === "string") options.content = args[0];
this.identifier = `toast-${incrementer}`;
incrementer++;
this.visible = false;
this.persistent = options.persistent !== undefined ? options.persistent : false;
this.timeout = options.timeout ? options.timeout : 6000;
this.interactable = options.interactable !== undefined ? options.interactable : true;
this.persistent = persistent !== undefined ? persistent : false;
this.timeout = timeout ? timeout : 6000;
this.interactable = interactable !== undefined ? interactable : true;
this.content = options.content;
this.content = content;
this.visible = options.visible !== undefined ? options.visible : true;

@@ -25,2 +31,13 @@ if (!this.persistent) this.startTimer();

get visible() {
return this._visible;
}
set visible(value) {
this._visible = value;
if (!this.visible) this.hide();
else this.show();
}
get content() {

@@ -50,4 +67,2 @@ return this._content;

}
this.visible = true;
}

@@ -127,14 +142,10 @@

show() {
if (!this.visible) {
this.element.style.display = "block";
this.visible = true;
}
this.element.style.display = "flex";
if (!this.visible) this.visible = true;
}
hide() {
if (this.visible) {
this.element.style.display = "none";
this.visible = false;
}
this.element.style.display = "none";
if (this.visible) this.visible = false;
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc