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

toast-me

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

toast-me - npm Package Compare versions

Comparing version 1.2.4 to 1.3.0

CHANGELOG.md

2

jest.config.js

@@ -18,3 +18,3 @@ const chalk = require('chalk');

],
testEnvironment: 'node',
testEnvironment: 'jsdom',
testURL: 'http://localhost',

@@ -21,0 +21,0 @@ transform: {

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("toast-me",[],e):"object"==typeof exports?exports["toast-me"]=e():t["toast-me"]=e()}("undefined"!=typeof self?self:this,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=5)}([function(t,e,n){var o=n(1);"string"==typeof o&&(o=[[t.i,o,""]]);var i={hmr:!0,transform:void 0,insertInto:void 0};n(3)(o,i);o.locals&&(t.exports=o.locals)},function(t,e,n){(e=t.exports=n(2)(!1)).push([t.i,'.index__toast___233-Y{height:48px;width:40%;min-width:270px;padding:0 15px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:stretch;justify-content:stretch;background-color:rgba(0,0,0,.9);border-radius:4px;left:50%;-ms-flex-negative:0;flex-shrink:0}.index__toast___233-Y.index__error___38eWT{background-color:#d40d00}.index__container___1eyTh{position:fixed;width:100%;height:0;color:#fff}.index__container___1eyTh.index__chain___2Fk0I{display:-ms-flexbox;display:flex;-ms-flex-pack:end;justify-content:flex-end;-ms-flex-align:center;align-items:center}.index__container___1eyTh.index__chain___2Fk0I.index__top___7QDtU{-ms-flex-direction:column-reverse;flex-direction:column-reverse}.index__container___1eyTh.index__chain___2Fk0I.index__bottom___1F1B5{-ms-flex-direction:column;flex-direction:column}.index__container___1eyTh.index__top___7QDtU{top:0}.index__container___1eyTh.index__bottom___1F1B5{bottom:0}.index__container___1eyTh.index__top___7QDtU.index__over___1V7jO .index__toast___233-Y{position:absolute;top:12px;-webkit-animation:index__toast-in-top-over___27LM6 .3s ease-out forwards;animation:index__toast-in-top-over___27LM6 .3s ease-out forwards}.index__container___1eyTh.index__top___7QDtU.index__over___1V7jO .index__toast___233-Y.index__remove___nvwuo{-webkit-transform:translate(-50%);-ms-transform:translate(-50%);transform:translate(-50%);-webkit-animation:index__toast-out___1NqCu .4s forwards;animation:index__toast-out___1NqCu .4s forwards}.index__container___1eyTh.index__bottom___1F1B5.index__over___1V7jO .index__toast___233-Y{position:absolute;bottom:30px;-webkit-animation:index__toast-in-bottom-over___1_t8U .3s ease-out forwards;animation:index__toast-in-bottom-over___1_t8U .3s ease-out forwards}.index__container___1eyTh.index__bottom___1F1B5.index__over___1V7jO .index__toast___233-Y.index__remove___nvwuo{-webkit-transform:translate(-50%);-ms-transform:translate(-50%);transform:translate(-50%);-webkit-animation:index__toast-out___1NqCu .4s forwards;animation:index__toast-out___1NqCu .4s forwards}.index__container___1eyTh.index__top___7QDtU.index__chain___2Fk0I .index__toast___233-Y{margin-top:12px;-webkit-animation:index__toast-in-chain___3guV3 .4s ease-out none;animation:index__toast-in-chain___3guV3 .4s ease-out none;max-height:100px}.index__container___1eyTh.index__top___7QDtU.index__chain___2Fk0I .index__toast___233-Y.index__remove___nvwuo{-webkit-transition:margin-top .2s .2s,max-height .2s .2s,opacity .2s;-o-transition:margin-top .2s .2s,max-height .2s .2s,opacity .2s;transition:margin-top .2s .2s,max-height .2s .2s,opacity .2s;margin-top:0;opacity:0;max-height:0}.index__container___1eyTh.index__bottom___1F1B5.index__chain___2Fk0I .index__toast___233-Y{margin-bottom:12px;-webkit-animation:index__toast-in-chain___3guV3 .4s ease-out none;animation:index__toast-in-chain___3guV3 .4s ease-out none;max-height:100px}.index__container___1eyTh.index__bottom___1F1B5.index__chain___2Fk0I .index__toast___233-Y:last-child{margin-bottom:30px}.index__container___1eyTh.index__bottom___1F1B5.index__chain___2Fk0I .index__toast___233-Y.index__remove___nvwuo{-webkit-transition:margin-bottom .2s .2s,max-height .2s .2s,opacity .2s;-o-transition:margin-bottom .2s .2s,max-height .2s .2s,opacity .2s;transition:margin-bottom .2s .2s,max-height .2s .2s,opacity .2s;margin-bottom:0;opacity:0;max-height:0}@-webkit-keyframes index__toast-in-top-over___27LM6{0%{-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0}to{-webkit-transform:translate(-50%);transform:translate(-50%);opacity:1}}@keyframes index__toast-in-top-over___27LM6{0%{-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0}to{-webkit-transform:translate(-50%);transform:translate(-50%);opacity:1}}@-webkit-keyframes index__toast-in-bottom-over___1_t8U{0%{-webkit-transform:translate(-50%,50%);transform:translate(-50%,50%);opacity:0}to{-webkit-transform:translate(-50%);transform:translate(-50%);opacity:1}}@keyframes index__toast-in-bottom-over___1_t8U{0%{-webkit-transform:translate(-50%,50%);transform:translate(-50%,50%);opacity:0}to{-webkit-transform:translate(-50%);transform:translate(-50%);opacity:1}}@-webkit-keyframes index__toast-in-chain___3guV3{0%{max-height:0;opacity:0}25%{max-height:100px;opacity:0}to{opacity:1}}@keyframes index__toast-in-chain___3guV3{0%{max-height:0;opacity:0}25%{max-height:100px;opacity:0}to{opacity:1}}@-webkit-keyframes index__toast-out___1NqCu{0%{opacity:1}50%{max-height:100px;opacity:0}to{max-height:0;opacity:0}}@keyframes index__toast-out___1NqCu{0%{opacity:1}50%{max-height:100px;opacity:0}to{max-height:0;opacity:0}}.index__message___2bel9{-ms-flex:1 1;flex:1 1;-o-text-overflow:ellipsis;text-overflow:ellipsis;overflow:hidden;white-space:nowrap}.index__button___1t8u7{outline:none;border:none;border-radius:4px;background-color:transparent;position:relative;cursor:pointer;color:#fff;-webkit-transition:background-color .2s;-o-transition:background-color .2s;transition:background-color .2s;padding:0;-webkit-box-shadow:none;box-shadow:none}.index__button___1t8u7:hover{background-color:hsla(0,0%,100%,.1)}.index__button___1t8u7:active{background-color:hsla(0,0%,100%,.2)}.index__action___2faCa{-ms-flex-negative:0;flex-shrink:0;-ms-flex-positive:0;flex-grow:0;padding:0 8px;line-height:24px;color:#0b8aff;margin:0 8px}.index__close___2o6CK{-ms-flex:0 0 24px;flex:0 0 24px;width:24px;height:24px}.index__close___2o6CK:after,.index__close___2o6CK:before{content:"";display:block;position:absolute;width:20px;height:2px;top:calc(50% - 1px);left:50%;background-color:#fff}.index__close___2o6CK:before{-webkit-transform:translateX(-50%) rotate(45deg);-ms-transform:translateX(-50%) rotate(45deg);transform:translateX(-50%) rotate(45deg)}.index__close___2o6CK:after{-webkit-transform:translateX(-50%) rotate(135deg);-ms-transform:translateX(-50%) rotate(135deg);transform:translateX(-50%) rotate(135deg)}.index__close___2o6CK.index__hidden___Ov2Dy{display:none}',""]),e.locals={toast:"index__toast___233-Y",error:"index__error___38eWT",container:"index__container___1eyTh",chain:"index__chain___2Fk0I",top:"index__top___7QDtU",bottom:"index__bottom___1F1B5",over:"index__over___1V7jO","toast-in-top-over":"index__toast-in-top-over___27LM6",remove:"index__remove___nvwuo","toast-out":"index__toast-out___1NqCu","toast-in-bottom-over":"index__toast-in-bottom-over___1_t8U","toast-in-chain":"index__toast-in-chain___3guV3",message:"index__message___2bel9",button:"index__button___1t8u7",action:"index__action___2faCa",close:"index__close___2o6CK",hidden:"index__hidden___Ov2Dy"}},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,"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(a))))+" */"),r=o.sources.map(function(t){return"/*# sourceURL="+o.sourceRoot+t+" */"});return[n].concat(r).concat([i]).join("\n")}var a;return[n].join("\n")}(e,t);return e[2]?"@media "+e[2]+"{"+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(i=0;i<t.length;i++){var a=t[i];null!=a[0]&&o[a[0]]||(n&&!a[2]?a[2]=n:n&&(a[2]="("+a[2]+") and ("+n+")"),e.push(a))}},e}},function(t,e,n){var o,i,r={},a=(o=function(){return window&&document&&document.all&&!window.atob},function(){return void 0===i&&(i=o.apply(this,arguments)),i}),s=function(t){var e={};return function(t,n){if("function"==typeof t)return t();if(void 0===e[t]){var o=function(t,e){return e?e.querySelector(t):document.querySelector(t)}.call(this,t,n);if(window.HTMLIFrameElement&&o instanceof window.HTMLIFrameElement)try{o=o.contentDocument.head}catch(t){o=null}e[t]=o}return e[t]}}(),_=null,c=0,l=[],d=n(4);function u(t,e){for(var n=0;n<t.length;n++){var o=t[n],i=r[o.id];if(i){i.refs++;for(var a=0;a<i.parts.length;a++)i.parts[a](o.parts[a]);for(;a<o.parts.length;a++)i.parts.push(b(o.parts[a],e))}else{var s=[];for(a=0;a<o.parts.length;a++)s.push(b(o.parts[a],e));r[o.id]={id:o.id,refs:1,parts:s}}}}function f(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 p(t,e){var n=s(t.insertInto);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");var o=l[l.length-1];if("top"===t.insertAt)o?o.nextSibling?n.insertBefore(e,o.nextSibling):n.appendChild(e):n.insertBefore(e,n.firstChild),l.push(e);else if("bottom"===t.insertAt)n.appendChild(e);else{if("object"!=typeof t.insertAt||!t.insertAt.before)throw new Error("[Style Loader]\n\n Invalid value for parameter 'insertAt' ('options.insertAt') found.\n Must be 'top', 'bottom', or Object.\n (https://github.com/webpack-contrib/style-loader#insertat)\n");var i=s(t.insertAt.before,n);n.insertBefore(e,i)}}function m(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t);var e=l.indexOf(t);e>=0&&l.splice(e,1)}function h(t){var e=document.createElement("style");if(void 0===t.attrs.type&&(t.attrs.type="text/css"),void 0===t.attrs.nonce){var o=function(){0;return n.nc}();o&&(t.attrs.nonce=o)}return x(e,t.attrs),p(t,e),e}function x(t,e){Object.keys(e).forEach(function(n){t.setAttribute(n,e[n])})}function b(t,e){var n,o,i,r;if(e.transform&&t.css){if(!(r="function"==typeof e.transform?e.transform(t.css):e.transform.default(t.css)))return function(){};t.css=r}if(e.singleton){var a=c++;n=_||(_=h(e)),o=g.bind(null,n,a,!1),i=g.bind(null,n,a,!0)}else t.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(n=function(t){var e=document.createElement("link");return void 0===t.attrs.type&&(t.attrs.type="text/css"),t.attrs.rel="stylesheet",x(e,t.attrs),p(t,e),e}(e),o=function(t,e,n){var o=n.css,i=n.sourceMap,r=void 0===e.convertToAbsoluteUrls&&i;(e.convertToAbsoluteUrls||r)&&(o=d(o));i&&(o+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(i))))+" */");var a=new Blob([o],{type:"text/css"}),s=t.href;t.href=URL.createObjectURL(a),s&&URL.revokeObjectURL(s)}.bind(null,n,e),i=function(){m(n),n.href&&URL.revokeObjectURL(n.href)}):(n=h(e),o=function(t,e){var n=e.css,o=e.media;o&&t.setAttribute("media",o);if(t.styleSheet)t.styleSheet.cssText=n;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(n))}}.bind(null,n),i=function(){m(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){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(e=e||{}).attrs="object"==typeof e.attrs?e.attrs:{},e.singleton||"boolean"==typeof e.singleton||(e.singleton=a()),e.insertInto||(e.insertInto="head"),e.insertAt||(e.insertAt="bottom");var n=f(t,e);return u(n,e),function(t){for(var o=[],i=0;i<n.length;i++){var a=n[i];(s=r[a.id]).refs--,o.push(s)}t&&u(f(t,e),e);for(i=0;i<o.length;i++){var s;if(0===(s=o[i]).refs){for(var _=0;_<s.parts.length;_++)s.parts[_]();delete r[s.id]}}}};var v,y=(v=[],function(t,e){return v[t]=e,v.filter(Boolean).join("\n")});function g(t,e,n,o){var i=n?"":o.css;if(t.styleSheet)t.styleSheet.cssText=y(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)}}},function(t,e){t.exports=function(t){var e="undefined"!=typeof window&&window.location;if(!e)throw new Error("fixUrls requires window.location");if(!t||"string"!=typeof t)return t;var n=e.protocol+"//"+e.host,o=n+e.pathname.replace(/\/[^\/]*$/,"/");return t.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,function(t,e){var i,r=e.trim().replace(/^"(.*)"$/,function(t,e){return e}).replace(/^'(.*)'$/,function(t,e){return e});return/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(r)?t:(i=0===r.indexOf("//")?r:0===r.indexOf("/")?n+r:o+r.replace(/^\.\//,""),"url("+JSON.stringify(i)+")")})}},function(t,e,n){"use strict";n.r(e);var o=n(0),i=n.n(o),r={default:{position:"top",type:"over",toastClass:"",removedToastClass:"",closeable:!0,timeoutOnRemove:1e3,duration:5e3},error:{toastClass:i.a.error,timeoutOnRemove:1e3,duration:5e3}};function a(t,e){(Array.isArray(e)?e:e.split(" ")).forEach(function(e){return e&&t.classList.add(e)})}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 _(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),o.forEach(function(e){c(t,e,n[e])})}return t}function c(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function l(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)}}function d(t,e,n){return e&&l(t.prototype,e),n&&l(t,n),t}var u=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"notify",o=arguments.length>2?arguments[2]:void 0;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);var i=_({},r.default);"string"==typeof n&&r[n]?i=_({},i,r[n]):"object"===s(n)&&(i=_({},i,n)),"over"===i.type&&t.removeAll(i),this.options=i,this.content=e,this.domNode=this.createToastNode(o),t.getContainer(i).appendChild(this.domNode),this.startTimer()}return d(t,null,[{key:"getContainer",value:function(t){var e=t.position,n=void 0===e?"top":e,o=t.type,r=void 0===o?"over":o,s="bottom"===n?i.a.bottom:i.a.top,_="chain"===r?i.a.chain:i.a.over,c=".".concat(i.a.container,".").concat(s,".").concat(_),l=document.querySelector(c);return l||(a(l=document.createElement("div"),[i.a.container,s,_]),document.body.appendChild(l)),l}},{key:"removeAll",value:function(e){for(var n=t.getContainer(e).querySelectorAll(".".concat(i.a.close)),o=0,r=n.length;o<r;o+=1)n[o].click()}}]),d(t,[{key:"createToastNode",value:function(t){var e=this,n=document.createElement("div");a(n,i.a.toast);var o=document.createElement("div");if(a(o,i.a.message),o.textContent=this.content,n.appendChild(o),n.title=this.content,a(n,[this.options.toastClass]),t){var r=document.createElement("button");a(r,[i.a.action,i.a.button,t.class]),r.title=t.label,r.textContent=t.label,r.addEventListener("click",function(){t.action(),e.close()}),n.appendChild(r)}var s=document.createElement("button");return a(s,[i.a.close,i.a.button,!this.options.closeable&&i.a.hidden]),s.title="Close",s.addEventListener("click",function(){return e.close()}),n.appendChild(s),n.addEventListener("mouseenter",function(){return e.stopTimer()}),n.addEventListener("mouseleave",function(){return e.startTimer()}),n}},{key:"close",value:function(){var t=this;this.stopTimer(),this.domNode&&(a(this.domNode,[i.a.remove,this.options.removedToastClass]),setTimeout(function(){t.domNode.remove()},this.options.timeoutOnRemove||1e3))}},{key:"startTimer",value:function(){var t=this;this.stopTimer(),this.timerShow=setTimeout(function(){return t.close()},this.options.duration||5e3)}},{key:"stopTimer",value:function(){clearTimeout(this.timerShow)}}]),t}();function f(t){u.removeAll(t)}n.d(e,"ToastOptions",function(){return r}),n.d(e,"ToastMeClass",function(){return u}),n.d(e,"removeAllToasts",function(){return f});e.default=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"notify",n=arguments.length>2?arguments[2]:void 0;return new u(t,e,n)}}])});
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("toast-me",[],e):"object"==typeof exports?exports["toast-me"]=e():t["toast-me"]=e()}("undefined"!=typeof self?self:this,(function(){return function(t){var e={};function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.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 r in t)n.d(o,r,function(e){return t[e]}.bind(null,r));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=5)}([function(t,e,n){var o=n(1);"string"==typeof o&&(o=[[t.i,o,""]]);var r={hmr:!0,transform:void 0,insertInto:void 0};n(3)(o,r);o.locals&&(t.exports=o.locals)},function(t,e,n){(e=t.exports=n(2)(!1)).push([t.i,'.index__toast___233-Y{height:48px;width:40%;min-width:270px;padding:0 15px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:stretch;justify-content:stretch;background-color:rgba(0,0,0,.9);border-radius:4px;left:50%;-ms-flex-negative:0;flex-shrink:0}.index__toast___233-Y.index__error___38eWT{background-color:#d40d00}.index__container___1eyTh{position:fixed;width:100%;height:0;color:#fff}.index__container___1eyTh.index__chain___2Fk0I{display:-ms-flexbox;display:flex;-ms-flex-pack:end;justify-content:flex-end;-ms-flex-align:center;align-items:center}.index__container___1eyTh.index__chain___2Fk0I.index__top___7QDtU{-ms-flex-direction:column-reverse;flex-direction:column-reverse}.index__container___1eyTh.index__chain___2Fk0I.index__bottom___1F1B5{-ms-flex-direction:column;flex-direction:column}.index__container___1eyTh.index__top___7QDtU{top:0}.index__container___1eyTh.index__bottom___1F1B5{bottom:0}.index__container___1eyTh.index__top___7QDtU.index__over___1V7jO .index__toast___233-Y{position:absolute;top:12px;-webkit-animation:index__toast-in-top-over___27LM6 .3s ease-out forwards;animation:index__toast-in-top-over___27LM6 .3s ease-out forwards}.index__container___1eyTh.index__top___7QDtU.index__over___1V7jO .index__toast___233-Y.index__remove___nvwuo{-webkit-transform:translate(-50%);-ms-transform:translate(-50%);transform:translate(-50%);-webkit-animation:index__toast-out___1NqCu .4s forwards;animation:index__toast-out___1NqCu .4s forwards}.index__container___1eyTh.index__bottom___1F1B5.index__over___1V7jO .index__toast___233-Y{position:absolute;bottom:30px;-webkit-animation:index__toast-in-bottom-over___1_t8U .3s ease-out forwards;animation:index__toast-in-bottom-over___1_t8U .3s ease-out forwards}.index__container___1eyTh.index__bottom___1F1B5.index__over___1V7jO .index__toast___233-Y.index__remove___nvwuo{-webkit-transform:translate(-50%);-ms-transform:translate(-50%);transform:translate(-50%);-webkit-animation:index__toast-out___1NqCu .4s forwards;animation:index__toast-out___1NqCu .4s forwards}.index__container___1eyTh.index__top___7QDtU.index__chain___2Fk0I .index__toast___233-Y{margin-top:12px;-webkit-animation:index__toast-in-chain___3guV3 .4s ease-out none;animation:index__toast-in-chain___3guV3 .4s ease-out none;max-height:100px}.index__container___1eyTh.index__top___7QDtU.index__chain___2Fk0I .index__toast___233-Y.index__remove___nvwuo{-webkit-transition:margin-top .2s .2s,max-height .2s .2s,opacity .2s;-o-transition:margin-top .2s .2s,max-height .2s .2s,opacity .2s;transition:margin-top .2s .2s,max-height .2s .2s,opacity .2s;margin-top:0;opacity:0;max-height:0}.index__container___1eyTh.index__bottom___1F1B5.index__chain___2Fk0I .index__toast___233-Y{margin-bottom:12px;-webkit-animation:index__toast-in-chain___3guV3 .4s ease-out none;animation:index__toast-in-chain___3guV3 .4s ease-out none;max-height:100px}.index__container___1eyTh.index__bottom___1F1B5.index__chain___2Fk0I .index__toast___233-Y:last-child{margin-bottom:30px}.index__container___1eyTh.index__bottom___1F1B5.index__chain___2Fk0I .index__toast___233-Y.index__remove___nvwuo{-webkit-transition:margin-bottom .2s .2s,max-height .2s .2s,opacity .2s;-o-transition:margin-bottom .2s .2s,max-height .2s .2s,opacity .2s;transition:margin-bottom .2s .2s,max-height .2s .2s,opacity .2s;margin-bottom:0;opacity:0;max-height:0}@-webkit-keyframes index__toast-in-top-over___27LM6{0%{-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0}to{-webkit-transform:translate(-50%);transform:translate(-50%);opacity:1}}@keyframes index__toast-in-top-over___27LM6{0%{-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0}to{-webkit-transform:translate(-50%);transform:translate(-50%);opacity:1}}@-webkit-keyframes index__toast-in-bottom-over___1_t8U{0%{-webkit-transform:translate(-50%,50%);transform:translate(-50%,50%);opacity:0}to{-webkit-transform:translate(-50%);transform:translate(-50%);opacity:1}}@keyframes index__toast-in-bottom-over___1_t8U{0%{-webkit-transform:translate(-50%,50%);transform:translate(-50%,50%);opacity:0}to{-webkit-transform:translate(-50%);transform:translate(-50%);opacity:1}}@-webkit-keyframes index__toast-in-chain___3guV3{0%{max-height:0;opacity:0}25%{max-height:100px;opacity:0}to{opacity:1}}@keyframes index__toast-in-chain___3guV3{0%{max-height:0;opacity:0}25%{max-height:100px;opacity:0}to{opacity:1}}@-webkit-keyframes index__toast-out___1NqCu{0%{opacity:1}50%{max-height:100px;opacity:0}to{max-height:0;opacity:0}}@keyframes index__toast-out___1NqCu{0%{opacity:1}50%{max-height:100px;opacity:0}to{max-height:0;opacity:0}}.index__message___2bel9{-ms-flex:1 1;flex:1 1;-o-text-overflow:ellipsis;text-overflow:ellipsis;overflow:hidden;white-space:nowrap}.index__button___1t8u7{outline:none;border:none;border-radius:4px;background-color:transparent;position:relative;cursor:pointer;color:#fff;-webkit-transition:background-color .2s;-o-transition:background-color .2s;transition:background-color .2s;padding:0;-webkit-box-shadow:none;box-shadow:none}.index__button___1t8u7:hover{background-color:hsla(0,0%,100%,.1)}.index__button___1t8u7:active{background-color:hsla(0,0%,100%,.2)}.index__action___2faCa{-ms-flex-negative:0;flex-shrink:0;-ms-flex-positive:0;flex-grow:0;padding:0 8px;line-height:24px;color:#0b8aff;margin:0 8px}.index__close___2o6CK{-ms-flex:0 0 24px;flex:0 0 24px;width:24px;height:24px}.index__close___2o6CK:after,.index__close___2o6CK:before{content:"";display:block;position:absolute;width:20px;height:2px;top:calc(50% - 1px);left:50%;background-color:#fff}.index__close___2o6CK:before{-webkit-transform:translateX(-50%) rotate(45deg);-ms-transform:translateX(-50%) rotate(45deg);transform:translateX(-50%) rotate(45deg)}.index__close___2o6CK:after{-webkit-transform:translateX(-50%) rotate(135deg);-ms-transform:translateX(-50%) rotate(135deg);transform:translateX(-50%) rotate(135deg)}.index__close___2o6CK.index__hidden___Ov2Dy{display:none}',""]),e.locals={toast:"index__toast___233-Y",error:"index__error___38eWT",container:"index__container___1eyTh",chain:"index__chain___2Fk0I",top:"index__top___7QDtU",bottom:"index__bottom___1F1B5",over:"index__over___1V7jO","toast-in-top-over":"index__toast-in-top-over___27LM6",remove:"index__remove___nvwuo","toast-out":"index__toast-out___1NqCu","toast-in-bottom-over":"index__toast-in-bottom-over___1_t8U","toast-in-chain":"index__toast-in-chain___3guV3",message:"index__message___2bel9",button:"index__button___1t8u7",action:"index__action___2faCa",close:"index__close___2o6CK",hidden:"index__hidden___Ov2Dy"}},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 r=(a=o,"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(a))))+" */"),i=o.sources.map((function(t){return"/*# sourceURL="+o.sourceRoot+t+" */"}));return[n].concat(i).concat([r]).join("\n")}var a;return[n].join("\n")}(e,t);return e[2]?"@media "+e[2]+"{"+n+"}":n})).join("")},e.i=function(t,n){"string"==typeof t&&(t=[[null,t,""]]);for(var o={},r=0;r<this.length;r++){var i=this[r][0];null!=i&&(o[i]=!0)}for(r=0;r<t.length;r++){var a=t[r];null!=a[0]&&o[a[0]]||(n&&!a[2]?a[2]=n:n&&(a[2]="("+a[2]+") and ("+n+")"),e.push(a))}},e}},function(t,e,n){var o,r,i={},a=(o=function(){return window&&document&&document.all&&!window.atob},function(){return void 0===r&&(r=o.apply(this,arguments)),r}),s=function(t,e){return e?e.querySelector(t):document.querySelector(t)},_=function(t){var e={};return function(t,n){if("function"==typeof t)return t();if(void 0===e[t]){var o=s.call(this,t,n);if(window.HTMLIFrameElement&&o instanceof window.HTMLIFrameElement)try{o=o.contentDocument.head}catch(t){o=null}e[t]=o}return e[t]}}(),c=null,l=0,u=[],d=n(4);function f(t,e){for(var n=0;n<t.length;n++){var o=t[n],r=i[o.id];if(r){r.refs++;for(var a=0;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{var s=[];for(a=0;a<o.parts.length;a++)s.push(v(o.parts[a],e));i[o.id]={id:o.id,refs:1,parts:s}}}}function p(t,e){for(var n=[],o={},r=0;r<t.length;r++){var i=t[r],a=e.base?i[0]+e.base:i[0],s={css:i[1],media:i[2],sourceMap:i[3]};o[a]?o[a].parts.push(s):n.push(o[a]={id:a,parts:[s]})}return n}function m(t,e){var n=_(t.insertInto);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");var o=u[u.length-1];if("top"===t.insertAt)o?o.nextSibling?n.insertBefore(e,o.nextSibling):n.appendChild(e):n.insertBefore(e,n.firstChild),u.push(e);else if("bottom"===t.insertAt)n.appendChild(e);else{if("object"!=typeof t.insertAt||!t.insertAt.before)throw new Error("[Style Loader]\n\n Invalid value for parameter 'insertAt' ('options.insertAt') found.\n Must be 'top', 'bottom', or Object.\n (https://github.com/webpack-contrib/style-loader#insertat)\n");var r=_(t.insertAt.before,n);n.insertBefore(e,r)}}function h(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t);var e=u.indexOf(t);e>=0&&u.splice(e,1)}function x(t){var e=document.createElement("style");if(void 0===t.attrs.type&&(t.attrs.type="text/css"),void 0===t.attrs.nonce){var o=function(){0;return n.nc}();o&&(t.attrs.nonce=o)}return b(e,t.attrs),m(t,e),e}function b(t,e){Object.keys(e).forEach((function(n){t.setAttribute(n,e[n])}))}function v(t,e){var n,o,r,i;if(e.transform&&t.css){if(!(i="function"==typeof e.transform?e.transform(t.css):e.transform.default(t.css)))return function(){};t.css=i}if(e.singleton){var a=l++;n=c||(c=x(e)),o=w.bind(null,n,a,!1),r=w.bind(null,n,a,!0)}else t.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(n=function(t){var e=document.createElement("link");return void 0===t.attrs.type&&(t.attrs.type="text/css"),t.attrs.rel="stylesheet",b(e,t.attrs),m(t,e),e}(e),o=C.bind(null,n,e),r=function(){h(n),n.href&&URL.revokeObjectURL(n.href)}):(n=x(e),o=k.bind(null,n),r=function(){h(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 r()}}t.exports=function(t,e){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(e=e||{}).attrs="object"==typeof e.attrs?e.attrs:{},e.singleton||"boolean"==typeof e.singleton||(e.singleton=a()),e.insertInto||(e.insertInto="head"),e.insertAt||(e.insertAt="bottom");var n=p(t,e);return f(n,e),function(t){for(var o=[],r=0;r<n.length;r++){var a=n[r];(s=i[a.id]).refs--,o.push(s)}t&&f(p(t,e),e);for(r=0;r<o.length;r++){var s;if(0===(s=o[r]).refs){for(var _=0;_<s.parts.length;_++)s.parts[_]();delete i[s.id]}}}};var y,g=(y=[],function(t,e){return y[t]=e,y.filter(Boolean).join("\n")});function w(t,e,n,o){var r=n?"":o.css;if(t.styleSheet)t.styleSheet.cssText=g(e,r);else{var i=document.createTextNode(r),a=t.childNodes;a[e]&&t.removeChild(a[e]),a.length?t.insertBefore(i,a[e]):t.appendChild(i)}}function k(t,e){var n=e.css,o=e.media;if(o&&t.setAttribute("media",o),t.styleSheet)t.styleSheet.cssText=n;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(n))}}function C(t,e,n){var o=n.css,r=n.sourceMap,i=void 0===e.convertToAbsoluteUrls&&r;(e.convertToAbsoluteUrls||i)&&(o=d(o)),r&&(o+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(r))))+" */");var a=new Blob([o],{type:"text/css"}),s=t.href;t.href=URL.createObjectURL(a),s&&URL.revokeObjectURL(s)}},function(t,e){t.exports=function(t){var e="undefined"!=typeof window&&window.location;if(!e)throw new Error("fixUrls requires window.location");if(!t||"string"!=typeof t)return t;var n=e.protocol+"//"+e.host,o=n+e.pathname.replace(/\/[^\/]*$/,"/");return t.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,(function(t,e){var r,i=e.trim().replace(/^"(.*)"$/,(function(t,e){return e})).replace(/^'(.*)'$/,(function(t,e){return e}));return/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(i)?t:(r=0===i.indexOf("//")?i:0===i.indexOf("/")?n+i:o+i.replace(/^\.\//,""),"url("+JSON.stringify(r)+")")}))}},function(t,e,n){"use strict";n.r(e);var o=n(0),r=n.n(o),i={default:{position:"top",type:"over",toastClass:"",removedToastClass:"",containerClass:"",useUniqueContainer:!1,closeable:!0,timeoutOnRemove:1e3,duration:5e3},error:{toastClass:r.a.error,timeoutOnRemove:1e3,duration:5e3}};function a(t,e){(Array.isArray(e)?function t(e){return e.reduce((function(e,n){return e.concat(Array.isArray(n)?t(n):n)}),[])}(e.map((function(t){return t&&t.split(" ")}))):e.split(" ")).forEach((function(e){return e&&t.classList.add(e)}))}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 _(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 c(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?_(n,!0).forEach((function(e){l(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):_(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function l(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function u(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)}}function d(t,e,n){return e&&u(t.prototype,e),n&&u(t,n),t}var f=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"notify",o=arguments.length>2?arguments[2]:void 0;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);var r=c({},i.default);"string"==typeof n&&i[n]?r=c({},r,{},i[n]):"object"===s(n)&&(r=c({},r,{},n)),"over"===r.type&&t.removeAll(r),this.options=r,this.content=e,this.domNode=this.createToastNode(o),t.getContainer(r).appendChild(this.domNode),this.startTimer()}return d(t,null,[{key:"getContainer",value:function(t){var e=t.position,n=void 0===e?"top":e,o=t.type,i=void 0===o?"over":o,s=t.containerClass,_=void 0===s?"":s,c=t.useUniqueContainer,l=void 0!==c&&c,u="bottom"===n?r.a.bottom:r.a.top,d="chain"===i?r.a.chain:r.a.over,f=".".concat(r.a.container,".").concat(u,".").concat(d),p=l?null:document.querySelector(f);return p?p.className="":(p=document.createElement("div"),document.body.appendChild(p)),a(p,[r.a.container,u,d,_]),p}},{key:"removeAll",value:function(e){for(var n=t.getContainer(e).querySelectorAll(".".concat(r.a.close)),o=0,i=n.length;o<i;o+=1)n[o].click()}}]),d(t,[{key:"createToastNode",value:function(t){var e=this,n=document.createElement("div");a(n,r.a.toast);var o=document.createElement("div");if(a(o,r.a.message),o.textContent=this.content,n.appendChild(o),n.title=this.content,a(n,[this.options.toastClass]),t){var i=document.createElement("button");a(i,[r.a.action,r.a.button,t.class]),i.title=t.label,i.textContent=t.label,i.addEventListener("click",(function(){t.action(),e.close()})),n.appendChild(i)}var s=document.createElement("button");return a(s,[r.a.close,r.a.button,!this.options.closeable&&r.a.hidden]),s.title="Close",s.addEventListener("click",(function(){return e.close()})),n.appendChild(s),n.addEventListener("mouseenter",(function(){return e.stopTimer()})),n.addEventListener("mouseleave",(function(){return e.startTimer()})),n}},{key:"close",value:function(){var t=this;this.stopTimer(),this.domNode&&(a(this.domNode,[r.a.remove,this.options.removedToastClass]),setTimeout((function(){t.domNode.remove()}),this.options.timeoutOnRemove||1e3))}},{key:"startTimer",value:function(){var t=this;this.stopTimer(),this.timerShow=setTimeout((function(){return t.close()}),this.options.duration||5e3)}},{key:"stopTimer",value:function(){clearTimeout(this.timerShow)}}]),t}();function p(t){f.removeAll(t)}n.d(e,"ToastOptions",(function(){return i})),n.d(e,"ToastMeClass",(function(){return f})),n.d(e,"removeAllToasts",(function(){return p}));e.default=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"notify",n=arguments.length>2?arguments[2]:void 0;return new f(t,e,n)}}])}));
{
"name": "toast-me",
"version": "1.2.4",
"version": "1.3.0",
"description": "Creates toast messages",

@@ -10,3 +10,4 @@ "main": "lib/toast-me.min.js",

"watch": "webpack --colors --watch --env dev --config scripts/config/webpack.config.devLib.js",
"test": "node scripts/test.js --env=jsdom --config jest.config.js"
"test": "node scripts/test.js --env=jsdom --config jest.config.js",
"test-ci": "node scripts/test.js --env=jsdom --config jest.config.js --coverage --runInBand && flow"
},

@@ -58,2 +59,3 @@ "repository": {

"html-webpack-plugin": "^3.2.0",
"husky": "^3.0.9",
"identity-obj-proxy": "^3.0.0",

@@ -79,3 +81,8 @@ "jest": "^24.7.1",

},
"dependencies": {}
"dependencies": {},
"husky": {
"hooks": {
"pre-commit": "yarn test-ci"
}
}
}

@@ -39,3 +39,3 @@ # toast-me

* Customizable
* Light-weight (15kB until gzip, 5kB zipped)
* Light-weight (17kB until gzip, 6kB zipped)
* Supports actions' button inside toast

@@ -130,2 +130,4 @@ * Closeable

removedToastClass: '',
containerClass: '',
useUniqueContainer: false,
closeable: true,

@@ -142,2 +144,10 @@ timeoutOnRemove: 1000,

Default `""` - empty string
* `removedToastClass` - *string*, CSS class name for removed toast node, can be used for custom CSS
animation or styling. Default `""` - empty string
* `containerClass` - *string*, CSS class name for toast's container node, can be used for custom
container styling. Once it is set, container node will have that class (classname won't be erased
on next toast creating). If you want prevent this behaviour - set `useUniqueContainer` option
to `true` when set `containerClass`. Default `""` - empty string
* `useUniqueContainer` - *boolean*, create new toast's container node, instead of re-using existing
one, if it is presented. Default `false`
* `closeable` - *boolean*, enables/hides "close" button on toast. Default `true`

@@ -144,0 +154,0 @@ * `timeoutOnRemove` - *number*, time in ms, till node should be removed from DOM after toast hides.

// @flow
export function arrayFlat(array: Array<any>) {
return array.reduce(
(acc, val) => acc.concat(Array.isArray(val) ? arrayFlat(val) : val),
[]
);
}
export function setClass(node: Element, classes: string | Array<string>) {
const arr = Array.isArray(classes) ? classes : classes.split(' ');
const arr = Array.isArray(classes)
? arrayFlat(classes.map(el => el && el.split(' ')))
: classes.split(' ');
arr.forEach(cls => cls && node.classList.add(cls));
}

@@ -15,2 +15,4 @@ // @flow

removedToastClass: '',
containerClass: '',
useUniqueContainer: false,
closeable: true,

@@ -17,0 +19,0 @@ timeoutOnRemove: DEFAULT_TIMEOUT_BEFORE_REMOVE,

@@ -9,12 +9,20 @@ // @flow

export default class ToastMeClass {
static getContainer({ position = 'top', type = 'over' }: ContainerOptionsType): Element {
static getContainer({
position = 'top',
type = 'over',
containerClass = '',
useUniqueContainer = false,
}: ContainerOptionsType): Element {
const positionClass = position === 'bottom' ? styles.bottom : styles.top;
const typeClass = type === 'chain' ? styles.chain : styles.over;
const selector = `.${styles.container}.${positionClass}.${typeClass}`;
let node = document.querySelector(selector);
let node = useUniqueContainer ? null : document.querySelector(selector);
if (!node) {
node = document.createElement('div');
setClass(node, [styles.container, positionClass, typeClass]);
document.body.appendChild(node);
} else {
node.className = '';
}
setClass(node, [styles.container, positionClass, typeClass, containerClass]);
return node;

@@ -21,0 +29,0 @@ }

@@ -10,2 +10,4 @@ // @flow

type: ContainerType,
containerClass?: string,
useUniqueContainer?: boolean,
};

@@ -18,2 +20,4 @@

removedToastClass?: string,
containerClass?: string,
useUniqueContainer?: boolean,
closeable?: boolean,

@@ -20,0 +24,0 @@ showAll?: boolean,

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

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