xtendui
Version:
Xtend UI is a powerful frontend library of Tailwind CSS components enhanced by vanilla js. It helps you build interfaces with advanced interactions and animations.
3 lines • 7.97 kB
JavaScript
/*! For license information please see 986.min.js.LICENSE.txt */
;(globalThis.webpackChunkxtendui=globalThis.webpackChunkxtendui||[]).push([[986],{2324:(t,e,o)=>{var n=o(2138),s=o(8026),a=o(6933),r=o(4274),i=URLSearchParams,c=i.prototype,l=s(c.getAll),h=s(c.has),d=new i("a=1");!d.has("a",2)&&d.has("a",void 0)||n(c,"has",(function(t){var e=arguments.length,o=e<2?void 0:arguments[1];if(e&&void 0===o)return h(this,t);var n=l(this,t);r(e,1);for(var s=a(o),i=0;i<n.length;)if(n[i++]===s)return!0;return!1}),{enumerable:!0,unsafe:!0})},3385:(t,e,o)=>{var n=o(2138),s=o(8026),a=o(6933),r=o(4274),i=URLSearchParams,c=i.prototype,l=s(c.append),h=s(c.delete),d=s(c.forEach),u=s([].push),v=new i("a=1&a=2&b=3");v.delete("a",1),v.delete("b",void 0),v+""!="a=2"&&n(c,"delete",(function(t){var e=arguments.length,o=e<2?void 0:arguments[1];if(e&&void 0===o)return h(this,t);var n=[];d(this,(function(t,e){u(n,{key:e,value:t})})),r(e,1);for(var s,i=a(t),c=a(o),v=0,g=0,f=!1,p=n.length;v<p;)s=n[v++],f||s.key===i?(f=!0,h(this,s.key)):g++;for(;g<p;)(s=n[g++]).key===i&&s.value===c||l(this,s.key,s.value)}),{enumerable:!0,unsafe:!0})},4274:t=>{var e=TypeError;t.exports=function(t,o){if(t<o)throw new e("Not enough arguments");return t}},4303:(t,e,o)=>{var n=o(6846),s=o(8026),a=o(5096),r=URLSearchParams.prototype,i=s(r.forEach);n&&!("size"in r)&&a(r,"size",{get:function(){var t=0;return i(this,(function(){t++})),t},configurable:!0,enumerable:!0})},4986:(t,e,o)=>{o.r(e),o.d(e,{ScrolltoInit:()=>s});o(793),o(6961),o(4615),o(2925),o(9526),o(3385),o(2324),o(4303);var n=o(5498);class s{_init(){this._initVars(),this._initLogic()}_initVars(){const t=this;t._optionsDefault=n.Xt.merge([t.constructor.optionsDefault,n.Xt.options[t.componentName]]),t.options=n.Xt.merge([t._optionsDefault,t._optionsCustom])}_initLogic(){const t=this,e=t.options;t.ns=t.ns??n.Xt.uniqueId(),t.initial=!0,t._classes=e.class?e.class.split(" "):[];const o=n.Xt.dataStorage.put(t.container,`click/${t.ns}`,t._eventChange.bind(t,{}));t.container.addEventListener("click",o);const s=n.Xt.dataStorage.put(window,`scrollto/${t.ns}`,t._eventScrollto.bind(t,{}));addEventListener(`scrollto.trigger.${t._componentNs}`,s,!0);const a=n.Xt.dataStorage.put(window,`hashchange/${t.ns}`,t._eventChange.bind(t).bind(t,{hashchange:!0}));addEventListener("hashchange",a),t.scrollers=[document.scrollingElement,...document.querySelectorAll(e.scrollers)].reverse();for(const o of t.scrollers)if(o){const s=n.Xt.dataStorage.put(o,`scroll/${t.ns}`,t._eventActivationHandler.bind(t).bind(t,{scroller:o})),a=e.events?e.events.split(" "):[];if(o===document.scrollingElement)for(const t of a)addEventListener(t,s);else for(const t of a)o.addEventListener(t,s)}n.Xt.ready({state:"complete",func:()=>{t.container.dispatchEvent(new CustomEvent(`setup.${t._componentNs}`)),n.Xt.frameDouble({el:t.container,ns:`${t.ns}Init`,func:()=>{t._initStart(),t.container.setAttribute(`data-${t.componentName}-init`,""),t.container.dispatchEvent(new CustomEvent(`init.${t._componentNs}`)),t.initial=!1,e.debug&&console.debug(`${t.componentName} init`,t)}})}})}_initStart(){const t=this;t._eventStart();for(const e of t.scrollers)e&&t._eventActivationHandler({scroller:e})}_eventStart(){const t=this,e=t.options,o=location.hash;if(o){const n=t.container.querySelector(e.anchors.replace("{hash}",o));n&&t._eventChange({el:n})}}_eventScrollto(){let{el:t,tr:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=arguments.length>1?arguments[1]:void 0;const n=this,s=n.options;if(n.hashchange=!!t&&n.hashchange,t=t??o.target,t&&t.nodeName&&t!==window&&(n.target=e??t,n.target)){for(const t of n.scrollers)if(t&&t.contains(n.target)){n.scroller=t;break}(s.hash||t.getAttribute("data-xt-scrollto-hash"))&&n.target.dispatchEvent(new CustomEvent("openauto.trigger.xt")),n._eventScrolltoLogic()}}_eventScrolltoLogic(){const t=this,e=t.options;if(n.Xt.visible({el:t.target})){t.hashchange=n.Xt.scrolltoHashforce??t.hashchange,n.Xt.scrolltoHashforce=null,t.position=e.position({self:t}),t.space=e.space({self:t}),t.duration=e.duration({self:t}),t.position=t.position-t.space;const o=0,s=t.scroller.scrollHeight-t.scroller.clientHeight;t.position=t.position<o?o:t.position,t.position=t.position>s?s:t.position,t.scroller.scrollTop===t.position&&t.scroller.dispatchEvent(new CustomEvent("scroll")),t.container.dispatchEvent(new CustomEvent(`scrollto.${t._componentNs}`))}}_eventChange(t,e){let{hashchange:o=!1,el:n}=t;const s=this,a=s.options;if(s.hashchange=!1,o){s.hashchange=!0;const t=location.hash,e=s.container.querySelector(a.anchors.replace("{hash}",t));e&&(a.hash||e.getAttribute("data-xt-scrollto-hash"))&&(n=e)}if(n=n??e.target,n&&n.nodeName&&n!==window&&(n=n.closest(a.anchors.replace("{hash}","#")),n&&n.matches(a.anchors.replace("{hash}","#")))){const t=new URL(n.getAttribute("href"),location);if(t.hash&&t.pathname===location.pathname&&(!o||location.hash===n.hash)){const r=o?t.hash:n.hash.toString(),i=s.container.querySelector(r);if(i){e&&e.preventDefault();for(const t of s.scrollers)if(t&&t.contains(i)){s.scroller=t;break}o||!a.hash&&"true"!==n.getAttribute("data-xt-scrollto-hash")||"false"===n.getAttribute("data-xt-scrollto-hash")||location.hash===n.hash||history.pushState({},"",t.hash);const r=Array.from(s.container.querySelectorAll(a.anchors.replace("{hash}","#")));for(const t of r)t.classList.remove(...s._classes);n.classList.add(...s._classes),s._eventScrollto({el:n,tr:i})}}}}_eventActivationHandler(){let{scroller:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=this,o=e.options;o.scrollActivation&&(clearTimeout(n.Xt.dataStorage.get(t,`${e.ns}ScrollTimeout`)),n.Xt.dataStorage.set(t,`${e.ns}ScrollTimeout`,setTimeout((()=>{e._eventActivation({scroller:t})}),o.scrollDelay)))}_eventActivation(){let{scroller:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=this,o=e.options;e.target=!1,e.scroller=t;let s=!1,a=e.scroller.scrollTop;const r=e.scroller.scrollHeight;a+e.scroller.clientHeight>=r&&(a=r);const i=Array.from(e.container.querySelectorAll(o.anchors.replace("{hash}","#")));for(const t of i){for(const o of e.scrollers)if(o){if(o===e.scroller)break;if(o.contains(t))return}const r=new URL(t.getAttribute("href"),location);if(r.hash){try{document.createDocumentFragment().querySelector(r.hash)}catch{continue}if(e.target=document.querySelector(r.hash),e.target&&n.Xt.visible({el:e.target})){const t=o.position({self:e}),n=o.space({self:e});if(a>=Math.floor(t-n)){const t=o.anchors.replace("{hash}",r.hash),n=i.filter((e=>e.matches(t)));s=!!n.length;for(const t of i.filter((t=>!n.includes(t))))t.classList.remove(...e._classes);for(const t of n)e._classes.length&&!t.classList.contains(...e._classes)&&t.classList.add(...e._classes)}}}}if(!s&&e.target)for(const t of i)t.classList.remove(...e._classes)}enable(){const t=this;t.disabled&&(t.disabled=!1,t.container.dispatchEvent(new CustomEvent(`status.${t._componentNs}`)))}disable(){let{skipEvent:t=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=this;e.disabled||(e.disabled=!0,t||e.container.dispatchEvent(new CustomEvent(`status.${e._componentNs}`)))}reinit(){this._initLogic()}destroy(){const t=this,e=t.options,o=n.Xt.dataStorage.get(t.container,`click/${t.ns}`);t.container.removeEventListener("click",o);const s=n.Xt.dataStorage.get(window,`scrollto/${t.ns}`);removeEventListener(`scrollto.trigger.${t._componentNs}`,s,!0);const a=n.Xt.dataStorage.get(window,`hashchange/${t.ns}`);removeEventListener("hashchange",a);for(const o of t.scrollers)if(o){const s=n.Xt.dataStorage.get(o,`scroll/${t.ns}`),a=e.events?e.events.split(" "):[];if(o===document.scrollingElement)for(const t of a)removeEventListener(t,s);else for(const t of a)o.removeEventListener(t,s)}t.container.removeAttribute(`data-${t.componentName}-init`),n.Xt._remove({name:t.componentName,el:t.container}),t.container.dispatchEvent(new CustomEvent(`destroy.${t._componentNs}`))}}}}]);
//# sourceMappingURL=986.min.js.map