@studiometa/js-toolkit 2.0.0-alpha.4 → 2.0.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Base/index.d.ts +29 -47
- package/Base/index.js +19 -14
- package/Base/managers/ChildrenManager.d.ts +6 -6
- package/Base/managers/ChildrenManager.js +1 -2
- package/Base/managers/EventsManager.d.ts +9 -9
- package/Base/managers/EventsManager.js +18 -33
- package/Base/managers/OptionsManager.d.ts +0 -8
- package/Base/managers/OptionsManager.js +1 -6
- package/Base/managers/RefsManager.js +1 -2
- package/Base/managers/ServicesManager.d.ts +14 -3
- package/Base/managers/ServicesManager.js +30 -12
- package/Base/utils.js +1 -2
- package/README.md +12 -70
- package/decorators/index.js +1 -2
- package/decorators/withBreakpointManager.d.ts +4 -4
- package/decorators/withBreakpointManager.js +1 -2
- package/decorators/withBreakpointObserver.d.ts +2 -2
- package/decorators/withBreakpointObserver.js +1 -2
- package/decorators/withDrag.d.ts +3 -3
- package/decorators/withDrag.js +1 -2
- package/decorators/withExtraConfig.d.ts +3 -3
- package/decorators/withExtraConfig.js +1 -2
- package/decorators/withIntersectionObserver.d.ts +2 -2
- package/decorators/withIntersectionObserver.js +1 -11
- package/decorators/withMountWhenInView.d.ts +3 -3
- package/decorators/withMountWhenInView.js +1 -2
- package/helpers/createApp.d.ts +3 -3
- package/helpers/createApp.js +9 -9
- package/helpers/importOnInteraction.d.ts +3 -3
- package/helpers/importOnInteraction.js +1 -2
- package/helpers/importWhenIdle.d.ts +3 -3
- package/helpers/importWhenIdle.js +1 -2
- package/helpers/importWhenVisible.d.ts +3 -3
- package/helpers/importWhenVisible.js +1 -2
- package/helpers/index.js +1 -2
- package/helpers/utils.js +1 -2
- package/index.d.ts +2 -2
- package/index.js +1 -2
- package/index.modern.js +1 -2
- package/index.umd.js +1 -2
- package/package.json +3 -4
- package/services/Service.js +1 -2
- package/services/drag.js +1 -2
- package/services/index.js +1 -2
- package/services/key.js +1 -2
- package/services/load.d.ts +1 -1
- package/services/load.js +2 -3
- package/services/pointer.js +1 -2
- package/services/raf.js +1 -2
- package/services/resize.js +1 -6
- package/services/scroll.js +1 -2
- package/utils/collide/boundingRectToCircle.js +1 -2
- package/utils/collide/collideCircleCircle.js +1 -2
- package/utils/collide/collideCircleRect.js +1 -2
- package/utils/collide/collidePointCircle.js +1 -2
- package/utils/collide/collidePointRect.js +1 -2
- package/utils/collide/collideRectRect.js +1 -2
- package/utils/collide/index.js +1 -2
- package/utils/css/classes.js +1 -2
- package/utils/css/index.js +1 -2
- package/utils/css/matrix.js +1 -2
- package/utils/css/styles.js +1 -2
- package/utils/css/transition.js +1 -2
- package/utils/debounce.js +1 -2
- package/utils/focusTrap.js +1 -2
- package/utils/history.js +2 -3
- package/utils/index.d.ts +2 -1
- package/utils/index.js +2 -2
- package/utils/keyCodes.js +1 -2
- package/utils/math/clamp.js +1 -2
- package/utils/math/clamp01.js +1 -2
- package/utils/math/damp.js +1 -2
- package/utils/math/index.js +1 -2
- package/utils/math/inertiaFinalValue.js +1 -2
- package/utils/math/lerp.js +1 -2
- package/utils/math/map.js +1 -2
- package/utils/math/round.js +1 -2
- package/utils/memoize.d.ts +30 -0
- package/utils/memoize.js +30 -0
- package/utils/nextFrame.js +1 -2
- package/utils/object/autoBind.js +1 -2
- package/utils/object/getAllProperties.js +1 -2
- package/utils/object/index.js +1 -2
- package/utils/object/isObject.js +1 -2
- package/utils/string/index.js +1 -2
- package/utils/string/withLeadingCharacters.js +1 -2
- package/utils/string/withLeadingSlash.js +1 -2
- package/utils/string/withTrailingCharacters.js +1 -2
- package/utils/string/withTrailingSlash.js +1 -2
- package/utils/string/withoutLeadingCharacters.js +1 -2
- package/utils/string/withoutLeadingCharactersRecursive.js +1 -2
- package/utils/string/withoutLeadingSlash.js +1 -2
- package/utils/string/withoutTrailingCharacters.js +1 -2
- package/utils/string/withoutTrailingCharactersRecursive.js +1 -2
- package/utils/string/withoutTrailingSlash.js +1 -2
- package/utils/throttle.js +1 -2
- package/Base/index.js.map +0 -1
- package/Base/managers/ChildrenManager.js.map +0 -1
- package/Base/managers/EventsManager.js.map +0 -1
- package/Base/managers/OptionsManager.js.map +0 -1
- package/Base/managers/RefsManager.js.map +0 -1
- package/Base/managers/ServicesManager.js.map +0 -1
- package/Base/utils.js.map +0 -1
- package/components/Accordion/Accordion.d.ts +0 -83
- package/components/Accordion/Accordion.js +0 -58
- package/components/Accordion/Accordion.js.map +0 -1
- package/components/Accordion/AccordionItem.d.ts +0 -122
- package/components/Accordion/AccordionItem.js +0 -244
- package/components/Accordion/AccordionItem.js.map +0 -1
- package/components/Accordion/index.d.ts +0 -27
- package/components/Accordion/index.js +0 -19
- package/components/Accordion/index.js.map +0 -1
- package/components/Cursor.d.ts +0 -138
- package/components/Cursor.js +0 -136
- package/components/Cursor.js.map +0 -1
- package/components/Draggable.d.ts +0 -49
- package/components/Draggable.js +0 -43
- package/components/Draggable.js.map +0 -1
- package/components/Modal.d.ts +0 -158
- package/components/Modal.js +0 -186
- package/components/Modal.js.map +0 -1
- package/components/Tabs.d.ts +0 -108
- package/components/Tabs.js +0 -120
- package/components/Tabs.js.map +0 -1
- package/components/index.d.ts +0 -6
- package/components/index.js +0 -7
- package/components/index.js.map +0 -1
- package/decorators/index.js.map +0 -1
- package/decorators/withBreakpointManager.js.map +0 -1
- package/decorators/withBreakpointObserver.js.map +0 -1
- package/decorators/withDrag.js.map +0 -1
- package/decorators/withExtraConfig.js.map +0 -1
- package/decorators/withIntersectionObserver.js.map +0 -1
- package/decorators/withMountWhenInView.js.map +0 -1
- package/helpers/createApp.js.map +0 -1
- package/helpers/importOnInteraction.js.map +0 -1
- package/helpers/importWhenIdle.js.map +0 -1
- package/helpers/importWhenVisible.js.map +0 -1
- package/helpers/index.js.map +0 -1
- package/helpers/utils.js.map +0 -1
- package/index.js.map +0 -1
- package/index.modern.js.map +0 -1
- package/index.umd.js.map +0 -1
- package/services/Service.js.map +0 -1
- package/services/drag.js.map +0 -1
- package/services/index.js.map +0 -1
- package/services/key.js.map +0 -1
- package/services/load.js.map +0 -1
- package/services/pointer.js.map +0 -1
- package/services/raf.js.map +0 -1
- package/services/resize.js.map +0 -1
- package/services/scroll.js.map +0 -1
- package/utils/collide/boundingRectToCircle.js.map +0 -1
- package/utils/collide/collideCircleCircle.js.map +0 -1
- package/utils/collide/collideCircleRect.js.map +0 -1
- package/utils/collide/collidePointCircle.js.map +0 -1
- package/utils/collide/collidePointRect.js.map +0 -1
- package/utils/collide/collideRectRect.js.map +0 -1
- package/utils/collide/index.js.map +0 -1
- package/utils/css/classes.js.map +0 -1
- package/utils/css/index.js.map +0 -1
- package/utils/css/matrix.js.map +0 -1
- package/utils/css/styles.js.map +0 -1
- package/utils/css/transition.js.map +0 -1
- package/utils/debounce.js.map +0 -1
- package/utils/focusTrap.js.map +0 -1
- package/utils/history.js.map +0 -1
- package/utils/index.js.map +0 -1
- package/utils/keyCodes.js.map +0 -1
- package/utils/math/clamp.js.map +0 -1
- package/utils/math/clamp01.js.map +0 -1
- package/utils/math/damp.js.map +0 -1
- package/utils/math/index.js.map +0 -1
- package/utils/math/inertiaFinalValue.js.map +0 -1
- package/utils/math/lerp.js.map +0 -1
- package/utils/math/map.js.map +0 -1
- package/utils/math/round.js.map +0 -1
- package/utils/nextFrame.js.map +0 -1
- package/utils/object/autoBind.js.map +0 -1
- package/utils/object/getAllProperties.js.map +0 -1
- package/utils/object/index.js.map +0 -1
- package/utils/object/isObject.js.map +0 -1
- package/utils/string/index.js.map +0 -1
- package/utils/string/withLeadingCharacters.js.map +0 -1
- package/utils/string/withLeadingSlash.js.map +0 -1
- package/utils/string/withTrailingCharacters.js.map +0 -1
- package/utils/string/withTrailingSlash.js.map +0 -1
- package/utils/string/withoutLeadingCharacters.js.map +0 -1
- package/utils/string/withoutLeadingCharactersRecursive.js.map +0 -1
- package/utils/string/withoutLeadingSlash.js.map +0 -1
- package/utils/string/withoutTrailingCharacters.js.map +0 -1
- package/utils/string/withoutTrailingCharactersRecursive.js.map +0 -1
- package/utils/string/withoutTrailingSlash.js.map +0 -1
- package/utils/throttle.js.map +0 -1
package/index.modern.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
function e(){return(e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n])}return e}).apply(this,arguments)}var t=0;function i(e){return"__private_"+t+++"_"+e}function n(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}function s(e,t=[],i=null){const n=Object.getPrototypeOf(e);if(n===Object.prototype)return t;let r=Object.getOwnPropertyNames(n);return"function"==typeof i&&(r=r.filter(e=>i(e,n))),r=r.map(e=>[e,n]).reduce((e,t)=>[...e,t],t),s(n,r,i)}function r(e,t){return"function"==typeof e[t]}function o(e,t,...i){return e.__debug("callMethod",t,...i),"destroyed"===t&&!e.$isMounted||"mounted"===t&&e.$isMounted?(e.__debug("not",t,"because the method has already been triggered once."),e):(e.$emit(t,...i),r(e,t)?(e[t].call(e,...i),e.__debug(t,e,...i),e):e)}function a(e,t=document){const i=`[data-component="${e}"]`;let n=[];try{n=Array.from(t.querySelectorAll(i))}catch(e){}return 0===n.length&&(n=Array.from(t.querySelectorAll(e))),n}class h{get registeredNames(){return Object.keys(this).filter(e=>!e.startsWith("__"))}constructor(e,t,i,n){this.__base=e,this.__element=t,this.__components=i,this.__eventsManager=n}registerAll(){Object.entries(this.__components).forEach(([e,t])=>this.__register(e,t))}__register(e,t){Object.defineProperty(this,e,{enumerable:!0,configurable:!0,get:()=>{const i=a(e,this.__element);return 0===i.length?[]:i.map(i=>this.__getChild(i,t,e)).filter(e=>"terminated"!==e)}})}__getChild(e,t,i){if(e.__base__)return e.__base__;if("$isBase"in t){const i=new t(e);return Object.defineProperty(i,"$parent",{get:()=>this.__base}),i}return t(this.__base).then(t=>{var n;return this.__getChild(e,null!=(n=t.default)?n:t,i)})}mountAll(){this.__triggerHookForAll("$mount")}updateAll(){this.__triggerHookForAll("$update")}destroyAll(){this.__triggerHookForAll("$destroy")}__triggerHookForAll(e){this.registeredNames.forEach(t=>{this[t].forEach(i=>{i instanceof Promise?i.then(i=>this.__triggerHook(e,i,t)):this.__triggerHook(e,i,t)})})}__triggerHook(e,t,i){"$update"!==e||t.$isMounted||(e="$mount"),"$update"!==e&&"$destroy"!==e||this.__eventsManager.unbindChild(i,t),"$update"!==e&&"$mount"!==e||this.__eventsManager.bindChild(i,t),t[e]()}}class d{constructor(e,t,i,n){this.__element=t,this.__refs=i,this.__base=e,this.__eventsManager=n}registerAll(){this.__refs.forEach(e=>this.__register(e))}unregisterAll(){this.__refs.forEach(e=>this.__unregister(e))}__register(e){const t=e.endsWith("[]"),i=d.normalizeRefName(e),n=Array.from(this.__element.querySelectorAll(`[data-ref="${e}"]`)).filter(e=>this.__filterRefsBelongingToInstance(e));!t&&n.length>1&&console.warn(`[${this.__base.$options.name}]`,`The "${e}" ref has been found multiple times.`,"Did you forgot to add the `[]` suffix to its name?"),this.__eventsManager.bindRef(e,n),Object.defineProperty(this,i,{value:t||n.length>1?n:n[0],enumerable:!0,configurable:!0})}__unregister(e){const t=d.normalizeRefName(e),i=Array.isArray(this[t])?this[t]:[this[t]];this.__eventsManager.unbindRef(e,i)}static normalizeRefName(e){return e.endsWith("[]")?e.replace(/\[\]$/,""):e}__filterRefsBelongingToInstance(e){let t=e.parentElement;for(;t&&void 0===t.dataset.component;)t=t.parentElement;return null===t||t===this.__element}}class c{constructor(){this.callbacks=new Map,this.isInit=!1}get props(){throw new Error("The `props` getter must be implemented.")}init(){throw new Error("The `init` method must be implemented.")}kill(){throw new Error("The `kill` method must be implemented.")}add(e,t){if(this.has(e))throw new Error(`A callback with the key \`${e}\` has already been registered.`);return 0!==this.callbacks.size||this.isInit||(this.init(),this.isInit=!0),this.callbacks.set(e,t),this}has(e){return this.callbacks.has(e)}get(e){return this.callbacks.get(e)}remove(e){return this.callbacks.delete(e),0===this.callbacks.size&&this.isInit&&(this.kill(),this.isInit=!1),this}trigger(...e){return this.callbacks.forEach(function(t){t(...e)}),this}}function u(e){return"undefined"!=typeof TouchEvent&&e instanceof TouchEvent}class l extends c{constructor(...e){super(...e),this.isDown=!1,this.y=window.innerHeight/2,this.yLast=window.innerHeight/2,this.x=window.innerWidth/2,this.xLast=window.innerWidth/2,this.hasRaf=!1}init(){document.documentElement.addEventListener("mouseenter",this,{once:!0,capture:!0});const e={passive:!0,capture:!0};return document.addEventListener("mousemove",this,e),document.addEventListener("touchmove",this,e),document.addEventListener("mousedown",this,e),document.addEventListener("touchstart",this,e),document.addEventListener("mouseup",this,e),document.addEventListener("touchend",this,e),this}handleEvent(e){switch(e.type){case"mouseenter":case"mousemove":case"touchmove":this.handler(e);break;case"mousedown":case"touchstart":this.downHandler();break;case"mouseup":case"touchend":this.upHandler()}}kill(){return document.removeEventListener("mousemove",this),document.removeEventListener("touchmove",this),document.removeEventListener("mousedown",this),document.removeEventListener("touchstart",this),document.removeEventListener("mouseup",this),document.removeEventListener("touchend",this),this}handler(e){this.updateValues(e),this.trigger(this.props)}downHandler(){this.isDown=!0,this.trigger(this.props)}upHandler(){this.isDown=!1,this.trigger(this.props)}updateValues(e){var t,i;this.event=e,this.yLast=this.y,this.xLast=this.x;const n=u(e)?null==(t=e.touches[0])?void 0:t.clientY:e.clientY;n!==this.y&&(this.y=n);const s=u(e)?null==(i=e.touches[0])?void 0:i.clientX:e.clientX;s!==this.x&&(this.x=s)}get props(){return{event:this.event,isDown:this.isDown,x:this.x,y:this.y,changed:{x:this.x!==this.xLast,y:this.y!==this.yLast},last:{x:this.xLast,y:this.yLast},delta:{x:this.x-this.xLast,y:this.y-this.yLast},progress:{x:this.x/window.innerWidth,y:this.y/window.innerHeight},max:{x:window.innerWidth,y:window.innerHeight}}}}let p=null;function m(){return p||(p=new l),{add:p.add.bind(p),remove:p.remove.bind(p),has:p.has.bind(p),props:()=>p.props}}class f extends c{constructor(){super(),this.isTicking=!1,this.id=0,this.raf="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):setTimeout,this.cancelRaf="undefined"!=typeof window&&window.cancelAnimationFrame?window.cancelAnimationFrame.bind(window):clearTimeout,this.loop=this.loop.bind(this)}init(){return this.isTicking=!0,this.loop(),this}loop(){this.trigger(this.props),this.isTicking&&(this.id=this.raf(this.loop))}kill(){return this.cancelRaf(this.id),this.isTicking=!1,this}get props(){return{time:window.performance.now()}}}let g=null;function _(){return g||(g=new f),{add:g.add.bind(g),remove:g.remove.bind(g),has:g.has.bind(g),props:function(){return g.props}}}function b(e,t=300){let i;return function(...n){clearTimeout(i),i=setTimeout(()=>{e(...n)},t)}}class y extends c{init(){return this.handler=b(()=>{this.trigger(this.props)}).bind(this),window.addEventListener("resize",this.handler),this}kill(){return window.removeEventListener("resize",this.handler),this}get props(){const e={width:window.innerWidth,height:window.innerHeight,ratio:window.innerWidth/window.innerHeight,orientation:"square"};return e.ratio>1&&(e.orientation="landscape"),e.ratio<1&&(e.orientation="portrait"),this.breakpointElement&&(e.breakpoint=this.breakpoint,e.breakpoints=this.breakpoints),e}get breakpointElement(){return document.querySelector("[data-breakpoint]")||null}get breakpoint(){return window.getComputedStyle(this.breakpointElement,"::before").getPropertyValue("content").replace(/"/g,"")}get breakpoints(){return window.getComputedStyle(this.breakpointElement,"::after").getPropertyValue("content").replace(/"/g,"").split(",")}get canUseResizeObserver(){return void 0!==window.ResizeObserver}}let v=null;function w(){return v||(v=new y),{add:v.add.bind(v),remove:v.remove.bind(v),has:v.has.bind(v),props:()=>v.props}}class $ extends c{constructor(...e){super(...e),this.y=window.pageYOffset,this.yLast=window.pageYOffset,this.x=window.pageXOffset,this.xLast=window.pageXOffset}init(){return document.addEventListener("scroll",this,{passive:!0,capture:!0}),this}get debouncedHandler(){const e=b(()=>{this.trigger(this.props)},0);return Object.defineProperty(this,"debouncedHandler",{value:e}),e}handleEvent(){this.trigger(this.props),this.debouncedHandler()}kill(){return document.removeEventListener("scroll",this),this}get props(){return this.yLast=this.y,this.xLast=this.x,window.pageYOffset!==this.y&&(this.y=window.pageYOffset),window.pageXOffset!==this.x&&(this.x=window.pageXOffset),{x:this.x,y:this.y,changed:{x:this.x!==this.xLast,y:this.y!==this.yLast},last:{x:this.xLast,y:this.yLast},delta:{x:this.x-this.xLast,y:this.y-this.yLast},progress:{x:0===this.max.x?1:this.x/this.max.x,y:0===this.max.y?1:this.y/this.max.y},direction:{x:this.x>this.xLast?"RIGHT":this.x<this.xLast?"LEFT":"NONE",y:this.y>this.yLast?"DOWN":this.y<this.yLast?"UP":"NONE"},max:this.max}}get max(){return{x:(document.scrollingElement||document.body).scrollWidth-window.innerWidth,y:(document.scrollingElement||document.body).scrollHeight-window.innerHeight}}}let E=null;function x(){return E||(E=new $),{add:E.add.bind(E),remove:E.remove.bind(E),has:E.has.bind(E),props:()=>E.props}}var k={ENTER:13,SPACE:32,TAB:9,ESC:27,LEFT:37,UP:38,RIGHT:39,DOWN:40};class O extends c{constructor(...e){super(...e),this.event={},this.triggered=0,this.previousEvent={}}init(){return this.handler=e=>{this.event=e,this.trigger(this.props)},document.addEventListener("keydown",this.handler,{passive:!1}),document.addEventListener("keyup",this.handler,{passive:!1}),this}kill(){return document.removeEventListener("keydown",this.handler),document.removeEventListener("keyup",this.handler),this}get props(){const t=Object.entries(k).reduce((e,[t,i])=>(e[t]=i===this.event.keyCode,e),{});return this.previousEvent.type||(this.triggered=0),"keydown"===this.event.type&&"keydown"===this.previousEvent.type?this.triggered+=1:this.triggered=1,this.previousEvent=this.event,e({event:this.event,triggered:this.triggered,direction:"keydown"===this.event.type?"down":"up",isUp:"keyup"===this.event.type,isDown:"keydown"===this.event.type},t)}}let A=null;function L(){return A||(A=new O),{add:A.add.bind(A),remove:A.remove.bind(A),has:A.has.bind(A),props:()=>A.props}}class N extends c{init(){return this.handler=()=>{this.trigger(this.props)},window.addEventListener("load",this.handler),this}kill(){return window.removeEventListener("load",this.handler),this}get props(){return{}}}let M=null;function j(){return M||(M=new N),{add:M.add.bind(M),remove:M.remove.bind(M),has:M.has.bind(M),props:function(){return M.props}}}const T={scrolled:x,resized:w,ticked:_,moved:m,keyed:L,loaded:j};class B{constructor(e){this.__base=e}has(e){if(!r(this.__base,e)&&!T[e])return!1;const{has:t}=T[e]();return t(this.__base.$id)}enable(e){if(this.has(e))return this.disable.bind(this,e);if(!r(this.__base,e)||!T[e])return function(){};const{add:t}=T[e](),i=this;return t(this.__base.$id,function(...t){o(i.__base,e,...t)}),this.disable.bind(this,e)}enableAll(){return Object.keys(T).map(e=>this.enable(e))}disableAll(){Object.keys(T).forEach(e=>{this.disable(e)})}disable(e){if(!T[e])return;const{remove:t}=T[e]();t(this.__base.$id)}register(e,t){T[e]=t}unregister(e){delete T[e]}}class P{constructor(e,t){this.__methodsCache=new WeakMap,this.__rootElementHandler={handleEvent:e=>{const t=`on${P.normalizeName(e.type)}`;"function"==typeof this.__base[t]&&this.__base[t](e)}},this.__refsHandler={handleEvent:e=>{const t=e.currentTarget,i=d.normalizeRefName(t.dataset.ref),n=`on${P.normalizeName(i)}${P.normalizeName(e.type)}`;if("function"==typeof this.__base[n]){let s=0;Array.isArray(this.__base.$refs[i])&&(s=this.__base.$refs[i].indexOf(t)),this.__base[n](e,s)}}},this.__childrenHandler={handleEvent:e=>{const t=e.currentTarget.__base__;let i,n=0;const s=this.__base.$children;s.registeredNames.find(e=>!!s[e].includes(t)&&(i=e,n=s[e].indexOf(t),!0));const r=`on${P.normalizeName(i)}${P.normalizeName(e.type)}`;if("function"==typeof this.__base[r]){var o;const t=null!=(o=e.detail)?o:[];this.__base[r](...t,n,e)}}},this.__rootElement=e,this.__base=t}__manageRef(e,t,i="add"){const n=`${i}EventListener`;this.__getEventMethodsByName(e).forEach(i=>{const s=this.__getEventNameByMethod(i,e);t.forEach(e=>e[n](s,this.__refsHandler))})}bindRef(e,t){this.__manageRef(e,t)}unbindRef(e,t){this.__manageRef(e,t,"remove")}__manageChild(e,t,i="add"){const n="add"===i?"$on":"$off";this.__getEventMethodsByName(e).forEach(i=>{const s=this.__getEventNameByMethod(i,e);t[n](s,this.__childrenHandler)})}bindChild(e,t){this.__manageChild(e,t)}unbindChild(e,t){this.__manageChild(e,t,"remove")}__manageRootElement(e="add"){const t=`${e}EventListener`;this.__getEventMethodsByName().forEach(e=>{const i=this.__getEventNameByMethod(e);this.__rootElement[t](i,this.__rootElementHandler)})}bindRootElement(){this.__manageRootElement()}unbindRootElement(){this.__manageRootElement("remove")}__getEventNameByMethod(e,t=""){const i=P.normalizeName(t),n=new RegExp(`^on${i}([A-Z].*)$`),[,s]=e.match(n);return P.normalizeEventName(s)}__getEventMethodsByName(e=""){const t=P.normalizeName(e),i=new RegExp(`^on${t}[A-Z].*$`);let n=this.__methodsCache.get(i);return n||(n=s(this.__base,[],e=>i.test(e)),this.__methodsCache.set(i,n)),n.reduce((e,[t])=>(e.includes(t)||e.push(t),e),[])}static normalizeName(e){return e.replace(/[A-Z]([A-Z].*)/g,e=>e.toLowerCase()).replace(/[^a-zA-Z\d\s:]/g," ").replace(/(^\w|\s+\w)/g,e=>e.trim().toUpperCase()).trim()}static normalizeEventName(e){return e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`).replace(/^-/,"")}}var H=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===C}(e)}(e)},C="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function R(e,t){return!1!==t.clone&&t.isMergeableObject(e)?W(Array.isArray(e)?[]:{},e,t):e}function I(e,t,i){return e.concat(t).map(function(e){return R(e,i)})}function S(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return e.propertyIsEnumerable(t)}):[]}(e))}function z(e,t){try{return t in e}catch(e){return!1}}function W(e,t,i){(i=i||{}).arrayMerge=i.arrayMerge||I,i.isMergeableObject=i.isMergeableObject||H,i.cloneUnlessOtherwiseSpecified=R;var n=Array.isArray(t);return n===Array.isArray(e)?n?i.arrayMerge(e,t,i):function(e,t,i){var n={};return i.isMergeableObject(e)&&S(e).forEach(function(t){n[t]=R(e[t],i)}),S(t).forEach(function(s){(function(e,t){return z(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,s)||(n[s]=z(e,s)&&i.isMergeableObject(t[s])?function(e,t){if(!t.customMerge)return W;var i=t.customMerge(e);return"function"==typeof i?i:W}(s,i)(e[s],t[s],i):R(t[s],i))}),n}(e,t,i):R(t,i)}W.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(e,i){return W(e,i,t)},{})};var D=W;class F{constructor(e,t,i){var n,s;return this.__values={},this.__defaultValues={String:"",Number:0,Boolean:!1,Array:()=>[],Object:()=>({})},this.name="Base",this.debug=!1,this.log=!1,this.__element=e,this.name=i.name,t.debug={type:Boolean,default:null!=(n=i.debug)&&n},t.log={type:Boolean,default:null!=(s=i.log)&&s},Object.entries(t).forEach(([e,t])=>{this.__register(e,t)}),this}__register(e,t){const i=!F.types.includes(t),n=i?t.type:t;if(!F.types.includes(n))throw new Error(`The "${e}" option has an invalid type. The allowed types are: String, Number, Boolean, Array and Object.`);const s=i?t.default:this.__defaultValues[n.name];if((n===Array||n===Object)&&"function"!=typeof s)throw new Error(`The default value for options of type "${n.name}" must be returned by a function.`);Object.defineProperty(this,e,{get:()=>this.get(e,n,s),set:t=>{this.set(e,n,t,s)},enumerable:!0})}get(e,t,i){const n=F.__getPropertyName(e),s=this.__hasProperty(n);if(t===Boolean){if(i){const t=F.__getPropertyName(e,"No");return!this.__hasProperty(t)}return s||i}const r=this.__element.dataset[n];if(t===Number)return s?Number(r):i;if(t===Array||t===Object){const n=D(i(),s?JSON.parse(r):this.__defaultValues[t.name]());return this.__values[e]||(this.__values[e]=n),this.__values[e]}return s?r:i}set(e,t,i,n){const s=F.__getPropertyName(e);if(i.constructor.name!==t.name){const n=Array.isArray(i)||function(e){return"object"==typeof e&&!!e&&"[object Object]"===e.toString()}(i)?JSON.stringify(i):i;throw new TypeError(`The "${n}" value for the "${e}" option must be of type "${t.name}"`)}switch(t){case Boolean:if(n){const t=F.__getPropertyName(e,"No");i?delete this.__element.dataset[t]:this.__element.dataset[t]=""}else i?this.__element.dataset[s]="":delete this.__element.dataset[s];break;case Array:case Object:this.__values[e]=i;break;default:this.__element.dataset[s]=i}}__hasProperty(e){return void 0!==this.__element.dataset[e]}static __getPropertyName(e,t=""){const i=e+t;if(F.__propertyNameCache.has(i))return F.__propertyNameCache.get(i);const n=`option${t}${e.replace(/^\w/,e=>e.toUpperCase())}`;return F.__propertyNameCache.set(i,n),n}static __isPrimitive(e){return"string"==typeof e||"number"==typeof e||"symbol"==typeof e||"boolean"==typeof e}}F.types=[String,Number,Boolean,Array,Object],F.__propertyNameCache=new Map;let q=0;const V=function(){};class G{get __excludeFromAutoBind(){return["$mount","$update","$destroy","$terminate","$log","$on","$once","$off","$emit","mounted","loaded","ticked","resized","moved","keyed","scrolled","destroyed","terminated"]}get __config(){let t=Object.getPrototypeOf(this),{config:i}=t.constructor;for(;t.constructor.config&&t.constructor.$isBase;)i=e({},t.constructor.config,i),t.constructor.config.options&&(i.options=e({},t.constructor.config.options,i.options)),t=Object.getPrototypeOf(t);return i}get $services(){const e=this.__services;return this.$emit("get:services",e),e}get $refs(){const e=this.__refs;return this.$emit("get:refs",e),e}get $options(){const e=this.__options;return this.$emit("get:options",e),e}get $children(){this.__debug("before:getChildren",this.$el,this.__config.components);const e=this.__children;return this.$emit("get:children",e),this.__debug(this,"after:getChildren",e),e}get $log(){return this.__options.log?window.console.log.bind(window,`[${this.__config.name}]`):V}get __debug(){return this.__options.debug&&void 0!==window.__DEV__&&window.__DEV__?window.console.log.bind(window,`[debug] [${this.$id}]`):V}constructor(e){if(this.$parent=null,this.$isMounted=!1,!e)throw new Error("The root element must be defined.");const{__config:t}=this;if(!t)throw new Error("The `config` static property must be defined.");if(!t.name)throw new Error("The `config.name` property is required.");return this.$id=`${t.name}-${q}`,q+=1,this.$el=e,"__base__"in this.$el||Object.defineProperty(this.$el,"__base__",{get:()=>this,configurable:!0}),this.__options=new F(e,t.options||{},t),this.__services=new B(this),this.__events=new P(e,this),this.__children=new h(this,e,t.components||{},this.__events),this.__refs=new d(this,e,t.refs||[],this.__events),function(e,t){const{exclude:i,include:n}=t||{};s(e).filter(([e])=>"constructor"!==e&&(e=>{const t=t=>"string"==typeof t?e===t:t.test(e);return n?n.some(t):!i||!i.some(t)})(e)).forEach(([t,i])=>{const n=Object.getOwnPropertyDescriptor(i,t);n&&"function"==typeof n.value&&(e[t]=e[t].bind(e))})}(this,{exclude:[...this.__excludeFromAutoBind]}),this.__debug("constructor",this),this}$mount(){return this.__debug("$mount"),this.$children.registerAll(),this.$refs.registerAll(),this.__events.bindRootElement(),this.$services.enableAll(),this.$children.mountAll(),o(this,"mounted"),this.$isMounted=!0,this}$update(){return this.__debug("$update"),this.$refs.unregisterAll(),this.$services.disableAll(),this.$children.registerAll(),this.$refs.registerAll(),this.$services.enableAll(),this.$children.updateAll(),o(this,"updated"),this}$destroy(){return this.__debug("$destroy"),this.__events.unbindRootElement(),this.$refs.unregisterAll(),this.$services.disableAll(),this.$children.destroyAll(),o(this,"destroyed"),this.$isMounted=!1,this}$terminate(){this.__debug("$terminate"),this.$destroy(),o(this,"terminated"),Object.defineProperty(this.$el,"__base__",{value:"terminated",configurable:!1,writable:!1})}static $factory(e){if(!e)throw new Error("The $factory method requires a component’s name or selector to be specified.");return a(e).map(e=>new this(e).$mount())}$on(e,t,i){return this.__debug("$on",e,t,i),this.$el.addEventListener(e,t,i),()=>{this.$off(e,t,i)}}$off(e,t,i){this.__debug("$off",e,t),this.$el.removeEventListener(e,t,i)}$emit(e,...t){this.__debug("$emit",e,t),this.$el.dispatchEvent(new CustomEvent(e,{detail:t}))}}function Y(e){const{breakpoint:t}=w().props();e.forEach(([e,i])=>{e.includes(t)&&!i.$isMounted?setTimeout(()=>i.$mount(),0):!e.includes(t)&&i.$isMounted&&i.$destroy()})}G.$isBase=!0;const X=new WeakMap;function U(e,t){if(!Array.isArray(t))throw new Error("[withBreakpointManager] The `breakpoints` parameter must be an array.");if(t.length<2)throw new Error("[withBreakpointManager] You must define at least 2 breakpoints.");const{add:i,props:n}=w();if(!n().breakpoint)throw new Error("The `BreakpointManager` class requires breakpoints to be defined.");return class extends e{constructor(e){return super(e),X.has(this)||X.set(this,function(e,t){return t.map(([t,i])=>{const n=new i(e.$el);return Object.defineProperty(n,"$parent",{get:()=>e.$parent}),[t,n]})}(this,t)),i(`BreakpointManager-${this.$id}`,()=>{Y(X.get(this))}),this.instances=X.get(this),this}$mount(){return super.$mount(),Y(X.get(this)),this}$destroy(){return Array.isArray(X.get(this))&&X.get(this).forEach(([,e])=>{e.$destroy()}),super.$destroy()}}}function Z(e,t=w().props().breakpoint){const{activeBreakpoints:i,inactiveBreakpoints:n}=e.$options,s=i&&i.split(" ").includes(t),r=n&&n.split(" ").includes(t);return i&&s||n&&!r?"$mount":"$destroy"}function J(e){const{activeBreakpoints:t,inactiveBreakpoints:i}=e.$options;return Boolean(t||i)}function K(e,t){!function(e){const{activeBreakpoints:t,inactiveBreakpoints:i,name:n}=e.$options;if(t&&i)throw new Error(`[${n}] Incorrect configuration: the \`activeBreakpoints\` and \`inactiveBreakpoints\` are not compatible.`)}(t);const{add:i,has:n}=w();n(e)||i(e,function({breakpoint:e}){const i=Z(t,e);"$destroy"===i&&t.$isMounted?t[i]():"$mount"!==i||t.$isMounted||setTimeout(()=>t[i](),0)})}function Q(t){var i,n,s,r,o;return n=i=class extends t{constructor(e){super(e);const{remove:t,props:i}=w(),{name:n}=this.$options;if(!i().breakpoint)throw new Error(`[${n}] The \`BreakpointObserver\` class requires breakpoints to be defined.`);const s=`BreakpointObserver-${this.$id}`;return new MutationObserver(([e])=>{if("attributes"===e.type&&("data-options"===e.attributeName||e.attributeName.startsWith("data-option-"))){if(!J(this))return this.$mount(),void t(s);K(s,this)}}).observe(this.$el,{attributes:!0}),J(this)?(K(s,this),this):this}$mount(){return J(this)?"$mount"===Z(this)?super.$mount():this:super.$mount()}},i.config=e({},t.config||{},{name:`${null!=(s=null==t||null==(r=t.config)?void 0:r.name)?s:""}WithBreakpointObserver`,options:e({},(null==t||null==(o=t.config)?void 0:o.options)||{},{activeBreakpoints:String,inactiveBreakpoints:String})}),n}function ee(e,t,i=.85){if(i>=1||i<=0)throw new Error(`The \`factor\` parameter must be a number greater than 0 and smaller than 1, \`${i}\` given.`);let n=t,s=e;for(;Math.abs(n)>.1;)s+=n,n*=i;return s}let te=0;class ie extends c{constructor(t,i={}){return super(),this.isGrabbing=!1,this.hasInertia=!1,this.x=0,this.y=0,this.delta={x:0,y:0},this.origin={x:0,y:0},this.distance={x:0,y:0},this.final={x:0,y:0},this.options={factor:.85},te+=1,this.id=`drag-${te}`,this.target=t,this.options=e({},this.options,i),this.pointerHandler=this.pointerHandler.bind(this),this.rafHandler=this.rafHandler.bind(this),this}init(){const e={passive:!0};return this.target.addEventListener("mousedown",this,e),this.target.addEventListener("touchstart",this,e),m().add(this.id,this.pointerHandler),this}kill(){return this.target.removeEventListener("mousemove",this),this.target.removeEventListener("touchmove",this),m().remove(this.id),this}handleEvent(e){const t=e instanceof MouseEvent?e.clientX:e.touches[0].clientX,i=e instanceof MouseEvent?e.clientY:e.touches[0].clientY;this.start(t,i)}start(e,t){this.x=e,this.y=t,this.origin.x=e,this.origin.y=t,this.delta.x=0,this.delta.y=0,this.distance.x=0,this.distance.y=0,this.final.x=e,this.final.y=t,this.mode="start",this.isGrabbing=!0,this.trigger(this.props)}drop(){this.isGrabbing=!1,this.mode="drop",this.hasInertia=!0,this.final.x=ee(this.x,this.delta.x,this.options.factor),this.final.y=ee(this.y,this.delta.y,this.options.factor),this.trigger(this.props),setTimeout(()=>{const e=_();e.remove(this.id),e.add(this.id,this.rafHandler)},0)}stop(){_().remove(this.id),this.hasInertia=!1,this.mode="stop",this.trigger(this.props)}rafHandler(){this.isGrabbing||(this.x+=this.delta.x,this.y+=this.delta.y,this.distance.x=this.x-this.origin.x,this.distance.y=this.y-this.origin.y,this.delta.x*=this.options.factor,this.delta.y*=this.options.factor,"inertia"!==this.mode&&(this.mode="inertia"),this.trigger(this.props),Math.abs(this.delta.x)<.1&&Math.abs(this.delta.y)<.1&&this.stop())}pointerHandler(e){this.isGrabbing&&(this.x=e.x,this.y=e.y,this.delta.x=e.delta.x,this.delta.y=e.delta.y,this.final.x=e.x,this.final.y=e.y,this.distance.x=this.x-this.origin.x,this.distance.y=this.y-this.origin.y,"drag"!==this.mode&&(this.mode="drag"),this.trigger(this.props),e.isDown||this.drop())}get props(){return{target:this.target,mode:this.mode,isGrabbing:this.isGrabbing,hasInertia:this.hasInertia,x:this.x,y:this.y,delta:this.delta,origin:this.origin,distance:this.distance,final:this.final}}}const ne=new WeakMap;function se(e,t){let i=ne.get(e);return i||(i=new ie(e,t),ne.set(e,i)),{add:i.add.bind(i),remove:i.remove.bind(i),has:i.has.bind(i),props:()=>i.props}}const re=["target"];function oe(e,t={target(){return this.$el}}){return class extends e{constructor(e){super(e),this.$on("mounted",()=>{const{target:e}=t,i=function(e,t){if(null==e)return{};var i,n,s={},r=Object.keys(e);for(n=0;n<r.length;n++)t.indexOf(i=r[n])>=0||(s[i]=e[i]);return s}(t,re),n=se.bind(void 0,e.call(this),i);this.$services.register("dragged",n),this.$services.enable("dragged")}),this.$on("destroyed",()=>{this.$services.disable("dragged"),this.$services.unregister("dragged")})}}}function ae(e,t,i={}){var n,s;const r=D(e.config,t,i);return r.name===e.config.name&&(r.name=`${e.config.name}WithExtraConfig`),s=n=class extends e{},n.config=r,s}function he(e){return[...new Array(e+1)].map((t,i)=>i/e)}function de(t,i={threshold:he(100)}){var n,s,r,o,a;return s=n=class extends t{get __excludeFromAutoBind(){return[...super.__excludeFromAutoBind||[],"intersected"]}constructor(t){if(super(t),!this.intersected||"function"!=typeof this.intersected)throw new Error("[withIntersectionObserver] The `intersected` method must be defined.");return this.$observer=new IntersectionObserver(e=>{this.__debug("intersected",e),this.$emit("intersected",e),this.intersected(e)},e({},i,this.$options.intersectionObserver||{})),this.$isMounted&&this.$observer.observe(this.$el),this.$on("mounted",()=>{this.$observer.observe(this.$el)}),this.$on("destroyed",()=>{this.$observer.unobserve(this.$el)}),this}},n.config=e({},t.config||{},{name:`${null!=(r=null==t||null==(o=t.config)?void 0:o.name)?r:""}WithIntersectionObserver`,options:e({},(null==t||null==(a=t.config)?void 0:a.options)||{},{intersectionObserver:Object})}),s}function ce(t,s={threshold:[0,1]}){var r,o,a,h,d,c,u;return o=i("isVisible"),a=i("observer"),h=r=class extends t{constructor(t){return super(t),Object.defineProperty(this,o,{writable:!0,value:!1}),Object.defineProperty(this,a,{writable:!0,value:void 0}),n(this,a)[a]=new IntersectionObserver(e=>{const t=e.reduce((e,t)=>e||t.isIntersecting,!1);n(this,o)[o]!==t&&(n(this,o)[o]=t,this[t?"$mount":"$destroy"]())},e({},s,this.$options.intersectionObserver)),n(this,a)[a].observe(this.$el),this.$on("terminated",()=>{n(this,a)[a].disconnect()}),this}$mount(){return n(this,o)[o]&&super.$mount(),this}},r.config=e({},t.config||{},{name:`${null!=(d=null==t||null==(c=t.config)?void 0:c.name)?d:""}WithMountWhenInView`,options:e({},(null==t||null==(u=t.config)?void 0:u.options)||{},{intersectionObserver:Object})}),h}function ue(e,t){let i,n="complete"===document.readyState;return n?i=new e(t).$mount():document.addEventListener("readystatechange",()=>{"complete"===document.readyState&&(i=new e(t).$mount(),n=!0)}),function(){return n?Promise.resolve(i):new Promise(e=>{document.addEventListener("readystatechange",()=>{"complete"===document.readyState&&setTimeout(()=>e(i),0)})})}}function le(e,t){return"string"==typeof e?a(e,t):Array.isArray(e)?e:[e]}function pe(e,t,i,n){const s="string"==typeof i?[i]:i;let r;return new Promise(i=>{const o=le(t,null==n?void 0:n.$el),a={capture:!0,passive:!0,once:!0},h=()=>{(t=>{e().then(e=>{r="default"in e?e.default:e,t(r)})})(i)};o.forEach(e=>{s.forEach(t=>{e.addEventListener(t,h,a)})})})}function me(e,t){let i;const n=t=>{e().then(e=>{i="default"in e?e.default:e,t(i)})};return new Promise(e=>{var i;const s=null!=(i=null==t?void 0:t.timeout)?i:1;"requestIdleCallback"in window?window.requestIdleCallback(()=>{setTimeout(()=>{n(e)},0)},{timeout:null==t?void 0:t.timeout}):setTimeout(()=>{n(e)},s)})}function fe(e,t,i,n={}){let s;return new Promise(r=>{const o=new IntersectionObserver(t=>{t.some(e=>e.isIntersecting)&&setTimeout(()=>{((t,i)=>{e().then(e=>{s="default"in e?e.default:e,t(s),o.disconnect()})})(r)},0)},n);le(t,null==i?void 0:i.$el).forEach(e=>o.observe(e))})}export{G as Base,ue as createApp,pe as importOnInteraction,me as importWhenIdle,fe as importWhenVisible,se as useDrag,L as useKey,j as useLoad,m as usePointer,_ as useRaf,w as useResize,x as useScroll,U as withBreakpointManager,Q as withBreakpointObserver,oe as withDrag,ae as withExtraConfig,de as withIntersectionObserver,ce as withMountWhenInView};
|
|
2
|
-
//# sourceMappingURL=index.modern.js.map
|
|
1
|
+
function e(){return(e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(e[s]=i[s])}return e}).apply(this,arguments)}var t=0;function i(e){return"__private_"+t+++"_"+e}function s(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}function n(e,t){return"function"==typeof e[t]}function r(e,t,...i){return e.__debug("callMethod",t,...i),"destroyed"===t&&!e.$isMounted||"mounted"===t&&e.$isMounted?(e.__debug("not",t,"because the method has already been triggered once."),e):(e.$emit(t,...i),n(e,t)?(e[t].call(e,...i),e.__debug(t,e,...i),e):e)}function o(e,t=document){const i=`[data-component="${e}"]`;let s=[];try{s=Array.from(t.querySelectorAll(i))}catch(e){}return 0===s.length&&(s=Array.from(t.querySelectorAll(e))),s}class a{get registeredNames(){return Object.keys(this).filter(e=>!e.startsWith("__"))}constructor(e,t,i,s){this.__base=e,this.__element=t,this.__components=i,this.__eventsManager=s}registerAll(){Object.entries(this.__components).forEach(([e,t])=>this.__register(e,t))}__register(e,t){Object.defineProperty(this,e,{enumerable:!0,configurable:!0,get:()=>{const i=o(e,this.__element);return 0===i.length?[]:i.map(i=>this.__getChild(i,t,e)).filter(e=>"terminated"!==e)}})}__getChild(e,t,i){if(e.__base__)return e.__base__;if("$isBase"in t){const i=new t(e);return Object.defineProperty(i,"$parent",{get:()=>this.__base}),i}return t(this.__base).then(t=>{var s;return this.__getChild(e,null!=(s=t.default)?s:t,i)})}mountAll(){this.__triggerHookForAll("$mount")}updateAll(){this.__triggerHookForAll("$update")}destroyAll(){this.__triggerHookForAll("$destroy")}__triggerHookForAll(e){this.registeredNames.forEach(t=>{this[t].forEach(i=>{i instanceof Promise?i.then(i=>this.__triggerHook(e,i,t)):this.__triggerHook(e,i,t)})})}__triggerHook(e,t,i){"$update"!==e||t.$isMounted||(e="$mount"),"$update"!==e&&"$destroy"!==e||this.__eventsManager.unbindChild(i,t),"$update"!==e&&"$mount"!==e||this.__eventsManager.bindChild(i,t),t[e]()}}class h{constructor(e,t,i,s){this.__element=t,this.__refs=i,this.__base=e,this.__eventsManager=s}registerAll(){this.__refs.forEach(e=>this.__register(e))}unregisterAll(){this.__refs.forEach(e=>this.__unregister(e))}__register(e){const t=e.endsWith("[]"),i=h.normalizeRefName(e),s=Array.from(this.__element.querySelectorAll(`[data-ref="${e}"]`)).filter(e=>this.__filterRefsBelongingToInstance(e));!t&&s.length>1&&console.warn(`[${this.__base.$options.name}]`,`The "${e}" ref has been found multiple times.`,"Did you forgot to add the `[]` suffix to its name?"),this.__eventsManager.bindRef(e,s),Object.defineProperty(this,i,{value:t||s.length>1?s:s[0],enumerable:!0,configurable:!0})}__unregister(e){const t=h.normalizeRefName(e),i=Array.isArray(this[t])?this[t]:[this[t]];this.__eventsManager.unbindRef(e,i)}static normalizeRefName(e){return e.endsWith("[]")?e.replace(/\[\]$/,""):e}__filterRefsBelongingToInstance(e){let t=e.parentElement;for(;t&&void 0===t.dataset.component;)t=t.parentElement;return null===t||t===this.__element}}class d{constructor(){this.callbacks=new Map,this.isInit=!1}get props(){throw new Error("The `props` getter must be implemented.")}init(){throw new Error("The `init` method must be implemented.")}kill(){throw new Error("The `kill` method must be implemented.")}add(e,t){if(this.has(e))throw new Error(`A callback with the key \`${e}\` has already been registered.`);return 0!==this.callbacks.size||this.isInit||(this.init(),this.isInit=!0),this.callbacks.set(e,t),this}has(e){return this.callbacks.has(e)}get(e){return this.callbacks.get(e)}remove(e){return this.callbacks.delete(e),0===this.callbacks.size&&this.isInit&&(this.kill(),this.isInit=!1),this}trigger(...e){return this.callbacks.forEach(function(t){t(...e)}),this}}function c(e){return"undefined"!=typeof TouchEvent&&e instanceof TouchEvent}class l extends d{constructor(...e){super(...e),this.isDown=!1,this.y=window.innerHeight/2,this.yLast=window.innerHeight/2,this.x=window.innerWidth/2,this.xLast=window.innerWidth/2,this.hasRaf=!1}init(){document.documentElement.addEventListener("mouseenter",this,{once:!0,capture:!0});const e={passive:!0,capture:!0};return document.addEventListener("mousemove",this,e),document.addEventListener("touchmove",this,e),document.addEventListener("mousedown",this,e),document.addEventListener("touchstart",this,e),document.addEventListener("mouseup",this,e),document.addEventListener("touchend",this,e),this}handleEvent(e){switch(e.type){case"mouseenter":case"mousemove":case"touchmove":this.handler(e);break;case"mousedown":case"touchstart":this.downHandler();break;case"mouseup":case"touchend":this.upHandler()}}kill(){return document.removeEventListener("mousemove",this),document.removeEventListener("touchmove",this),document.removeEventListener("mousedown",this),document.removeEventListener("touchstart",this),document.removeEventListener("mouseup",this),document.removeEventListener("touchend",this),this}handler(e){this.updateValues(e),this.trigger(this.props)}downHandler(){this.isDown=!0,this.trigger(this.props)}upHandler(){this.isDown=!1,this.trigger(this.props)}updateValues(e){var t,i;this.event=e,this.yLast=this.y,this.xLast=this.x;const s=c(e)?null==(t=e.touches[0])?void 0:t.clientY:e.clientY;s!==this.y&&(this.y=s);const n=c(e)?null==(i=e.touches[0])?void 0:i.clientX:e.clientX;n!==this.x&&(this.x=n)}get props(){return{event:this.event,isDown:this.isDown,x:this.x,y:this.y,changed:{x:this.x!==this.xLast,y:this.y!==this.yLast},last:{x:this.xLast,y:this.yLast},delta:{x:this.x-this.xLast,y:this.y-this.yLast},progress:{x:this.x/window.innerWidth,y:this.y/window.innerHeight},max:{x:window.innerWidth,y:window.innerHeight}}}}let u=null;function p(){return u||(u=new l),{add:u.add.bind(u),remove:u.remove.bind(u),has:u.has.bind(u),props:()=>u.props}}class m extends d{constructor(){super(),this.isTicking=!1,this.id=0,this.raf="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):setTimeout,this.cancelRaf="undefined"!=typeof window&&window.cancelAnimationFrame?window.cancelAnimationFrame.bind(window):clearTimeout,this.loop=this.loop.bind(this)}init(){return this.isTicking=!0,this.loop(),this}loop(){this.trigger(this.props),this.isTicking&&(this.id=this.raf(this.loop))}kill(){return this.cancelRaf(this.id),this.isTicking=!1,this}get props(){return{time:window.performance.now()}}}let _=null;function g(){return _||(_=new m),{add:_.add.bind(_),remove:_.remove.bind(_),has:_.has.bind(_),props:function(){return _.props}}}function f(e,t=300){let i;return function(...s){clearTimeout(i),i=setTimeout(()=>{e(...s)},t)}}class b extends d{init(){return this.handler=f(()=>{this.trigger(this.props)}).bind(this),window.addEventListener("resize",this.handler),this}kill(){return window.removeEventListener("resize",this.handler),this}get props(){const e={width:window.innerWidth,height:window.innerHeight,ratio:window.innerWidth/window.innerHeight,orientation:"square"};return e.ratio>1&&(e.orientation="landscape"),e.ratio<1&&(e.orientation="portrait"),this.breakpointElement&&(e.breakpoint=this.breakpoint,e.breakpoints=this.breakpoints),e}get breakpointElement(){return document.querySelector("[data-breakpoint]")||null}get breakpoint(){return window.getComputedStyle(this.breakpointElement,"::before").getPropertyValue("content").replace(/"/g,"")}get breakpoints(){return window.getComputedStyle(this.breakpointElement,"::after").getPropertyValue("content").replace(/"/g,"").split(",")}}let y=null;function v(){return y||(y=new b),{add:y.add.bind(y),remove:y.remove.bind(y),has:y.has.bind(y),props:()=>y.props}}class w extends d{constructor(...e){super(...e),this.y=window.pageYOffset,this.yLast=window.pageYOffset,this.x=window.pageXOffset,this.xLast=window.pageXOffset}init(){return document.addEventListener("scroll",this,{passive:!0,capture:!0}),this}get debouncedHandler(){const e=f(()=>{this.trigger(this.props)},0);return Object.defineProperty(this,"debouncedHandler",{value:e}),e}handleEvent(){this.trigger(this.props),this.debouncedHandler()}kill(){return document.removeEventListener("scroll",this),this}get props(){return this.yLast=this.y,this.xLast=this.x,window.pageYOffset!==this.y&&(this.y=window.pageYOffset),window.pageXOffset!==this.x&&(this.x=window.pageXOffset),{x:this.x,y:this.y,changed:{x:this.x!==this.xLast,y:this.y!==this.yLast},last:{x:this.xLast,y:this.yLast},delta:{x:this.x-this.xLast,y:this.y-this.yLast},progress:{x:0===this.max.x?1:this.x/this.max.x,y:0===this.max.y?1:this.y/this.max.y},direction:{x:this.x>this.xLast?"RIGHT":this.x<this.xLast?"LEFT":"NONE",y:this.y>this.yLast?"DOWN":this.y<this.yLast?"UP":"NONE"},max:this.max}}get max(){return{x:(document.scrollingElement||document.body).scrollWidth-window.innerWidth,y:(document.scrollingElement||document.body).scrollHeight-window.innerHeight}}}let $=null;function E(){return $||($=new w),{add:$.add.bind($),remove:$.remove.bind($),has:$.has.bind($),props:()=>$.props}}var x={ENTER:13,SPACE:32,TAB:9,ESC:27,LEFT:37,UP:38,RIGHT:39,DOWN:40};class k extends d{constructor(...e){super(...e),this.event={},this.triggered=0,this.previousEvent={}}init(){return this.handler=e=>{this.event=e,this.trigger(this.props)},document.addEventListener("keydown",this.handler,{passive:!1}),document.addEventListener("keyup",this.handler,{passive:!1}),this}kill(){return document.removeEventListener("keydown",this.handler),document.removeEventListener("keyup",this.handler),this}get props(){const t=Object.entries(x).reduce((e,[t,i])=>(e[t]=i===this.event.keyCode,e),{});return this.previousEvent.type||(this.triggered=0),"keydown"===this.event.type&&"keydown"===this.previousEvent.type?this.triggered+=1:this.triggered=1,this.previousEvent=this.event,e({event:this.event,triggered:this.triggered,direction:"keydown"===this.event.type?"down":"up",isUp:"keyup"===this.event.type,isDown:"keydown"===this.event.type},t)}}let O=null;function A(){return O||(O=new k),{add:O.add.bind(O),remove:O.remove.bind(O),has:O.has.bind(O),props:()=>O.props}}class L extends d{init(){return this.handler=()=>{this.trigger(this.props)},window.addEventListener("load",this.handler),this}kill(){return window.removeEventListener("load",this.handler),this}get props(){return{}}}let N=null;function M(){return N||(N=new L),{add:N.add.bind(N),remove:N.remove.bind(N),has:N.has.bind(N),props:function(){return N.props}}}const j={scrolled:E,resized:v,ticked:g,moved:p,keyed:A,loaded:M},T=Object.keys(j);class B{get __services(){return e({},this.__customServices,j)}constructor(e){this.__customServices={},this.__base=e}has(e){if(!n(this.__base,e)&&!this.__services[e])return!1;const{has:t}=this.__services[e]();return t(this.__base.$id)}enable(e){if(this.has(e))return this.disable.bind(this,e);if(!n(this.__base,e)||!this.__services[e])return function(){};const{add:t}=this.__services[e](),i=this;return t(this.__base.$id,function(...t){r(i.__base,e,...t)}),this.disable.bind(this,e)}enableAll(){return Object.keys(this.__services).map(e=>this.enable(e))}disableAll(){Object.keys(this.__services).forEach(e=>{this.disable(e)})}disable(e){if(!this.__services[e])return;const{remove:t}=this.__services[e]();t(this.__base.$id)}register(e,t){this.__customServices[e]=t}unregister(e){if(T.includes(e))throw new Error(`[ServicesManager] The \`${e}\` core service can not be unregistered.`);delete this.__customServices[e]}}function H(e,t=[],i=null){const s=Object.getPrototypeOf(e);if(s===Object.prototype)return t;let n=Object.getOwnPropertyNames(s);return"function"==typeof i&&(n=n.filter(e=>i(e,s))),n=n.map(e=>[e,s]).reduce((e,t)=>[...e,t],t),H(s,n,i)}class P{constructor(e,t){this.__methodsCache=new Map,this.__rootElementHandler={handleEvent:e=>{const t=P.normalizeName(e.type);this.__base[`on${t}`](e)}},this.__refsHandler={handleEvent:e=>{const t=e.currentTarget,i=h.normalizeRefName(t.dataset.ref),s=`on${P.normalizeName(i)}${P.normalizeName(e.type)}`;let n=0;Array.isArray(this.__base.$refs[i])&&(n=this.__base.$refs[i].indexOf(t)),this.__base[s](e,n)}},this.__childrenHandler={handleEvent:e=>{const t=e.currentTarget.__base__;let i,s=0;const n=this.__base.$children;n.registeredNames.find(e=>!!n[e].includes(t)&&(i=e,s=n[e].indexOf(t),!0));const r=`on${P.normalizeName(i)}${P.normalizeName(e.type)}`,o=Array.isArray(e.detail)?e.detail:[];this.__base[r](...o,s,e)}},this.__rootElement=e,this.__base=t}__manageRef(e,t,i="add"){const s=`${i}EventListener`;this.__getEventMethodsByName(e).forEach(i=>{const n=this.__getEventNameByMethod(i,e);t.forEach(e=>e[s](n,this.__refsHandler))})}bindRef(e,t){this.__manageRef(e,t)}unbindRef(e,t){this.__manageRef(e,t,"remove")}__manageChild(e,t,i="add"){const s="add"===i?"$on":"$off";this.__getEventMethodsByName(e).forEach(i=>{const n=this.__getEventNameByMethod(i,e);t[s](n,this.__childrenHandler)})}bindChild(e,t){this.__manageChild(e,t)}unbindChild(e,t){this.__manageChild(e,t,"remove")}__manageRootElement(e="add"){const t=`${e}EventListener`;this.__getEventMethodsByName().forEach(e=>{const i=this.__getEventNameByMethod(e);this.__rootElement[t](i,this.__rootElementHandler)})}bindRootElement(){this.__manageRootElement()}unbindRootElement(){this.__manageRootElement("remove")}__getEventNameByMethod(e,t=""){const i=P.normalizeName(t),s=new RegExp(`^on${i}([A-Z].*)$`),[,n]=e.match(s);return P.normalizeEventName(n)}__getEventMethodsByName(e=""){const t=P.normalizeName(e),i=new RegExp(`^on${t}[A-Z].*$`),s=i.toString();let n=this.__methodsCache.get(s);return n||(n=Array.from(H(this.__base,[],e=>i.test(e)).reduce((e,[t])=>e.add(t),new Set)),this.__methodsCache.set(s,n)),n}static normalizeName(e){return e.replace(/[A-Z]([A-Z].*)/g,e=>e.toLowerCase()).replace(/[^a-zA-Z\d\s:]/g," ").replace(/(^\w|\s+\w)/g,e=>e.trim().toUpperCase()).trim()}static normalizeEventName(e){return e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`).replace(/^-/,"")}}var S=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===C}(e)}(e)},C="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function R(e,t){return!1!==t.clone&&t.isMergeableObject(e)?q(Array.isArray(e)?[]:{},e,t):e}function I(e,t,i){return e.concat(t).map(function(e){return R(e,i)})}function W(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return e.propertyIsEnumerable(t)}):[]}(e))}function z(e,t){try{return t in e}catch(e){return!1}}function q(e,t,i){(i=i||{}).arrayMerge=i.arrayMerge||I,i.isMergeableObject=i.isMergeableObject||S,i.cloneUnlessOtherwiseSpecified=R;var s=Array.isArray(t);return s===Array.isArray(e)?s?i.arrayMerge(e,t,i):function(e,t,i){var s={};return i.isMergeableObject(e)&&W(e).forEach(function(t){s[t]=R(e[t],i)}),W(t).forEach(function(n){(function(e,t){return z(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,n)||(s[n]=z(e,n)&&i.isMergeableObject(t[n])?function(e,t){if(!t.customMerge)return q;var i=t.customMerge(e);return"function"==typeof i?i:q}(n,i)(e[n],t[n],i):R(t[n],i))}),s}(e,t,i):R(t,i)}q.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(e,i){return q(e,i,t)},{})};var D=q;class V{constructor(e,t,i){var s,n;return this.__values={},this.__defaultValues={String:"",Number:0,Boolean:!1,Array:()=>[],Object:()=>({})},this.name="Base",this.debug=!1,this.log=!1,this.__element=e,this.name=i.name,t.debug={type:Boolean,default:null!=(s=i.debug)&&s},t.log={type:Boolean,default:null!=(n=i.log)&&n},Object.entries(t).forEach(([e,t])=>{this.__register(e,t)}),this}__register(e,t){const i=!V.types.includes(t),s=i?t.type:t;if(!V.types.includes(s))throw new Error(`The "${e}" option has an invalid type. The allowed types are: String, Number, Boolean, Array and Object.`);const n=i?t.default:this.__defaultValues[s.name];if((s===Array||s===Object)&&"function"!=typeof n)throw new Error(`The default value for options of type "${s.name}" must be returned by a function.`);Object.defineProperty(this,e,{get:()=>this.get(e,s,n),set:t=>{this.set(e,s,t,n)},enumerable:!0})}get(e,t,i){const s=V.__getPropertyName(e),n=this.__hasProperty(s);if(t===Boolean){if(i){const t=V.__getPropertyName(e,"No");return!this.__hasProperty(t)}return n||i}const r=this.__element.dataset[s];if(t===Number)return n?Number(r):i;if(t===Array||t===Object){const s=D(i(),n?JSON.parse(r):this.__defaultValues[t.name]());return this.__values[e]||(this.__values[e]=s),this.__values[e]}return n?r:i}set(e,t,i,s){const n=V.__getPropertyName(e);if(i.constructor.name!==t.name){const s=Array.isArray(i)||function(e){return"object"==typeof e&&!!e&&"[object Object]"===e.toString()}(i)?JSON.stringify(i):i;throw new TypeError(`The "${s}" value for the "${e}" option must be of type "${t.name}"`)}switch(t){case Boolean:if(s){const t=V.__getPropertyName(e,"No");i?delete this.__element.dataset[t]:this.__element.dataset[t]=""}else i?this.__element.dataset[n]="":delete this.__element.dataset[n];break;case Array:case Object:this.__values[e]=i;break;default:this.__element.dataset[n]=i}}__hasProperty(e){return void 0!==this.__element.dataset[e]}static __getPropertyName(e,t=""){const i=e+t;if(V.__propertyNameCache.has(i))return V.__propertyNameCache.get(i);const s=`option${t}${e.replace(/^\w/,e=>e.toUpperCase())}`;return V.__propertyNameCache.set(i,s),s}}V.types=[String,Number,Boolean,Array,Object],V.__propertyNameCache=new Map;let F=0;function G(){}class Y{get $root(){if(!this.$parent)return this;let e=this.$parent,t=this.$parent;for(;e;)e.$parent||(t=e),e=e.$parent;return t}get __config(){let t=Object.getPrototypeOf(this),{config:i}=t.constructor;for(;t.constructor.config&&t.constructor.$isBase;)i=e({},t.constructor.config,i),t.constructor.config.options&&(i.options=e({},t.constructor.config.options,i.options)),t=Object.getPrototypeOf(t);return i}get $services(){const e=this.__services;return this.$emit("get:services",e),e}get $refs(){const e=this.__refs;return this.$emit("get:refs",e),e}get $options(){const e=this.__options;return this.$emit("get:options",e),e}get $children(){const e=this.__children;return this.$emit("get:children",e),e}get $log(){return this.__options.log?window.console.log.bind(window,`[${this.__config.name}]`):G}get __debug(){return this.__options.debug&&void 0!==window.__DEV__&&window.__DEV__?window.console.log.bind(window,`[debug] [${this.$id}]`):G}constructor(e){if(this.$parent=null,this.$isMounted=!1,!e)throw new Error("The root element must be defined.");const{__config:t}=this;if(!t)throw new Error("The `config` static property must be defined.");if(!t.name)throw new Error("The `config.name` property is required.");return this.$id=`${t.name}-${F}`,F+=1,this.$el=e,"__base__"in this.$el||Object.defineProperty(this.$el,"__base__",{get:()=>this,configurable:!0}),this.__options=new V(e,t.options||{},t),this.__services=new B(this),this.__events=new P(e,this),this.__children=new a(this,e,t.components||{},this.__events),this.__refs=new h(this,e,t.refs||[],this.__events),this.__debug("constructor",this),this}$mount(){return this.__debug("$mount"),this.$children.registerAll(),this.$refs.registerAll(),this.__events.bindRootElement(),this.$services.enableAll(),this.$children.mountAll(),r(this,"mounted"),this.$isMounted=!0,this}$update(){return this.__debug("$update"),this.$refs.unregisterAll(),this.$services.disableAll(),this.$children.registerAll(),this.$refs.registerAll(),this.$services.enableAll(),this.$children.updateAll(),r(this,"updated"),this}$destroy(){return this.__debug("$destroy"),this.__events.unbindRootElement(),this.$refs.unregisterAll(),this.$services.disableAll(),this.$children.destroyAll(),r(this,"destroyed"),this.$isMounted=!1,this}$terminate(){this.__debug("$terminate"),this.$destroy(),r(this,"terminated"),Object.defineProperty(this.$el,"__base__",{value:"terminated",configurable:!1,writable:!1})}static $factory(e){if(!e)throw new Error("The $factory method requires a component’s name or selector to be specified.");return o(e).map(e=>new this(e).$mount())}$on(e,t,i){return this.__debug("$on",e,t,i),this.$el.addEventListener(e,t,i),()=>{this.$off(e,t,i)}}$off(e,t,i){this.__debug("$off",e,t),this.$el.removeEventListener(e,t,i)}$emit(e,...t){this.__debug("$emit",e,t),this.$el.dispatchEvent(new CustomEvent(e,{detail:t}))}}function X(e){const{breakpoint:t}=v().props();e.forEach(([e,i])=>{e.includes(t)&&!i.$isMounted?setTimeout(()=>i.$mount(),0):!e.includes(t)&&i.$isMounted&&i.$destroy()})}Y.$isBase=!0;const U=new WeakMap;function Z(e,t){if(!Array.isArray(t))throw new Error("[withBreakpointManager] The `breakpoints` parameter must be an array.");if(t.length<2)throw new Error("[withBreakpointManager] You must define at least 2 breakpoints.");const{add:i,props:s}=v();if(!s().breakpoint)throw new Error("The `BreakpointManager` class requires breakpoints to be defined.");return class extends e{constructor(e){return super(e),U.has(this)||U.set(this,function(e,t){return t.map(([t,i])=>{const s=new i(e.$el);return Object.defineProperty(s,"$parent",{get:()=>e.$parent}),[t,s]})}(this,t)),i(`BreakpointManager-${this.$id}`,()=>{X(U.get(this))}),this.instances=U.get(this),this}$mount(){return super.$mount(),X(U.get(this)),this}$destroy(){return Array.isArray(U.get(this))&&U.get(this).forEach(([,e])=>{e.$destroy()}),super.$destroy()}}}function J(e,t=v().props().breakpoint){const{activeBreakpoints:i,inactiveBreakpoints:s}=e.$options,n=i&&i.split(" ").includes(t),r=s&&s.split(" ").includes(t);return i&&n||s&&!r?"$mount":"$destroy"}function K(e){const{activeBreakpoints:t,inactiveBreakpoints:i}=e.$options;return Boolean(t||i)}function Q(e,t){!function(e){const{activeBreakpoints:t,inactiveBreakpoints:i,name:s}=e.$options;if(t&&i)throw new Error(`[${s}] Incorrect configuration: the \`activeBreakpoints\` and \`inactiveBreakpoints\` are not compatible.`)}(t);const{add:i,has:s}=v();s(e)||i(e,function({breakpoint:e}){const i=J(t,e);"$destroy"===i&&t.$isMounted?t[i]():"$mount"!==i||t.$isMounted||setTimeout(()=>t[i](),0)})}function ee(t){var i,s,n,r,o;return s=i=class extends t{constructor(e){super(e);const{remove:t,props:i}=v(),{name:s}=this.$options;if(!i().breakpoint)throw new Error(`[${s}] The \`BreakpointObserver\` class requires breakpoints to be defined.`);const n=`BreakpointObserver-${this.$id}`;return new MutationObserver(([e])=>{if("attributes"===e.type&&("data-options"===e.attributeName||e.attributeName.startsWith("data-option-"))){if(!K(this))return this.$mount(),void t(n);Q(n,this)}}).observe(this.$el,{attributes:!0}),K(this)?(Q(n,this),this):this}$mount(){return K(this)?"$mount"===J(this)?super.$mount():this:super.$mount()}},i.config=e({},t.config||{},{name:`${null!=(n=null==t||null==(r=t.config)?void 0:r.name)?n:""}WithBreakpointObserver`,options:e({},(null==t||null==(o=t.config)?void 0:o.options)||{},{activeBreakpoints:String,inactiveBreakpoints:String})}),s}function te(e,t,i=.85){if(i>=1||i<=0)throw new Error(`The \`factor\` parameter must be a number greater than 0 and smaller than 1, \`${i}\` given.`);let s=t,n=e;for(;Math.abs(s)>.1;)n+=s,s*=i;return n}let ie=0;class se extends d{constructor(t,i={}){return super(),this.isGrabbing=!1,this.hasInertia=!1,this.x=0,this.y=0,this.delta={x:0,y:0},this.origin={x:0,y:0},this.distance={x:0,y:0},this.final={x:0,y:0},this.options={factor:.85},ie+=1,this.id=`drag-${ie}`,this.target=t,this.options=e({},this.options,i),this.pointerHandler=this.pointerHandler.bind(this),this.rafHandler=this.rafHandler.bind(this),this}init(){const e={passive:!0};return this.target.addEventListener("mousedown",this,e),this.target.addEventListener("touchstart",this,e),p().add(this.id,this.pointerHandler),this}kill(){return this.target.removeEventListener("mousemove",this),this.target.removeEventListener("touchmove",this),p().remove(this.id),this}handleEvent(e){const t=e instanceof MouseEvent?e.clientX:e.touches[0].clientX,i=e instanceof MouseEvent?e.clientY:e.touches[0].clientY;this.start(t,i)}start(e,t){this.x=e,this.y=t,this.origin.x=e,this.origin.y=t,this.delta.x=0,this.delta.y=0,this.distance.x=0,this.distance.y=0,this.final.x=e,this.final.y=t,this.mode="start",this.isGrabbing=!0,this.trigger(this.props)}drop(){this.isGrabbing=!1,this.mode="drop",this.hasInertia=!0,this.final.x=te(this.x,this.delta.x,this.options.factor),this.final.y=te(this.y,this.delta.y,this.options.factor),this.trigger(this.props),setTimeout(()=>{const e=g();e.remove(this.id),e.add(this.id,this.rafHandler)},0)}stop(){g().remove(this.id),this.hasInertia=!1,this.mode="stop",this.trigger(this.props)}rafHandler(){this.isGrabbing||(this.x+=this.delta.x,this.y+=this.delta.y,this.distance.x=this.x-this.origin.x,this.distance.y=this.y-this.origin.y,this.delta.x*=this.options.factor,this.delta.y*=this.options.factor,"inertia"!==this.mode&&(this.mode="inertia"),this.trigger(this.props),Math.abs(this.delta.x)<.1&&Math.abs(this.delta.y)<.1&&this.stop())}pointerHandler(e){this.isGrabbing&&(this.x=e.x,this.y=e.y,this.delta.x=e.delta.x,this.delta.y=e.delta.y,this.final.x=e.x,this.final.y=e.y,this.distance.x=this.x-this.origin.x,this.distance.y=this.y-this.origin.y,"drag"!==this.mode&&(this.mode="drag"),this.trigger(this.props),e.isDown||this.drop())}get props(){return{target:this.target,mode:this.mode,isGrabbing:this.isGrabbing,hasInertia:this.hasInertia,x:this.x,y:this.y,delta:this.delta,origin:this.origin,distance:this.distance,final:this.final}}}const ne=new WeakMap;function re(e,t){let i=ne.get(e);return i||(i=new se(e,t),ne.set(e,i)),{add:i.add.bind(i),remove:i.remove.bind(i),has:i.has.bind(i),props:()=>i.props}}const oe=["target"];function ae(e,t={target(){return this.$el}}){return class extends e{constructor(e){super(e),this.$on("mounted",()=>{const{target:e}=t,i=function(e,t){if(null==e)return{};var i,s,n={},r=Object.keys(e);for(s=0;s<r.length;s++)t.indexOf(i=r[s])>=0||(n[i]=e[i]);return n}(t,oe),s=re.bind(void 0,e.call(this),i);this.$services.register("dragged",s),this.$services.enable("dragged")}),this.$on("destroyed",()=>{this.$services.disable("dragged"),this.$services.unregister("dragged")})}}}function he(e,t,i={}){var s,n;const r=D(e.config,t,i);return r.name===e.config.name&&(r.name=`${e.config.name}WithExtraConfig`),n=s=class extends e{},s.config=r,n}function de(e){return[...new Array(e+1)].map((t,i)=>i/e)}function ce(t,i={threshold:de(100)}){var s,n,r,o,a;return n=s=class extends t{constructor(t){if(super(t),!this.intersected||"function"!=typeof this.intersected)throw new Error("[withIntersectionObserver] The `intersected` method must be defined.");return this.$observer=new IntersectionObserver(e=>{this.__debug("intersected",e),this.$emit("intersected",e),this.intersected(e)},e({},i,this.$options.intersectionObserver||{})),this.$on("mounted",()=>{this.$observer.observe(this.$el)}),this.$on("destroyed",()=>{this.$observer.unobserve(this.$el)}),this}},s.config=e({},t.config||{},{name:`${null!=(r=null==t||null==(o=t.config)?void 0:o.name)?r:""}WithIntersectionObserver`,options:e({},(null==t||null==(a=t.config)?void 0:a.options)||{},{intersectionObserver:Object})}),n}function le(t,n={threshold:[0,1]}){var r,o,a,h,d,c,l;return o=i("isVisible"),a=i("observer"),h=r=class extends t{constructor(t){return super(t),Object.defineProperty(this,o,{writable:!0,value:!1}),Object.defineProperty(this,a,{writable:!0,value:void 0}),s(this,a)[a]=new IntersectionObserver(e=>{const t=e.reduce((e,t)=>e||t.isIntersecting,!1);s(this,o)[o]!==t&&(s(this,o)[o]=t,this[t?"$mount":"$destroy"]())},e({},n,this.$options.intersectionObserver)),s(this,a)[a].observe(this.$el),this.$on("terminated",()=>{s(this,a)[a].disconnect()}),this}$mount(){return s(this,o)[o]&&super.$mount(),this}},r.config=e({},t.config||{},{name:`${null!=(d=null==t||null==(c=t.config)?void 0:c.name)?d:""}WithMountWhenInView`,options:e({},(null==t||null==(l=t.config)?void 0:l.options)||{},{intersectionObserver:Object})}),h}function ue(e,t){let i,s="complete"===document.readyState;s?i=new e(t).$mount():document.addEventListener("readystatechange",()=>{"complete"===document.readyState&&(i=new e(t).$mount(),s=!0)});const n=new Promise(e=>{document.addEventListener("readystatechange",()=>{"complete"===document.readyState&&setTimeout(()=>e(i),0)})});return function(){return s?Promise.resolve(i):n}}function pe(e,t){return"string"==typeof e?o(e,t):Array.isArray(e)?e:[e]}function me(e,t,i,s){const n="string"==typeof i?[i]:i;let r;return new Promise(i=>{const o=pe(t,null==s?void 0:s.$el),a={capture:!0,passive:!0,once:!0},h=()=>{(t=>{e().then(e=>{r="default"in e?e.default:e,t(r)})})(i)};o.forEach(e=>{n.forEach(t=>{e.addEventListener(t,h,a)})})})}function _e(e,t){let i;const s=t=>{e().then(e=>{i="default"in e?e.default:e,t(i)})};return new Promise(e=>{var i;const n=null!=(i=null==t?void 0:t.timeout)?i:1;"requestIdleCallback"in window?window.requestIdleCallback(()=>{setTimeout(()=>{s(e)},0)},{timeout:null==t?void 0:t.timeout}):setTimeout(()=>{s(e)},n)})}function ge(e,t,i,s={}){let n;return new Promise(r=>{const o=new IntersectionObserver(t=>{t.some(e=>e.isIntersecting)&&setTimeout(()=>{((t,i)=>{e().then(e=>{n="default"in e?e.default:e,t(n),o.disconnect()})})(r)},0)},s);pe(t,null==i?void 0:i.$el).forEach(e=>o.observe(e))})}export{Y as Base,ue as createApp,me as importOnInteraction,_e as importWhenIdle,ge as importWhenVisible,re as useDrag,A as useKey,M as useLoad,p as usePointer,g as useRaf,v as useResize,E as useScroll,Z as withBreakpointManager,ee as withBreakpointObserver,ae as withDrag,he as withExtraConfig,ce as withIntersectionObserver,le as withMountWhenInView};
|
package/index.umd.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e||self).Base={})}(this,function(e){function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e}).apply(this,arguments)}var i=0;function r(e){return"__private_"+i+++"_"+e}function n(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}function s(e,t,i){void 0===t&&(t=[]),void 0===i&&(i=null);var r=Object.getPrototypeOf(e);if(r===Object.prototype)return t;var n=Object.getOwnPropertyNames(r);return"function"==typeof i&&(n=n.filter(e=>i(e,r))),n=n.map(e=>[e,r]).reduce((e,t)=>[...e,t],t),s(r,n,i)}function o(e,t){return"function"==typeof e[t]}function a(e,t){var i=[].slice.call(arguments,2);return e.__debug("callMethod",t,...i),"destroyed"===t&&!e.$isMounted||"mounted"===t&&e.$isMounted?(e.__debug("not",t,"because the method has already been triggered once."),e):(e.$emit(t,...i),o(e,t)?(e[t].call(e,...i),e.__debug(t,e,...i),e):e)}function h(e,t){void 0===t&&(t=document);var i='[data-component="'+e+'"]',r=[];try{r=Array.from(t.querySelectorAll(i))}catch(e){}return 0===r.length&&(r=Array.from(t.querySelectorAll(e))),r}class d{get registeredNames(){return Object.keys(this).filter(e=>!e.startsWith("__"))}constructor(e,t,i,r){this.__base=e,this.__element=t,this.__components=i,this.__eventsManager=r}registerAll(){Object.entries(this.__components).forEach(e=>{var[t,i]=e;return this.__register(t,i)})}__register(e,t){Object.defineProperty(this,e,{enumerable:!0,configurable:!0,get:()=>{var i=h(e,this.__element);return 0===i.length?[]:i.map(i=>this.__getChild(i,t,e)).filter(e=>"terminated"!==e)}})}__getChild(e,t,i){if(e.__base__)return e.__base__;if("$isBase"in t){var r=new t(e);return Object.defineProperty(r,"$parent",{get:()=>this.__base}),r}return t(this.__base).then(t=>{var r;return this.__getChild(e,null!=(r=t.default)?r:t,i)})}mountAll(){this.__triggerHookForAll("$mount")}updateAll(){this.__triggerHookForAll("$update")}destroyAll(){this.__triggerHookForAll("$destroy")}__triggerHookForAll(e){this.registeredNames.forEach(t=>{this[t].forEach(i=>{i instanceof Promise?i.then(i=>this.__triggerHook(e,i,t)):this.__triggerHook(e,i,t)})})}__triggerHook(e,t,i){"$update"!==e||t.$isMounted||(e="$mount"),"$update"!==e&&"$destroy"!==e||this.__eventsManager.unbindChild(i,t),"$update"!==e&&"$mount"!==e||this.__eventsManager.bindChild(i,t),t[e]()}}class u{constructor(e,t,i,r){this.__element=t,this.__refs=i,this.__base=e,this.__eventsManager=r}registerAll(){this.__refs.forEach(e=>this.__register(e))}unregisterAll(){this.__refs.forEach(e=>this.__unregister(e))}__register(e){var t=e.endsWith("[]"),i=u.normalizeRefName(e),r=Array.from(this.__element.querySelectorAll('[data-ref="'+e+'"]')).filter(e=>this.__filterRefsBelongingToInstance(e));!t&&r.length>1&&console.warn("["+this.__base.$options.name+"]",'The "'+e+'" ref has been found multiple times.',"Did you forgot to add the `[]` suffix to its name?"),this.__eventsManager.bindRef(e,r),Object.defineProperty(this,i,{value:t||r.length>1?r:r[0],enumerable:!0,configurable:!0})}__unregister(e){var t=u.normalizeRefName(e),i=Array.isArray(this[t])?this[t]:[this[t]];this.__eventsManager.unbindRef(e,i)}static normalizeRefName(e){return e.endsWith("[]")?e.replace(/\[\]$/,""):e}__filterRefsBelongingToInstance(e){for(var t=e.parentElement;t&&void 0===t.dataset.component;)t=t.parentElement;return null===t||t===this.__element}}class l{constructor(){this.callbacks=new Map,this.isInit=!1}get props(){throw new Error("The `props` getter must be implemented.")}init(){throw new Error("The `init` method must be implemented.")}kill(){throw new Error("The `kill` method must be implemented.")}add(e,t){if(this.has(e))throw new Error("A callback with the key `"+e+"` has already been registered.");return 0!==this.callbacks.size||this.isInit||(this.init(),this.isInit=!0),this.callbacks.set(e,t),this}has(e){return this.callbacks.has(e)}get(e){return this.callbacks.get(e)}remove(e){return this.callbacks.delete(e),0===this.callbacks.size&&this.isInit&&(this.kill(),this.isInit=!1),this}trigger(){var e=[].slice.call(arguments);return this.callbacks.forEach(function(t){t(...e)}),this}}function c(e){return"undefined"!=typeof TouchEvent&&e instanceof TouchEvent}class p extends l{constructor(){super(...arguments),this.isDown=!1,this.y=window.innerHeight/2,this.yLast=window.innerHeight/2,this.x=window.innerWidth/2,this.xLast=window.innerWidth/2,this.hasRaf=!1}init(){document.documentElement.addEventListener("mouseenter",this,{once:!0,capture:!0});var e={passive:!0,capture:!0};return document.addEventListener("mousemove",this,e),document.addEventListener("touchmove",this,e),document.addEventListener("mousedown",this,e),document.addEventListener("touchstart",this,e),document.addEventListener("mouseup",this,e),document.addEventListener("touchend",this,e),this}handleEvent(e){switch(e.type){case"mouseenter":case"mousemove":case"touchmove":this.handler(e);break;case"mousedown":case"touchstart":this.downHandler();break;case"mouseup":case"touchend":this.upHandler()}}kill(){return document.removeEventListener("mousemove",this),document.removeEventListener("touchmove",this),document.removeEventListener("mousedown",this),document.removeEventListener("touchstart",this),document.removeEventListener("mouseup",this),document.removeEventListener("touchend",this),this}handler(e){this.updateValues(e),this.trigger(this.props)}downHandler(){this.isDown=!0,this.trigger(this.props)}upHandler(){this.isDown=!1,this.trigger(this.props)}updateValues(e){var t,i;this.event=e,this.yLast=this.y,this.xLast=this.x;var r=c(e)?null==(t=e.touches[0])?void 0:t.clientY:e.clientY;r!==this.y&&(this.y=r);var n=c(e)?null==(i=e.touches[0])?void 0:i.clientX:e.clientX;n!==this.x&&(this.x=n)}get props(){return{event:this.event,isDown:this.isDown,x:this.x,y:this.y,changed:{x:this.x!==this.xLast,y:this.y!==this.yLast},last:{x:this.xLast,y:this.yLast},delta:{x:this.x-this.xLast,y:this.y-this.yLast},progress:{x:this.x/window.innerWidth,y:this.y/window.innerHeight},max:{x:window.innerWidth,y:window.innerHeight}}}}var m=null;function f(){return m||(m=new p),{add:m.add.bind(m),remove:m.remove.bind(m),has:m.has.bind(m),props:()=>m.props}}class v extends l{constructor(){super(),this.isTicking=!1,this.id=0,this.raf="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):setTimeout,this.cancelRaf="undefined"!=typeof window&&window.cancelAnimationFrame?window.cancelAnimationFrame.bind(window):clearTimeout,this.loop=this.loop.bind(this)}init(){return this.isTicking=!0,this.loop(),this}loop(){this.trigger(this.props),this.isTicking&&(this.id=this.raf(this.loop))}kill(){return this.cancelRaf(this.id),this.isTicking=!1,this}get props(){return{time:window.performance.now()}}}var g=null;function _(){return g||(g=new v),{add:g.add.bind(g),remove:g.remove.bind(g),has:g.has.bind(g),props:function(){return g.props}}}function b(e,t){var i;return void 0===t&&(t=300),function(){clearTimeout(i),i=setTimeout(()=>{e(...[].slice.call(arguments))},t)}}class y extends l{init(){return this.handler=b(()=>{this.trigger(this.props)}).bind(this),window.addEventListener("resize",this.handler),this}kill(){return window.removeEventListener("resize",this.handler),this}get props(){var e={width:window.innerWidth,height:window.innerHeight,ratio:window.innerWidth/window.innerHeight,orientation:"square"};return e.ratio>1&&(e.orientation="landscape"),e.ratio<1&&(e.orientation="portrait"),this.breakpointElement&&(e.breakpoint=this.breakpoint,e.breakpoints=this.breakpoints),e}get breakpointElement(){return document.querySelector("[data-breakpoint]")||null}get breakpoint(){return window.getComputedStyle(this.breakpointElement,"::before").getPropertyValue("content").replace(/"/g,"")}get breakpoints(){return window.getComputedStyle(this.breakpointElement,"::after").getPropertyValue("content").replace(/"/g,"").split(",")}get canUseResizeObserver(){return void 0!==window.ResizeObserver}}var w=null;function $(){return w||(w=new y),{add:w.add.bind(w),remove:w.remove.bind(w),has:w.has.bind(w),props:()=>w.props}}class E extends l{constructor(){super(...arguments),this.y=window.pageYOffset,this.yLast=window.pageYOffset,this.x=window.pageXOffset,this.xLast=window.pageXOffset}init(){return document.addEventListener("scroll",this,{passive:!0,capture:!0}),this}get debouncedHandler(){var e=b(()=>{this.trigger(this.props)},0);return Object.defineProperty(this,"debouncedHandler",{value:e}),e}handleEvent(){this.trigger(this.props),this.debouncedHandler()}kill(){return document.removeEventListener("scroll",this),this}get props(){return this.yLast=this.y,this.xLast=this.x,window.pageYOffset!==this.y&&(this.y=window.pageYOffset),window.pageXOffset!==this.x&&(this.x=window.pageXOffset),{x:this.x,y:this.y,changed:{x:this.x!==this.xLast,y:this.y!==this.yLast},last:{x:this.xLast,y:this.yLast},delta:{x:this.x-this.xLast,y:this.y-this.yLast},progress:{x:0===this.max.x?1:this.x/this.max.x,y:0===this.max.y?1:this.y/this.max.y},direction:{x:this.x>this.xLast?"RIGHT":this.x<this.xLast?"LEFT":"NONE",y:this.y>this.yLast?"DOWN":this.y<this.yLast?"UP":"NONE"},max:this.max}}get max(){return{x:(document.scrollingElement||document.body).scrollWidth-window.innerWidth,y:(document.scrollingElement||document.body).scrollHeight-window.innerHeight}}}var x=null;function k(){return x||(x=new E),{add:x.add.bind(x),remove:x.remove.bind(x),has:x.has.bind(x),props:()=>x.props}}var O={ENTER:13,SPACE:32,TAB:9,ESC:27,LEFT:37,UP:38,RIGHT:39,DOWN:40};class A extends l{constructor(){super(...arguments),this.event={},this.triggered=0,this.previousEvent={}}init(){return this.handler=e=>{this.event=e,this.trigger(this.props)},document.addEventListener("keydown",this.handler,{passive:!1}),document.addEventListener("keyup",this.handler,{passive:!1}),this}kill(){return document.removeEventListener("keydown",this.handler),document.removeEventListener("keyup",this.handler),this}get props(){var e=Object.entries(O).reduce((e,t)=>{var[i,r]=t;return e[i]=r===this.event.keyCode,e},{});return this.previousEvent.type||(this.triggered=0),"keydown"===this.event.type&&"keydown"===this.previousEvent.type?this.triggered+=1:this.triggered=1,this.previousEvent=this.event,t({event:this.event,triggered:this.triggered,direction:"keydown"===this.event.type?"down":"up",isUp:"keyup"===this.event.type,isDown:"keydown"===this.event.type},e)}}var L=null;function M(){return L||(L=new A),{add:L.add.bind(L),remove:L.remove.bind(L),has:L.has.bind(L),props:()=>L.props}}class N extends l{init(){return this.handler=()=>{this.trigger(this.props)},window.addEventListener("load",this.handler),this}kill(){return window.removeEventListener("load",this.handler),this}get props(){return{}}}var j=null;function B(){return j||(j=new N),{add:j.add.bind(j),remove:j.remove.bind(j),has:j.has.bind(j),props:function(){return j.props}}}var T={scrolled:k,resized:$,ticked:_,moved:f,keyed:M,loaded:B};class P{constructor(e){this.__base=e}has(e){if(!o(this.__base,e)&&!T[e])return!1;var{has:t}=T[e]();return t(this.__base.$id)}enable(e){if(this.has(e))return this.disable.bind(this,e);if(!o(this.__base,e)||!T[e])return function(){};var{add:t}=T[e](),i=this;return t(this.__base.$id,function(){a(i.__base,e,...[].slice.call(arguments))}),this.disable.bind(this,e)}enableAll(){return Object.keys(T).map(e=>this.enable(e))}disableAll(){Object.keys(T).forEach(e=>{this.disable(e)})}disable(e){if(T[e]){var{remove:t}=T[e]();t(this.__base.$id)}}register(e,t){T[e]=t}unregister(e){delete T[e]}}class H{constructor(e,t){this.__methodsCache=new WeakMap,this.__rootElementHandler={handleEvent:e=>{var t="on"+H.normalizeName(e.type);"function"==typeof this.__base[t]&&this.__base[t](e)}},this.__refsHandler={handleEvent:e=>{var t=e.currentTarget,i=u.normalizeRefName(t.dataset.ref),r="on"+H.normalizeName(i)+H.normalizeName(e.type);if("function"==typeof this.__base[r]){var n=0;Array.isArray(this.__base.$refs[i])&&(n=this.__base.$refs[i].indexOf(t)),this.__base[r](e,n)}}},this.__childrenHandler={handleEvent:e=>{var t,i=e.currentTarget.__base__,r=0,n=this.__base.$children;n.registeredNames.find(e=>!!n[e].includes(i)&&(t=e,r=n[e].indexOf(i),!0));var s="on"+H.normalizeName(t)+H.normalizeName(e.type);if("function"==typeof this.__base[s]){var o,a=null!=(o=e.detail)?o:[];this.__base[s](...a,r,e)}}},this.__rootElement=e,this.__base=t}__manageRef(e,t,i){void 0===i&&(i="add");var r=i+"EventListener";this.__getEventMethodsByName(e).forEach(i=>{var n=this.__getEventNameByMethod(i,e);t.forEach(e=>e[r](n,this.__refsHandler))})}bindRef(e,t){this.__manageRef(e,t)}unbindRef(e,t){this.__manageRef(e,t,"remove")}__manageChild(e,t,i){void 0===i&&(i="add");var r="add"===i?"$on":"$off";this.__getEventMethodsByName(e).forEach(i=>{var n=this.__getEventNameByMethod(i,e);t[r](n,this.__childrenHandler)})}bindChild(e,t){this.__manageChild(e,t)}unbindChild(e,t){this.__manageChild(e,t,"remove")}__manageRootElement(e){void 0===e&&(e="add");var t=e+"EventListener";this.__getEventMethodsByName().forEach(e=>{var i=this.__getEventNameByMethod(e);this.__rootElement[t](i,this.__rootElementHandler)})}bindRootElement(){this.__manageRootElement()}unbindRootElement(){this.__manageRootElement("remove")}__getEventNameByMethod(e,t){void 0===t&&(t="");var i=H.normalizeName(t),r=new RegExp("^on"+i+"([A-Z].*)$"),[,n]=e.match(r);return H.normalizeEventName(n)}__getEventMethodsByName(e){void 0===e&&(e="");var t=H.normalizeName(e),i=new RegExp("^on"+t+"[A-Z].*$"),r=this.__methodsCache.get(i);return r||(r=s(this.__base,[],e=>i.test(e)),this.__methodsCache.set(i,r)),r.reduce((e,t)=>{var[i]=t;return e.includes(i)||e.push(i),e},[])}static normalizeName(e){return e.replace(/[A-Z]([A-Z].*)/g,e=>e.toLowerCase()).replace(/[^a-zA-Z\d\s:]/g," ").replace(/(^\w|\s+\w)/g,e=>e.trim().toUpperCase()).trim()}static normalizeEventName(e){return e.replace(/[A-Z]/g,e=>"-"+e.toLowerCase()).replace(/^-/,"")}}var C=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===R}(e)}(e)},R="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function I(e,t){return!1!==t.clone&&t.isMergeableObject(e)?D(Array.isArray(e)?[]:{},e,t):e}function S(e,t,i){return e.concat(t).map(function(e){return I(e,i)})}function W(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return e.propertyIsEnumerable(t)}):[]}(e))}function z(e,t){try{return t in e}catch(e){return!1}}function D(e,t,i){(i=i||{}).arrayMerge=i.arrayMerge||S,i.isMergeableObject=i.isMergeableObject||C,i.cloneUnlessOtherwiseSpecified=I;var r=Array.isArray(t);return r===Array.isArray(e)?r?i.arrayMerge(e,t,i):function(e,t,i){var r={};return i.isMergeableObject(e)&&W(e).forEach(function(t){r[t]=I(e[t],i)}),W(t).forEach(function(n){(function(e,t){return z(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,n)||(r[n]=z(e,n)&&i.isMergeableObject(t[n])?function(e,t){if(!t.customMerge)return D;var i=t.customMerge(e);return"function"==typeof i?i:D}(n,i)(e[n],t[n],i):I(t[n],i))}),r}(e,t,i):I(t,i)}D.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(e,i){return D(e,i,t)},{})};var F=D;class q{constructor(e,t,i){var r,n;return this.__values={},this.__defaultValues={String:"",Number:0,Boolean:!1,Array:()=>[],Object:()=>({})},this.name="Base",this.debug=!1,this.log=!1,this.__element=e,this.name=i.name,t.debug={type:Boolean,default:null!=(r=i.debug)&&r},t.log={type:Boolean,default:null!=(n=i.log)&&n},Object.entries(t).forEach(e=>{var[t,i]=e;this.__register(t,i)}),this}__register(e,t){var i=!q.types.includes(t),r=i?t.type:t;if(!q.types.includes(r))throw new Error('The "'+e+'" option has an invalid type. The allowed types are: String, Number, Boolean, Array and Object.');var n=i?t.default:this.__defaultValues[r.name];if((r===Array||r===Object)&&"function"!=typeof n)throw new Error('The default value for options of type "'+r.name+'" must be returned by a function.');Object.defineProperty(this,e,{get:()=>this.get(e,r,n),set:t=>{this.set(e,r,t,n)},enumerable:!0})}get(e,t,i){var r=q.__getPropertyName(e),n=this.__hasProperty(r);if(t===Boolean){if(i){var s=q.__getPropertyName(e,"No");return!this.__hasProperty(s)}return n||i}var o=this.__element.dataset[r];if(t===Number)return n?Number(o):i;if(t===Array||t===Object){var a=F(i(),n?JSON.parse(o):this.__defaultValues[t.name]());return this.__values[e]||(this.__values[e]=a),this.__values[e]}return n?o:i}set(e,t,i,r){var n=q.__getPropertyName(e);if(i.constructor.name!==t.name){var s=Array.isArray(i)||function(e){return"object"==typeof e&&!!e&&"[object Object]"===e.toString()}(i)?JSON.stringify(i):i;throw new TypeError('The "'+s+'" value for the "'+e+'" option must be of type "'+t.name+'"')}switch(t){case Boolean:if(r){var o=q.__getPropertyName(e,"No");i?delete this.__element.dataset[o]:this.__element.dataset[o]=""}else i?this.__element.dataset[n]="":delete this.__element.dataset[n];break;case Array:case Object:this.__values[e]=i;break;default:this.__element.dataset[n]=i}}__hasProperty(e){return void 0!==this.__element.dataset[e]}static __getPropertyName(e,t){void 0===t&&(t="");var i=e+t;if(q.__propertyNameCache.has(i))return q.__propertyNameCache.get(i);var r="option"+t+e.replace(/^\w/,e=>e.toUpperCase());return q.__propertyNameCache.set(i,r),r}static __isPrimitive(e){return"string"==typeof e||"number"==typeof e||"symbol"==typeof e||"boolean"==typeof e}}q.types=[String,Number,Boolean,Array,Object],q.__propertyNameCache=new Map;var V=0,G=function(){};class Y{get __excludeFromAutoBind(){return["$mount","$update","$destroy","$terminate","$log","$on","$once","$off","$emit","mounted","loaded","ticked","resized","moved","keyed","scrolled","destroyed","terminated"]}get __config(){for(var e=Object.getPrototypeOf(this),{config:i}=e.constructor;e.constructor.config&&e.constructor.$isBase;)i=t({},e.constructor.config,i),e.constructor.config.options&&(i.options=t({},e.constructor.config.options,i.options)),e=Object.getPrototypeOf(e);return i}get $services(){var e=this.__services;return this.$emit("get:services",e),e}get $refs(){var e=this.__refs;return this.$emit("get:refs",e),e}get $options(){var e=this.__options;return this.$emit("get:options",e),e}get $children(){this.__debug("before:getChildren",this.$el,this.__config.components);var e=this.__children;return this.$emit("get:children",e),this.__debug(this,"after:getChildren",e),e}get $log(){return this.__options.log?window.console.log.bind(window,"["+this.__config.name+"]"):G}get __debug(){return this.__options.debug&&void 0!==window.__DEV__&&window.__DEV__?window.console.log.bind(window,"[debug] ["+this.$id+"]"):G}constructor(e){if(this.$parent=null,this.$isMounted=!1,!e)throw new Error("The root element must be defined.");var{__config:t}=this;if(!t)throw new Error("The `config` static property must be defined.");if(!t.name)throw new Error("The `config.name` property is required.");return this.$id=t.name+"-"+V,V+=1,this.$el=e,"__base__"in this.$el||Object.defineProperty(this.$el,"__base__",{get:()=>this,configurable:!0}),this.__options=new q(e,t.options||{},t),this.__services=new P(this),this.__events=new H(e,this),this.__children=new d(this,e,t.components||{},this.__events),this.__refs=new u(this,e,t.refs||[],this.__events),function(e,t){var{exclude:i,include:r}=t||{};s(e).filter(e=>{var[t]=e;return"constructor"!==t&&(e=>{var t=t=>"string"==typeof t?e===t:t.test(e);return r?r.some(t):!i||!i.some(t)})(t)}).forEach(t=>{var[i,r]=t,n=Object.getOwnPropertyDescriptor(r,i);n&&"function"==typeof n.value&&(e[i]=e[i].bind(e))})}(this,{exclude:[...this.__excludeFromAutoBind]}),this.__debug("constructor",this),this}$mount(){return this.__debug("$mount"),this.$children.registerAll(),this.$refs.registerAll(),this.__events.bindRootElement(),this.$services.enableAll(),this.$children.mountAll(),a(this,"mounted"),this.$isMounted=!0,this}$update(){return this.__debug("$update"),this.$refs.unregisterAll(),this.$services.disableAll(),this.$children.registerAll(),this.$refs.registerAll(),this.$services.enableAll(),this.$children.updateAll(),a(this,"updated"),this}$destroy(){return this.__debug("$destroy"),this.__events.unbindRootElement(),this.$refs.unregisterAll(),this.$services.disableAll(),this.$children.destroyAll(),a(this,"destroyed"),this.$isMounted=!1,this}$terminate(){this.__debug("$terminate"),this.$destroy(),a(this,"terminated"),Object.defineProperty(this.$el,"__base__",{value:"terminated",configurable:!1,writable:!1})}static $factory(e){if(!e)throw new Error("The $factory method requires a component’s name or selector to be specified.");return h(e).map(e=>new this(e).$mount())}$on(e,t,i){return this.__debug("$on",e,t,i),this.$el.addEventListener(e,t,i),()=>{this.$off(e,t,i)}}$off(e,t,i){this.__debug("$off",e,t),this.$el.removeEventListener(e,t,i)}$emit(e){var t=[].slice.call(arguments,1);this.__debug("$emit",e,t),this.$el.dispatchEvent(new CustomEvent(e,{detail:t}))}}function X(e){var{breakpoint:t}=$().props();e.forEach(e=>{var[i,r]=e;i.includes(t)&&!r.$isMounted?setTimeout(()=>r.$mount(),0):!i.includes(t)&&r.$isMounted&&r.$destroy()})}Y.$isBase=!0;var U=new WeakMap;function Z(e,t){void 0===t&&(t=$().props().breakpoint);var{activeBreakpoints:i,inactiveBreakpoints:r}=e.$options,n=i&&i.split(" ").includes(t),s=r&&r.split(" ").includes(t);return i&&n||r&&!s?"$mount":"$destroy"}function J(e){var{activeBreakpoints:t,inactiveBreakpoints:i}=e.$options;return Boolean(t||i)}function K(e,t){!function(e){var{activeBreakpoints:t,inactiveBreakpoints:i,name:r}=e.$options;if(t&&i)throw new Error("["+r+"] Incorrect configuration: the `activeBreakpoints` and `inactiveBreakpoints` are not compatible.")}(t);var{add:i,has:r}=$();r(e)||i(e,function(e){var{breakpoint:i}=e,r=Z(t,i);"$destroy"===r&&t.$isMounted?t[r]():"$mount"!==r||t.$isMounted||setTimeout(()=>t[r](),0)})}function Q(e,t,i){if(void 0===i&&(i=.85),i>=1||i<=0)throw new Error("The `factor` parameter must be a number greater than 0 and smaller than 1, `"+i+"` given.");for(var r=t,n=e;Math.abs(r)>.1;)n+=r,r*=i;return n}var ee="drag",te="inertia",ie=0;class re extends l{constructor(e,i){return void 0===i&&(i={}),super(),this.isGrabbing=!1,this.hasInertia=!1,this.x=0,this.y=0,this.delta={x:0,y:0},this.origin={x:0,y:0},this.distance={x:0,y:0},this.final={x:0,y:0},this.options={factor:.85},this.id="drag-"+(ie+=1),this.target=e,this.options=t({},this.options,i),this.pointerHandler=this.pointerHandler.bind(this),this.rafHandler=this.rafHandler.bind(this),this}init(){var e={passive:!0};return this.target.addEventListener("mousedown",this,e),this.target.addEventListener("touchstart",this,e),f().add(this.id,this.pointerHandler),this}kill(){return this.target.removeEventListener("mousemove",this),this.target.removeEventListener("touchmove",this),f().remove(this.id),this}handleEvent(e){var t=e instanceof MouseEvent?e.clientX:e.touches[0].clientX,i=e instanceof MouseEvent?e.clientY:e.touches[0].clientY;this.start(t,i)}start(e,t){this.x=e,this.y=t,this.origin.x=e,this.origin.y=t,this.delta.x=0,this.delta.y=0,this.distance.x=0,this.distance.y=0,this.final.x=e,this.final.y=t,this.mode="start",this.isGrabbing=!0,this.trigger(this.props)}drop(){this.isGrabbing=!1,this.mode="drop",this.hasInertia=!0,this.final.x=Q(this.x,this.delta.x,this.options.factor),this.final.y=Q(this.y,this.delta.y,this.options.factor),this.trigger(this.props),setTimeout(()=>{var e=_();e.remove(this.id),e.add(this.id,this.rafHandler)},0)}stop(){_().remove(this.id),this.hasInertia=!1,this.mode="stop",this.trigger(this.props)}rafHandler(){this.isGrabbing||(this.x+=this.delta.x,this.y+=this.delta.y,this.distance.x=this.x-this.origin.x,this.distance.y=this.y-this.origin.y,this.delta.x*=this.options.factor,this.delta.y*=this.options.factor,this.mode!==te&&(this.mode=te),this.trigger(this.props),Math.abs(this.delta.x)<.1&&Math.abs(this.delta.y)<.1&&this.stop())}pointerHandler(e){this.isGrabbing&&(this.x=e.x,this.y=e.y,this.delta.x=e.delta.x,this.delta.y=e.delta.y,this.final.x=e.x,this.final.y=e.y,this.distance.x=this.x-this.origin.x,this.distance.y=this.y-this.origin.y,this.mode!==ee&&(this.mode=ee),this.trigger(this.props),e.isDown||this.drop())}get props(){return{target:this.target,mode:this.mode,isGrabbing:this.isGrabbing,hasInertia:this.hasInertia,x:this.x,y:this.y,delta:this.delta,origin:this.origin,distance:this.distance,final:this.final}}}var ne=new WeakMap;function se(e,t){var i=ne.get(e);return i||(i=new re(e,t),ne.set(e,i)),{add:i.add.bind(i),remove:i.remove.bind(i),has:i.has.bind(i),props:()=>i.props}}var oe=["target"];function ae(e,t){return"string"==typeof e?h(e,t):Array.isArray(e)?e:[e]}e.Base=Y,e.createApp=function(e,t){var i,r="complete"===document.readyState;return r?i=new e(t).$mount():document.addEventListener("readystatechange",()=>{"complete"===document.readyState&&(i=new e(t).$mount(),r=!0)}),function(){return r?Promise.resolve(i):new Promise(e=>{document.addEventListener("readystatechange",()=>{"complete"===document.readyState&&setTimeout(()=>e(i),0)})})}},e.importOnInteraction=function(e,t,i,r){var n="string"==typeof i?[i]:i;return new Promise(i=>{var s=ae(t,null==r?void 0:r.$el),o={capture:!0,passive:!0,once:!0},a=()=>{(t=>{e().then(e=>{t("default"in e?e.default:e)})})(i)};s.forEach(e=>{n.forEach(t=>{e.addEventListener(t,a,o)})})})},e.importWhenIdle=function(e,t){var i=t=>{e().then(e=>{t("default"in e?e.default:e)})};return new Promise(e=>{var r,n=null!=(r=null==t?void 0:t.timeout)?r:1;"requestIdleCallback"in window?window.requestIdleCallback(()=>{setTimeout(()=>{i(e)},0)},{timeout:null==t?void 0:t.timeout}):setTimeout(()=>{i(e)},n)})},e.importWhenVisible=function(e,t,i,r){return void 0===r&&(r={}),new Promise(n=>{var s=new IntersectionObserver(t=>{t.some(e=>e.isIntersecting)&&setTimeout(()=>{((t,i)=>{e().then(e=>{t("default"in e?e.default:e),s.disconnect()})})(n)},0)},r);ae(t,null==i?void 0:i.$el).forEach(e=>s.observe(e))})},e.useDrag=se,e.useKey=M,e.useLoad=B,e.usePointer=f,e.useRaf=_,e.useResize=$,e.useScroll=k,e.withBreakpointManager=function(e,t){if(!Array.isArray(t))throw new Error("[withBreakpointManager] The `breakpoints` parameter must be an array.");if(t.length<2)throw new Error("[withBreakpointManager] You must define at least 2 breakpoints.");var{add:i,props:r}=$();if(!r().breakpoint)throw new Error("The `BreakpointManager` class requires breakpoints to be defined.");return class extends e{constructor(e){return super(e),U.has(this)||U.set(this,function(e,t){return t.map(t=>{var[i,r]=t,n=new r(e.$el);return Object.defineProperty(n,"$parent",{get:()=>e.$parent}),[i,n]})}(this,t)),i("BreakpointManager-"+this.$id,()=>{X(U.get(this))}),this.instances=U.get(this),this}$mount(){return super.$mount(),X(U.get(this)),this}$destroy(){return Array.isArray(U.get(this))&&U.get(this).forEach(e=>{var[,t]=e;t.$destroy()}),super.$destroy()}}},e.withBreakpointObserver=function(e){var i,r,n,s,o;return r=i=class extends e{constructor(e){super(e);var{remove:t,props:i}=$(),{name:r}=this.$options;if(!i().breakpoint)throw new Error("["+r+"] The `BreakpointObserver` class requires breakpoints to be defined.");var n="BreakpointObserver-"+this.$id;return new MutationObserver(e=>{var[i]=e;if("attributes"===i.type&&("data-options"===i.attributeName||i.attributeName.startsWith("data-option-"))){if(!J(this))return this.$mount(),void t(n);K(n,this)}}).observe(this.$el,{attributes:!0}),J(this)?(K(n,this),this):this}$mount(){return J(this)?"$mount"===Z(this)?super.$mount():this:super.$mount()}},i.config=t({},e.config||{},{name:(null!=(n=null==e||null==(s=e.config)?void 0:s.name)?n:"")+"WithBreakpointObserver",options:t({},(null==e||null==(o=e.config)?void 0:o.options)||{},{activeBreakpoints:String,inactiveBreakpoints:String})}),r},e.withDrag=function(e,t){return void 0===t&&(t={target(){return this.$el}}),class extends e{constructor(e){super(e),this.$on("mounted",()=>{var{target:e}=t,i=function(e,t){if(null==e)return{};var i,r,n={},s=Object.keys(e);for(r=0;r<s.length;r++)t.indexOf(i=s[r])>=0||(n[i]=e[i]);return n}(t,oe),r=se.bind(void 0,e.call(this),i);this.$services.register("dragged",r),this.$services.enable("dragged")}),this.$on("destroyed",()=>{this.$services.disable("dragged"),this.$services.unregister("dragged")})}}},e.withExtraConfig=function(e,t,i){var r,n;void 0===i&&(i={});var s=F(e.config,t,i);return s.name===e.config.name&&(s.name=e.config.name+"WithExtraConfig"),n=r=class extends e{},r.config=s,n},e.withIntersectionObserver=function(e,i){var r,n,s,o,a;return void 0===i&&(i={threshold:[...new Array(101)].map((e,t)=>t/100)}),n=r=class extends e{get __excludeFromAutoBind(){return[...super.__excludeFromAutoBind||[],"intersected"]}constructor(e){if(super(e),!this.intersected||"function"!=typeof this.intersected)throw new Error("[withIntersectionObserver] The `intersected` method must be defined.");return this.$observer=new IntersectionObserver(e=>{this.__debug("intersected",e),this.$emit("intersected",e),this.intersected(e)},t({},i,this.$options.intersectionObserver||{})),this.$isMounted&&this.$observer.observe(this.$el),this.$on("mounted",()=>{this.$observer.observe(this.$el)}),this.$on("destroyed",()=>{this.$observer.unobserve(this.$el)}),this}},r.config=t({},e.config||{},{name:(null!=(s=null==e||null==(o=e.config)?void 0:o.name)?s:"")+"WithIntersectionObserver",options:t({},(null==e||null==(a=e.config)?void 0:a.options)||{},{intersectionObserver:Object})}),n},e.withMountWhenInView=function(e,i){var s,o,a,h,d,u,l;return void 0===i&&(i={threshold:[0,1]}),o=r("isVisible"),a=r("observer"),h=s=class extends e{constructor(e){return super(e),Object.defineProperty(this,o,{writable:!0,value:!1}),Object.defineProperty(this,a,{writable:!0,value:void 0}),n(this,a)[a]=new IntersectionObserver(e=>{var t=e.reduce((e,t)=>e||t.isIntersecting,!1);n(this,o)[o]!==t&&(n(this,o)[o]=t,this[t?"$mount":"$destroy"]())},t({},i,this.$options.intersectionObserver)),n(this,a)[a].observe(this.$el),this.$on("terminated",()=>{n(this,a)[a].disconnect()}),this}$mount(){return n(this,o)[o]&&super.$mount(),this}},s.config=t({},e.config||{},{name:(null!=(d=null==e||null==(u=e.config)?void 0:u.name)?d:"")+"WithMountWhenInView",options:t({},(null==e||null==(l=e.config)?void 0:l.options)||{},{intersectionObserver:Object})}),h}});
|
|
2
|
-
//# sourceMappingURL=index.umd.js.map
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e||self).Base={})}(this,function(e){function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e}).apply(this,arguments)}var i=0;function r(e){return"__private_"+i+++"_"+e}function s(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}function n(e,t){return"function"==typeof e[t]}function o(e,t){var i=[].slice.call(arguments,2);return e.__debug("callMethod",t,...i),"destroyed"===t&&!e.$isMounted||"mounted"===t&&e.$isMounted?(e.__debug("not",t,"because the method has already been triggered once."),e):(e.$emit(t,...i),n(e,t)?(e[t].call(e,...i),e.__debug(t,e,...i),e):e)}function a(e,t){void 0===t&&(t=document);var i='[data-component="'+e+'"]',r=[];try{r=Array.from(t.querySelectorAll(i))}catch(e){}return 0===r.length&&(r=Array.from(t.querySelectorAll(e))),r}class h{get registeredNames(){return Object.keys(this).filter(e=>!e.startsWith("__"))}constructor(e,t,i,r){this.__base=e,this.__element=t,this.__components=i,this.__eventsManager=r}registerAll(){Object.entries(this.__components).forEach(e=>{var[t,i]=e;return this.__register(t,i)})}__register(e,t){Object.defineProperty(this,e,{enumerable:!0,configurable:!0,get:()=>{var i=a(e,this.__element);return 0===i.length?[]:i.map(i=>this.__getChild(i,t,e)).filter(e=>"terminated"!==e)}})}__getChild(e,t,i){if(e.__base__)return e.__base__;if("$isBase"in t){var r=new t(e);return Object.defineProperty(r,"$parent",{get:()=>this.__base}),r}return t(this.__base).then(t=>{var r;return this.__getChild(e,null!=(r=t.default)?r:t,i)})}mountAll(){this.__triggerHookForAll("$mount")}updateAll(){this.__triggerHookForAll("$update")}destroyAll(){this.__triggerHookForAll("$destroy")}__triggerHookForAll(e){this.registeredNames.forEach(t=>{this[t].forEach(i=>{i instanceof Promise?i.then(i=>this.__triggerHook(e,i,t)):this.__triggerHook(e,i,t)})})}__triggerHook(e,t,i){"$update"!==e||t.$isMounted||(e="$mount"),"$update"!==e&&"$destroy"!==e||this.__eventsManager.unbindChild(i,t),"$update"!==e&&"$mount"!==e||this.__eventsManager.bindChild(i,t),t[e]()}}class d{constructor(e,t,i,r){this.__element=t,this.__refs=i,this.__base=e,this.__eventsManager=r}registerAll(){this.__refs.forEach(e=>this.__register(e))}unregisterAll(){this.__refs.forEach(e=>this.__unregister(e))}__register(e){var t=e.endsWith("[]"),i=d.normalizeRefName(e),r=Array.from(this.__element.querySelectorAll('[data-ref="'+e+'"]')).filter(e=>this.__filterRefsBelongingToInstance(e));!t&&r.length>1&&console.warn("["+this.__base.$options.name+"]",'The "'+e+'" ref has been found multiple times.',"Did you forgot to add the `[]` suffix to its name?"),this.__eventsManager.bindRef(e,r),Object.defineProperty(this,i,{value:t||r.length>1?r:r[0],enumerable:!0,configurable:!0})}__unregister(e){var t=d.normalizeRefName(e),i=Array.isArray(this[t])?this[t]:[this[t]];this.__eventsManager.unbindRef(e,i)}static normalizeRefName(e){return e.endsWith("[]")?e.replace(/\[\]$/,""):e}__filterRefsBelongingToInstance(e){for(var t=e.parentElement;t&&void 0===t.dataset.component;)t=t.parentElement;return null===t||t===this.__element}}class u{constructor(){this.callbacks=new Map,this.isInit=!1}get props(){throw new Error("The `props` getter must be implemented.")}init(){throw new Error("The `init` method must be implemented.")}kill(){throw new Error("The `kill` method must be implemented.")}add(e,t){if(this.has(e))throw new Error("A callback with the key `"+e+"` has already been registered.");return 0!==this.callbacks.size||this.isInit||(this.init(),this.isInit=!0),this.callbacks.set(e,t),this}has(e){return this.callbacks.has(e)}get(e){return this.callbacks.get(e)}remove(e){return this.callbacks.delete(e),0===this.callbacks.size&&this.isInit&&(this.kill(),this.isInit=!1),this}trigger(){var e=[].slice.call(arguments);return this.callbacks.forEach(function(t){t(...e)}),this}}function l(e){return"undefined"!=typeof TouchEvent&&e instanceof TouchEvent}class c extends u{constructor(){super(...arguments),this.isDown=!1,this.y=window.innerHeight/2,this.yLast=window.innerHeight/2,this.x=window.innerWidth/2,this.xLast=window.innerWidth/2,this.hasRaf=!1}init(){document.documentElement.addEventListener("mouseenter",this,{once:!0,capture:!0});var e={passive:!0,capture:!0};return document.addEventListener("mousemove",this,e),document.addEventListener("touchmove",this,e),document.addEventListener("mousedown",this,e),document.addEventListener("touchstart",this,e),document.addEventListener("mouseup",this,e),document.addEventListener("touchend",this,e),this}handleEvent(e){switch(e.type){case"mouseenter":case"mousemove":case"touchmove":this.handler(e);break;case"mousedown":case"touchstart":this.downHandler();break;case"mouseup":case"touchend":this.upHandler()}}kill(){return document.removeEventListener("mousemove",this),document.removeEventListener("touchmove",this),document.removeEventListener("mousedown",this),document.removeEventListener("touchstart",this),document.removeEventListener("mouseup",this),document.removeEventListener("touchend",this),this}handler(e){this.updateValues(e),this.trigger(this.props)}downHandler(){this.isDown=!0,this.trigger(this.props)}upHandler(){this.isDown=!1,this.trigger(this.props)}updateValues(e){var t,i;this.event=e,this.yLast=this.y,this.xLast=this.x;var r=l(e)?null==(t=e.touches[0])?void 0:t.clientY:e.clientY;r!==this.y&&(this.y=r);var s=l(e)?null==(i=e.touches[0])?void 0:i.clientX:e.clientX;s!==this.x&&(this.x=s)}get props(){return{event:this.event,isDown:this.isDown,x:this.x,y:this.y,changed:{x:this.x!==this.xLast,y:this.y!==this.yLast},last:{x:this.xLast,y:this.yLast},delta:{x:this.x-this.xLast,y:this.y-this.yLast},progress:{x:this.x/window.innerWidth,y:this.y/window.innerHeight},max:{x:window.innerWidth,y:window.innerHeight}}}}var p=null;function m(){return p||(p=new c),{add:p.add.bind(p),remove:p.remove.bind(p),has:p.has.bind(p),props:()=>p.props}}class v extends u{constructor(){super(),this.isTicking=!1,this.id=0,this.raf="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):setTimeout,this.cancelRaf="undefined"!=typeof window&&window.cancelAnimationFrame?window.cancelAnimationFrame.bind(window):clearTimeout,this.loop=this.loop.bind(this)}init(){return this.isTicking=!0,this.loop(),this}loop(){this.trigger(this.props),this.isTicking&&(this.id=this.raf(this.loop))}kill(){return this.cancelRaf(this.id),this.isTicking=!1,this}get props(){return{time:window.performance.now()}}}var g=null;function f(){return g||(g=new v),{add:g.add.bind(g),remove:g.remove.bind(g),has:g.has.bind(g),props:function(){return g.props}}}function _(e,t){var i;return void 0===t&&(t=300),function(){clearTimeout(i),i=setTimeout(()=>{e(...[].slice.call(arguments))},t)}}class b extends u{init(){return this.handler=_(()=>{this.trigger(this.props)}).bind(this),window.addEventListener("resize",this.handler),this}kill(){return window.removeEventListener("resize",this.handler),this}get props(){var e={width:window.innerWidth,height:window.innerHeight,ratio:window.innerWidth/window.innerHeight,orientation:"square"};return e.ratio>1&&(e.orientation="landscape"),e.ratio<1&&(e.orientation="portrait"),this.breakpointElement&&(e.breakpoint=this.breakpoint,e.breakpoints=this.breakpoints),e}get breakpointElement(){return document.querySelector("[data-breakpoint]")||null}get breakpoint(){return window.getComputedStyle(this.breakpointElement,"::before").getPropertyValue("content").replace(/"/g,"")}get breakpoints(){return window.getComputedStyle(this.breakpointElement,"::after").getPropertyValue("content").replace(/"/g,"").split(",")}}var y=null;function w(){return y||(y=new b),{add:y.add.bind(y),remove:y.remove.bind(y),has:y.has.bind(y),props:()=>y.props}}class $ extends u{constructor(){super(...arguments),this.y=window.pageYOffset,this.yLast=window.pageYOffset,this.x=window.pageXOffset,this.xLast=window.pageXOffset}init(){return document.addEventListener("scroll",this,{passive:!0,capture:!0}),this}get debouncedHandler(){var e=_(()=>{this.trigger(this.props)},0);return Object.defineProperty(this,"debouncedHandler",{value:e}),e}handleEvent(){this.trigger(this.props),this.debouncedHandler()}kill(){return document.removeEventListener("scroll",this),this}get props(){return this.yLast=this.y,this.xLast=this.x,window.pageYOffset!==this.y&&(this.y=window.pageYOffset),window.pageXOffset!==this.x&&(this.x=window.pageXOffset),{x:this.x,y:this.y,changed:{x:this.x!==this.xLast,y:this.y!==this.yLast},last:{x:this.xLast,y:this.yLast},delta:{x:this.x-this.xLast,y:this.y-this.yLast},progress:{x:0===this.max.x?1:this.x/this.max.x,y:0===this.max.y?1:this.y/this.max.y},direction:{x:this.x>this.xLast?"RIGHT":this.x<this.xLast?"LEFT":"NONE",y:this.y>this.yLast?"DOWN":this.y<this.yLast?"UP":"NONE"},max:this.max}}get max(){return{x:(document.scrollingElement||document.body).scrollWidth-window.innerWidth,y:(document.scrollingElement||document.body).scrollHeight-window.innerHeight}}}var E=null;function x(){return E||(E=new $),{add:E.add.bind(E),remove:E.remove.bind(E),has:E.has.bind(E),props:()=>E.props}}var k={ENTER:13,SPACE:32,TAB:9,ESC:27,LEFT:37,UP:38,RIGHT:39,DOWN:40};class O extends u{constructor(){super(...arguments),this.event={},this.triggered=0,this.previousEvent={}}init(){return this.handler=e=>{this.event=e,this.trigger(this.props)},document.addEventListener("keydown",this.handler,{passive:!1}),document.addEventListener("keyup",this.handler,{passive:!1}),this}kill(){return document.removeEventListener("keydown",this.handler),document.removeEventListener("keyup",this.handler),this}get props(){var e=Object.entries(k).reduce((e,t)=>{var[i,r]=t;return e[i]=r===this.event.keyCode,e},{});return this.previousEvent.type||(this.triggered=0),"keydown"===this.event.type&&"keydown"===this.previousEvent.type?this.triggered+=1:this.triggered=1,this.previousEvent=this.event,t({event:this.event,triggered:this.triggered,direction:"keydown"===this.event.type?"down":"up",isUp:"keyup"===this.event.type,isDown:"keydown"===this.event.type},e)}}var A=null;function L(){return A||(A=new O),{add:A.add.bind(A),remove:A.remove.bind(A),has:A.has.bind(A),props:()=>A.props}}class M extends u{init(){return this.handler=()=>{this.trigger(this.props)},window.addEventListener("load",this.handler),this}kill(){return window.removeEventListener("load",this.handler),this}get props(){return{}}}var N=null;function j(){return N||(N=new M),{add:N.add.bind(N),remove:N.remove.bind(N),has:N.has.bind(N),props:function(){return N.props}}}var T={scrolled:x,resized:w,ticked:f,moved:m,keyed:L,loaded:j},B=Object.keys(T);class P{get __services(){return t({},this.__customServices,T)}constructor(e){this.__customServices={},this.__base=e}has(e){if(!n(this.__base,e)&&!this.__services[e])return!1;var{has:t}=this.__services[e]();return t(this.__base.$id)}enable(e){if(this.has(e))return this.disable.bind(this,e);if(!n(this.__base,e)||!this.__services[e])return function(){};var{add:t}=this.__services[e](),i=this;return t(this.__base.$id,function(){o(i.__base,e,...[].slice.call(arguments))}),this.disable.bind(this,e)}enableAll(){return Object.keys(this.__services).map(e=>this.enable(e))}disableAll(){Object.keys(this.__services).forEach(e=>{this.disable(e)})}disable(e){if(this.__services[e]){var{remove:t}=this.__services[e]();t(this.__base.$id)}}register(e,t){this.__customServices[e]=t}unregister(e){if(B.includes(e))throw new Error("[ServicesManager] The `"+e+"` core service can not be unregistered.");delete this.__customServices[e]}}function H(e,t,i){void 0===t&&(t=[]),void 0===i&&(i=null);var r=Object.getPrototypeOf(e);if(r===Object.prototype)return t;var s=Object.getOwnPropertyNames(r);return"function"==typeof i&&(s=s.filter(e=>i(e,r))),s=s.map(e=>[e,r]).reduce((e,t)=>[...e,t],t),H(r,s,i)}class S{constructor(e,t){this.__methodsCache=new Map,this.__rootElementHandler={handleEvent:e=>{var t=S.normalizeName(e.type);this.__base["on"+t](e)}},this.__refsHandler={handleEvent:e=>{var t=e.currentTarget,i=d.normalizeRefName(t.dataset.ref),r="on"+S.normalizeName(i)+S.normalizeName(e.type),s=0;Array.isArray(this.__base.$refs[i])&&(s=this.__base.$refs[i].indexOf(t)),this.__base[r](e,s)}},this.__childrenHandler={handleEvent:e=>{var t,i=e.currentTarget.__base__,r=0,s=this.__base.$children;s.registeredNames.find(e=>!!s[e].includes(i)&&(t=e,r=s[e].indexOf(i),!0));var n="on"+S.normalizeName(t)+S.normalizeName(e.type),o=Array.isArray(e.detail)?e.detail:[];this.__base[n](...o,r,e)}},this.__rootElement=e,this.__base=t}__manageRef(e,t,i){void 0===i&&(i="add");var r=i+"EventListener";this.__getEventMethodsByName(e).forEach(i=>{var s=this.__getEventNameByMethod(i,e);t.forEach(e=>e[r](s,this.__refsHandler))})}bindRef(e,t){this.__manageRef(e,t)}unbindRef(e,t){this.__manageRef(e,t,"remove")}__manageChild(e,t,i){void 0===i&&(i="add");var r="add"===i?"$on":"$off";this.__getEventMethodsByName(e).forEach(i=>{var s=this.__getEventNameByMethod(i,e);t[r](s,this.__childrenHandler)})}bindChild(e,t){this.__manageChild(e,t)}unbindChild(e,t){this.__manageChild(e,t,"remove")}__manageRootElement(e){void 0===e&&(e="add");var t=e+"EventListener";this.__getEventMethodsByName().forEach(e=>{var i=this.__getEventNameByMethod(e);this.__rootElement[t](i,this.__rootElementHandler)})}bindRootElement(){this.__manageRootElement()}unbindRootElement(){this.__manageRootElement("remove")}__getEventNameByMethod(e,t){void 0===t&&(t="");var i=S.normalizeName(t),r=new RegExp("^on"+i+"([A-Z].*)$"),[,s]=e.match(r);return S.normalizeEventName(s)}__getEventMethodsByName(e){void 0===e&&(e="");var t=S.normalizeName(e),i=new RegExp("^on"+t+"[A-Z].*$"),r=i.toString(),s=this.__methodsCache.get(r);return s||(s=Array.from(H(this.__base,[],e=>i.test(e)).reduce((e,t)=>{var[i]=t;return e.add(i)},new Set)),this.__methodsCache.set(r,s)),s}static normalizeName(e){return e.replace(/[A-Z]([A-Z].*)/g,e=>e.toLowerCase()).replace(/[^a-zA-Z\d\s:]/g," ").replace(/(^\w|\s+\w)/g,e=>e.trim().toUpperCase()).trim()}static normalizeEventName(e){return e.replace(/[A-Z]/g,e=>"-"+e.toLowerCase()).replace(/^-/,"")}}var C=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===I}(e)}(e)},I="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function R(e,t){return!1!==t.clone&&t.isMergeableObject(e)?q(Array.isArray(e)?[]:{},e,t):e}function W(e,t,i){return e.concat(t).map(function(e){return R(e,i)})}function z(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return e.propertyIsEnumerable(t)}):[]}(e))}function D(e,t){try{return t in e}catch(e){return!1}}function q(e,t,i){(i=i||{}).arrayMerge=i.arrayMerge||W,i.isMergeableObject=i.isMergeableObject||C,i.cloneUnlessOtherwiseSpecified=R;var r=Array.isArray(t);return r===Array.isArray(e)?r?i.arrayMerge(e,t,i):function(e,t,i){var r={};return i.isMergeableObject(e)&&z(e).forEach(function(t){r[t]=R(e[t],i)}),z(t).forEach(function(s){(function(e,t){return D(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,s)||(r[s]=D(e,s)&&i.isMergeableObject(t[s])?function(e,t){if(!t.customMerge)return q;var i=t.customMerge(e);return"function"==typeof i?i:q}(s,i)(e[s],t[s],i):R(t[s],i))}),r}(e,t,i):R(t,i)}q.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(e,i){return q(e,i,t)},{})};var V=q;class F{constructor(e,t,i){var r,s;return this.__values={},this.__defaultValues={String:"",Number:0,Boolean:!1,Array:()=>[],Object:()=>({})},this.name="Base",this.debug=!1,this.log=!1,this.__element=e,this.name=i.name,t.debug={type:Boolean,default:null!=(r=i.debug)&&r},t.log={type:Boolean,default:null!=(s=i.log)&&s},Object.entries(t).forEach(e=>{var[t,i]=e;this.__register(t,i)}),this}__register(e,t){var i=!F.types.includes(t),r=i?t.type:t;if(!F.types.includes(r))throw new Error('The "'+e+'" option has an invalid type. The allowed types are: String, Number, Boolean, Array and Object.');var s=i?t.default:this.__defaultValues[r.name];if((r===Array||r===Object)&&"function"!=typeof s)throw new Error('The default value for options of type "'+r.name+'" must be returned by a function.');Object.defineProperty(this,e,{get:()=>this.get(e,r,s),set:t=>{this.set(e,r,t,s)},enumerable:!0})}get(e,t,i){var r=F.__getPropertyName(e),s=this.__hasProperty(r);if(t===Boolean){if(i){var n=F.__getPropertyName(e,"No");return!this.__hasProperty(n)}return s||i}var o=this.__element.dataset[r];if(t===Number)return s?Number(o):i;if(t===Array||t===Object){var a=V(i(),s?JSON.parse(o):this.__defaultValues[t.name]());return this.__values[e]||(this.__values[e]=a),this.__values[e]}return s?o:i}set(e,t,i,r){var s=F.__getPropertyName(e);if(i.constructor.name!==t.name){var n=Array.isArray(i)||function(e){return"object"==typeof e&&!!e&&"[object Object]"===e.toString()}(i)?JSON.stringify(i):i;throw new TypeError('The "'+n+'" value for the "'+e+'" option must be of type "'+t.name+'"')}switch(t){case Boolean:if(r){var o=F.__getPropertyName(e,"No");i?delete this.__element.dataset[o]:this.__element.dataset[o]=""}else i?this.__element.dataset[s]="":delete this.__element.dataset[s];break;case Array:case Object:this.__values[e]=i;break;default:this.__element.dataset[s]=i}}__hasProperty(e){return void 0!==this.__element.dataset[e]}static __getPropertyName(e,t){void 0===t&&(t="");var i=e+t;if(F.__propertyNameCache.has(i))return F.__propertyNameCache.get(i);var r="option"+t+e.replace(/^\w/,e=>e.toUpperCase());return F.__propertyNameCache.set(i,r),r}}F.types=[String,Number,Boolean,Array,Object],F.__propertyNameCache=new Map;var G=0;function Y(){}class X{get $root(){if(!this.$parent)return this;for(var e=this.$parent,t=this.$parent;e;)e.$parent||(t=e),e=e.$parent;return t}get __config(){for(var e=Object.getPrototypeOf(this),{config:i}=e.constructor;e.constructor.config&&e.constructor.$isBase;)i=t({},e.constructor.config,i),e.constructor.config.options&&(i.options=t({},e.constructor.config.options,i.options)),e=Object.getPrototypeOf(e);return i}get $services(){var e=this.__services;return this.$emit("get:services",e),e}get $refs(){var e=this.__refs;return this.$emit("get:refs",e),e}get $options(){var e=this.__options;return this.$emit("get:options",e),e}get $children(){var e=this.__children;return this.$emit("get:children",e),e}get $log(){return this.__options.log?window.console.log.bind(window,"["+this.__config.name+"]"):Y}get __debug(){return this.__options.debug&&void 0!==window.__DEV__&&window.__DEV__?window.console.log.bind(window,"[debug] ["+this.$id+"]"):Y}constructor(e){if(this.$parent=null,this.$isMounted=!1,!e)throw new Error("The root element must be defined.");var{__config:t}=this;if(!t)throw new Error("The `config` static property must be defined.");if(!t.name)throw new Error("The `config.name` property is required.");return this.$id=t.name+"-"+G,G+=1,this.$el=e,"__base__"in this.$el||Object.defineProperty(this.$el,"__base__",{get:()=>this,configurable:!0}),this.__options=new F(e,t.options||{},t),this.__services=new P(this),this.__events=new S(e,this),this.__children=new h(this,e,t.components||{},this.__events),this.__refs=new d(this,e,t.refs||[],this.__events),this.__debug("constructor",this),this}$mount(){return this.__debug("$mount"),this.$children.registerAll(),this.$refs.registerAll(),this.__events.bindRootElement(),this.$services.enableAll(),this.$children.mountAll(),o(this,"mounted"),this.$isMounted=!0,this}$update(){return this.__debug("$update"),this.$refs.unregisterAll(),this.$services.disableAll(),this.$children.registerAll(),this.$refs.registerAll(),this.$services.enableAll(),this.$children.updateAll(),o(this,"updated"),this}$destroy(){return this.__debug("$destroy"),this.__events.unbindRootElement(),this.$refs.unregisterAll(),this.$services.disableAll(),this.$children.destroyAll(),o(this,"destroyed"),this.$isMounted=!1,this}$terminate(){this.__debug("$terminate"),this.$destroy(),o(this,"terminated"),Object.defineProperty(this.$el,"__base__",{value:"terminated",configurable:!1,writable:!1})}static $factory(e){if(!e)throw new Error("The $factory method requires a component’s name or selector to be specified.");return a(e).map(e=>new this(e).$mount())}$on(e,t,i){return this.__debug("$on",e,t,i),this.$el.addEventListener(e,t,i),()=>{this.$off(e,t,i)}}$off(e,t,i){this.__debug("$off",e,t),this.$el.removeEventListener(e,t,i)}$emit(e){var t=[].slice.call(arguments,1);this.__debug("$emit",e,t),this.$el.dispatchEvent(new CustomEvent(e,{detail:t}))}}function U(e){var{breakpoint:t}=w().props();e.forEach(e=>{var[i,r]=e;i.includes(t)&&!r.$isMounted?setTimeout(()=>r.$mount(),0):!i.includes(t)&&r.$isMounted&&r.$destroy()})}X.$isBase=!0;var Z=new WeakMap;function J(e,t){void 0===t&&(t=w().props().breakpoint);var{activeBreakpoints:i,inactiveBreakpoints:r}=e.$options,s=i&&i.split(" ").includes(t),n=r&&r.split(" ").includes(t);return i&&s||r&&!n?"$mount":"$destroy"}function K(e){var{activeBreakpoints:t,inactiveBreakpoints:i}=e.$options;return Boolean(t||i)}function Q(e,t){!function(e){var{activeBreakpoints:t,inactiveBreakpoints:i,name:r}=e.$options;if(t&&i)throw new Error("["+r+"] Incorrect configuration: the `activeBreakpoints` and `inactiveBreakpoints` are not compatible.")}(t);var{add:i,has:r}=w();r(e)||i(e,function(e){var{breakpoint:i}=e,r=J(t,i);"$destroy"===r&&t.$isMounted?t[r]():"$mount"!==r||t.$isMounted||setTimeout(()=>t[r](),0)})}function ee(e,t,i){if(void 0===i&&(i=.85),i>=1||i<=0)throw new Error("The `factor` parameter must be a number greater than 0 and smaller than 1, `"+i+"` given.");for(var r=t,s=e;Math.abs(r)>.1;)s+=r,r*=i;return s}var te="drag",ie="inertia",re=0;class se extends u{constructor(e,i){return void 0===i&&(i={}),super(),this.isGrabbing=!1,this.hasInertia=!1,this.x=0,this.y=0,this.delta={x:0,y:0},this.origin={x:0,y:0},this.distance={x:0,y:0},this.final={x:0,y:0},this.options={factor:.85},this.id="drag-"+(re+=1),this.target=e,this.options=t({},this.options,i),this.pointerHandler=this.pointerHandler.bind(this),this.rafHandler=this.rafHandler.bind(this),this}init(){var e={passive:!0};return this.target.addEventListener("mousedown",this,e),this.target.addEventListener("touchstart",this,e),m().add(this.id,this.pointerHandler),this}kill(){return this.target.removeEventListener("mousemove",this),this.target.removeEventListener("touchmove",this),m().remove(this.id),this}handleEvent(e){var t=e instanceof MouseEvent?e.clientX:e.touches[0].clientX,i=e instanceof MouseEvent?e.clientY:e.touches[0].clientY;this.start(t,i)}start(e,t){this.x=e,this.y=t,this.origin.x=e,this.origin.y=t,this.delta.x=0,this.delta.y=0,this.distance.x=0,this.distance.y=0,this.final.x=e,this.final.y=t,this.mode="start",this.isGrabbing=!0,this.trigger(this.props)}drop(){this.isGrabbing=!1,this.mode="drop",this.hasInertia=!0,this.final.x=ee(this.x,this.delta.x,this.options.factor),this.final.y=ee(this.y,this.delta.y,this.options.factor),this.trigger(this.props),setTimeout(()=>{var e=f();e.remove(this.id),e.add(this.id,this.rafHandler)},0)}stop(){f().remove(this.id),this.hasInertia=!1,this.mode="stop",this.trigger(this.props)}rafHandler(){this.isGrabbing||(this.x+=this.delta.x,this.y+=this.delta.y,this.distance.x=this.x-this.origin.x,this.distance.y=this.y-this.origin.y,this.delta.x*=this.options.factor,this.delta.y*=this.options.factor,this.mode!==ie&&(this.mode=ie),this.trigger(this.props),Math.abs(this.delta.x)<.1&&Math.abs(this.delta.y)<.1&&this.stop())}pointerHandler(e){this.isGrabbing&&(this.x=e.x,this.y=e.y,this.delta.x=e.delta.x,this.delta.y=e.delta.y,this.final.x=e.x,this.final.y=e.y,this.distance.x=this.x-this.origin.x,this.distance.y=this.y-this.origin.y,this.mode!==te&&(this.mode=te),this.trigger(this.props),e.isDown||this.drop())}get props(){return{target:this.target,mode:this.mode,isGrabbing:this.isGrabbing,hasInertia:this.hasInertia,x:this.x,y:this.y,delta:this.delta,origin:this.origin,distance:this.distance,final:this.final}}}var ne=new WeakMap;function oe(e,t){var i=ne.get(e);return i||(i=new se(e,t),ne.set(e,i)),{add:i.add.bind(i),remove:i.remove.bind(i),has:i.has.bind(i),props:()=>i.props}}var ae=["target"];function he(e,t){return"string"==typeof e?a(e,t):Array.isArray(e)?e:[e]}e.Base=X,e.createApp=function(e,t){var i,r="complete"===document.readyState;r?i=new e(t).$mount():document.addEventListener("readystatechange",()=>{"complete"===document.readyState&&(i=new e(t).$mount(),r=!0)});var s=new Promise(e=>{document.addEventListener("readystatechange",()=>{"complete"===document.readyState&&setTimeout(()=>e(i),0)})});return function(){return r?Promise.resolve(i):s}},e.importOnInteraction=function(e,t,i,r){var s="string"==typeof i?[i]:i;return new Promise(i=>{var n=he(t,null==r?void 0:r.$el),o={capture:!0,passive:!0,once:!0},a=()=>{(t=>{e().then(e=>{t("default"in e?e.default:e)})})(i)};n.forEach(e=>{s.forEach(t=>{e.addEventListener(t,a,o)})})})},e.importWhenIdle=function(e,t){var i=t=>{e().then(e=>{t("default"in e?e.default:e)})};return new Promise(e=>{var r,s=null!=(r=null==t?void 0:t.timeout)?r:1;"requestIdleCallback"in window?window.requestIdleCallback(()=>{setTimeout(()=>{i(e)},0)},{timeout:null==t?void 0:t.timeout}):setTimeout(()=>{i(e)},s)})},e.importWhenVisible=function(e,t,i,r){return void 0===r&&(r={}),new Promise(s=>{var n=new IntersectionObserver(t=>{t.some(e=>e.isIntersecting)&&setTimeout(()=>{((t,i)=>{e().then(e=>{t("default"in e?e.default:e),n.disconnect()})})(s)},0)},r);he(t,null==i?void 0:i.$el).forEach(e=>n.observe(e))})},e.useDrag=oe,e.useKey=L,e.useLoad=j,e.usePointer=m,e.useRaf=f,e.useResize=w,e.useScroll=x,e.withBreakpointManager=function(e,t){if(!Array.isArray(t))throw new Error("[withBreakpointManager] The `breakpoints` parameter must be an array.");if(t.length<2)throw new Error("[withBreakpointManager] You must define at least 2 breakpoints.");var{add:i,props:r}=w();if(!r().breakpoint)throw new Error("The `BreakpointManager` class requires breakpoints to be defined.");return class extends e{constructor(e){return super(e),Z.has(this)||Z.set(this,function(e,t){return t.map(t=>{var[i,r]=t,s=new r(e.$el);return Object.defineProperty(s,"$parent",{get:()=>e.$parent}),[i,s]})}(this,t)),i("BreakpointManager-"+this.$id,()=>{U(Z.get(this))}),this.instances=Z.get(this),this}$mount(){return super.$mount(),U(Z.get(this)),this}$destroy(){return Array.isArray(Z.get(this))&&Z.get(this).forEach(e=>{var[,t]=e;t.$destroy()}),super.$destroy()}}},e.withBreakpointObserver=function(e){var i,r,s,n,o;return r=i=class extends e{constructor(e){super(e);var{remove:t,props:i}=w(),{name:r}=this.$options;if(!i().breakpoint)throw new Error("["+r+"] The `BreakpointObserver` class requires breakpoints to be defined.");var s="BreakpointObserver-"+this.$id;return new MutationObserver(e=>{var[i]=e;if("attributes"===i.type&&("data-options"===i.attributeName||i.attributeName.startsWith("data-option-"))){if(!K(this))return this.$mount(),void t(s);Q(s,this)}}).observe(this.$el,{attributes:!0}),K(this)?(Q(s,this),this):this}$mount(){return K(this)?"$mount"===J(this)?super.$mount():this:super.$mount()}},i.config=t({},e.config||{},{name:(null!=(s=null==e||null==(n=e.config)?void 0:n.name)?s:"")+"WithBreakpointObserver",options:t({},(null==e||null==(o=e.config)?void 0:o.options)||{},{activeBreakpoints:String,inactiveBreakpoints:String})}),r},e.withDrag=function(e,t){return void 0===t&&(t={target(){return this.$el}}),class extends e{constructor(e){super(e),this.$on("mounted",()=>{var{target:e}=t,i=function(e,t){if(null==e)return{};var i,r,s={},n=Object.keys(e);for(r=0;r<n.length;r++)t.indexOf(i=n[r])>=0||(s[i]=e[i]);return s}(t,ae),r=oe.bind(void 0,e.call(this),i);this.$services.register("dragged",r),this.$services.enable("dragged")}),this.$on("destroyed",()=>{this.$services.disable("dragged"),this.$services.unregister("dragged")})}}},e.withExtraConfig=function(e,t,i){var r,s;void 0===i&&(i={});var n=V(e.config,t,i);return n.name===e.config.name&&(n.name=e.config.name+"WithExtraConfig"),s=r=class extends e{},r.config=n,s},e.withIntersectionObserver=function(e,i){var r,s,n,o,a;return void 0===i&&(i={threshold:[...new Array(101)].map((e,t)=>t/100)}),s=r=class extends e{constructor(e){if(super(e),!this.intersected||"function"!=typeof this.intersected)throw new Error("[withIntersectionObserver] The `intersected` method must be defined.");return this.$observer=new IntersectionObserver(e=>{this.__debug("intersected",e),this.$emit("intersected",e),this.intersected(e)},t({},i,this.$options.intersectionObserver||{})),this.$on("mounted",()=>{this.$observer.observe(this.$el)}),this.$on("destroyed",()=>{this.$observer.unobserve(this.$el)}),this}},r.config=t({},e.config||{},{name:(null!=(n=null==e||null==(o=e.config)?void 0:o.name)?n:"")+"WithIntersectionObserver",options:t({},(null==e||null==(a=e.config)?void 0:a.options)||{},{intersectionObserver:Object})}),s},e.withMountWhenInView=function(e,i){var n,o,a,h,d,u,l;return void 0===i&&(i={threshold:[0,1]}),o=r("isVisible"),a=r("observer"),h=n=class extends e{constructor(e){return super(e),Object.defineProperty(this,o,{writable:!0,value:!1}),Object.defineProperty(this,a,{writable:!0,value:void 0}),s(this,a)[a]=new IntersectionObserver(e=>{var t=e.reduce((e,t)=>e||t.isIntersecting,!1);s(this,o)[o]!==t&&(s(this,o)[o]=t,this[t?"$mount":"$destroy"]())},t({},i,this.$options.intersectionObserver)),s(this,a)[a].observe(this.$el),this.$on("terminated",()=>{s(this,a)[a].disconnect()}),this}$mount(){return s(this,o)[o]&&super.$mount(),this}},n.config=t({},e.config||{},{name:(null!=(d=null==e||null==(u=e.config)?void 0:u.name)?d:"")+"WithMountWhenInView",options:t({},(null==e||null==(l=e.config)?void 0:l.options)||{},{intersectionObserver:Object})}),h}});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@studiometa/js-toolkit",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.8",
|
|
4
4
|
"description": "A set of useful little bits of JavaScript to boost your project! 🚀",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"type": "module",
|
|
19
19
|
"sideEffects": false,
|
|
20
20
|
"unpkg": "./index.umd.js",
|
|
21
|
-
"main": "./index.
|
|
21
|
+
"main": "./index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"keywords": [
|
|
24
24
|
"js-toolkit",
|
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
"types": "index.d.ts",
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@babel/runtime": "^7.15.4",
|
|
32
|
-
"deepmerge": "^4.2.2"
|
|
33
|
-
"stylefire": "^7.0.3"
|
|
32
|
+
"deepmerge": "^4.2.2"
|
|
34
33
|
}
|
|
35
34
|
}
|
package/services/Service.js
CHANGED
package/services/drag.js
CHANGED
package/services/index.js
CHANGED
|
@@ -5,5 +5,4 @@ import usePointer from './pointer.js';
|
|
|
5
5
|
import useRaf from './raf.js';
|
|
6
6
|
import useResize from './resize.js';
|
|
7
7
|
import useScroll from './scroll.js';
|
|
8
|
-
export { useKey, usePointer, useDrag, useLoad, useRaf, useResize, useScroll };
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
|
8
|
+
export { useKey, usePointer, useDrag, useLoad, useRaf, useResize, useScroll };
|
package/services/key.js
CHANGED
package/services/load.d.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*
|
|
12
12
|
* @return {ServiceInterface & LoadService}
|
|
13
13
|
*/
|
|
14
|
-
export default function
|
|
14
|
+
export default function useLoad(): ServiceInterface & LoadService;
|
|
15
15
|
export type ServiceInterface = import('./index').ServiceInterface;
|
|
16
16
|
export type LoadServiceProps = {
|
|
17
17
|
time: DOMHighResTimeStamp;
|
package/services/load.js
CHANGED
|
@@ -22,7 +22,7 @@ class Load extends Service {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
var instance = null;
|
|
25
|
-
export default function
|
|
25
|
+
export default function useLoad() {
|
|
26
26
|
if (!instance) {
|
|
27
27
|
instance = new Load();
|
|
28
28
|
}
|
|
@@ -41,5 +41,4 @@ export default function useRaf() {
|
|
|
41
41
|
has,
|
|
42
42
|
props
|
|
43
43
|
};
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=load.js.map
|
|
44
|
+
}
|
package/services/pointer.js
CHANGED
package/services/raf.js
CHANGED
package/services/resize.js
CHANGED
|
@@ -52,10 +52,6 @@ class Resize extends Service {
|
|
|
52
52
|
return breakpoints.split(',');
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
get canUseResizeObserver() {
|
|
56
|
-
return typeof window.ResizeObserver !== 'undefined';
|
|
57
|
-
}
|
|
58
|
-
|
|
59
55
|
}
|
|
60
56
|
|
|
61
57
|
var resize = null;
|
|
@@ -76,5 +72,4 @@ export default function useResize() {
|
|
|
76
72
|
has,
|
|
77
73
|
props
|
|
78
74
|
};
|
|
79
|
-
}
|
|
80
|
-
//# sourceMappingURL=resize.js.map
|
|
75
|
+
}
|
package/services/scroll.js
CHANGED
package/utils/collide/index.js
CHANGED
|
@@ -4,5 +4,4 @@ import boundingRectToCircle from './boundingRectToCircle.js';
|
|
|
4
4
|
import collideCircleRect from './collideCircleRect.js';
|
|
5
5
|
import collideCircleCircle from './collideCircleCircle.js';
|
|
6
6
|
import collidePointCircle from './collidePointCircle.js';
|
|
7
|
-
export { collidePointRect, collideRectRect, boundingRectToCircle, collideCircleRect, collideCircleCircle, collidePointCircle };
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
|
7
|
+
export { collidePointRect, collideRectRect, boundingRectToCircle, collideCircleRect, collideCircleCircle, collidePointCircle };
|
package/utils/css/classes.js
CHANGED
package/utils/css/index.js
CHANGED
|
@@ -2,5 +2,4 @@ import * as classes from './classes.js';
|
|
|
2
2
|
import * as styles from './styles.js';
|
|
3
3
|
import matrix from './matrix.js';
|
|
4
4
|
import transition from './transition.js';
|
|
5
|
-
export { classes, styles, matrix, transition };
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
|
5
|
+
export { classes, styles, matrix, transition };
|
package/utils/css/matrix.js
CHANGED
|
@@ -3,5 +3,4 @@ export default function matrix(transform) {
|
|
|
3
3
|
|
|
4
4
|
transform = transform || {};
|
|
5
5
|
return "matrix(".concat((_transform$scaleX = transform.scaleX) !== null && _transform$scaleX !== void 0 ? _transform$scaleX : 1, ", ").concat((_transform$skewY = transform.skewY) !== null && _transform$skewY !== void 0 ? _transform$skewY : 0, ", ").concat((_transform$skewX = transform.skewX) !== null && _transform$skewX !== void 0 ? _transform$skewX : 0, ", ").concat((_transform$scaleY = transform.scaleY) !== null && _transform$scaleY !== void 0 ? _transform$scaleY : 1, ", ").concat((_transform$translateX = transform.translateX) !== null && _transform$translateX !== void 0 ? _transform$translateX : 0, ", ").concat((_transform$translateY = transform.translateY) !== null && _transform$translateY !== void 0 ? _transform$translateY : 0, ")");
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=matrix.js.map
|
|
6
|
+
}
|
package/utils/css/styles.js
CHANGED
package/utils/css/transition.js
CHANGED
package/utils/debounce.js
CHANGED
package/utils/focusTrap.js
CHANGED
package/utils/history.js
CHANGED
|
@@ -37,7 +37,7 @@ function updateUrlSearchParam(params, name, value) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
export function objectToURLSearchParams(obj) {
|
|
40
|
-
var defaultSearch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window.location.search;
|
|
40
|
+
var defaultSearch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : typeof window === 'undefined' ? '' : window.location.search;
|
|
41
41
|
return Object.entries(obj).reduce((urlSearchParams, _ref2) => {
|
|
42
42
|
var [name, value] = _ref2;
|
|
43
43
|
return updateUrlSearchParam(urlSearchParams, name, value);
|
|
@@ -86,5 +86,4 @@ export function push(options, data, title) {
|
|
|
86
86
|
}
|
|
87
87
|
export function replace(options, data, title) {
|
|
88
88
|
updateHistory('replace', options, data, title);
|
|
89
|
-
}
|
|
90
|
-
//# sourceMappingURL=history.js.map
|
|
89
|
+
}
|
package/utils/index.d.ts
CHANGED
|
@@ -5,8 +5,9 @@ import focusTrap from "./focusTrap.js";
|
|
|
5
5
|
import * as history from "./history.js";
|
|
6
6
|
import keyCodes from "./keyCodes.js";
|
|
7
7
|
import * as math from "./math/index.js";
|
|
8
|
+
import memoize from "./memoize.js";
|
|
8
9
|
import nextFrame from "./nextFrame.js";
|
|
9
10
|
import * as object from "./object/index.js";
|
|
10
11
|
import * as string from "./string/index.js";
|
|
11
12
|
import throttle from "./throttle.js";
|
|
12
|
-
export { collide, css, debounce, focusTrap, history, keyCodes, math, nextFrame, object, string, throttle };
|
|
13
|
+
export { collide, css, debounce, focusTrap, history, keyCodes, math, memoize, nextFrame, object, string, throttle };
|
package/utils/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import * as string from './string/index.js';
|
|
|
7
7
|
import debounce from './debounce.js';
|
|
8
8
|
import focusTrap from './focusTrap.js';
|
|
9
9
|
import keyCodes from './keyCodes.js';
|
|
10
|
+
import memoize from './memoize.js';
|
|
10
11
|
import nextFrame from './nextFrame.js';
|
|
11
12
|
import throttle from './throttle.js';
|
|
12
|
-
export { collide, css, debounce, focusTrap, history, keyCodes, math, nextFrame, object, string, throttle };
|
|
13
|
-
//# sourceMappingURL=index.js.map
|
|
13
|
+
export { collide, css, debounce, focusTrap, history, keyCodes, math, memoize, nextFrame, object, string, throttle };
|
package/utils/keyCodes.js
CHANGED
package/utils/math/clamp.js
CHANGED