@spectrum-web-components/overlay 1.7.0 → 1.8.0

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.
Files changed (87) hide show
  1. package/README.md +28 -10
  2. package/custom-elements.json +20 -0
  3. package/local.d.ts +10 -10
  4. package/overlay-trigger.dev.js.map +1 -1
  5. package/overlay-trigger.js.map +1 -1
  6. package/package.json +6 -6
  7. package/sp-overlay.dev.js.map +1 -1
  8. package/sp-overlay.js.map +1 -1
  9. package/src/AbstractOverlay.d.ts +11 -0
  10. package/src/AbstractOverlay.dev.js.map +1 -1
  11. package/src/AbstractOverlay.js.map +1 -1
  12. package/src/ClickController.d.ts +11 -0
  13. package/src/ClickController.dev.js.map +1 -1
  14. package/src/ClickController.js.map +1 -1
  15. package/src/HoverController.d.ts +11 -0
  16. package/src/HoverController.dev.js.map +1 -1
  17. package/src/HoverController.js.map +1 -1
  18. package/src/InteractionController.d.ts +11 -0
  19. package/src/InteractionController.dev.js.map +1 -1
  20. package/src/InteractionController.js.map +1 -1
  21. package/src/LongpressController.d.ts +11 -0
  22. package/src/LongpressController.dev.js.map +1 -1
  23. package/src/LongpressController.js.map +1 -1
  24. package/src/Overlay.d.ts +22 -1
  25. package/src/Overlay.dev.js +20 -2
  26. package/src/Overlay.dev.js.map +2 -2
  27. package/src/Overlay.js +2 -2
  28. package/src/Overlay.js.map +2 -2
  29. package/src/OverlayNoPopover.dev.js.map +1 -1
  30. package/src/OverlayNoPopover.js.map +1 -1
  31. package/src/OverlayPopover.dev.js.map +1 -1
  32. package/src/OverlayPopover.js.map +1 -1
  33. package/src/OverlayStack.d.ts +17 -0
  34. package/src/OverlayStack.dev.js +20 -0
  35. package/src/OverlayStack.dev.js.map +2 -2
  36. package/src/OverlayStack.js +1 -1
  37. package/src/OverlayStack.js.map +3 -3
  38. package/src/OverlayTrigger.d.ts +11 -0
  39. package/src/OverlayTrigger.dev.js.map +1 -1
  40. package/src/OverlayTrigger.js.map +1 -1
  41. package/src/PlacementController.d.ts +11 -0
  42. package/src/PlacementController.dev.js.map +1 -1
  43. package/src/PlacementController.js.map +1 -1
  44. package/src/VirtualTrigger.d.ts +11 -0
  45. package/src/VirtualTrigger.dev.js.map +2 -2
  46. package/src/VirtualTrigger.js.map +2 -2
  47. package/src/events.d.ts +11 -0
  48. package/src/events.dev.js.map +1 -1
  49. package/src/events.js.map +1 -1
  50. package/src/fullSizePlugin.d.ts +11 -0
  51. package/src/fullSizePlugin.dev.js.map +1 -1
  52. package/src/fullSizePlugin.js.map +1 -1
  53. package/src/index.d.ts +11 -0
  54. package/src/index.dev.js.map +1 -1
  55. package/src/index.js.map +1 -1
  56. package/src/loader.d.ts +11 -0
  57. package/src/loader.dev.js.map +1 -1
  58. package/src/loader.js.map +1 -1
  59. package/src/overlay-events.d.ts +11 -0
  60. package/src/overlay-events.dev.js.map +1 -1
  61. package/src/overlay-events.js.map +1 -1
  62. package/src/overlay-timer.d.ts +11 -0
  63. package/src/overlay-timer.dev.js.map +1 -1
  64. package/src/overlay-timer.js.map +1 -1
  65. package/src/overlay-trigger-directive.d.ts +11 -0
  66. package/src/overlay-trigger-directive.dev.js.map +1 -1
  67. package/src/overlay-trigger-directive.js.map +1 -1
  68. package/src/overlay-trigger.css.dev.js.map +1 -1
  69. package/src/overlay-trigger.css.js.map +1 -1
  70. package/src/overlay-types.d.ts +11 -0
  71. package/src/overlay-types.dev.js.map +1 -1
  72. package/src/overlay-types.js.map +1 -1
  73. package/src/overlay.css.dev.js.map +1 -1
  74. package/src/overlay.css.js.map +1 -1
  75. package/src/slottable-request-directive.d.ts +11 -0
  76. package/src/slottable-request-directive.dev.js.map +1 -1
  77. package/src/slottable-request-directive.js.map +1 -1
  78. package/src/slottable-request-event.d.ts +11 -0
  79. package/src/slottable-request-event.dev.js +1 -1
  80. package/src/slottable-request-event.dev.js.map +2 -2
  81. package/src/slottable-request-event.js.map +2 -2
  82. package/src/strategies.d.ts +11 -0
  83. package/src/strategies.dev.js.map +1 -1
  84. package/src/strategies.js.map +1 -1
  85. package/sync/overlay-trigger.d.ts +11 -0
  86. package/sync/overlay-trigger.dev.js.map +1 -1
  87. package/sync/overlay-trigger.js.map +1 -1
package/src/Overlay.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var b=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var r=(m,l,e,t)=>{for(var i=t>1?void 0:t?E(l,e):l,s=m.length-1,a;s>=0;s--)(a=m[s])&&(i=(t?a(l,e,i):a(i))||i);return t&&i&&b(l,e,i),i};import{html as c}from"@spectrum-web-components/base";import{property as n,query as g,queryAssignedElements as C,state as T}from"@spectrum-web-components/base/src/decorators.js";import{ElementResolutionController as P,elementResolverUpdatedSymbol as w}from"@spectrum-web-components/reactive-controllers/src/ElementResolution.js";import{ifDefined as d,styleMap as S}from"@spectrum-web-components/base/src/directives.js";import{randomID as O}from"@spectrum-web-components/shared/src/random-id.js";import{AbstractOverlay as f,nextFrame as u}from"./AbstractOverlay.js";import{OverlayPopover as L}from"./OverlayPopover.js";import{OverlayNoPopover as R}from"./OverlayNoPopover.js";import{overlayStack as v}from"./OverlayStack.js";import{VirtualTrigger as H}from"./VirtualTrigger.js";import{PlacementController as M}from"./PlacementController.js";export{LONGPRESS_INSTRUCTIONS}from"./LongpressController.js";import{strategies as F}from"./strategies.js";import{removeSlottableRequest as q,SlottableRequestEvent as N}from"./slottable-request-event.js";import $ from"./overlay.css.js";const I="showPopover"in document.createElement("div");let y=L(f);I||(y=R(f));const o=class o extends y{constructor(){super(...arguments);this._delayed=!1;this._disabled=!1;this.offset=0;this._open=!1;this.lastRequestSlottableState=!1;this.receivesFocus="auto";this._state="closed";this.triggerElement=null;this.type="auto";this.wasOpen=!1;this._focusTrap=null;this.closeOnFocusOut=e=>{if(!e.relatedTarget)return;const t=new Event("overlay-relation-query",{bubbles:!0,composed:!0});e.relatedTarget.addEventListener(t.type,i=>{i.composedPath().some(p=>p===this)||(this.open=!1)}),e.relatedTarget.dispatchEvent(t)};this.closeOnCancelEvent=()=>{this.open=!1}}get delayed(){var e;return((e=this.elements.at(-1))==null?void 0:e.hasAttribute("delayed"))||this._delayed}set delayed(e){this._delayed=e}get disabled(){return this._disabled}set disabled(e){var t;this._disabled=e,e?((t=this.strategy)==null||t.abort(),this.wasOpen=this.open,this.open=!1):(this.bindEvents(),this.open=this.open||this.wasOpen,this.wasOpen=!1)}get hasNonVirtualTrigger(){return!!this.triggerElement&&!(this.triggerElement instanceof H)}get placementController(){return this._placementController||(this._placementController=new M(this)),this._placementController}get open(){return this._open}set open(e){var t;e&&this.disabled||e!==this.open&&((t=this.strategy)!=null&&t.activelyOpening&&!e||(this._open=e,this.open&&(o.openCount+=1),this.requestUpdate("open",!this.open),this.open&&this.requestSlottable()))}get state(){return this._state}set state(e){var i;if(e===this.state)return;const t=this.state;this._state=e,(this.state==="opened"||this.state==="closed")&&((i=this.strategy)==null||i.shouldCompleteOpen()),this.requestUpdate("state",t)}get elementResolver(){return this._elementResolver||(this._elementResolver=new P(this)),this._elementResolver}get popoverValue(){if("popover"in this)switch(this.type){case"modal":return"auto";case"page":return"manual";case"hint":return"manual";default:return this.type}}get requiresPositioning(){return!(this.type==="page"||!this.open||!this.triggerElement||!this.placement&&this.type!=="hint")}managePosition(){if(!this.requiresPositioning||!this.open)return;const e=this.offset||0,t=this.triggerElement,i=this.placement||"right",s=this.tipPadding;this.placementController.placeOverlay(this.dialogEl,{offset:e,placement:i,tipPadding:s,trigger:t,type:this.type})}async managePopoverOpen(){super.managePopoverOpen();const e=this.open;if(this.open!==e||(await this.manageDelay(e),this.open!==e)||(this.triggerInteraction==="longpress"&&await u(),await this.ensureOnDOM(e),this.open!==e))return;const t=await this.makeTransition(e);if(this.open===e){if(e){const i=await import("focus-trap");this._focusTrap=i.createFocusTrap(this.dialogEl,{initialFocus:t||void 0,tabbableOptions:{getShadowRoot:!0},fallbackFocus:()=>(this.dialogEl.setAttribute("tabIndex","-1"),this.dialogEl),escapeDeactivates:!1}),(this.type==="modal"||this.type==="page")&&this._focusTrap.activate()}await this.applyFocus(e,t)}}async applyFocus(e,t){if(!(this.receivesFocus==="false"||this.type==="hint")){if(await u(),await u(),e===this.open&&!this.open){this.hasNonVirtualTrigger&&this.contains(this.getRootNode().activeElement)&&this.triggerElement.focus();return}t==null||t.focus()}}returnFocus(){var t;if(this.open||this.type==="hint")return;const e=()=>{var a,p;const i=[];let s=document.activeElement;for(;(a=s==null?void 0:s.shadowRoot)!=null&&a.activeElement;)s=s.shadowRoot.activeElement;for(;s;){const h=s.assignedSlot||s.parentElement||((p=s.getRootNode())==null?void 0:p.host);h&&i.push(h),s=h}return i};this.receivesFocus!=="false"&&((t=this.triggerElement)!=null&&t.focus)&&(this.contains(this.getRootNode().activeElement)||e().includes(this)||document.activeElement===document.body)&&this.triggerElement.focus()}async manageOpen(e){var i;if(!this.isConnected&&this.open)return;this.hasUpdated||await this.updateComplete,this.open?(v.add(this),this.willPreventClose&&(document.addEventListener("pointerup",()=>{this.dialogEl.classList.toggle("not-immediately-closable",!1),this.willPreventClose=!1},{once:!0}),this.dialogEl.classList.toggle("not-immediately-closable",!0))):(e&&((i=this._focusTrap)==null||i.deactivate(),this._focusTrap=null,this.dispose()),v.remove(this)),this.open&&this.state!=="opened"?this.state="opening":!this.open&&this.state!=="closed"&&(this.state="closing"),this.managePopoverOpen();const t=this.getRootNode();this.type==="auto"&&(this.open?t.addEventListener("focusout",this.closeOnFocusOut,{capture:!0}):t.removeEventListener("focusout",this.closeOnFocusOut,{capture:!0})),(this.type==="modal"||this.type==="page")&&(this.open?t.addEventListener("cancel",this.closeOnCancelEvent,{capture:!0}):t.removeEventListener("cancel",this.closeOnCancelEvent,{capture:!0}))}bindEvents(){var e;(e=this.strategy)==null||e.abort(),this.strategy=void 0,this.hasNonVirtualTrigger&&this.triggerInteraction&&(this.strategy=new F[this.triggerInteraction](this.triggerElement,{overlay:this}))}handleBeforetoggle(e){e.newState!=="open"&&this.handleBrowserClose(e)}handleBrowserClose(e){var t;if(e.stopPropagation(),!((t=this.strategy)!=null&&t.activelyOpening)){this.open=!1;return}this.manuallyKeepOpen()}manuallyKeepOpen(){this.open=!0,this.placementController.allowPlacementUpdate=!0,this.manageOpen(!1)}handleSlotchange(){var e,t;this.elements.length?this.hasNonVirtualTrigger&&((t=this.strategy)==null||t.prepareDescription(this.triggerElement)):(e=this.strategy)==null||e.releaseDescription()}shouldPreventClose(){const e=this.willPreventClose;return this.willPreventClose=!1,e}requestSlottable(){this.lastRequestSlottableState!==this.open&&(this.open||document.body.offsetHeight,this.dispatchEvent(new N("overlay-content",this.open?{}:q)),this.lastRequestSlottableState=this.open)}willUpdate(e){var i;if(this.hasAttribute("id")||this.setAttribute("id",`${this.tagName.toLowerCase()}-${O()}`),e.has("open")&&(this.hasUpdated||this.open)&&this.manageOpen(e.get("open")),e.has("trigger")){const[s,a]=((i=this.trigger)==null?void 0:i.split("@"))||[];this.elementResolver.selector=s?`#${s}`:"",this.triggerInteraction=a}let t=!1;e.has(w)&&(t=this.triggerElement,this.triggerElement=this.elementResolver.element),e.has("triggerElement")&&(t=e.get("triggerElement")),t!==!1&&this.bindEvents()}updated(e){super.updated(e),e.has("placement")&&(this.placement?this.dialogEl.setAttribute("actual-placement",this.placement):this.dialogEl.removeAttribute("actual-placement"),this.open&&typeof e.get("placement")!="undefined"&&this.placementController.resetOverlayPosition()),e.has("state")&&this.state==="closed"&&typeof e.get("state")!="undefined"&&this.placementController.clearOverlayPosition()}renderContent(){return c`
1
+ "use strict";var y=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var r=(m,l,e,t)=>{for(var i=t>1?void 0:t?E(l,e):l,s=m.length-1,a;s>=0;s--)(a=m[s])&&(i=(t?a(l,e,i):a(i))||i);return t&&i&&y(l,e,i),i};import{html as c}from"@spectrum-web-components/base";import{property as n,query as g,queryAssignedElements as w,state as C}from"@spectrum-web-components/base/src/decorators.js";import{ElementResolutionController as T,elementResolverUpdatedSymbol as P}from"@spectrum-web-components/reactive-controllers/src/ElementResolution.js";import{ifDefined as d,styleMap as S}from"@spectrum-web-components/base/src/directives.js";import{randomID as O}from"@spectrum-web-components/shared/src/random-id.js";import{AbstractOverlay as f,nextFrame as u}from"./AbstractOverlay.js";import{OverlayPopover as L}from"./OverlayPopover.js";import{OverlayNoPopover as R}from"./OverlayNoPopover.js";import{overlayStack as v}from"./OverlayStack.js";import{VirtualTrigger as k}from"./VirtualTrigger.js";import{PlacementController as H}from"./PlacementController.js";export{LONGPRESS_INSTRUCTIONS}from"./LongpressController.js";import{strategies as M}from"./strategies.js";import{removeSlottableRequest as F,SlottableRequestEvent as N}from"./slottable-request-event.js";import $ from"./overlay.css.js";const q="showPopover"in document.createElement("div");let b=L(f);q||(b=R(f));const o=class o extends b{constructor(){super(...arguments);this._delayed=!1;this._disabled=!1;this.offset=0;this._open=!1;this.lastRequestSlottableState=!1;this.receivesFocus="auto";this.allowOutsideClick=!1;this._state="closed";this.triggerElement=null;this.type="auto";this.wasOpen=!1;this._focusTrap=null;this.closeOnFocusOut=e=>{if(!e.relatedTarget)return;const t=new Event("overlay-relation-query",{bubbles:!0,composed:!0});e.relatedTarget.addEventListener(t.type,i=>{i.composedPath().some(p=>p===this)||(this.open=!1)}),e.relatedTarget.dispatchEvent(t)};this.closeOnCancelEvent=()=>{this.open=!1}}get delayed(){var e;return((e=this.elements.at(-1))==null?void 0:e.hasAttribute("delayed"))||this._delayed}set delayed(e){this._delayed=e}get disabled(){return this._disabled}set disabled(e){var t;this._disabled=e,e?((t=this.strategy)==null||t.abort(),this.wasOpen=this.open,this.open=!1):(this.bindEvents(),this.open=this.open||this.wasOpen,this.wasOpen=!1)}get hasNonVirtualTrigger(){return!!this.triggerElement&&!(this.triggerElement instanceof k)}get placementController(){return this._placementController||(this._placementController=new H(this)),this._placementController}get open(){return this._open}set open(e){var t;e&&this.disabled||e!==this.open&&((t=this.strategy)!=null&&t.activelyOpening&&!e||(this._open=e,this.open&&(o.openCount+=1),this.requestUpdate("open",!this.open),this.open&&this.requestSlottable()))}get state(){return this._state}set state(e){var i;if(e===this.state)return;const t=this.state;this._state=e,(this.state==="opened"||this.state==="closed")&&((i=this.strategy)==null||i.shouldCompleteOpen()),this.requestUpdate("state",t)}get elementResolver(){return this._elementResolver||(this._elementResolver=new T(this)),this._elementResolver}get popoverValue(){if("popover"in this)switch(this.type){case"modal":return"auto";case"page":return"manual";case"hint":return"manual";default:return this.type}}get requiresPositioning(){return!(this.type==="page"||!this.open||!this.triggerElement||!this.placement&&this.type!=="hint")}managePosition(){if(!this.requiresPositioning||!this.open)return;const e=this.offset||0,t=this.triggerElement,i=this.placement||"right",s=this.tipPadding;this.placementController.placeOverlay(this.dialogEl,{offset:e,placement:i,tipPadding:s,trigger:t,type:this.type})}async managePopoverOpen(){super.managePopoverOpen();const e=this.open;if(this.open!==e||(await this.manageDelay(e),this.open!==e)||(this.triggerInteraction==="longpress"&&await u(),await this.ensureOnDOM(e),this.open!==e))return;const t=await this.makeTransition(e);if(this.open===e){if(e){const i=await import("focus-trap");this._focusTrap=i.createFocusTrap(this.dialogEl,{initialFocus:t||void 0,tabbableOptions:{getShadowRoot:!0},fallbackFocus:()=>(this.dialogEl.setAttribute("tabIndex","-1"),this.dialogEl),escapeDeactivates:!1,allowOutsideClick:this.allowOutsideClick}),(this.type==="modal"||this.type==="page")&&this._focusTrap.activate()}await this.applyFocus(e,t)}}async applyFocus(e,t){if(!(this.receivesFocus==="false"||this.type==="hint")){if(await u(),await u(),e===this.open&&!this.open){this.hasNonVirtualTrigger&&this.contains(this.getRootNode().activeElement)&&this.triggerElement.focus();return}t==null||t.focus()}}returnFocus(){var t;if(this.open||this.type==="hint")return;const e=()=>{var a,p;const i=[];let s=document.activeElement;for(;(a=s==null?void 0:s.shadowRoot)!=null&&a.activeElement;)s=s.shadowRoot.activeElement;for(;s;){const h=s.assignedSlot||s.parentElement||((p=s.getRootNode())==null?void 0:p.host);h&&i.push(h),s=h}return i};this.receivesFocus!=="false"&&((t=this.triggerElement)!=null&&t.focus)&&(this.contains(this.getRootNode().activeElement)||e().includes(this)||document.activeElement===document.body)&&this.triggerElement.focus()}async manageOpen(e){var i;if(!this.isConnected&&this.open)return;this.hasUpdated||await this.updateComplete,this.open?(v.add(this),this.willPreventClose&&(document.addEventListener("pointerup",()=>{this.dialogEl.classList.toggle("not-immediately-closable",!1),this.willPreventClose=!1},{once:!0}),this.dialogEl.classList.toggle("not-immediately-closable",!0))):(e&&((i=this._focusTrap)==null||i.deactivate(),this._focusTrap=null,this.dispose()),v.remove(this)),this.open&&this.state!=="opened"?this.state="opening":!this.open&&this.state!=="closed"&&(this.state="closing"),this.managePopoverOpen();const t=this.getRootNode();this.type==="auto"&&(this.open?t.addEventListener("focusout",this.closeOnFocusOut,{capture:!0}):t.removeEventListener("focusout",this.closeOnFocusOut,{capture:!0})),(this.type==="modal"||this.type==="page")&&(this.open?t.addEventListener("cancel",this.closeOnCancelEvent,{capture:!0}):t.removeEventListener("cancel",this.closeOnCancelEvent,{capture:!0}))}bindEvents(){var e;(e=this.strategy)==null||e.abort(),this.strategy=void 0,this.hasNonVirtualTrigger&&this.triggerInteraction&&(this.strategy=new M[this.triggerInteraction](this.triggerElement,{overlay:this}))}handleBeforetoggle(e){e.newState!=="open"&&this.handleBrowserClose(e)}handleBrowserClose(e){var t;if(e.stopPropagation(),!((t=this.strategy)!=null&&t.activelyOpening)){this.open=!1;return}this.manuallyKeepOpen()}manuallyKeepOpen(){this.open=!0,this.placementController.allowPlacementUpdate=!0,this.manageOpen(!1)}handleSlotchange(){var e,t;this.elements.length?this.hasNonVirtualTrigger&&((t=this.strategy)==null||t.prepareDescription(this.triggerElement)):(e=this.strategy)==null||e.releaseDescription()}shouldPreventClose(){const e=this.willPreventClose;return this.willPreventClose=!1,e}requestSlottable(){this.lastRequestSlottableState!==this.open&&(this.open||document.body.offsetHeight,this.dispatchEvent(new N("overlay-content",this.open?{}:F)),this.lastRequestSlottableState=this.open)}willUpdate(e){var i;if(this.hasAttribute("id")||this.setAttribute("id",`${this.tagName.toLowerCase()}-${O()}`),e.has("allowOutsideClick")&&this.allowOutsideClick&&console.warn(`[${this.localName}] The "allow-outside-click" attribute has been deprecated and will be removed in a future release. We do not recommend using this attribute for accessibility reasons. It allows clicks outside the overlay to close it, which can cause unexpected behavior and accessibility issues.`),e.has("open")&&(this.hasUpdated||this.open)&&this.manageOpen(e.get("open")),e.has("trigger")){const[s,a]=((i=this.trigger)==null?void 0:i.split("@"))||[];this.elementResolver.selector=s?`#${s}`:"",this.triggerInteraction=a}let t=!1;e.has(P)&&(t=this.triggerElement,this.triggerElement=this.elementResolver.element),e.has("triggerElement")&&(t=e.get("triggerElement")),t!==!1&&this.bindEvents()}updated(e){super.updated(e),e.has("placement")&&(this.placement?this.dialogEl.setAttribute("actual-placement",this.placement):this.dialogEl.removeAttribute("actual-placement"),this.open&&typeof e.get("placement")!="undefined"&&this.placementController.resetOverlayPosition()),e.has("state")&&this.state==="closed"&&typeof e.get("state")!="undefined"&&this.placementController.clearOverlayPosition()}renderContent(){return c`
2
2
  <slot @slotchange=${this.handleSlotchange}></slot>
3
3
  `}get dialogStyleMap(){return{"--swc-overlay-open-count":o.openCount.toString()}}renderPopover(){return c`
4
4
  <div
@@ -18,5 +18,5 @@
18
18
  `}render(){return c`
19
19
  ${this.renderPopover()}
20
20
  <slot name="longpress-describedby-descriptor"></slot>
21
- `}connectedCallback(){super.connectedCallback(),this.addEventListener("close",()=>{this.open=!1}),this.hasUpdated&&this.bindEvents()}disconnectedCallback(){var e;(e=this.strategy)==null||e.releaseDescription(),this.open=!1,super.disconnectedCallback()}};o.styles=[$],o.openCount=1,r([n({type:Boolean})],o.prototype,"delayed",1),r([g(".dialog")],o.prototype,"dialogEl",2),r([n({type:Boolean})],o.prototype,"disabled",1),r([C({flatten:!0,selector:':not([slot="longpress-describedby-descriptor"], slot)'})],o.prototype,"elements",2),r([n({type:Number})],o.prototype,"offset",2),r([n({type:Boolean,reflect:!0})],o.prototype,"open",1),r([n()],o.prototype,"placement",2),r([n({attribute:"receives-focus"})],o.prototype,"receivesFocus",2),r([g("slot")],o.prototype,"slotEl",2),r([T()],o.prototype,"state",1),r([n({type:Number,attribute:"tip-padding"})],o.prototype,"tipPadding",2),r([n()],o.prototype,"trigger",2),r([n({attribute:!1})],o.prototype,"triggerElement",2),r([n({attribute:!1})],o.prototype,"triggerInteraction",2),r([n()],o.prototype,"type",2);export let Overlay=o;
21
+ `}connectedCallback(){super.connectedCallback(),this.addEventListener("close",()=>{this.open=!1}),this.hasUpdated&&this.bindEvents()}disconnectedCallback(){var e;(e=this.strategy)==null||e.releaseDescription(),this.open=!1,super.disconnectedCallback()}};o.styles=[$],o.openCount=1,r([n({type:Boolean})],o.prototype,"delayed",1),r([g(".dialog")],o.prototype,"dialogEl",2),r([n({type:Boolean})],o.prototype,"disabled",1),r([w({flatten:!0,selector:':not([slot="longpress-describedby-descriptor"], slot)'})],o.prototype,"elements",2),r([n({type:Number})],o.prototype,"offset",2),r([n({type:Boolean,reflect:!0})],o.prototype,"open",1),r([n()],o.prototype,"placement",2),r([n({attribute:"receives-focus"})],o.prototype,"receivesFocus",2),r([n({type:Boolean,attribute:"allow-outside-click"})],o.prototype,"allowOutsideClick",2),r([g("slot")],o.prototype,"slotEl",2),r([C()],o.prototype,"state",1),r([n({type:Number,attribute:"tip-padding"})],o.prototype,"tipPadding",2),r([n()],o.prototype,"trigger",2),r([n({attribute:!1})],o.prototype,"triggerElement",2),r([n({attribute:!1})],o.prototype,"triggerInteraction",2),r([n()],o.prototype,"type",2);export let Overlay=o;
22
22
  //# sourceMappingURL=Overlay.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["Overlay.ts"],
