UNPKG

@esri/calcite-components

Version:

Web Components for Esri's Calcite Design System.

1 lines • 18.2 kB
import{g as t}from"./p-fbd3d700.js";var e="top",n="bottom",r="right",o="left",i=[e,n,r,o],a=i.reduce((function(t,e){return t.concat([e+"-start",e+"-end"])}),[]),u=[].concat(i,["auto"]).reduce((function(t,e){return t.concat([e,e+"-start",e+"-end"])}),[]),f=["beforeRead","read","afterRead","beforeMain","main","afterMain","beforeWrite","write","afterWrite"];function c(t){return t?(t.nodeName||"").toLowerCase():null}function p(t){if("[object Window]"!==t.toString()){var e=t.ownerDocument;return e&&e.defaultView||window}return t}function s(t){return t instanceof p(t).Element||t instanceof Element}function d(t){return t instanceof p(t).HTMLElement||t instanceof HTMLElement}function l(t){return t.split("-")[0]}function v(t){return{x:t.offsetLeft,y:t.offsetTop,width:t.offsetWidth,height:t.offsetHeight}}function b(t,e){var n,r=e.getRootNode&&e.getRootNode();if(t.contains(e))return!0;if(r&&((n=r)instanceof p(n).ShadowRoot||n instanceof ShadowRoot)){var o=e;do{if(o&&t.isSameNode(o))return!0;o=o.parentNode||o.host}while(o)}return!1}function h(t){return p(t).getComputedStyle(t)}function m(t){return["table","td","th"].indexOf(c(t))>=0}function y(t){return((s(t)?t.ownerDocument:t.document)||window.document).documentElement}function O(t){return"html"===c(t)?t:t.assignedSlot||t.parentNode||t.host||y(t)}function j(t){if(!d(t)||"fixed"===h(t).position)return null;var e=t.offsetParent;if(e){var n=y(e);if("body"===c(e)&&"static"===h(e).position&&"static"!==h(n).position)return n}return e}function g(t){for(var e=p(t),n=j(t);n&&m(n)&&"static"===h(n).position;)n=j(n);return n&&"body"===c(n)&&"static"===h(n).position?e:n||function(t){for(var e=O(t);d(e)&&["html","body"].indexOf(c(e))<0;){var n=h(e);if("none"!==n.transform||"none"!==n.perspective||n.willChange&&"auto"!==n.willChange)return e;e=e.parentNode}return null}(t)||e}function w(t){return["top","bottom"].indexOf(t)>=0?"x":"y"}function x(t,e,n){return Math.max(t,Math.min(e,n))}function M(t){return Object.assign(Object.assign({},{top:0,right:0,bottom:0,left:0}),t)}function k(t,e){return e.reduce((function(e,n){return e[n]=t,e}),{})}var E={top:"auto",right:"auto",bottom:"auto",left:"auto"};function q(t){var i,a=t.popper,u=t.popperRect,f=t.placement,c=t.offsets,s=t.position,d=t.gpuAcceleration,l=t.adaptive,v=t.roundOffsets?function(t){var e=t.y,n=window.devicePixelRatio||1;return{x:Math.round(t.x*n)/n||0,y:Math.round(e*n)/n||0}}(c):c,b=v.x,h=void 0===b?0:b,m=v.y,O=void 0===m?0:m,j=c.hasOwnProperty("x"),w=c.hasOwnProperty("y"),x=o,M=e,k=window;if(l){var q=g(a);q===p(a)&&(q=y(a)),f===e&&(M=n,O-=q.clientHeight-u.height,O*=d?1:-1),f===o&&(x=r,h-=q.clientWidth-u.width,h*=d?1:-1)}var B,P=Object.assign({position:s},l&&E);return Object.assign(Object.assign({},P),{},d?((B={})[M]=w?"0":"",B[x]=j?"0":"",B.transform=(k.devicePixelRatio||1)<2?"translate("+h+"px, "+O+"px)":"translate3d("+h+"px, "+O+"px, 0)",B):((i={})[M]=w?O+"px":"",i[x]=j?h+"px":"",i.transform="",i))}var B={passive:!0},P={left:"right",right:"left",bottom:"top",top:"bottom"};function L(t){return t.replace(/left|right|bottom|top/g,(function(t){return P[t]}))}var R={start:"end",end:"start"};function S(t){return t.replace(/start|end/g,(function(t){return R[t]}))}function A(t){var e=t.getBoundingClientRect();return{width:e.width,height:e.height,top:e.top,right:e.right,bottom:e.bottom,left:e.left,x:e.left,y:e.top}}function I(t){var e=p(t);return{scrollLeft:e.pageXOffset,scrollTop:e.pageYOffset}}function T(t){return A(y(t)).left+I(t).scrollLeft}function W(t){var e=h(t);return/auto|scroll|overlay|hidden/.test(e.overflow+e.overflowY+e.overflowX)}function C(t){return["html","body","#document"].indexOf(c(t))>=0?t.ownerDocument.body:d(t)&&W(t)?t:C(O(t))}function z(t,e){void 0===e&&(e=[]);var n=C(t),r="body"===c(n),o=p(n),i=r?[o].concat(o.visualViewport||[],W(n)?n:[]):n,a=e.concat(i);return r?a:a.concat(z(O(i)))}function H(t){return Object.assign(Object.assign({},t),{},{left:t.x,top:t.y,right:t.x+t.width,bottom:t.y+t.height})}function D(t,e){return"viewport"===e?H(function(t){var e=p(t),n=y(t),r=e.visualViewport,o=n.clientWidth,i=n.clientHeight,a=0,u=0;return r&&(o=r.width,i=r.height,/^((?!chrome|android).)*safari/i.test(navigator.userAgent)||(a=r.offsetLeft,u=r.offsetTop)),{width:o,height:i,x:a+T(t),y:u}}(t)):d(e)?function(t){var e=A(t);return e.top=e.top+t.clientTop,e.left=e.left+t.clientLeft,e.bottom=e.top+t.clientHeight,e.right=e.left+t.clientWidth,e.width=t.clientWidth,e.height=t.clientHeight,e.x=e.left,e.y=e.top,e}(e):H(function(t){var e=y(t),n=I(t),r=t.ownerDocument.body,o=Math.max(e.scrollWidth,e.clientWidth,r?r.scrollWidth:0,r?r.clientWidth:0),i=Math.max(e.scrollHeight,e.clientHeight,r?r.scrollHeight:0,r?r.clientHeight:0),a=-n.scrollLeft+T(t),u=-n.scrollTop;return"rtl"===h(r||e).direction&&(a+=Math.max(e.clientWidth,r?r.clientWidth:0)-o),{width:o,height:i,x:a,y:u}}(y(t)))}function U(t){return t.split("-")[1]}function V(t){var i,a=t.reference,u=t.element,f=t.placement,c=f?l(f):null,p=f?U(f):null,s=a.x+a.width/2-u.width/2,d=a.y+a.height/2-u.height/2;switch(c){case e:i={x:s,y:a.y-u.height};break;case n:i={x:s,y:a.y+a.height};break;case r:i={x:a.x+a.width,y:d};break;case o:i={x:a.x-u.width,y:d};break;default:i={x:a.x,y:a.y}}var v=c?w(c):null;if(null!=v){var b="y"===v?"height":"width";switch(p){case"start":i[v]=i[v]-(a[b]/2-u[b]/2);break;case"end":i[v]=i[v]+(a[b]/2-u[b]/2)}}return i}function _(t,o){void 0===o&&(o={});var a=o.placement,u=void 0===a?t.placement:a,f=o.boundary,p=void 0===f?"clippingParents":f,l=o.rootBoundary,v=void 0===l?"viewport":l,m=o.elementContext,j=void 0===m?"popper":m,w=o.altBoundary,x=void 0!==w&&w,E=o.padding,q=void 0===E?0:E,B=M("number"!=typeof q?q:k(q,i)),P=t.elements.reference,L=t.rects.popper,R=t.elements[x?"popper"===j?"reference":"popper":j],S=function(t,e,n){var r="clippingParents"===e?function(t){var e=z(O(t)),n=["absolute","fixed"].indexOf(h(t).position)>=0&&d(t)?g(t):t;return s(n)?e.filter((function(t){return s(t)&&b(t,n)&&"body"!==c(t)})):[]}(t):[].concat(e),o=[].concat(r,[n]),i=o.reduce((function(e,n){var r=D(t,n);return e.top=Math.max(r.top,e.top),e.right=Math.min(r.right,e.right),e.bottom=Math.min(r.bottom,e.bottom),e.left=Math.max(r.left,e.left),e}),D(t,o[0]));return i.width=i.right-i.left,i.height=i.bottom-i.top,i.x=i.left,i.y=i.top,i}(s(R)?R:R.contextElement||y(t.elements.popper),p,v),I=A(P),T=V({reference:I,element:L,strategy:"absolute",placement:u}),W=H(Object.assign(Object.assign({},L),T)),C="popper"===j?W:I,U={top:S.top-C.top+B.top,bottom:C.bottom-S.bottom+B.bottom,left:S.left-C.left+B.left,right:C.right-S.right+B.right},_=t.modifiersData.offset;if("popper"===j&&_){var F=_[u];Object.keys(U).forEach((function(t){var o=[r,n].indexOf(t)>=0?1:-1,i=[e,n].indexOf(t)>=0?"y":"x";U[t]+=F[i]*o}))}return U}function F(t,e){void 0===e&&(e={});var n=e.boundary,r=e.rootBoundary,o=e.padding,f=e.flipVariations,c=e.allowedAutoPlacements,p=void 0===c?u:c,s=U(e.placement),d=s?f?a:a.filter((function(t){return U(t)===s})):i,v=d.filter((function(t){return p.indexOf(t)>=0}));0===v.length&&(v=d);var b=v.reduce((function(e,i){return e[i]=_(t,{placement:i,boundary:n,rootBoundary:r,padding:o})[l(i)],e}),{});return Object.keys(b).sort((function(t,e){return b[t]-b[e]}))}function G(t,e,n){return void 0===n&&(n={x:0,y:0}),{top:t.top-e.height-n.y,right:t.right-e.width+n.x,bottom:t.bottom-e.height+n.y,left:t.left-e.width-n.x}}function J(t){return[e,r,n,o].some((function(e){return t[e]>=0}))}function K(t,e,n){void 0===n&&(n=!1);var r,o,i=y(e),a=A(t),u=d(e),f={scrollLeft:0,scrollTop:0},s={x:0,y:0};return(u||!u&&!n)&&(("body"!==c(e)||W(i))&&(f=(r=e)!==p(r)&&d(r)?{scrollLeft:(o=r).scrollLeft,scrollTop:o.scrollTop}:I(r)),d(e)?((s=A(e)).x+=e.clientLeft,s.y+=e.clientTop):i&&(s.x=T(i))),{x:a.left+f.scrollLeft-s.x,y:a.top+f.scrollTop-s.y,width:a.width,height:a.height}}function N(t){var e=new Map,n=new Set,r=[];function o(t){n.add(t.name),[].concat(t.requires||[],t.requiresIfExists||[]).forEach((function(t){if(!n.has(t)){var r=e.get(t);r&&o(r)}})),r.push(t)}return t.forEach((function(t){e.set(t.name,t)})),t.forEach((function(t){n.has(t.name)||o(t)})),r}var Q={placement:"bottom",modifiers:[],strategy:"absolute"};function X(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return!e.some((function(t){return!(t&&"function"==typeof t.getBoundingClientRect)}))}function Y(t){void 0===t&&(t={});var e=t.defaultModifiers,n=void 0===e?[]:e,r=t.defaultOptions,o=void 0===r?Q:r;return function(t,e,r){void 0===r&&(r=o);var i,a,u={placement:"bottom",orderedModifiers:[],options:Object.assign(Object.assign({},Q),o),modifiersData:{},elements:{reference:t,popper:e},attributes:{},styles:{}},c=[],p=!1,d={state:u,setOptions:function(r){l(),u.options=Object.assign(Object.assign(Object.assign({},o),u.options),r),u.scrollParents={reference:s(t)?z(t):t.contextElement?z(t.contextElement):[],popper:z(e)};var i,a,p=function(t){var e=N(t);return f.reduce((function(t,n){return t.concat(e.filter((function(t){return t.phase===n})))}),[])}((i=[].concat(n,u.options.modifiers),a=i.reduce((function(t,e){var n=t[e.name];return t[e.name]=n?Object.assign(Object.assign(Object.assign({},n),e),{},{options:Object.assign(Object.assign({},n.options),e.options),data:Object.assign(Object.assign({},n.data),e.data)}):e,t}),{}),Object.keys(a).map((function(t){return a[t]}))));return u.orderedModifiers=p.filter((function(t){return t.enabled})),u.orderedModifiers.forEach((function(t){var e=t.options,n=t.effect;if("function"==typeof n){var r=n({state:u,name:t.name,instance:d,options:void 0===e?{}:e});c.push(r||function(){})}})),d.update()},forceUpdate:function(){if(!p){var t=u.elements,e=t.reference,n=t.popper;if(X(e,n)){u.rects={reference:K(e,g(n),"fixed"===u.options.strategy),popper:v(n)},u.reset=!1,u.placement=u.options.placement,u.orderedModifiers.forEach((function(t){return u.modifiersData[t.name]=Object.assign({},t.data)}));for(var r=0;r<u.orderedModifiers.length;r++)if(!0!==u.reset){var o=u.orderedModifiers[r],i=o.fn,a=o.options;"function"==typeof i&&(u=i({state:u,options:void 0===a?{}:a,name:o.name,instance:d})||u)}else u.reset=!1,r=-1}}},update:(i=function(){return new Promise((function(t){d.forceUpdate(),t(u)}))},function(){return a||(a=new Promise((function(t){Promise.resolve().then((function(){a=void 0,t(i())}))}))),a}),destroy:function(){l(),p=!0}};if(!X(t,e))return d;function l(){c.forEach((function(t){return t()})),c=[]}return d.setOptions(r).then((function(t){!p&&r.onFirstUpdate&&r.onFirstUpdate(t)})),d}}var Z=Y({defaultModifiers:[{name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:function(t){var e=t.state,n=t.instance,r=t.options,o=r.scroll,i=void 0===o||o,a=r.resize,u=void 0===a||a,f=p(e.elements.popper),c=[].concat(e.scrollParents.reference,e.scrollParents.popper);return i&&c.forEach((function(t){t.addEventListener("scroll",n.update,B)})),u&&f.addEventListener("resize",n.update,B),function(){i&&c.forEach((function(t){t.removeEventListener("scroll",n.update,B)})),u&&f.removeEventListener("resize",n.update,B)}},data:{}},{name:"popperOffsets",enabled:!0,phase:"read",fn:function(t){var e=t.state;e.modifiersData[t.name]=V({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})},data:{}},{name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:function(t){var e=t.state,n=t.options,r=n.gpuAcceleration,o=void 0===r||r,i=n.adaptive,a=void 0===i||i,u=n.roundOffsets,f=void 0===u||u,c={placement:l(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:o};null!=e.modifiersData.popperOffsets&&(e.styles.popper=Object.assign(Object.assign({},e.styles.popper),q(Object.assign(Object.assign({},c),{},{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:a,roundOffsets:f})))),null!=e.modifiersData.arrow&&(e.styles.arrow=Object.assign(Object.assign({},e.styles.arrow),q(Object.assign(Object.assign({},c),{},{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:f})))),e.attributes.popper=Object.assign(Object.assign({},e.attributes.popper),{},{"data-popper-placement":e.placement})},data:{}},{name:"applyStyles",enabled:!0,phase:"write",fn:function(t){var e=t.state;Object.keys(e.elements).forEach((function(t){var n=e.styles[t]||{},r=e.attributes[t]||{},o=e.elements[t];d(o)&&c(o)&&(Object.assign(o.style,n),Object.keys(r).forEach((function(t){var e=r[t];!1===e?o.removeAttribute(t):o.setAttribute(t,!0===e?"":e)})))}))},effect:function(t){var e=t.state,n={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,n.popper),e.elements.arrow&&Object.assign(e.elements.arrow.style,n.arrow),function(){Object.keys(e.elements).forEach((function(t){var r=e.elements[t],o=e.attributes[t]||{},i=Object.keys(e.styles.hasOwnProperty(t)?e.styles[t]:n[t]).reduce((function(t,e){return t[e]="",t}),{});d(r)&&c(r)&&(Object.assign(r.style,i),Object.keys(o).forEach((function(t){r.removeAttribute(t)})))}))}},requires:["computeStyles"]},{name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:function(t){var n=t.state,i=t.name,a=t.options.offset,f=void 0===a?[0,0]:a,c=u.reduce((function(t,i){return t[i]=function(t,n,i){var a=l(t),u=[o,e].indexOf(a)>=0?-1:1,f="function"==typeof i?i(Object.assign(Object.assign({},n),{},{placement:t})):i,c=f[0],p=f[1];return c=c||0,p=(p||0)*u,[o,r].indexOf(a)>=0?{x:p,y:c}:{x:c,y:p}}(i,n.rects,f),t}),{}),p=c[n.placement],s=p.y;null!=n.modifiersData.popperOffsets&&(n.modifiersData.popperOffsets.x+=p.x,n.modifiersData.popperOffsets.y+=s),n.modifiersData[i]=c}},{name:"flip",enabled:!0,phase:"main",fn:function(t){var i=t.state,a=t.options,u=t.name;if(!i.modifiersData[u]._skip){for(var f=a.mainAxis,c=void 0===f||f,p=a.altAxis,s=void 0===p||p,d=a.fallbackPlacements,v=a.padding,b=a.boundary,h=a.rootBoundary,m=a.altBoundary,y=a.flipVariations,O=void 0===y||y,j=a.allowedAutoPlacements,g=i.options.placement,w=l(g),x=d||(w!==g&&O?function(t){if("auto"===l(t))return[];var e=L(t);return[S(t),e,S(e)]}(g):[L(g)]),M=[g].concat(x).reduce((function(t,e){return t.concat("auto"===l(e)?F(i,{placement:e,boundary:b,rootBoundary:h,padding:v,flipVariations:O,allowedAutoPlacements:j}):e)}),[]),k=i.rects.reference,E=i.rects.popper,q=new Map,B=!0,P=M[0],R=0;R<M.length;R++){var A=M[R],I=l(A),T="start"===U(A),W=[e,n].indexOf(I)>=0,C=W?"width":"height",z=_(i,{placement:A,boundary:b,rootBoundary:h,altBoundary:m,padding:v}),H=W?T?r:o:T?n:e;k[C]>E[C]&&(H=L(H));var D=L(H),V=[];if(c&&V.push(z[I]<=0),s&&V.push(z[H]<=0,z[D]<=0),V.every((function(t){return t}))){P=A,B=!1;break}q.set(A,V)}if(B)for(var G=function(t){var e=M.find((function(e){var n=q.get(e);if(n)return n.slice(0,t).every((function(t){return t}))}));if(e)return P=e,"break"},J=O?3:1;J>0&&"break"!==G(J);J--);i.placement!==P&&(i.modifiersData[u]._skip=!0,i.placement=P,i.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}},{name:"preventOverflow",enabled:!0,phase:"main",fn:function(t){var i=t.state,a=t.options,u=t.name,f=a.mainAxis,c=void 0===f||f,p=a.altAxis,s=void 0!==p&&p,d=a.tether,b=void 0===d||d,h=a.tetherOffset,m=void 0===h?0:h,y=_(i,{boundary:a.boundary,rootBoundary:a.rootBoundary,padding:a.padding,altBoundary:a.altBoundary}),O=l(i.placement),j=U(i.placement),M=!j,k=w(O),E="x"===k?"y":"x",q=i.modifiersData.popperOffsets,B=i.rects.reference,P=i.rects.popper,L="function"==typeof m?m(Object.assign(Object.assign({},i.rects),{},{placement:i.placement})):m,R={x:0,y:0};if(q){if(c){var S="y"===k?e:o,A="y"===k?n:r,I="y"===k?"height":"width",T=q[k],W=q[k]+y[S],C=q[k]-y[A],z=b?-P[I]/2:0,H="start"===j?B[I]:P[I],D="start"===j?-P[I]:-B[I],V=i.elements.arrow,F=b&&V?v(V):{width:0,height:0},G=i.modifiersData["arrow#persistent"]?i.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0},J=G[S],K=G[A],N=x(0,B[I],F[I]),Q=M?B[I]/2-z-N-J-L:H-N-J-L,X=M?-B[I]/2+z+N+K+L:D+N+K+L,Y=i.elements.arrow&&g(i.elements.arrow),Z=i.modifiersData.offset?i.modifiersData.offset[i.placement][k]:0,$=q[k]+X-Z,tt=x(b?Math.min(W,q[k]+Q-Z-(Y?"y"===k?Y.clientTop||0:Y.clientLeft||0:0)):W,T,b?Math.max(C,$):C);q[k]=tt,R[k]=tt-T}if(s){var et=q[E],nt=x(et+y["x"===k?e:o],et,et-y["x"===k?n:r]);q[E]=nt,R[E]=nt-et}i.modifiersData[u]=R}},requiresIfExists:["offset"]},{name:"arrow",enabled:!0,phase:"main",fn:function(t){var i,a=t.state,u=t.name,f=a.elements.arrow,c=a.modifiersData.popperOffsets,p=l(a.placement),s=w(p),d=[o,r].indexOf(p)>=0?"height":"width";if(f&&c){var b=a.modifiersData[u+"#persistent"].padding,h=v(f),m="y"===s?e:o,y="y"===s?n:r,O=a.rects.reference[d]+a.rects.reference[s]-c[s]-a.rects.popper[d],j=c[s]-a.rects.reference[s],M=g(f),k=M?"y"===s?M.clientHeight||0:M.clientWidth||0:0,E=k/2-h[d]/2+(O/2-j/2),q=x(b[m],E,k-h[d]-b[y]);a.modifiersData[u]=((i={})[s]=q,i.centerOffset=q-E,i)}},effect:function(t){var e=t.state,n=t.options,r=t.name,o=n.element,a=void 0===o?"[data-popper-arrow]":o,u=n.padding,f=void 0===u?0:u;null!=a&&("string"!=typeof a||(a=e.elements.popper.querySelector(a)))&&b(e.elements.popper,a)&&(e.elements.arrow=a,e.modifiersData[r+"#persistent"]={padding:M("number"!=typeof f?f:k(f,i))})},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]},{name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function(t){var e=t.state,n=t.name,r=e.rects.reference,o=e.rects.popper,i=e.modifiersData.preventOverflow,a=_(e,{elementContext:"reference"}),u=_(e,{altBoundary:!0}),f=G(a,r),c=G(u,o,i),p=J(f),s=J(c);e.modifiersData[n]={referenceClippingOffsets:f,popperEscapeOffsets:c,isReferenceHidden:p,hasPopperEscaped:s},e.attributes.popper=Object.assign(Object.assign({},e.attributes.popper),{},{"data-popper-reference-hidden":p,"data-popper-escaped":s})}}]});const $={animation:"calcite-popper-anim",animationActive:"calcite-popper-anim--active"};function tt(e,n){const r=["left","right"];return"rtl"===t(e)&&r.reverse(),n.replace(/leading/gi,r[0]).replace(/trailing/gi,r[1])}function et({referenceEl:t,el:e,placement:n,modifiers:r}){return t?Z(t,e,{placement:tt(e,n),modifiers:r}):null}function nt({el:t,modifiers:e,placement:n,popper:r}){const o=tt(t,n);r.setOptions({modifiers:e,placement:o})}const rt=Math.ceil((4,Math.sqrt(Math.pow(4,2)+Math.pow(4,2))));export{$ as C,et as c,rt as d,nt as u}