limepot-xyz/node_modules/bulma-toast/dist/bulma-toast.cjs.js

7 lines
6.3 KiB
JavaScript
Raw Normal View History

2023-02-16 17:51:43 -07:00
/*!
* bulma-toast 2.4.2
* (c) 2018-present @rfoel <rafaelfr@outlook.com>
* Released under the MIT License.
*/
'use strict';Object.defineProperty(exports,"__esModule",{value:!0});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}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}var baseConfig={duration:2e3,position:"top-right",closeOnClick:!0,opacity:1,single:!1,offsetTop:0,offsetBottom:0,offsetLeft:0,offsetRight:0,extraClasses:""},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,this.extraClasses=b.extraClasses;var d="width:auto;pointer-events:auto;display:inline-flex;white-space:pre-wrap;opacity:".concat(this.opacity,";"),e=["notification",this.extraClasses];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(t