4
- "sourcesContent": ["/*\nCopyright 2023 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport {\n html,\n PropertyValues,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n query,\n queryAssignedElements,\n state,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport {\n ElementResolutionController,\n elementResolverUpdatedSymbol,\n} from '@spectrum-web-components/reactive-controllers/src/ElementResolution.js';\nimport {\n ifDefined,\n StyleInfo,\n styleMap,\n} from '@spectrum-web-components/base/src/directives.js';\nimport { randomID } from '@spectrum-web-components/shared/src/random-id.js';\nimport type {\n OpenableElement,\n OverlayState,\n OverlayTypes,\n Placement,\n TriggerInteraction,\n} from './overlay-types.js';\nimport { AbstractOverlay, nextFrame } from './AbstractOverlay.js';\nimport { OverlayPopover } from './OverlayPopover.js';\nimport { OverlayNoPopover } from './OverlayNoPopover.js';\nimport { overlayStack } from './OverlayStack.js';\nimport { VirtualTrigger } from './VirtualTrigger.js';\nimport { PlacementController } from './PlacementController.js';\nimport type { ClickController } from './ClickController.js';\nimport type { HoverController } from './HoverController.js';\nimport type { LongpressController } from './LongpressController.js';\nexport { LONGPRESS_INSTRUCTIONS } from './LongpressController.js';\nimport { strategies } from './strategies.js';\nimport {\n removeSlottableRequest,\n SlottableRequestEvent,\n} from './slottable-request-event.js';\n\nimport styles from './overlay.css.js';\nimport { FocusTrap } from 'focus-trap';\n\nconst browserSupportsPopover = 'showPopover' in document.createElement('div');\n\n// Start the base class and add the popover or no-popover functionality\nlet ComputedOverlayBase = OverlayPopover(AbstractOverlay);\nif (!browserSupportsPopover) {\n ComputedOverlayBase = OverlayNoPopover(AbstractOverlay);\n}\n\n/**\n * @element sp-overlay\n *\n * @slot default - The content that will be displayed in the overlay\n *\n * @fires sp-opened - announces that an overlay has completed any entry animations\n * @fires sp-closed - announce that an overlay has compelted any exit animations\n * @fires slottable-request - requests to add or remove slottable content\n *\n * @attr {string} placement - The placement of the overlay relative to the trigger\n * @attr {number} offset - The distance between the overlay and the trigger\n * @attr {boolean} disabled - Whether the overlay trigger is disabled\n * @attr {string} receives-focus - How focus should be handled ('true'|'false'|'auto')\n * @attr {boolean} delayed - Whether the overlay should wait for a warm-up period before opening\n * @attr {boolean} open - Whether the overlay is currently open\n */\nexport class Overlay extends ComputedOverlayBase {\n static override styles = [styles];\n\n /**\n * An Overlay that is `delayed` will wait until a warm-up period of 1000ms\n * has completed before opening. Once the warm-up period has completed, all\n * subsequent Overlays will open immediately. When no Overlays are opened,\n * a cool-down period of 1000ms will begin. Once the cool-down has completed,\n * the next Overlay to be opened will be subject to the warm-up period if\n * provided that option.\n *\n * This behavior helps to manage the performance and user experience by\n * preventing multiple overlays from opening simultaneously and ensuring\n * a smooth transition between opening and closing overlays.\n *\n * @type {boolean}\n * @default false\n */\n @property({ type: Boolean })\n override get delayed(): boolean {\n return this.elements.at(-1)?.hasAttribute('delayed') || this._delayed;\n }\n\n override set delayed(delayed: boolean) {\n this._delayed = delayed;\n }\n\n private _delayed = false;\n\n /**\n * A reference to the dialog element within the overlay.\n * This element is expected to have `showPopover` and `hidePopover` methods.\n */\n @query('.dialog')\n override dialogEl!: HTMLDialogElement & {\n showPopover(): void;\n hidePopover(): void;\n };\n\n /**\n * Indicates whether the overlay is currently functional or not.\n *\n * When set to `true`, the overlay is disabled, and any active strategy is aborted.\n * The overlay will also close if it is currently open. When set to `false`, the\n * overlay will re-bind events and re-open if it was previously open.\n *\n * @type {boolean}\n * @default false\n */\n @property({ type: Boolean })\n override get disabled(): boolean {\n return this._disabled;\n }\n\n override set disabled(disabled: boolean) {\n this._disabled = disabled;\n if (disabled) {\n // Abort any active strategy and close the overlay if it is currently open\n this.strategy?.abort();\n this.wasOpen = this.open;\n this.open = false;\n } else {\n // Re-bind events and re-open the overlay if it was previously open\n this.bindEvents();\n this.open = this.open || this.wasOpen;\n this.wasOpen = false;\n }\n }\n\n private _disabled = false;\n\n /**\n * A query to gather all elements slotted into the default slot, excluding elements\n * with the slot name \"longpress-describedby-descriptor\".\n */\n @queryAssignedElements({\n flatten: true,\n selector: ':not([slot=\"longpress-describedby-descriptor\"], slot)',\n })\n override elements!: OpenableElement[];\n\n /**\n * A reference to the parent overlay that should be force-closed, if any.\n */\n public parentOverlayToForceClose?: Overlay;\n\n /**\n * Determines if the overlay has a non-virtual trigger element.\n *\n * @returns {boolean} `true` if the trigger element is not a virtual trigger, otherwise `false`.\n */\n private get hasNonVirtualTrigger(): boolean {\n return (\n !!this.triggerElement &&\n !(this.triggerElement instanceof VirtualTrigger)\n );\n }\n\n /**\n * The `offset` property accepts either a single number to define the offset of the\n * Overlay along the main axis from the trigger, or a 2-tuple to define the offset\n * along both the main axis and the cross axis. This option has no effect when there\n * is no trigger element.\n *\n * @type {number | [number, number]}\n * @default 0\n */\n @property({ type: Number })\n override offset: number | [number, number] = 0;\n\n /**\n * Provides an instance of the `PlacementController` for managing the positioning\n * of the overlay relative to its trigger element.\n *\n * If the `PlacementController` instance does not already exist, it is created and\n * assigned to the `_placementController` property.\n *\n * @protected\n * @returns {PlacementController} The `PlacementController` instance.\n */\n protected override get placementController(): PlacementController {\n if (!this._placementController) {\n this._placementController = new PlacementController(this);\n }\n return this._placementController;\n }\n\n /**\n * Indicates whether the Overlay is projected onto the \"top layer\" or not.\n *\n * When set to `true`, the overlay is open and visible. When set to `false`, the overlay is closed and hidden.\n *\n * @type {boolean}\n * @default false\n */\n @property({ type: Boolean, reflect: true })\n override get open(): boolean {\n return this._open;\n }\n\n override set open(open: boolean) {\n // Don't respond if the overlay is disabled.\n if (open && this.disabled) return;\n\n // Don't respond if the state is not changing.\n if (open === this.open) return;\n\n // Don't respond if the overlay is in the shadow state during a longpress.\n // The shadow state occurs when the first \"click\" would normally close the popover.\n if (this.strategy?.activelyOpening && !open) return;\n\n // Update the internal _open property.\n this._open = open;\n\n // Increment the open count if the overlay is opening.\n if (this.open) {\n Overlay.openCount += 1;\n }\n\n // Request an update to re-render the component if necessary.\n this.requestUpdate('open', !this.open);\n\n // Request slottable content if the overlay is opening.\n if (this.open) {\n this.requestSlottable();\n }\n }\n\n private _open = false;\n\n /**\n * Tracks the number of overlays that have been opened.\n *\n * This static property is used to manage the stacking context of multiple overlays.\n *\n * @type {number}\n * @default 1\n */\n static openCount = 1;\n\n /**\n * Instruct the Overlay where to place itself in relationship to the trigger element.\n *\n * @type {\"top\" | \"top-start\" | \"top-end\" | \"right\" | \"right-start\" | \"right-end\" | \"bottom\" | \"bottom-start\" | \"bottom-end\" | \"left\" | \"left-start\" | \"left-end\"}\n */\n @property()\n override placement?: Placement;\n\n /**\n * The state in which the last `request-slottable` event was dispatched.\n *\n * This property ensures that overlays do not dispatch the same state twice in a row.\n *\n * @type {boolean}\n * @default false\n */\n private lastRequestSlottableState = false;\n\n /**\n * Whether to pass focus to the overlay once opened, or\n * to the appropriate value based on the \"type\" of the overlay\n * when set to `\"auto\"`.\n *\n * @type {'true' | 'false' | 'auto'}\n * @default 'auto'\n */\n @property({ attribute: 'receives-focus' })\n override receivesFocus: 'true' | 'false' | 'auto' = 'auto';\n\n /**\n * A reference to the slot element within the overlay.\n *\n * This element is used to manage the content slotted into the overlay.\n *\n * @type {HTMLSlotElement}\n */\n @query('slot')\n slotEl!: HTMLSlotElement;\n\n /**\n * The current state of the overlay.\n *\n * This property reflects the current state of the overlay, such as 'opened' or 'closed'.\n * When the state changes, it triggers the appropriate actions and updates the component.\n *\n * @type {OverlayState}\n * @default 'closed'\n */\n @state()\n override get state(): OverlayState {\n return this._state;\n }\n\n override set state(state) {\n // Do not respond if the state is not changing.\n if (state === this.state) return;\n\n const oldState = this.state;\n\n this._state = state;\n\n // Complete the opening strategy if the state is 'opened' or 'closed'.\n if (this.state === 'opened' || this.state === 'closed') {\n this.strategy?.shouldCompleteOpen();\n }\n\n // Request an update to re-render the component if necessary.\n this.requestUpdate('state', oldState);\n }\n\n override _state: OverlayState = 'closed';\n\n /**\n * The interaction strategy for opening the overlay.\n * This can be a ClickController, HoverController, or LongpressController.\n */\n public strategy?: ClickController | HoverController | LongpressController;\n\n /**\n * The padding around the tip of the overlay.\n * This property defines the padding around the tip of the overlay, which can be used to adjust its positioning.\n *\n * @type {number}\n */\n @property({ type: Number, attribute: 'tip-padding' })\n tipPadding?: number;\n\n /**\n * An optional ID reference for the trigger element combined with the optional\n * interaction (click | hover | longpress) by which the overlay should open.\n * The format is `trigger@interaction`, e.g., `trigger@click` opens the overlay\n * when an element with the ID \"trigger\" is clicked.\n *\n * @type {string}\n */\n @property()\n trigger?: string;\n\n /**\n * An element reference for the trigger element that the overlay should relate to.\n * This property is not reflected as an attribute.\n *\n * @type {HTMLElement | VirtualTrigger | null}\n */\n @property({ attribute: false })\n override triggerElement: HTMLElement | VirtualTrigger | null = null;\n\n /**\n * The specific interaction to listen for on the `triggerElement` to open the overlay.\n * This property is not reflected as an attribute.\n *\n * @type {TriggerInteraction}\n */\n @property({ attribute: false })\n triggerInteraction?: TriggerInteraction;\n\n /**\n * Configures the open/close heuristics of the Overlay.\n *\n * @type {\"auto\" | \"hint\" | \"manual\" | \"modal\" | \"page\"}\n * @default \"auto\"\n */\n @property()\n override type: OverlayTypes = 'auto';\n\n /**\n * Tracks whether the overlay was previously open.\n * This is used to restore the open state when re-enabling the overlay.\n *\n * @type {boolean}\n * @default false\n */\n protected wasOpen = false;\n\n /**\n * Focus trap to keep focus within the dialog\n * @private\n */\n private _focusTrap: FocusTrap | null = null;\n\n /**\n * Provides an instance of the `ElementResolutionController` for managing the element\n * that the overlay should be associated with. If the instance does not already exist,\n * it is created and assigned to the `_elementResolver` property.\n *\n * @protected\n * @returns {ElementResolutionController} The `ElementResolutionController` instance.\n */\n protected override get elementResolver(): ElementResolutionController {\n if (!this._elementResolver) {\n this._elementResolver = new ElementResolutionController(this);\n }\n\n return this._elementResolver;\n }\n\n /**\n * Determines the value for the popover attribute based on the overlay type.\n *\n * @private\n * @returns {'auto' | 'manual' | undefined} The popover value or undefined if not applicable.\n */\n private get popoverValue(): 'auto' | 'manual' | undefined {\n const hasPopoverAttribute = 'popover' in this;\n\n if (!hasPopoverAttribute) {\n return undefined;\n }\n\n switch (this.type) {\n case 'modal':\n return 'auto';\n case 'page':\n return 'manual';\n case 'hint':\n return 'manual';\n default:\n return this.type;\n }\n }\n\n /**\n * Determines if the overlay requires positioning based on its type and state.\n *\n * @protected\n * @returns {boolean} True if the overlay requires positioning, otherwise false.\n */\n protected get requiresPositioning(): boolean {\n // Do not position \"page\" overlays as they should block the entire UI.\n if (this.type === 'page' || !this.open) return false;\n\n // Do not position content without a trigger element, as there is nothing to position it relative to.\n // Do not automatically position content unless it is a \"hint\".\n if (!this.triggerElement || (!this.placement && this.type !== 'hint'))\n return false;\n\n return true;\n }\n\n /**\n * Manages the positioning of the overlay relative to its trigger element.\n *\n * This method calculates the necessary parameters for positioning the overlay,\n * such as offset, placement, and tip padding, and then delegates the actual\n * positioning to the `PlacementController`.\n *\n * @protected\n * @override\n */\n protected override managePosition(): void {\n // Do not proceed if positioning is not required or the overlay is not open.\n if (!this.requiresPositioning || !this.open) return;\n\n const offset = this.offset || 0;\n\n const trigger = this.triggerElement as HTMLElement;\n\n const placement = (this.placement as Placement) || 'right';\n\n const tipPadding = this.tipPadding;\n\n this.placementController.placeOverlay(this.dialogEl, {\n offset,\n placement,\n tipPadding,\n trigger,\n type: this.type,\n });\n }\n\n /**\n * Manages the process of opening the popover.\n *\n * This method handles the necessary steps to open the popover, including managing delays,\n * ensuring the popover is in the DOM, making transitions, and applying focus.\n *\n * @protected\n * @override\n * @returns {Promise<void>} A promise that resolves when the popover has been fully opened.\n */\n protected override async managePopoverOpen(): Promise<void> {\n // Call the base class method to handle any initial setup.\n super.managePopoverOpen();\n\n const targetOpenState = this.open;\n\n // Ensure the open state has not changed before proceeding.\n if (this.open !== targetOpenState) {\n return;\n }\n\n // Manage any delays before opening the popover.\n await this.manageDelay(targetOpenState);\n\n if (this.open !== targetOpenState) {\n return;\n }\n\n // Only wait for next frame if `longpress` is the trigger.\n // In Safari, awaiting nextFrame here causes layout issues\n // when rendering trays inside modals, so we skip it otherwise.\n if (this.triggerInteraction === 'longpress') {\n await nextFrame();\n }\n\n // Ensure the popover is in the DOM before proceeding.\n await this.ensureOnDOM(targetOpenState);\n\n if (this.open !== targetOpenState) {\n return;\n }\n\n // Make any necessary transitions for opening the popover.\n const focusEl = await this.makeTransition(targetOpenState);\n\n if (this.open !== targetOpenState) {\n return;\n }\n if (targetOpenState) {\n const focusTrap = await import('focus-trap');\n this._focusTrap = focusTrap.createFocusTrap(this.dialogEl, {\n initialFocus: focusEl || undefined,\n tabbableOptions: {\n getShadowRoot: true,\n },\n fallbackFocus: () => {\n // set tabIndex to -1 allow the focus-trap to still be applied\n this.dialogEl.setAttribute('tabIndex', '-1');\n return this.dialogEl;\n },\n // disable escape key capture to close the overlay, the focus-trap library captures it otherwise\n escapeDeactivates: false,\n });\n\n if (this.type === 'modal' || this.type === 'page') {\n this._focusTrap.activate();\n }\n }\n // Apply focus to the appropriate element after opening the popover.\n await this.applyFocus(targetOpenState, focusEl);\n }\n\n /**\n * Applies focus to the appropriate element after the popover has been opened.\n *\n * This method handles the focus management for the overlay, ensuring that the correct\n * element receives focus based on the overlay's type and state.\n *\n * @protected\n * @override\n * @param {boolean} targetOpenState - The target open state of the overlay.\n * @param {HTMLElement | null} focusEl - The element to focus after opening the popover.\n * @returns {Promise<void>} A promise that resolves when the focus has been applied.\n */\n protected override async applyFocus(\n targetOpenState: boolean,\n focusEl: HTMLElement | null\n ): Promise<void> {\n // Do not move focus when explicitly told not to or when the overlay is a \"hint\".\n if (this.receivesFocus === 'false' || this.type === 'hint') {\n return;\n }\n\n // Wait for the next two animation frames to ensure the DOM is updated.\n await nextFrame();\n await nextFrame();\n\n // If the open state has changed during the delay, do not proceed.\n if (targetOpenState === this.open && !this.open) {\n // If the overlay is closing and the trigger element is still focused, return focus to the trigger element.\n if (\n this.hasNonVirtualTrigger &&\n this.contains((this.getRootNode() as Document).activeElement)\n ) {\n (this.triggerElement as HTMLElement).focus();\n }\n return;\n }\n\n // Apply focus to the specified focus element.\n focusEl?.focus();\n }\n\n /**\n * Returns focus to the trigger element if the overlay is closed.\n *\n * This method ensures that focus is returned to the trigger element when the overlay is closed,\n * unless the overlay is of type \"hint\" or the focus is already outside the overlay.\n *\n * @protected\n * @override\n */\n protected override returnFocus(): void {\n // Do not proceed if the overlay is open or if the overlay type is \"hint\".\n if (this.open || this.type === 'hint') return;\n\n /**\n * Retrieves the ancestors of the currently focused element.\n *\n * @returns {HTMLElement[]} An array of ancestor elements.\n */\n const getAncestors = (): HTMLElement[] => {\n const ancestors: HTMLElement[] = [];\n\n // eslint-disable-next-line @spectrum-web-components/document-active-element\n let currentNode = document.activeElement;\n\n // Traverse the shadow DOM to find the active element.\n while (currentNode?.shadowRoot?.activeElement) {\n currentNode = currentNode.shadowRoot.activeElement;\n }\n\n // Traverse the DOM tree to collect ancestor elements.\n while (currentNode) {\n const ancestor =\n currentNode.assignedSlot ||\n currentNode.parentElement ||\n (currentNode.getRootNode() as ShadowRoot)?.host;\n if (ancestor) {\n ancestors.push(ancestor as HTMLElement);\n }\n currentNode = ancestor;\n }\n return ancestors;\n };\n\n // Check if focus should be returned to the trigger element.\n if (\n this.receivesFocus !== 'false' &&\n !!(this.triggerElement as HTMLElement)?.focus &&\n (this.contains((this.getRootNode() as Document).activeElement) ||\n getAncestors().includes(this) ||\n // eslint-disable-next-line @spectrum-web-components/document-active-element\n document.activeElement === document.body)\n ) {\n // Return focus to the trigger element.\n (this.triggerElement as HTMLElement).focus();\n }\n }\n\n /**\n * Handles the focus out event to close the overlay if the focus moves outside of it.\n *\n * This method ensures that the overlay is closed when the focus moves to an element\n * outside of the overlay, unless the focus is moved to a related element.\n *\n * @private\n * @param {FocusEvent} event - The focus out event.\n */\n private closeOnFocusOut = (event: FocusEvent): void => {\n // If the related target (newly focused element) is not known, do nothing.\n if (!event.relatedTarget) {\n return;\n }\n\n // Create a custom event to query the relationship of the newly focused element.\n const relationEvent = new Event('overlay-relation-query', {\n bubbles: true,\n composed: true,\n });\n\n // Add an event listener to the related target to handle the custom event.\n event.relatedTarget.addEventListener(\n relationEvent.type,\n (event: Event) => {\n // Check if the newly focused element is within the overlay or its children\n const path = event.composedPath();\n const isWithinOverlay = path.some((el) => el === this);\n\n // Only close if focus moves outside the overlay and its children\n if (!isWithinOverlay) {\n this.open = false;\n }\n }\n );\n\n // Dispatch the custom event to the related target.\n event.relatedTarget.dispatchEvent(relationEvent);\n };\n\n private closeOnCancelEvent = (): void => {\n this.open = false;\n };\n\n /**\n * Manages the process of opening or closing the overlay.\n *\n * This method handles the necessary steps to open or close the overlay, including updating the state,\n * managing the overlay stack, and handling focus events.\n *\n * @protected\n * @param {boolean} oldOpen - The previous open state of the overlay.\n * @returns {Promise<void>} A promise that resolves when the overlay has been fully managed.\n */\n protected async manageOpen(oldOpen: boolean): Promise<void> {\n // Prevent entering the manage workflow if the overlay is not connected to the DOM.\n // The `.showPopover()` event will error on content that is not connected to the DOM.\n if (!this.isConnected && this.open) return;\n\n // Wait for the component to finish updating if it has not already done so.\n if (!this.hasUpdated) {\n await this.updateComplete;\n }\n\n if (this.open) {\n // Add the overlay to the overlay stack.\n overlayStack.add(this);\n\n if (this.willPreventClose) {\n // Add an event listener to handle the pointerup event and toggle the 'not-immediately-closable' class.\n document.addEventListener(\n 'pointerup',\n () => {\n this.dialogEl.classList.toggle(\n 'not-immediately-closable',\n false\n );\n this.willPreventClose = false;\n },\n { once: true }\n );\n this.dialogEl.classList.toggle(\n 'not-immediately-closable',\n true\n );\n }\n } else {\n if (oldOpen) {\n this._focusTrap?.deactivate();\n this._focusTrap = null;\n // Dispose of the overlay if it was previously open.\n this.dispose();\n }\n\n // Remove the overlay from the overlay stack.\n overlayStack.remove(this);\n }\n\n // Update the state of the overlay based on the open property.\n if (this.open && this.state !== 'opened') {\n this.state = 'opening';\n } else if (!this.open && this.state !== 'closed') {\n this.state = 'closing';\n }\n\n this.managePopoverOpen();\n\n const listenerRoot = this.getRootNode() as Document;\n // Handle focus events for auto type overlays.\n if (this.type === 'auto') {\n if (this.open) {\n listenerRoot.addEventListener(\n 'focusout',\n this.closeOnFocusOut,\n { capture: true }\n );\n } else {\n listenerRoot.removeEventListener(\n 'focusout',\n this.closeOnFocusOut,\n { capture: true }\n );\n }\n }\n\n // Handle cancel events for modal and page type overlays.\n if (this.type === 'modal' || this.type === 'page') {\n if (this.open) {\n listenerRoot.addEventListener(\n 'cancel',\n this.closeOnCancelEvent,\n {\n capture: true,\n }\n );\n } else {\n listenerRoot.removeEventListener(\n 'cancel',\n this.closeOnCancelEvent,\n {\n capture: true,\n }\n );\n }\n }\n }\n\n /**\n * Binds event handling strategies to the overlay based on the specified trigger interaction.\n *\n * This method sets up the appropriate event handling strategy for the overlay, ensuring that\n * it responds correctly to user interactions such as clicks, hovers, or long presses.\n *\n * @protected\n */\n protected bindEvents(): void {\n // Abort any existing strategy to ensure a clean setup.\n this.strategy?.abort();\n this.strategy = undefined;\n\n // Return early if there is no non-virtual trigger element.\n if (!this.hasNonVirtualTrigger) return;\n\n // Return early if no trigger interaction is specified.\n if (!this.triggerInteraction) return;\n\n // Set up a new event handling strategy based on the specified trigger interaction.\n this.strategy = new strategies[this.triggerInteraction](\n this.triggerElement as HTMLElement,\n {\n overlay: this,\n }\n );\n }\n\n /**\n * Handles the `beforetoggle` event to manage the overlay's state.\n *\n * This method checks the new state of the event and calls `handleBrowserClose`\n * if the new state is not 'open'.\n *\n * @protected\n * @param {Event & { newState: string }} event - The `beforetoggle` event with the new state.\n */\n protected handleBeforetoggle(event: Event & { newState: string }): void {\n if (event.newState !== 'open') {\n this.handleBrowserClose(event);\n }\n }\n\n /**\n * Handles the browser's close event to manage the overlay's state.\n *\n * This method stops the propagation of the event and closes the overlay if it is not\n * actively opening. If the overlay is actively opening, it calls `manuallyKeepOpen`.\n *\n * @protected\n * @param {Event} event - The browser's close event.\n */\n protected handleBrowserClose(event: Event): void {\n event.stopPropagation();\n if (!this.strategy?.activelyOpening) {\n this.open = false;\n return;\n }\n this.manuallyKeepOpen();\n }\n\n /**\n * Manually keeps the overlay open.\n *\n * This method sets the overlay to open, allows placement updates, and manages the open state.\n *\n * @public\n * @override\n */\n public override manuallyKeepOpen(): void {\n this.open = true;\n this.placementController.allowPlacementUpdate = true;\n this.manageOpen(false);\n }\n\n /**\n * Handles the `slotchange` event to manage the overlay's state.\n *\n * This method checks if there are any elements in the slot. If there are no elements,\n * it releases the description from the strategy. If there are elements and the trigger\n * is non-virtual, it prepares the description for the trigger element.\n *\n * @protected\n */\n protected handleSlotchange(): void {\n if (!this.elements.length) {\n // Release the description if there are no elements in the slot.\n this.strategy?.releaseDescription();\n } else if (this.hasNonVirtualTrigger) {\n // Prepare the description for the trigger element if it is non-virtual.\n this.strategy?.prepareDescription(\n this.triggerElement as HTMLElement\n );\n }\n }\n\n /**\n * Determines whether the overlay should prevent closing.\n *\n * This method checks the `willPreventClose` flag and resets it to `false`.\n * It returns the value of the `willPreventClose` flag.\n *\n * @public\n * @returns {boolean} `true` if the overlay should prevent closing, otherwise `false`.\n */\n public shouldPreventClose(): boolean {\n const shouldPreventClose = this.willPreventClose;\n this.willPreventClose = false;\n return shouldPreventClose;\n }\n\n /**\n * Requests slottable content for the overlay.\n *\n * This method dispatches a `SlottableRequestEvent` to request or remove slottable content\n * based on the current open state of the overlay. It ensures that the same state is not\n * dispatched twice in a row.\n *\n * @protected\n * @override\n */\n protected override requestSlottable(): void {\n // Do not dispatch the same state twice in a row.\n if (this.lastRequestSlottableState === this.open) {\n return;\n }\n\n // Force a reflow if the overlay is closing.\n if (!this.open) {\n document.body.offsetHeight;\n }\n\n /**\n * @ignore\n */\n // Dispatch a custom event to request or remove slottable content based on the open state.\n this.dispatchEvent(\n new SlottableRequestEvent(\n 'overlay-content',\n this.open ? {} : removeSlottableRequest\n )\n );\n\n // Update the last request slottable state.\n this.lastRequestSlottableState = this.open;\n }\n\n /**\n * Lifecycle method called before the component updates.\n *\n * This method handles various tasks before the component updates, such as setting an ID,\n * managing the open state, resolving the trigger element, and binding events.\n *\n * @override\n * @param {PropertyValues} changes - The properties that have changed.\n */\n override willUpdate(changes: PropertyValues): void {\n // Ensure the component has an ID attribute.\n if (!this.hasAttribute('id')) {\n this.setAttribute(\n 'id',\n `${this.tagName.toLowerCase()}-${randomID()}`\n );\n }\n\n // Manage the open state if the 'open' property has changed.\n if (changes.has('open') && (this.hasUpdated || this.open)) {\n this.manageOpen(changes.get('open'));\n }\n\n // Resolve the trigger element if the 'trigger' property has changed.\n if (changes.has('trigger')) {\n const [id, interaction] = this.trigger?.split('@') || [];\n this.elementResolver.selector = id ? `#${id}` : '';\n this.triggerInteraction = interaction as\n | 'click'\n | 'longpress'\n | 'hover'\n | undefined;\n }\n\n // Initialize oldTrigger to track the previous trigger element.\n let oldTrigger: HTMLElement | false | undefined = false;\n\n // Check if the element resolver has been updated.\n if (changes.has(elementResolverUpdatedSymbol)) {\n // Store the current trigger element.\n oldTrigger = this.triggerElement as HTMLElement;\n // Update the trigger element from the element resolver.\n this.triggerElement = this.elementResolver.element;\n }\n\n // Check if the 'triggerElement' property has changed.\n if (changes.has('triggerElement')) {\n // Store the old trigger element.\n oldTrigger = changes.get('triggerElement');\n }\n\n // If the trigger element has changed, bind the new events.\n if (oldTrigger !== false) {\n this.bindEvents();\n }\n }\n\n /**\n * Lifecycle method called after the component updates.\n *\n * This method handles various tasks after the component updates, such as updating the placement\n * attribute, resetting the overlay position, and clearing the overlay position based on the state.\n *\n * @override\n * @param {PropertyValues} changes - The properties that have changed.\n */\n protected override updated(changes: PropertyValues): void {\n // Call the base class method to handle any initial setup.\n super.updated(changes);\n\n // Check if the 'placement' property has changed.\n if (changes.has('placement')) {\n if (this.placement) {\n // Set the 'actual-placement' attribute on the dialog element.\n this.dialogEl.setAttribute('actual-placement', this.placement);\n } else {\n // Remove the 'actual-placement' attribute from the dialog element.\n this.dialogEl.removeAttribute('actual-placement');\n }\n\n // If the overlay is open and the 'placement' property has changed, reset the overlay position.\n if (this.open && typeof changes.get('placement') !== 'undefined') {\n this.placementController.resetOverlayPosition();\n }\n }\n\n // Check if the 'state' property has changed and the overlay is closed.\n if (\n changes.has('state') &&\n this.state === 'closed' &&\n typeof changes.get('state') !== 'undefined'\n ) {\n // Clear the overlay position.\n this.placementController.clearOverlayPosition();\n }\n }\n\n /**\n * Renders the content of the overlay.\n *\n * This method returns a template result containing a slot element. The slot element\n * listens for the `slotchange` event to manage the overlay's state.\n *\n * @protected\n * @returns {TemplateResult} The template result containing the slot element.\n */\n protected renderContent(): TemplateResult {\n return html`\n <slot @slotchange=${this.handleSlotchange}></slot>\n `;\n }\n\n /**\n * Generates a style map for the dialog element.\n *\n * This method returns an object containing CSS custom properties for the dialog element.\n * The `--swc-overlay-open-count` custom property is set to the current open count of overlays.\n *\n * @private\n * @returns {StyleInfo} The style map for the dialog element.\n */\n private get dialogStyleMap(): StyleInfo {\n return {\n '--swc-overlay-open-count': Overlay.openCount.toString(),\n };\n }\n\n /**\n * Renders the popover element for the overlay.\n *\n * This method returns a template result containing a div element styled as a popover.\n * The popover element includes various attributes and event listeners to manage the overlay's state and behavior.\n *\n * @protected\n * @returns {TemplateResult} The template result containing the popover element.\n */\n protected renderPopover(): TemplateResult {\n /**\n * The `--swc-overlay-open-count` custom property is applied to mimic the single stack\n * nature of the top layer in browsers that do not yet support it.\n *\n * The value should always represent the total number of overlays that have ever been opened.\n * This value will be added to the `--swc-overlay-z-index-base` custom property, which can be\n * provided by a consuming developer. By default, `--swc-overlay-z-index-base` is set to 1000\n * to ensure that the overlay stacks above most other elements during fallback delivery.\n */\n return html`\n <div\n class=\"dialog\"\n part=\"dialog\"\n role=${ifDefined(\n this.type === 'modal' || this.type === 'page'\n ? 'dialog'\n : undefined\n )}\n aria-modal=${ifDefined(\n this.type === 'modal' || this.type === 'page'\n ? 'true'\n : undefined\n )}\n placement=${ifDefined(\n this.requiresPositioning\n ? this.placement || 'right'\n : undefined\n )}\n popover=${ifDefined(this.popoverValue)}\n style=${styleMap(this.dialogStyleMap)}\n @beforetoggle=${this.handleBeforetoggle}\n @close=${this.handleBrowserClose}\n ?is-visible=${this.state !== 'closed'}\n >\n ${this.renderContent()}\n </div>\n `;\n }\n\n /**\n * Renders the overlay component.\n *\n * This method returns a template result containing either a dialog or popover element\n * based on the overlay type. It also includes a slot for longpress descriptors.\n *\n * @override\n * @returns {TemplateResult} The template result containing the overlay content.\n */\n public override render(): TemplateResult {\n return html`\n ${this.renderPopover()}\n <slot name=\"longpress-describedby-descriptor\"></slot>\n `;\n }\n\n /**\n * Lifecycle method called when the component is added to the DOM.\n *\n * This method sets up event listeners and binds events if the component has already updated.\n *\n * @override\n */\n override connectedCallback(): void {\n super.connectedCallback();\n\n // Add an event listener to handle the 'close' event and update the 'open' property.\n this.addEventListener('close', () => {\n this.open = false;\n });\n\n // Bind events if the component has already updated.\n if (this.hasUpdated) {\n this.bindEvents();\n }\n }\n\n /**\n * Lifecycle method called when the component is removed from the DOM.\n *\n * This method releases the description from the strategy and updates the 'open' property.\n *\n * @override\n */\n override disconnectedCallback(): void {\n // Release the description from the strategy.\n this.strategy?.releaseDescription();\n // Update the 'open' property to false.\n this.open = false;\n super.disconnectedCallback();\n }\n}\n"],
5
- "mappings": "qNAWA,OACI,QAAAA,MAGG,gCACP,OACI,YAAAC,EACA,SAAAC,EACA,yBAAAC,EACA,SAAAC,MACG,kDACP,OACI,+BAAAC,EACA,gCAAAC,MACG,yEACP,OACI,aAAAC,EAEA,YAAAC,MACG,kDACP,OAAS,YAAAC,MAAgB,mDAQzB,OAAS,mBAAAC,EAAiB,aAAAC,MAAiB,uBAC3C,OAAS,kBAAAC,MAAsB,sBAC/B,OAAS,oBAAAC,MAAwB,wBACjC,OAAS,gBAAAC,MAAoB,oBAC7B,OAAS,kBAAAC,MAAsB,sBAC/B,OAAS,uBAAAC,MAA2B,2BAIpC,OAAS,2BAA8B,2BACvC,OAAS,cAAAC,MAAkB,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EAAA,CADRlD,EAAS,CAAE,KAAM,MAAO,CAAC,GA3GjBsB,EA4GA,sBA4BI4B,EAAA,CADZlD,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,GAvIjCsB,EAwII,oBAkDJ4B,EAAA,CADRlD,EAAS,GAzLDsB,EA0LA,yBAqBA4B,EAAA,CADRlD,EAAS,CAAE,UAAW,gBAAiB,CAAC,GA9MhCsB,EA+MA,6BAUT4B,EAAA,CADCjD,EAAM,MAAM,GAxNJqB,EAyNT,sBAYa4B,EAAA,CADZ/C,EAAM,GApOEmB,EAqOI,qBAoCb4B,EAAA,CADClD,EAAS,CAAE,KAAM,OAAQ,UAAW,aAAc,CAAC,GAxQ3CsB,EAyQT,0BAWA4B,EAAA,CADClD,EAAS,GAnRDsB,EAoRT,uBASS4B,EAAA,CADRlD,EAAS,CAAE,UAAW,EAAM,CAAC,GA5RrBsB,EA6RA,8BAST4B,EAAA,CADClD,EAAS,CAAE,UAAW,EAAM,CAAC,GArSrBsB,EAsST,kCASS4B,EAAA,CADRlD,EAAS,GA9SDsB,EA+SA,oBA/SN,WAAM,QAANA",
4
+ "sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport {\n html,\n PropertyValues,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n query,\n queryAssignedElements,\n state,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport {\n ElementResolutionController,\n elementResolverUpdatedSymbol,\n} from '@spectrum-web-components/reactive-controllers/src/ElementResolution.js';\nimport {\n ifDefined,\n StyleInfo,\n styleMap,\n} from '@spectrum-web-components/base/src/directives.js';\nimport { randomID } from '@spectrum-web-components/shared/src/random-id.js';\nimport type {\n OpenableElement,\n OverlayState,\n OverlayTypes,\n Placement,\n TriggerInteraction,\n} from './overlay-types.js';\nimport { AbstractOverlay, nextFrame } from './AbstractOverlay.js';\nimport { OverlayPopover } from './OverlayPopover.js';\nimport { OverlayNoPopover } from './OverlayNoPopover.js';\nimport { overlayStack } from './OverlayStack.js';\nimport { VirtualTrigger } from './VirtualTrigger.js';\nimport { PlacementController } from './PlacementController.js';\nimport type { ClickController } from './ClickController.js';\nimport type { HoverController } from './HoverController.js';\nimport type { LongpressController } from './LongpressController.js';\nexport { LONGPRESS_INSTRUCTIONS } from './LongpressController.js';\nimport { strategies } from './strategies.js';\nimport {\n removeSlottableRequest,\n SlottableRequestEvent,\n} from './slottable-request-event.js';\n\nimport styles from './overlay.css.js';\nimport { FocusTrap } from 'focus-trap';\n\nconst browserSupportsPopover = 'showPopover' in document.createElement('div');\n\n// Start the base class and add the popover or no-popover functionality\nlet ComputedOverlayBase = OverlayPopover(AbstractOverlay);\nif (!browserSupportsPopover) {\n ComputedOverlayBase = OverlayNoPopover(AbstractOverlay);\n}\n\n/**\n * @element sp-overlay\n *\n * @slot default - The content that will be displayed in the overlay\n *\n * @fires sp-opened - announces that an overlay has completed any entry animations\n * @fires sp-closed - announce that an overlay has compelted any exit animations\n * @fires slottable-request - requests to add or remove slottable content\n *\n * @attr {string} placement - The placement of the overlay relative to the trigger\n * @attr {number} offset - The distance between the overlay and the trigger\n * @attr {boolean} disabled - Whether the overlay trigger is disabled\n * @attr {string} receives-focus - How focus should be handled ('true'|'false'|'auto')\n * @attr {boolean} delayed - Whether the overlay should wait for a warm-up period before opening\n * @attr {boolean} open - Whether the overlay is currently open\n * @attr {boolean} allow-outside-click - @deprecated Whether clicks outside the overlay should close it (not recommended for accessibility)\n */\nexport class Overlay extends ComputedOverlayBase {\n static override styles = [styles];\n\n /**\n * An Overlay that is `delayed` will wait until a warm-up period of 1000ms\n * has completed before opening. Once the warm-up period has completed, all\n * subsequent Overlays will open immediately. When no Overlays are opened,\n * a cool-down period of 1000ms will begin. Once the cool-down has completed,\n * the next Overlay to be opened will be subject to the warm-up period if\n * provided that option.\n *\n * This behavior helps to manage the performance and user experience by\n * preventing multiple overlays from opening simultaneously and ensuring\n * a smooth transition between opening and closing overlays.\n *\n * @type {boolean}\n * @default false\n */\n @property({ type: Boolean })\n override get delayed(): boolean {\n return this.elements.at(-1)?.hasAttribute('delayed') || this._delayed;\n }\n\n override set delayed(delayed: boolean) {\n this._delayed = delayed;\n }\n\n private _delayed = false;\n\n /**\n * A reference to the dialog element within the overlay.\n * This element is expected to have `showPopover` and `hidePopover` methods.\n */\n @query('.dialog')\n override dialogEl!: HTMLDialogElement & {\n showPopover(): void;\n hidePopover(): void;\n };\n\n /**\n * Indicates whether the overlay is currently functional or not.\n *\n * When set to `true`, the overlay is disabled, and any active strategy is aborted.\n * The overlay will also close if it is currently open. When set to `false`, the\n * overlay will re-bind events and re-open if it was previously open.\n *\n * @type {boolean}\n * @default false\n */\n @property({ type: Boolean })\n override get disabled(): boolean {\n return this._disabled;\n }\n\n override set disabled(disabled: boolean) {\n this._disabled = disabled;\n if (disabled) {\n // Abort any active strategy and close the overlay if it is currently open\n this.strategy?.abort();\n this.wasOpen = this.open;\n this.open = false;\n } else {\n // Re-bind events and re-open the overlay if it was previously open\n this.bindEvents();\n this.open = this.open || this.wasOpen;\n this.wasOpen = false;\n }\n }\n\n private _disabled = false;\n\n /**\n * A query to gather all elements slotted into the default slot, excluding elements\n * with the slot name \"longpress-describedby-descriptor\".\n */\n @queryAssignedElements({\n flatten: true,\n selector: ':not([slot=\"longpress-describedby-descriptor\"], slot)',\n })\n override elements!: OpenableElement[];\n\n /**\n * A reference to the parent overlay that should be force-closed, if any.\n */\n public parentOverlayToForceClose?: Overlay;\n\n /**\n * Determines if the overlay has a non-virtual trigger element.\n *\n * @returns {boolean} `true` if the trigger element is not a virtual trigger, otherwise `false`.\n */\n private get hasNonVirtualTrigger(): boolean {\n return (\n !!this.triggerElement &&\n !(this.triggerElement instanceof VirtualTrigger)\n );\n }\n\n /**\n * The `offset` property accepts either a single number to define the offset of the\n * Overlay along the main axis from the trigger, or a 2-tuple to define the offset\n * along both the main axis and the cross axis. This option has no effect when there\n * is no trigger element.\n *\n * @type {number | [number, number]}\n * @default 0\n */\n @property({ type: Number })\n override offset: number | [number, number] = 0;\n\n /**\n * Provides an instance of the `PlacementController` for managing the positioning\n * of the overlay relative to its trigger element.\n *\n * If the `PlacementController` instance does not already exist, it is created and\n * assigned to the `_placementController` property.\n *\n * @protected\n * @returns {PlacementController} The `PlacementController` instance.\n */\n protected override get placementController(): PlacementController {\n if (!this._placementController) {\n this._placementController = new PlacementController(this);\n }\n return this._placementController;\n }\n\n /**\n * Indicates whether the Overlay is projected onto the \"top layer\" or not.\n *\n * When set to `true`, the overlay is open and visible. When set to `false`, the overlay is closed and hidden.\n *\n * @type {boolean}\n * @default false\n */\n @property({ type: Boolean, reflect: true })\n override get open(): boolean {\n return this._open;\n }\n\n override set open(open: boolean) {\n // Don't respond if the overlay is disabled.\n if (open && this.disabled) return;\n\n // Don't respond if the state is not changing.\n if (open === this.open) return;\n\n // Don't respond if the overlay is in the shadow state during a longpress.\n // The shadow state occurs when the first \"click\" would normally close the popover.\n if (this.strategy?.activelyOpening && !open) return;\n\n // Update the internal _open property.\n this._open = open;\n\n // Increment the open count if the overlay is opening.\n if (this.open) {\n Overlay.openCount += 1;\n }\n\n // Request an update to re-render the component if necessary.\n this.requestUpdate('open', !this.open);\n\n // Request slottable content if the overlay is opening.\n if (this.open) {\n this.requestSlottable();\n }\n }\n\n private _open = false;\n\n /**\n * Tracks the number of overlays that have been opened.\n *\n * This static property is used to manage the stacking context of multiple overlays.\n *\n * @type {number}\n * @default 1\n */\n static openCount = 1;\n\n /**\n * Instruct the Overlay where to place itself in relationship to the trigger element.\n *\n * @type {\"top\" | \"top-start\" | \"top-end\" | \"right\" | \"right-start\" | \"right-end\" | \"bottom\" | \"bottom-start\" | \"bottom-end\" | \"left\" | \"left-start\" | \"left-end\"}\n */\n @property()\n override placement?: Placement;\n\n /**\n * The state in which the last `request-slottable` event was dispatched.\n *\n * This property ensures that overlays do not dispatch the same state twice in a row.\n *\n * @type {boolean}\n * @default false\n */\n private lastRequestSlottableState = false;\n\n /**\n * Whether to pass focus to the overlay once opened, or\n * to the appropriate value based on the \"type\" of the overlay\n * when set to `\"auto\"`.\n *\n * @type {'true' | 'false' | 'auto'}\n * @default 'auto'\n */\n @property({ attribute: 'receives-focus' })\n override receivesFocus: 'true' | 'false' | 'auto' = 'auto';\n\n /**\n * @deprecated This property will be removed in a future version.\n * We do not recommend using this property for accessibility reasons.\n * It allows clicks outside the overlay to close it, which can cause\n * unexpected behavior and accessibility issues.\n *\n * @type {boolean}\n * @default false\n */\n @property({ type: Boolean, attribute: 'allow-outside-click' })\n allowOutsideClick = false;\n\n /**\n * A reference to the slot element within the overlay.\n *\n * This element is used to manage the content slotted into the overlay.\n *\n * @type {HTMLSlotElement}\n */\n @query('slot')\n slotEl!: HTMLSlotElement;\n\n /**\n * The current state of the overlay.\n *\n * This property reflects the current state of the overlay, such as 'opened' or 'closed'.\n * When the state changes, it triggers the appropriate actions and updates the component.\n *\n * @type {OverlayState}\n * @default 'closed'\n */\n @state()\n override get state(): OverlayState {\n return this._state;\n }\n\n override set state(state) {\n // Do not respond if the state is not changing.\n if (state === this.state) return;\n\n const oldState = this.state;\n\n this._state = state;\n\n // Complete the opening strategy if the state is 'opened' or 'closed'.\n if (this.state === 'opened' || this.state === 'closed') {\n this.strategy?.shouldCompleteOpen();\n }\n\n // Request an update to re-render the component if necessary.\n this.requestUpdate('state', oldState);\n }\n\n override _state: OverlayState = 'closed';\n\n /**\n * The interaction strategy for opening the overlay.\n * This can be a ClickController, HoverController, or LongpressController.\n */\n public strategy?: ClickController | HoverController | LongpressController;\n\n /**\n * The padding around the tip of the overlay.\n * This property defines the padding around the tip of the overlay, which can be used to adjust its positioning.\n *\n * @type {number}\n */\n @property({ type: Number, attribute: 'tip-padding' })\n tipPadding?: number;\n\n /**\n * An optional ID reference for the trigger element combined with the optional\n * interaction (click | hover | longpress) by which the overlay should open.\n * The format is `trigger@interaction`, e.g., `trigger@click` opens the overlay\n * when an element with the ID \"trigger\" is clicked.\n *\n * @type {string}\n */\n @property()\n trigger?: string;\n\n /**\n * An element reference for the trigger element that the overlay should relate to.\n * This property is not reflected as an attribute.\n *\n * @type {HTMLElement | VirtualTrigger | null}\n */\n @property({ attribute: false })\n override triggerElement: HTMLElement | VirtualTrigger | null = null;\n\n /**\n * The specific interaction to listen for on the `triggerElement` to open the overlay.\n * This property is not reflected as an attribute.\n *\n * @type {TriggerInteraction}\n */\n @property({ attribute: false })\n triggerInteraction?: TriggerInteraction;\n\n /**\n * Configures the open/close heuristics of the Overlay.\n *\n * @type {\"auto\" | \"hint\" | \"manual\" | \"modal\" | \"page\"}\n * @default \"auto\"\n */\n @property()\n override type: OverlayTypes = 'auto';\n\n /**\n * Tracks whether the overlay was previously open.\n * This is used to restore the open state when re-enabling the overlay.\n *\n * @type {boolean}\n * @default false\n */\n protected wasOpen = false;\n\n /**\n * Focus trap to keep focus within the dialog\n * @private\n */\n private _focusTrap: FocusTrap | null = null;\n\n /**\n * Provides an instance of the `ElementResolutionController` for managing the element\n * that the overlay should be associated with. If the instance does not already exist,\n * it is created and assigned to the `_elementResolver` property.\n *\n * @protected\n * @returns {ElementResolutionController} The `ElementResolutionController` instance.\n */\n protected override get elementResolver(): ElementResolutionController {\n if (!this._elementResolver) {\n this._elementResolver = new ElementResolutionController(this);\n }\n\n return this._elementResolver;\n }\n\n /**\n * Determines the value for the popover attribute based on the overlay type.\n *\n * @private\n * @returns {'auto' | 'manual' | undefined} The popover value or undefined if not applicable.\n */\n private get popoverValue(): 'auto' | 'manual' | undefined {\n const hasPopoverAttribute = 'popover' in this;\n\n if (!hasPopoverAttribute) {\n return undefined;\n }\n\n switch (this.type) {\n case 'modal':\n return 'auto';\n case 'page':\n return 'manual';\n case 'hint':\n return 'manual';\n default:\n return this.type;\n }\n }\n\n /**\n * Determines if the overlay requires positioning based on its type and state.\n *\n * @protected\n * @returns {boolean} True if the overlay requires positioning, otherwise false.\n */\n protected get requiresPositioning(): boolean {\n // Do not position \"page\" overlays as they should block the entire UI.\n if (this.type === 'page' || !this.open) return false;\n\n // Do not position content without a trigger element, as there is nothing to position it relative to.\n // Do not automatically position content unless it is a \"hint\".\n if (!this.triggerElement || (!this.placement && this.type !== 'hint'))\n return false;\n\n return true;\n }\n\n /**\n * Manages the positioning of the overlay relative to its trigger element.\n *\n * This method calculates the necessary parameters for positioning the overlay,\n * such as offset, placement, and tip padding, and then delegates the actual\n * positioning to the `PlacementController`.\n *\n * @protected\n * @override\n */\n protected override managePosition(): void {\n // Do not proceed if positioning is not required or the overlay is not open.\n if (!this.requiresPositioning || !this.open) return;\n\n const offset = this.offset || 0;\n\n const trigger = this.triggerElement as HTMLElement;\n\n const placement = (this.placement as Placement) || 'right';\n\n const tipPadding = this.tipPadding;\n\n this.placementController.placeOverlay(this.dialogEl, {\n offset,\n placement,\n tipPadding,\n trigger,\n type: this.type,\n });\n }\n\n /**\n * Manages the process of opening the popover.\n *\n * This method handles the necessary steps to open the popover, including managing delays,\n * ensuring the popover is in the DOM, making transitions, and applying focus.\n * @protected\n * @override\n * @returns {Promise<void>} A promise that resolves when the popover has been fully opened.\n */\n protected override async managePopoverOpen(): Promise<void> {\n // Call the base class method to handle any initial setup.\n super.managePopoverOpen();\n\n const targetOpenState = this.open;\n\n // Ensure the open state has not changed before proceeding.\n if (this.open !== targetOpenState) {\n return;\n }\n\n // Manage any delays before opening the popover.\n await this.manageDelay(targetOpenState);\n\n if (this.open !== targetOpenState) {\n return;\n }\n\n // Only wait for next frame if `longpress` is the trigger.\n // In Safari, awaiting nextFrame here causes layout issues\n // when rendering trays inside modals, so we skip it otherwise.\n if (this.triggerInteraction === 'longpress') {\n await nextFrame();\n }\n\n // Ensure the popover is in the DOM before proceeding.\n await this.ensureOnDOM(targetOpenState);\n\n if (this.open !== targetOpenState) {\n return;\n }\n\n // Make any necessary transitions for opening the popover.\n const focusEl = await this.makeTransition(targetOpenState);\n\n if (this.open !== targetOpenState) {\n return;\n }\n if (targetOpenState) {\n const focusTrap = await import('focus-trap');\n this._focusTrap = focusTrap.createFocusTrap(this.dialogEl, {\n initialFocus: focusEl || undefined,\n tabbableOptions: {\n getShadowRoot: true,\n },\n fallbackFocus: () => {\n // set tabIndex to -1 allow the focus-trap to still be applied\n this.dialogEl.setAttribute('tabIndex', '-1');\n return this.dialogEl;\n },\n // disable escape key capture to close the overlay, the focus-trap library captures it otherwise\n escapeDeactivates: false,\n allowOutsideClick: this.allowOutsideClick,\n });\n\n if (this.type === 'modal' || this.type === 'page') {\n this._focusTrap.activate();\n }\n }\n // Apply focus to the appropriate element after opening the popover.\n await this.applyFocus(targetOpenState, focusEl);\n }\n\n /**\n * Applies focus to the appropriate element after the popover has been opened.\n *\n * This method handles the focus management for the overlay, ensuring that the correct\n * element receives focus based on the overlay's type and state.\n *\n * @protected\n * @override\n * @param {boolean} targetOpenState - The target open state of the overlay.\n * @param {HTMLElement | null} focusEl - The element to focus after opening the popover.\n * @returns {Promise<void>} A promise that resolves when the focus has been applied.\n */\n protected override async applyFocus(\n targetOpenState: boolean,\n focusEl: HTMLElement | null\n ): Promise<void> {\n // Do not move focus when explicitly told not to or when the overlay is a \"hint\".\n if (this.receivesFocus === 'false' || this.type === 'hint') {\n return;\n }\n\n // Wait for the next two animation frames to ensure the DOM is updated.\n await nextFrame();\n await nextFrame();\n\n // If the open state has changed during the delay, do not proceed.\n if (targetOpenState === this.open && !this.open) {\n // If the overlay is closing and the trigger element is still focused, return focus to the trigger element.\n if (\n this.hasNonVirtualTrigger &&\n this.contains((this.getRootNode() as Document).activeElement)\n ) {\n (this.triggerElement as HTMLElement).focus();\n }\n return;\n }\n\n // Apply focus to the specified focus element.\n focusEl?.focus();\n }\n\n /**\n * Returns focus to the trigger element if the overlay is closed.\n *\n * This method ensures that focus is returned to the trigger element when the overlay is closed,\n * unless the overlay is of type \"hint\" or the focus is already outside the overlay.\n *\n * @protected\n * @override\n */\n protected override returnFocus(): void {\n // Do not proceed if the overlay is open or if the overlay type is \"hint\".\n if (this.open || this.type === 'hint') return;\n\n /**\n * Retrieves the ancestors of the currently focused element.\n *\n * @returns {HTMLElement[]} An array of ancestor elements.\n */\n const getAncestors = (): HTMLElement[] => {\n const ancestors: HTMLElement[] = [];\n\n // eslint-disable-next-line @spectrum-web-components/document-active-element\n let currentNode = document.activeElement;\n\n // Traverse the shadow DOM to find the active element.\n while (currentNode?.shadowRoot?.activeElement) {\n currentNode = currentNode.shadowRoot.activeElement;\n }\n\n // Traverse the DOM tree to collect ancestor elements.\n while (currentNode) {\n const ancestor =\n currentNode.assignedSlot ||\n currentNode.parentElement ||\n (currentNode.getRootNode() as ShadowRoot)?.host;\n if (ancestor) {\n ancestors.push(ancestor as HTMLElement);\n }\n currentNode = ancestor;\n }\n return ancestors;\n };\n\n // Check if focus should be returned to the trigger element.\n if (\n this.receivesFocus !== 'false' &&\n !!(this.triggerElement as HTMLElement)?.focus &&\n (this.contains((this.getRootNode() as Document).activeElement) ||\n getAncestors().includes(this) ||\n // eslint-disable-next-line @spectrum-web-components/document-active-element\n document.activeElement === document.body)\n ) {\n // Return focus to the trigger element.\n (this.triggerElement as HTMLElement).focus();\n }\n }\n\n /**\n * Handles the focus out event to close the overlay if the focus moves outside of it.\n *\n * This method ensures that the overlay is closed when the focus moves to an element\n * outside of the overlay, unless the focus is moved to a related element.\n *\n * @private\n * @param {FocusEvent} event - The focus out event.\n */\n private closeOnFocusOut = (event: FocusEvent): void => {\n // If the related target (newly focused element) is not known, do nothing.\n if (!event.relatedTarget) {\n return;\n }\n\n // Create a custom event to query the relationship of the newly focused element.\n const relationEvent = new Event('overlay-relation-query', {\n bubbles: true,\n composed: true,\n });\n\n // Add an event listener to the related target to handle the custom event.\n event.relatedTarget.addEventListener(\n relationEvent.type,\n (event: Event) => {\n // Check if the newly focused element is within the overlay or its children\n const path = event.composedPath();\n const isWithinOverlay = path.some((el) => el === this);\n\n // Only close if focus moves outside the overlay and its children\n if (!isWithinOverlay) {\n this.open = false;\n }\n }\n );\n\n // Dispatch the custom event to the related target.\n event.relatedTarget.dispatchEvent(relationEvent);\n };\n\n private closeOnCancelEvent = (): void => {\n this.open = false;\n };\n\n /**\n * Manages the process of opening or closing the overlay.\n *\n * This method handles the necessary steps to open or close the overlay, including updating the state,\n * managing the overlay stack, and handling focus events.\n *\n * @protected\n * @param {boolean} oldOpen - The previous open state of the overlay.\n * @returns {Promise<void>} A promise that resolves when the overlay has been fully managed.\n */\n protected async manageOpen(oldOpen: boolean): Promise<void> {\n // Prevent entering the manage workflow if the overlay is not connected to the DOM.\n // The `.showPopover()` event will error on content that is not connected to the DOM.\n if (!this.isConnected && this.open) return;\n\n // Wait for the component to finish updating if it has not already done so.\n if (!this.hasUpdated) {\n await this.updateComplete;\n }\n\n if (this.open) {\n // Add the overlay to the overlay stack.\n overlayStack.add(this);\n\n if (this.willPreventClose) {\n // Add an event listener to handle the pointerup event and toggle the 'not-immediately-closable' class.\n document.addEventListener(\n 'pointerup',\n () => {\n this.dialogEl.classList.toggle(\n 'not-immediately-closable',\n false\n );\n this.willPreventClose = false;\n },\n { once: true }\n );\n this.dialogEl.classList.toggle(\n 'not-immediately-closable',\n true\n );\n }\n } else {\n if (oldOpen) {\n this._focusTrap?.deactivate();\n this._focusTrap = null;\n // Dispose of the overlay if it was previously open.\n this.dispose();\n }\n\n // Remove the overlay from the overlay stack.\n overlayStack.remove(this);\n }\n\n // Update the state of the overlay based on the open property.\n if (this.open && this.state !== 'opened') {\n this.state = 'opening';\n } else if (!this.open && this.state !== 'closed') {\n this.state = 'closing';\n }\n\n this.managePopoverOpen();\n\n const listenerRoot = this.getRootNode() as Document;\n // Handle focus events for auto type overlays.\n if (this.type === 'auto') {\n if (this.open) {\n listenerRoot.addEventListener(\n 'focusout',\n this.closeOnFocusOut,\n { capture: true }\n );\n } else {\n listenerRoot.removeEventListener(\n 'focusout',\n this.closeOnFocusOut,\n { capture: true }\n );\n }\n }\n\n // Handle cancel events for modal and page type overlays.\n if (this.type === 'modal' || this.type === 'page') {\n if (this.open) {\n listenerRoot.addEventListener(\n 'cancel',\n this.closeOnCancelEvent,\n {\n capture: true,\n }\n );\n } else {\n listenerRoot.removeEventListener(\n 'cancel',\n this.closeOnCancelEvent,\n {\n capture: true,\n }\n );\n }\n }\n }\n\n /**\n * Binds event handling strategies to the overlay based on the specified trigger interaction.\n *\n * This method sets up the appropriate event handling strategy for the overlay, ensuring that\n * it responds correctly to user interactions such as clicks, hovers, or long presses.\n *\n * @protected\n */\n protected bindEvents(): void {\n // Abort any existing strategy to ensure a clean setup.\n this.strategy?.abort();\n this.strategy = undefined;\n\n // Return early if there is no non-virtual trigger element.\n if (!this.hasNonVirtualTrigger) return;\n\n // Return early if no trigger interaction is specified.\n if (!this.triggerInteraction) return;\n\n // Set up a new event handling strategy based on the specified trigger interaction.\n this.strategy = new strategies[this.triggerInteraction](\n this.triggerElement as HTMLElement,\n {\n overlay: this,\n }\n );\n }\n\n /**\n * Handles the `beforetoggle` event to manage the overlay's state.\n *\n * This method checks the new state of the event and calls `handleBrowserClose`\n * if the new state is not 'open'.\n *\n * @protected\n * @param {Event & { newState: string }} event - The `beforetoggle` event with the new state.\n */\n protected handleBeforetoggle(event: Event & { newState: string }): void {\n if (event.newState !== 'open') {\n this.handleBrowserClose(event);\n }\n }\n\n /**\n * Handles the browser's close event to manage the overlay's state.\n *\n * This method stops the propagation of the event and closes the overlay if it is not\n * actively opening. If the overlay is actively opening, it calls `manuallyKeepOpen`.\n *\n * @protected\n * @param {Event} event - The browser's close event.\n */\n protected handleBrowserClose(event: Event): void {\n event.stopPropagation();\n if (!this.strategy?.activelyOpening) {\n this.open = false;\n return;\n }\n this.manuallyKeepOpen();\n }\n\n /**\n * Manually keeps the overlay open.\n *\n * This method sets the overlay to open, allows placement updates, and manages the open state.\n *\n * @public\n * @override\n */\n public override manuallyKeepOpen(): void {\n this.open = true;\n this.placementController.allowPlacementUpdate = true;\n this.manageOpen(false);\n }\n\n /**\n * Handles the `slotchange` event to manage the overlay's state.\n *\n * This method checks if there are any elements in the slot. If there are no elements,\n * it releases the description from the strategy. If there are elements and the trigger\n * is non-virtual, it prepares the description for the trigger element.\n *\n * @protected\n */\n protected handleSlotchange(): void {\n if (!this.elements.length) {\n // Release the description if there are no elements in the slot.\n this.strategy?.releaseDescription();\n } else if (this.hasNonVirtualTrigger) {\n // Prepare the description for the trigger element if it is non-virtual.\n this.strategy?.prepareDescription(\n this.triggerElement as HTMLElement\n );\n }\n }\n\n /**\n * Determines whether the overlay should prevent closing.\n *\n * This method checks the `willPreventClose` flag and resets it to `false`.\n * It returns the value of the `willPreventClose` flag.\n *\n * @public\n * @returns {boolean} `true` if the overlay should prevent closing, otherwise `false`.\n */\n public shouldPreventClose(): boolean {\n const shouldPreventClose = this.willPreventClose;\n this.willPreventClose = false;\n return shouldPreventClose;\n }\n\n /**\n * Requests slottable content for the overlay.\n *\n * This method dispatches a `SlottableRequestEvent` to request or remove slottable content\n * based on the current open state of the overlay. It ensures that the same state is not\n * dispatched twice in a row.\n *\n * @protected\n * @override\n */\n protected override requestSlottable(): void {\n // Do not dispatch the same state twice in a row.\n if (this.lastRequestSlottableState === this.open) {\n return;\n }\n\n // Force a reflow if the overlay is closing.\n if (!this.open) {\n document.body.offsetHeight;\n }\n\n /**\n * @ignore\n */\n // Dispatch a custom event to request or remove slottable content based on the open state.\n this.dispatchEvent(\n new SlottableRequestEvent(\n 'overlay-content',\n this.open ? {} : removeSlottableRequest\n )\n );\n\n // Update the last request slottable state.\n this.lastRequestSlottableState = this.open;\n }\n\n /**\n * Lifecycle method called before the component updates.\n *\n * This method handles various tasks before the component updates, such as setting an ID,\n * managing the open state, resolving the trigger element, and binding events.\n *\n * @override\n * @param {PropertyValues} changes - The properties that have changed.\n */\n override willUpdate(changes: PropertyValues): void {\n // Ensure the component has an ID attribute.\n if (!this.hasAttribute('id')) {\n this.setAttribute(\n 'id',\n `${this.tagName.toLowerCase()}-${randomID()}`\n );\n }\n\n // Warn about deprecated allowOutsideClick property\n if (changes.has('allowOutsideClick') && this.allowOutsideClick) {\n if (window.__swc?.DEBUG) {\n window.__swc.warn(\n this,\n `The \"allow-outside-click\" attribute on <${this.localName}> has been deprecated and will be removed in a future release. We do not recommend using this attribute for accessibility reasons. It allows clicks outside the overlay to close it, which can cause unexpected behavior and accessibility issues.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/overlay/',\n { level: 'deprecation' }\n );\n } else {\n // Fallback for testing environments or when SWC is not available\n console.warn(\n `[${this.localName}] The \"allow-outside-click\" attribute has been deprecated and will be removed in a future release. We do not recommend using this attribute for accessibility reasons. It allows clicks outside the overlay to close it, which can cause unexpected behavior and accessibility issues.`\n );\n }\n }\n\n // Manage the open state if the 'open' property has changed.\n if (changes.has('open') && (this.hasUpdated || this.open)) {\n this.manageOpen(changes.get('open'));\n }\n\n // Resolve the trigger element if the 'trigger' property has changed.\n if (changes.has('trigger')) {\n const [id, interaction] = this.trigger?.split('@') || [];\n this.elementResolver.selector = id ? `#${id}` : '';\n this.triggerInteraction = interaction as\n | 'click'\n | 'longpress'\n | 'hover'\n | undefined;\n }\n\n // Initialize oldTrigger to track the previous trigger element.\n let oldTrigger: HTMLElement | false | undefined = false;\n\n // Check if the element resolver has been updated.\n if (changes.has(elementResolverUpdatedSymbol)) {\n // Store the current trigger element.\n oldTrigger = this.triggerElement as HTMLElement;\n // Update the trigger element from the element resolver.\n this.triggerElement = this.elementResolver.element;\n }\n\n // Check if the 'triggerElement' property has changed.\n if (changes.has('triggerElement')) {\n // Store the old trigger element.\n oldTrigger = changes.get('triggerElement');\n }\n\n // If the trigger element has changed, bind the new events.\n if (oldTrigger !== false) {\n this.bindEvents();\n }\n }\n\n /**\n * Lifecycle method called after the component updates.\n *\n * This method handles various tasks after the component updates, such as updating the placement\n * attribute, resetting the overlay position, and clearing the overlay position based on the state.\n *\n * @override\n * @param {PropertyValues} changes - The properties that have changed.\n */\n protected override updated(changes: PropertyValues): void {\n // Call the base class method to handle any initial setup.\n super.updated(changes);\n\n // Check if the 'placement' property has changed.\n if (changes.has('placement')) {\n if (this.placement) {\n // Set the 'actual-placement' attribute on the dialog element.\n this.dialogEl.setAttribute('actual-placement', this.placement);\n } else {\n // Remove the 'actual-placement' attribute from the dialog element.\n this.dialogEl.removeAttribute('actual-placement');\n }\n\n // If the overlay is open and the 'placement' property has changed, reset the overlay position.\n if (this.open && typeof changes.get('placement') !== 'undefined') {\n this.placementController.resetOverlayPosition();\n }\n }\n\n // Check if the 'state' property has changed and the overlay is closed.\n if (\n changes.has('state') &&\n this.state === 'closed' &&\n typeof changes.get('state') !== 'undefined'\n ) {\n // Clear the overlay position.\n this.placementController.clearOverlayPosition();\n }\n }\n\n /**\n * Renders the content of the overlay.\n *\n * This method returns a template result containing a slot element. The slot element\n * listens for the `slotchange` event to manage the overlay's state.\n *\n * @protected\n * @returns {TemplateResult} The template result containing the slot element.\n */\n protected renderContent(): TemplateResult {\n return html`\n <slot @slotchange=${this.handleSlotchange}></slot>\n `;\n }\n\n /**\n * Generates a style map for the dialog element.\n *\n * This method returns an object containing CSS custom properties for the dialog element.\n * The `--swc-overlay-open-count` custom property is set to the current open count of overlays.\n *\n * @private\n * @returns {StyleInfo} The style map for the dialog element.\n */\n private get dialogStyleMap(): StyleInfo {\n return {\n '--swc-overlay-open-count': Overlay.openCount.toString(),\n };\n }\n\n /**\n * Renders the popover element for the overlay.\n *\n * This method returns a template result containing a div element styled as a popover.\n * The popover element includes various attributes and event listeners to manage the overlay's state and behavior.\n *\n * @protected\n * @returns {TemplateResult} The template result containing the popover element.\n */\n protected renderPopover(): TemplateResult {\n /**\n * The `--swc-overlay-open-count` custom property is applied to mimic the single stack\n * nature of the top layer in browsers that do not yet support it.\n *\n * The value should always represent the total number of overlays that have ever been opened.\n * This value will be added to the `--swc-overlay-z-index-base` custom property, which can be\n * provided by a consuming developer. By default, `--swc-overlay-z-index-base` is set to 1000\n * to ensure that the overlay stacks above most other elements during fallback delivery.\n */\n return html`\n <div\n class=\"dialog\"\n part=\"dialog\"\n role=${ifDefined(\n this.type === 'modal' || this.type === 'page'\n ? 'dialog'\n : undefined\n )}\n aria-modal=${ifDefined(\n this.type === 'modal' || this.type === 'page'\n ? 'true'\n : undefined\n )}\n placement=${ifDefined(\n this.requiresPositioning\n ? this.placement || 'right'\n : undefined\n )}\n popover=${ifDefined(this.popoverValue)}\n style=${styleMap(this.dialogStyleMap)}\n @beforetoggle=${this.handleBeforetoggle}\n @close=${this.handleBrowserClose}\n ?is-visible=${this.state !== 'closed'}\n >\n ${this.renderContent()}\n </div>\n `;\n }\n\n /**\n * Renders the overlay component.\n *\n * This method returns a template result containing either a dialog or popover element\n * based on the overlay type. It also includes a slot for longpress descriptors.\n *\n * @override\n * @returns {TemplateResult} The template result containing the overlay content.\n */\n public override render(): TemplateResult {\n return html`\n ${this.renderPopover()}\n <slot name=\"longpress-describedby-descriptor\"></slot>\n `;\n }\n\n /**\n * Lifecycle method called when the component is added to the DOM.\n *\n * This method sets up event listeners and binds events if the component has already updated.\n *\n * @override\n */\n override connectedCallback(): void {\n super.connectedCallback();\n\n // Add an event listener to handle the 'close' event and update the 'open' property.\n this.addEventListener('close', () => {\n this.open = false;\n });\n\n // Bind events if the component has already updated.\n if (this.hasUpdated) {\n this.bindEvents();\n }\n }\n\n /**\n * Lifecycle method called when the component is removed from the DOM.\n *\n * This method releases the description from the strategy and updates the 'open' property.\n *\n * @override\n */\n override disconnectedCallback(): void {\n // Release the description from the strategy.\n this.strategy?.releaseDescription();\n // Update the 'open' property to false.\n this.open = false;\n super.disconnectedCallback();\n }\n}\n"],
5
+ "mappings": "qNAWA,OACI,QAAAA,MAGG,gCACP,OACI,YAAAC,EACA,SAAAC,EACA,yBAAAC,EACA,S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A2TA,oBA3TN,WAAM,QAANA",
6
6
  "names": ["html", "property", "query", "queryAssignedElements", "state", "ElementResolutionController", "elementResolverUpdatedSymbol", "ifDefined", "styleMap", "randomID", "AbstractOverlay", "nextFrame", "OverlayPopover", "OverlayNoPopover", "overlayStack", "VirtualTrigger", "PlacementController", "strategies", "removeSlottableRequest", "SlottableRequestEvent", "styles", "browserSupportsPopover", "ComputedOverlayBase", "_Overlay", "event", "relationEvent", "el", "_a", "delayed", "disabled", "open", "oldState", "offset", "trigger", "placement", "tipPadding", "targetOpenState", "focusEl", "focusTrap", "getAncestors", "_b", "ancestors", "currentNode", "ancestor", "oldOpen", "listenerRoot", "shouldPreventClose", "changes", "id", "interaction", "oldTrigger", "__decorateClass"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["OverlayNoPopover.ts"],
4
- "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport {\n firstFocusableIn,\n firstFocusableSlottedIn,\n} from '@spectrum-web-components/shared/src/first-focusable-in.js';\nimport type { SpectrumElement } from '@spectrum-web-components/base';\nimport { VirtualTrigger } from './VirtualTrigger.dev.js'\nimport { Constructor, OpenableElement } from './overlay-types.dev.js'\nimport {\n guaranteedAllTransitionend,\n nextFrame,\n overlayTimer,\n} from './AbstractOverlay.dev.js'\nimport {\n BeforetoggleClosedEvent,\n BeforetoggleOpenEvent,\n OverlayStateEvent,\n} from './events.dev.js'\nimport type { AbstractOverlay } from './AbstractOverlay.dev.js'\nimport { userFocusableSelector } from '@spectrum-web-components/shared';\n\nexport function OverlayNoPopover<T extends Constructor<AbstractOverlay>>(\n constructor: T\n): T & Constructor<SpectrumElement> {\n class OverlayWithNoPopover extends constructor {\n protected override async managePopoverOpen(): Promise<void> {\n await this.managePosition();\n }\n\n protected override async manageDelay(\n targetOpenState: boolean\n ): Promise<void> {\n if (targetOpenState === false || targetOpenState !== this.open) {\n overlayTimer.close(this);\n return;\n }\n if (this.delayed) {\n const cancelled = await overlayTimer.openTimer(this);\n if (cancelled) {\n this.open = !targetOpenState;\n }\n }\n }\n\n protected override async ensureOnDOM(\n _targetOpenState: boolean\n ): Promise<void> {\n // force the browser to paint\n document.body.offsetHeight;\n }\n\n protected override async makeTransition(\n targetOpenState: boolean\n ): Promise<HTMLElement | null> {\n if (this.open !== targetOpenState) {\n return null;\n }\n let focusEl = null as HTMLElement | null;\n const start = (el: OpenableElement, index: number) => (): void => {\n if (targetOpenState !== this.open) {\n return;\n }\n el.open = targetOpenState;\n if (index === 0) {\n const event = targetOpenState\n ? BeforetoggleOpenEvent\n : BeforetoggleClosedEvent;\n this.dispatchEvent(new event());\n }\n if (targetOpenState !== true) {\n return;\n }\n if (el.matches(userFocusableSelector)) {\n focusEl = el;\n }\n focusEl = focusEl || firstFocusableIn(el);\n if (focusEl) {\n return;\n }\n const childSlots = el.querySelectorAll('slot');\n childSlots.forEach((slot) => {\n if (!focusEl) {\n focusEl = firstFocusableSlottedIn(slot);\n }\n });\n };\n const finish =\n (el: OpenableElement, index: number) =>\n async (): Promise<void> => {\n if (this.open !== targetOpenState) {\n return;\n }\n const eventName = targetOpenState\n ? 'sp-opened'\n : 'sp-closed';\n el.dispatchEvent(\n new OverlayStateEvent(eventName, this, {\n interaction: this.type,\n })\n );\n if (index > 0) {\n return;\n }\n const hasVirtualTrigger =\n this.triggerElement instanceof VirtualTrigger;\n this.dispatchEvent(\n new OverlayStateEvent(eventName, this, {\n interaction: this.type,\n publish: hasVirtualTrigger,\n })\n );\n if (this.triggerElement && !hasVirtualTrigger) {\n (this.triggerElement as HTMLElement).dispatchEvent(\n new OverlayStateEvent(eventName, this, {\n interaction: this.type,\n publish: true,\n })\n );\n }\n this.state = targetOpenState ? 'opened' : 'closed';\n this.returnFocus();\n // Ensure layout and paint are done and the Overlay is still closed before removing the slottable request.\n await nextFrame();\n await nextFrame();\n if (\n targetOpenState === this.open &&\n targetOpenState === false\n ) {\n this.requestSlottable();\n }\n };\n this.elements.forEach((el, index) => {\n guaranteedAllTransitionend(\n el,\n start(el, index),\n finish(el, index)\n );\n });\n return focusEl;\n }\n }\n return OverlayWithNoPopover;\n}\n"],
4
+ "sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport {\n firstFocusableIn,\n firstFocusableSlottedIn,\n} from '@spectrum-web-components/shared/src/first-focusable-in.js';\nimport type { SpectrumElement } from '@spectrum-web-components/base';\nimport { VirtualTrigger } from './VirtualTrigger.dev.js'\nimport { Constructor, OpenableElement } from './overlay-types.dev.js'\nimport {\n guaranteedAllTransitionend,\n nextFrame,\n overlayTimer,\n} from './AbstractOverlay.dev.js'\nimport {\n BeforetoggleClosedEvent,\n BeforetoggleOpenEvent,\n OverlayStateEvent,\n} from './events.dev.js'\nimport type { AbstractOverlay } from './AbstractOverlay.dev.js'\nimport { userFocusableSelector } from '@spectrum-web-components/shared';\n\nexport function OverlayNoPopover<T extends Constructor<AbstractOverlay>>(\n constructor: T\n): T & Constructor<SpectrumElement> {\n class OverlayWithNoPopover extends constructor {\n protected override async managePopoverOpen(): Promise<void> {\n await this.managePosition();\n }\n\n protected override async manageDelay(\n targetOpenState: boolean\n ): Promise<void> {\n if (targetOpenState === false || targetOpenState !== this.open) {\n overlayTimer.close(this);\n return;\n }\n if (this.delayed) {\n const cancelled = await overlayTimer.openTimer(this);\n if (cancelled) {\n this.open = !targetOpenState;\n }\n }\n }\n\n protected override async ensureOnDOM(\n _targetOpenState: boolean\n ): Promise<void> {\n // force the browser to paint\n document.body.offsetHeight;\n }\n\n protected override async makeTransition(\n targetOpenState: boolean\n ): Promise<HTMLElement | null> {\n if (this.open !== targetOpenState) {\n return null;\n }\n let focusEl = null as HTMLElement | null;\n const start = (el: OpenableElement, index: number) => (): void => {\n if (targetOpenState !== this.open) {\n return;\n }\n el.open = targetOpenState;\n if (index === 0) {\n const event = targetOpenState\n ? BeforetoggleOpenEvent\n : BeforetoggleClosedEvent;\n this.dispatchEvent(new event());\n }\n if (targetOpenState !== true) {\n return;\n }\n if (el.matches(userFocusableSelector)) {\n focusEl = el;\n }\n focusEl = focusEl || firstFocusableIn(el);\n if (focusEl) {\n return;\n }\n const childSlots = el.querySelectorAll('slot');\n childSlots.forEach((slot) => {\n if (!focusEl) {\n focusEl = firstFocusableSlottedIn(slot);\n }\n });\n };\n const finish =\n (el: OpenableElement, index: number) =>\n async (): Promise<void> => {\n if (this.open !== targetOpenState) {\n return;\n }\n const eventName = targetOpenState\n ? 'sp-opened'\n : 'sp-closed';\n el.dispatchEvent(\n new OverlayStateEvent(eventName, this, {\n interaction: this.type,\n })\n );\n if (index > 0) {\n return;\n }\n const hasVirtualTrigger =\n this.triggerElement instanceof VirtualTrigger;\n this.dispatchEvent(\n new OverlayStateEvent(eventName, this, {\n interaction: this.type,\n publish: hasVirtualTrigger,\n })\n );\n if (this.triggerElement && !hasVirtualTrigger) {\n (this.triggerElement as HTMLElement).dispatchEvent(\n new OverlayStateEvent(eventName, this, {\n interaction: this.type,\n publish: true,\n })\n );\n }\n this.state = targetOpenState ? 'opened' : 'closed';\n this.returnFocus();\n // Ensure layout and paint are done and the Overlay is still closed before removing the slottable request.\n await nextFrame();\n await nextFrame();\n if (\n targetOpenState === this.open &&\n targetOpenState === false\n ) {\n this.requestSlottable();\n }\n };\n this.elements.forEach((el, index) => {\n guaranteedAllTransitionend(\n el,\n start(el, index),\n finish(el, index)\n );\n });\n return focusEl;\n }\n }\n return OverlayWithNoPopover;\n}\n"],
5
5
  "mappings": ";AAWA;AAAA,EACI;AAAA,EACA;AAAA,OACG;AAEP,SAAS,sBAAsB;AAE/B;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,OACG;AACP;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAEP,SAAS,6BAA6B;AAE/B,gBAAS,iBACZ,aACgC;AAAA,EAChC,MAAM,6BAA6B,YAAY;AAAA,IAC3C,MAAyB,oBAAmC;AACxD,YAAM,KAAK,eAAe;AAAA,IAC9B;AAAA,IAEA,MAAyB,YACrB,iBACa;AACb,UAAI,oBAAoB,SAAS,oBAAoB,KAAK,MAAM;AAC5D,qBAAa,MAAM,IAAI;AACvB;AAAA,MACJ;AACA,UAAI,KAAK,SAAS;AACd,cAAM,YAAY,MAAM,aAAa,UAAU,IAAI;AACnD,YAAI,WAAW;AACX,eAAK,OAAO,CAAC;AAAA,QACjB;AAAA,MACJ;AAAA,IACJ;AAAA,IAEA,MAAyB,YACrB,kBACa;AAEb,eAAS,KAAK;AAAA,IAClB;AAAA,IAEA,MAAyB,eACrB,iBAC2B;AAC3B,UAAI,KAAK,SAAS,iBAAiB;AAC/B,eAAO;AAAA,MACX;AACA,UAAI,UAAU;AACd,YAAM,QAAQ,CAAC,IAAqB,UAAkB,MAAY;AAC9D,YAAI,oBAAoB,KAAK,MAAM;AAC/B;AAAA,QACJ;AACA,WAAG,OAAO;AACV,YAAI,UAAU,GAAG;AACb,gBAAM,QAAQ,kBACR,wBACA;AACN,eAAK,cAAc,IAAI,MAAM,CAAC;AAAA,QAClC;AACA,YAAI,oBAAoB,MAAM;AAC1B;AAAA,QACJ;AACA,YAAI,GAAG,QAAQ,qBAAqB,GAAG;AACnC,oB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  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["OverlayNoPopover.ts"],
