UNPKG

@arcgis/map-components

Version:
3 lines (2 loc) 6.02 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */ import{h as w}from"./AKBXFBDL.js";import"./LMBRORN7.js";import"./PBSJQPB2.js";import{O as f,Q as u,U as _,a as d,b as m}from"./WUJCCZQC.js";import"./3TTFCHAA.js";var x=d`:host{display:block;pointer-events:initial}calcite-popover{pointer-events:initial}.content{min-inline-size:min(calc(100cqw - var(--arcgis-view-popover-width-reserve, 32px)),var(--arcgis-view-popover-min-inline-size, 300px));max-inline-size:min(calc(100cqw - var(--arcgis-view-popover-width-reserve, 32px)),var(--arcgis-view-popover-max-inline-size, 400px));max-height:var( --arcgis-view-popover-content-max-height, calc(100cqh - var(--arcgis-view-popover-height-reserve, 77px)) );-webkit-user-select:none;user-select:none;overflow-y:auto}`,h=6,y=2,A=32,S=77,B=0;function z(t){let e=C(t),i=t.actionBarLayout==="vertical"?0:e;return{effectiveTailOffset:e,horizontalMargin:$(t),verticalMargin:P(t)+i+t.headerRect.height,offsetSkidding:O(t),placement:L(t)}}function C({actionBarLayout:t,actionRect:e,barRect:i,tailAttachmentAppearance:a}){let n=a==="bar"?t==="vertical"?Math.max(0,e.left-i.left):Math.max(0,e.top-i.top):0;return h+n}function $({actionBarLayout:t,barRect:{left:e,right:i},actionRect:{left:a},tailAttachmentAppearance:n,viewEdgeMargin:r}){let s=r*2;if(t==="vertical"){let l=i-e,v=n==="action"?-(a-e-h):h;return s+l+v}return s}function O(t){return t.actionBarLayout==="vertical"||b(t)==="left"?t.viewEdgeMargin:-t.viewEdgeMargin}function L(t){let{actionBarLayout:e,actionRect:i,viewRect:a}=t,n=b(t);if(e==="vertical")return n==="left"?"right-end":"left-end";let r=i.bottom-a.top<a.height/2?"bottom":"top";return n==="left"?`${r}-end`:`${r}-start`}function b({barRect:{left:t,right:e},viewRect:{left:i,right:a}}){return t-i<a-e?"left":"right"}function k({actionRect:t,viewRect:e}){return t.top-e.top>e.height/2?"bottom":"top"}function P(t){let{actionBarLayout:e,actionRect:i,attributionHeight:a,viewEdgeMargin:n,viewRect:r}=t,s=k(t),l=i.bottom-r.top,v=i.top-r.top,E=s==="top"?l:n,R=n,g=a+n,M=s==="top"?g:r.height-v;return(e==="vertical"?R+g:E+M)+y}function o(){return new DOMRect(0,0,0,0)}function c(t){return t?.getBoundingClientRect()??o()}var p=class extends f{constructor(){super(...arguments),this._handlePopoverBeforeOpen=e=>{if(e.target!==e.currentTarget)return;let i=e.currentTarget;this._headerElement=i.shadowRoot?.querySelector(".header")??void 0,this._observeMeasurementElements(),this._remeasureAndSolve()},this._handlePopoverClose=e=>{e.target===e.currentTarget&&(e.preventDefault(),this.open=!1,this._stopMeasuring())},this._viewRect=o(),this._barRect=o(),this._actionRect=o(),this._headerRect=o(),this._resizeObserver=new ResizeObserver(()=>this._remeasureAndSolve()),this._placement="bottom-end",this._effectiveTailOffset=h,this._offsetSkidding=B,this._horizontalMargin=A,this._verticalMargin=S,this.closable=!0,this.open=!1,this.maxContentWidth=400,this.minContentWidth=300,this.viewEdgeMargin=16,this.visualScale="m",this.tailAttachmentAppearance="bar",this.arcgisPropertyChange=w()("open")}static{this.properties={_placement:16,_effectiveTailOffset:16,_offsetSkidding:16,_horizontalMargin:16,_verticalMargin:16,view:0,actionBarLayout:32,actionBarElement:0,anchorElement:0,closable:5,heading:1,label:1,open:5,maxContentWidth:9,minContentWidth:9,viewEdgeMargin:9,visualScale:1,tailAttachmentAppearance:1}}static{this.styles=x}get _viewElement(){return this.view?.container??void 0}get actionBarLayout(){return this.actionBarElement?.layout==="vertical"?"vertical":"horizontal"}willUpdate(e){e.has("open")&&!this.open?this._stopMeasuring():this.open&&this._hasParameterInputChange(e)?this._remeasureAndSolve():this.open&&this._hasObservedElementChange(e)&&this._observeMeasurementElements()}disconnectedCallback(){super.disconnectedCallback(),this._stopMeasuring()}_hasObservedElementChange(e){return e.has("actionBarElement")||e.has("anchorElement")||e.has("view")}_hasParameterInputChange(e){return e.has("open")&&this.open||e.has("tailAttachmentAppearance")||e.has("viewEdgeMargin")||e.has("visualScale")}_observeMeasurementElements(){this._resizeObserver.disconnect();for(let e of[this.anchorElement,this.actionBarElement,this._viewElement,this._headerElement])e&&this._resizeObserver.observe(e);this._remeasureAndSolve()}_stopMeasuring(){this._resizeObserver.disconnect(),this._headerElement=void 0}_remeasureAndSolve(){this._actionRect=c(this.anchorElement),this._barRect=c(this.actionBarElement),this._headerRect=c(this._headerElement),this._viewRect=c(this._viewElement),this._solveLayoutAndUpdate()}_solveLayoutAndUpdate(){let{effectiveTailOffset:e,horizontalMargin:i,verticalMargin:a,offsetSkidding:n,placement:r}=z({actionBarLayout:this.actionBarLayout,actionRect:this._actionRect,attributionHeight:this.view?.attributionHeight??0,barRect:this._barRect,headerRect:this._headerRect,visualScale:this.visualScale,tailAttachmentAppearance:this.tailAttachmentAppearance,viewEdgeMargin:this.viewEdgeMargin,viewRect:this._viewRect});this._effectiveTailOffset=e,this._horizontalMargin=i,this._verticalMargin=a,this._offsetSkidding=n,this._placement=r}render(){return this.anchorElement?m`<calcite-popover .closable=${this.closable} .heading=${this.heading} .label=${this.label??""} .open=${this.open} .offsetDistance=${this._effectiveTailOffset} .offsetSkidding=${this._offsetSkidding} overlay-positioning=fixed flip-disabled .placement=${this._placement} .referenceElement=${this.anchorElement} @calcitePopoverBeforeOpen=${this._handlePopoverBeforeOpen} .scale=${this.visualScale} style=${u({"--arcgis-view-popover-max-inline-size":`${this.maxContentWidth}px`,"--arcgis-view-popover-min-inline-size":`${this.minContentWidth}px`,"--arcgis-view-popover-height-reserve":`${this._verticalMargin}px`,"--arcgis-view-popover-width-reserve":`${this._horizontalMargin}px`})} trigger-disabled @calcitePopoverClose=${this._handlePopoverClose}><div class="content"><slot></slot></div></calcite-popover>`:null}};_("arcgis-view-popover",p);export{p as ArcgisViewPopover};