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

bulma-toast

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bulma-toast - npm Package Compare versions

Comparing version 2.3.0 to 2.3.1

7

CHANGELOG.md

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

## [2.3.1](https://github.com/rfoel/bulma-toast/compare/v2.3.0...v2.3.1) (2021-05-21)
### Bug Fixes
* fix ssr ([a5156b2](https://github.com/rfoel/bulma-toast/commit/a5156b2f50d8b2de8c928cc058aeac55cf53fdf4))
# [2.3.0](https://github.com/rfoel/bulma-toast/compare/v2.2.0...v2.3.0) (2021-03-22)

@@ -2,0 +9,0 @@

4

dist/bulma-toast.cjs.js
/*!
* bulma-toast 2.3.0
* bulma-toast 2.3.1
* (c) 2018-present @rfoel <rafaelfr@outlook.com>
* Released under the MIT License.
*/
'use strict';Object.defineProperty(exports,"__esModule",{value:!0});function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),a}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread2(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}var baseConfig={duration:2e3,position:"top-right",closeOnClick:!0,opacity:1,single:!1,offsetTop:0,offsetBottom:0,offsetLeft:0,offsetRight:0},defaults=_objectSpread2({},baseConfig),containers={},doc=document,COMMON_STYLES="width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;",CONTAINER_STYLES=function(a,b,c,d,e){return"top-left"===a?"left:".concat(d,";top:").concat(b,";text-align:left;align-items:flex-start;"):"top-right"===a?"right:".concat(e,";top:").concat(b,";text-align:right;align-items:flex-end;"):"top-center"===a?"top:".concat(b,";left:0;right:0;text-align:center;align-items:center;"):"bottom-left"===a?"left:".concat(d,";bottom:").concat(c,";text-align:left;align-items:flex-start;"):"bottom-right"===a?"right:".concat(e,";bottom:").concat(c,";text-align:right;align-items:flex-end;"):"bottom-center"===a?"bottom:".concat(c,";left:0;right:0;text-align:center;align-items:center;"):"center"===a?"top:0;left:0;right:0;bottom:0;flex-flow:column;justify-content:center;align-items:center;":void 0};function findOrCreateContainer(a,b,c,d,e,f){if(containers.position)return containers.position;var g=doc.createElement("div");return g.setAttribute("style",COMMON_STYLES+CONTAINER_STYLES(b,c,d,e,f)),a.appendChild(g),containers.position=g,g}function setDefaults(a){defaults=_objectSpread2(_objectSpread2({},baseConfig),a)}function resetDefaults(){defaults=_objectSpread2({},baseConfig)}function setDoc(a){for(var b in containers)containers[b].remove();containers={},doc=a}function toast(a){if(!a.message)throw new Error("message is required");var b=_objectSpread2(_objectSpread2({},defaults),a),c=new Toast(b),d=findOrCreateContainer(b.appendTo||doc.body,b.position||defaults.position,b.offsetTop||defaults.offsetTop,b.offsetBottom||defaults.offsetBottom,b.offsetLeft||defaults.offsetLeft,b.offsetRight||defaults.offsetRight);if(b.single)for(var e=d.lastElementChild;e;)d.removeChild(e),e=d.lastElementChild;d.appendChild(c.element)}var Toast=/*#__PURE__*/function(){function a(b){var c=this;_classCallCheck(this,a),this.element=doc.createElement("div"),this.opacity=b.opacity,this.type=b.type,this.animate=b.animate,this.dismissible=b.dismissible,this.closeOnClick=b.closeOnClick,this.message=b.message,this.duration=b.duration,this.pauseOnHover=b.pauseOnHover,this.offsetTop=b.offsetTop,this.offsetBottom=b.offsetBottom,this.offsetLeft=b.offsetLeft,this.offsetRight=b.offsetRight;var d="width:auto;pointer-events:auto;display:inline-flex;white-space:pre-wrap;opacity:".concat(this.opacity,";"),e=["notification"];if(this.type&&e.push(this.type),this.animate&&this.animate["in"]){var f="animate__".concat(this.animate["in"]),g=this.animate.speed?"animate__".concat(this.animate.speed):"animate__faster";e.push("animate__animated ".concat(f," ").concat(g)),this.onAnimationEnd(function(){return c.element.classList.remove(f)})}if(this.element.className=e.join(" "),this.dismissible){var h=doc.createElement("button");h.className="delete",h.addEventListener("click",function(){c.destroy()}),this.element.insertAdjacentElement("afterbegin",h)}else d+="padding: 1.25rem 1.5rem";this.closeOnClick&&this.element.addEventListener("click",function(){c.destroy()}),this.element.setAttribute("style",d),"string"==typeof this.message?this.element.insertAdjacentHTML("beforeend",this.message):this.element.appendChild(this.message);var i=new Timer(function(){c.destroy()},this.duration);this.pauseOnHover&&(this.element.addEventListener("mouseover",function(){i.pause()}),this.element.addEventListener("mouseout",function(){i.resume()}))}return _createClass(a,[{key:"destroy",value:function(){var a=this;this.animate&&this.animate.out?(this.element.classList.add("animate__".concat(this.animate.out)),this.onAnimationEnd(function(){a.removeParent(a.element.parentNode),a.element.remove(),delete containers.position})):(this.removeParent(this.element.parentNode),this.element.remove(),delete containers.position)}},{key:"removeParent",value:function(a){a&&1>=a.children.length&&a.remove()}},{key:"onAnimationEnd",value:function(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:function(){},b={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"mozAnimationEnd",WebkitAnimation:"webkitAnimationEnd"};for(var c in b)if(void 0!==this.element.style[c]){this.element.addEventListener(b[c],function(){return a()});break}}}]),a}(),Timer=/*#__PURE__*/function(){function a(b,c){_classCallCheck(this,a),this.timer,this.start,this.remaining=c,this.callback=b,this.resume()}return _createClass(a,[{key:"pause",value:function(){"undefined"==typeof document||(window.clearTimeout(this.timer),this.remaining-=new Date-this.start)}},{key:"resume",value:function(){"undefined"==typeof document||(this.start=new Date,window.clearTimeout(this.timer),this.timer=window.setTimeout(this.callback,this.remaining))}}]),a}();exports.resetDefaults=resetDefaults,exports.setDefaults=setDefaults,exports.setDoc=setDoc,exports.toast=toast;
'use strict';Object.defineProperty(exports,"__esModule",{value:!0});function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),a}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread2(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}var baseConfig={duration:2e3,position:"top-right",closeOnClick:!0,opacity:1,single:!1,offsetTop:0,offsetBottom:0,offsetLeft:0,offsetRight:0},defaults=_objectSpread2({},baseConfig),containers={},doc=null,COMMON_STYLES="width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;",CONTAINER_STYLES=function(a,b,c,d,e){return"top-left"===a?"left:".concat(d,";top:").concat(b,";text-align:left;align-items:flex-start;"):"top-right"===a?"right:".concat(e,";top:").concat(b,";text-align:right;align-items:flex-end;"):"top-center"===a?"top:".concat(b,";left:0;right:0;text-align:center;align-items:center;"):"bottom-left"===a?"left:".concat(d,";bottom:").concat(c,";text-align:left;align-items:flex-start;"):"bottom-right"===a?"right:".concat(e,";bottom:").concat(c,";text-align:right;align-items:flex-end;"):"bottom-center"===a?"bottom:".concat(c,";left:0;right:0;text-align:center;align-items:center;"):"center"===a?"top:0;left:0;right:0;bottom:0;flex-flow:column;justify-content:center;align-items:center;":void 0};function getDocument(){var a;return null!==(a=doc)&&void 0!==a?a:document}function findOrCreateContainer(a,b,c,d,e,f){if(containers.position)return containers.position;var g=getDocument().createElement("div");return g.setAttribute("style",COMMON_STYLES+CONTAINER_STYLES(b,c,d,e,f)),a.appendChild(g),containers.position=g,g}function setDefaults(a){defaults=_objectSpread2(_objectSpread2({},baseConfig),a)}function resetDefaults(){defaults=_objectSpread2({},baseConfig)}function setDoc(a){for(var b in containers)containers[b].remove();containers={},doc=a}function toast(a){if(!a.message)throw new Error("message is required");var b=_objectSpread2(_objectSpread2({},defaults),a),c=new Toast(b),d=findOrCreateContainer(b.appendTo||getDocument().body,b.position||defaults.position,b.offsetTop||defaults.offsetTop,b.offsetBottom||defaults.offsetBottom,b.offsetLeft||defaults.offsetLeft,b.offsetRight||defaults.offsetRight);if(b.single)for(var e=d.lastElementChild;e;)d.removeChild(e),e=d.lastElementChild;d.appendChild(c.element)}var Toast=/*#__PURE__*/function(){function a(b){var c=this;_classCallCheck(this,a),this.element=getDocument().createElement("div"),this.opacity=b.opacity,this.type=b.type,this.animate=b.animate,this.dismissible=b.dismissible,this.closeOnClick=b.closeOnClick,this.message=b.message,this.duration=b.duration,this.pauseOnHover=b.pauseOnHover,this.offsetTop=b.offsetTop,this.offsetBottom=b.offsetBottom,this.offsetLeft=b.offsetLeft,this.offsetRight=b.offsetRight;var d="width:auto;pointer-events:auto;display:inline-flex;white-space:pre-wrap;opacity:".concat(this.opacity,";"),e=["notification"];if(this.type&&e.push(this.type),this.animate&&this.animate["in"]){var f="animate__".concat(this.animate["in"]),g=this.animate.speed?"animate__".concat(this.animate.speed):"animate__faster";e.push("animate__animated ".concat(f," ").concat(g)),this.onAnimationEnd(function(){return c.element.classList.remove(f)})}if(this.element.className=e.join(" "),this.dismissible){var h=getDocument().createElement("button");h.className="delete",h.addEventListener("click",function(){c.destroy()}),this.element.insertAdjacentElement("afterbegin",h)}else d+="padding: 1.25rem 1.5rem";this.closeOnClick&&this.element.addEventListener("click",function(){c.destroy()}),this.element.setAttribute("style",d),"string"==typeof this.message?this.element.insertAdjacentHTML("beforeend",this.message):this.element.appendChild(this.message);var i=new Timer(function(){c.destroy()},this.duration);this.pauseOnHover&&(this.element.addEventListener("mouseover",function(){i.pause()}),this.element.addEventListener("mouseout",function(){i.resume()}))}return _createClass(a,[{key:"destroy",value:function(){var a=this;this.animate&&this.animate.out?(this.element.classList.add("animate__".concat(this.animate.out)),this.onAnimationEnd(function(){a.removeParent(a.element.parentNode),a.element.remove(),delete containers.position})):(this.removeParent(this.element.parentNode),this.element.remove(),delete containers.position)}},{key:"removeParent",value:function(a){a&&1>=a.children.length&&a.remove()}},{key:"onAnimationEnd",value:function(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:function(){},b={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"mozAnimationEnd",WebkitAnimation:"webkitAnimationEnd"};for(var c in b)if(void 0!==this.element.style[c]){this.element.addEventListener(b[c],function(){return a()});break}}}]),a}(),Timer=/*#__PURE__*/function(){function a(b,c){_classCallCheck(this,a),this.timer,this.start,this.remaining=c,this.callback=b,this.resume()}return _createClass(a,[{key:"pause",value:function(){"undefined"==typeof document||(window.clearTimeout(this.timer),this.remaining-=new Date-this.start)}},{key:"resume",value:function(){"undefined"==typeof document||(this.start=new Date,window.clearTimeout(this.timer),this.timer=window.setTimeout(this.callback,this.remaining))}}]),a}();exports.resetDefaults=resetDefaults,exports.setDefaults=setDefaults,exports.setDoc=setDoc,exports.toast=toast;
/*!
* bulma-toast 2.3.0
* bulma-toast 2.3.1
* (c) 2018-present @rfoel <rafaelfr@outlook.com>
* Released under the MIT License.
*/
function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),a}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread2(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}var baseConfig={duration:2e3,position:"top-right",closeOnClick:!0,opacity:1,single:!1,offsetTop:0,offsetBottom:0,offsetLeft:0,offsetRight:0},defaults=_objectSpread2({},baseConfig),containers={},doc=document,COMMON_STYLES="width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;",CONTAINER_STYLES=function(a,b,c,d,e){return"top-left"===a?"left:".concat(d,";top:").concat(b,";text-align:left;align-items:flex-start;"):"top-right"===a?"right:".concat(e,";top:").concat(b,";text-align:right;align-items:flex-end;"):"top-center"===a?"top:".concat(b,";left:0;right:0;text-align:center;align-items:center;"):"bottom-left"===a?"left:".concat(d,";bottom:").concat(c,";text-align:left;align-items:flex-start;"):"bottom-right"===a?"right:".concat(e,";bottom:").concat(c,";text-align:right;align-items:flex-end;"):"bottom-center"===a?"bottom:".concat(c,";left:0;right:0;text-align:center;align-items:center;"):"center"===a?"top:0;left:0;right:0;bottom:0;flex-flow:column;justify-content:center;align-items:center;":void 0};function findOrCreateContainer(a,b,c,d,e,f){if(containers.position)return containers.position;var g=doc.createElement("div");return g.setAttribute("style",COMMON_STYLES+CONTAINER_STYLES(b,c,d,e,f)),a.appendChild(g),containers.position=g,g}function setDefaults(a){defaults=_objectSpread2(_objectSpread2({},baseConfig),a)}function resetDefaults(){defaults=_objectSpread2({},baseConfig)}function setDoc(a){for(var b in containers)containers[b].remove();containers={},doc=a}function toast(a){if(!a.message)throw new Error("message is required");var b=_objectSpread2(_objectSpread2({},defaults),a),c=new Toast(b),d=findOrCreateContainer(b.appendTo||doc.body,b.position||defaults.position,b.offsetTop||defaults.offsetTop,b.offsetBottom||defaults.offsetBottom,b.offsetLeft||defaults.offsetLeft,b.offsetRight||defaults.offsetRight);if(b.single)for(var e=d.lastElementChild;e;)d.removeChild(e),e=d.lastElementChild;d.appendChild(c.element)}var Toast=/*#__PURE__*/function(){function a(b){var c=this;_classCallCheck(this,a),this.element=doc.createElement("div"),this.opacity=b.opacity,this.type=b.type,this.animate=b.animate,this.dismissible=b.dismissible,this.closeOnClick=b.closeOnClick,this.message=b.message,this.duration=b.duration,this.pauseOnHover=b.pauseOnHover,this.offsetTop=b.offsetTop,this.offsetBottom=b.offsetBottom,this.offsetLeft=b.offsetLeft,this.offsetRight=b.offsetRight;var d="width:auto;pointer-events:auto;display:inline-flex;white-space:pre-wrap;opacity:".concat(this.opacity,";"),e=["notification"];if(this.type&&e.push(this.type),this.animate&&this.animate["in"]){var f="animate__".concat(this.animate["in"]),g=this.animate.speed?"animate__".concat(this.animate.speed):"animate__faster";e.push("animate__animated ".concat(f," ").concat(g)),this.onAnimationEnd(function(){return c.element.classList.remove(f)})}if(this.element.className=e.join(" "),this.dismissible){var h=doc.createElement("button");h.className="delete",h.addEventListener("click",function(){c.destroy()}),this.element.insertAdjacentElement("afterbegin",h)}else d+="padding: 1.25rem 1.5rem";this.closeOnClick&&this.element.addEventListener("click",function(){c.destroy()}),this.element.setAttribute("style",d),"string"==typeof this.message?this.element.insertAdjacentHTML("beforeend",this.message):this.element.appendChild(this.message);var i=new Timer(function(){c.destroy()},this.duration);this.pauseOnHover&&(this.element.addEventListener("mouseover",function(){i.pause()}),this.element.addEventListener("mouseout",function(){i.resume()}))}return _createClass(a,[{key:"destroy",value:function(){var a=this;this.animate&&this.animate.out?(this.element.classList.add("animate__".concat(this.animate.out)),this.onAnimationEnd(function(){a.removeParent(a.element.parentNode),a.element.remove(),delete containers.position})):(this.removeParent(this.element.parentNode),this.element.remove(),delete containers.position)}},{key:"removeParent",value:function(a){a&&1>=a.children.length&&a.remove()}},{key:"onAnimationEnd",value:function(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:function(){},b={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"mozAnimationEnd",WebkitAnimation:"webkitAnimationEnd"};for(var c in b)if(void 0!==this.element.style[c]){this.element.addEventListener(b[c],function(){return a()});break}}}]),a}(),Timer=/*#__PURE__*/function(){function a(b,c){_classCallCheck(this,a),this.timer,this.start,this.remaining=c,this.callback=b,this.resume()}return _createClass(a,[{key:"pause",value:function(){"undefined"==typeof document||(window.clearTimeout(this.timer),this.remaining-=new Date-this.start)}},{key:"resume",value:function(){"undefined"==typeof document||(this.start=new Date,window.clearTimeout(this.timer),this.timer=window.setTimeout(this.callback,this.remaining))}}]),a}();export{resetDefaults,setDefaults,setDoc,toast};
function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),a}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread2(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}var baseConfig={duration:2e3,position:"top-right",closeOnClick:!0,opacity:1,single:!1,offsetTop:0,offsetBottom:0,offsetLeft:0,offsetRight:0},defaults=_objectSpread2({},baseConfig),containers={},doc=null,COMMON_STYLES="width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;",CONTAINER_STYLES=function(a,b,c,d,e){return"top-left"===a?"left:".concat(d,";top:").concat(b,";text-align:left;align-items:flex-start;"):"top-right"===a?"right:".concat(e,";top:").concat(b,";text-align:right;align-items:flex-end;"):"top-center"===a?"top:".concat(b,";left:0;right:0;text-align:center;align-items:center;"):"bottom-left"===a?"left:".concat(d,";bottom:").concat(c,";text-align:left;align-items:flex-start;"):"bottom-right"===a?"right:".concat(e,";bottom:").concat(c,";text-align:right;align-items:flex-end;"):"bottom-center"===a?"bottom:".concat(c,";left:0;right:0;text-align:center;align-items:center;"):"center"===a?"top:0;left:0;right:0;bottom:0;flex-flow:column;justify-content:center;align-items:center;":void 0};function getDocument(){var a;return null!==(a=doc)&&void 0!==a?a:document}function findOrCreateContainer(a,b,c,d,e,f){if(containers.position)return containers.position;var g=getDocument().createElement("div");return g.setAttribute("style",COMMON_STYLES+CONTAINER_STYLES(b,c,d,e,f)),a.appendChild(g),containers.position=g,g}function setDefaults(a){defaults=_objectSpread2(_objectSpread2({},baseConfig),a)}function resetDefaults(){defaults=_objectSpread2({},baseConfig)}function setDoc(a){for(var b in containers)containers[b].remove();containers={},doc=a}function toast(a){if(!a.message)throw new Error("message is required");var b=_objectSpread2(_objectSpread2({},defaults),a),c=new Toast(b),d=findOrCreateContainer(b.appendTo||getDocument().body,b.position||defaults.position,b.offsetTop||defaults.offsetTop,b.offsetBottom||defaults.offsetBottom,b.offsetLeft||defaults.offsetLeft,b.offsetRight||defaults.offsetRight);if(b.single)for(var e=d.lastElementChild;e;)d.removeChild(e),e=d.lastElementChild;d.appendChild(c.element)}var Toast=/*#__PURE__*/function(){function a(b){var c=this;_classCallCheck(this,a),this.element=getDocument().createElement("div"),this.opacity=b.opacity,this.type=b.type,this.animate=b.animate,this.dismissible=b.dismissible,this.closeOnClick=b.closeOnClick,this.message=b.message,this.duration=b.duration,this.pauseOnHover=b.pauseOnHover,this.offsetTop=b.offsetTop,this.offsetBottom=b.offsetBottom,this.offsetLeft=b.offsetLeft,this.offsetRight=b.offsetRight;var d="width:auto;pointer-events:auto;display:inline-flex;white-space:pre-wrap;opacity:".concat(this.opacity,";"),e=["notification"];if(this.type&&e.push(this.type),this.animate&&this.animate["in"]){var f="animate__".concat(this.animate["in"]),g=this.animate.speed?"animate__".concat(this.animate.speed):"animate__faster";e.push("animate__animated ".concat(f," ").concat(g)),this.onAnimationEnd(function(){return c.element.classList.remove(f)})}if(this.element.className=e.join(" "),this.dismissible){var h=getDocument().createElement("button");h.className="delete",h.addEventListener("click",function(){c.destroy()}),this.element.insertAdjacentElement("afterbegin",h)}else d+="padding: 1.25rem 1.5rem";this.closeOnClick&&this.element.addEventListener("click",function(){c.destroy()}),this.element.setAttribute("style",d),"string"==typeof this.message?this.element.insertAdjacentHTML("beforeend",this.message):this.element.appendChild(this.message);var i=new Timer(function(){c.destroy()},this.duration);this.pauseOnHover&&(this.element.addEventListener("mouseover",function(){i.pause()}),this.element.addEventListener("mouseout",function(){i.resume()}))}return _createClass(a,[{key:"destroy",value:function(){var a=this;this.animate&&this.animate.out?(this.element.classList.add("animate__".concat(this.animate.out)),this.onAnimationEnd(function(){a.removeParent(a.element.parentNode),a.element.remove(),delete containers.position})):(this.removeParent(this.element.parentNode),this.element.remove(),delete containers.position)}},{key:"removeParent",value:function(a){a&&1>=a.children.length&&a.remove()}},{key:"onAnimationEnd",value:function(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:function(){},b={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"mozAnimationEnd",WebkitAnimation:"webkitAnimationEnd"};for(var c in b)if(void 0!==this.element.style[c]){this.element.addEventListener(b[c],function(){return a()});break}}}]),a}(),Timer=/*#__PURE__*/function(){function a(b,c){_classCallCheck(this,a),this.timer,this.start,this.remaining=c,this.callback=b,this.resume()}return _createClass(a,[{key:"pause",value:function(){"undefined"==typeof document||(window.clearTimeout(this.timer),this.remaining-=new Date-this.start)}},{key:"resume",value:function(){"undefined"==typeof document||(this.start=new Date,window.clearTimeout(this.timer),this.timer=window.setTimeout(this.callback,this.remaining))}}]),a}();export{resetDefaults,setDefaults,setDoc,toast};
/*!
* bulma-toast 2.3.0
* bulma-toast 2.3.1
* (c) 2018-present @rfoel <rafaelfr@outlook.com>
* Released under the MIT License.
*/
(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?b(exports):"function"==typeof define&&define.amd?define(["exports"],b):(a=a||self,b(a.bulmaToast={}))})(this,function(a){'use strict';function b(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function c(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function d(a,b,d){return b&&c(a.prototype,b),d&&c(a,d),a}function e(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function f(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function g(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?f(Object(b),!0).forEach(function(c){e(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):f(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function h(a,b,c,d,e,f){if(m.position)return m.position;var g=n.createElement("div");return g.setAttribute("style","width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;"+o(b,c,d,e,f)),a.appendChild(g),m.position=g,g}function i(a){for(var b in m)m[b].remove();m={},n=a}function j(a){if(!a.message)throw new Error("message is required");var b=g(g({},l),a),c=new p(b),d=h(b.appendTo||n.body,b.position||l.position,b.offsetTop||l.offsetTop,b.offsetBottom||l.offsetBottom,b.offsetLeft||l.offsetLeft,b.offsetRight||l.offsetRight);if(b.single)for(var e=d.lastElementChild;e;)d.removeChild(e),e=d.lastElementChild;d.appendChild(c.element)}var k={duration:2e3,position:"top-right",closeOnClick:!0,opacity:1,single:!1,offsetTop:0,offsetBottom:0,offsetLeft:0,offsetRight:0},l=g({},k),m={},n=document,o=function(a,b,c,d,e){return"top-left"===a?"left:".concat(d,";top:").concat(b,";text-align:left;align-items:flex-start;"):"top-right"===a?"right:".concat(e,";top:").concat(b,";text-align:right;align-items:flex-end;"):"top-center"===a?"top:".concat(b,";left:0;right:0;text-align:center;align-items:center;"):"bottom-left"===a?"left:".concat(d,";bottom:").concat(c,";text-align:left;align-items:flex-start;"):"bottom-right"===a?"right:".concat(e,";bottom:").concat(c,";text-align:right;align-items:flex-end;"):"bottom-center"===a?"bottom:".concat(c,";left:0;right:0;text-align:center;align-items:center;"):"center"===a?"top:0;left:0;right:0;bottom:0;flex-flow:column;justify-content:center;align-items:center;":void 0},p=/*#__PURE__*/function(){function a(c){var d=this;b(this,a),this.element=n.createElement("div"),this.opacity=c.opacity,this.type=c.type,this.animate=c.animate,this.dismissible=c.dismissible,this.closeOnClick=c.closeOnClick,this.message=c.message,this.duration=c.duration,this.pauseOnHover=c.pauseOnHover,this.offsetTop=c.offsetTop,this.offsetBottom=c.offsetBottom,this.offsetLeft=c.offsetLeft,this.offsetRight=c.offsetRight;var e="width:auto;pointer-events:auto;display:inline-flex;white-space:pre-wrap;opacity:".concat(this.opacity,";"),f=["notification"];if(this.type&&f.push(this.type),this.animate&&this.animate["in"]){var g="animate__".concat(this.animate["in"]),h=this.animate.speed?"animate__".concat(this.animate.speed):"animate__faster";f.push("animate__animated ".concat(g," ").concat(h)),this.onAnimationEnd(function(){return d.element.classList.remove(g)})}if(this.element.className=f.join(" "),this.dismissible){var i=n.createElement("button");i.className="delete",i.addEventListener("click",function(){d.destroy()}),this.element.insertAdjacentElement("afterbegin",i)}else e+="padding: 1.25rem 1.5rem";this.closeOnClick&&this.element.addEventListener("click",function(){d.destroy()}),this.element.setAttribute("style",e),"string"==typeof this.message?this.element.insertAdjacentHTML("beforeend",this.message):this.element.appendChild(this.message);var j=new q(function(){d.destroy()},this.duration);this.pauseOnHover&&(this.element.addEventListener("mouseover",function(){j.pause()}),this.element.addEventListener("mouseout",function(){j.resume()}))}return d(a,[{key:"destroy",value:function(){var a=this;this.animate&&this.animate.out?(this.element.classList.add("animate__".concat(this.animate.out)),this.onAnimationEnd(function(){a.removeParent(a.element.parentNode),a.element.remove(),delete m.position})):(this.removeParent(this.element.parentNode),this.element.remove(),delete m.position)}},{key:"removeParent",value:function(a){a&&1>=a.children.length&&a.remove()}},{key:"onAnimationEnd",value:function(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:function(){},b={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"mozAnimationEnd",WebkitAnimation:"webkitAnimationEnd"};for(var c in b)if(void 0!==this.element.style[c]){this.element.addEventListener(b[c],function(){return a()});break}}}]),a}(),q=/*#__PURE__*/function(){function a(c,d){b(this,a),this.timer,this.start,this.remaining=d,this.callback=c,this.resume()}return d(a,[{key:"pause",value:function(){"undefined"==typeof document||(window.clearTimeout(this.timer),this.remaining-=new Date-this.start)}},{key:"resume",value:function(){"undefined"==typeof document||(this.start=new Date,window.clearTimeout(this.timer),this.timer=window.setTimeout(this.callback,this.remaining))}}]),a}();a.resetDefaults=function(){l=g({},k)},a.setDefaults=function(a){l=g(g({},k),a)},a.setDoc=i,a.toast=j,Object.defineProperty(a,"__esModule",{value:!0})});
(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?b(exports):"function"==typeof define&&define.amd?define(["exports"],b):(a="undefined"==typeof globalThis?a||self:globalThis,b(a.bulmaToast={}))})(this,function(a){'use strict';function b(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function c(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function d(a,b,d){return b&&c(a.prototype,b),d&&c(a,d),a}function e(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function f(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function g(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?f(Object(b),!0).forEach(function(c){e(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):f(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function h(){var a;return null!==(a=o)&&void 0!==a?a:document}function i(a,b,c,d,e,f){if(n.position)return n.position;var g=h().createElement("div");return g.setAttribute("style","width:100%;z-index:99999;position:fixed;pointer-events:none;display:flex;flex-direction:column;padding:15px;"+p(b,c,d,e,f)),a.appendChild(g),n.position=g,g}function j(a){for(var b in n)n[b].remove();n={},o=a}function k(a){if(!a.message)throw new Error("message is required");var b=g(g({},m),a),c=new q(b),d=i(b.appendTo||h().body,b.position||m.position,b.offsetTop||m.offsetTop,b.offsetBottom||m.offsetBottom,b.offsetLeft||m.offsetLeft,b.offsetRight||m.offsetRight);if(b.single)for(var e=d.lastElementChild;e;)d.removeChild(e),e=d.lastElementChild;d.appendChild(c.element)}var l={duration:2e3,position:"top-right",closeOnClick:!0,opacity:1,single:!1,offsetTop:0,offsetBottom:0,offsetLeft:0,offsetRight:0},m=g({},l),n={},o=null,p=function(a,b,c,d,e){return"top-left"===a?"left:".concat(d,";top:").concat(b,";text-align:left;align-items:flex-start;"):"top-right"===a?"right:".concat(e,";top:").concat(b,";text-align:right;align-items:flex-end;"):"top-center"===a?"top:".concat(b,";left:0;right:0;text-align:center;align-items:center;"):"bottom-left"===a?"left:".concat(d,";bottom:").concat(c,";text-align:left;align-items:flex-start;"):"bottom-right"===a?"right:".concat(e,";bottom:").concat(c,";text-align:right;align-items:flex-end;"):"bottom-center"===a?"bottom:".concat(c,";left:0;right:0;text-align:center;align-items:center;"):"center"===a?"top:0;left:0;right:0;bottom:0;flex-flow:column;justify-content:center;align-items:center;":void 0},q=/*#__PURE__*/function(){function a(c){var d=this;b(this,a),this.element=h().createElement("div"),this.opacity=c.opacity,this.type=c.type,this.animate=c.animate,this.dismissible=c.dismissible,this.closeOnClick=c.closeOnClick,this.message=c.message,this.duration=c.duration,this.pauseOnHover=c.pauseOnHover,this.offsetTop=c.offsetTop,this.offsetBottom=c.offsetBottom,this.offsetLeft=c.offsetLeft,this.offsetRight=c.offsetRight;var e="width:auto;pointer-events:auto;display:inline-flex;white-space:pre-wrap;opacity:".concat(this.opacity,";"),f=["notification"];if(this.type&&f.push(this.type),this.animate&&this.animate["in"]){var g="animate__".concat(this.animate["in"]),i=this.animate.speed?"animate__".concat(this.animate.speed):"animate__faster";f.push("animate__animated ".concat(g," ").concat(i)),this.onAnimationEnd(function(){return d.element.classList.remove(g)})}if(this.element.className=f.join(" "),this.dismissible){var j=h().createElement("button");j.className="delete",j.addEventListener("click",function(){d.destroy()}),this.element.insertAdjacentElement("afterbegin",j)}else e+="padding: 1.25rem 1.5rem";this.closeOnClick&&this.element.addEventListener("click",function(){d.destroy()}),this.element.setAttribute("style",e),"string"==typeof this.message?this.element.insertAdjacentHTML("beforeend",this.message):this.element.appendChild(this.message);var k=new r(function(){d.destroy()},this.duration);this.pauseOnHover&&(this.element.addEventListener("mouseover",function(){k.pause()}),this.element.addEventListener("mouseout",function(){k.resume()}))}return d(a,[{key:"destroy",value:function(){var a=this;this.animate&&this.animate.out?(this.element.classList.add("animate__".concat(this.animate.out)),this.onAnimationEnd(function(){a.removeParent(a.element.parentNode),a.element.remove(),delete n.position})):(this.removeParent(this.element.parentNode),this.element.remove(),delete n.position)}},{key:"removeParent",value:function(a){a&&1>=a.children.length&&a.remove()}},{key:"onAnimationEnd",value:function(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:function(){},b={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"mozAnimationEnd",WebkitAnimation:"webkitAnimationEnd"};for(var c in b)if(void 0!==this.element.style[c]){this.element.addEventListener(b[c],function(){return a()});break}}}]),a}(),r=/*#__PURE__*/function(){function a(c,d){b(this,a),this.timer,this.start,this.remaining=d,this.callback=c,this.resume()}return d(a,[{key:"pause",value:function(){"undefined"==typeof document||(window.clearTimeout(this.timer),this.remaining-=new Date-this.start)}},{key:"resume",value:function(){"undefined"==typeof document||(this.start=new Date,window.clearTimeout(this.timer),this.timer=window.setTimeout(this.callback,this.remaining))}}]),a}();a.resetDefaults=function(){m=g({},l)},a.setDefaults=function(a){m=g(g({},l),a)},a.setDoc=j,a.toast=k,Object.defineProperty(a,"__esModule",{value:!0})});
{
"name": "bulma-toast",
"version": "2.3.0",
"version": "2.3.1",
"description": "Bulma's pure JavaScript extension to display toasts",

@@ -40,3 +40,3 @@ "main": "dist/bulma-toast.cjs.js",

"jest-environment-jsdom-sixteen": "^1.0.3",
"rollup": "^1.23.1",
"rollup": "^2.42.2",
"rollup-plugin-babel": "^4.3.3",

@@ -43,0 +43,0 @@ "rollup-plugin-babel-minify": "^10.0.0",

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