4
- "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport {\n firstFocusableIn,\n firstFocusableSlottedIn,\n} from '@spectrum-web-components/shared/src/first-focusable-in.js';\nimport type { SpectrumElement } from '@spectrum-web-components/base';\nimport { VirtualTrigger } from './VirtualTrigger.js';\nimport { Constructor, OpenableElement } from './overlay-types.js';\nimport {\n guaranteedAllTransitionend,\n nextFrame,\n overlayTimer,\n} from './AbstractOverlay.js';\nimport {\n BeforetoggleClosedEvent,\n BeforetoggleOpenEvent,\n OverlayStateEvent,\n} from './events.js';\nimport type { AbstractOverlay } from './AbstractOverlay.js';\nimport { userFocusableSelector } from '@spectrum-web-components/shared';\n\nexport function OverlayNoPopover<T extends Constructor<AbstractOverlay>>(\n constructor: T\n): T & Constructor<SpectrumElement> {\n class OverlayWithNoPopover extends constructor {\n protected override async managePopoverOpen(): Promise<void> {\n await this.managePosition();\n }\n\n protected override async manageDelay(\n targetOpenState: boolean\n ): Promise<void> {\n if (targetOpenState === false || targetOpenState !== this.open) {\n overlayTimer.close(this);\n return;\n }\n if (this.delayed) {\n const cancelled = await overlayTimer.openTimer(this);\n if (cancelled) {\n this.open = !targetOpenState;\n }\n }\n }\n\n protected override async ensureOnDOM(\n _targetOpenState: boolean\n ): Promise<void> {\n // force the browser to paint\n document.body.offsetHeight;\n }\n\n protected override async makeTransition(\n targetOpenState: boolean\n ): Promise<HTMLElement | null> {\n if (this.open !== targetOpenState) {\n return null;\n }\n let focusEl = null as HTMLElement | null;\n const start = (el: OpenableElement, index: number) => (): void => {\n if (targetOpenState !== this.open) {\n return;\n }\n el.open = targetOpenState;\n if (index === 0) {\n const event = targetOpenState\n ? BeforetoggleOpenEvent\n : BeforetoggleClosedEvent;\n this.dispatchEvent(new event());\n }\n if (targetOpenState !== true) {\n return;\n }\n if (el.matches(userFocusableSelector)) {\n focusEl = el;\n }\n focusEl = focusEl || firstFocusableIn(el);\n if (focusEl) {\n return;\n }\n const childSlots = el.querySelectorAll('slot');\n childSlots.forEach((slot) => {\n if (!focusEl) {\n focusEl = firstFocusableSlottedIn(slot);\n }\n });\n };\n const finish =\n (el: OpenableElement, index: number) =>\n async (): Promise<void> => {\n if (this.open !== targetOpenState) {\n return;\n }\n const eventName = targetOpenState\n ? 'sp-opened'\n : 'sp-closed';\n el.dispatchEvent(\n new OverlayStateEvent(eventName, this, {\n interaction: this.type,\n })\n );\n if (index > 0) {\n return;\n }\n const hasVirtualTrigger =\n this.triggerElement instanceof VirtualTrigger;\n this.dispatchEvent(\n new OverlayStateEvent(eventName, this, {\n interaction: this.type,\n publish: hasVirtualTrigger,\n })\n );\n if (this.triggerElement && !hasVirtualTrigger) {\n (this.triggerElement as HTMLElement).dispatchEvent(\n new OverlayStateEvent(eventName, this, {\n interaction: this.type,\n publish: true,\n })\n );\n }\n this.state = targetOpenState ? 'opened' : 'closed';\n this.returnFocus();\n // Ensure layout and paint are done and the Overlay is still closed before removing the slottable request.\n await nextFrame();\n await nextFrame();\n if (\n targetOpenState === this.open &&\n targetOpenState === false\n ) {\n this.requestSlottable();\n }\n };\n this.elements.forEach((el, index) => {\n guaranteedAllTransitionend(\n el,\n start(el, index),\n finish(el, index)\n );\n });\n return focusEl;\n }\n }\n return OverlayWithNoPopover;\n}\n"],
4
+ "sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport {\n firstFocusableIn,\n firstFocusableSlottedIn,\n} from '@spectrum-web-components/shared/src/first-focusable-in.js';\nimport type { SpectrumElement } from '@spectrum-web-components/base';\nimport { VirtualTrigger } from './VirtualTrigger.js';\nimport { Constructor, OpenableElement } from './overlay-types.js';\nimport {\n guaranteedAllTransitionend,\n nextFrame,\n overlayTimer,\n} from './AbstractOverlay.js';\nimport {\n BeforetoggleClosedEvent,\n BeforetoggleOpenEvent,\n OverlayStateEvent,\n} from './events.js';\nimport type { AbstractOverlay } from './AbstractOverlay.js';\nimport { userFocusableSelector } from '@spectrum-web-components/shared';\n\nexport function OverlayNoPopover<T extends Constructor<AbstractOverlay>>(\n constructor: T\n): T & Constructor<SpectrumElement> {\n class OverlayWithNoPopover extends constructor {\n protected override async managePopoverOpen(): Promise<void> {\n await this.managePosition();\n }\n\n protected override async manageDelay(\n targetOpenState: boolean\n ): Promise<void> {\n if (targetOpenState === false || targetOpenState !== this.open) {\n overlayTimer.close(this);\n return;\n }\n if (this.delayed) {\n const cancelled = await overlayTimer.openTimer(this);\n if (cancelled) {\n this.open = !targetOpenState;\n }\n }\n }\n\n protected override async ensureOnDOM(\n _targetOpenState: boolean\n ): Promise<void> {\n // force the browser to paint\n document.body.offsetHeight;\n }\n\n protected override async makeTransition(\n targetOpenState: boolean\n ): Promise<HTMLElement | null> {\n if (this.open !== targetOpenState) {\n return null;\n }\n let focusEl = null as HTMLElement | null;\n const start = (el: OpenableElement, index: number) => (): void => {\n if (targetOpenState !== this.open) {\n return;\n }\n el.open = targetOpenState;\n if (index === 0) {\n const event = targetOpenState\n ? BeforetoggleOpenEvent\n : BeforetoggleClosedEvent;\n this.dispatchEvent(new event());\n }\n if (targetOpenState !== true) {\n return;\n }\n if (el.matches(userFocusableSelector)) {\n focusEl = el;\n }\n focusEl = focusEl || firstFocusableIn(el);\n if (focusEl) {\n return;\n }\n const childSlots = el.querySelectorAll('slot');\n childSlots.forEach((slot) => {\n if (!focusEl) {\n focusEl = firstFocusableSlottedIn(slot);\n }\n });\n };\n const finish =\n (el: OpenableElement, index: number) =>\n async (): Promise<void> => {\n if (this.open !== targetOpenState) {\n return;\n }\n const eventName = targetOpenState\n ? 'sp-opened'\n : 'sp-closed';\n el.dispatchEvent(\n new OverlayStateEvent(eventName, this, {\n interaction: this.type,\n })\n );\n if (index > 0) {\n return;\n }\n const hasVirtualTrigger =\n this.triggerElement instanceof VirtualTrigger;\n this.dispatchEvent(\n new OverlayStateEvent(eventName, this, {\n interaction: this.type,\n publish: hasVirtualTrigger,\n })\n );\n if (this.triggerElement && !hasVirtualTrigger) {\n (this.triggerElement as HTMLElement).dispatchEvent(\n new OverlayStateEvent(eventName, this, {\n interaction: this.type,\n publish: true,\n })\n );\n }\n this.state = targetOpenState ? 'opened' : 'closed';\n this.returnFocus();\n // Ensure layout and paint are done and the Overlay is still closed before removing the slottable request.\n await nextFrame();\n await nextFrame();\n if (\n targetOpenState === this.open &&\n targetOpenState === false\n ) {\n this.requestSlottable();\n }\n };\n this.elements.forEach((el, index) => {\n guaranteedAllTransitionend(\n el,\n start(el, index),\n finish(el, index)\n );\n });\n return focusEl;\n }\n }\n return OverlayWithNoPopover;\n}\n"],
5
5
  "mappings": "aAWA,OACI,oBAAAA,EACA,2BAAAC,MACG,4DAEP,OAAS,kBAAAC,MAAsB,sBAE/B,OACI,8BAAAC,EACA,aAAAC,EACA,gBAAAC,MACG,uBACP,OACI,2BAAAC,EACA,yBAAAC,EACA,qBAAAC,MACG,cAEP,OAAS,yBAAAC,MAA6B,kCAE/B,gBAAS,iBACZC,EACgC,CAChC,MAAMC,UAA6BD,CAAY,CAC3C,MAAyB,mBAAmC,CACxD,MAAM,KAAK,eAAe,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AY,EAEjB,MAAMR,EAAU,EAChB,MAAMA,EAAU,EAEZQ,IAAoB,KAAK,MACzBA,IAAoB,IAEpB,KAAK,iBAAiB,CAE9B,EACJ,YAAK,SAAS,QAAQ,CAACI,EAAIC,IAAU,CACjCd,EACIa,EACAD,EAAMC,EAAIC,CAAK,EACfG,EAAOJ,EAAIC,CAAK,CACpB,CACJ,CAAC,EACMH,CACX,CACJ,CACA,OAAOH,CACX",
