aptechka 0.97.3 → 0.97.4
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.
|
@@ -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);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const cssValueParser_index=require("../css-value-parser/index.cjs"),order_index=require("../order/index.cjs"),Store=require("../Store-BP8tuWzQ.cjs"),dom=require("../dom-B40i6NXw.cjs");require("construct-style-sheets-polyfill");require("../index-BrasTsja.cjs");const windowResizer_index=require("../window-resizer/index.cjs");var _element,_property,_currentRawValue,_rawValueCheck,_active,_resizeListener;const _CSSProperty=class _CSSProperty extends Store.Store{constructor(elementOrSelector,property,defaultValue,options){super(defaultValue,options);__privateAdd(this,_element);__privateAdd(this,_property);__privateAdd(this,_currentRawValue);__privateAdd(this,_rawValueCheck);__privateAdd(this,_active,!1);__privateAdd(this,_resizeListener,__name(()=>{this.check()},"#resizeListener"));__privateSet(this,_element,dom.getElement(elementOrSelector)),__privateSet(this,_property,property),__privateSet(this,_currentRawValue,defaultValue.toString()),__privateSet(this,_rawValueCheck,(options==null?void 0:options.rawValueCheck)!==!1)}get currentRawValue(){return __privateGet(this,_currentRawValue)}observe(){__privateGet(this,_active)||(__privateSet(this,_active,!0),__privateGet(this,_resizeListener).call(this),windowResizer_index.windowResizer.subscribe(__privateGet(this,_resizeListener),order_index.RESIZE_ORDER.CSS_VARIABLE))}unobserve(){__privateGet(this,_active)&&(__privateSet(this,_active,!1),windowResizer_index.windowResizer.unsubscribe(__privateGet(this,_resizeListener)))}subscribe(callback,order){return this.subscribers.length||this.observe(),super.subscribe(callback,order)}unsubscribe(callback){super.unsubscribe(callback),this.subscribers.length||this.unobserve()}close(){this.unobserve(),super.close()}check(){const rawValue=getComputedStyle(__privateGet(this,_element)).getPropertyValue(__privateGet(this,_property)).trim()
|
|
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);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const cssValueParser_index=require("../css-value-parser/index.cjs"),order_index=require("../order/index.cjs"),Store=require("../Store-BP8tuWzQ.cjs"),dom=require("../dom-B40i6NXw.cjs");require("construct-style-sheets-polyfill");require("../index-BrasTsja.cjs");const windowResizer_index=require("../window-resizer/index.cjs");var _element,_property,_currentRawValue,_rawValueCheck,_active,_resizeListener;const _CSSProperty=class _CSSProperty extends Store.Store{constructor(elementOrSelector,property,defaultValue,options){super(defaultValue,options);__privateAdd(this,_element);__privateAdd(this,_property);__privateAdd(this,_currentRawValue);__privateAdd(this,_rawValueCheck);__privateAdd(this,_active,!1);__privateAdd(this,_resizeListener,__name(()=>{this.check()},"#resizeListener"));__privateSet(this,_element,dom.getElement(elementOrSelector)),__privateSet(this,_property,property),__privateSet(this,_currentRawValue,defaultValue.toString()),__privateSet(this,_rawValueCheck,(options==null?void 0:options.rawValueCheck)!==!1)}get currentRawValue(){return __privateGet(this,_currentRawValue)}observe(){__privateGet(this,_active)||(__privateSet(this,_active,!0),__privateGet(this,_resizeListener).call(this),windowResizer_index.windowResizer.subscribe(__privateGet(this,_resizeListener),order_index.RESIZE_ORDER.CSS_VARIABLE))}unobserve(){__privateGet(this,_active)&&(__privateSet(this,_active,!1),windowResizer_index.windowResizer.unsubscribe(__privateGet(this,_resizeListener)))}subscribe(callback,order){return this.subscribers.length||this.observe(),super.subscribe(callback,order)}unsubscribe(callback){super.unsubscribe(callback),this.subscribers.length||this.unobserve()}close(){this.unobserve(),super.close(),__privateSet(this,_currentRawValue,this.initial.toString())}check(){const rawValue=getComputedStyle(__privateGet(this,_element)).getPropertyValue(__privateGet(this,_property)).trim(),nextValue=rawValue?cssValueParser_index.cssValueParser.parse(rawValue,__privateGet(this,_element)):this.initial;__privateGet(this,_rawValueCheck)&&__privateGet(this,_currentRawValue)===rawValue&&this.current===nextValue||(__privateSet(this,_currentRawValue,rawValue),this.current=nextValue)}};_element=new WeakMap,_property=new WeakMap,_currentRawValue=new WeakMap,_rawValueCheck=new WeakMap,_active=new WeakMap,_resizeListener=new WeakMap,__name(_CSSProperty,"CSSProperty");let CSSProperty=_CSSProperty;exports.CSSProperty=CSSProperty;
|
|
@@ -42,16 +42,11 @@ const _CSSProperty = class _CSSProperty extends Store {
|
|
|
42
42
|
super.unsubscribe(callback), this.subscribers.length || this.unobserve();
|
|
43
43
|
}
|
|
44
44
|
close() {
|
|
45
|
-
this.unobserve(), super.close();
|
|
45
|
+
this.unobserve(), super.close(), __privateSet(this, _currentRawValue, this.initial.toString());
|
|
46
46
|
}
|
|
47
47
|
check() {
|
|
48
|
-
const rawValue = getComputedStyle(__privateGet(this, _element)).getPropertyValue(__privateGet(this, _property)).trim();
|
|
49
|
-
|
|
50
|
-
if (__privateSet(this, _currentRawValue, rawValue), rawValue) {
|
|
51
|
-
const result = cssValueParser.parse(__privateGet(this, _currentRawValue), __privateGet(this, _element));
|
|
52
|
-
this.current = result;
|
|
53
|
-
} else
|
|
54
|
-
this.current = this.initial;
|
|
48
|
+
const rawValue = getComputedStyle(__privateGet(this, _element)).getPropertyValue(__privateGet(this, _property)).trim(), nextValue = rawValue ? cssValueParser.parse(rawValue, __privateGet(this, _element)) : this.initial;
|
|
49
|
+
__privateGet(this, _rawValueCheck) && __privateGet(this, _currentRawValue) === rawValue && this.current === nextValue || (__privateSet(this, _currentRawValue, rawValue), this.current = nextValue);
|
|
55
50
|
}
|
|
56
51
|
};
|
|
57
52
|
_element = new WeakMap(), _property = new WeakMap(), _currentRawValue = new WeakMap(), _rawValueCheck = new WeakMap(), _active = new WeakMap(), _resizeListener = new WeakMap(), __name(_CSSProperty, "CSSProperty");
|
|
@@ -31,6 +31,8 @@ export declare class PopoverElement extends HTMLElement {
|
|
|
31
31
|
get lastTrigger(): any;
|
|
32
32
|
get idWithValue(): string;
|
|
33
33
|
updateUrlValue(value?: string | number): void;
|
|
34
|
+
static resetAllForNavigation(): void;
|
|
35
|
+
resetForNavigation(): void;
|
|
34
36
|
open(options?: {
|
|
35
37
|
skipTransition?: boolean;
|
|
36
38
|
trigger?: any;
|
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,_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;
|
|
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,_resetAll,_clickOutsideListener,_keydownListener;const _PopoverGroups=class _PopoverGroups{constructor(){__privateAdd(this,_groups,new Map);__privateAdd(this,_stack,[]);__privateAdd(this,_resetAll,__name(()=>{this.resetAll()},"#resetAll"));__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)),document.addEventListener("astro:before-preparation",__privateGet(this,_resetAll)),document.addEventListener("spaBeforeFetch",__privateGet(this,_resetAll))}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)}removeSync(groupName,element){__privateSet(this,_stack,__privateGet(this,_stack).filter(e=>e!==element));const group=__privateGet(this,_groups).get(groupName);if(group){const filtered=group.filter(el=>el!==element);filtered.length?__privateGet(this,_groups).set(groupName,filtered):__privateGet(this,_groups).delete(groupName)}}resetAll(){const popovers=new Set;__privateGet(this,_stack).forEach(popover=>popovers.add(popover)),__privateGet(this,_groups).forEach(group=>group.forEach(popover=>popovers.add(popover))),document.querySelectorAll("e-popover").forEach(element=>{element instanceof PopoverElement&&popovers.add(element)}),popovers.forEach(popover=>popover.resetForNavigation()),__privateSet(this,_stack,[]),__privateGet(this,_groups).clear()}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,_resetAll=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,_skipHistorySync,_PopoverElement_instances,path_get,toggleGlobalClass_fn,deleteSearchParam_fn,clearGroupDocumentClasses_fn,syncCssProperties_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,_skipHistorySync);__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,_skipHistorySync,!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)}static resetAllForNavigation(){_PopoverElement.stack.resetAll()}resetForNavigation(){__privateSet(this,_skipHistorySync,!0),cancelAnimationFrame(__privateGet(this,_openFrameId)),clearTimeout(__privateGet(this,_startClosingTimeoutId)),clearTimeout(__privateGet(this,_closeTimeoutId)),clearTimeout(__privateGet(this,_openTransitionTimeoutId)),__privateSet(this,_opened,!1),_PopoverElement.stack.removeSync(__privateGet(this,_group).current,this),__privateGet(this,_status).reset(),__privateMethod(this,_PopoverElement_instances,toggleGlobalClass_fn).call(this,!1,this.openClass),__privateMethod(this,_PopoverElement_instances,toggleGlobalClass_fn).call(this,!1,this.closingClass),__privateMethod(this,_PopoverElement_instances,clearGroupDocumentClasses_fn).call(this),__privateGet(this,_anchorPlaceholder)&&__privateMethod(this,_PopoverElement_instances,restoreFromAnchor_fn).call(this),__privateMethod(this,_PopoverElement_instances,syncCssProperties_fn).call(this),setTimeout(()=>{__privateSet(this,_skipHistorySync,!1)},0)}open(options){if(__privateGet(this,_opened))return;__privateMethod(this,_PopoverElement_instances,syncCssProperties_fn).call(this),__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&&!__privateGet(this,_skipHistorySync)&&(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(),__privateMethod(this,_PopoverElement_instances,syncCssProperties_fn).call(this),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,_skipHistorySync=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,_skipHistorySync)||!__privateGet(this,_history).current)return;const url2=new URL(location.href);url2.searchParams.delete(this.id),shared_index.historyManager.replaceState(url2.href)},"#deleteSearchParam"),clearGroupDocumentClasses_fn=__name(function(){new Set([__privateGet(this,_group).current,__privateGet(this,_group).previous].filter(Boolean)).forEach(group=>{document.documentElement.classList.remove(`${group}-closing`),document.documentElement.classList.remove(`${group}-opened`)})},"#clearGroupDocumentClasses"),syncCssProperties_fn=__name(function(){__privateGet(this,_history).check(),__privateGet(this,_restore).check(),__privateGet(this,_dispatchResize).check(),__privateGet(this,_closeRest).check(),__privateGet(this,_closeRestInGroup).check(),__privateGet(this,_group).check(),__privateGet(this,_clickOutside).check(),__privateGet(this,_escape).check(),__privateGet(this,_checkViewportBounds).check(),__privateGet(this,_anchor).check()},"#syncCssProperties"),_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
|
@@ -17,11 +17,14 @@ import "construct-style-sheets-polyfill";
|
|
|
17
17
|
import "../index-Z2Lgb7xU.js";
|
|
18
18
|
import { u as updateSearchParameter, p as parseSearchParameters } from "../url-bipuV3FR.js";
|
|
19
19
|
import { windowResizer } from "../window-resizer/index.js";
|
|
20
|
-
var _groups, _stack, _clickOutsideListener, _keydownListener;
|
|
20
|
+
var _groups, _stack, _resetAll, _clickOutsideListener, _keydownListener;
|
|
21
21
|
const _PopoverGroups = class _PopoverGroups {
|
|
22
22
|
constructor() {
|
|
23
23
|
__privateAdd(this, _groups, /* @__PURE__ */ new Map());
|
|
24
24
|
__privateAdd(this, _stack, []);
|
|
25
|
+
__privateAdd(this, _resetAll, /* @__PURE__ */ __name(() => {
|
|
26
|
+
this.resetAll();
|
|
27
|
+
}, "#resetAll"));
|
|
25
28
|
__privateAdd(this, _clickOutsideListener, /* @__PURE__ */ __name((e) => {
|
|
26
29
|
var _a;
|
|
27
30
|
const lastPopover = [...__privateGet(this, _stack)].reverse().find((el) => el.clickOutside.current);
|
|
@@ -44,7 +47,7 @@ const _PopoverGroups = class _PopoverGroups {
|
|
|
44
47
|
document.documentElement.addEventListener(
|
|
45
48
|
"click",
|
|
46
49
|
__privateGet(this, _clickOutsideListener)
|
|
47
|
-
), addEventListener("keydown", __privateGet(this, _keydownListener));
|
|
50
|
+
), addEventListener("keydown", __privateGet(this, _keydownListener)), document.addEventListener("astro:before-preparation", __privateGet(this, _resetAll)), document.addEventListener("spaBeforeFetch", __privateGet(this, _resetAll));
|
|
48
51
|
}
|
|
49
52
|
get groups() {
|
|
50
53
|
return __privateGet(this, _groups);
|
|
@@ -68,6 +71,22 @@ const _PopoverGroups = class _PopoverGroups {
|
|
|
68
71
|
let group = __privateGet(this, _groups).get(groupName);
|
|
69
72
|
group != null && group.length || (group = [], __privateGet(this, _groups).set(groupName, group)), __privateGet(this, _stack).push(element), group.push(element);
|
|
70
73
|
}
|
|
74
|
+
removeSync(groupName, element) {
|
|
75
|
+
__privateSet(this, _stack, __privateGet(this, _stack).filter((e) => e !== element));
|
|
76
|
+
const group = __privateGet(this, _groups).get(groupName);
|
|
77
|
+
if (group) {
|
|
78
|
+
const filtered = group.filter((el) => el !== element);
|
|
79
|
+
filtered.length ? __privateGet(this, _groups).set(groupName, filtered) : __privateGet(this, _groups).delete(groupName);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
resetAll() {
|
|
83
|
+
const popovers = /* @__PURE__ */ new Set();
|
|
84
|
+
__privateGet(this, _stack).forEach((popover) => popovers.add(popover)), __privateGet(this, _groups).forEach(
|
|
85
|
+
(group) => group.forEach((popover) => popovers.add(popover))
|
|
86
|
+
), document.querySelectorAll("e-popover").forEach((element) => {
|
|
87
|
+
element instanceof PopoverElement && popovers.add(element);
|
|
88
|
+
}), popovers.forEach((popover) => popover.resetForNavigation()), __privateSet(this, _stack, []), __privateGet(this, _groups).clear();
|
|
89
|
+
}
|
|
71
90
|
remove(groupName, element) {
|
|
72
91
|
if (setTimeout(() => {
|
|
73
92
|
__privateSet(this, _stack, __privateGet(this, _stack).filter((e) => e !== element));
|
|
@@ -87,9 +106,9 @@ const _PopoverGroups = class _PopoverGroups {
|
|
|
87
106
|
}
|
|
88
107
|
}
|
|
89
108
|
};
|
|
90
|
-
_groups = new WeakMap(), _stack = new WeakMap(), _clickOutsideListener = new WeakMap(), _keydownListener = new WeakMap(), __name(_PopoverGroups, "PopoverGroups");
|
|
109
|
+
_groups = new WeakMap(), _stack = new WeakMap(), _resetAll = new WeakMap(), _clickOutsideListener = new WeakMap(), _keydownListener = new WeakMap(), __name(_PopoverGroups, "PopoverGroups");
|
|
91
110
|
let PopoverGroups = _PopoverGroups;
|
|
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;
|
|
111
|
+
var _opened, _startClosingTimeoutId, _closeTimeoutId, _openFrameId, _openTransitionTimeoutId, _history, _restore, _dispatchResize, _closeRest, _closeRestInGroup, _group, _clickOutside, _escape, _checkViewportBounds, _anchor, _lastTrigger, _status, _innerCloseElements, _resetScrollElements, _isFromPopState, _anchorPlaceholder, _isAnchorDomMutation, _skipHistorySync, _PopoverElement_instances, path_get, toggleGlobalClass_fn, deleteSearchParam_fn, clearGroupDocumentClasses_fn, syncCssProperties_fn, _popStateListener, _resizeListener, _debouncedResize, _resize, _closeElementClickListener, queryAnchorIn_fn, normalizeAnchorSelector_fn, getAnchorSelector_fn, resolveAnchorHost_fn, resolveAnchorElement_fn, moveToAnchor_fn, restoreFromAnchor_fn, cleanupAnchorPlaceholder_fn;
|
|
93
112
|
const _PopoverElement = class _PopoverElement extends HTMLElement {
|
|
94
113
|
constructor() {
|
|
95
114
|
super();
|
|
@@ -116,6 +135,7 @@ const _PopoverElement = class _PopoverElement extends HTMLElement {
|
|
|
116
135
|
__privateAdd(this, _isFromPopState);
|
|
117
136
|
__privateAdd(this, _anchorPlaceholder);
|
|
118
137
|
__privateAdd(this, _isAnchorDomMutation);
|
|
138
|
+
__privateAdd(this, _skipHistorySync);
|
|
119
139
|
__privateAdd(this, _popStateListener);
|
|
120
140
|
__privateAdd(this, _resizeListener);
|
|
121
141
|
__privateAdd(this, _debouncedResize);
|
|
@@ -131,7 +151,7 @@ const _PopoverElement = class _PopoverElement extends HTMLElement {
|
|
|
131
151
|
opened: !1,
|
|
132
152
|
closing: !1,
|
|
133
153
|
transitionend: !1
|
|
134
|
-
})), __privateSet(this, _innerCloseElements, []), __privateSet(this, _resetScrollElements, []), __privateSet(this, _isFromPopState, !1), __privateSet(this, _anchorPlaceholder, null), __privateSet(this, _isAnchorDomMutation, !1), __privateSet(this, _popStateListener, () => {
|
|
154
|
+
})), __privateSet(this, _innerCloseElements, []), __privateSet(this, _resetScrollElements, []), __privateSet(this, _isFromPopState, !1), __privateSet(this, _anchorPlaceholder, null), __privateSet(this, _isAnchorDomMutation, !1), __privateSet(this, _skipHistorySync, !1), __privateSet(this, _popStateListener, () => {
|
|
135
155
|
_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(() => {
|
|
136
156
|
__privateSet(this, _isFromPopState, !1);
|
|
137
157
|
}, 0));
|
|
@@ -212,10 +232,18 @@ const _PopoverElement = class _PopoverElement extends HTMLElement {
|
|
|
212
232
|
updateUrlValue(value) {
|
|
213
233
|
this.urlValue = (value == null ? void 0 : value.toString()) || "", __privateGet(this, _opened) && updateSearchParameter(this.id, value);
|
|
214
234
|
}
|
|
235
|
+
static resetAllForNavigation() {
|
|
236
|
+
_PopoverElement.stack.resetAll();
|
|
237
|
+
}
|
|
238
|
+
resetForNavigation() {
|
|
239
|
+
__privateSet(this, _skipHistorySync, !0), cancelAnimationFrame(__privateGet(this, _openFrameId)), clearTimeout(__privateGet(this, _startClosingTimeoutId)), clearTimeout(__privateGet(this, _closeTimeoutId)), clearTimeout(__privateGet(this, _openTransitionTimeoutId)), __privateSet(this, _opened, !1), _PopoverElement.stack.removeSync(__privateGet(this, _group).current, this), __privateGet(this, _status).reset(), __privateMethod(this, _PopoverElement_instances, toggleGlobalClass_fn).call(this, !1, this.openClass), __privateMethod(this, _PopoverElement_instances, toggleGlobalClass_fn).call(this, !1, this.closingClass), __privateMethod(this, _PopoverElement_instances, clearGroupDocumentClasses_fn).call(this), __privateGet(this, _anchorPlaceholder) && __privateMethod(this, _PopoverElement_instances, restoreFromAnchor_fn).call(this), __privateMethod(this, _PopoverElement_instances, syncCssProperties_fn).call(this), setTimeout(() => {
|
|
240
|
+
__privateSet(this, _skipHistorySync, !1);
|
|
241
|
+
}, 0);
|
|
242
|
+
}
|
|
215
243
|
open(options) {
|
|
216
244
|
if (__privateGet(this, _opened))
|
|
217
245
|
return;
|
|
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", {
|
|
246
|
+
__privateMethod(this, _PopoverElement_instances, syncCssProperties_fn).call(this), __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", {
|
|
219
247
|
custom: !0,
|
|
220
248
|
detail: {
|
|
221
249
|
trigger: __privateGet(this, _lastTrigger)
|
|
@@ -244,7 +272,7 @@ const _PopoverElement = class _PopoverElement extends HTMLElement {
|
|
|
244
272
|
options != null && options.skipTransition ? opened() : __privateSet(this, _openFrameId, requestAnimationFrame(opened));
|
|
245
273
|
}
|
|
246
274
|
close(back) {
|
|
247
|
-
__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 ? historyManager.back() : __privateMethod(this, _PopoverElement_instances, deleteSearchParam_fn).call(this), this.endHistoryTransaction()), __privateSet(this, _startClosingTimeoutId, setTimeout(() => {
|
|
275
|
+
__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 && !__privateGet(this, _skipHistorySync) && (this.beginHistoryTransaction(), back ? historyManager.back() : __privateMethod(this, _PopoverElement_instances, deleteSearchParam_fn).call(this), this.endHistoryTransaction()), __privateSet(this, _startClosingTimeoutId, setTimeout(() => {
|
|
248
276
|
__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), dispatchEvent(this, "popoverClosing", {
|
|
249
277
|
custom: !0,
|
|
250
278
|
bubbles: !0
|
|
@@ -278,7 +306,7 @@ const _PopoverElement = class _PopoverElement extends HTMLElement {
|
|
|
278
306
|
...this.querySelectorAll(
|
|
279
307
|
`[data-popover-reset-scroll${this.id ? `="${this.id}"` : ""}]`
|
|
280
308
|
)
|
|
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(() => {
|
|
309
|
+
]), __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(), __privateMethod(this, _PopoverElement_instances, syncCssProperties_fn).call(this), this.setAttribute("role", "dialog"), historyManager.addPopStateHandler(__privateGet(this, _popStateListener), !0), setTimeout(() => {
|
|
282
310
|
__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(() => {
|
|
283
311
|
__privateSet(this, _isFromPopState, !1);
|
|
284
312
|
}, 0);
|
|
@@ -292,18 +320,26 @@ const _PopoverElement = class _PopoverElement extends HTMLElement {
|
|
|
292
320
|
}), _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));
|
|
293
321
|
}
|
|
294
322
|
};
|
|
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() {
|
|
323
|
+
_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(), _skipHistorySync = new WeakMap(), _PopoverElement_instances = new WeakSet(), path_get = /* @__PURE__ */ __name(function() {
|
|
296
324
|
return `${location.pathname}${location.search ? location.search + "&" : "?"}${this.idWithValue}`;
|
|
297
325
|
}, "#path"), toggleGlobalClass_fn = /* @__PURE__ */ __name(function(on, className) {
|
|
298
326
|
className && className.split(" ").map((v) => {
|
|
299
327
|
document.documentElement.classList.toggle(v.trim(), on);
|
|
300
328
|
});
|
|
301
329
|
}, "#toggleGlobalClass"), deleteSearchParam_fn = /* @__PURE__ */ __name(function() {
|
|
302
|
-
if (__privateGet(this, _history).current)
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
}, "#deleteSearchParam"),
|
|
330
|
+
if (__privateGet(this, _skipHistorySync) || !__privateGet(this, _history).current)
|
|
331
|
+
return;
|
|
332
|
+
const url = new URL(location.href);
|
|
333
|
+
url.searchParams.delete(this.id), historyManager.replaceState(url.href);
|
|
334
|
+
}, "#deleteSearchParam"), clearGroupDocumentClasses_fn = /* @__PURE__ */ __name(function() {
|
|
335
|
+
new Set(
|
|
336
|
+
[__privateGet(this, _group).current, __privateGet(this, _group).previous].filter(Boolean)
|
|
337
|
+
).forEach((group) => {
|
|
338
|
+
document.documentElement.classList.remove(`${group}-closing`), document.documentElement.classList.remove(`${group}-opened`);
|
|
339
|
+
});
|
|
340
|
+
}, "#clearGroupDocumentClasses"), syncCssProperties_fn = /* @__PURE__ */ __name(function() {
|
|
341
|
+
__privateGet(this, _history).check(), __privateGet(this, _restore).check(), __privateGet(this, _dispatchResize).check(), __privateGet(this, _closeRest).check(), __privateGet(this, _closeRestInGroup).check(), __privateGet(this, _group).check(), __privateGet(this, _clickOutside).check(), __privateGet(this, _escape).check(), __privateGet(this, _checkViewportBounds).check(), __privateGet(this, _anchor).check();
|
|
342
|
+
}, "#syncCssProperties"), _popStateListener = new WeakMap(), _resizeListener = new WeakMap(), _debouncedResize = new WeakMap(), _resize = new WeakMap(), _closeElementClickListener = new WeakMap(), queryAnchorIn_fn = /* @__PURE__ */ __name(function(root, selector) {
|
|
307
343
|
if (!("querySelector" in root))
|
|
308
344
|
return null;
|
|
309
345
|
let anchor = root.querySelector(selector);
|