aptechka 0.97.1 → 0.97.3
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/lib/{Damped-DTVkIAqc.cjs → Damped-BAQBov5D.cjs} +1 -1
- package/lib/{Damped-BxBI6Dds.js → Damped-BhEzeWpa.js} +1 -1
- package/lib/{DragControls-CqNPYkc2.cjs → DragControls-F2rdrdaN.cjs} +1 -1
- package/lib/{DragControls-DDFMqZg4.js → DragControls-K3bJpg3q.js} +2 -2
- package/lib/{ScrollNavigator-CNKI1Iae.cjs → ScrollNavigator-8_lZG25T.cjs} +1 -1
- package/lib/{ScrollNavigator-CiZjoiyk.js → ScrollNavigator-CA93_yQT.js} +1 -1
- package/lib/{Tweened-BAR8oYF3.js → Tweened-BBO6Q8Ac.js} +1 -1
- package/lib/{Tweened-FpbbJ3xC.cjs → Tweened-BsMp2sCL.cjs} +1 -1
- package/lib/{Tweened-9ATB544_.js → Tweened-CSKUDxZu.js} +1 -1
- package/lib/{Tweened-BNb6DQ39.cjs → Tweened-DajVDfaz.cjs} +1 -1
- package/lib/animation/index.cjs +1 -1
- package/lib/animation/index.js +1 -1
- package/lib/animation-kit/index.cjs +1 -1
- package/lib/animation-kit/index.js +3 -3
- package/lib/api-fetcher/index.cjs +1 -1
- package/lib/api-fetcher/index.js +1 -1
- package/lib/controls/index.cjs +1 -1
- package/lib/controls/index.js +1 -1
- package/lib/{easings-D9LNSyOP.js → easings-B6c-XGye.js} +1 -1
- package/lib/easings-CjBFuwDt.cjs +1 -0
- package/lib/en3/En3.d.ts +1 -1
- package/lib/en3/En3View.d.ts +1 -1
- package/lib/en3/index.cjs +1 -1
- package/lib/en3/index.js +9 -1
- package/lib/morph/index.cjs +1 -1
- package/lib/morph/index.js +2 -2
- package/lib/popover/PopoverElement.d.ts +1 -0
- package/lib/popover/index.cjs +1 -1
- package/lib/popover/index.js +78 -12
- package/lib/scroll/index.cjs +1 -1
- package/lib/scroll/index.js +3 -3
- package/lib/scroll-kit/index.cjs +1 -1
- package/lib/scroll-kit/index.js +2 -2
- package/lib/spa/index.cjs +1 -1
- package/lib/spa/index.js +1 -1
- package/lib/utils/index.cjs +1 -1
- package/lib/utils/index.js +1 -1
- package/package.json +13 -13
- package/lib/easings-Bgvyia2r.cjs +0 -1
package/lib/morph/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __defProp=Object.defineProperty,__defProps=Object.defineProperties;var __getOwnPropDescs=Object.getOwnPropertyDescriptors;var __getOwnPropSymbols=Object.getOwnPropertySymbols;var __hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable;var __knownSymbol=(name,symbol)=>(symbol=Symbol[name])?symbol:Symbol.for("Symbol."+name),__typeError=msg=>{throw TypeError(msg)};var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,__spreadValues=(a,b)=>{for(var prop in b||(b={}))__hasOwnProp.call(b,prop)&&__defNormalProp(a,prop,b[prop]);if(__getOwnPropSymbols)for(var prop of __getOwnPropSymbols(b))__propIsEnum.call(b,prop)&&__defNormalProp(a,prop,b[prop]);return a},__spreadProps=(a,b)=>__defProps(a,__getOwnPropDescs(b)),__name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __accessCheck=(obj,member,msg)=>member.has(obj)||__typeError("Cannot "+msg);var __privateGet=(obj,member,getter)=>(__accessCheck(obj,member,"read from private field"),getter?getter.call(obj):member.get(obj)),__privateAdd=(obj,member,value)=>member.has(obj)?__typeError("Cannot add the same private member more than once"):member instanceof WeakSet?member.add(obj):member.set(obj,value),__privateSet=(obj,member,value,setter)=>(__accessCheck(obj,member,"write to private field"),setter?setter.call(obj,value):member.set(obj,value),value),__privateMethod=(obj,member,method)=>(__accessCheck(obj,member,"access private method"),method);var __async=(__this,__arguments,generator)=>new Promise((resolve,reject)=>{var fulfilled=value=>{try{step(generator.next(value))}catch(e){reject(e)}},rejected=value=>{try{step(generator.throw(value))}catch(e){reject(e)}},step=x=>x.done?resolve(x.value):Promise.resolve(x.value).then(fulfilled,rejected);step((generator=generator.apply(__this,__arguments)).next())});var __forAwait=(obj,it,method)=>(it=obj[__knownSymbol("asyncIterator")])?it.call(obj):(obj=obj[__knownSymbol("iterator")](),it={},method=(key,fn)=>(fn=obj[key])&&(it[key]=arg=>new Promise((yes,no,done)=>(arg=fn.call(obj,arg),done=arg.done,Promise.resolve(arg.value).then(value=>yes({value,done}),no)))),method("next"),method("return"),it);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const browser=require("../browser-CIp8NsnF.cjs"),dom=require("../dom-B40i6NXw.cjs"),events=require("../events-UlGk63iC.cjs"),promises=require("../promises-nDm8_iG6.cjs");require("construct-style-sheets-polyfill");require("../index-BrasTsja.cjs");const url=require("../url-D_KuhhOg.cjs"),cssValueParser_index=require("../css-value-parser/index.cjs"),string=require("../string-Bx5N38JG.cjs"),ScrollNavigator=require("../ScrollNavigator-CNKI1Iae.cjs"),shared_index=require("../shared/index.cjs"),_MorphAnnouncer=class _MorphAnnouncer extends HTMLElement{connectedCallback(){const attrs={"aria-live":"assertive","aria-atomic":"true",style:"position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px"};for(const[key,value]of Object.entries(attrs))this.setAttribute(key,value)}};__name(_MorphAnnouncer,"MorphAnnouncer");let MorphAnnouncer=_MorphAnnouncer;browser.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",MorphAnnouncer);var _morph,_element,_MorphLink_instances,path_get,click_fn,_clickListener,_pointerListener;const _MorphLink=class _MorphLink{constructor(element,morph){__privateAdd(this,_MorphLink_instances);__privateAdd(this,_morph);__privateAdd(this,_element);__privateAdd(this,_clickListener,__name(e=>{e.preventDefault(),__privateMethod(this,_MorphLink_instances,click_fn).call(this)},"#clickListener"));__privateAdd(this,_pointerListener,__name(()=>{const revalidate=__privateGet(this,_element).hasAttribute("data-revalidate");__privateGet(this,_morph).prefetch(__privateGet(this,_MorphLink_instances,path_get),revalidate),__privateGet(this,_element).removeEventListener("pointerenter",__privateGet(this,_pointerListener))},"#pointerListener"));__privateSet(this,_morph,morph),__privateSet(this,_element,element),__privateGet(this,_element).addEventListener("click",__privateGet(this,_clickListener)),this.checkCurrent(location.href.replace(location.origin,"")),__privateGet(this,_element).hasAttribute("data-prefetch")&&__privateGet(this,_element).addEventListener("pointerenter",__privateGet(this,_pointerListener))}get element(){return __privateGet(this,_element)}checkCurrent(path){var _a,_b;const locationUrl=__privateGet(this,_morph).normalizePath(path),linkUrl=__privateGet(this,_morph).normalizePath(__privateGet(this,_MorphLink_instances,path_get));__privateGet(this,_element).hasAttribute("data-include")&&locationUrl.pathname.includes(linkUrl.pathname)?__privateGet(this,_element).classList.add("current"):linkUrl.pathname===locationUrl.pathname?__privateGet(this,_element).classList.add("current"):(_a=__privateGet(this,_element).getAttribute("data-associated-paths"))!=null&&_a.split(",").find(path2=>locationUrl.pathname.includes(path2))?__privateGet(this,_element).classList.add("current"):__privateGet(this,_element).classList.remove("current"),locationUrl.path===linkUrl.path?__privateGet(this,_element).classList.add("exact"):__privateGet(this,_element).classList.remove("exact");const[pathWithoutParams,pathParamsStr]=(_b=__privateGet(this,_MorphLink_instances,path_get).split("#")[0])==null?void 0:_b.split("?"),pathParams=new URLSearchParams(pathParamsStr),locationParams=new URLSearchParams(location.search);let matchCounter=0;for(const[key]of locationParams)pathParams.has(key)&&locationParams.get(key)===pathParams.get(key)&&matchCounter++;matchCounter?(__privateGet(this,_element).classList.toggle("all-params-matched",locationParams.size===matchCounter),__privateGet(this,_element).classList.toggle("some-params-matched",locationParams.size!==matchCounter)):!locationParams.size&&__privateGet(this,_element).hasAttribute("data-match-no-params")?__privateGet(this,_element).classList.add("all-params-matched"):(__privateGet(this,_element).classList.remove("all-params-matched"),__privateGet(this,_element).classList.remove("some-params-matched"));for(const key in __privateGet(this,_element).dataset){const kebabKey=string.camelToKebab(key);if(kebabKey.startsWith("match-param-")){const name=kebabKey.split("match-param-")[1],value=__privateGet(this,_element).dataset[key],className=`param-${name}-matched`;locationParams.has(name)&&locationParams.get(name)===value||!locationParams.has(name)&&(value===""||value==="*"||value==="all"||value==="any"||value==="vse")?__privateGet(this,_element).classList.add(className):__privateGet(this,_element).classList.remove(className)}}}destroy(){__privateGet(this,_element).removeEventListener("click",__privateGet(this,_clickListener)),__privateGet(this,_element).removeEventListener("pointerenter",__privateGet(this,_pointerListener)),__privateGet(this,_element).classList.remove("current","exact")}};_morph=new WeakMap,_element=new WeakMap,_MorphLink_instances=new WeakSet,path_get=__name(function(){const url2=new URL(__privateGet(this,_element).href);return __privateGet(this,_morph).normalizePath(url2.pathname+url2.search+url2.hash).path},"#path"),click_fn=__name(function(){var _a;if(document.documentElement.classList.contains("click-disabled"))return;if(__privateGet(this,_element).hasAttribute("data-back")&&__privateGet(this,_morph).previousURL)history.back();else{const historyAction=__privateGet(this,_element).getAttribute("data-history-action")||"push",centerScroll=__privateGet(this,_element).hasAttribute("data-center-scroll"),offsetScrollRawValue=getComputedStyle(__privateGet(this,_element)).getPropertyValue("--offset-scroll").trim(),offsetScroll=offsetScrollRawValue?cssValueParser_index.cssValueParser.parse(offsetScrollRawValue):void 0,scrollDuration=parseFloat(__privateGet(this,_element).getAttribute("data-scroll-duration")||"0")||void 0,scrollEasing=__privateGet(this,_element).getAttribute("data-scroll-easing")||void 0,revalidate=__privateGet(this,_element).hasAttribute("data-revalidate")||__privateGet(this,_element).hasAttribute("data-pagination-more-link")||__privateGet(this,_element).hasAttribute("data-pagination-set-link")||__privateGet(this,_element).hasAttribute("data-pagination-next-link")||__privateGet(this,_element).hasAttribute("data-pagination-prev-link"),keepSearchParameters=__privateGet(this,_element).hasAttribute("data-keep-search-parameters"),keepScrollPosition=__privateGet(this,_element).hasAttribute("data-keep-scroll-position")||__privateGet(this,_element).hasAttribute("data-pagination-more-link"),scrollBehaviour=__privateGet(this,_element).getAttribute("data-scroll-behaviour"),submorph=(_a=__privateGet(this,_element).getAttribute("data-submorph")||__privateGet(this,_element).getAttribute("data-submorph-append"))==null?void 0:_a.split(",").map(v=>v.trim()),clearState=__privateGet(this,_element).hasAttribute("data-clear-state");let path=__privateGet(this,_MorphLink_instances,path_get);if(__privateGet(this,_element).hasAttribute("data-toggle-params")){const[pathWithoutParams,pathParamsStr]=__privateGet(this,_MorphLink_instances,path_get).split("?"),pathParams=new URLSearchParams(pathParamsStr),locationParams=new URLSearchParams(location.search),resultParams=new URLSearchParams;for(const[key]of pathParams)(!locationParams.has(key)||locationParams.has(key)&&locationParams.get(key)!==pathParams.get(key))&&resultParams.append(key,pathParams.get(key));if(__privateGet(this,_element).hasAttribute("data-merge-params"))for(const[key]of locationParams)pathParams.has(key)||resultParams.append(key,locationParams.get(key));path=`${pathWithoutParams}?${resultParams.toString()}`}__privateGet(this,_morph).navigate(path,{historyAction,centerScroll,offsetScroll,revalidate,keepSearchParameters,submorph,clearState,keepScrollPosition,scrollBehaviour,scrollDuration,scrollEasing,submorphAppend:__privateGet(this,_element).hasAttribute("data-submorph-append"),mergeParams:__privateGet(this,_element).hasAttribute("data-merge-params")&&!__privateGet(this,_element).hasAttribute("data-toggle-params"),detail:__privateGet(this,_element).getAttribute("data-detail"),removeParams:__privateGet(this,_element).getAttribute("data-remove-params")||void 0,scrollTo:__privateGet(this,_element).getAttribute("data-scroll-to")||void 0})}},"#click"),_clickListener=new WeakMap,_pointerListener=new WeakMap,__name(_MorphLink,"MorphLink");let MorphLink=_MorphLink;var _element2,_params,_MorphParamsDependent_instances,update_fn,_urlChangeListener;const _MorphParamsDependent=class _MorphParamsDependent{constructor(element){__privateAdd(this,_MorphParamsDependent_instances);__privateAdd(this,_element2);__privateAdd(this,_params,[]);__privateAdd(this,_urlChangeListener,__name(()=>{__privateMethod(this,_MorphParamsDependent_instances,update_fn).call(this)},"#urlChangeListener"));__privateSet(this,_element2,element);for(const key in __privateGet(this,_element2).dataset){const kebabKey=string.camelToKebab(key);if(kebabKey.startsWith("param-")){const name=kebabKey.split("param-")[1],value=__privateGet(this,_element2).dataset[key];__privateGet(this,_params).push({name,value})}}document.addEventListener("morphURLParametersChange",__privateGet(this,_urlChangeListener)),__privateMethod(this,_MorphParamsDependent_instances,update_fn).call(this)}destroy(){document.removeEventListener("morphURLParametersChange",__privateGet(this,_urlChangeListener))}};_element2=new WeakMap,_params=new WeakMap,_MorphParamsDependent_instances=new WeakSet,update_fn=__name(function(){const locationParams=new URLSearchParams(location.search);let matched=!!__privateGet(this,_params).find(param=>locationParams.has(param.name)&&(locationParams.get(param.name)===param.value||param.value==="*"||param.value==="all"||param.value==="any"||param.value==="vse"||locationParams.get(param.name)==="*"||locationParams.get(param.name)==="all"||locationParams.get(param.name)==="any"||locationParams.get(param.name)==="vse"));!matched&&__privateGet(this,_element2).hasAttribute("data-match-no-params")&&(matched=!__privateGet(this,_params).filter(param=>locationParams.has(param.name)).length);const hideClass=__privateGet(this,_element2).getAttribute("data-hide-class");matched?hideClass?__privateGet(this,_element2).classList.remove(hideClass):__privateGet(this,_element2).style.display="":hideClass?__privateGet(this,_element2).classList.add(hideClass):__privateGet(this,_element2).style.display="none",requestAnimationFrame(()=>{window.dispatchEvent(new CustomEvent("resize"))})},"#update"),_urlChangeListener=new WeakMap,__name(_MorphParamsDependent,"MorphParamsDependent");let MorphParamsDependent=_MorphParamsDependent;const domParser=new DOMParser;var _morph2,_pathname,_scrollState,_initialDocument,_modifiedDocument,_currentDocument,_savedState,_abortController,_fetching,_headers,_needRavalidation;const _MorphRoute=class _MorphRoute{constructor(morph,pathname){__privateAdd(this,_morph2);__privateAdd(this,_pathname);__privateAdd(this,_scrollState,{x:0,y:0});__privateAdd(this,_initialDocument,null);__privateAdd(this,_modifiedDocument,null);__privateAdd(this,_currentDocument,null);__privateAdd(this,_savedState,null);__privateAdd(this,_abortController,null);__privateAdd(this,_fetching,null);__privateAdd(this,_headers);__privateAdd(this,_needRavalidation,!1);__privateSet(this,_morph2,morph),__privateSet(this,_pathname,pathname)}get pathname(){return __privateGet(this,_pathname)}get scrollState(){return __privateGet(this,_scrollState)}get document(){return __privateGet(this,_currentDocument)}needRavalidation(){__privateSet(this,_needRavalidation,!0)}setHeaders(headers){__privateSet(this,_headers,headers)}setInitialDocument(document2){__privateSet(this,_initialDocument,document2.cloneNode(!0))}abort(){var _a;return(_a=__privateGet(this,_abortController))==null?void 0:_a.abort(`[${__privateGet(this,_pathname)}] page loading cancelled`)}fetch(path,currentPath,revalidate){return __async(this,null,function*(){var _a;if(!revalidate&&!__privateGet(this,_needRavalidation)){const shouldUseCache=((_a=__privateGet(this,_initialDocument))==null?void 0:_a.documentElement.getAttribute("data-cache"))&¤tPath!==path,isPopstateNavigation=__privateGet(this,_initialDocument)&&__privateGet(this,_morph2).isPopstateNavigation;if(__privateGet(this,_fetching)||shouldUseCache||isPopstateNavigation)return __privateGet(this,_fetching)}return __privateSet(this,_fetching,new Promise(res=>__async(this,null,function*(){try{__privateSet(this,_abortController,new AbortController);const text=yield(yield fetch(path,{signal:__privateGet(this,_abortController).signal,headers:__spreadValues({"X-MORPH":"true","X-MORPH-REVALIDATE":revalidate?"true":"false","X-MORPH-CURRENT-PATH":encodeURIComponent(currentPath),"X-MORPH-NEW-PATH":encodeURIComponent(path)},__privateGet(this,_headers))})).text(),document2=domParser.parseFromString(text,"text/html");this.setInitialDocument(document2),__privateSet(this,_needRavalidation,!1)}catch(e){console.warn(e)}finally{__privateSet(this,_abortController,null),__privateSet(this,_fetching,null),res()}}))),__privateGet(this,_fetching)})}cloneDocument(){__privateSet(this,_currentDocument,(__privateGet(this,_modifiedDocument)||__privateGet(this,_initialDocument)).cloneNode(!0))}get title(){let title="";if(__privateGet(this,_currentDocument).title)title=__privateGet(this,_currentDocument).title;else{const h1=__privateGet(this,_currentDocument).querySelector("h1");title=(h1==null?void 0:h1.innerText)||(h1==null?void 0:h1.textContent)||__privateGet(this,_pathname)}return title}clearScrollState(){__privateGet(this,_scrollState).x=0,__privateGet(this,_scrollState).y=0}clearDocumentState(){__privateSet(this,_modifiedDocument,null)}saveScrollState(){__privateGet(this,_initialDocument).documentElement.hasAttribute("data-no-scroll-restoration")?(__privateGet(this,_scrollState).x=0,__privateGet(this,_scrollState).y=0):(__privateGet(this,_scrollState).x=__privateGet(this,_morph2).scrollValue.left,__privateGet(this,_scrollState).y=__privateGet(this,_morph2).scrollValue.top)}restoreScrollPosition(){__privateGet(this,_morph2).scrollElement.scroll({top:__privateGet(this,_scrollState).y,left:__privateGet(this,_scrollState).x,behavior:"instant"})}saveDocumentState(){__privateGet(this,_initialDocument).documentElement.hasAttribute("data-no-page-restoration")?__privateSet(this,_modifiedDocument,null):__privateSet(this,_modifiedDocument,document.cloneNode(!0))}renewScrollPosition(){__privateGet(this,_morph2).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(state){__privateSet(this,_savedState,state)}clearState(){const state=__privateGet(this,_savedState);return __privateSet(this,_savedState,null),state}};_morph2=new WeakMap,_pathname=new WeakMap,_scrollState=new WeakMap,_initialDocument=new WeakMap,_modifiedDocument=new WeakMap,_currentDocument=new WeakMap,_savedState=new WeakMap,_abortController=new WeakMap,_fetching=new WeakMap,_headers=new WeakMap,_needRavalidation=new WeakMap,__name(_MorphRoute,"MorphRoute");let MorphRoute=_MorphRoute;var _options,_morphElements,_links,_candidateURL,_currentURL,_previousURL,_promises,_isPopstateNavigation,_currentScrollElement,_isWindowScroll,_routes,_paramDependent,_announcer,_currentScrollX,_currentScrollY,_lastSubmorph,_lastRevalidate,_lastKeepScrollPosition,_checkLink,_Morph_instances,getRoute_fn,getMorphElements_fn,isElementEmitsLoadEvent_fn,updateCurrentScrollElement_fn,tryScrollToElement_fn,_popStateListener,_scrollListener;const _Morph=class _Morph{constructor(parameters){__privateAdd(this,_Morph_instances);__privateAdd(this,_options,null);__privateAdd(this,_morphElements,null);__privateAdd(this,_links,[]);__privateAdd(this,_candidateURL);__privateAdd(this,_currentURL,null);__privateAdd(this,_previousURL);__privateAdd(this,_promises,[]);__privateAdd(this,_isPopstateNavigation,!1);__privateAdd(this,_currentScrollElement,null);__privateAdd(this,_isWindowScroll,!1);__privateAdd(this,_routes,new Map);__privateAdd(this,_paramDependent,[]);__privateAdd(this,_announcer,null);__privateAdd(this,_currentScrollX,0);__privateAdd(this,_currentScrollY,0);__privateAdd(this,_lastSubmorph);__privateAdd(this,_lastRevalidate);__privateAdd(this,_lastKeepScrollPosition);__privateAdd(this,_checkLink,__name(element=>{var _a,_b;return(((_a=element.getAttribute("href"))==null?void 0:_a.startsWith("/"))||((_b=element.getAttribute("href"))==null?void 0:_b.startsWith("?")))&&!element.hasAttribute("download")&&!element.hasAttribute("data-morph-skip")&&!element.closest("[data-morph-skip]")&&element.getAttribute("target")!=="_blank"},"#checkLink"));__privateAdd(this,_popStateListener,__name(event=>__async(this,null,function*(){var _a,_b,_c,_d;(_b=(_a=event.state)==null?void 0:_a.data)!=null&&_b.popover||(_d=(_c=event.previousState)==null?void 0:_c.data)!=null&&_d.popover||(__privateSet(this,_isPopstateNavigation,!0),yield this.navigate(location.href.replace(location.origin,""),{historyAction:"none",submorph:__privateGet(this,_lastRevalidate)?void 0:__privateGet(this,_lastSubmorph),revalidate:__privateGet(this,_lastRevalidate),keepScrollPosition:__privateGet(this,_lastKeepScrollPosition)}),__privateSet(this,_isPopstateNavigation,!1))}),"#popStateListener"));__privateAdd(this,_scrollListener,__name(()=>{const{left,top}=this.scrollValue,directionY=top-__privateGet(this,_currentScrollY),directionX=left-__privateGet(this,_currentScrollX);__privateSet(this,_currentScrollY,top),__privateSet(this,_currentScrollX,left),document.documentElement.classList.toggle("scroll-y",top>0),document.documentElement.classList.toggle("scroll-x",left>0),document.documentElement.classList.toggle("scroll-y-forward",directionY>0),document.documentElement.classList.toggle("scroll-y-backward",directionY<0),document.documentElement.classList.toggle("scroll-x-forward",directionX>0),document.documentElement.classList.toggle("scroll-x-backward",directionX<0),events.dispatchEvent(document,"morphScroll",{detail:{left,top}})},"#scrollListener"));if(browser.isBrowser&&!_Morph.instance){_Morph.instance=this,__privateSet(this,_options,{base:url.normalizeBase(parameters==null?void 0:parameters.base),waitForHeadToLoad:(parameters==null?void 0:parameters.waitForHeadToLoad)!==!1,trailingSlash:(parameters==null?void 0:parameters.trailingSlash)||!1,scrollSelector:parameters==null?void 0:parameters.scrollSelector,morphInsideScrollContainer:(parameters==null?void 0:parameters.morphInsideScrollContainer)||!1}),__privateSet(this,_morphElements,__privateMethod(this,_Morph_instances,getMorphElements_fn).call(this,document.body));const normalizedURL=this.normalizePath(location.pathname+location.search+location.hash);__privateSet(this,_currentURL,normalizedURL);const initialRoute=new MorphRoute(this,__privateGet(this,_currentURL).pathname);initialRoute.setInitialDocument(document),__privateGet(this,_routes).set(__privateGet(this,_currentURL).pathname,initialRoute),document.documentElement.setAttribute("data-current-pathname",__privateGet(this,_currentURL).pathname),document.documentElement.setAttribute("data-current-leaf",normalizedURL.leaf),this.findLinks(),this.findParamsDependent(),shared_index.historyManager.addPopStateHandler(__privateGet(this,_popStateListener)),shared_index.historyManager.__change({action:"replace",pathname:normalizedURL.pathname,searchParameters:normalizedURL.parameters,hash:normalizedURL.hash}),__privateSet(this,_announcer,new MorphAnnouncer),__privateMethod(this,_Morph_instances,updateCurrentScrollElement_fn).call(this,document)}}get currentURL(){return __privateGet(this,_currentURL)}get previousURL(){return __privateGet(this,_previousURL)}get links(){return __privateGet(this,_links)}get scrollElement(){return __privateGet(this,_currentScrollElement)}get isPopstateNavigation(){return __privateGet(this,_isPopstateNavigation)}get scrollValue(){let top=0,left=0;return __privateGet(this,_isWindowScroll)?(top=window.scrollY,left=window.scrollX):(top=__privateGet(this,_currentScrollElement).scrollTop,left=__privateGet(this,_currentScrollElement).scrollLeft),{top,left}}get isNavigating(){return!!__privateGet(this,_promises).length}saveState(state){const route=__privateGet(this,_routes).get(__privateGet(this,_currentURL).path);route&&route.saveState(state)}getState(){const route=__privateGet(this,_routes).get(__privateGet(this,_currentURL).path);return route==null?void 0:route.clearState()}normalizePath(path,options){return url.splitPath(path,{base:__privateGet(this,_options).base,trailingSlash:__privateGet(this,_options).trailingSlash,mergeParams:options!=null&&options.mergeParams?location.search:"",removeParams:options==null?void 0:options.removeParams})}prefetch(path,revalidate){return __async(this,null,function*(){var _a;if(__privateGet(this,_promises).length)return;path=((_a=this.pathnameModifier)==null?void 0:_a.call(this,path))||path;const route=__privateMethod(this,_Morph_instances,getRoute_fn).call(this,path);route==null||route.fetch(path,__privateGet(this,_currentURL).path,revalidate)})}excludeHeadChild(child){return!1}needRavalidation(path){const normalizedURL=this.normalizePath(path),route=__privateMethod(this,_Morph_instances,getRoute_fn).call(this,normalizedURL.path);route==null||route.needRavalidation()}navigate(_0){return __async(this,arguments,function*(path,{historyAction="push",centerScroll,offsetScroll,scrollDuration,scrollEasing,scrollBehaviour,revalidate,keepSearchParameters,submorph,submorphAppend,clearState,keepScrollPosition,mergeParams,removeParams,detail,scrollTo}={}){var _a,_b,_c,_d;if(__privateGet(this,_promises).length)return;__privateSet(this,_lastSubmorph,submorph),__privateSet(this,_lastRevalidate,revalidate),__privateSet(this,_lastKeepScrollPosition,keepScrollPosition);const modifiedPath=((_a=this.pathnameModifier)==null?void 0:_a.call(this,path))||path,normalizedURL=this.normalizePath(modifiedPath,{mergeParams,removeParams});if(!revalidate&&(((_b=__privateGet(this,_candidateURL))==null?void 0:_b.pathname)===normalizedURL.pathname||__privateGet(this,_currentURL).pathname===normalizedURL.pathname)){keepScrollPosition||__privateMethod(this,_Morph_instances,tryScrollToElement_fn).call(this,scrollTo||normalizedURL.hash||0,{center:centerScroll,offset:offsetScroll,duration:scrollDuration,easing:scrollEasing,behavior:"smooth"}),events.dispatchEvent(document,"morphSamePath",{detail:{detail}}),((_c=__privateGet(this,_currentURL))==null?void 0:_c.parameters)!==normalizedURL.parameters&&(__privateSet(this,_previousURL,__privateGet(this,_currentURL)),__privateSet(this,_currentURL,normalizedURL),shared_index.historyManager.__change({action:((_d=__privateGet(this,_currentURL))==null?void 0:_d.hash)!==normalizedURL.hash?"replace":historyAction,pathname:normalizedURL.pathname,searchParameters:normalizedURL.parameters,hash:normalizedURL.hash}),events.dispatchEvent(document,"morphURLParametersChange",{detail:{newURL:__privateGet(this,_currentURL),previousURL:__privateGet(this,_previousURL),detail}})),__privateGet(this,_links).forEach(link=>{link.checkCurrent(normalizedURL.path)});return}else __privateGet(this,_links).forEach(link=>{link.checkCurrent(normalizedURL.path)});__privateSet(this,_candidateURL,normalizedURL);try{let preprocessedSuccesfully=!0;if(this.preprocessor)try{yield new Promise((resolve,reject)=>{var _a2;(_a2=this.preprocessor)==null||_a2.call(this,{url:normalizedURL,resolve,reject,submorph,detail})})}catch(e){e?console.error(e):console.log("Route change canceled"),preprocessedSuccesfully=!1}if(!preprocessedSuccesfully||__privateGet(this,_candidateURL).pathname!==normalizedURL.pathname){__privateGet(this,_links).forEach(link=>{link.checkCurrent(__privateGet(this,_currentURL).path)});return}const navigationEntry={url:normalizedURL,submorph,detail};submorph?submorphAppend||submorph.forEach(sel=>{document.querySelectorAll(sel).forEach(el=>{el.classList.add("out"),el.setAttribute("data-morph-out","")})}):__privateGet(this,_morphElements).forEach(el=>{var _a2,_b2;(_a2=el.firstElementChild)==null||_a2.classList.add("out"),(_b2=el.firstElementChild)==null||_b2.setAttribute("data-morph-out","")}),events.dispatchEvent(document,"morphNavigation",{detail:navigationEntry});const currentRoute=__privateMethod(this,_Morph_instances,getRoute_fn).call(this,__privateGet(this,_currentURL).pathname),nextRoute=__privateMethod(this,_Morph_instances,getRoute_fn).call(this,normalizedURL.pathname);if(__privateGet(this,_routes).forEach(el=>{el.pathname!==normalizedURL.pathname&&el.abort()}),yield nextRoute==null?void 0:nextRoute.fetch(modifiedPath,__privateGet(this,_currentURL).path,revalidate),__privateGet(this,_candidateURL).pathname!==normalizedURL.pathname){__privateGet(this,_links).forEach(link=>{link.checkCurrent(__privateGet(this,_currentURL).path)});return}currentRoute.clearState(),currentRoute.saveScrollState(),currentRoute.saveDocumentState(),(!__privateGet(this,_isPopstateNavigation)||revalidate)&&(nextRoute.clearScrollState(),nextRoute.clearDocumentState()),clearState&&nextRoute.clearState(),nextRoute.cloneDocument(),__privateGet(this,_announcer).textContent=nextRoute.title,document.body.appendChild(__privateGet(this,_announcer));const documentFetchedEntry=__spreadProps(__spreadValues({},navigationEntry),{document:nextRoute.document});submorphAppend||documentFetchedEntry.document.querySelectorAll("[data-morph-out]").forEach(el=>{el.classList.remove("out")}),events.dispatchEvent(document,"morphStart",{detail:documentFetchedEntry});const currentHeadChildren=Array.from(document.head.children),newHeadChildren=Array.from(nextRoute.document.head.children),identicalHeadChildren=dom.intersectElements(currentHeadChildren,newHeadChildren),removeHeadChildren=dom.excludeElements(currentHeadChildren,identicalHeadChildren),addHeadChildren=dom.excludeElements(newHeadChildren,identicalHeadChildren).filter(child=>!this.excludeHeadChild(child));addHeadChildren.forEach((child,index)=>{child.tagName==="SCRIPT"&&(addHeadChildren[index]=dom.createScriptElement(child))}),addHeadChildren.forEach(child=>{document.head.appendChild(child)});const elementsWithLoad=addHeadChildren.filter(child=>{if(child.hasAttribute("data-no-waiting"))return!1;if(__privateMethod(this,_Morph_instances,isElementEmitsLoadEvent_fn).call(this,child))return!0});__privateGet(this,_options).waitForHeadToLoad&&elementsWithLoad.length&&(yield new Promise(res=>__async(this,null,function*(){let counter=0;try{for(var iter=__forAwait(elementsWithLoad),more,temp,error;more=!(temp=yield iter.next()).done;more=!1){const element=temp.value;element.onload=()=>{counter++,counter===elementsWithLoad.length&&res()}}}catch(temp){error=[temp]}finally{try{more&&(temp=iter.return)&&(yield temp.call(iter))}finally{if(error)throw error[0]}}}))),yield promises.wait(10);const oldElementsWithLoadEvent=[];submorphAppend||removeHeadChildren.forEach(child=>{child.hasAttribute("data-permanent")||(__privateMethod(this,_Morph_instances,isElementEmitsLoadEvent_fn).call(this,child)?oldElementsWithLoadEvent.push(child):child.remove())});const newMorphElements=__privateMethod(this,_Morph_instances,getMorphElements_fn).call(this,nextRoute.document.body);!__privateGet(this,_options).morphInsideScrollContainer&&!submorph&&__privateMethod(this,_Morph_instances,updateCurrentScrollElement_fn).call(this,nextRoute.document),document.documentElement.setAttribute("data-current-pathname",normalizedURL.pathname),document.documentElement.setAttribute("data-current-leaf",normalizedURL.leaf),shared_index.historyManager.__change({action:historyAction,pathname:normalizedURL.pathname,searchParameters:normalizedURL.parameters||(keepSearchParameters?location.search:""),hash:normalizedURL.hash}),__privateGet(this,_announcer).remove(),__privateSet(this,_previousURL,__privateGet(this,_currentURL)),__privateSet(this,_currentURL,normalizedURL);const morphedElements=[];__privateGet(this,_morphElements).forEach((morphElement,i)=>{const newMorphElement=newMorphElements[i],duration=getComputedStyle(morphElement).getPropertyValue("--morph-duration");let newMorphElementChildNodes=[],currentMorphElementChildNodes=[];submorph?(submorph.forEach(selector=>{const curSubMorphElement=morphElement.querySelector(selector),newSubMorphElement=newMorphElement.querySelector(selector);curSubMorphElement&&newSubMorphElement&&(currentMorphElementChildNodes.push(curSubMorphElement),newMorphElementChildNodes.push(newSubMorphElement))}),currentMorphElementChildNodes.forEach(el=>{el.parentElement&&morphedElements.push(el.parentElement)})):(newMorphElementChildNodes.push(...newMorphElement.childNodes),currentMorphElementChildNodes.push(...morphElement.childNodes),morphedElements.push(morphElement));const transfer=[];submorphAppend||currentMorphElementChildNodes.forEach(element=>{element instanceof HTMLElement&&(this.destroyOldLinks(element),element.classList.add("old"),element.querySelectorAll("[data-morph-transfer]").forEach(el=>{const selector=el.getAttribute("data-morph-transfer");transfer.push({element:el,selector})}))}),newMorphElementChildNodes.forEach(element=>{element instanceof HTMLElement&&(transfer.forEach(item=>{const nestlement=element.querySelector(item.selector);nestlement&&nestlement.replaceWith(nextRoute.document.importNode(item.element,!0))}),this.findNewLinks(element),element.classList.add("new"))}),submorph?submorphAppend?newMorphElementChildNodes.forEach((el,i2)=>{currentMorphElementChildNodes[i2]instanceof HTMLElement&¤tMorphElementChildNodes[i2].append(...el.childNodes)}):newMorphElementChildNodes.forEach((el,i2)=>{var _a2;(_a2=currentMorphElementChildNodes[i2].parentElement)==null||_a2.insertBefore(el,currentMorphElementChildNodes[i2])}):morphElement.prepend(...newMorphElementChildNodes),setTimeout(()=>{submorphAppend||currentMorphElementChildNodes.forEach(element=>{element instanceof HTMLElement&&element.classList.add("old-idle")}),newMorphElementChildNodes.forEach(element=>{var _a2;element instanceof HTMLElement&&((_a2=element.parentElement)==null||_a2.style.setProperty("--new-content-height",element.offsetHeight+"px"),element.classList.add("new-idle"))})},0);const detail2=__spreadProps(__spreadValues({},documentFetchedEntry),{morphElement});events.dispatchEvent(document,"morphNewChildrenAdded",{detail:detail2});const promise=new Promise(res=>{setTimeout(()=>{submorphAppend||currentMorphElementChildNodes.forEach(el=>{el.remove()}),newMorphElementChildNodes.forEach(element=>{var _a2;element instanceof HTMLElement&&((_a2=element.parentElement)==null||_a2.style.removeProperty("--new-content-height"),element.classList.remove("new-idle","new"))}),submorphAppend||events.dispatchEvent(document,"morphOldChildrenRemoved",{detail:detail2}),res()},(parseFloat(duration)||0)*1e3+10)});__privateGet(this,_promises).push(promise)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-nextRoute.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),events.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:nextRoute.scrollState}),scrollTo?(nextRoute.clearScrollState(),__privateMethod(this,_Morph_instances,tryScrollToElement_fn).call(this,scrollTo,{center:centerScroll,offset:offsetScroll,duration:scrollDuration,easing:scrollEasing,behavior:scrollBehaviour})):normalizedURL.hash?(nextRoute.clearScrollState(),__privateMethod(this,_Morph_instances,tryScrollToElement_fn).call(this,normalizedURL.hash,{center:centerScroll,offset:offsetScroll,duration:scrollDuration,easing:scrollEasing,behavior:scrollBehaviour})):__privateGet(this,_isPopstateNavigation)?nextRoute.restoreScrollPosition():keepScrollPosition||nextRoute.renewScrollPosition(),yield Promise.all(__privateGet(this,_promises)),submorphAppend||oldElementsWithLoadEvent.forEach(child=>child.remove()),__privateSet(this,_promises,[]),morphedElements.forEach(el=>{el.querySelectorAll("script").forEach(element=>{element.replaceWith(dom.createScriptElement(element))})}),__privateGet(this,_links).forEach(link=>{link.checkCurrent(__privateGet(this,_currentURL).path)}),this.findParamsDependent(),events.dispatchEvent(document,"morphComplete",{detail:documentFetchedEntry}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch(e){console.error(e)}__privateSet(this,_candidateURL,void 0)})}addLink(element){__privateGet(this,_links).push(new MorphLink(element,this))}addLinks(elements){elements.forEach(element=>{this.addLink(element)})}removeLink(element){__privateSet(this,_links,__privateGet(this,_links).filter(link=>link.element===element?(link.destroy(),!1):!0))}destroyOldLinks(morphElement){__privateSet(this,_links,__privateGet(this,_links).filter(link=>morphElement.contains(link.element)?(link.destroy(),!1):!0))}findNewLinks(morphElement){const linkElements=[...morphElement.querySelectorAll("a")].filter(__privateGet(this,_checkLink));__privateGet(this,_links).push(...linkElements.map(element=>new MorphLink(element,this)))}findLinks(){const linkElements=[...document.documentElement.querySelectorAll("a")].filter(__privateGet(this,_checkLink));__privateGet(this,_links).forEach(link=>link.destroy()),__privateSet(this,_links,linkElements.map(element=>new MorphLink(element,this)))}findParamsDependent(){const elements=[...document.documentElement.querySelectorAll("[data-morph-params-dependent]")];__privateGet(this,_paramDependent).forEach(link=>link.destroy()),__privateSet(this,_paramDependent,elements.map(element=>new MorphParamsDependent(element)))}};_options=new WeakMap,_morphElements=new WeakMap,_links=new WeakMap,_candidateURL=new WeakMap,_currentURL=new WeakMap,_previousURL=new WeakMap,_promises=new WeakMap,_isPopstateNavigation=new WeakMap,_currentScrollElement=new WeakMap,_isWindowScroll=new WeakMap,_routes=new WeakMap,_paramDependent=new WeakMap,_announcer=new WeakMap,_currentScrollX=new WeakMap,_currentScrollY=new WeakMap,_lastSubmorph=new WeakMap,_lastRevalidate=new WeakMap,_lastKeepScrollPosition=new WeakMap,_checkLink=new WeakMap,_Morph_instances=new WeakSet,getRoute_fn=__name(function(path){const normalizedURL=this.normalizePath(path);let route=__privateGet(this,_routes).get(normalizedURL.pathname);return route||(route=new MorphRoute(this,normalizedURL.pathname),__privateGet(this,_routes).set(normalizedURL.pathname,route)),route},"#getRoute"),getMorphElements_fn=__name(function(el){const morphElements=[...el.querySelectorAll("[data-morph]")];return morphElements.length?morphElements:[el]},"#getMorphElements"),isElementEmitsLoadEvent_fn=__name(function(element){return element.tagName==="SCRIPT"||element.tagName==="STYLE"||element.tagName==="LINK"&&element.getAttribute("rel")==="stylesheet"},"#isElementEmitsLoadEvent"),updateCurrentScrollElement_fn=__name(function(document2){var _a,_b;(_a=__privateGet(this,_currentScrollElement))==null||_a.removeEventListener("scroll",__privateGet(this,_scrollListener)),__privateSet(this,_currentScrollY,0),__privateSet(this,_currentScrollX,0),__privateSet(this,_currentScrollElement,__privateGet(this,_options).scrollSelector&&document2.querySelector(__privateGet(this,_options).scrollSelector)||window),__privateSet(this,_isWindowScroll,__privateGet(this,_currentScrollElement)===window),(_b=__privateGet(this,_currentScrollElement))==null||_b.addEventListener("scroll",__privateGet(this,_scrollListener)),__privateGet(this,_scrollListener).call(this)},"#updateCurrentScrollElement"),tryScrollToElement_fn=__name(function(id,options){const value=typeof id=="string"?document.querySelector(id):id;(typeof value=="number"||value)&&ScrollNavigator.ScrollNavigator.scrollToElement(value,__spreadValues({scrollElement:__privateGet(this,_currentScrollElement)},options))},"#tryScrollToElement"),_popStateListener=new WeakMap,_scrollListener=new WeakMap,__name(_Morph,"Morph"),_Morph.instance=null;let Morph=_Morph;exports.Morph=Morph;
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty,__defProps=Object.defineProperties;var __getOwnPropDescs=Object.getOwnPropertyDescriptors;var __getOwnPropSymbols=Object.getOwnPropertySymbols;var __hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable;var __knownSymbol=(name,symbol)=>(symbol=Symbol[name])?symbol:Symbol.for("Symbol."+name),__typeError=msg=>{throw TypeError(msg)};var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,__spreadValues=(a,b)=>{for(var prop in b||(b={}))__hasOwnProp.call(b,prop)&&__defNormalProp(a,prop,b[prop]);if(__getOwnPropSymbols)for(var prop of __getOwnPropSymbols(b))__propIsEnum.call(b,prop)&&__defNormalProp(a,prop,b[prop]);return a},__spreadProps=(a,b)=>__defProps(a,__getOwnPropDescs(b)),__name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __accessCheck=(obj,member,msg)=>member.has(obj)||__typeError("Cannot "+msg);var __privateGet=(obj,member,getter)=>(__accessCheck(obj,member,"read from private field"),getter?getter.call(obj):member.get(obj)),__privateAdd=(obj,member,value)=>member.has(obj)?__typeError("Cannot add the same private member more than once"):member instanceof WeakSet?member.add(obj):member.set(obj,value),__privateSet=(obj,member,value,setter)=>(__accessCheck(obj,member,"write to private field"),setter?setter.call(obj,value):member.set(obj,value),value),__privateMethod=(obj,member,method)=>(__accessCheck(obj,member,"access private method"),method);var __async=(__this,__arguments,generator)=>new Promise((resolve,reject)=>{var fulfilled=value=>{try{step(generator.next(value))}catch(e){reject(e)}},rejected=value=>{try{step(generator.throw(value))}catch(e){reject(e)}},step=x=>x.done?resolve(x.value):Promise.resolve(x.value).then(fulfilled,rejected);step((generator=generator.apply(__this,__arguments)).next())});var __forAwait=(obj,it,method)=>(it=obj[__knownSymbol("asyncIterator")])?it.call(obj):(obj=obj[__knownSymbol("iterator")](),it={},method=(key,fn)=>(fn=obj[key])&&(it[key]=arg=>new Promise((yes,no,done)=>(arg=fn.call(obj,arg),done=arg.done,Promise.resolve(arg.value).then(value=>yes({value,done}),no)))),method("next"),method("return"),it);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const browser=require("../browser-CIp8NsnF.cjs"),dom=require("../dom-B40i6NXw.cjs"),events=require("../events-UlGk63iC.cjs"),promises=require("../promises-nDm8_iG6.cjs");require("construct-style-sheets-polyfill");require("../index-BrasTsja.cjs");const url=require("../url-D_KuhhOg.cjs"),cssValueParser_index=require("../css-value-parser/index.cjs"),string=require("../string-Bx5N38JG.cjs"),ScrollNavigator=require("../ScrollNavigator-8_lZG25T.cjs"),shared_index=require("../shared/index.cjs"),_MorphAnnouncer=class _MorphAnnouncer extends HTMLElement{connectedCallback(){const attrs={"aria-live":"assertive","aria-atomic":"true",style:"position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px"};for(const[key,value]of Object.entries(attrs))this.setAttribute(key,value)}};__name(_MorphAnnouncer,"MorphAnnouncer");let MorphAnnouncer=_MorphAnnouncer;browser.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",MorphAnnouncer);var _morph,_element,_MorphLink_instances,path_get,click_fn,_clickListener,_pointerListener;const _MorphLink=class _MorphLink{constructor(element,morph){__privateAdd(this,_MorphLink_instances);__privateAdd(this,_morph);__privateAdd(this,_element);__privateAdd(this,_clickListener,__name(e=>{e.preventDefault(),__privateMethod(this,_MorphLink_instances,click_fn).call(this)},"#clickListener"));__privateAdd(this,_pointerListener,__name(()=>{const revalidate=__privateGet(this,_element).hasAttribute("data-revalidate");__privateGet(this,_morph).prefetch(__privateGet(this,_MorphLink_instances,path_get),revalidate),__privateGet(this,_element).removeEventListener("pointerenter",__privateGet(this,_pointerListener))},"#pointerListener"));__privateSet(this,_morph,morph),__privateSet(this,_element,element),__privateGet(this,_element).addEventListener("click",__privateGet(this,_clickListener)),this.checkCurrent(location.href.replace(location.origin,"")),__privateGet(this,_element).hasAttribute("data-prefetch")&&__privateGet(this,_element).addEventListener("pointerenter",__privateGet(this,_pointerListener))}get element(){return __privateGet(this,_element)}checkCurrent(path){var _a,_b;const locationUrl=__privateGet(this,_morph).normalizePath(path),linkUrl=__privateGet(this,_morph).normalizePath(__privateGet(this,_MorphLink_instances,path_get));__privateGet(this,_element).hasAttribute("data-include")&&locationUrl.pathname.includes(linkUrl.pathname)?__privateGet(this,_element).classList.add("current"):linkUrl.pathname===locationUrl.pathname?__privateGet(this,_element).classList.add("current"):(_a=__privateGet(this,_element).getAttribute("data-associated-paths"))!=null&&_a.split(",").find(path2=>locationUrl.pathname.includes(path2))?__privateGet(this,_element).classList.add("current"):__privateGet(this,_element).classList.remove("current"),locationUrl.path===linkUrl.path?__privateGet(this,_element).classList.add("exact"):__privateGet(this,_element).classList.remove("exact");const[pathWithoutParams,pathParamsStr]=(_b=__privateGet(this,_MorphLink_instances,path_get).split("#")[0])==null?void 0:_b.split("?"),pathParams=new URLSearchParams(pathParamsStr),locationParams=new URLSearchParams(location.search);let matchCounter=0;for(const[key]of locationParams)pathParams.has(key)&&locationParams.get(key)===pathParams.get(key)&&matchCounter++;matchCounter?(__privateGet(this,_element).classList.toggle("all-params-matched",locationParams.size===matchCounter),__privateGet(this,_element).classList.toggle("some-params-matched",locationParams.size!==matchCounter)):!locationParams.size&&__privateGet(this,_element).hasAttribute("data-match-no-params")?__privateGet(this,_element).classList.add("all-params-matched"):(__privateGet(this,_element).classList.remove("all-params-matched"),__privateGet(this,_element).classList.remove("some-params-matched"));for(const key in __privateGet(this,_element).dataset){const kebabKey=string.camelToKebab(key);if(kebabKey.startsWith("match-param-")){const name=kebabKey.split("match-param-")[1],value=__privateGet(this,_element).dataset[key],className=`param-${name}-matched`;locationParams.has(name)&&locationParams.get(name)===value||!locationParams.has(name)&&(value===""||value==="*"||value==="all"||value==="any"||value==="vse")?__privateGet(this,_element).classList.add(className):__privateGet(this,_element).classList.remove(className)}}}destroy(){__privateGet(this,_element).removeEventListener("click",__privateGet(this,_clickListener)),__privateGet(this,_element).removeEventListener("pointerenter",__privateGet(this,_pointerListener)),__privateGet(this,_element).classList.remove("current","exact")}};_morph=new WeakMap,_element=new WeakMap,_MorphLink_instances=new WeakSet,path_get=__name(function(){const url2=new URL(__privateGet(this,_element).href);return __privateGet(this,_morph).normalizePath(url2.pathname+url2.search+url2.hash).path},"#path"),click_fn=__name(function(){var _a;if(document.documentElement.classList.contains("click-disabled"))return;if(__privateGet(this,_element).hasAttribute("data-back")&&__privateGet(this,_morph).previousURL)history.back();else{const historyAction=__privateGet(this,_element).getAttribute("data-history-action")||"push",centerScroll=__privateGet(this,_element).hasAttribute("data-center-scroll"),offsetScrollRawValue=getComputedStyle(__privateGet(this,_element)).getPropertyValue("--offset-scroll").trim(),offsetScroll=offsetScrollRawValue?cssValueParser_index.cssValueParser.parse(offsetScrollRawValue):void 0,scrollDuration=parseFloat(__privateGet(this,_element).getAttribute("data-scroll-duration")||"0")||void 0,scrollEasing=__privateGet(this,_element).getAttribute("data-scroll-easing")||void 0,revalidate=__privateGet(this,_element).hasAttribute("data-revalidate")||__privateGet(this,_element).hasAttribute("data-pagination-more-link")||__privateGet(this,_element).hasAttribute("data-pagination-set-link")||__privateGet(this,_element).hasAttribute("data-pagination-next-link")||__privateGet(this,_element).hasAttribute("data-pagination-prev-link"),keepSearchParameters=__privateGet(this,_element).hasAttribute("data-keep-search-parameters"),keepScrollPosition=__privateGet(this,_element).hasAttribute("data-keep-scroll-position")||__privateGet(this,_element).hasAttribute("data-pagination-more-link"),scrollBehaviour=__privateGet(this,_element).getAttribute("data-scroll-behaviour"),submorph=(_a=__privateGet(this,_element).getAttribute("data-submorph")||__privateGet(this,_element).getAttribute("data-submorph-append"))==null?void 0:_a.split(",").map(v=>v.trim()),clearState=__privateGet(this,_element).hasAttribute("data-clear-state");let path=__privateGet(this,_MorphLink_instances,path_get);if(__privateGet(this,_element).hasAttribute("data-toggle-params")){const[pathWithoutParams,pathParamsStr]=__privateGet(this,_MorphLink_instances,path_get).split("?"),pathParams=new URLSearchParams(pathParamsStr),locationParams=new URLSearchParams(location.search),resultParams=new URLSearchParams;for(const[key]of pathParams)(!locationParams.has(key)||locationParams.has(key)&&locationParams.get(key)!==pathParams.get(key))&&resultParams.append(key,pathParams.get(key));if(__privateGet(this,_element).hasAttribute("data-merge-params"))for(const[key]of locationParams)pathParams.has(key)||resultParams.append(key,locationParams.get(key));path=`${pathWithoutParams}?${resultParams.toString()}`}__privateGet(this,_morph).navigate(path,{historyAction,centerScroll,offsetScroll,revalidate,keepSearchParameters,submorph,clearState,keepScrollPosition,scrollBehaviour,scrollDuration,scrollEasing,submorphAppend:__privateGet(this,_element).hasAttribute("data-submorph-append"),mergeParams:__privateGet(this,_element).hasAttribute("data-merge-params")&&!__privateGet(this,_element).hasAttribute("data-toggle-params"),detail:__privateGet(this,_element).getAttribute("data-detail"),removeParams:__privateGet(this,_element).getAttribute("data-remove-params")||void 0,scrollTo:__privateGet(this,_element).getAttribute("data-scroll-to")||void 0})}},"#click"),_clickListener=new WeakMap,_pointerListener=new WeakMap,__name(_MorphLink,"MorphLink");let MorphLink=_MorphLink;var _element2,_params,_MorphParamsDependent_instances,update_fn,_urlChangeListener;const _MorphParamsDependent=class _MorphParamsDependent{constructor(element){__privateAdd(this,_MorphParamsDependent_instances);__privateAdd(this,_element2);__privateAdd(this,_params,[]);__privateAdd(this,_urlChangeListener,__name(()=>{__privateMethod(this,_MorphParamsDependent_instances,update_fn).call(this)},"#urlChangeListener"));__privateSet(this,_element2,element);for(const key in __privateGet(this,_element2).dataset){const kebabKey=string.camelToKebab(key);if(kebabKey.startsWith("param-")){const name=kebabKey.split("param-")[1],value=__privateGet(this,_element2).dataset[key];__privateGet(this,_params).push({name,value})}}document.addEventListener("morphURLParametersChange",__privateGet(this,_urlChangeListener)),__privateMethod(this,_MorphParamsDependent_instances,update_fn).call(this)}destroy(){document.removeEventListener("morphURLParametersChange",__privateGet(this,_urlChangeListener))}};_element2=new WeakMap,_params=new WeakMap,_MorphParamsDependent_instances=new WeakSet,update_fn=__name(function(){const locationParams=new URLSearchParams(location.search);let matched=!!__privateGet(this,_params).find(param=>locationParams.has(param.name)&&(locationParams.get(param.name)===param.value||param.value==="*"||param.value==="all"||param.value==="any"||param.value==="vse"||locationParams.get(param.name)==="*"||locationParams.get(param.name)==="all"||locationParams.get(param.name)==="any"||locationParams.get(param.name)==="vse"));!matched&&__privateGet(this,_element2).hasAttribute("data-match-no-params")&&(matched=!__privateGet(this,_params).filter(param=>locationParams.has(param.name)).length);const hideClass=__privateGet(this,_element2).getAttribute("data-hide-class");matched?hideClass?__privateGet(this,_element2).classList.remove(hideClass):__privateGet(this,_element2).style.display="":hideClass?__privateGet(this,_element2).classList.add(hideClass):__privateGet(this,_element2).style.display="none",requestAnimationFrame(()=>{window.dispatchEvent(new CustomEvent("resize"))})},"#update"),_urlChangeListener=new WeakMap,__name(_MorphParamsDependent,"MorphParamsDependent");let MorphParamsDependent=_MorphParamsDependent;const domParser=new DOMParser;var _morph2,_pathname,_scrollState,_initialDocument,_modifiedDocument,_currentDocument,_savedState,_abortController,_fetching,_headers,_needRavalidation;const _MorphRoute=class _MorphRoute{constructor(morph,pathname){__privateAdd(this,_morph2);__privateAdd(this,_pathname);__privateAdd(this,_scrollState,{x:0,y:0});__privateAdd(this,_initialDocument,null);__privateAdd(this,_modifiedDocument,null);__privateAdd(this,_currentDocument,null);__privateAdd(this,_savedState,null);__privateAdd(this,_abortController,null);__privateAdd(this,_fetching,null);__privateAdd(this,_headers);__privateAdd(this,_needRavalidation,!1);__privateSet(this,_morph2,morph),__privateSet(this,_pathname,pathname)}get pathname(){return __privateGet(this,_pathname)}get scrollState(){return __privateGet(this,_scrollState)}get document(){return __privateGet(this,_currentDocument)}needRavalidation(){__privateSet(this,_needRavalidation,!0)}setHeaders(headers){__privateSet(this,_headers,headers)}setInitialDocument(document2){__privateSet(this,_initialDocument,document2.cloneNode(!0))}abort(){var _a;return(_a=__privateGet(this,_abortController))==null?void 0:_a.abort(`[${__privateGet(this,_pathname)}] page loading cancelled`)}fetch(path,currentPath,revalidate){return __async(this,null,function*(){var _a;if(!revalidate&&!__privateGet(this,_needRavalidation)){const shouldUseCache=((_a=__privateGet(this,_initialDocument))==null?void 0:_a.documentElement.getAttribute("data-cache"))&¤tPath!==path,isPopstateNavigation=__privateGet(this,_initialDocument)&&__privateGet(this,_morph2).isPopstateNavigation;if(__privateGet(this,_fetching)||shouldUseCache||isPopstateNavigation)return __privateGet(this,_fetching)}return __privateSet(this,_fetching,new Promise(res=>__async(this,null,function*(){try{__privateSet(this,_abortController,new AbortController);const text=yield(yield fetch(path,{signal:__privateGet(this,_abortController).signal,headers:__spreadValues({"X-MORPH":"true","X-MORPH-REVALIDATE":revalidate?"true":"false","X-MORPH-CURRENT-PATH":encodeURIComponent(currentPath),"X-MORPH-NEW-PATH":encodeURIComponent(path)},__privateGet(this,_headers))})).text(),document2=domParser.parseFromString(text,"text/html");this.setInitialDocument(document2),__privateSet(this,_needRavalidation,!1)}catch(e){console.warn(e)}finally{__privateSet(this,_abortController,null),__privateSet(this,_fetching,null),res()}}))),__privateGet(this,_fetching)})}cloneDocument(){__privateSet(this,_currentDocument,(__privateGet(this,_modifiedDocument)||__privateGet(this,_initialDocument)).cloneNode(!0))}get title(){let title="";if(__privateGet(this,_currentDocument).title)title=__privateGet(this,_currentDocument).title;else{const h1=__privateGet(this,_currentDocument).querySelector("h1");title=(h1==null?void 0:h1.innerText)||(h1==null?void 0:h1.textContent)||__privateGet(this,_pathname)}return title}clearScrollState(){__privateGet(this,_scrollState).x=0,__privateGet(this,_scrollState).y=0}clearDocumentState(){__privateSet(this,_modifiedDocument,null)}saveScrollState(){__privateGet(this,_initialDocument).documentElement.hasAttribute("data-no-scroll-restoration")?(__privateGet(this,_scrollState).x=0,__privateGet(this,_scrollState).y=0):(__privateGet(this,_scrollState).x=__privateGet(this,_morph2).scrollValue.left,__privateGet(this,_scrollState).y=__privateGet(this,_morph2).scrollValue.top)}restoreScrollPosition(){__privateGet(this,_morph2).scrollElement.scroll({top:__privateGet(this,_scrollState).y,left:__privateGet(this,_scrollState).x,behavior:"instant"})}saveDocumentState(){__privateGet(this,_initialDocument).documentElement.hasAttribute("data-no-page-restoration")?__privateSet(this,_modifiedDocument,null):__privateSet(this,_modifiedDocument,document.cloneNode(!0))}renewScrollPosition(){__privateGet(this,_morph2).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(state){__privateSet(this,_savedState,state)}clearState(){const state=__privateGet(this,_savedState);return __privateSet(this,_savedState,null),state}};_morph2=new WeakMap,_pathname=new WeakMap,_scrollState=new WeakMap,_initialDocument=new WeakMap,_modifiedDocument=new WeakMap,_currentDocument=new WeakMap,_savedState=new WeakMap,_abortController=new WeakMap,_fetching=new WeakMap,_headers=new WeakMap,_needRavalidation=new WeakMap,__name(_MorphRoute,"MorphRoute");let MorphRoute=_MorphRoute;var _options,_morphElements,_links,_candidateURL,_currentURL,_previousURL,_promises,_isPopstateNavigation,_currentScrollElement,_isWindowScroll,_routes,_paramDependent,_announcer,_currentScrollX,_currentScrollY,_lastSubmorph,_lastRevalidate,_lastKeepScrollPosition,_checkLink,_Morph_instances,getRoute_fn,getMorphElements_fn,isElementEmitsLoadEvent_fn,updateCurrentScrollElement_fn,tryScrollToElement_fn,_popStateListener,_scrollListener;const _Morph=class _Morph{constructor(parameters){__privateAdd(this,_Morph_instances);__privateAdd(this,_options,null);__privateAdd(this,_morphElements,null);__privateAdd(this,_links,[]);__privateAdd(this,_candidateURL);__privateAdd(this,_currentURL,null);__privateAdd(this,_previousURL);__privateAdd(this,_promises,[]);__privateAdd(this,_isPopstateNavigation,!1);__privateAdd(this,_currentScrollElement,null);__privateAdd(this,_isWindowScroll,!1);__privateAdd(this,_routes,new Map);__privateAdd(this,_paramDependent,[]);__privateAdd(this,_announcer,null);__privateAdd(this,_currentScrollX,0);__privateAdd(this,_currentScrollY,0);__privateAdd(this,_lastSubmorph);__privateAdd(this,_lastRevalidate);__privateAdd(this,_lastKeepScrollPosition);__privateAdd(this,_checkLink,__name(element=>{var _a,_b;return(((_a=element.getAttribute("href"))==null?void 0:_a.startsWith("/"))||((_b=element.getAttribute("href"))==null?void 0:_b.startsWith("?")))&&!element.hasAttribute("download")&&!element.hasAttribute("data-morph-skip")&&!element.closest("[data-morph-skip]")&&element.getAttribute("target")!=="_blank"},"#checkLink"));__privateAdd(this,_popStateListener,__name(event=>__async(this,null,function*(){var _a,_b,_c,_d;(_b=(_a=event.state)==null?void 0:_a.data)!=null&&_b.popover||(_d=(_c=event.previousState)==null?void 0:_c.data)!=null&&_d.popover||(__privateSet(this,_isPopstateNavigation,!0),yield this.navigate(location.href.replace(location.origin,""),{historyAction:"none",submorph:__privateGet(this,_lastRevalidate)?void 0:__privateGet(this,_lastSubmorph),revalidate:__privateGet(this,_lastRevalidate),keepScrollPosition:__privateGet(this,_lastKeepScrollPosition)}),__privateSet(this,_isPopstateNavigation,!1))}),"#popStateListener"));__privateAdd(this,_scrollListener,__name(()=>{const{left,top}=this.scrollValue,directionY=top-__privateGet(this,_currentScrollY),directionX=left-__privateGet(this,_currentScrollX);__privateSet(this,_currentScrollY,top),__privateSet(this,_currentScrollX,left),document.documentElement.classList.toggle("scroll-y",top>0),document.documentElement.classList.toggle("scroll-x",left>0),document.documentElement.classList.toggle("scroll-y-forward",directionY>0),document.documentElement.classList.toggle("scroll-y-backward",directionY<0),document.documentElement.classList.toggle("scroll-x-forward",directionX>0),document.documentElement.classList.toggle("scroll-x-backward",directionX<0),events.dispatchEvent(document,"morphScroll",{detail:{left,top}})},"#scrollListener"));if(browser.isBrowser&&!_Morph.instance){_Morph.instance=this,__privateSet(this,_options,{base:url.normalizeBase(parameters==null?void 0:parameters.base),waitForHeadToLoad:(parameters==null?void 0:parameters.waitForHeadToLoad)!==!1,trailingSlash:(parameters==null?void 0:parameters.trailingSlash)||!1,scrollSelector:parameters==null?void 0:parameters.scrollSelector,morphInsideScrollContainer:(parameters==null?void 0:parameters.morphInsideScrollContainer)||!1}),__privateSet(this,_morphElements,__privateMethod(this,_Morph_instances,getMorphElements_fn).call(this,document.body));const normalizedURL=this.normalizePath(location.pathname+location.search+location.hash);__privateSet(this,_currentURL,normalizedURL);const initialRoute=new MorphRoute(this,__privateGet(this,_currentURL).pathname);initialRoute.setInitialDocument(document),__privateGet(this,_routes).set(__privateGet(this,_currentURL).pathname,initialRoute),document.documentElement.setAttribute("data-current-pathname",__privateGet(this,_currentURL).pathname),document.documentElement.setAttribute("data-current-leaf",normalizedURL.leaf),this.findLinks(),this.findParamsDependent(),shared_index.historyManager.addPopStateHandler(__privateGet(this,_popStateListener)),shared_index.historyManager.__change({action:"replace",pathname:normalizedURL.pathname,searchParameters:normalizedURL.parameters,hash:normalizedURL.hash}),__privateSet(this,_announcer,new MorphAnnouncer),__privateMethod(this,_Morph_instances,updateCurrentScrollElement_fn).call(this,document)}}get currentURL(){return __privateGet(this,_currentURL)}get previousURL(){return __privateGet(this,_previousURL)}get links(){return __privateGet(this,_links)}get scrollElement(){return __privateGet(this,_currentScrollElement)}get isPopstateNavigation(){return __privateGet(this,_isPopstateNavigation)}get scrollValue(){let top=0,left=0;return __privateGet(this,_isWindowScroll)?(top=window.scrollY,left=window.scrollX):(top=__privateGet(this,_currentScrollElement).scrollTop,left=__privateGet(this,_currentScrollElement).scrollLeft),{top,left}}get isNavigating(){return!!__privateGet(this,_promises).length}saveState(state){const route=__privateGet(this,_routes).get(__privateGet(this,_currentURL).path);route&&route.saveState(state)}getState(){const route=__privateGet(this,_routes).get(__privateGet(this,_currentURL).path);return route==null?void 0:route.clearState()}normalizePath(path,options){return url.splitPath(path,{base:__privateGet(this,_options).base,trailingSlash:__privateGet(this,_options).trailingSlash,mergeParams:options!=null&&options.mergeParams?location.search:"",removeParams:options==null?void 0:options.removeParams})}prefetch(path,revalidate){return __async(this,null,function*(){var _a;if(__privateGet(this,_promises).length)return;path=((_a=this.pathnameModifier)==null?void 0:_a.call(this,path))||path;const route=__privateMethod(this,_Morph_instances,getRoute_fn).call(this,path);route==null||route.fetch(path,__privateGet(this,_currentURL).path,revalidate)})}excludeHeadChild(child){return!1}needRavalidation(path){const normalizedURL=this.normalizePath(path),route=__privateMethod(this,_Morph_instances,getRoute_fn).call(this,normalizedURL.path);route==null||route.needRavalidation()}navigate(_0){return __async(this,arguments,function*(path,{historyAction="push",centerScroll,offsetScroll,scrollDuration,scrollEasing,scrollBehaviour,revalidate,keepSearchParameters,submorph,submorphAppend,clearState,keepScrollPosition,mergeParams,removeParams,detail,scrollTo}={}){var _a,_b,_c,_d;if(__privateGet(this,_promises).length)return;__privateSet(this,_lastSubmorph,submorph),__privateSet(this,_lastRevalidate,revalidate),__privateSet(this,_lastKeepScrollPosition,keepScrollPosition);const modifiedPath=((_a=this.pathnameModifier)==null?void 0:_a.call(this,path))||path,normalizedURL=this.normalizePath(modifiedPath,{mergeParams,removeParams});if(!revalidate&&(((_b=__privateGet(this,_candidateURL))==null?void 0:_b.pathname)===normalizedURL.pathname||__privateGet(this,_currentURL).pathname===normalizedURL.pathname)){keepScrollPosition||__privateMethod(this,_Morph_instances,tryScrollToElement_fn).call(this,scrollTo||normalizedURL.hash||0,{center:centerScroll,offset:offsetScroll,duration:scrollDuration,easing:scrollEasing,behavior:"smooth"}),events.dispatchEvent(document,"morphSamePath",{detail:{detail}}),((_c=__privateGet(this,_currentURL))==null?void 0:_c.parameters)!==normalizedURL.parameters&&(__privateSet(this,_previousURL,__privateGet(this,_currentURL)),__privateSet(this,_currentURL,normalizedURL),shared_index.historyManager.__change({action:((_d=__privateGet(this,_currentURL))==null?void 0:_d.hash)!==normalizedURL.hash?"replace":historyAction,pathname:normalizedURL.pathname,searchParameters:normalizedURL.parameters,hash:normalizedURL.hash}),events.dispatchEvent(document,"morphURLParametersChange",{detail:{newURL:__privateGet(this,_currentURL),previousURL:__privateGet(this,_previousURL),detail}})),__privateGet(this,_links).forEach(link=>{link.checkCurrent(normalizedURL.path)});return}else __privateGet(this,_links).forEach(link=>{link.checkCurrent(normalizedURL.path)});__privateSet(this,_candidateURL,normalizedURL);try{let preprocessedSuccesfully=!0;if(this.preprocessor)try{yield new Promise((resolve,reject)=>{var _a2;(_a2=this.preprocessor)==null||_a2.call(this,{url:normalizedURL,resolve,reject,submorph,detail})})}catch(e){e?console.error(e):console.log("Route change canceled"),preprocessedSuccesfully=!1}if(!preprocessedSuccesfully||__privateGet(this,_candidateURL).pathname!==normalizedURL.pathname){__privateGet(this,_links).forEach(link=>{link.checkCurrent(__privateGet(this,_currentURL).path)});return}const navigationEntry={url:normalizedURL,submorph,detail};submorph?submorphAppend||submorph.forEach(sel=>{document.querySelectorAll(sel).forEach(el=>{el.classList.add("out"),el.setAttribute("data-morph-out","")})}):__privateGet(this,_morphElements).forEach(el=>{var _a2,_b2;(_a2=el.firstElementChild)==null||_a2.classList.add("out"),(_b2=el.firstElementChild)==null||_b2.setAttribute("data-morph-out","")}),events.dispatchEvent(document,"morphNavigation",{detail:navigationEntry});const currentRoute=__privateMethod(this,_Morph_instances,getRoute_fn).call(this,__privateGet(this,_currentURL).pathname),nextRoute=__privateMethod(this,_Morph_instances,getRoute_fn).call(this,normalizedURL.pathname);if(__privateGet(this,_routes).forEach(el=>{el.pathname!==normalizedURL.pathname&&el.abort()}),yield nextRoute==null?void 0:nextRoute.fetch(modifiedPath,__privateGet(this,_currentURL).path,revalidate),__privateGet(this,_candidateURL).pathname!==normalizedURL.pathname){__privateGet(this,_links).forEach(link=>{link.checkCurrent(__privateGet(this,_currentURL).path)});return}currentRoute.clearState(),currentRoute.saveScrollState(),currentRoute.saveDocumentState(),(!__privateGet(this,_isPopstateNavigation)||revalidate)&&(nextRoute.clearScrollState(),nextRoute.clearDocumentState()),clearState&&nextRoute.clearState(),nextRoute.cloneDocument(),__privateGet(this,_announcer).textContent=nextRoute.title,document.body.appendChild(__privateGet(this,_announcer));const documentFetchedEntry=__spreadProps(__spreadValues({},navigationEntry),{document:nextRoute.document});submorphAppend||documentFetchedEntry.document.querySelectorAll("[data-morph-out]").forEach(el=>{el.classList.remove("out")}),events.dispatchEvent(document,"morphStart",{detail:documentFetchedEntry});const currentHeadChildren=Array.from(document.head.children),newHeadChildren=Array.from(nextRoute.document.head.children),identicalHeadChildren=dom.intersectElements(currentHeadChildren,newHeadChildren),removeHeadChildren=dom.excludeElements(currentHeadChildren,identicalHeadChildren),addHeadChildren=dom.excludeElements(newHeadChildren,identicalHeadChildren).filter(child=>!this.excludeHeadChild(child));addHeadChildren.forEach((child,index)=>{child.tagName==="SCRIPT"&&(addHeadChildren[index]=dom.createScriptElement(child))}),addHeadChildren.forEach(child=>{document.head.appendChild(child)});const elementsWithLoad=addHeadChildren.filter(child=>{if(child.hasAttribute("data-no-waiting"))return!1;if(__privateMethod(this,_Morph_instances,isElementEmitsLoadEvent_fn).call(this,child))return!0});__privateGet(this,_options).waitForHeadToLoad&&elementsWithLoad.length&&(yield new Promise(res=>__async(this,null,function*(){let counter=0;try{for(var iter=__forAwait(elementsWithLoad),more,temp,error;more=!(temp=yield iter.next()).done;more=!1){const element=temp.value;element.onload=()=>{counter++,counter===elementsWithLoad.length&&res()}}}catch(temp){error=[temp]}finally{try{more&&(temp=iter.return)&&(yield temp.call(iter))}finally{if(error)throw error[0]}}}))),yield promises.wait(10);const oldElementsWithLoadEvent=[];submorphAppend||removeHeadChildren.forEach(child=>{child.hasAttribute("data-permanent")||(__privateMethod(this,_Morph_instances,isElementEmitsLoadEvent_fn).call(this,child)?oldElementsWithLoadEvent.push(child):child.remove())});const newMorphElements=__privateMethod(this,_Morph_instances,getMorphElements_fn).call(this,nextRoute.document.body);!__privateGet(this,_options).morphInsideScrollContainer&&!submorph&&__privateMethod(this,_Morph_instances,updateCurrentScrollElement_fn).call(this,nextRoute.document),document.documentElement.setAttribute("data-current-pathname",normalizedURL.pathname),document.documentElement.setAttribute("data-current-leaf",normalizedURL.leaf),shared_index.historyManager.__change({action:historyAction,pathname:normalizedURL.pathname,searchParameters:normalizedURL.parameters||(keepSearchParameters?location.search:""),hash:normalizedURL.hash}),__privateGet(this,_announcer).remove(),__privateSet(this,_previousURL,__privateGet(this,_currentURL)),__privateSet(this,_currentURL,normalizedURL);const morphedElements=[];__privateGet(this,_morphElements).forEach((morphElement,i)=>{const newMorphElement=newMorphElements[i],duration=getComputedStyle(morphElement).getPropertyValue("--morph-duration");let newMorphElementChildNodes=[],currentMorphElementChildNodes=[];submorph?(submorph.forEach(selector=>{const curSubMorphElement=morphElement.querySelector(selector),newSubMorphElement=newMorphElement.querySelector(selector);curSubMorphElement&&newSubMorphElement&&(currentMorphElementChildNodes.push(curSubMorphElement),newMorphElementChildNodes.push(newSubMorphElement))}),currentMorphElementChildNodes.forEach(el=>{el.parentElement&&morphedElements.push(el.parentElement)})):(newMorphElementChildNodes.push(...newMorphElement.childNodes),currentMorphElementChildNodes.push(...morphElement.childNodes),morphedElements.push(morphElement));const transfer=[];submorphAppend||currentMorphElementChildNodes.forEach(element=>{element instanceof HTMLElement&&(this.destroyOldLinks(element),element.classList.add("old"),element.querySelectorAll("[data-morph-transfer]").forEach(el=>{const selector=el.getAttribute("data-morph-transfer");transfer.push({element:el,selector})}))}),newMorphElementChildNodes.forEach(element=>{element instanceof HTMLElement&&(transfer.forEach(item=>{const nestlement=element.querySelector(item.selector);nestlement&&nestlement.replaceWith(nextRoute.document.importNode(item.element,!0))}),this.findNewLinks(element),element.classList.add("new"))}),submorph?submorphAppend?newMorphElementChildNodes.forEach((el,i2)=>{currentMorphElementChildNodes[i2]instanceof HTMLElement&¤tMorphElementChildNodes[i2].append(...el.childNodes)}):newMorphElementChildNodes.forEach((el,i2)=>{var _a2;(_a2=currentMorphElementChildNodes[i2].parentElement)==null||_a2.insertBefore(el,currentMorphElementChildNodes[i2])}):morphElement.prepend(...newMorphElementChildNodes),setTimeout(()=>{submorphAppend||currentMorphElementChildNodes.forEach(element=>{element instanceof HTMLElement&&element.classList.add("old-idle")}),newMorphElementChildNodes.forEach(element=>{var _a2;element instanceof HTMLElement&&((_a2=element.parentElement)==null||_a2.style.setProperty("--new-content-height",element.offsetHeight+"px"),element.classList.add("new-idle"))})},0);const detail2=__spreadProps(__spreadValues({},documentFetchedEntry),{morphElement});events.dispatchEvent(document,"morphNewChildrenAdded",{detail:detail2});const promise=new Promise(res=>{setTimeout(()=>{submorphAppend||currentMorphElementChildNodes.forEach(el=>{el.remove()}),newMorphElementChildNodes.forEach(element=>{var _a2;element instanceof HTMLElement&&((_a2=element.parentElement)==null||_a2.style.removeProperty("--new-content-height"),element.classList.remove("new-idle","new"))}),submorphAppend||events.dispatchEvent(document,"morphOldChildrenRemoved",{detail:detail2}),res()},(parseFloat(duration)||0)*1e3+10)});__privateGet(this,_promises).push(promise)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-nextRoute.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),events.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:nextRoute.scrollState}),scrollTo?(nextRoute.clearScrollState(),__privateMethod(this,_Morph_instances,tryScrollToElement_fn).call(this,scrollTo,{center:centerScroll,offset:offsetScroll,duration:scrollDuration,easing:scrollEasing,behavior:scrollBehaviour})):normalizedURL.hash?(nextRoute.clearScrollState(),__privateMethod(this,_Morph_instances,tryScrollToElement_fn).call(this,normalizedURL.hash,{center:centerScroll,offset:offsetScroll,duration:scrollDuration,easing:scrollEasing,behavior:scrollBehaviour})):__privateGet(this,_isPopstateNavigation)?nextRoute.restoreScrollPosition():keepScrollPosition||nextRoute.renewScrollPosition(),yield Promise.all(__privateGet(this,_promises)),submorphAppend||oldElementsWithLoadEvent.forEach(child=>child.remove()),__privateSet(this,_promises,[]),morphedElements.forEach(el=>{el.querySelectorAll("script").forEach(element=>{element.replaceWith(dom.createScriptElement(element))})}),__privateGet(this,_links).forEach(link=>{link.checkCurrent(__privateGet(this,_currentURL).path)}),this.findParamsDependent(),events.dispatchEvent(document,"morphComplete",{detail:documentFetchedEntry}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch(e){console.error(e)}__privateSet(this,_candidateURL,void 0)})}addLink(element){__privateGet(this,_links).push(new MorphLink(element,this))}addLinks(elements){elements.forEach(element=>{this.addLink(element)})}removeLink(element){__privateSet(this,_links,__privateGet(this,_links).filter(link=>link.element===element?(link.destroy(),!1):!0))}destroyOldLinks(morphElement){__privateSet(this,_links,__privateGet(this,_links).filter(link=>morphElement.contains(link.element)?(link.destroy(),!1):!0))}findNewLinks(morphElement){const linkElements=[...morphElement.querySelectorAll("a")].filter(__privateGet(this,_checkLink));__privateGet(this,_links).push(...linkElements.map(element=>new MorphLink(element,this)))}findLinks(){const linkElements=[...document.documentElement.querySelectorAll("a")].filter(__privateGet(this,_checkLink));__privateGet(this,_links).forEach(link=>link.destroy()),__privateSet(this,_links,linkElements.map(element=>new MorphLink(element,this)))}findParamsDependent(){const elements=[...document.documentElement.querySelectorAll("[data-morph-params-dependent]")];__privateGet(this,_paramDependent).forEach(link=>link.destroy()),__privateSet(this,_paramDependent,elements.map(element=>new MorphParamsDependent(element)))}};_options=new WeakMap,_morphElements=new WeakMap,_links=new WeakMap,_candidateURL=new WeakMap,_currentURL=new WeakMap,_previousURL=new WeakMap,_promises=new WeakMap,_isPopstateNavigation=new WeakMap,_currentScrollElement=new WeakMap,_isWindowScroll=new WeakMap,_routes=new WeakMap,_paramDependent=new WeakMap,_announcer=new WeakMap,_currentScrollX=new WeakMap,_currentScrollY=new WeakMap,_lastSubmorph=new WeakMap,_lastRevalidate=new WeakMap,_lastKeepScrollPosition=new WeakMap,_checkLink=new WeakMap,_Morph_instances=new WeakSet,getRoute_fn=__name(function(path){const normalizedURL=this.normalizePath(path);let route=__privateGet(this,_routes).get(normalizedURL.pathname);return route||(route=new MorphRoute(this,normalizedURL.pathname),__privateGet(this,_routes).set(normalizedURL.pathname,route)),route},"#getRoute"),getMorphElements_fn=__name(function(el){const morphElements=[...el.querySelectorAll("[data-morph]")];return morphElements.length?morphElements:[el]},"#getMorphElements"),isElementEmitsLoadEvent_fn=__name(function(element){return element.tagName==="SCRIPT"||element.tagName==="STYLE"||element.tagName==="LINK"&&element.getAttribute("rel")==="stylesheet"},"#isElementEmitsLoadEvent"),updateCurrentScrollElement_fn=__name(function(document2){var _a,_b;(_a=__privateGet(this,_currentScrollElement))==null||_a.removeEventListener("scroll",__privateGet(this,_scrollListener)),__privateSet(this,_currentScrollY,0),__privateSet(this,_currentScrollX,0),__privateSet(this,_currentScrollElement,__privateGet(this,_options).scrollSelector&&document2.querySelector(__privateGet(this,_options).scrollSelector)||window),__privateSet(this,_isWindowScroll,__privateGet(this,_currentScrollElement)===window),(_b=__privateGet(this,_currentScrollElement))==null||_b.addEventListener("scroll",__privateGet(this,_scrollListener)),__privateGet(this,_scrollListener).call(this)},"#updateCurrentScrollElement"),tryScrollToElement_fn=__name(function(id,options){const value=typeof id=="string"?document.querySelector(id):id;(typeof value=="number"||value)&&ScrollNavigator.ScrollNavigator.scrollToElement(value,__spreadValues({scrollElement:__privateGet(this,_currentScrollElement)},options))},"#tryScrollToElement"),_popStateListener=new WeakMap,_scrollListener=new WeakMap,__name(_Morph,"Morph"),_Morph.instance=null;let Morph=_Morph;exports.Morph=Morph;
|
package/lib/morph/index.js
CHANGED
|
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty, __defProps = Object.defineProperties;
|
|
|
2
2
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty, __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name), __typeError = (msg) => {
|
|
5
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name), __typeError = (msg) => {
|
|
6
6
|
throw TypeError(msg);
|
|
7
7
|
};
|
|
8
8
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues = (a, b) => {
|
|
@@ -41,7 +41,7 @@ import "../index-Z2Lgb7xU.js";
|
|
|
41
41
|
import { a as normalizeBase, c as splitPath } from "../url-bipuV3FR.js";
|
|
42
42
|
import { cssValueParser } from "../css-value-parser/index.js";
|
|
43
43
|
import { c as camelToKebab } from "../string-Ct-dy_cs.js";
|
|
44
|
-
import { S as ScrollNavigator } from "../ScrollNavigator-
|
|
44
|
+
import { S as ScrollNavigator } from "../ScrollNavigator-CA93_yQT.js";
|
|
45
45
|
import { historyManager } from "../shared/index.js";
|
|
46
46
|
const _MorphAnnouncer = class _MorphAnnouncer extends HTMLElement {
|
|
47
47
|
connectedCallback() {
|
|
@@ -26,6 +26,7 @@ export declare class PopoverElement extends HTMLElement {
|
|
|
26
26
|
get group(): CSSProperty<"">;
|
|
27
27
|
get clickOutside(): CSSProperty<false>;
|
|
28
28
|
get escape(): CSSProperty<false>;
|
|
29
|
+
get anchor(): CSSProperty<"">;
|
|
29
30
|
get opened(): boolean;
|
|
30
31
|
get lastTrigger(): any;
|
|
31
32
|
get idWithValue(): string;
|
package/lib/popover/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __defProp=Object.defineProperty;var __typeError=msg=>{throw TypeError(msg)};var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __accessCheck=(obj,member,msg)=>member.has(obj)||__typeError("Cannot "+msg);var __privateGet=(obj,member,getter)=>(__accessCheck(obj,member,"read from private field"),getter?getter.call(obj):member.get(obj)),__privateAdd=(obj,member,value)=>member.has(obj)?__typeError("Cannot add the same private member more than once"):member instanceof WeakSet?member.add(obj):member.set(obj,value),__privateSet=(obj,member,value,setter)=>(__accessCheck(obj,member,"write to private field"),setter?setter.call(obj,value):member.set(obj,value),value),__privateMethod=(obj,member,method)=>(__accessCheck(obj,member,"access private method"),method);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const cssProperty_index=require("../css-property/index.cjs"),Viewport=require("../Viewport-BdFs1Zsn.cjs"),elementLinkedStore_index=require("../element-linked-store/index.cjs"),shared_index=require("../shared/index.cjs"),browser=require("../browser-CIp8NsnF.cjs"),events=require("../events-UlGk63iC.cjs"),_function=require("../function-H4b_gTg6.cjs"),style=require("../style-IDJ6db6n.cjs");require("construct-style-sheets-polyfill");require("../index-BrasTsja.cjs");const url=require("../url-D_KuhhOg.cjs"),windowResizer_index=require("../window-resizer/index.cjs");var _groups,_stack,_clickOutsideListener,_keydownListener;const _PopoverGroups=class _PopoverGroups{constructor(){__privateAdd(this,_groups,new Map);__privateAdd(this,_stack,[]);__privateAdd(this,_clickOutsideListener,__name(e=>{var _a;const lastPopover=[...__privateGet(this,_stack)].reverse().find(el=>el.clickOutside.current);if(lastPopover){const path=e.composedPath();if(path.find(el=>el instanceof HTMLElement&&el.hasAttribute("data-popover-content")))return;const target=path[0],containsTarget=target instanceof Node&&(lastPopover.contains(target)||((_a=lastPopover.shadowRoot)==null?void 0:_a.contains(target))),outsideTarget=target instanceof HTMLElement&&target.hasAttribute("data-outside");(!containsTarget||outsideTarget)&&lastPopover.close(!0)}},"#clickOutsideListener"));__privateAdd(this,_keydownListener,__name(e=>{if(e.code==="Escape"){const lastPopover=[...__privateGet(this,_stack)].reverse().find(el=>el.escape.current);lastPopover&&lastPopover.close(!0)}},"#keydownListener"));document.documentElement.addEventListener("click",__privateGet(this,_clickOutsideListener)),addEventListener("keydown",__privateGet(this,_keydownListener))}get groups(){return __privateGet(this,_groups)}get stack(){return __privateGet(this,_stack)}add(groupName,element){if(element.closeRest.current)__privateGet(this,_groups).forEach(g=>{g.forEach(e=>{e.close()})});else if(element.closeRestInGroup.current){let group2=__privateGet(this,_groups).get(groupName);group2==null||group2.forEach(e=>{e.close()})}let group=__privateGet(this,_groups).get(groupName);group!=null&&group.length||(group=[],__privateGet(this,_groups).set(groupName,group)),__privateGet(this,_stack).push(element),group.push(element)}remove(groupName,element){if(setTimeout(()=>{__privateSet(this,_stack,__privateGet(this,_stack).filter(e=>e!==element))}),element.closeRest.current){let elements=[];__privateGet(this,_groups).forEach(group=>{group.forEach(element2=>elements.push(element2))}),__privateGet(this,_groups).clear(),elements.forEach(element2=>element2.close())}else if(element.closeRestInGroup.current){const group=__privateGet(this,_groups).get(groupName);__privateGet(this,_groups).delete(groupName),group==null||group.forEach(element2=>{element2.close()})}else{let group=__privateGet(this,_groups).get(groupName);group&&(group=group.filter(el=>el!==element),__privateGet(this,_groups).set(groupName,group))}}};_groups=new WeakMap,_stack=new WeakMap,_clickOutsideListener=new WeakMap,_keydownListener=new WeakMap,__name(_PopoverGroups,"PopoverGroups");let PopoverGroups=_PopoverGroups;var _opened,_startClosingTimeoutId,_closeTimeoutId,_openFrameId,_openTransitionTimeoutId,_history,_restore,_dispatchResize,_closeRest,_closeRestInGroup,_group,_clickOutside,_escape,_checkViewportBounds,_lastTrigger,_status,_innerCloseElements,_resetScrollElements,_isFromPopState,_PopoverElement_instances,path_get,toggleGlobalClass_fn,deleteSearchParam_fn,_popStateListener,_resizeListener,_debouncedResize,_resize,_closeElementClickListener;const _PopoverElement=class _PopoverElement extends HTMLElement{constructor(){super();__privateAdd(this,_PopoverElement_instances);__privateAdd(this,_opened);__privateAdd(this,_startClosingTimeoutId);__privateAdd(this,_closeTimeoutId);__privateAdd(this,_openFrameId);__privateAdd(this,_openTransitionTimeoutId);__privateAdd(this,_history);__privateAdd(this,_restore);__privateAdd(this,_dispatchResize);__privateAdd(this,_closeRest);__privateAdd(this,_closeRestInGroup);__privateAdd(this,_group);__privateAdd(this,_clickOutside);__privateAdd(this,_escape);__privateAdd(this,_checkViewportBounds);__privateAdd(this,_lastTrigger);__privateAdd(this,_status);__privateAdd(this,_innerCloseElements);__privateAdd(this,_resetScrollElements);__privateAdd(this,_isFromPopState);__privateAdd(this,_popStateListener);__privateAdd(this,_resizeListener);__privateAdd(this,_debouncedResize);__privateAdd(this,_resize);__privateAdd(this,_closeElementClickListener);this.urlValue="",__privateSet(this,_opened,!1),__privateSet(this,_history,new cssProperty_index.CSSProperty(this,"--history",!1)),__privateSet(this,_restore,new cssProperty_index.CSSProperty(this,"--restore",!1)),__privateSet(this,_dispatchResize,new cssProperty_index.CSSProperty(this,"--dispatch-resize",!1)),__privateSet(this,_closeRest,new cssProperty_index.CSSProperty(this,"--close-rest",!1)),__privateSet(this,_closeRestInGroup,new cssProperty_index.CSSProperty(this,"--close-rest-in-group",!1)),__privateSet(this,_group,new cssProperty_index.CSSProperty(this,"--group","")),__privateSet(this,_clickOutside,new cssProperty_index.CSSProperty(this,"--click-outside",!1)),__privateSet(this,_escape,new cssProperty_index.CSSProperty(this,"--escape",!1)),__privateSet(this,_checkViewportBounds,new cssProperty_index.CSSProperty(this,"--check-viewport-bounds",!1)),__privateSet(this,_status,new elementLinkedStore_index.ElementLinkedStore(this,{triggered:!1,beforeopen:!1,opened:!1,closing:!1,transitionend:!1})),__privateSet(this,_innerCloseElements,[]),__privateSet(this,_resetScrollElements,[]),__privateSet(this,_isFromPopState,!1),__privateSet(this,_popStateListener,()=>{_PopoverElement.popoverHistoryTransactionsDepth>0||(__privateSet(this,_isFromPopState,!0),__privateGet(this,_opened)&&__privateGet(this,_history).current&&!location.search.includes(this.id)?this.close():!__privateGet(this,_opened)&&__privateGet(this,_history).current&&location.search.includes(this.id)&&this.open({trigger:this.idWithValue}),setTimeout(()=>{__privateSet(this,_isFromPopState,!1)},0))}),__privateSet(this,_resizeListener,()=>{this.style.setProperty("--content-width","initial"),this.style.setProperty("--content-height","initial"),this.style.setProperty("--viewport-offset-x","0px"),this.style.setProperty("--viewport-offset-y","0px"),__privateGet(this,_debouncedResize).call(this)}),__privateSet(this,_debouncedResize,_function.debounce(()=>{__privateGet(this,_resize).call(this)},10)),__privateSet(this,_resize,()=>{if(this.style.setProperty("--content-width",this.scrollWidth+"px"),this.style.setProperty("--content-height",this.scrollHeight+"px"),__privateGet(this,_checkViewportBounds).current){const rect=this.getBoundingClientRect();let viewportOffsetX=0,viewportOffsetY=0;rect.right>Viewport.viewport.width?viewportOffsetX=Viewport.viewport.width-rect.right:rect.left<0&&(viewportOffsetX=rect.left*-1),rect.bottom>Viewport.viewport.height?viewportOffsetY=Viewport.viewport.height-rect.bottom:rect.top<0&&(viewportOffsetY=rect.top*-1),this.style.setProperty("--viewport-offset-x",viewportOffsetX+"px"),this.style.setProperty("--viewport-offset-y",viewportOffsetY+"px")}}),__privateSet(this,_closeElementClickListener,()=>{this.close(!0)}),__privateGet(this,_group).subscribe(e=>{e.previous&&(_PopoverElement.stack.remove(e.previous,this),e.current||(document.documentElement.classList.remove(`${this.group.previous}-closing`),document.documentElement.classList.remove(`${this.group.previous}-opened`)))}),__privateGet(this,_status).subscribe(e=>{if(this.group.current){document.documentElement.classList.toggle(`${this.group.current}-closing`,e.current.closing);const group=_PopoverElement.stack.groups.get(this.group.current),element=group==null?void 0:group.find(e2=>e2.opened);document.documentElement.classList.toggle(`${this.group.current}-opened`,!!element)}})}get openClass(){return this.getAttribute("data-open-global-class")}get closingClass(){return this.getAttribute("data-closing-global-class")}get history(){return __privateGet(this,_history)}get restore(){return __privateGet(this,_restore)}get dispatchResize(){return __privateGet(this,_dispatchResize)}get closeRest(){return __privateGet(this,_closeRest)}get closeRestInGroup(){return __privateGet(this,_closeRestInGroup)}get group(){return __privateGet(this,_group)}get clickOutside(){return __privateGet(this,_clickOutside)}get escape(){return __privateGet(this,_escape)}get opened(){return __privateGet(this,_opened)}get lastTrigger(){return __privateGet(this,_lastTrigger)}get idWithValue(){return`${this.id}${this.urlValue?"="+this.urlValue:""}`}updateUrlValue(value){this.urlValue=(value==null?void 0:value.toString())||"",__privateGet(this,_opened)&&url.updateSearchParameter(this.id,value)}open(options){if(__privateGet(this,_opened))return;__privateSet(this,_lastTrigger,options==null?void 0:options.trigger),clearTimeout(__privateGet(this,_startClosingTimeoutId)),clearTimeout(__privateGet(this,_closeTimeoutId)),__privateMethod(this,_PopoverElement_instances,toggleGlobalClass_fn).call(this,!1,this.closingClass),__privateGet(this,_status).setKey("closing",!1),__privateGet(this,_status).setKey("triggered",!0),events.dispatchEvent(this,"popoverTriggered",{custom:!0,detail:{trigger:__privateGet(this,_lastTrigger)}}),__privateGet(this,_history).current&&(this.beginHistoryTransaction(),__privateGet(this,_isFromPopState)||shared_index.historyManager.pushState(__privateGet(this,_PopoverElement_instances,path_get),{popover:!0}),this.endHistoryTransaction()),__privateGet(this,_status).setKey("beforeopen",!0),__privateSet(this,_opened,!0);const opened=__name(()=>{_PopoverElement.stack.add(__privateGet(this,_group).current,this),__privateGet(this,_resetScrollElements).forEach(el=>{el.scroll({top:0,left:0,behavior:"instant"})}),__privateMethod(this,_PopoverElement_instances,toggleGlobalClass_fn).call(this,!0,this.openClass),__privateGet(this,_status).setKey("opened",!0),__privateGet(this,_dispatchResize).current?events.dispatchEvent(window,"resize",{custom:!0}):__privateGet(this,_resizeListener).call(this),events.dispatchEvent(this,"popoverOpened",{custom:!0,detail:{trigger:__privateGet(this,_lastTrigger)},bubbles:!0}),__privateSet(this,_openFrameId,void 0),__privateSet(this,_openTransitionTimeoutId,setTimeout(()=>{__privateGet(this,_status).setKey("transitionend",!0),events.dispatchEvent(this,"popoverTransitionend")},style.getElementTransitionDurationMS(this)+10))},"opened");options!=null&&options.skipTransition?opened():__privateSet(this,_openFrameId,requestAnimationFrame(opened))}close(back){__privateGet(this,_opened)&&(__privateSet(this,_opened,!1),cancelAnimationFrame(__privateGet(this,_openFrameId)),clearTimeout(__privateGet(this,_openTransitionTimeoutId)),_PopoverElement.stack.remove(__privateGet(this,_group).current,this),__privateGet(this,_history).current&&(this.beginHistoryTransaction(),back?shared_index.historyManager.back():__privateMethod(this,_PopoverElement_instances,deleteSearchParam_fn).call(this),this.endHistoryTransaction()),__privateSet(this,_startClosingTimeoutId,setTimeout(()=>{__privateGet(this,_status).setKey("transitionend",!1),__privateGet(this,_status).setKey("opened",!1),__privateGet(this,_status).setKey("closing",!0),__privateMethod(this,_PopoverElement_instances,toggleGlobalClass_fn).call(this,!1,this.openClass),__privateMethod(this,_PopoverElement_instances,toggleGlobalClass_fn).call(this,!0,this.closingClass),events.dispatchEvent(this,"popoverClosing",{custom:!0,bubbles:!0}),__privateSet(this,_closeTimeoutId,setTimeout(()=>{__privateGet(this,_status).setKey("triggered",!1),__privateGet(this,_status).setKey("beforeopen",!1),__privateGet(this,_status).setKey("closing",!1),__privateMethod(this,_PopoverElement_instances,toggleGlobalClass_fn).call(this,!1,this.closingClass),events.dispatchEvent(this,"popoverClosed",{custom:!0,bubbles:!0})},style.getElementTransitionDurationMS(this)+10))},10)))}beginHistoryTransaction(){_PopoverElement.popoverHistoryTransactionsDepth++}endHistoryTransaction(){setTimeout(()=>{_PopoverElement.popoverHistoryTransactionsDepth--},0)}connectedCallback(){__privateSet(this,_innerCloseElements,[...this.querySelectorAll(`[data-popover-close${this.id?`="${this.id}"`:""}]`)]),__privateGet(this,_innerCloseElements).forEach(el=>{el.addEventListener("click",__privateGet(this,_closeElementClickListener))}),__privateSet(this,_resetScrollElements,[...this.querySelectorAll(`[data-popover-reset-scroll${this.id?`="${this.id}"`:""}]`)]),__privateGet(this,_history).observe(),__privateGet(this,_restore).observe(),__privateGet(this,_dispatchResize).observe(),__privateGet(this,_closeRest).observe(),__privateGet(this,_closeRestInGroup).observe(),__privateGet(this,_group).observe(),__privateGet(this,_clickOutside).observe(),__privateGet(this,_escape).observe(),__privateGet(this,_checkViewportBounds).observe(),this.setAttribute("role","dialog"),shared_index.historyManager.addPopStateHandler(__privateGet(this,_popStateListener),!0),setTimeout(()=>{__privateSet(this,_isFromPopState,!0),__privateGet(this,_restore).current?(this.urlValue=url.parseSearchParameters(location.search)[this.id],location.search.includes(this.id)&&this.open({trigger:this.idWithValue})):__privateMethod(this,_PopoverElement_instances,deleteSearchParam_fn).call(this),setTimeout(()=>{__privateSet(this,_isFromPopState,!1)},0)},0),__privateGet(this,_checkViewportBounds).subscribe(()=>{__privateGet(this,_resizeListener).call(this)}),windowResizer_index.windowResizer.subscribe(__privateGet(this,_resizeListener))}disconnectedCallback(){__privateGet(this,_innerCloseElements).forEach(el=>{el.removeEventListener("click",__privateGet(this,_closeElementClickListener))}),_PopoverElement.stack.remove(__privateGet(this,_group).current,this),windowResizer_index.windowResizer.unsubscribe(__privateGet(this,_resizeListener)),__privateGet(this,_history).close(),__privateGet(this,_restore).close(),__privateGet(this,_dispatchResize).close(),__privateGet(this,_closeRest).close(),__privateGet(this,_closeRestInGroup).close(),__privateGet(this,_group).close(),__privateGet(this,_clickOutside).close(),__privateGet(this,_escape).close(),__privateGet(this,_checkViewportBounds).close(),this.removeAttribute("role"),__privateMethod(this,_PopoverElement_instances,toggleGlobalClass_fn).call(this,!1,this.openClass),__privateMethod(this,_PopoverElement_instances,toggleGlobalClass_fn).call(this,!1,this.closingClass),clearTimeout(__privateGet(this,_startClosingTimeoutId)),clearTimeout(__privateGet(this,_closeTimeoutId)),clearTimeout(__privateGet(this,_openFrameId)),clearTimeout(__privateGet(this,_openTransitionTimeoutId)),shared_index.historyManager.removePopStateHandler(__privateGet(this,_popStateListener)),this.style.removeProperty("--content-width"),this.style.removeProperty("--content-height"),this.style.removeProperty("--viewport-offset-x"),this.style.removeProperty("--viewport-offset-y"),__privateMethod(this,_PopoverElement_instances,deleteSearchParam_fn).call(this)}};_opened=new WeakMap,_startClosingTimeoutId=new WeakMap,_closeTimeoutId=new WeakMap,_openFrameId=new WeakMap,_openTransitionTimeoutId=new WeakMap,_history=new WeakMap,_restore=new WeakMap,_dispatchResize=new WeakMap,_closeRest=new WeakMap,_closeRestInGroup=new WeakMap,_group=new WeakMap,_clickOutside=new WeakMap,_escape=new WeakMap,_checkViewportBounds=new WeakMap,_lastTrigger=new WeakMap,_status=new WeakMap,_innerCloseElements=new WeakMap,_resetScrollElements=new WeakMap,_isFromPopState=new WeakMap,_PopoverElement_instances=new WeakSet,path_get=__name(function(){return`${location.pathname}${location.search?location.search+"&":"?"}${this.idWithValue}`},"#path"),toggleGlobalClass_fn=__name(function(on,className){className&&className.split(" ").map(v=>{document.documentElement.classList.toggle(v.trim(),on)})},"#toggleGlobalClass"),deleteSearchParam_fn=__name(function(){if(__privateGet(this,_history).current){const url2=new URL(location.href);url2.searchParams.delete(this.id),shared_index.historyManager.replaceState(url2.href)}},"#deleteSearchParam"),_popStateListener=new WeakMap,_resizeListener=new WeakMap,_debouncedResize=new WeakMap,_resize=new WeakMap,_closeElementClickListener=new WeakMap,__name(_PopoverElement,"PopoverElement"),_PopoverElement.stack=new PopoverGroups,_PopoverElement.popoverHistoryTransactionsDepth=0;let PopoverElement=_PopoverElement;browser.isBrowser&&!customElements.get("e-popover")&&customElements.define("e-popover",PopoverElement);var _popoverElement,_type,_PopoverButtonElement_instances,unlistenPopover_fn,_popoverTriggeredListener,_popoverOpenedListener,_popoverClosingListener,_popoverClosedListener,updateType_fn;const _PopoverButtonElement=class _PopoverButtonElement extends HTMLElement{constructor(){super();__privateAdd(this,_PopoverButtonElement_instances);__privateAdd(this,_popoverElement);__privateAdd(this,_type,new cssProperty_index.CSSProperty(this,"--type","open"));__privateAdd(this,_popoverTriggeredListener,__name(e=>{e.target===__privateGet(this,_popoverElement)&&__privateGet(this,_type).current!=="close"&&this.classList.add("triggered")},"#popoverTriggeredListener"));__privateAdd(this,_popoverOpenedListener,__name(e=>{e.target===__privateGet(this,_popoverElement)&&__privateGet(this,_type).current!=="close"&&(this.classList.add("opened"),this.setAttribute("aria-expanded","true"))},"#popoverOpenedListener"));__privateAdd(this,_popoverClosingListener,__name(e=>{e.target===__privateGet(this,_popoverElement)&&__privateGet(this,_type).current!=="close"&&this.classList.remove("opened")},"#popoverClosingListener"));__privateAdd(this,_popoverClosedListener,__name(e=>{e.target===__privateGet(this,_popoverElement)&&__privateGet(this,_type).current!=="close"&&(this.classList.remove("triggered"),this.setAttribute("aria-expanded","false"))},"#popoverClosedListener"));browser.isBrowser&&(this.addEventListener("click",()=>{if(__privateGet(this,_popoverElement)){const type=__privateGet(this,_type).current;type==="open"||type==="toggle"&&!__privateGet(this,_popoverElement).opened?__privateGet(this,_popoverElement).open({trigger:this}):(type==="close"||type==="toggle"&&__privateGet(this,_popoverElement).opened)&&__privateGet(this,_popoverElement).close(!0)}}),this.addEventListener("keydown",e=>{e.code==="Space"&&!this.hasAttribute("keydown-disabled")&&(e.preventDefault(),this.click())}))}get type(){return __privateGet(this,_type)}get popoverElement(){return __privateGet(this,_popoverElement)}changePopover(targetId){var _a;if(__privateMethod(this,_PopoverButtonElement_instances,unlistenPopover_fn).call(this),targetId){let popoverElement=null;if(targetId==="parent"){const closestTarget=this.closest("[data-popover]");if(closestTarget)popoverElement=closestTarget;else{const rootNode=this.getRootNode();rootNode instanceof ShadowRoot?popoverElement=rootNode.host.closest("[data-popover]"):rootNode instanceof HTMLElement&&(popoverElement=rootNode.closest("[data-popover]"))}}else if(targetId==="sibling")popoverElement=(_a=this.parentElement)==null?void 0:_a.querySelector("[data-popover]");else if(targetId==="ancestor-child"){const find=__name(el=>{if(!el)return null;let founded=el.querySelector("[data-popover]");return!founded&&(el!=null&&el.parentElement)&&(founded=find(el.parentElement)),founded},"find");popoverElement=find(this.parentElement)||null}else{let selector=targetId;if(isNaN(parseInt(selector))&&(!targetId.startsWith(".")&&!targetId.startsWith("[")&&!targetId.startsWith("#")&&(selector=`#${targetId}`),popoverElement=document.querySelector(selector)||this.getRootNode().querySelector(selector)),!popoverElement){const founded=[...document.querySelectorAll("[data-popover-ids]")].find(el=>{var _a2;return(_a2=el.getAttribute("data-popover-ids"))==null?void 0:_a2.split(",").find(v=>v.trim()===targetId)});founded&&(popoverElement=founded)}}popoverElement instanceof HTMLElement?(__privateSet(this,_popoverElement,popoverElement),__privateGet(this,_popoverElement).addEventListener("popoverTriggered",__privateGet(this,_popoverTriggeredListener)),__privateGet(this,_popoverElement).addEventListener("popoverOpened",__privateGet(this,_popoverOpenedListener)),__privateGet(this,_popoverElement).addEventListener("popoverClosing",__privateGet(this,_popoverClosingListener)),__privateGet(this,_popoverElement).addEventListener("popoverClosed",__privateGet(this,_popoverClosedListener))):console.warn(this,`target ${targetId} not found`)}__privateMethod(this,_PopoverButtonElement_instances,updateType_fn).call(this,__privateGet(this,_type).current)}connectedCallback(){__privateGet(this,_type).subscribe(e=>{__privateMethod(this,_PopoverButtonElement_instances,updateType_fn).call(this,e.current)}),this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("role")||this.setAttribute("role","button");const targetId=this.getAttribute("target");targetId&&this.changePopover(targetId),this.isConnected&&__privateGet(this,_type).observe()}disconnectedCallback(){__privateGet(this,_type).unobserve(),this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.removeAttribute("aria-controls"),this.removeAttribute("role"),this.removeAttribute("tabindex"),__privateMethod(this,_PopoverButtonElement_instances,unlistenPopover_fn).call(this)}};_popoverElement=new WeakMap,_type=new WeakMap,_PopoverButtonElement_instances=new WeakSet,unlistenPopover_fn=__name(function(){__privateGet(this,_popoverElement)&&(__privateGet(this,_popoverElement).removeEventListener("popoverTriggered",__privateGet(this,_popoverTriggeredListener)),__privateGet(this,_popoverElement).removeEventListener("popoverOpened",__privateGet(this,_popoverOpenedListener)),__privateGet(this,_popoverElement).removeEventListener("popoverClosing",__privateGet(this,_popoverClosingListener)),__privateGet(this,_popoverElement).removeEventListener("popoverClosed",__privateGet(this,_popoverClosedListener)))},"#unlistenPopover"),_popoverTriggeredListener=new WeakMap,_popoverOpenedListener=new WeakMap,_popoverClosingListener=new WeakMap,_popoverClosedListener=new WeakMap,updateType_fn=__name(function(value){__privateGet(this,_popoverElement)instanceof PopoverElement&&(value!=="close"?(this.setAttribute("aria-haspopup","true"),this.setAttribute("aria-expanded",__privateGet(this,_popoverElement).opened?"true":"false"),this.setAttribute("aria-controls",__privateGet(this,_popoverElement).id||"")):(this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.removeAttribute("aria-controls")))},"#updateType"),__name(_PopoverButtonElement,"PopoverButtonElement");let PopoverButtonElement=_PopoverButtonElement;browser.isBrowser&&!customElements.get("e-popover-button")&&customElements.define("e-popover-button",PopoverButtonElement);exports.PopoverButtonElement=PopoverButtonElement;exports.PopoverElement=PopoverElement;
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty;var __typeError=msg=>{throw TypeError(msg)};var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __accessCheck=(obj,member,msg)=>member.has(obj)||__typeError("Cannot "+msg);var __privateGet=(obj,member,getter)=>(__accessCheck(obj,member,"read from private field"),getter?getter.call(obj):member.get(obj)),__privateAdd=(obj,member,value)=>member.has(obj)?__typeError("Cannot add the same private member more than once"):member instanceof WeakSet?member.add(obj):member.set(obj,value),__privateSet=(obj,member,value,setter)=>(__accessCheck(obj,member,"write to private field"),setter?setter.call(obj,value):member.set(obj,value),value),__privateMethod=(obj,member,method)=>(__accessCheck(obj,member,"access private method"),method);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const cssProperty_index=require("../css-property/index.cjs"),Viewport=require("../Viewport-BdFs1Zsn.cjs"),elementLinkedStore_index=require("../element-linked-store/index.cjs"),shared_index=require("../shared/index.cjs"),browser=require("../browser-CIp8NsnF.cjs"),events=require("../events-UlGk63iC.cjs"),_function=require("../function-H4b_gTg6.cjs"),style=require("../style-IDJ6db6n.cjs");require("construct-style-sheets-polyfill");require("../index-BrasTsja.cjs");const url=require("../url-D_KuhhOg.cjs"),windowResizer_index=require("../window-resizer/index.cjs");var _groups,_stack,_clickOutsideListener,_keydownListener;const _PopoverGroups=class _PopoverGroups{constructor(){__privateAdd(this,_groups,new Map);__privateAdd(this,_stack,[]);__privateAdd(this,_clickOutsideListener,__name(e=>{var _a;const lastPopover=[...__privateGet(this,_stack)].reverse().find(el=>el.clickOutside.current);if(lastPopover){const path=e.composedPath();if(path.find(el=>el instanceof HTMLElement&&el.hasAttribute("data-popover-content")))return;const target=path[0],containsTarget=target instanceof Node&&(lastPopover.contains(target)||((_a=lastPopover.shadowRoot)==null?void 0:_a.contains(target))),outsideTarget=target instanceof HTMLElement&&target.hasAttribute("data-outside");(!containsTarget||outsideTarget)&&lastPopover.close(!0)}},"#clickOutsideListener"));__privateAdd(this,_keydownListener,__name(e=>{if(e.code==="Escape"){const lastPopover=[...__privateGet(this,_stack)].reverse().find(el=>el.escape.current);lastPopover&&lastPopover.close(!0)}},"#keydownListener"));document.documentElement.addEventListener("click",__privateGet(this,_clickOutsideListener)),addEventListener("keydown",__privateGet(this,_keydownListener))}get groups(){return __privateGet(this,_groups)}get stack(){return __privateGet(this,_stack)}add(groupName,element){if(element.closeRest.current)__privateGet(this,_groups).forEach(g=>{g.forEach(e=>{e.close()})});else if(element.closeRestInGroup.current){let group2=__privateGet(this,_groups).get(groupName);group2==null||group2.forEach(e=>{e.close()})}let group=__privateGet(this,_groups).get(groupName);group!=null&&group.length||(group=[],__privateGet(this,_groups).set(groupName,group)),__privateGet(this,_stack).push(element),group.push(element)}remove(groupName,element){if(setTimeout(()=>{__privateSet(this,_stack,__privateGet(this,_stack).filter(e=>e!==element))}),element.closeRest.current){let elements=[];__privateGet(this,_groups).forEach(group=>{group.forEach(element2=>elements.push(element2))}),__privateGet(this,_groups).clear(),elements.forEach(element2=>element2.close())}else if(element.closeRestInGroup.current){const group=__privateGet(this,_groups).get(groupName);__privateGet(this,_groups).delete(groupName),group==null||group.forEach(element2=>{element2.close()})}else{let group=__privateGet(this,_groups).get(groupName);group&&(group=group.filter(el=>el!==element),__privateGet(this,_groups).set(groupName,group))}}};_groups=new WeakMap,_stack=new WeakMap,_clickOutsideListener=new WeakMap,_keydownListener=new WeakMap,__name(_PopoverGroups,"PopoverGroups");let PopoverGroups=_PopoverGroups;var _opened,_startClosingTimeoutId,_closeTimeoutId,_openFrameId,_openTransitionTimeoutId,_history,_restore,_dispatchResize,_closeRest,_closeRestInGroup,_group,_clickOutside,_escape,_checkViewportBounds,_anchor,_lastTrigger,_status,_innerCloseElements,_resetScrollElements,_isFromPopState,_anchorPlaceholder,_isAnchorDomMutation,_PopoverElement_instances,path_get,toggleGlobalClass_fn,deleteSearchParam_fn,_popStateListener,_resizeListener,_debouncedResize,_resize,_closeElementClickListener,queryAnchorIn_fn,normalizeAnchorSelector_fn,getAnchorSelector_fn,resolveAnchorHost_fn,resolveAnchorElement_fn,moveToAnchor_fn,restoreFromAnchor_fn,cleanupAnchorPlaceholder_fn;const _PopoverElement=class _PopoverElement extends HTMLElement{constructor(){super();__privateAdd(this,_PopoverElement_instances);__privateAdd(this,_opened);__privateAdd(this,_startClosingTimeoutId);__privateAdd(this,_closeTimeoutId);__privateAdd(this,_openFrameId);__privateAdd(this,_openTransitionTimeoutId);__privateAdd(this,_history);__privateAdd(this,_restore);__privateAdd(this,_dispatchResize);__privateAdd(this,_closeRest);__privateAdd(this,_closeRestInGroup);__privateAdd(this,_group);__privateAdd(this,_clickOutside);__privateAdd(this,_escape);__privateAdd(this,_checkViewportBounds);__privateAdd(this,_anchor);__privateAdd(this,_lastTrigger);__privateAdd(this,_status);__privateAdd(this,_innerCloseElements);__privateAdd(this,_resetScrollElements);__privateAdd(this,_isFromPopState);__privateAdd(this,_anchorPlaceholder);__privateAdd(this,_isAnchorDomMutation);__privateAdd(this,_popStateListener);__privateAdd(this,_resizeListener);__privateAdd(this,_debouncedResize);__privateAdd(this,_resize);__privateAdd(this,_closeElementClickListener);this.urlValue="",__privateSet(this,_opened,!1),__privateSet(this,_history,new cssProperty_index.CSSProperty(this,"--history",!1)),__privateSet(this,_restore,new cssProperty_index.CSSProperty(this,"--restore",!1)),__privateSet(this,_dispatchResize,new cssProperty_index.CSSProperty(this,"--dispatch-resize",!1)),__privateSet(this,_closeRest,new cssProperty_index.CSSProperty(this,"--close-rest",!1)),__privateSet(this,_closeRestInGroup,new cssProperty_index.CSSProperty(this,"--close-rest-in-group",!1)),__privateSet(this,_group,new cssProperty_index.CSSProperty(this,"--group","")),__privateSet(this,_clickOutside,new cssProperty_index.CSSProperty(this,"--click-outside",!1)),__privateSet(this,_escape,new cssProperty_index.CSSProperty(this,"--escape",!1)),__privateSet(this,_checkViewportBounds,new cssProperty_index.CSSProperty(this,"--check-viewport-bounds",!1)),__privateSet(this,_anchor,new cssProperty_index.CSSProperty(this,"--anchor","")),__privateSet(this,_status,new elementLinkedStore_index.ElementLinkedStore(this,{triggered:!1,beforeopen:!1,opened:!1,closing:!1,transitionend:!1})),__privateSet(this,_innerCloseElements,[]),__privateSet(this,_resetScrollElements,[]),__privateSet(this,_isFromPopState,!1),__privateSet(this,_anchorPlaceholder,null),__privateSet(this,_isAnchorDomMutation,!1),__privateSet(this,_popStateListener,()=>{_PopoverElement.popoverHistoryTransactionsDepth>0||(__privateSet(this,_isFromPopState,!0),__privateGet(this,_opened)&&__privateGet(this,_history).current&&!location.search.includes(this.id)?this.close():!__privateGet(this,_opened)&&__privateGet(this,_history).current&&location.search.includes(this.id)&&this.open({trigger:this.idWithValue}),setTimeout(()=>{__privateSet(this,_isFromPopState,!1)},0))}),__privateSet(this,_resizeListener,()=>{this.style.setProperty("--content-width","initial"),this.style.setProperty("--content-height","initial"),this.style.setProperty("--viewport-offset-x","0px"),this.style.setProperty("--viewport-offset-y","0px"),__privateGet(this,_debouncedResize).call(this)}),__privateSet(this,_debouncedResize,_function.debounce(()=>{__privateGet(this,_resize).call(this)},10)),__privateSet(this,_resize,()=>{if(this.style.setProperty("--content-width",this.scrollWidth+"px"),this.style.setProperty("--content-height",this.scrollHeight+"px"),__privateGet(this,_checkViewportBounds).current){const rect=this.getBoundingClientRect();let viewportOffsetX=0,viewportOffsetY=0;rect.right>Viewport.viewport.width?viewportOffsetX=Viewport.viewport.width-rect.right:rect.left<0&&(viewportOffsetX=rect.left*-1),rect.bottom>Viewport.viewport.height?viewportOffsetY=Viewport.viewport.height-rect.bottom:rect.top<0&&(viewportOffsetY=rect.top*-1),this.style.setProperty("--viewport-offset-x",viewportOffsetX+"px"),this.style.setProperty("--viewport-offset-y",viewportOffsetY+"px")}}),__privateSet(this,_closeElementClickListener,()=>{this.close(!0)}),__privateGet(this,_group).subscribe(e=>{e.previous&&(_PopoverElement.stack.remove(e.previous,this),e.current||(document.documentElement.classList.remove(`${this.group.previous}-closing`),document.documentElement.classList.remove(`${this.group.previous}-opened`)))}),__privateGet(this,_status).subscribe(e=>{if(this.group.current){document.documentElement.classList.toggle(`${this.group.current}-closing`,e.current.closing);const group=_PopoverElement.stack.groups.get(this.group.current),element=group==null?void 0:group.find(e2=>e2.opened);document.documentElement.classList.toggle(`${this.group.current}-opened`,!!element)}})}get openClass(){return this.getAttribute("data-open-global-class")}get closingClass(){return this.getAttribute("data-closing-global-class")}get history(){return __privateGet(this,_history)}get restore(){return __privateGet(this,_restore)}get dispatchResize(){return __privateGet(this,_dispatchResize)}get closeRest(){return __privateGet(this,_closeRest)}get closeRestInGroup(){return __privateGet(this,_closeRestInGroup)}get group(){return __privateGet(this,_group)}get clickOutside(){return __privateGet(this,_clickOutside)}get escape(){return __privateGet(this,_escape)}get anchor(){return __privateGet(this,_anchor)}get opened(){return __privateGet(this,_opened)}get lastTrigger(){return __privateGet(this,_lastTrigger)}get idWithValue(){return`${this.id}${this.urlValue?"="+this.urlValue:""}`}updateUrlValue(value){this.urlValue=(value==null?void 0:value.toString())||"",__privateGet(this,_opened)&&url.updateSearchParameter(this.id,value)}open(options){if(__privateGet(this,_opened))return;__privateSet(this,_lastTrigger,options==null?void 0:options.trigger),clearTimeout(__privateGet(this,_startClosingTimeoutId)),clearTimeout(__privateGet(this,_closeTimeoutId)),__privateMethod(this,_PopoverElement_instances,toggleGlobalClass_fn).call(this,!1,this.closingClass),__privateGet(this,_status).setKey("closing",!1),__privateGet(this,_anchor).check(),__privateMethod(this,_PopoverElement_instances,moveToAnchor_fn).call(this),__privateGet(this,_status).setKey("triggered",!0),events.dispatchEvent(this,"popoverTriggered",{custom:!0,detail:{trigger:__privateGet(this,_lastTrigger)}}),__privateGet(this,_history).current&&(this.beginHistoryTransaction(),__privateGet(this,_isFromPopState)||shared_index.historyManager.pushState(__privateGet(this,_PopoverElement_instances,path_get),{popover:!0}),this.endHistoryTransaction()),__privateGet(this,_status).setKey("beforeopen",!0),__privateSet(this,_opened,!0);const opened=__name(()=>{_PopoverElement.stack.add(__privateGet(this,_group).current,this),__privateGet(this,_resetScrollElements).forEach(el=>{el.scroll({top:0,left:0,behavior:"instant"})}),__privateMethod(this,_PopoverElement_instances,toggleGlobalClass_fn).call(this,!0,this.openClass),__privateGet(this,_status).setKey("opened",!0),__privateGet(this,_dispatchResize).current?events.dispatchEvent(window,"resize",{custom:!0}):__privateGet(this,_resizeListener).call(this),events.dispatchEvent(this,"popoverOpened",{custom:!0,detail:{trigger:__privateGet(this,_lastTrigger)},bubbles:!0}),__privateSet(this,_openFrameId,void 0),__privateSet(this,_openTransitionTimeoutId,setTimeout(()=>{__privateGet(this,_status).setKey("transitionend",!0),events.dispatchEvent(this,"popoverTransitionend")},style.getElementTransitionDurationMS(this)+10))},"opened");options!=null&&options.skipTransition?opened():__privateSet(this,_openFrameId,requestAnimationFrame(opened))}close(back){__privateGet(this,_opened)&&(__privateSet(this,_opened,!1),cancelAnimationFrame(__privateGet(this,_openFrameId)),clearTimeout(__privateGet(this,_openTransitionTimeoutId)),_PopoverElement.stack.remove(__privateGet(this,_group).current,this),__privateGet(this,_history).current&&(this.beginHistoryTransaction(),back?shared_index.historyManager.back():__privateMethod(this,_PopoverElement_instances,deleteSearchParam_fn).call(this),this.endHistoryTransaction()),__privateSet(this,_startClosingTimeoutId,setTimeout(()=>{__privateGet(this,_status).setKey("transitionend",!1),__privateGet(this,_status).setKey("opened",!1),__privateGet(this,_status).setKey("closing",!0),__privateMethod(this,_PopoverElement_instances,toggleGlobalClass_fn).call(this,!1,this.openClass),__privateMethod(this,_PopoverElement_instances,toggleGlobalClass_fn).call(this,!0,this.closingClass),events.dispatchEvent(this,"popoverClosing",{custom:!0,bubbles:!0}),__privateSet(this,_closeTimeoutId,setTimeout(()=>{__privateGet(this,_status).setKey("triggered",!1),__privateGet(this,_status).setKey("beforeopen",!1),__privateGet(this,_status).setKey("closing",!1),__privateMethod(this,_PopoverElement_instances,toggleGlobalClass_fn).call(this,!1,this.closingClass),__privateMethod(this,_PopoverElement_instances,restoreFromAnchor_fn).call(this),events.dispatchEvent(this,"popoverClosed",{custom:!0,bubbles:!0})},style.getElementTransitionDurationMS(this)+10))},10)))}beginHistoryTransaction(){_PopoverElement.popoverHistoryTransactionsDepth++}endHistoryTransaction(){setTimeout(()=>{_PopoverElement.popoverHistoryTransactionsDepth--},0)}connectedCallback(){__privateGet(this,_isAnchorDomMutation)||(__privateSet(this,_innerCloseElements,[...this.querySelectorAll(`[data-popover-close${this.id?`="${this.id}"`:""}]`)]),__privateGet(this,_innerCloseElements).forEach(el=>{el.addEventListener("click",__privateGet(this,_closeElementClickListener))}),__privateSet(this,_resetScrollElements,[...this.querySelectorAll(`[data-popover-reset-scroll${this.id?`="${this.id}"`:""}]`)]),__privateGet(this,_history).observe(),__privateGet(this,_restore).observe(),__privateGet(this,_dispatchResize).observe(),__privateGet(this,_closeRest).observe(),__privateGet(this,_closeRestInGroup).observe(),__privateGet(this,_group).observe(),__privateGet(this,_clickOutside).observe(),__privateGet(this,_escape).observe(),__privateGet(this,_checkViewportBounds).observe(),__privateGet(this,_anchor).observe(),this.setAttribute("role","dialog"),shared_index.historyManager.addPopStateHandler(__privateGet(this,_popStateListener),!0),setTimeout(()=>{__privateSet(this,_isFromPopState,!0),__privateGet(this,_restore).current?(this.urlValue=url.parseSearchParameters(location.search)[this.id],location.search.includes(this.id)&&this.open({trigger:this.idWithValue})):__privateMethod(this,_PopoverElement_instances,deleteSearchParam_fn).call(this),setTimeout(()=>{__privateSet(this,_isFromPopState,!1)},0)},0),__privateGet(this,_checkViewportBounds).subscribe(()=>{__privateGet(this,_resizeListener).call(this)}),windowResizer_index.windowResizer.subscribe(__privateGet(this,_resizeListener)))}disconnectedCallback(){__privateGet(this,_isAnchorDomMutation)||(__privateGet(this,_innerCloseElements).forEach(el=>{el.removeEventListener("click",__privateGet(this,_closeElementClickListener))}),_PopoverElement.stack.remove(__privateGet(this,_group).current,this),windowResizer_index.windowResizer.unsubscribe(__privateGet(this,_resizeListener)),__privateGet(this,_history).close(),__privateGet(this,_restore).close(),__privateGet(this,_dispatchResize).close(),__privateGet(this,_closeRest).close(),__privateGet(this,_closeRestInGroup).close(),__privateGet(this,_group).close(),__privateGet(this,_clickOutside).close(),__privateGet(this,_escape).close(),__privateGet(this,_checkViewportBounds).close(),__privateGet(this,_anchor).close(),this.removeAttribute("role"),__privateMethod(this,_PopoverElement_instances,toggleGlobalClass_fn).call(this,!1,this.openClass),__privateMethod(this,_PopoverElement_instances,toggleGlobalClass_fn).call(this,!1,this.closingClass),clearTimeout(__privateGet(this,_startClosingTimeoutId)),clearTimeout(__privateGet(this,_closeTimeoutId)),clearTimeout(__privateGet(this,_openFrameId)),clearTimeout(__privateGet(this,_openTransitionTimeoutId)),shared_index.historyManager.removePopStateHandler(__privateGet(this,_popStateListener)),__privateGet(this,_isAnchorDomMutation)||__privateMethod(this,_PopoverElement_instances,cleanupAnchorPlaceholder_fn).call(this),this.style.removeProperty("--content-width"),this.style.removeProperty("--content-height"),this.style.removeProperty("--viewport-offset-x"),this.style.removeProperty("--viewport-offset-y"),__privateMethod(this,_PopoverElement_instances,deleteSearchParam_fn).call(this))}};_opened=new WeakMap,_startClosingTimeoutId=new WeakMap,_closeTimeoutId=new WeakMap,_openFrameId=new WeakMap,_openTransitionTimeoutId=new WeakMap,_history=new WeakMap,_restore=new WeakMap,_dispatchResize=new WeakMap,_closeRest=new WeakMap,_closeRestInGroup=new WeakMap,_group=new WeakMap,_clickOutside=new WeakMap,_escape=new WeakMap,_checkViewportBounds=new WeakMap,_anchor=new WeakMap,_lastTrigger=new WeakMap,_status=new WeakMap,_innerCloseElements=new WeakMap,_resetScrollElements=new WeakMap,_isFromPopState=new WeakMap,_anchorPlaceholder=new WeakMap,_isAnchorDomMutation=new WeakMap,_PopoverElement_instances=new WeakSet,path_get=__name(function(){return`${location.pathname}${location.search?location.search+"&":"?"}${this.idWithValue}`},"#path"),toggleGlobalClass_fn=__name(function(on,className){className&&className.split(" ").map(v=>{document.documentElement.classList.toggle(v.trim(),on)})},"#toggleGlobalClass"),deleteSearchParam_fn=__name(function(){if(__privateGet(this,_history).current){const url2=new URL(location.href);url2.searchParams.delete(this.id),shared_index.historyManager.replaceState(url2.href)}},"#deleteSearchParam"),_popStateListener=new WeakMap,_resizeListener=new WeakMap,_debouncedResize=new WeakMap,_resize=new WeakMap,_closeElementClickListener=new WeakMap,queryAnchorIn_fn=__name(function(root,selector){if(!("querySelector"in root))return null;let anchor=root.querySelector(selector);return!anchor&&!selector.startsWith("#")&&!selector.startsWith(".")&&!selector.startsWith("[")&&(anchor=root.querySelector(`#${selector}`)),anchor},"#queryAnchorIn"),normalizeAnchorSelector_fn=__name(function(value){const trimmed=value.trim();return trimmed.startsWith('"')&&trimmed.endsWith('"')||trimmed.startsWith("'")&&trimmed.endsWith("'")?trimmed.slice(1,-1).trim():trimmed},"#normalizeAnchorSelector"),getAnchorSelector_fn=__name(function(){var _a,_b;const fromAttr=((_a=this.getAttribute("anchor"))==null?void 0:_a.trim())||((_b=this.getAttribute("data-popover-anchor"))==null?void 0:_b.trim()),fromCssRaw=__privateGet(this,_anchor).currentRawValue.trim(),fromCssParsed=typeof __privateGet(this,_anchor).current=="string"?__privateGet(this,_anchor).current.trim():"";return __privateMethod(this,_PopoverElement_instances,normalizeAnchorSelector_fn).call(this,fromAttr||fromCssRaw||fromCssParsed||"")||null},"#getAnchorSelector"),resolveAnchorHost_fn=__name(function(selector){switch(selector.toLowerCase()){case"body":return document.body;case"html":case"documentelement":return document.documentElement;default:return null}},"#resolveAnchorHost"),resolveAnchorElement_fn=__name(function(){const selector=__privateMethod(this,_PopoverElement_instances,getAnchorSelector_fn).call(this);if(!selector)return null;const host=__privateMethod(this,_PopoverElement_instances,resolveAnchorHost_fn).call(this,selector);if(host)return host;const root=this.getRootNode(),anchor=__privateMethod(this,_PopoverElement_instances,queryAnchorIn_fn).call(this,document,selector)||(root instanceof Document||root instanceof ShadowRoot?__privateMethod(this,_PopoverElement_instances,queryAnchorIn_fn).call(this,root,selector):null);return anchor||console.warn(this,`anchor target "${selector}" not found`),anchor},"#resolveAnchorElement"),moveToAnchor_fn=__name(function(){const anchor=__privateMethod(this,_PopoverElement_instances,resolveAnchorElement_fn).call(this);if(!(!anchor||anchor===this.parentElement)&&this.isConnected){if(!__privateGet(this,_anchorPlaceholder)){__privateSet(this,_anchorPlaceholder,document.createComment("e-popover-anchor"));const parent=this.parentNode;parent&&parent.insertBefore(__privateGet(this,_anchorPlaceholder),this.nextSibling)}__privateSet(this,_isAnchorDomMutation,!0);try{anchor.appendChild(this)}finally{__privateSet(this,_isAnchorDomMutation,!1)}}},"#moveToAnchor"),restoreFromAnchor_fn=__name(function(){var _a;const placeholderParent=(_a=__privateGet(this,_anchorPlaceholder))==null?void 0:_a.parentNode;if(placeholderParent){__privateSet(this,_isAnchorDomMutation,!0);try{placeholderParent.insertBefore(this,__privateGet(this,_anchorPlaceholder)),__privateGet(this,_anchorPlaceholder).remove(),__privateSet(this,_anchorPlaceholder,null)}finally{__privateSet(this,_isAnchorDomMutation,!1)}}},"#restoreFromAnchor"),cleanupAnchorPlaceholder_fn=__name(function(){var _a;(_a=__privateGet(this,_anchorPlaceholder))==null||_a.remove(),__privateSet(this,_anchorPlaceholder,null)},"#cleanupAnchorPlaceholder"),__name(_PopoverElement,"PopoverElement"),_PopoverElement.stack=new PopoverGroups,_PopoverElement.popoverHistoryTransactionsDepth=0;let PopoverElement=_PopoverElement;browser.isBrowser&&!customElements.get("e-popover")&&customElements.define("e-popover",PopoverElement);var _popoverElement,_type,_PopoverButtonElement_instances,unlistenPopover_fn,_popoverTriggeredListener,_popoverOpenedListener,_popoverClosingListener,_popoverClosedListener,updateType_fn;const _PopoverButtonElement=class _PopoverButtonElement extends HTMLElement{constructor(){super();__privateAdd(this,_PopoverButtonElement_instances);__privateAdd(this,_popoverElement);__privateAdd(this,_type,new cssProperty_index.CSSProperty(this,"--type","open"));__privateAdd(this,_popoverTriggeredListener,__name(e=>{e.target===__privateGet(this,_popoverElement)&&__privateGet(this,_type).current!=="close"&&this.classList.add("triggered")},"#popoverTriggeredListener"));__privateAdd(this,_popoverOpenedListener,__name(e=>{e.target===__privateGet(this,_popoverElement)&&__privateGet(this,_type).current!=="close"&&(this.classList.add("opened"),this.setAttribute("aria-expanded","true"))},"#popoverOpenedListener"));__privateAdd(this,_popoverClosingListener,__name(e=>{e.target===__privateGet(this,_popoverElement)&&__privateGet(this,_type).current!=="close"&&this.classList.remove("opened")},"#popoverClosingListener"));__privateAdd(this,_popoverClosedListener,__name(e=>{e.target===__privateGet(this,_popoverElement)&&__privateGet(this,_type).current!=="close"&&(this.classList.remove("triggered"),this.setAttribute("aria-expanded","false"))},"#popoverClosedListener"));browser.isBrowser&&(this.addEventListener("click",()=>{if(__privateGet(this,_popoverElement)){const type=__privateGet(this,_type).current;type==="open"||type==="toggle"&&!__privateGet(this,_popoverElement).opened?__privateGet(this,_popoverElement).open({trigger:this}):(type==="close"||type==="toggle"&&__privateGet(this,_popoverElement).opened)&&__privateGet(this,_popoverElement).close(!0)}}),this.addEventListener("keydown",e=>{e.code==="Space"&&!this.hasAttribute("keydown-disabled")&&(e.preventDefault(),this.click())}))}get type(){return __privateGet(this,_type)}get popoverElement(){return __privateGet(this,_popoverElement)}changePopover(targetId){var _a;if(__privateMethod(this,_PopoverButtonElement_instances,unlistenPopover_fn).call(this),targetId){let popoverElement=null;if(targetId==="parent"){const closestTarget=this.closest("[data-popover]");if(closestTarget)popoverElement=closestTarget;else{const rootNode=this.getRootNode();rootNode instanceof ShadowRoot?popoverElement=rootNode.host.closest("[data-popover]"):rootNode instanceof HTMLElement&&(popoverElement=rootNode.closest("[data-popover]"))}}else if(targetId==="sibling")popoverElement=(_a=this.parentElement)==null?void 0:_a.querySelector("[data-popover]");else if(targetId==="ancestor-child"){const find=__name(el=>{if(!el)return null;let founded=el.querySelector("[data-popover]");return!founded&&(el!=null&&el.parentElement)&&(founded=find(el.parentElement)),founded},"find");popoverElement=find(this.parentElement)||null}else{let selector=targetId;if(isNaN(parseInt(selector))&&(!targetId.startsWith(".")&&!targetId.startsWith("[")&&!targetId.startsWith("#")&&(selector=`#${targetId}`),popoverElement=document.querySelector(selector)||this.getRootNode().querySelector(selector)),!popoverElement){const founded=[...document.querySelectorAll("[data-popover-ids]")].find(el=>{var _a2;return(_a2=el.getAttribute("data-popover-ids"))==null?void 0:_a2.split(",").find(v=>v.trim()===targetId)});founded&&(popoverElement=founded)}}popoverElement instanceof HTMLElement?(__privateSet(this,_popoverElement,popoverElement),__privateGet(this,_popoverElement).addEventListener("popoverTriggered",__privateGet(this,_popoverTriggeredListener)),__privateGet(this,_popoverElement).addEventListener("popoverOpened",__privateGet(this,_popoverOpenedListener)),__privateGet(this,_popoverElement).addEventListener("popoverClosing",__privateGet(this,_popoverClosingListener)),__privateGet(this,_popoverElement).addEventListener("popoverClosed",__privateGet(this,_popoverClosedListener))):console.warn(this,`target ${targetId} not found`)}__privateMethod(this,_PopoverButtonElement_instances,updateType_fn).call(this,__privateGet(this,_type).current)}connectedCallback(){__privateGet(this,_type).subscribe(e=>{__privateMethod(this,_PopoverButtonElement_instances,updateType_fn).call(this,e.current)}),this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("role")||this.setAttribute("role","button");const targetId=this.getAttribute("target");targetId&&this.changePopover(targetId),this.isConnected&&__privateGet(this,_type).observe()}disconnectedCallback(){__privateGet(this,_type).unobserve(),this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.removeAttribute("aria-controls"),this.removeAttribute("role"),this.removeAttribute("tabindex"),__privateMethod(this,_PopoverButtonElement_instances,unlistenPopover_fn).call(this)}};_popoverElement=new WeakMap,_type=new WeakMap,_PopoverButtonElement_instances=new WeakSet,unlistenPopover_fn=__name(function(){__privateGet(this,_popoverElement)&&(__privateGet(this,_popoverElement).removeEventListener("popoverTriggered",__privateGet(this,_popoverTriggeredListener)),__privateGet(this,_popoverElement).removeEventListener("popoverOpened",__privateGet(this,_popoverOpenedListener)),__privateGet(this,_popoverElement).removeEventListener("popoverClosing",__privateGet(this,_popoverClosingListener)),__privateGet(this,_popoverElement).removeEventListener("popoverClosed",__privateGet(this,_popoverClosedListener)))},"#unlistenPopover"),_popoverTriggeredListener=new WeakMap,_popoverOpenedListener=new WeakMap,_popoverClosingListener=new WeakMap,_popoverClosedListener=new WeakMap,updateType_fn=__name(function(value){__privateGet(this,_popoverElement)instanceof PopoverElement&&(value!=="close"?(this.setAttribute("aria-haspopup","true"),this.setAttribute("aria-expanded",__privateGet(this,_popoverElement).opened?"true":"false"),this.setAttribute("aria-controls",__privateGet(this,_popoverElement).id||"")):(this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.removeAttribute("aria-controls")))},"#updateType"),__name(_PopoverButtonElement,"PopoverButtonElement");let PopoverButtonElement=_PopoverButtonElement;browser.isBrowser&&!customElements.get("e-popover-button")&&customElements.define("e-popover-button",PopoverButtonElement);exports.PopoverButtonElement=PopoverButtonElement;exports.PopoverElement=PopoverElement;
|
package/lib/popover/index.js
CHANGED
|
@@ -89,7 +89,7 @@ const _PopoverGroups = class _PopoverGroups {
|
|
|
89
89
|
};
|
|
90
90
|
_groups = new WeakMap(), _stack = new WeakMap(), _clickOutsideListener = new WeakMap(), _keydownListener = new WeakMap(), __name(_PopoverGroups, "PopoverGroups");
|
|
91
91
|
let PopoverGroups = _PopoverGroups;
|
|
92
|
-
var _opened, _startClosingTimeoutId, _closeTimeoutId, _openFrameId, _openTransitionTimeoutId, _history, _restore, _dispatchResize, _closeRest, _closeRestInGroup, _group, _clickOutside, _escape, _checkViewportBounds, _lastTrigger, _status, _innerCloseElements, _resetScrollElements, _isFromPopState, _PopoverElement_instances, path_get, toggleGlobalClass_fn, deleteSearchParam_fn, _popStateListener, _resizeListener, _debouncedResize, _resize, _closeElementClickListener;
|
|
92
|
+
var _opened, _startClosingTimeoutId, _closeTimeoutId, _openFrameId, _openTransitionTimeoutId, _history, _restore, _dispatchResize, _closeRest, _closeRestInGroup, _group, _clickOutside, _escape, _checkViewportBounds, _anchor, _lastTrigger, _status, _innerCloseElements, _resetScrollElements, _isFromPopState, _anchorPlaceholder, _isAnchorDomMutation, _PopoverElement_instances, path_get, toggleGlobalClass_fn, deleteSearchParam_fn, _popStateListener, _resizeListener, _debouncedResize, _resize, _closeElementClickListener, queryAnchorIn_fn, normalizeAnchorSelector_fn, getAnchorSelector_fn, resolveAnchorHost_fn, resolveAnchorElement_fn, moveToAnchor_fn, restoreFromAnchor_fn, cleanupAnchorPlaceholder_fn;
|
|
93
93
|
const _PopoverElement = class _PopoverElement extends HTMLElement {
|
|
94
94
|
constructor() {
|
|
95
95
|
super();
|
|
@@ -108,11 +108,14 @@ const _PopoverElement = class _PopoverElement extends HTMLElement {
|
|
|
108
108
|
__privateAdd(this, _clickOutside);
|
|
109
109
|
__privateAdd(this, _escape);
|
|
110
110
|
__privateAdd(this, _checkViewportBounds);
|
|
111
|
+
__privateAdd(this, _anchor);
|
|
111
112
|
__privateAdd(this, _lastTrigger);
|
|
112
113
|
__privateAdd(this, _status);
|
|
113
114
|
__privateAdd(this, _innerCloseElements);
|
|
114
115
|
__privateAdd(this, _resetScrollElements);
|
|
115
116
|
__privateAdd(this, _isFromPopState);
|
|
117
|
+
__privateAdd(this, _anchorPlaceholder);
|
|
118
|
+
__privateAdd(this, _isAnchorDomMutation);
|
|
116
119
|
__privateAdd(this, _popStateListener);
|
|
117
120
|
__privateAdd(this, _resizeListener);
|
|
118
121
|
__privateAdd(this, _debouncedResize);
|
|
@@ -122,13 +125,13 @@ const _PopoverElement = class _PopoverElement extends HTMLElement {
|
|
|
122
125
|
this,
|
|
123
126
|
"--close-rest-in-group",
|
|
124
127
|
!1
|
|
125
|
-
)), __privateSet(this, _group, new CSSProperty(this, "--group", "")), __privateSet(this, _clickOutside, new CSSProperty(this, "--click-outside", !1)), __privateSet(this, _escape, new CSSProperty(this, "--escape", !1)), __privateSet(this, _checkViewportBounds, new CSSProperty(this, "--check-viewport-bounds", !1)), __privateSet(this, _status, new ElementLinkedStore(this, {
|
|
128
|
+
)), __privateSet(this, _group, new CSSProperty(this, "--group", "")), __privateSet(this, _clickOutside, new CSSProperty(this, "--click-outside", !1)), __privateSet(this, _escape, new CSSProperty(this, "--escape", !1)), __privateSet(this, _checkViewportBounds, new CSSProperty(this, "--check-viewport-bounds", !1)), __privateSet(this, _anchor, new CSSProperty(this, "--anchor", "")), __privateSet(this, _status, new ElementLinkedStore(this, {
|
|
126
129
|
triggered: !1,
|
|
127
130
|
beforeopen: !1,
|
|
128
131
|
opened: !1,
|
|
129
132
|
closing: !1,
|
|
130
133
|
transitionend: !1
|
|
131
|
-
})), __privateSet(this, _innerCloseElements, []), __privateSet(this, _resetScrollElements, []), __privateSet(this, _isFromPopState, !1), __privateSet(this, _popStateListener, () => {
|
|
134
|
+
})), __privateSet(this, _innerCloseElements, []), __privateSet(this, _resetScrollElements, []), __privateSet(this, _isFromPopState, !1), __privateSet(this, _anchorPlaceholder, null), __privateSet(this, _isAnchorDomMutation, !1), __privateSet(this, _popStateListener, () => {
|
|
132
135
|
_PopoverElement.popoverHistoryTransactionsDepth > 0 || (__privateSet(this, _isFromPopState, !0), __privateGet(this, _opened) && __privateGet(this, _history).current && !location.search.includes(this.id) ? this.close() : !__privateGet(this, _opened) && __privateGet(this, _history).current && location.search.includes(this.id) && this.open({ trigger: this.idWithValue }), setTimeout(() => {
|
|
133
136
|
__privateSet(this, _isFromPopState, !1);
|
|
134
137
|
}, 0));
|
|
@@ -194,6 +197,9 @@ const _PopoverElement = class _PopoverElement extends HTMLElement {
|
|
|
194
197
|
get escape() {
|
|
195
198
|
return __privateGet(this, _escape);
|
|
196
199
|
}
|
|
200
|
+
get anchor() {
|
|
201
|
+
return __privateGet(this, _anchor);
|
|
202
|
+
}
|
|
197
203
|
get opened() {
|
|
198
204
|
return __privateGet(this, _opened);
|
|
199
205
|
}
|
|
@@ -209,7 +215,7 @@ const _PopoverElement = class _PopoverElement extends HTMLElement {
|
|
|
209
215
|
open(options) {
|
|
210
216
|
if (__privateGet(this, _opened))
|
|
211
217
|
return;
|
|
212
|
-
__privateSet(this, _lastTrigger, options == null ? void 0 : options.trigger), clearTimeout(__privateGet(this, _startClosingTimeoutId)), clearTimeout(__privateGet(this, _closeTimeoutId)), __privateMethod(this, _PopoverElement_instances, toggleGlobalClass_fn).call(this, !1, this.closingClass), __privateGet(this, _status).setKey("closing", !1), __privateGet(this, _status).setKey("triggered", !0), dispatchEvent(this, "popoverTriggered", {
|
|
218
|
+
__privateSet(this, _lastTrigger, options == null ? void 0 : options.trigger), clearTimeout(__privateGet(this, _startClosingTimeoutId)), clearTimeout(__privateGet(this, _closeTimeoutId)), __privateMethod(this, _PopoverElement_instances, toggleGlobalClass_fn).call(this, !1, this.closingClass), __privateGet(this, _status).setKey("closing", !1), __privateGet(this, _anchor).check(), __privateMethod(this, _PopoverElement_instances, moveToAnchor_fn).call(this), __privateGet(this, _status).setKey("triggered", !0), dispatchEvent(this, "popoverTriggered", {
|
|
213
219
|
custom: !0,
|
|
214
220
|
detail: {
|
|
215
221
|
trigger: __privateGet(this, _lastTrigger)
|
|
@@ -244,7 +250,7 @@ const _PopoverElement = class _PopoverElement extends HTMLElement {
|
|
|
244
250
|
bubbles: !0
|
|
245
251
|
}), __privateSet(this, _closeTimeoutId, setTimeout(
|
|
246
252
|
() => {
|
|
247
|
-
__privateGet(this, _status).setKey("triggered", !1), __privateGet(this, _status).setKey("beforeopen", !1), __privateGet(this, _status).setKey("closing", !1), __privateMethod(this, _PopoverElement_instances, toggleGlobalClass_fn).call(this, !1, this.closingClass), dispatchEvent(this, "popoverClosed", {
|
|
253
|
+
__privateGet(this, _status).setKey("triggered", !1), __privateGet(this, _status).setKey("beforeopen", !1), __privateGet(this, _status).setKey("closing", !1), __privateMethod(this, _PopoverElement_instances, toggleGlobalClass_fn).call(this, !1, this.closingClass), __privateMethod(this, _PopoverElement_instances, restoreFromAnchor_fn).call(this), dispatchEvent(this, "popoverClosed", {
|
|
248
254
|
custom: !0,
|
|
249
255
|
bubbles: !0
|
|
250
256
|
});
|
|
@@ -262,7 +268,7 @@ const _PopoverElement = class _PopoverElement extends HTMLElement {
|
|
|
262
268
|
}, 0);
|
|
263
269
|
}
|
|
264
270
|
connectedCallback() {
|
|
265
|
-
__privateSet(this, _innerCloseElements, [
|
|
271
|
+
__privateGet(this, _isAnchorDomMutation) || (__privateSet(this, _innerCloseElements, [
|
|
266
272
|
...this.querySelectorAll(
|
|
267
273
|
`[data-popover-close${this.id ? `="${this.id}"` : ""}]`
|
|
268
274
|
)
|
|
@@ -272,21 +278,21 @@ const _PopoverElement = class _PopoverElement extends HTMLElement {
|
|
|
272
278
|
...this.querySelectorAll(
|
|
273
279
|
`[data-popover-reset-scroll${this.id ? `="${this.id}"` : ""}]`
|
|
274
280
|
)
|
|
275
|
-
]), __privateGet(this, _history).observe(), __privateGet(this, _restore).observe(), __privateGet(this, _dispatchResize).observe(), __privateGet(this, _closeRest).observe(), __privateGet(this, _closeRestInGroup).observe(), __privateGet(this, _group).observe(), __privateGet(this, _clickOutside).observe(), __privateGet(this, _escape).observe(), __privateGet(this, _checkViewportBounds).observe(), this.setAttribute("role", "dialog"), historyManager.addPopStateHandler(__privateGet(this, _popStateListener), !0), setTimeout(() => {
|
|
281
|
+
]), __privateGet(this, _history).observe(), __privateGet(this, _restore).observe(), __privateGet(this, _dispatchResize).observe(), __privateGet(this, _closeRest).observe(), __privateGet(this, _closeRestInGroup).observe(), __privateGet(this, _group).observe(), __privateGet(this, _clickOutside).observe(), __privateGet(this, _escape).observe(), __privateGet(this, _checkViewportBounds).observe(), __privateGet(this, _anchor).observe(), this.setAttribute("role", "dialog"), historyManager.addPopStateHandler(__privateGet(this, _popStateListener), !0), setTimeout(() => {
|
|
276
282
|
__privateSet(this, _isFromPopState, !0), __privateGet(this, _restore).current ? (this.urlValue = parseSearchParameters(location.search)[this.id], location.search.includes(this.id) && this.open({ trigger: this.idWithValue })) : __privateMethod(this, _PopoverElement_instances, deleteSearchParam_fn).call(this), setTimeout(() => {
|
|
277
283
|
__privateSet(this, _isFromPopState, !1);
|
|
278
284
|
}, 0);
|
|
279
285
|
}, 0), __privateGet(this, _checkViewportBounds).subscribe(() => {
|
|
280
286
|
__privateGet(this, _resizeListener).call(this);
|
|
281
|
-
}), windowResizer.subscribe(__privateGet(this, _resizeListener));
|
|
287
|
+
}), windowResizer.subscribe(__privateGet(this, _resizeListener)));
|
|
282
288
|
}
|
|
283
289
|
disconnectedCallback() {
|
|
284
|
-
__privateGet(this, _innerCloseElements).forEach((el) => {
|
|
290
|
+
__privateGet(this, _isAnchorDomMutation) || (__privateGet(this, _innerCloseElements).forEach((el) => {
|
|
285
291
|
el.removeEventListener("click", __privateGet(this, _closeElementClickListener));
|
|
286
|
-
}), _PopoverElement.stack.remove(__privateGet(this, _group).current, this), windowResizer.unsubscribe(__privateGet(this, _resizeListener)), __privateGet(this, _history).close(), __privateGet(this, _restore).close(), __privateGet(this, _dispatchResize).close(), __privateGet(this, _closeRest).close(), __privateGet(this, _closeRestInGroup).close(), __privateGet(this, _group).close(), __privateGet(this, _clickOutside).close(), __privateGet(this, _escape).close(), __privateGet(this, _checkViewportBounds).close(), this.removeAttribute("role"), __privateMethod(this, _PopoverElement_instances, toggleGlobalClass_fn).call(this, !1, this.openClass), __privateMethod(this, _PopoverElement_instances, toggleGlobalClass_fn).call(this, !1, this.closingClass), clearTimeout(__privateGet(this, _startClosingTimeoutId)), clearTimeout(__privateGet(this, _closeTimeoutId)), clearTimeout(__privateGet(this, _openFrameId)), clearTimeout(__privateGet(this, _openTransitionTimeoutId)), historyManager.removePopStateHandler(__privateGet(this, _popStateListener)), this.style.removeProperty("--content-width"), this.style.removeProperty("--content-height"), this.style.removeProperty("--viewport-offset-x"), this.style.removeProperty("--viewport-offset-y"), __privateMethod(this, _PopoverElement_instances, deleteSearchParam_fn).call(this);
|
|
292
|
+
}), _PopoverElement.stack.remove(__privateGet(this, _group).current, this), windowResizer.unsubscribe(__privateGet(this, _resizeListener)), __privateGet(this, _history).close(), __privateGet(this, _restore).close(), __privateGet(this, _dispatchResize).close(), __privateGet(this, _closeRest).close(), __privateGet(this, _closeRestInGroup).close(), __privateGet(this, _group).close(), __privateGet(this, _clickOutside).close(), __privateGet(this, _escape).close(), __privateGet(this, _checkViewportBounds).close(), __privateGet(this, _anchor).close(), this.removeAttribute("role"), __privateMethod(this, _PopoverElement_instances, toggleGlobalClass_fn).call(this, !1, this.openClass), __privateMethod(this, _PopoverElement_instances, toggleGlobalClass_fn).call(this, !1, this.closingClass), clearTimeout(__privateGet(this, _startClosingTimeoutId)), clearTimeout(__privateGet(this, _closeTimeoutId)), clearTimeout(__privateGet(this, _openFrameId)), clearTimeout(__privateGet(this, _openTransitionTimeoutId)), historyManager.removePopStateHandler(__privateGet(this, _popStateListener)), __privateGet(this, _isAnchorDomMutation) || __privateMethod(this, _PopoverElement_instances, cleanupAnchorPlaceholder_fn).call(this), this.style.removeProperty("--content-width"), this.style.removeProperty("--content-height"), this.style.removeProperty("--viewport-offset-x"), this.style.removeProperty("--viewport-offset-y"), __privateMethod(this, _PopoverElement_instances, deleteSearchParam_fn).call(this));
|
|
287
293
|
}
|
|
288
294
|
};
|
|
289
|
-
_opened = new WeakMap(), _startClosingTimeoutId = new WeakMap(), _closeTimeoutId = new WeakMap(), _openFrameId = new WeakMap(), _openTransitionTimeoutId = new WeakMap(), _history = new WeakMap(), _restore = new WeakMap(), _dispatchResize = new WeakMap(), _closeRest = new WeakMap(), _closeRestInGroup = new WeakMap(), _group = new WeakMap(), _clickOutside = new WeakMap(), _escape = new WeakMap(), _checkViewportBounds = new WeakMap(), _lastTrigger = new WeakMap(), _status = new WeakMap(), _innerCloseElements = new WeakMap(), _resetScrollElements = new WeakMap(), _isFromPopState = new WeakMap(), _PopoverElement_instances = new WeakSet(), path_get = /* @__PURE__ */ __name(function() {
|
|
295
|
+
_opened = new WeakMap(), _startClosingTimeoutId = new WeakMap(), _closeTimeoutId = new WeakMap(), _openFrameId = new WeakMap(), _openTransitionTimeoutId = new WeakMap(), _history = new WeakMap(), _restore = new WeakMap(), _dispatchResize = new WeakMap(), _closeRest = new WeakMap(), _closeRestInGroup = new WeakMap(), _group = new WeakMap(), _clickOutside = new WeakMap(), _escape = new WeakMap(), _checkViewportBounds = new WeakMap(), _anchor = new WeakMap(), _lastTrigger = new WeakMap(), _status = new WeakMap(), _innerCloseElements = new WeakMap(), _resetScrollElements = new WeakMap(), _isFromPopState = new WeakMap(), _anchorPlaceholder = new WeakMap(), _isAnchorDomMutation = new WeakMap(), _PopoverElement_instances = new WeakSet(), path_get = /* @__PURE__ */ __name(function() {
|
|
290
296
|
return `${location.pathname}${location.search ? location.search + "&" : "?"}${this.idWithValue}`;
|
|
291
297
|
}, "#path"), toggleGlobalClass_fn = /* @__PURE__ */ __name(function(on, className) {
|
|
292
298
|
className && className.split(" ").map((v) => {
|
|
@@ -297,7 +303,67 @@ _opened = new WeakMap(), _startClosingTimeoutId = new WeakMap(), _closeTimeoutId
|
|
|
297
303
|
const url = new URL(location.href);
|
|
298
304
|
url.searchParams.delete(this.id), historyManager.replaceState(url.href);
|
|
299
305
|
}
|
|
300
|
-
}, "#deleteSearchParam"), _popStateListener = new WeakMap(), _resizeListener = new WeakMap(), _debouncedResize = new WeakMap(), _resize = new WeakMap(), _closeElementClickListener = new WeakMap(),
|
|
306
|
+
}, "#deleteSearchParam"), _popStateListener = new WeakMap(), _resizeListener = new WeakMap(), _debouncedResize = new WeakMap(), _resize = new WeakMap(), _closeElementClickListener = new WeakMap(), queryAnchorIn_fn = /* @__PURE__ */ __name(function(root, selector) {
|
|
307
|
+
if (!("querySelector" in root))
|
|
308
|
+
return null;
|
|
309
|
+
let anchor = root.querySelector(selector);
|
|
310
|
+
return !anchor && !selector.startsWith("#") && !selector.startsWith(".") && !selector.startsWith("[") && (anchor = root.querySelector(`#${selector}`)), anchor;
|
|
311
|
+
}, "#queryAnchorIn"), normalizeAnchorSelector_fn = /* @__PURE__ */ __name(function(value) {
|
|
312
|
+
const trimmed = value.trim();
|
|
313
|
+
return trimmed.startsWith('"') && trimmed.endsWith('"') || trimmed.startsWith("'") && trimmed.endsWith("'") ? trimmed.slice(1, -1).trim() : trimmed;
|
|
314
|
+
}, "#normalizeAnchorSelector"), getAnchorSelector_fn = /* @__PURE__ */ __name(function() {
|
|
315
|
+
var _a, _b;
|
|
316
|
+
const fromAttr = ((_a = this.getAttribute("anchor")) == null ? void 0 : _a.trim()) || ((_b = this.getAttribute("data-popover-anchor")) == null ? void 0 : _b.trim()), fromCssRaw = __privateGet(this, _anchor).currentRawValue.trim(), fromCssParsed = typeof __privateGet(this, _anchor).current == "string" ? __privateGet(this, _anchor).current.trim() : "";
|
|
317
|
+
return __privateMethod(this, _PopoverElement_instances, normalizeAnchorSelector_fn).call(this, fromAttr || fromCssRaw || fromCssParsed || "") || null;
|
|
318
|
+
}, "#getAnchorSelector"), resolveAnchorHost_fn = /* @__PURE__ */ __name(function(selector) {
|
|
319
|
+
switch (selector.toLowerCase()) {
|
|
320
|
+
case "body":
|
|
321
|
+
return document.body;
|
|
322
|
+
case "html":
|
|
323
|
+
case "documentelement":
|
|
324
|
+
return document.documentElement;
|
|
325
|
+
default:
|
|
326
|
+
return null;
|
|
327
|
+
}
|
|
328
|
+
}, "#resolveAnchorHost"), resolveAnchorElement_fn = /* @__PURE__ */ __name(function() {
|
|
329
|
+
const selector = __privateMethod(this, _PopoverElement_instances, getAnchorSelector_fn).call(this);
|
|
330
|
+
if (!selector)
|
|
331
|
+
return null;
|
|
332
|
+
const host = __privateMethod(this, _PopoverElement_instances, resolveAnchorHost_fn).call(this, selector);
|
|
333
|
+
if (host)
|
|
334
|
+
return host;
|
|
335
|
+
const root = this.getRootNode(), anchor = __privateMethod(this, _PopoverElement_instances, queryAnchorIn_fn).call(this, document, selector) || (root instanceof Document || root instanceof ShadowRoot ? __privateMethod(this, _PopoverElement_instances, queryAnchorIn_fn).call(this, root, selector) : null);
|
|
336
|
+
return anchor || console.warn(this, `anchor target "${selector}" not found`), anchor;
|
|
337
|
+
}, "#resolveAnchorElement"), moveToAnchor_fn = /* @__PURE__ */ __name(function() {
|
|
338
|
+
const anchor = __privateMethod(this, _PopoverElement_instances, resolveAnchorElement_fn).call(this);
|
|
339
|
+
if (!(!anchor || anchor === this.parentElement) && this.isConnected) {
|
|
340
|
+
if (!__privateGet(this, _anchorPlaceholder)) {
|
|
341
|
+
__privateSet(this, _anchorPlaceholder, document.createComment("e-popover-anchor"));
|
|
342
|
+
const parent = this.parentNode;
|
|
343
|
+
parent && parent.insertBefore(__privateGet(this, _anchorPlaceholder), this.nextSibling);
|
|
344
|
+
}
|
|
345
|
+
__privateSet(this, _isAnchorDomMutation, !0);
|
|
346
|
+
try {
|
|
347
|
+
anchor.appendChild(this);
|
|
348
|
+
} finally {
|
|
349
|
+
__privateSet(this, _isAnchorDomMutation, !1);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}, "#moveToAnchor"), restoreFromAnchor_fn = /* @__PURE__ */ __name(function() {
|
|
353
|
+
var _a;
|
|
354
|
+
const placeholderParent = (_a = __privateGet(this, _anchorPlaceholder)) == null ? void 0 : _a.parentNode;
|
|
355
|
+
if (placeholderParent) {
|
|
356
|
+
__privateSet(this, _isAnchorDomMutation, !0);
|
|
357
|
+
try {
|
|
358
|
+
placeholderParent.insertBefore(this, __privateGet(this, _anchorPlaceholder)), __privateGet(this, _anchorPlaceholder).remove(), __privateSet(this, _anchorPlaceholder, null);
|
|
359
|
+
} finally {
|
|
360
|
+
__privateSet(this, _isAnchorDomMutation, !1);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}, "#restoreFromAnchor"), cleanupAnchorPlaceholder_fn = /* @__PURE__ */ __name(function() {
|
|
364
|
+
var _a;
|
|
365
|
+
(_a = __privateGet(this, _anchorPlaceholder)) == null || _a.remove(), __privateSet(this, _anchorPlaceholder, null);
|
|
366
|
+
}, "#cleanupAnchorPlaceholder"), __name(_PopoverElement, "PopoverElement"), _PopoverElement.stack = new PopoverGroups(), _PopoverElement.popoverHistoryTransactionsDepth = 0;
|
|
301
367
|
let PopoverElement = _PopoverElement;
|
|
302
368
|
isBrowser && !customElements.get("e-popover") && customElements.define("e-popover", PopoverElement);
|
|
303
369
|
var _popoverElement, _type, _PopoverButtonElement_instances, unlistenPopover_fn, _popoverTriggeredListener, _popoverOpenedListener, _popoverClosingListener, _popoverClosedListener, updateType_fn;
|