balm-ui
Version:
A modular and customizable UI library based on Material Design and Vue 3
1 lines • 3.56 kB
JavaScript
!function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e(require("vue")):"function"===typeof define&&define.amd?define("$event",["vue"],e):"object"===typeof exports?exports.$event=e(require("vue")):t.$event=e(t.Vue)}("undefined"!==typeof self?self:this,(function(t){return function(){"use strict";var e={154:function(e){e.exports=t}},n={};function o(t){var r=n[t];if(void 0!==r)return r.exports;var i=n[t]={exports:{}};return e[t](i,i.exports,o),i.exports}o.d=function(t,e){for(var n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};o.r(r),o.d(r,{default:function(){return C},install:function(){return x},useBus:function(){return j},useEvent:function(){return O}});var i=o(154);const u=/(?:^\[object\s(.*?)\]$)/;var l=t=>Object.prototype.toString.call(t).replace(u,"$1").toLowerCase();var c=function(){if("function"===typeof window.CustomEvent)return!1;window.CustomEvent=function(t,e){e=e||{bubbles:!1,cancelable:!1,detail:null};const n=document.createEvent("CustomEvent");return n.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),n}};var s=function(t,e,n){n=n||window;let o=!1;n.addEventListener(t,(function(){o||(o=!0,requestAnimationFrame((function(){n.dispatchEvent(new CustomEvent(e)),o=!1})))}))};var a=function(){c(),s("resize","balmResize"),s("scroll","balmScroll")};const f=new Map,d=new Map;function v(t){f.has(t)&&f.delete(t)}const p={on:function(t,e){f.set(t,e)},once:function(t,e){d.set(t,e)},off:function(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];t?Array.isArray(t)?t.forEach((e=>v(t))):v(t):f.clear()},emit:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),o=1;o<e;o++)n[o-1]=arguments[o];d.has(t)?(d.get(t)(...n),d.delete(t)):f.has(t)?f.get(t)(...n):console.warn("[$bus]",`The '${t}' event is not defined`)}};var h=p;const b=()=>{};let g=!1;function y(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const o=t.shift(),r=n?n[o]:this[o];t.length?y.call(this,t,e,r):n?n[o]=e:this[o]=e}function w(t,e,n){"function"===l(new Function)?new Function("value",`this.${e} = value;`).call(t,n):y.call(t,e.split("."),n)}function m(t,e){const n=t.split(".")[0];if(n){const{setupState:o,data:r}=this;if(o.hasOwnProperty(n))w(o,t,e);else{if(!r.hasOwnProperty(n))throw new Error("[$event]: Only support 'setup' or 'data' state.");w(r,t,e)}}}function E(t){let e,n=l(t);return e="function"===n||"generatorfunction"===n?t():t,e}class ${constructor(){const t=(0,i.getCurrentInstance)();this.instance=t}onChange(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:b;return m.call(this.instance,t,e),E(n)}onOpen(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b;return m.call(this.instance,t,!0),E(e)}onClose(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b;return m.call(this.instance,t,!1),E(e)}onShow(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b;return m.call(this.instance,t,!0),E(e)}onHide(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b;return m.call(this.instance,t,!1),E(e)}}function x(t){t.mixin({mounted(){g||(g=!0,a())}}),t.config.globalProperties.$bus=h,t.provide("bus",h),t.config.globalProperties.$throttle=s,t.provide("throttle",s)}const O=()=>new $,j=()=>h;var C={install:x};return r}()}));