6
6
  "names": ["firstFocusableIn", "firstFocusableSlottedIn", "VirtualTrigger", "guaranteedAllTransitionend", "nextFrame", "overlayTimer", "BeforetoggleClosedEvent", "BeforetoggleOpenEvent", "OverlayStateEvent", "userFocusableSelector", "constructor", "OverlayWithNoPopover", "targetOpenState", "_targetOpenState", "focusEl", "start", "el", "index", "event", "slot", "finish", "eventName", "hasVirtualTrigger"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["OverlayPopover.ts"],
4
- "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport {\n firstFocusableIn,\n firstFocusableSlottedIn,\n} from '@spectrum-web-components/shared/src/first-focusable-in.js';\nimport type { SpectrumElement } from '@spectrum-web-components/base';\nimport { VirtualTrigger } from './VirtualTrigger.dev.js'\nimport { Constructor, OpenableElement } from './overlay-types.dev.js'\nimport {\n guaranteedAllTransitionend,\n nextFrame,\n overlayTimer,\n} from './AbstractOverlay.dev.js'\nimport {\n BeforetoggleClosedEvent,\n BeforetoggleOpenEvent,\n OverlayStateEvent,\n} from './events.dev.js'\nimport type { AbstractOverlay } from './AbstractOverlay.dev.js'\nimport { userFocusableSelector } from '@spectrum-web-components/shared';\n\nconst supportsOverlayAuto = CSS.supports('(overlay: auto)');\n\nfunction isOpen(el: HTMLElement): boolean {\n let popoverOpen = false;\n try {\n popoverOpen = el.matches(':popover-open');\n // eslint-disable-next-line no-empty\n } catch (error) {}\n let open = false;\n try {\n open = el.matches(':open');\n // eslint-disable-next-line no-empty\n } catch (error) {}\n return popoverOpen || open;\n}\n\nexport function OverlayPopover<T extends Constructor<AbstractOverlay>>(\n constructor: T\n): T & Constructor<SpectrumElement> {\n class OverlayWithPopover extends constructor {\n protected override async manageDelay(\n targetOpenState: boolean\n ): Promise<void> {\n if (targetOpenState === false || targetOpenState !== this.open) {\n overlayTimer.close(this);\n return;\n }\n if (this.delayed) {\n const cancelled = await overlayTimer.openTimer(this);\n if (cancelled) {\n this.open = !targetOpenState;\n }\n }\n }\n\n /**\n * A popover should be hidden _after_ it is no longer on top-layer because\n * the position metrics will have changed from when it was originally positioned.\n */\n private async shouldHidePopover(\n targetOpenState: boolean\n ): Promise<void> {\n if (targetOpenState && this.open !== targetOpenState) {\n return;\n }\n const update = async ({\n newState,\n }: { newState?: string } = {}): Promise<void> => {\n if (newState === 'open') {\n return;\n }\n // When in a parent Overlay, this Overlay may need to position itself\n // while closing in due to the parent _also_ closing which means the\n // location can no longer rely on \"top layer over transform\" math.\n await this.placementController.resetOverlayPosition();\n };\n if (!isOpen(this.dialogEl)) {\n // The means the Overlay was closed from the outside, it is already off of top-layer\n // so we need to position it in regards to this new state.\n update();\n return;\n }\n // `toggle` is an async event, so it's possible for this handler to run a frame late\n this.dialogEl.addEventListener('toggle', update as EventListener, {\n once: true,\n });\n }\n\n private shouldShowPopover(targetOpenState: boolean): void {\n let popoverOpen = false;\n try {\n popoverOpen = this.dialogEl.matches(':popover-open');\n // eslint-disable-next-line no-empty\n } catch (error) {}\n let open = false;\n try {\n open = this.dialogEl.matches(':open');\n // eslint-disable-next-line no-empty\n } catch (error) {}\n if (\n targetOpenState &&\n this.open === targetOpenState &&\n !popoverOpen &&\n !open &&\n this.isConnected\n ) {\n this.dialogEl.showPopover();\n this.managePosition();\n }\n }\n\n protected override async ensureOnDOM(\n targetOpenState: boolean\n ): Promise<void> {\n if (!supportsOverlayAuto) {\n await this.shouldHidePopover(targetOpenState);\n }\n this.shouldShowPopover(targetOpenState);\n await nextFrame();\n }\n\n protected override async makeTransition(\n targetOpenState: boolean\n ): Promise<HTMLElement | null> {\n if (this.open !== targetOpenState) {\n return null;\n }\n let focusEl = null as HTMLElement | null;\n const start = (el: OpenableElement, index: number) => (): void => {\n el.open = targetOpenState;\n if (index === 0) {\n const event = targetOpenState\n ? BeforetoggleOpenEvent\n : BeforetoggleClosedEvent;\n this.dispatchEvent(new event());\n }\n if (!targetOpenState) {\n return;\n }\n if (el.matches(userFocusableSelector)) {\n focusEl = el;\n }\n focusEl = focusEl || firstFocusableIn(el);\n if (focusEl) {\n return;\n }\n const childSlots = el.querySelectorAll('slot');\n childSlots.forEach((slot) => {\n if (!focusEl) {\n focusEl = firstFocusableSlottedIn(slot);\n }\n });\n };\n const finish =\n (el: OpenableElement, index: number) =>\n async (): Promise<void> => {\n if (this.open !== targetOpenState) {\n return;\n }\n const eventName = targetOpenState\n ? 'sp-opened'\n : 'sp-closed';\n if (index > 0) {\n el.dispatchEvent(\n new OverlayStateEvent(eventName, this, {\n interaction: this.type,\n publish: false,\n })\n );\n return;\n }\n const reportChange = async (): Promise<void> => {\n if (this.open !== targetOpenState) {\n return;\n }\n await nextFrame();\n const hasVirtualTrigger =\n this.triggerElement instanceof VirtualTrigger;\n this.dispatchEvent(\n new OverlayStateEvent(eventName, this, {\n interaction: this.type,\n publish: hasVirtualTrigger,\n })\n );\n el.dispatchEvent(\n new OverlayStateEvent(eventName, this, {\n interaction: this.type,\n publish: false,\n })\n );\n if (this.triggerElement && !hasVirtualTrigger) {\n (this.triggerElement as HTMLElement).dispatchEvent(\n new OverlayStateEvent(eventName, this, {\n interaction: this.type,\n publish: true,\n })\n );\n }\n this.state = targetOpenState ? 'opened' : 'closed';\n this.returnFocus();\n // Ensure layout and paint are done and the Overlay is still closed before removing the slottable request.\n await nextFrame();\n await nextFrame();\n if (\n targetOpenState === this.open &&\n targetOpenState === false\n ) {\n this.requestSlottable();\n }\n };\n if (this.open !== targetOpenState) {\n return;\n }\n const open = isOpen(this.dialogEl);\n if (targetOpenState !== true && open && this.isConnected) {\n this.dialogEl.addEventListener(\n 'beforetoggle',\n () => {\n reportChange();\n },\n { once: true }\n );\n this.dialogEl.hidePopover();\n } else {\n reportChange();\n }\n };\n this.elements.forEach((el, index) => {\n guaranteedAllTransitionend(\n el,\n start(el, index),\n finish(el, index)\n );\n });\n return focusEl;\n }\n }\n return OverlayWithPopover;\n}\n"],
4
+ "sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport {\n firstFocusableIn,\n firstFocusableSlottedIn,\n} from '@spectrum-web-components/shared/src/first-focusable-in.js';\nimport type { SpectrumElement } from '@spectrum-web-components/base';\nimport { VirtualTrigger } from './VirtualTrigger.dev.js'\nimport { Constructor, OpenableElement } from './overlay-types.dev.js'\nimport {\n guaranteedAllTransitionend,\n nextFrame,\n overlayTimer,\n} from './AbstractOverlay.dev.js'\nimport {\n BeforetoggleClosedEvent,\n BeforetoggleOpenEvent,\n OverlayStateEvent,\n} from './events.dev.js'\nimport type { AbstractOverlay } from './AbstractOverlay.dev.js'\nimport { userFocusableSelector } from '@spectrum-web-components/shared';\n\nconst supportsOverlayAuto = CSS.supports('(overlay: auto)');\n\nfunction isOpen(el: HTMLElement): boolean {\n let popoverOpen = false;\n try {\n popoverOpen = el.matches(':popover-open');\n // eslint-disable-next-line no-empty\n } catch (error) {}\n let open = false;\n try {\n open = el.matches(':open');\n // eslint-disable-next-line no-empty\n } catch (error) {}\n return popoverOpen || open;\n}\n\nexport function OverlayPopover<T extends Constructor<AbstractOverlay>>(\n constructor: T\n): T & Constructor<SpectrumElement> {\n class OverlayWithPopover extends constructor {\n protected override async manageDelay(\n targetOpenState: boolean\n ): Promise<void> {\n if (targetOpenState === false || targetOpenState !== this.open) {\n overlayTimer.close(this);\n return;\n }\n if (this.delayed) {\n const cancelled = await overlayTimer.openTimer(this);\n if (cancelled) {\n this.open = !targetOpenState;\n }\n }\n }\n\n /**\n * A popover should be hidden _after_ it is no longer on top-layer because\n * the position metrics will have changed from when it was originally positioned.\n */\n private async shouldHidePopover(\n targetOpenState: boolean\n ): Promise<void> {\n if (targetOpenState && this.open !== targetOpenState) {\n return;\n }\n const update = async ({\n newState,\n }: { newState?: string } = {}): Promise<void> => {\n if (newState === 'open') {\n return;\n }\n // When in a parent Overlay, this Overlay may need to position itself\n // while closing in due to the parent _also_ closing which means the\n // location can no longer rely on \"top layer over transform\" math.\n await this.placementController.resetOverlayPosition();\n };\n if (!isOpen(this.dialogEl)) {\n // The means the Overlay was closed from the outside, it is already off of top-layer\n // so we need to position it in regards to this new state.\n update();\n return;\n }\n // `toggle` is an async event, so it's possible for this handler to run a frame late\n this.dialogEl.addEventListener('toggle', update as EventListener, {\n once: true,\n });\n }\n\n private shouldShowPopover(targetOpenState: boolean): void {\n let popoverOpen = false;\n try {\n popoverOpen = this.dialogEl.matches(':popover-open');\n // eslint-disable-next-line no-empty\n } catch (error) {}\n let open = false;\n try {\n open = this.dialogEl.matches(':open');\n // eslint-disable-next-line no-empty\n } catch (error) {}\n if (\n targetOpenState &&\n this.open === targetOpenState &&\n !popoverOpen &&\n !open &&\n this.isConnected\n ) {\n this.dialogEl.showPopover();\n this.managePosition();\n }\n }\n\n protected override async ensureOnDOM(\n targetOpenState: boolean\n ): Promise<void> {\n if (!supportsOverlayAuto) {\n await this.shouldHidePopover(targetOpenState);\n }\n this.shouldShowPopover(targetOpenState);\n await nextFrame();\n }\n\n protected override async makeTransition(\n targetOpenState: boolean\n ): Promise<HTMLElement | null> {\n if (this.open !== targetOpenState) {\n return null;\n }\n let focusEl = null as HTMLElement | null;\n const start = (el: OpenableElement, index: number) => (): void => {\n el.open = targetOpenState;\n if (index === 0) {\n const event = targetOpenState\n ? BeforetoggleOpenEvent\n : BeforetoggleClosedEvent;\n this.dispatchEvent(new event());\n }\n if (!targetOpenState) {\n return;\n }\n if (el.matches(userFocusableSelector)) {\n focusEl = el;\n }\n focusEl = focusEl || firstFocusableIn(el);\n if (focusEl) {\n return;\n }\n const childSlots = el.querySelectorAll('slot');\n childSlots.forEach((slot) => {\n if (!focusEl) {\n focusEl = firstFocusableSlottedIn(slot);\n }\n });\n };\n const finish =\n (el: OpenableElement, index: number) =>\n async (): Promise<void> => {\n if (this.open !== targetOpenState) {\n return;\n }\n const eventName = targetOpenState\n ? 'sp-opened'\n : 'sp-closed';\n if (index > 0) {\n el.dispatchEvent(\n new OverlayStateEvent(eventName, this, {\n interaction: this.type,\n publish: false,\n })\n );\n return;\n }\n const reportChange = async (): Promise<void> => {\n if (this.open !== targetOpenState) {\n return;\n }\n await nextFrame();\n const hasVirtualTrigger =\n this.triggerElement instanceof VirtualTrigger;\n this.dispatchEvent(\n new OverlayStateEvent(eventName, this, {\n interaction: this.type,\n publish: hasVirtualTrigger,\n })\n );\n el.dispatchEvent(\n new OverlayStateEvent(eventName, this, {\n interaction: this.type,\n publish: false,\n })\n );\n if (this.triggerElement && !hasVirtualTrigger) {\n (this.triggerElement as HTMLElement).dispatchEvent(\n new OverlayStateEvent(eventName, this, {\n interaction: this.type,\n publish: true,\n })\n );\n }\n this.state = targetOpenState ? 'opened' : 'closed';\n this.returnFocus();\n // Ensure layout and paint are done and the Overlay is still closed before removing the slottable request.\n await nextFrame();\n await nextFrame();\n if (\n targetOpenState === this.open &&\n targetOpenState === false\n ) {\n this.requestSlottable();\n }\n };\n if (this.open !== targetOpenState) {\n return;\n }\n const open = isOpen(this.dialogEl);\n if (targetOpenState !== true && open && this.isConnected) {\n this.dialogEl.addEventListener(\n 'beforetoggle',\n () => {\n reportChange();\n },\n { once: true }\n );\n this.dialogEl.hidePopover();\n } else {\n reportChange();\n }\n };\n this.elements.forEach((el, index) => {\n guaranteedAllTransitionend(\n el,\n start(el, index),\n finish(el, index)\n );\n });\n return focusEl;\n }\n }\n return OverlayWithPopover;\n}\n"],
5
5
  "mappings": ";AAWA;AAAA,EACI;AAAA,EACA;AAAA,OACG;AAEP,SAAS,sBAAsB;AAE/B;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,OACG;AACP;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAEP,SAAS,6BAA6B;AAEtC,MAAM,sBAAsB,IAAI,SAAS,iBAAiB;AAE1D,SAAS,OAAO,IAA0B;AACtC,MAAI,cAAc;AAClB,MAAI;AACA,kBAAc,GAAG,QAAQ,eAAe;AAAA,EAE5C,SAAS,OAAO;AAAA,EAAC;AACjB,MAAI,OAAO;AACX,MAAI;AACA,WAAO,GAAG,QAAQ,OAAO;AAAA,EAE7B,SAAS,OAAO;AAAA,EAAC;AACjB,SAAO,eAAe;AAC1B;AAEO,gBAAS,eACZ,aACgC;AAAA,EAChC,MAAM,2BAA2B,YAAY;AAAA,IACzC,MAAyB,YACrB,iBACa;AACb,UAAI,oBAAoB,SAAS,oBAAoB,KAAK,MAAM;AAC5D,qBAAa,MAAM,IAAI;AACvB;AAAA,MACJ;AACA,UAAI,KAAK,SAAS;AACd,cAAM,YAAY,MAAM,aAAa,UAAU,IAAI;AACnD,YAAI,WAAW;AACX,eAAK,OAAO,CAAC;AAAA,QACjB;AAAA,MACJ;AAAA,IACJ;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,MAAc,kBACV,iBACa;AACb,UAAI,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oB,OACtB;AACE,iBAAK,iBAAiB;AAAA,UAC1B;AAAA,QACJ;AACA,YAAI,KAAK,SAAS,iBAAiB;AAC/B;AAAA,QACJ;AACA,cAAM,OAAO,OAAO,KAAK,QAAQ;AACjC,YAAI,oBAAoB,QAAQ,QAAQ,KAAK,aAAa;AACtD,eAAK,SAAS;AAAA,YACV;AAAA,YACA,MAAM;AACF,2BAAa;AAAA,YACjB;AAAA,YACA,EAAE,MAAM,KAAK;AAAA,UACjB;AACA,eAAK,SAAS,YAAY;AAAA,QAC9B,OAAO;AACH,uBAAa;AAAA,QACjB;AAAA,MACJ;AACJ,WAAK,SAAS,QAAQ,CAAC,IAAI,UAAU;AACjC;AAAA,UACI;AAAA,UACA,MAAM,IAAI,KAAK;AAAA,UACf,OAAO,IAAI,KAAK;AAAA,QACpB;AAAA,MACJ,CAAC;AACD,aAAO;AAAA,IACX;AAAA,EACJ;AACA,SAAO;AACX;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["OverlayPopover.ts"],
