123456 |
- /*!
- * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
- * v1.0.0-beta.97
- */
- import{r as t,h as i,H as e,g as a}from"./p-91755387.js";import{g as n}from"./p-d5bfadd8.js";import{b as o,c as r,u as s,a as c,r as l,F as m}from"./p-91b670e6.js";import{i as d,q as h,t as p}from"./p-96bf42e5.js";import"./p-622f8ecb.js";import"./p-af9e6e54.js";const f=new class{constructor(){this.registeredElements=new WeakMap,this.hoverTimeouts=new WeakMap,this.registeredElementCount=0,this.queryTooltip=t=>{const{registeredElements:i}=this,e=t.find((t=>i.has(t)));return i.get(e)},this.keyDownHandler=t=>{if("Escape"===t.key){const{activeTooltipEl:t}=this;t&&(this.clearHoverTimeout(t),this.toggleTooltip(t,!1))}},this.mouseEnterShow=t=>{this.hoverEvent(t,!0)},this.mouseLeaveHide=t=>{this.hoverEvent(t,!1)},this.clickHandler=t=>{if(!d(t))return;const i=this.queryTooltip(t.composedPath());this.clickedTooltip=i,(null==i?void 0:i.closeOnClick)&&(this.toggleTooltip(i,!1),this.clearHoverTimeout(i))},this.focusShow=t=>{this.focusEvent(t,!0)},this.blurHide=t=>{this.focusEvent(t,!1)},this.hoverToggle=(t,i)=>{const{hoverTimeouts:e}=this;e.delete(t),i&&this.closeExistingTooltip(),this.toggleTooltip(t,i)}}registerElement(t,i){this.registeredElementCount++,this.registeredElements.set(t,i),1===this.registeredElementCount&&this.addListeners()}unregisterElement(t){this.registeredElements.delete(t)&&this.registeredElementCount--,0===this.registeredElementCount&&this.removeListeners()}addListeners(){document.addEventListener("keydown",this.keyDownHandler),document.addEventListener("pointerover",this.mouseEnterShow,{capture:!0}),document.addEventListener("pointerout",this.mouseLeaveHide,{capture:!0}),document.addEventListener("pointerdown",this.clickHandler,{capture:!0}),document.addEventListener("focusin",this.focusShow,{capture:!0}),document.addEventListener("focusout",this.blurHide,{capture:!0})}removeListeners(){document.removeEventListener("keydown",this.keyDownHandler),document.removeEventListener("pointerover",this.mouseEnterShow,{capture:!0}),document.removeEventListener("pointerout",this.mouseLeaveHide,{capture:!0}),document.removeEventListener("pointerdown",this.clickHandler,{capture:!0}),document.removeEventListener("focusin",this.focusShow,{capture:!0}),document.removeEventListener("focusout",this.blurHide,{capture:!0})}clearHoverTimeout(t){const{hoverTimeouts:i}=this;i.has(t)&&(window.clearTimeout(i.get(t)),i.delete(t))}closeExistingTooltip(){const{activeTooltipEl:t}=this;t&&this.toggleTooltip(t,!1)}focusTooltip(t,i){this.closeExistingTooltip(),i&&this.clearHoverTimeout(t),this.toggleTooltip(t,i)}toggleTooltip(t,i){t.open=i,i&&(this.activeTooltipEl=t)}hoverTooltip(t,i){this.clearHoverTimeout(t);const{hoverTimeouts:e}=this,a=window.setTimeout((()=>this.hoverToggle(t,i)),500);e.set(t,a)}activeTooltipHover(t){const{activeTooltipEl:i,hoverTimeouts:e}=this,{type:a}=t;i&&("pointerover"===a&&t.composedPath().includes(i)?this.clearHoverTimeout(i):"pointerout"!==a||e.has(i)||this.hoverTooltip(i,!1))}hoverEvent(t,i){const e=this.queryTooltip(t.composedPath());this.activeTooltipHover(t),e&&this.hoverTooltip(e,i)}focusEvent(t,i){const e=this.queryTooltip(t.composedPath());e&&e!==this.clickedTooltip?this.focusTooltip(e,i):this.clickedTooltip=null}},u=class{constructor(i){t(this,i),this.closeOnClick=!1,this.offsetDistance=o,this.offsetSkidding=0,this.open=!1,this.overlayPositioning="absolute",this.placement="auto",this.guid=`calcite-tooltip-${n()}`,this.hasLoaded=!1,this.setUpReferenceElement=(t=!0)=>{this.removeReferences(),this.effectiveReferenceElement=this.getReferenceElement(),r(this,this.effectiveReferenceElement,this.el);const{el:i,referenceElement:e,effectiveReferenceElement:a}=this;t&&e&&!a&&console.warn(`${i.tagName}: reference-element id "${e}" was not found.`,{el:i}),this.addReferences()},this.getId=()=>this.el.id||this.guid,this.addReferences=()=>{const{effectiveReferenceElement:t}=this;if(!t)return;const i=this.getId();"setAttribute"in t&&t.setAttribute("aria-describedby",i),f.registerElement(t,this.el)},this.removeReferences=()=>{const{effectiveReferenceElement:t}=this;t&&("removeAttribute"in t&&t.removeAttribute("aria-describedby"),f.unregisterElement(t))}}offsetDistanceOffsetHandler(){this.reposition(!0)}offsetSkiddingHandler(){this.reposition(!0)}openHandler(t){t?this.reposition(!0):s(this.el)}overlayPositioningHandler(){this.reposition(!0)}placementHandler(){this.reposition(!0)}referenceElementHandler(){this.setUpReferenceElement()}connectedCallback(){this.setUpReferenceElement(this.hasLoaded)}componentDidLoad(){this.referenceElement&&!this.effectiveReferenceElement&&this.setUpReferenceElement(),this.reposition(!0),this.hasLoaded=!0}disconnectedCallback(){this.removeReferences(),c(this,this.effectiveReferenceElement,this.el)}async reposition(t=!1){const{el:i,effectiveReferenceElement:e,placement:a,overlayPositioning:n,offsetDistance:o,offsetSkidding:r,arrowEl:s}=this;return l(this,{floatingEl:i,referenceEl:e,overlayPositioning:n,placement:a,offsetDistance:o,offsetSkidding:r,includeArrow:!0,arrowEl:s,type:"tooltip"},t)}getReferenceElement(){const{referenceElement:t,el:i}=this;return("string"==typeof t?h(i,{id:t}):t)||null}render(){const{effectiveReferenceElement:t,label:a,open:n}=this,o=t&&n,r=!o;return i(e,{"aria-hidden":p(r),"aria-label":a,"aria-live":"polite","calcite-hydrated-hidden":r,id:this.getId(),role:"tooltip"},i("div",{class:{[m.animation]:!0,[m.animationActive]:o}},i("div",{class:"arrow",ref:t=>this.arrowEl=t}),i("div",{class:"container"},i("slot",null))))}get el(){return a(this)}static get watchers(){return{offsetDistance:["offsetDistanceOffsetHandler"],offsetSkidding:["offsetSkiddingHandler"],open:["openHandler"],overlayPositioning:["overlayPositioningHandler"],placement:["placementHandler"],referenceElement:["referenceElementHandler"]}}};u.style='@keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in-down{0%{opacity:0;transform:translate3D(0, -5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;transform:translate3D(0, 5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-scale{0%{opacity:0;transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;animation-fill-mode:both;animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{animation-name:in}.calcite-animate__in-down{animation-name:in-down}.calcite-animate__in-up{animation-name:in-up}.calcite-animate__in-scale{animation-name:in-scale}@media (prefers-reduced-motion: reduce){:root{--calcite-internal-duration-factor:0.01}}:root{--calcite-floating-ui-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:block;position:absolute;z-index:999}.calcite-floating-ui-anim{position:relative;transition:var(--calcite-floating-ui-transition);visibility:hidden;transition-property:transform, visibility, opacity;opacity:0;box-shadow:0 0 16px 0 rgba(0, 0, 0, 0.16);z-index:1;border-radius:0.25rem}:host([data-placement^=bottom]) .calcite-floating-ui-anim{transform:translateY(-5px)}:host([data-placement^=top]) .calcite-floating-ui-anim{transform:translateY(5px)}:host([data-placement^=left]) .calcite-floating-ui-anim{transform:translateX(5px)}:host([data-placement^=right]) .calcite-floating-ui-anim{transform:translateX(-5px)}:host([data-placement]) .calcite-floating-ui-anim--active{opacity:1;visibility:visible;transform:translate(0)}:host([calcite-hydrated-hidden]){visibility:hidden !important;pointer-events:none}.arrow,.arrow::before{position:absolute;inline-size:8px;block-size:8px;z-index:-1}.arrow::before{content:"";--tw-shadow:0 4px 8px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);--tw-shadow-colored:0 4px 8px -1px var(--tw-shadow-color), 0 2px 4px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);transform:rotate(45deg);background:var(--calcite-ui-foreground-1)}:host([data-placement^=top]) .arrow{inset-block-end:-4px}:host([data-placement^=bottom]) .arrow{inset-block-start:-4px}:host([data-placement^=left]) .arrow{direction:ltr;inset-inline-end:-4px}:host([data-placement^=right]) .arrow{direction:ltr;inset-inline-start:-4px}.container{position:relative;overflow:hidden;border-radius:0.25rem;background-color:var(--calcite-ui-foreground-1);padding-block:0.75rem;padding-inline:1rem;font-size:var(--calcite-font-size--2);line-height:1.375;font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-1);max-inline-size:20rem;max-block-size:20rem;text-align:start}.calcite-floating-ui-anim{border-radius:0.25rem;border-width:1px;border-style:solid;border-color:var(--calcite-ui-border-3);background-color:var(--calcite-ui-foreground-1)}.arrow::before{outline:1px solid var(--calcite-ui-border-3)}';const v=class{constructor(i){t(this,i),this.selector="[data-calcite-tooltip-reference]"}render(){return i("slot",null)}};v.style="@keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in-down{0%{opacity:0;transform:translate3D(0, -5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;transform:translate3D(0, 5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-scale{0%{opacity:0;transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;animation-fill-mode:both;animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{animation-name:in}.calcite-animate__in-down{animation-name:in-down}.calcite-animate__in-up{animation-name:in-up}.calcite-animate__in-scale{animation-name:in-scale}@media (prefers-reduced-motion: reduce){:root{--calcite-internal-duration-factor:0.01}}:root{--calcite-floating-ui-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{position:relative;display:block}";export{u as calcite_tooltip,v as calcite_tooltip_manager}
|