4
- "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport {\n firstFocusableIn,\n firstFocusableSlottedIn,\n} from '@spectrum-web-components/shared/src/first-focusable-in.js';\nimport type { SpectrumElement } from '@spectrum-web-components/base';\nimport { VirtualTrigger } from './VirtualTrigger.js';\nimport { Constructor, OpenableElement } from './overlay-types.js';\nimport {\n guaranteedAllTransitionend,\n nextFrame,\n overlayTimer,\n} from './AbstractOverlay.js';\nimport {\n BeforetoggleClosedEvent,\n BeforetoggleOpenEvent,\n OverlayStateEvent,\n} from './events.js';\nimport type { AbstractOverlay } from './AbstractOverlay.js';\nimport { userFocusableSelector } from '@spectrum-web-components/shared';\n\nconst supportsOverlayAuto = CSS.supports('(overlay: auto)');\n\nfunction isOpen(el: HTMLElement): boolean {\n let popoverOpen = false;\n try {\n popoverOpen = el.matches(':popover-open');\n // eslint-disable-next-line no-empty\n } catch (error) {}\n let open = false;\n try {\n open = el.matches(':open');\n // eslint-disable-next-line no-empty\n } catch (error) {}\n return popoverOpen || open;\n}\n\nexport function OverlayPopover<T extends Constructor<AbstractOverlay>>(\n constructor: T\n): T & Constructor<SpectrumElement> {\n class OverlayWithPopover extends constructor {\n protected override async manageDelay(\n targetOpenState: boolean\n ): Promise<void> {\n if (targetOpenState === false || targetOpenState !== this.open) {\n overlayTimer.close(this);\n return;\n }\n if (this.delayed) {\n const cancelled = await overlayTimer.openTimer(this);\n if (cancelled) {\n this.open = !targetOpenState;\n }\n }\n }\n\n /**\n * A popover should be hidden _after_ it is no longer on top-layer because\n * the position metrics will have changed from when it was originally positioned.\n */\n private async shouldHidePopover(\n targetOpenState: boolean\n ): Promise<void> {\n if (targetOpenState && this.open !== targetOpenState) {\n return;\n }\n const update = async ({\n newState,\n }: { newState?: string } = {}): Promise<void> => {\n if (newState === 'open') {\n return;\n }\n // When in a parent Overlay, this Overlay may need to position itself\n // while closing in due to the parent _also_ closing which means the\n // location can no longer rely on \"top layer over transform\" math.\n await this.placementController.resetOverlayPosition();\n };\n if (!isOpen(this.dialogEl)) {\n // The means the Overlay was closed from the outside, it is already off of top-layer\n // so we need to position it in regards to this new state.\n update();\n return;\n }\n // `toggle` is an async event, so it's possible for this handler to run a frame late\n this.dialogEl.addEventListener('toggle', update as EventListener, {\n once: true,\n });\n }\n\n private shouldShowPopover(targetOpenState: boolean): void {\n let popoverOpen = false;\n try {\n popoverOpen = this.dialogEl.matches(':popover-open');\n // eslint-disable-next-line no-empty\n } catch (error) {}\n let open = false;\n try {\n open = this.dialogEl.matches(':open');\n // eslint-disable-next-line no-empty\n } catch (error) {}\n if (\n targetOpenState &&\n this.open === targetOpenState &&\n !popoverOpen &&\n !open &&\n this.isConnected\n ) {\n this.dialogEl.showPopover();\n this.managePosition();\n }\n }\n\n protected override async ensureOnDOM(\n targetOpenState: boolean\n ): Promise<void> {\n if (!supportsOverlayAuto) {\n await this.shouldHidePopover(targetOpenState);\n }\n this.shouldShowPopover(targetOpenState);\n await nextFrame();\n }\n\n protected override async makeTransition(\n targetOpenState: boolean\n ): Promise<HTMLElement | null> {\n if (this.open !== targetOpenState) {\n return null;\n }\n let focusEl = null as HTMLElement | null;\n const start = (el: OpenableElement, index: number) => (): void => {\n el.open = targetOpenState;\n if (index === 0) {\n const event = targetOpenState\n ? BeforetoggleOpenEvent\n : BeforetoggleClosedEvent;\n this.dispatchEvent(new event());\n }\n if (!targetOpenState) {\n return;\n }\n if (el.matches(userFocusableSelector)) {\n focusEl = el;\n }\n focusEl = focusEl || firstFocusableIn(el);\n if (focusEl) {\n return;\n }\n const childSlots = el.querySelectorAll('slot');\n childSlots.forEach((slot) => {\n if (!focusEl) {\n focusEl = firstFocusableSlottedIn(slot);\n }\n });\n };\n const finish =\n (el: OpenableElement, index: number) =>\n async (): Promise<void> => {\n if (this.open !== targetOpenState) {\n return;\n }\n const eventName = targetOpenState\n ? 'sp-opened'\n : 'sp-closed';\n if (index > 0) {\n el.dispatchEvent(\n new OverlayStateEvent(eventName, this, {\n interaction: this.type,\n publish: false,\n })\n );\n return;\n }\n const reportChange = async (): Promise<void> => {\n if (this.open !== targetOpenState) {\n return;\n }\n await nextFrame();\n const hasVirtualTrigger =\n this.triggerElement instanceof VirtualTrigger;\n this.dispatchEvent(\n new OverlayStateEvent(eventName, this, {\n interaction: this.type,\n publish: hasVirtualTrigger,\n })\n );\n el.dispatchEvent(\n new OverlayStateEvent(eventName, this, {\n interaction: this.type,\n publish: false,\n })\n );\n if (this.triggerElement && !hasVirtualTrigger) {\n (this.triggerElement as HTMLElement).dispatchEvent(\n new OverlayStateEvent(eventName, this, {\n interaction: this.type,\n publish: true,\n })\n );\n }\n this.state = targetOpenState ? 'opened' : 'closed';\n this.returnFocus();\n // Ensure layout and paint are done and the Overlay is still closed before removing the slottable request.\n await nextFrame();\n await nextFrame();\n if (\n targetOpenState === this.open &&\n targetOpenState === false\n ) {\n this.requestSlottable();\n }\n };\n if (this.open !== targetOpenState) {\n return;\n }\n const open = isOpen(this.dialogEl);\n if (targetOpenState !== true && open && this.isConnected) {\n this.dialogEl.addEventListener(\n 'beforetoggle',\n () => {\n reportChange();\n },\n { once: true }\n );\n this.dialogEl.hidePopover();\n } else {\n reportChange();\n }\n };\n this.elements.forEach((el, index) => {\n guaranteedAllTransitionend(\n el,\n start(el, index),\n finish(el, index)\n );\n });\n return focusEl;\n }\n }\n return OverlayWithPopover;\n}\n"],
4
+ "sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport {\n firstFocusableIn,\n firstFocusableSlottedIn,\n} from '@spectrum-web-components/shared/src/first-focusable-in.js';\nimport type { SpectrumElement } from '@spectrum-web-components/base';\nimport { VirtualTrigger } from './VirtualTrigger.js';\nimport { Constructor, OpenableElement } from './overlay-types.js';\nimport {\n guaranteedAllTransitionend,\n nextFrame,\n overlayTimer,\n} from './AbstractOverlay.js';\nimport {\n BeforetoggleClosedEvent,\n BeforetoggleOpenEvent,\n OverlayStateEvent,\n} from './events.js';\nimport type { AbstractOverlay } from './AbstractOverlay.js';\nimport { userFocusableSelector } from '@spectrum-web-components/shared';\n\nconst supportsOverlayAuto = CSS.supports('(overlay: auto)');\n\nfunction isOpen(el: HTMLElement): boolean {\n let popoverOpen = false;\n try {\n popoverOpen = el.matches(':popover-open');\n // eslint-disable-next-line no-empty\n } catch (error) {}\n let open = false;\n try {\n open = el.matches(':open');\n // eslint-disable-next-line no-empty\n } catch (error) {}\n return popoverOpen || open;\n}\n\nexport function OverlayPopover<T extends Constructor<AbstractOverlay>>(\n constructor: T\n): T & Constructor<SpectrumElement> {\n class OverlayWithPopover extends constructor {\n protected override async manageDelay(\n targetOpenState: boolean\n ): Promise<void> {\n if (targetOpenState === false || targetOpenState !== this.open) {\n overlayTimer.close(this);\n return;\n }\n if (this.delayed) {\n const cancelled = await overlayTimer.openTimer(this);\n if (cancelled) {\n this.open = !targetOpenState;\n }\n }\n }\n\n /**\n * A popover should be hidden _after_ it is no longer on top-layer because\n * the position metrics will have changed from when it was originally positioned.\n */\n private async shouldHidePopover(\n targetOpenState: boolean\n ): Promise<void> {\n if (targetOpenState && this.open !== targetOpenState) {\n return;\n }\n const update = async ({\n newState,\n }: { newState?: string } = {}): Promise<void> => {\n if (newState === 'open') {\n return;\n }\n // When in a parent Overlay, this Overlay may need to position itself\n // while closing in due to the parent _also_ closing which means the\n // location can no longer rely on \"top layer over transform\" math.\n await this.placementController.resetOverlayPosition();\n };\n if (!isOpen(this.dialogEl)) {\n // The means the Overlay was closed from the outside, it is already off of top-layer\n // so we need to position it in regards to this new state.\n update();\n return;\n }\n // `toggle` is an async event, so it's possible for this handler to run a frame late\n this.dialogEl.addEventListener('toggle', update as EventListener, {\n once: true,\n });\n }\n\n private shouldShowPopover(targetOpenState: boolean): void {\n let popoverOpen = false;\n try {\n popoverOpen = this.dialogEl.matches(':popover-open');\n // eslint-disable-next-line no-empty\n } catch (error) {}\n let open = false;\n try {\n open = this.dialogEl.matches(':open');\n // eslint-disable-next-line no-empty\n } catch (error) {}\n if (\n targetOpenState &&\n this.open === targetOpenState &&\n !popoverOpen &&\n !open &&\n this.isConnected\n ) {\n this.dialogEl.showPopover();\n this.managePosition();\n }\n }\n\n protected override async ensureOnDOM(\n targetOpenState: boolean\n ): Promise<void> {\n if (!supportsOverlayAuto) {\n await this.shouldHidePopover(targetOpenState);\n }\n this.shouldShowPopover(targetOpenState);\n await nextFrame();\n }\n\n protected override async makeTransition(\n targetOpenState: boolean\n ): Promise<HTMLElement | null> {\n if (this.open !== targetOpenState) {\n return null;\n }\n let focusEl = null as HTMLElement | null;\n const start = (el: OpenableElement, index: number) => (): void => {\n el.open = targetOpenState;\n if (index === 0) {\n const event = targetOpenState\n ? BeforetoggleOpenEvent\n : BeforetoggleClosedEvent;\n this.dispatchEvent(new event());\n }\n if (!targetOpenState) {\n return;\n }\n if (el.matches(userFocusableSelector)) {\n focusEl = el;\n }\n focusEl = focusEl || firstFocusableIn(el);\n if (focusEl) {\n return;\n }\n const childSlots = el.querySelectorAll('slot');\n childSlots.forEach((slot) => {\n if (!focusEl) {\n focusEl = firstFocusableSlottedIn(slot);\n }\n });\n };\n const finish =\n (el: OpenableElement, index: number) =>\n async (): Promise<void> => {\n if (this.open !== targetOpenState) {\n return;\n }\n const eventName = targetOpenState\n ? 'sp-opened'\n : 'sp-closed';\n if (index > 0) {\n el.dispatchEvent(\n new OverlayStateEvent(eventName, this, {\n interaction: this.type,\n publish: false,\n })\n );\n return;\n }\n const reportChange = async (): Promise<void> => {\n if (this.open !== targetOpenState) {\n return;\n }\n await nextFrame();\n const hasVirtualTrigger =\n this.triggerElement instanceof VirtualTrigger;\n this.dispatchEvent(\n new OverlayStateEvent(eventName, this, {\n interaction: this.type,\n publish: hasVirtualTrigger,\n })\n );\n el.dispatchEvent(\n new OverlayStateEvent(eventName, this, {\n interaction: this.type,\n publish: false,\n })\n );\n if (this.triggerElement && !hasVirtualTrigger) {\n (this.triggerElement as HTMLElement).dispatchEvent(\n new OverlayStateEvent(eventName, this, {\n interaction: this.type,\n publish: true,\n })\n );\n }\n this.state = targetOpenState ? 'opened' : 'closed';\n this.returnFocus();\n // Ensure layout and paint are done and the Overlay is still closed before removing the slottable request.\n await nextFrame();\n await nextFrame();\n if (\n targetOpenState === this.open &&\n targetOpenState === false\n ) {\n this.requestSlottable();\n }\n };\n if (this.open !== targetOpenState) {\n return;\n }\n const open = isOpen(this.dialogEl);\n if (targetOpenState !== true && open && this.isConnected) {\n this.dialogEl.addEventListener(\n 'beforetoggle',\n () => {\n reportChange();\n },\n { once: true }\n );\n this.dialogEl.hidePopover();\n } else {\n reportChange();\n }\n };\n this.elements.forEach((el, index) => {\n guaranteedAllTransitionend(\n el,\n start(el, index),\n finish(el, index)\n );\n });\n return focusEl;\n }\n }\n return OverlayWithPopover;\n}\n"],
5
5
  "mappings": "aAWA,OACI,oBAAAA,EACA,2BAAAC,MACG,4DAEP,OAAS,kBAAAC,MAAsB,sBAE/B,OACI,8BAAAC,EACA,aAAAC,EACA,gBAAAC,MACG,uBACP,OACI,2BAAAC,EACA,yBAAAC,EACA,qBAAAC,MACG,cAEP,OAAS,yBAAAC,MAA6B,kCAEtC,MAAMC,EAAsB,IAAI,SAAS,iBAAiB,EAE1D,SAASC,EAAOC,EAA0B,CACtC,IAAIC,EAAc,GAClB,GAAI,CACAA,EAAcD,EAAG,QAAQ,eAAe,CAE5C,OAASE,EAAO,CAAC,CACjB,IAAIC,EAAO,GACX,GAAI,CACAA,EAAOH,EAAG,QAAQ,OAAO,CAE7B,OAASE,EAAO,CAAC,CACjB,OAAOD,GAAeE,CAC1B,CAEO,gBAAS,eACZC,EACgC,CAChC,MAAMC,UAA2BD,CAAY,CACzC,MAAyB,YACrBE,EACa,CACb,GAAIA,IAAoB,IAASA,IAAoB,KAAK,KAAM,CAC5Db,EAAa,MAAM,IAAI,EACvB,MACJ,CACI,KAAK,SACa,MAAMA,EAAa,UAAU,IAAI,IAE/C,KAAK,KAAO,CAACa,EAGzB,CAMA,MAAc,kBACVA,EACa,CACb,GAAIA,GAAmB,KAAK,OAASA,EACjC,OAEJ,MAAMC,EAAS,MAAO,CAClB,SAAAC,CACJ,EAA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EAAG,cACC,IAAIJ,EAAkBmB,EAAW,KAAM,CACnC,YAAa,KAAK,KAClB,QAAS,EACb,CAAC,CACL,EACA,MACJ,CACA,MAAMC,EAAe,SAA2B,CAC5C,GAAI,KAAK,OAASV,EACd,OAEJ,MAAMd,EAAU,EAChB,MAAMyB,EACF,KAAK,0BAA0B3B,EACnC,KAAK,cACD,IAAIM,EAAkBmB,EAAW,KAAM,CACnC,YAAa,KAAK,KAClB,QAASE,CACb,CAAC,CACL,EACAjB,EAAG,cACC,IAAIJ,EAAkBmB,EAAW,KAAM,CACnC,YAAa,KAAK,KAClB,QAAS,EACb,CAAC,CACL,EACI,KAAK,gBAAkB,CAACE,GACvB,KAAK,eAA+B,cACjC,IAAIrB,EAAkBmB,EAAW,KAAM,CACnC,YAAa,KAAK,KAClB,QAAS,EACb,CAAC,CACL,EAEJ,KAAK,MAAQT,EAAkB,SAAW,SAC1C,KAAK,YAAY,EAEjB,MAAMd,EAAU,EAChB,MAAMA,EAAU,EAEZc,IAAoB,KAAK,MACzBA,IAAoB,IAEpB,KAAK,iBAAiB,CAE9B,EACA,GAAI,KAAK,OAASA,EACd,OAEJ,MAAMH,EAAOJ,EAAO,KAAK,QAAQ,EAC7BO,IAAoB,IAAQH,GAAQ,KAAK,aACzC,KAAK,SAAS,iBACV,eACA,IAAM,CACFa,EAAa,CACjB,EACA,CAAE,KAAM,EAAK,CACjB,EACA,KAAK,SAAS,YAAY,GAE1BA,EAAa,CAErB,EACJ,YAAK,SAAS,QAAQ,CAAChB,EAAIW,IAAU,CACjCpB,EACIS,EACAU,EAAMV,EAAIW,CAAK,EACfG,EAAOd,EAAIW,CAAK,CACpB,CACJ,CAAC,EACMF,CACX,CACJ,CACA,OAAOJ,CACX",
6
6
  "names": ["firstFocusableIn", "firstFocusableSlottedIn", "VirtualTrigger", "guaranteedAllTransitionend", "nextFrame", "overlayTimer", "BeforetoggleClosedEvent", "BeforetoggleOpenEvent", "OverlayStateEvent", "userFocusableSelector", "supportsOverlayAuto", "isOpen", "el", "popoverOpen", "error", "open", "constructor", "OverlayWithPopover", "targetOpenState", "update", "newState", "focusEl", "start", "index", "event", "slot", "finish", "eventName", "reportChange", "hasVirtualTrigger"]
7
7
  }
@@ -1,3 +1,14 @@
1
+ /**
2
+ * Copyright 2025 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
1
12
  import { Overlay } from './Overlay.js';
2
13
  declare class OverlayStack {
3
14
  private get document();
@@ -5,10 +16,16 @@ declare class OverlayStack {
5
16
  private lastOverlay?;
6
17
  private root;
7
18
  stack: Overlay[];
19
+ private originalBodyOverflow;
20
+ private bodyScrollBlocked;
8
21
  constructor();
9
22
  bindEvents(): void;
10
23
  private handleScroll;
11
24
  private closeOverlay;
25
+ /**
26
+ * Manage body scroll blocking based on modal/page overlays
27
+ */
28
+ private manageBodyScroll;
12
29
  /**
13
30
  * Cach the `pointerdownTarget` for later testing
14
31
  *