@spectrum-web-components/overlay 0.35.1-rc.43 → 0.36.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 (156) hide show
  1. package/README.md +150 -237
  2. package/active-overlay.d.ts +6 -0
  3. package/active-overlay.dev.js +5 -0
  4. package/{sp-overlay.dev.js.map → active-overlay.dev.js.map} +3 -3
  5. package/active-overlay.js +2 -0
  6. package/{sp-overlay.js.map → active-overlay.js.map} +4 -4
  7. package/custom-elements.json +1215 -0
  8. package/package.json +22 -49
  9. package/src/ActiveOverlay.d.ts +84 -0
  10. package/src/ActiveOverlay.dev.js +517 -0
  11. package/src/ActiveOverlay.dev.js.map +7 -0
  12. package/src/ActiveOverlay.js +16 -0
  13. package/src/ActiveOverlay.js.map +7 -0
  14. package/src/OverlayTrigger.d.ts +41 -24
  15. package/src/OverlayTrigger.dev.js +295 -133
  16. package/src/OverlayTrigger.dev.js.map +3 -3
  17. package/src/OverlayTrigger.js +22 -52
  18. package/src/OverlayTrigger.js.map +3 -3
  19. package/src/VirtualTrigger.dev.js +1 -2
  20. package/src/VirtualTrigger.dev.js.map +2 -2
  21. package/src/VirtualTrigger.js +1 -1
  22. package/src/VirtualTrigger.js.map +2 -2
  23. package/src/active-overlay.css.dev.js +13 -0
  24. package/src/active-overlay.css.dev.js.map +7 -0
  25. package/src/active-overlay.css.js +10 -0
  26. package/src/active-overlay.css.js.map +7 -0
  27. package/src/index.d.ts +3 -2
  28. package/src/index.dev.js +3 -2
  29. package/src/index.dev.js.map +2 -2
  30. package/src/index.js +1 -1
  31. package/src/index.js.map +2 -2
  32. package/src/loader.d.ts +2 -1
  33. package/src/loader.dev.js +19 -2
  34. package/src/loader.dev.js.map +2 -2
  35. package/src/loader.js +1 -1
  36. package/src/loader.js.map +3 -3
  37. package/src/overlay-stack.d.ts +50 -0
  38. package/src/overlay-stack.dev.js +515 -0
  39. package/src/overlay-stack.dev.js.map +7 -0
  40. package/src/overlay-stack.js +34 -0
  41. package/src/overlay-stack.js.map +7 -0
  42. package/src/overlay-timer.dev.js.map +2 -2
  43. package/src/overlay-timer.js.map +2 -2
  44. package/src/overlay-trigger.css.dev.js +1 -1
  45. package/src/overlay-trigger.css.dev.js.map +1 -1
  46. package/src/overlay-trigger.css.js +1 -1
  47. package/src/overlay-trigger.css.js.map +1 -1
  48. package/src/overlay-types.d.ts +31 -25
  49. package/src/overlay-types.dev.js +0 -1
  50. package/src/overlay-types.dev.js.map +3 -3
  51. package/src/overlay-types.js +1 -1
  52. package/src/overlay-types.js.map +3 -3
  53. package/src/overlay-utils.d.ts +3 -0
  54. package/src/overlay-utils.dev.js +31 -0
  55. package/src/overlay-utils.dev.js.map +7 -0
  56. package/src/overlay-utils.js +2 -0
  57. package/src/overlay-utils.js.map +7 -0
  58. package/src/overlay.d.ts +59 -0
  59. package/src/overlay.dev.js +127 -0
  60. package/src/overlay.dev.js.map +7 -0
  61. package/src/overlay.js +2 -0
  62. package/src/overlay.js.map +7 -0
  63. package/stories/overlay-story-components.js +8 -9
  64. package/stories/overlay-story-components.js.map +2 -2
  65. package/stories/overlay.stories.js +697 -825
  66. package/stories/overlay.stories.js.map +2 -2
  67. package/sync/overlay-trigger.d.ts +0 -4
  68. package/sync/overlay-trigger.dev.js +4 -1
  69. package/sync/overlay-trigger.dev.js.map +2 -2
  70. package/sync/overlay-trigger.js +1 -1
  71. package/sync/overlay-trigger.js.map +3 -3
  72. package/test/benchmark/basic-test.js +1 -1
  73. package/test/benchmark/basic-test.js.map +1 -1
  74. package/test/index.js +377 -408
  75. package/test/index.js.map +3 -3
  76. package/test/overlay-lifecycle.test.js +106 -34
  77. package/test/overlay-lifecycle.test.js.map +2 -2
  78. package/test/overlay-trigger-click.test.js +5 -11
  79. package/test/overlay-trigger-click.test.js.map +2 -2
  80. package/test/overlay-trigger-extended.test.js +36 -42
  81. package/test/overlay-trigger-extended.test.js.map +2 -2
  82. package/test/overlay-trigger-hover-click.test.js +24 -27
  83. package/test/overlay-trigger-hover-click.test.js.map +2 -2
  84. package/test/overlay-trigger-hover.test.js +35 -41
  85. package/test/overlay-trigger-hover.test.js.map +2 -2
  86. package/test/overlay-trigger-longpress.test.js +81 -206
  87. package/test/overlay-trigger-longpress.test.js.map +2 -2
  88. package/test/overlay-trigger-sync.test.js +1 -1
  89. package/test/overlay-trigger-sync.test.js.map +2 -2
  90. package/test/overlay-trigger.test.js +1 -1
  91. package/test/overlay-trigger.test.js.map +2 -2
  92. package/test/overlay-update.test.js +4 -4
  93. package/test/overlay-update.test.js.map +2 -2
  94. package/test/overlay.test.js +268 -386
  95. package/test/overlay.test.js.map +3 -3
  96. package/sp-overlay.d.ts +0 -6
  97. package/sp-overlay.dev.js +0 -5
  98. package/sp-overlay.js +0 -2
  99. package/src/AbstractOverlay.d.ts +0 -56
  100. package/src/AbstractOverlay.dev.js +0 -202
  101. package/src/AbstractOverlay.dev.js.map +0 -7
  102. package/src/AbstractOverlay.js +0 -2
  103. package/src/AbstractOverlay.js.map +0 -7
  104. package/src/Overlay.d.ts +0 -147
  105. package/src/Overlay.dev.js +0 -777
  106. package/src/Overlay.dev.js.map +0 -7
  107. package/src/Overlay.js +0 -33
  108. package/src/Overlay.js.map +0 -7
  109. package/src/OverlayDialog.d.ts +0 -4
  110. package/src/OverlayDialog.dev.js +0 -135
  111. package/src/OverlayDialog.dev.js.map +0 -7
  112. package/src/OverlayDialog.js +0 -2
  113. package/src/OverlayDialog.js.map +0 -7
  114. package/src/OverlayNoPopover.d.ts +0 -4
  115. package/src/OverlayNoPopover.dev.js +0 -110
  116. package/src/OverlayNoPopover.dev.js.map +0 -7
  117. package/src/OverlayNoPopover.js +0 -2
  118. package/src/OverlayNoPopover.js.map +0 -7
  119. package/src/OverlayPopover.d.ts +0 -4
  120. package/src/OverlayPopover.dev.js +0 -169
  121. package/src/OverlayPopover.dev.js.map +0 -7
  122. package/src/OverlayPopover.js +0 -2
  123. package/src/OverlayPopover.js.map +0 -7
  124. package/src/OverlayStack.d.ts +0 -43
  125. package/src/OverlayStack.dev.js +0 -150
  126. package/src/OverlayStack.dev.js.map +0 -7
  127. package/src/OverlayStack.js +0 -2
  128. package/src/OverlayStack.js.map +0 -7
  129. package/src/PlacementController.d.ts +0 -38
  130. package/src/PlacementController.dev.js +0 -199
  131. package/src/PlacementController.dev.js.map +0 -7
  132. package/src/PlacementController.js +0 -2
  133. package/src/PlacementController.js.map +0 -7
  134. package/src/fullSizePlugin.d.ts +0 -12
  135. package/src/fullSizePlugin.dev.js +0 -39
  136. package/src/fullSizePlugin.dev.js.map +0 -7
  137. package/src/fullSizePlugin.js +0 -2
  138. package/src/fullSizePlugin.js.map +0 -7
  139. package/src/overlay.css.dev.js +0 -9
  140. package/src/overlay.css.dev.js.map +0 -7
  141. package/src/overlay.css.js +0 -6
  142. package/src/overlay.css.js.map +0 -7
  143. package/src/topLayerOverTransforms.d.ts +0 -2
  144. package/src/topLayerOverTransforms.dev.js +0 -91
  145. package/src/topLayerOverTransforms.dev.js.map +0 -7
  146. package/src/topLayerOverTransforms.js +0 -2
  147. package/src/topLayerOverTransforms.js.map +0 -7
  148. package/stories/overlay-element.stories.js +0 -463
  149. package/stories/overlay-element.stories.js.map +0 -7
  150. package/test/overlay-element.test-vrt.js +0 -5
  151. package/test/overlay-element.test-vrt.js.map +0 -7
  152. package/test/overlay-element.test.js +0 -681
  153. package/test/overlay-element.test.js.map +0 -7
  154. package/test/overlay-v1.test.js +0 -651
  155. package/test/overlay-v1.test.js.map +0 -7
  156. /package/src/{overlay.css.d.ts → active-overlay.css.d.ts} +0 -0
@@ -0,0 +1,34 @@
1
+ "use strict";import{ActiveOverlay as g}from"./ActiveOverlay.js";import{OverlayTimer as f}from"./overlay-timer.js";import"../active-overlay.js";import{findOverlaysRootedInOverlay as p,parentOverlayOf as v}from"./overlay-utils.js";import{getDeepElementFromPoint as b}from"@spectrum-web-components/shared/src/get-deep-element-from-point.js";function C(s){return s.button===0}function O(s){return!!(s.metaKey||s.altKey||s.ctrlKey||s.shiftKey)}function h(){return new Promise(s=>requestAnimationFrame(()=>s()))}export class OverlayStack{constructor(){this.overlays=[];this.preventMouseRootClose=!1;this.root=document.body;this.handlingResize=!1;this.overlayTimer=new f;this.canTabTrap=!0;this.trappingInited=!1;this._eventsAreBound=!1;this._bodyMarginsApplied=!1;this.forwardContextmenuEvent=async e=>{var o;const t=this.overlays[this.overlays.length-1];!this.trappingInited||t.interaction!=="modal"||e.target!==this.overlayHolder||(e.stopPropagation(),e.preventDefault(),await this.closeTopOverlay(),(o=b(e.clientX,e.clientY))==null||o.dispatchEvent(new MouseEvent("contextmenu",e)))};this.handleOverlayClose=e=>{const{root:t}=e;t&&this.closeOverlaysForRoot(t)};this.handleMouseCapture=e=>{const t=this.topOverlay;if(!e.target||!t||!t.overlayContent||O(e)||!C(e)){this.preventMouseRootClose=!0;return}if(e.target instanceof Node){if(e.composedPath().indexOf(t.overlayContent)>=0){this.preventMouseRootClose=!0;return}this.preventMouseRootClose=!1}};this._doesNotCloseOnFirstClick=!1;this.handleMouse=e=>{var n;if(this._doesNotCloseOnFirstClick){this._doesNotCloseOnFirstClick=!1;return}if(this.preventMouseRootClose||e.defaultPrevented)return;const t=[];let o=this.overlays.length;for(;o&&t.length===0;){o-=1;const a=this.overlays[o],l=e.composedPath();(!l.includes(a.trigger)||a.interaction!=="hover")&&!l.includes(a.overlayContent)&&t.push(a)}let r=(n=this.topOverlay)==null?void 0:n.root,i=v(r);for(;r&&i;)t.push(i),i=v(r),r=i==null?void 0:i.root;i&&t.push(i),t.forEach(a=>this.hideAndCloseOverlay(a))};this.handleKeydown=e=>{e.code==="Escape"&&this.closeTopOverlay()};this.handleResize=()=>{this.handlingResize||(this.handlingResize=!0,requestAnimationFrame(async()=>{const e=this.overlays.map(t=>t.updateOverlayPosition());await Promise.all(e),this.handlingResize=!1}))};this.initTabTrapping()}initTabTrapping(){if(document.readyState==="loading"){document.addEventListener("readystatechange",()=>{this.initTabTrapping()},{once:!0});return}if(this.trappingInited)return;if(this.document.body.shadowRoot){this.canTabTrap=!1;return}if(this.document.body.attachShadow({mode:"open"}),!this.document.body.shadowRoot)return;this.trappingInited=!0;const e=this.document.body.shadowRoot;e.innerHTML=`
2
+ <style>
3
+ :host {
4
+ position: relative;
5
+ }
6
+ #actual {
7
+ position: relative;
8
+ height: calc(100% - var(--swc-body-margins-block, 0px));
9
+ z-index: 0;
10
+ min-height: calc(100vh - var(--swc-body-margins-block, 0px));
11
+ min-height: calc(100dvh - var(--swc-body-margins-block, 0px));
12
+ }
13
+ #holder {
14
+ display: none;
15
+ align-items: center;
16
+ justify-content: center;
17
+ flex-flow: column;
18
+ width: 100%;
19
+ height: 100%;
20
+ position: absolute;
21
+ top: 0;
22
+ left: 0;
23
+ }
24
+ [name="open"]::slotted(*) {
25
+ pointer-events: all;
26
+ }
27
+ #actual[aria-hidden] + #holder {
28
+ display: flex;
29
+ }
30
+ </style>
31
+ <div id="actual"><slot></slot></div>
32
+ <div id="holder"><slot name="open"></slot></div>
33
+ `,this.tabTrapper=e.querySelector("#actual"),this.overlayHolder=e.querySelector("#holder"),this.tabTrapper.attachShadow({mode:"open"}),this.tabTrapper.shadowRoot&&(this.tabTrapper.shadowRoot.innerHTML="<slot></slot>"),this.overlayHolder.addEventListener("contextmenu",this.forwardContextmenuEvent,!0),requestAnimationFrame(()=>{this.applyBodyMargins(),new ResizeObserver(()=>{this.applyBodyMargins()}).observe(document.body)})}applyBodyMargins(){const{marginLeft:e,marginRight:t,marginTop:o,marginBottom:r}=getComputedStyle(document.body),i=parseFloat(e)===0&&parseFloat(t)===0&&parseFloat(o)===0&&parseFloat(r)===0;i&&!this._bodyMarginsApplied||(this.tabTrapper.style.setProperty("--swc-body-margins-inline",`calc(${e} + ${t})`),this.tabTrapper.style.setProperty("--swc-body-margins-block",`calc(${o} + ${r})`),this._bodyMarginsApplied=!i)}startTabTrapping(){this.initTabTrapping(),this.canTabTrap&&(this.tabTrapper.tabIndex=-1,this.tabTrapper.setAttribute("aria-hidden","true"))}stopTabTrapping(){!this.canTabTrap||!this.trappingInited||(this.tabTrapper.removeAttribute("tabindex"),this.tabTrapper.removeAttribute("aria-hidden"))}get document(){return this.root.ownerDocument||document}get topOverlay(){return this.overlays.slice(-1)[0]}findOverlayForContent(e){for(const t of this.overlays)if(e===t.overlayContent)return t}addEventListeners(){this._eventsAreBound||(this._eventsAreBound=!0,this.document.addEventListener("click",this.handleMouseCapture,!0),this.document.addEventListener("click",this.handleMouse),this.document.addEventListener("keydown",this.handleKeydown),this.document.addEventListener("sp-overlay-close",this.handleOverlayClose),window.addEventListener("resize",this.handleResize))}isClickOverlayActiveForTrigger(e){return this.overlays.some(t=>e===t.trigger&&t.interaction==="click")}async openOverlay(e){if(this.addEventListeners(),this.findOverlayForContent(e.content))return!1;e.notImmediatelyClosable&&(this._doesNotCloseOnFirstClick=!0),e.interaction==="modal"&&this.startTabTrapping();const t=e.content,{trigger:o}=e;if(t.overlayWillOpenCallback&&t.overlayWillOpenCallback({trigger:o}),e.delayed){const a=[this.overlayTimer.openTimer(e.content)];e.abortPromise&&a.push(e.abortPromise);const l=await Promise.race(a);if(l)return t.overlayOpenCancelledCallback&&t.overlayOpenCancelledCallback({trigger:o}),l}if(e.root&&this.closeOverlaysForRoot(e.root),e.interaction==="click")this.closeAllHoverOverlays();else if(e.interaction==="hover"&&this.isClickOverlayActiveForTrigger(e.trigger))return!0;const r=g.create(e);this.overlays.length&&this.overlays[this.overlays.length-1].obscure(r.interaction),document.body.appendChild(r),await h(),this.overlays.push(r),await r.updateComplete,this.addOverlayEventListeners(r),typeof t.open!="undefined"&&(await h(),t.open=!0);let i=()=>{};if(t.overlayOpenCallback){const{trigger:n}=r,{overlayOpenCallback:a}=t;i=async()=>await a({trigger:n})}return await r.openCallback(i),!1}addOverlayEventListeners(e){switch(e.addEventListener("close",()=>{this.hideAndCloseOverlay(e,!0)}),e.interaction){case"replace":this.addReplaceOverlayEventListeners(e);break;case"inline":this.addInlineOverlayEventListeners(e);break}}addReplaceOverlayEventListeners(e){e.addEventListener("keydown",t=>{const{code:o}=t;o==="Tab"&&(t.stopPropagation(),this.closeOverlay(e.overlayContent),e.tabbingAway=!0,e.trigger.focus(),e.trigger.dispatchEvent(new KeyboardEvent("keydown",t)))})}addInlineOverlayEventListeners(e){e.trigger.addEventListener("keydown",e.handleInlineTriggerKeydown),e.addEventListener("keydown",t=>{const{code:o,shiftKey:r}=t;if(o!=="Tab")return;if(e.tabbingAway=!0,r){const n=document.createElement("span");n.tabIndex=-1,e.trigger.hasAttribute("slot")&&(n.slot=e.trigger.slot),e.trigger.insertAdjacentElement("afterend",n),n.focus(),n.remove();return}t.stopPropagation();const i=e.trigger;typeof i.open!="undefined"&&(i.open=!1),this.closeOverlay(e.overlayContent),e.trigger.focus()})}closeOverlay(e){this.overlayTimer.close(e),requestAnimationFrame(()=>{const t=this.findOverlayForContent(e),o=[t];o.push(...p(t,this.overlays)),o.forEach(r=>this.hideAndCloseOverlay(r))})}closeAllHoverOverlays(){for(const e of this.overlays)e.interaction==="hover"&&this.hideAndCloseOverlay(e,!1)}closeOverlaysForRoot(e){const t=[];for(const o of this.overlays)o.root&&o.root===e&&(t.push(o),t.push(...p(o,this.overlays)));t.forEach(o=>this.hideAndCloseOverlay(o,!0,!0))}async manageFocusAfterCloseWhenOverlaysRemain(e,t){const o=this.overlays[this.overlays.length-1];if(o.feature(),o.interaction==="modal"||o.hasModalRoot){if(e)return;await(t||o).focus()}else this.stopTabTrapping()}manageFocusAfterCloseWhenLastOverlay(e){this.stopTabTrapping();const t=e.interaction==="modal",o=e.receivesFocus==="auto",r=e.interaction==="replace",i=e.interaction==="inline",n=(r||i)&&!e.tabbingAway;if(e.tabbingAway=!1,!t&&!o&&!n)return;const l=e.overlayContent.getRootNode().activeElement;let d,c;const u=()=>e.overlayContent.contains(l),y=()=>(d=e.trigger.getRootNode(),c=d.activeElement,d.contains(c)),m=()=>d.host&&d.host===c;(t||u()||y()||m())&&e.trigger.focus()}async hideAndCloseOverlay(e,t,o){if(!e)return;const r=e.overlayContent;if(typeof r.overlayWillCloseCallback!="undefined"){const{trigger:n}=e;if(r.overlayWillCloseCallback({trigger:n}))return}if(await e.hide(t),typeof r.open!="undefined"&&(r.open=!1),r.overlayCloseCallback){const{trigger:n}=e;await r.overlayCloseCallback({trigger:n})}if(e.state!="dispose")return;const i=this.overlays.indexOf(e);i>=0&&this.overlays.splice(i,1),this.overlays.length?await this.manageFocusAfterCloseWhenOverlaysRemain(o||e.interaction==="hover",e.trigger):this.manageFocusAfterCloseWhenLastOverlay(e),await e.updateComplete,e.remove(),e.dispose(),e.trigger.dispatchEvent(new CustomEvent("sp-closed",{bubbles:!0,composed:!0,cancelable:!0,detail:{interaction:e.interaction}}))}closeTopOverlay(){return this.hideAndCloseOverlay(this.topOverlay,!0)}}
34
+ //# sourceMappingURL=overlay-stack.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["overlay-stack.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*/\n\nimport { ActiveOverlay } from './ActiveOverlay.js';\nimport type {\n OverlayOpenCloseDetail,\n OverlayOpenDetail,\n} from './overlay-types';\nimport { OverlayTimer } from './overlay-timer.js';\nimport '../active-overlay.js';\nimport {\n findOverlaysRootedInOverlay,\n parentOverlayOf,\n} from './overlay-utils.js';\nimport { OverlayCloseEvent } from './overlay-events.js';\nimport { getDeepElementFromPoint } from '@spectrum-web-components/shared/src/get-deep-element-from-point.js';\n\nfunction isLeftClick(event: MouseEvent): boolean {\n return event.button === 0;\n}\n\nfunction hasModifier(event: MouseEvent): boolean {\n return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);\n}\n\ninterface ManagedOverlayContent {\n open: boolean;\n // Allow the overlaid content to do something before it is thrown.\n overlayWillOpenCallback?: (args: { trigger: HTMLElement }) => void;\n // Allow the overlaid content to do something when it has been thrown.\n overlayOpenCallback?: (args: { trigger: HTMLElement }) => void;\n // Allow the overlaid content to do something when its throw has been cancelled.\n overlayOpenCancelledCallback?: (args: { trigger: HTMLElement }) => void;\n // Allow the overlaid content to do something before it is recalled, and return `true` if it will self managing the recall.\n overlayWillCloseCallback?: (args: { trigger: HTMLElement }) => boolean;\n // Allow the overlaid content to do something when it has been recalled.\n overlayCloseCallback?: (args: { trigger: HTMLElement }) => void;\n // Surface possible LitElement lifecycle methods on the synthetically types element.\n updateComplete?: Promise<boolean>;\n}\n\nfunction nextFrame(): Promise<void> {\n return new Promise((res) => requestAnimationFrame(() => res()));\n}\n\nexport class OverlayStack {\n public overlays: ActiveOverlay[] = [];\n\n private preventMouseRootClose = false;\n private root: HTMLElement = document.body;\n private handlingResize = false;\n private overlayTimer = new OverlayTimer();\n\n private canTabTrap = true;\n private trappingInited = false;\n private tabTrapper!: HTMLElement;\n private overlayHolder!: HTMLElement;\n private _eventsAreBound = false;\n\n constructor() {\n this.initTabTrapping();\n }\n\n private initTabTrapping(): void {\n /* c8 ignore next 10 */\n if (document.readyState === 'loading') {\n document.addEventListener(\n 'readystatechange',\n () => {\n this.initTabTrapping();\n },\n { once: true }\n );\n return;\n }\n if (this.trappingInited) return;\n /* c8 ignore next 4 */\n if (this.document.body.shadowRoot) {\n this.canTabTrap = false;\n return;\n }\n this.document.body.attachShadow({ mode: 'open' });\n /* c8 ignore next 3 */\n if (!this.document.body.shadowRoot) {\n return;\n }\n this.trappingInited = true;\n const root = this.document.body.shadowRoot as ShadowRoot;\n root.innerHTML = `\n <style>\n :host {\n position: relative;\n }\n #actual {\n position: relative;\n height: calc(100% - var(--swc-body-margins-block, 0px));\n z-index: 0;\n min-height: calc(100vh - var(--swc-body-margins-block, 0px));\n min-height: calc(100dvh - var(--swc-body-margins-block, 0px));\n }\n #holder {\n display: none;\n align-items: center;\n justify-content: center;\n flex-flow: column;\n width: 100%;\n height: 100%;\n position: absolute;\n top: 0;\n left: 0;\n }\n [name=\"open\"]::slotted(*) {\n pointer-events: all;\n }\n #actual[aria-hidden] + #holder {\n display: flex;\n }\n </style>\n <div id=\"actual\"><slot></slot></div>\n <div id=\"holder\"><slot name=\"open\"></slot></div>\n `;\n this.tabTrapper = root.querySelector('#actual') as HTMLElement;\n this.overlayHolder = root.querySelector('#holder') as HTMLElement;\n this.tabTrapper.attachShadow({ mode: 'open' });\n if (this.tabTrapper.shadowRoot) {\n this.tabTrapper.shadowRoot.innerHTML = '<slot></slot>';\n }\n this.overlayHolder.addEventListener(\n 'contextmenu',\n this.forwardContextmenuEvent,\n true\n );\n requestAnimationFrame(() => {\n this.applyBodyMargins();\n const observer = new ResizeObserver(() => {\n this.applyBodyMargins();\n });\n observer.observe(document.body);\n });\n }\n\n private _bodyMarginsApplied = false;\n\n private applyBodyMargins(): void {\n const { marginLeft, marginRight, marginTop, marginBottom } =\n getComputedStyle(document.body);\n const allZero =\n parseFloat(marginLeft) === 0 &&\n parseFloat(marginRight) === 0 &&\n parseFloat(marginTop) === 0 &&\n parseFloat(marginBottom) === 0;\n if (allZero && !this._bodyMarginsApplied) {\n return;\n }\n this.tabTrapper.style.setProperty(\n '--swc-body-margins-inline',\n `calc(${marginLeft} + ${marginRight})`\n );\n this.tabTrapper.style.setProperty(\n '--swc-body-margins-block',\n `calc(${marginTop} + ${marginBottom})`\n );\n this._bodyMarginsApplied = !allZero;\n }\n\n private startTabTrapping(): void {\n this.initTabTrapping();\n /* c8 ignore next 3 */\n if (!this.canTabTrap) {\n return;\n }\n this.tabTrapper.tabIndex = -1;\n this.tabTrapper.setAttribute('aria-hidden', 'true');\n }\n\n private stopTabTrapping(): void {\n /* c8 ignore next 3 */\n if (!this.canTabTrap || !this.trappingInited) {\n return;\n }\n this.tabTrapper.removeAttribute('tabindex');\n this.tabTrapper.removeAttribute('aria-hidden');\n }\n\n private forwardContextmenuEvent = async (\n event: MouseEvent\n ): Promise<void> => {\n const topOverlay = this.overlays[this.overlays.length - 1];\n if (\n !this.trappingInited ||\n topOverlay.interaction !== 'modal' ||\n event.target !== this.overlayHolder\n ) {\n return;\n }\n event.stopPropagation();\n event.preventDefault();\n await this.closeTopOverlay();\n getDeepElementFromPoint(event.clientX, event.clientY)?.dispatchEvent(\n new MouseEvent('contextmenu', event)\n );\n };\n\n private get document(): Document {\n return this.root.ownerDocument /* c8 ignore next */ || document;\n }\n\n private get topOverlay(): ActiveOverlay | undefined {\n return this.overlays.slice(-1)[0];\n }\n\n private findOverlayForContent(\n overlayContent: HTMLElement\n ): ActiveOverlay | undefined {\n for (const item of this.overlays) {\n if (overlayContent === item.overlayContent) {\n return item;\n }\n }\n return undefined;\n }\n\n private addEventListeners(): void {\n if (this._eventsAreBound) return;\n this._eventsAreBound = true;\n this.document.addEventListener('click', this.handleMouseCapture, true);\n this.document.addEventListener('click', this.handleMouse);\n this.document.addEventListener('keydown', this.handleKeydown);\n this.document.addEventListener(\n 'sp-overlay-close',\n this.handleOverlayClose as EventListener\n );\n window.addEventListener('resize', this.handleResize);\n }\n\n handleOverlayClose = (event: OverlayCloseEvent): void => {\n const { root } = event;\n if (!root) return;\n this.closeOverlaysForRoot(root);\n };\n\n private isClickOverlayActiveForTrigger(trigger: HTMLElement): boolean {\n return this.overlays.some(\n (item) => trigger === item.trigger && item.interaction === 'click'\n );\n }\n\n public async openOverlay(details: OverlayOpenDetail): Promise<boolean> {\n this.addEventListeners();\n if (this.findOverlayForContent(details.content)) {\n return false;\n }\n if (details.notImmediatelyClosable) {\n this._doesNotCloseOnFirstClick = true;\n }\n if (details.interaction === 'modal') {\n this.startTabTrapping();\n }\n\n const contentWithLifecycle =\n details.content as unknown as ManagedOverlayContent;\n const { trigger } = details;\n if (contentWithLifecycle.overlayWillOpenCallback) {\n contentWithLifecycle.overlayWillOpenCallback({ trigger });\n }\n\n if (details.delayed) {\n const cancelledPromise = this.overlayTimer.openTimer(\n details.content\n );\n const promises = [cancelledPromise];\n if (details.abortPromise) {\n promises.push(details.abortPromise);\n }\n const cancelled = await Promise.race(promises);\n if (cancelled) {\n if (contentWithLifecycle.overlayOpenCancelledCallback) {\n contentWithLifecycle.overlayOpenCancelledCallback({\n trigger,\n });\n }\n return cancelled;\n }\n }\n\n if (details.root) {\n this.closeOverlaysForRoot(details.root);\n }\n if (details.interaction === 'click') {\n this.closeAllHoverOverlays();\n } else if (\n details.interaction === 'hover' &&\n this.isClickOverlayActiveForTrigger(details.trigger)\n ) {\n // Don't show a hover popover if the click popover is already active\n return true;\n }\n\n const activeOverlay = ActiveOverlay.create(details);\n\n if (this.overlays.length) {\n const topOverlay = this.overlays[this.overlays.length - 1];\n topOverlay.obscure(activeOverlay.interaction);\n }\n\n document.body.appendChild(activeOverlay);\n\n /**\n * The following work to make the new overlay the \"top\" of the stack\n * has to happen AFTER the current call stack completes in case there\n * is work there in to remove the previous \"top\" overlay.\n */\n await nextFrame();\n this.overlays.push(activeOverlay);\n await activeOverlay.updateComplete;\n this.addOverlayEventListeners(activeOverlay);\n if (typeof contentWithLifecycle.open !== 'undefined') {\n await nextFrame();\n // Without the rAF Firefox gets here to early\n // and is not able trigger the animation.\n contentWithLifecycle.open = true;\n }\n let cb: () => Promise<void> | void = () => {\n return;\n };\n if (contentWithLifecycle.overlayOpenCallback) {\n const { trigger } = activeOverlay;\n const { overlayOpenCallback } = contentWithLifecycle;\n cb = async () => await overlayOpenCallback({ trigger });\n }\n await activeOverlay.openCallback(cb);\n return false;\n }\n\n public addOverlayEventListeners(activeOverlay: ActiveOverlay): void {\n activeOverlay.addEventListener('close', (() => {\n this.hideAndCloseOverlay(\n activeOverlay,\n true // animated?\n );\n }) as EventListener);\n switch (activeOverlay.interaction) {\n case 'replace':\n this.addReplaceOverlayEventListeners(activeOverlay);\n break;\n case 'inline':\n this.addInlineOverlayEventListeners(activeOverlay);\n break;\n }\n }\n\n public addReplaceOverlayEventListeners(activeOverlay: ActiveOverlay): void {\n activeOverlay.addEventListener('keydown', (event: KeyboardEvent) => {\n const { code } = event;\n /* c8 ignore next */\n if (code !== 'Tab') return;\n\n event.stopPropagation();\n this.closeOverlay(activeOverlay.overlayContent);\n activeOverlay.tabbingAway = true;\n activeOverlay.trigger.focus();\n activeOverlay.trigger.dispatchEvent(\n new KeyboardEvent('keydown', event)\n );\n });\n }\n\n public addInlineOverlayEventListeners(activeOverlay: ActiveOverlay): void {\n activeOverlay.trigger.addEventListener(\n 'keydown',\n activeOverlay.handleInlineTriggerKeydown\n );\n activeOverlay.addEventListener('keydown', (event: KeyboardEvent) => {\n const { code, shiftKey } = event;\n /* c8 ignore next */\n if (code !== 'Tab') return;\n\n activeOverlay.tabbingAway = true;\n if (shiftKey) {\n const returnFocusElement = document.createElement('span');\n returnFocusElement.tabIndex = -1;\n if (activeOverlay.trigger.hasAttribute('slot')) {\n returnFocusElement.slot = activeOverlay.trigger.slot;\n }\n activeOverlay.trigger.insertAdjacentElement(\n 'afterend',\n returnFocusElement\n );\n returnFocusElement.focus();\n returnFocusElement.remove();\n return;\n }\n\n event.stopPropagation();\n const triggerWithLifecycle =\n activeOverlay.trigger as unknown as ManagedOverlayContent;\n if (typeof triggerWithLifecycle.open !== 'undefined') {\n triggerWithLifecycle.open = false;\n }\n this.closeOverlay(activeOverlay.overlayContent);\n activeOverlay.trigger.focus();\n });\n }\n\n public closeOverlay(content: HTMLElement): void {\n this.overlayTimer.close(content);\n requestAnimationFrame(() => {\n const overlayFromContent = this.findOverlayForContent(content);\n const overlaysToClose = [overlayFromContent];\n overlaysToClose.push(\n ...findOverlaysRootedInOverlay(\n overlayFromContent,\n this.overlays\n )\n );\n overlaysToClose.forEach((overlay) =>\n this.hideAndCloseOverlay(overlay)\n );\n });\n }\n\n private handleMouseCapture = (event: MouseEvent): void => {\n const topOverlay = this.topOverlay;\n if (\n !event.target ||\n !topOverlay ||\n !topOverlay.overlayContent ||\n hasModifier(event) ||\n !isLeftClick(event)\n ) {\n this.preventMouseRootClose = true;\n return;\n }\n\n if (event.target instanceof Node) {\n const path = event.composedPath();\n if (path.indexOf(topOverlay.overlayContent) >= 0) {\n this.preventMouseRootClose = true;\n return;\n }\n this.preventMouseRootClose = false;\n }\n };\n\n private closeAllHoverOverlays(): void {\n for (const overlay of this.overlays) {\n if (overlay.interaction === 'hover') {\n this.hideAndCloseOverlay(overlay, false);\n }\n }\n }\n\n private closeOverlaysForRoot(root: HTMLElement): void {\n const overlaysToClose: ActiveOverlay[] = [];\n for (const overlay of this.overlays) {\n if (overlay.root && overlay.root === root) {\n overlaysToClose.push(overlay);\n overlaysToClose.push(\n ...findOverlaysRootedInOverlay(overlay, this.overlays)\n );\n }\n }\n overlaysToClose.forEach((overlay) =>\n this.hideAndCloseOverlay(overlay, true, true)\n );\n }\n\n private async manageFocusAfterCloseWhenOverlaysRemain(\n returnBeforeFocus?: boolean,\n previousTrigger?: HTMLElement\n ): Promise<void> {\n const topOverlay = this.overlays[this.overlays.length - 1];\n topOverlay.feature();\n // Push focus in the the next remaining overlay as needed when a `type=\"modal\"` overlay exists.\n if (topOverlay.interaction === 'modal' || topOverlay.hasModalRoot) {\n if (returnBeforeFocus) return;\n await (previousTrigger || topOverlay).focus();\n } else {\n this.stopTabTrapping();\n }\n }\n\n private manageFocusAfterCloseWhenLastOverlay(overlay: ActiveOverlay): void {\n this.stopTabTrapping();\n const isModal = overlay.interaction === 'modal';\n const isReceivesFocus = overlay.receivesFocus === 'auto';\n const isReplace = overlay.interaction === 'replace';\n const isInline = overlay.interaction === 'inline';\n const isTabbingAwayFromInlineOrReplace =\n (isReplace || isInline) && !overlay.tabbingAway;\n overlay.tabbingAway = false;\n if (!isModal && !isReceivesFocus && !isTabbingAwayFromInlineOrReplace) {\n return;\n }\n // Manage post closure focus when needed.\n const overlayRoot = overlay.overlayContent.getRootNode() as ShadowRoot;\n const overlayContentActiveElement = overlayRoot.activeElement;\n let triggerRoot: ShadowRoot;\n let triggerActiveElement: Element | null;\n const contentContainsActiveElement = (): boolean =>\n overlay.overlayContent.contains(overlayContentActiveElement);\n const triggerRootContainsActiveElement = (): boolean => {\n triggerRoot = overlay.trigger.getRootNode() as ShadowRoot;\n triggerActiveElement = triggerRoot.activeElement;\n return triggerRoot.contains(triggerActiveElement);\n };\n const triggerHostIsActiveElement = (): boolean =>\n triggerRoot.host && triggerRoot.host === triggerActiveElement;\n // Return focus to the trigger as long as the user hasn't actively focused\n // something outside of the current overlay interface; trigger, root, host.\n if (\n isModal ||\n contentContainsActiveElement() ||\n triggerRootContainsActiveElement() ||\n triggerHostIsActiveElement()\n ) {\n overlay.trigger.focus();\n }\n }\n\n private async hideAndCloseOverlay(\n overlay?: ActiveOverlay,\n animated?: boolean,\n returnBeforeFocus?: boolean\n ): Promise<void> {\n if (!overlay) {\n return;\n }\n const contentWithLifecycle =\n overlay.overlayContent as unknown as ManagedOverlayContent;\n if (\n typeof contentWithLifecycle.overlayWillCloseCallback !== 'undefined'\n ) {\n const { trigger } = overlay;\n if (contentWithLifecycle.overlayWillCloseCallback({ trigger })) {\n return;\n }\n }\n await overlay.hide(animated);\n if (typeof contentWithLifecycle.open !== 'undefined') {\n contentWithLifecycle.open = false;\n }\n if (contentWithLifecycle.overlayCloseCallback) {\n const { trigger } = overlay;\n await contentWithLifecycle.overlayCloseCallback({ trigger });\n }\n\n if (overlay.state != 'dispose') return;\n\n const index = this.overlays.indexOf(overlay);\n if (index >= 0) {\n this.overlays.splice(index, 1);\n }\n\n if (this.overlays.length) {\n await this.manageFocusAfterCloseWhenOverlaysRemain(\n returnBeforeFocus || overlay.interaction === 'hover',\n overlay.trigger\n );\n } else {\n this.manageFocusAfterCloseWhenLastOverlay(overlay);\n }\n\n await overlay.updateComplete;\n overlay.remove();\n overlay.dispose();\n\n overlay.trigger.dispatchEvent(\n new CustomEvent<OverlayOpenCloseDetail>('sp-closed', {\n bubbles: true,\n composed: true,\n cancelable: true,\n detail: {\n interaction: overlay.interaction,\n },\n })\n );\n }\n\n private closeTopOverlay(): Promise<void> {\n return this.hideAndCloseOverlay(this.topOverlay, true);\n }\n\n /**\n * A \"longpress\" occurs before the \"click\" that creates it has occured.\n * In that way the first click will still be part of the \"longpress\" and\n * not part of closing the overlay.\n */\n private _doesNotCloseOnFirstClick = false;\n\n private handleMouse = (event: Event): void => {\n if (this._doesNotCloseOnFirstClick) {\n this._doesNotCloseOnFirstClick = false;\n return;\n }\n if (this.preventMouseRootClose || event.defaultPrevented) {\n return;\n }\n const overlaysToClose = [];\n /**\n * Find the first overlay that should be closed by this and include it in the\n * array of overlays for closure.\n *\n * Event path dictates closure while the click event:\n * - did not occur within the overlay content of the overlay\n * AND was\n * - not triggered by something in the click event's composed path\n * OR\n * - not a \"hover\" overlay\n * Select the overlay for closure\n */\n let index = this.overlays.length;\n while (index && overlaysToClose.length === 0) {\n index -= 1;\n const overlay = this.overlays[index];\n const path = event.composedPath();\n const eventPathDictatesClosure =\n (!path.includes(overlay.trigger) ||\n overlay.interaction !== 'hover') &&\n !path.includes(overlay.overlayContent);\n if (eventPathDictatesClosure) {\n overlaysToClose.push(overlay);\n }\n }\n let root: HTMLElement | undefined = this.topOverlay?.root;\n let overlay = parentOverlayOf(root);\n while (root && overlay) {\n overlaysToClose.push(overlay);\n overlay = parentOverlayOf(root);\n root = overlay?.root;\n }\n if (overlay) {\n overlaysToClose.push(overlay);\n }\n overlaysToClose.forEach((overlay) => this.hideAndCloseOverlay(overlay));\n };\n\n private handleKeydown = (event: KeyboardEvent): void => {\n if (event.code === 'Escape') {\n this.closeTopOverlay();\n }\n };\n\n private handleResize = (): void => {\n if (this.handlingResize) return;\n\n this.handlingResize = true;\n requestAnimationFrame(async () => {\n const promises = this.overlays.map((overlay) =>\n overlay.updateOverlayPosition()\n );\n await Promise.all(promises);\n this.handlingResize = false;\n });\n };\n}\n"],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"findOverlaysRootedInOverlay", "parentOverlayOf", "getDeepElementFromPoint", "isLeftClick", "event", "hasModifier", "nextFrame", "res", "_a", "topOverlay", "root", "overlaysToClose", "index", "overlay", "path", "promises", "marginLeft", "marginRight", "marginTop", "marginBottom", "allZero", "overlayContent", "item", "trigger", "details", "contentWithLifecycle", "cancelled", "activeOverlay", "cb", "overlayOpenCallback", "code", "shiftKey", "returnFocusElement", "triggerWithLifecycle", "content", "overlayFromContent", "returnBeforeFocus", "previousTrigger", "isModal", "isReceivesFocus", "isReplace", "isInline", "isTabbingAwayFromInlineOrReplace", "overlayContentActiveElement", "triggerRoot", "triggerActiveElement", "contentContainsActiveElement", "triggerRootContainsActiveElement", "triggerHostIsActiveElement", "animated"]
7
+ }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["overlay-timer.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*/\n\nconst DEFAULT_WARMUP = 1000;\nconst DEFAULT_COOLDOWN = 1000;\n\n/**\n * A timer to help with implementation of warnup/cooldown behavior as described here:\n * https://spectrum.adobe.com/page/tooltip/#Immediate-or-delayed-appearance\n */\nexport class OverlayTimer {\n private warmUpDelay = DEFAULT_WARMUP;\n private coolDownDelay = DEFAULT_COOLDOWN;\n\n private isWarm = false;\n private cooldownTimeout?: number;\n\n private component?: HTMLElement;\n private timeout = 0;\n private promise?: Promise<boolean>;\n private resolve?: (cancelled: boolean) => void;\n\n constructor(\n options: { warmUpDelay?: number; coolDownDelay?: number } = {}\n ) {\n Object.assign(this, options);\n }\n\n public async openTimer(component: HTMLElement): Promise<boolean> {\n this.cancelCooldownTimer();\n\n if (!this.component || component !== this.component) {\n if (this.component) {\n this.close(this.component);\n this.cancelCooldownTimer();\n }\n this.component = component;\n\n if (this.isWarm) {\n return false;\n }\n\n this.promise = new Promise((resolve) => {\n this.resolve = resolve;\n this.timeout = window.setTimeout(() => {\n if (this.resolve) {\n this.resolve(false);\n this.isWarm = true;\n }\n }, this.warmUpDelay);\n });\n return this.promise;\n } else if (this.promise) {\n return this.promise;\n /* c8 ignore next 4 */\n } else {\n // This should never happen\n throw new Error('Inconsistent state');\n }\n }\n\n public close(component: HTMLElement): void {\n if (this.component && this.component === component) {\n this.resetCooldownTimer();\n if (this.timeout > 0) {\n clearTimeout(this.timeout);\n this.timeout = 0;\n }\n if (this.resolve) {\n this.resolve(true);\n delete this.resolve;\n }\n delete this.promise;\n delete this.component;\n }\n }\n\n private resetCooldownTimer(): void {\n if (this.isWarm) {\n if (this.cooldownTimeout) {\n window.clearTimeout(this.cooldownTimeout);\n }\n this.cooldownTimeout = window.setTimeout(() => {\n this.isWarm = false;\n delete this.cooldownTimeout;\n }, this.coolDownDelay);\n }\n }\n\n private cancelCooldownTimer(): void {\n if (this.cooldownTimeout) {\n window.clearTimeout(this.cooldownTimeout);\n }\n delete this.cooldownTimeout;\n }\n}\n"],
5
- "mappings": ";AAYA,MAAM,iBAAiB;AACvB,MAAM,mBAAmB;AAMlB,aAAM,aAAa;AAAA,EAYtB,YACI,UAA4D,CAAC,GAC/D;AAbF,SAAQ,cAAc;AACtB,SAAQ,gBAAgB;AAExB,SAAQ,SAAS;AAIjB,SAAQ,UAAU;AAOd,WAAO,OAAO,MAAM,OAAO;AAAA,EAC/B;AAAA,EAEA,MAAa,UAAU,WAA0C;AAC7D,SAAK,oBAAoB;AAEzB,QAAI,CAAC,KAAK,aAAa,cAAc,KAAK,WAAW;AACjD,UAAI,KAAK,WAAW;AAChB,aAAK,MAAM,KAAK,SAAS;AACzB,aAAK,oBAAoB;AAAA,MAC7B;AACA,WAAK,YAAY;AAEjB,UAAI,KAAK,QAAQ;AACb,eAAO;AAAA,MACX;AAEA,WAAK,UAAU,IAAI,QAAQ,CAAC,YAAY;AACpC,aAAK,UAAU;AACf,aAAK,UAAU,OAAO,WAAW,MAAM;AACnC,cAAI,KAAK,SAAS;AACd,iBAAK,QAAQ,KAAK;AAClB,iBAAK,SAAS;AAAA,UAClB;AAAA,QACJ,GAAG,KAAK,WAAW;AAAA,MACvB,CAAC;AACD,aAAO,KAAK;AAAA,IAChB,WAAW,KAAK,SAAS;AACrB,aAAO,KAAK;AAAA,IAEhB,OAAO;AAEH,YAAM,IAAI,MAAM,oBAAoB;AAAA,IACxC;AAAA,EACJ;AAAA,EAEO,MAAM,WAA8B;AACvC,QAAI,KAAK,aAAa,KAAK,cAAc,WAAW;AAChD,WAAK,mBAAmB;AACxB,UAAI,KAAK,UAAU,GAAG;AAClB,qBAAa,KAAK,OAAO;AACzB,aAAK,UAAU;AAAA,MACnB;AACA,UAAI,KAAK,SAAS;AACd,aAAK,QAAQ,IAAI;AACjB,eAAO,KAAK;AAAA,MAChB;AACA,aAAO,KAAK;AACZ,aAAO,KAAK;AAAA,IAChB;AAAA,EACJ;AAAA,EAEQ,qBAA2B;AAC/B,QAAI,KAAK,QAAQ;AACb,UAAI,KAAK,iBAAiB;AACtB,eAAO,aAAa,KAAK,eAAe;AAAA,MAC5C;AACA,WAAK,kBAAkB,OAAO,WAAW,MAAM;AAC3C,aAAK,SAAS;AACd,eAAO,KAAK;AAAA,MAChB,GAAG,KAAK,aAAa;AAAA,IACzB;AAAA,EACJ;AAAA,EAEQ,sBAA4B;AAChC,QAAI,KAAK,iBAAiB;AACtB,aAAO,aAAa,KAAK,eAAe;AAAA,IAC5C;AACA,WAAO,KAAK;AAAA,EAChB;AACJ;",
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*/\n\nconst DEFAULT_WARMUP = 1000;\nconst DEFAULT_COOLDOWN = 1000;\n\n/**\n * A timer to help with implementation of warnup/cooldown behavior as described here:\n * https://spectrum.adobe.com/page/tooltip/#Immediate-or-delayed-appearance\n */\nexport class OverlayTimer {\n private warmUpDelay = DEFAULT_WARMUP;\n private coolDownDelay = DEFAULT_COOLDOWN;\n\n private isWarm = false;\n private cooldownTimeout?: number;\n\n private component?: HTMLElement;\n private timeout = 0;\n private promise?: Promise<boolean>;\n private resolve?: (cancelled: boolean) => void;\n\n constructor(\n options: { warmUpDelay?: number; coolDownDelay?: number } = {}\n ) {\n Object.assign(this, options);\n }\n\n public async openTimer(component: HTMLElement): Promise<boolean> {\n this.cancelCooldownTimer();\n\n if (!this.component || component !== this.component) {\n if (this.component) {\n this.close(this.component);\n this.cancelCooldownTimer();\n }\n this.component = component;\n\n if (this.isWarm) {\n return false;\n }\n\n this.promise = new Promise((resolve) => {\n this.resolve = resolve;\n this.timeout = window.setTimeout(() => {\n if (this.resolve) {\n this.resolve(false);\n this.isWarm = true;\n }\n }, this.warmUpDelay);\n });\n return this.promise;\n } else if (this.promise) {\n return this.promise;\n } else {\n // This should never happen\n throw new Error('Inconsistent state');\n }\n }\n\n public close(component: HTMLElement): void {\n if (this.component && this.component === component) {\n this.resetCooldownTimer();\n if (this.timeout > 0) {\n clearTimeout(this.timeout);\n this.timeout = 0;\n }\n if (this.resolve) {\n this.resolve(true);\n delete this.resolve;\n }\n delete this.promise;\n delete this.component;\n }\n }\n\n private resetCooldownTimer(): void {\n if (this.isWarm) {\n if (this.cooldownTimeout) {\n window.clearTimeout(this.cooldownTimeout);\n }\n this.cooldownTimeout = window.setTimeout(() => {\n this.isWarm = false;\n delete this.cooldownTimeout;\n }, this.coolDownDelay);\n }\n }\n\n private cancelCooldownTimer(): void {\n if (this.cooldownTimeout) {\n window.clearTimeout(this.cooldownTimeout);\n }\n delete this.cooldownTimeout;\n }\n}\n"],
5
+ "mappings": ";AAYA,MAAM,iBAAiB;AACvB,MAAM,mBAAmB;AAMlB,aAAM,aAAa;AAAA,EAYtB,YACI,UAA4D,CAAC,GAC/D;AAbF,SAAQ,cAAc;AACtB,SAAQ,gBAAgB;AAExB,SAAQ,SAAS;AAIjB,SAAQ,UAAU;AAOd,WAAO,OAAO,MAAM,OAAO;AAAA,EAC/B;AAAA,EAEA,MAAa,UAAU,WAA0C;AAC7D,SAAK,oBAAoB;AAEzB,QAAI,CAAC,KAAK,aAAa,cAAc,KAAK,WAAW;AACjD,UAAI,KAAK,WAAW;AAChB,aAAK,MAAM,KAAK,SAAS;AACzB,aAAK,oBAAoB;AAAA,MAC7B;AACA,WAAK,YAAY;AAEjB,UAAI,KAAK,QAAQ;AACb,eAAO;AAAA,MACX;AAEA,WAAK,UAAU,IAAI,QAAQ,CAAC,YAAY;AACpC,aAAK,UAAU;AACf,aAAK,UAAU,OAAO,WAAW,MAAM;AACnC,cAAI,KAAK,SAAS;AACd,iBAAK,QAAQ,KAAK;AAClB,iBAAK,SAAS;AAAA,UAClB;AAAA,QACJ,GAAG,KAAK,WAAW;AAAA,MACvB,CAAC;AACD,aAAO,KAAK;AAAA,IAChB,WAAW,KAAK,SAAS;AACrB,aAAO,KAAK;AAAA,IAChB,OAAO;AAEH,YAAM,IAAI,MAAM,oBAAoB;AAAA,IACxC;AAAA,EACJ;AAAA,EAEO,MAAM,WAA8B;AACvC,QAAI,KAAK,aAAa,KAAK,cAAc,WAAW;AAChD,WAAK,mBAAmB;AACxB,UAAI,KAAK,UAAU,GAAG;AAClB,qBAAa,KAAK,OAAO;AACzB,aAAK,UAAU;AAAA,MACnB;AACA,UAAI,KAAK,SAAS;AACd,aAAK,QAAQ,IAAI;AACjB,eAAO,KAAK;AAAA,MAChB;AACA,aAAO,KAAK;AACZ,aAAO,KAAK;AAAA,IAChB;AAAA,EACJ;AAAA,EAEQ,qBAA2B;AAC/B,QAAI,KAAK,QAAQ;AACb,UAAI,KAAK,iBAAiB;AACtB,eAAO,aAAa,KAAK,eAAe;AAAA,MAC5C;AACA,WAAK,kBAAkB,OAAO,WAAW,MAAM;AAC3C,aAAK,SAAS;AACd,eAAO,KAAK;AAAA,MAChB,GAAG,KAAK,aAAa;AAAA,IACzB;AAAA,EACJ;AAAA,EAEQ,sBAA4B;AAChC,QAAI,KAAK,iBAAiB;AACtB,aAAO,aAAa,KAAK,eAAe;AAAA,IAC5C;AACA,WAAO,KAAK;AAAA,EAChB;AACJ;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["overlay-timer.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*/\n\nconst DEFAULT_WARMUP = 1000;\nconst DEFAULT_COOLDOWN = 1000;\n\n/**\n * A timer to help with implementation of warnup/cooldown behavior as described here:\n * https://spectrum.adobe.com/page/tooltip/#Immediate-or-delayed-appearance\n */\nexport class OverlayTimer {\n private warmUpDelay = DEFAULT_WARMUP;\n private coolDownDelay = DEFAULT_COOLDOWN;\n\n private isWarm = false;\n private cooldownTimeout?: number;\n\n private component?: HTMLElement;\n private timeout = 0;\n private promise?: Promise<boolean>;\n private resolve?: (cancelled: boolean) => void;\n\n constructor(\n options: { warmUpDelay?: number; coolDownDelay?: number } = {}\n ) {\n Object.assign(this, options);\n }\n\n public async openTimer(component: HTMLElement): Promise<boolean> {\n this.cancelCooldownTimer();\n\n if (!this.component || component !== this.component) {\n if (this.component) {\n this.close(this.component);\n this.cancelCooldownTimer();\n }\n this.component = component;\n\n if (this.isWarm) {\n return false;\n }\n\n this.promise = new Promise((resolve) => {\n this.resolve = resolve;\n this.timeout = window.setTimeout(() => {\n if (this.resolve) {\n this.resolve(false);\n this.isWarm = true;\n }\n }, this.warmUpDelay);\n });\n return this.promise;\n } else if (this.promise) {\n return this.promise;\n /* c8 ignore next 4 */\n } else {\n // This should never happen\n throw new Error('Inconsistent state');\n }\n }\n\n public close(component: HTMLElement): void {\n if (this.component && this.component === component) {\n this.resetCooldownTimer();\n if (this.timeout > 0) {\n clearTimeout(this.timeout);\n this.timeout = 0;\n }\n if (this.resolve) {\n this.resolve(true);\n delete this.resolve;\n }\n delete this.promise;\n delete this.component;\n }\n }\n\n private resetCooldownTimer(): void {\n if (this.isWarm) {\n if (this.cooldownTimeout) {\n window.clearTimeout(this.cooldownTimeout);\n }\n this.cooldownTimeout = window.setTimeout(() => {\n this.isWarm = false;\n delete this.cooldownTimeout;\n }, this.coolDownDelay);\n }\n }\n\n private cancelCooldownTimer(): void {\n if (this.cooldownTimeout) {\n window.clearTimeout(this.cooldownTimeout);\n }\n delete this.cooldownTimeout;\n }\n}\n"],
5
- "mappings": "aAYA,MAAMA,EAAiB,IACjBC,EAAmB,IAMlB,aAAM,YAAa,CAYtB,YACIC,EAA4D,CAAC,EAC/D,CAbF,KAAQ,YAAc,IACtB,KAAQ,cAAgB,IAExB,KAAQ,OAAS,GAIjB,KAAQ,QAAU,EAOd,OAAO,OAAO,KAAMA,CAAO,CAC/B,CAEA,MAAa,UAAUC,EAA0C,CAG7D,GAFA,KAAK,oBAAoB,EAErB,CAAC,KAAK,WAAaA,IAAc,KAAK,UAOtC,OANI,KAAK,YACL,KAAK,MAAM,KAAK,SAAS,EACzB,KAAK,oBAAoB,GAE7B,KAAK,UAAYA,EAEb,KAAK,OACE,IAGX,KAAK,QAAU,IAAI,QAASC,GAAY,CACpC,KAAK,QAAUA,EACf,KAAK,QAAU,OAAO,WAAW,IAAM,CAC/B,KAAK,UACL,KAAK,QAAQ,EAAK,EAClB,KAAK,OAAS,GAEtB,EAAG,KAAK,WAAW,CACvB,CAAC,EACM,KAAK,SACT,GAAI,KAAK,QACZ,OAAO,KAAK,QAIZ,MAAM,IAAI,MAAM,oBAAoB,CAE5C,CAEO,MAAMD,EAA8B,CACnC,KAAK,WAAa,KAAK,YAAcA,IACrC,KAAK,mBAAmB,EACpB,KAAK,QAAU,IACf,aAAa,KAAK,OAAO,EACzB,KAAK,QAAU,GAEf,KAAK,UACL,KAAK,QAAQ,EAAI,EACjB,OAAO,KAAK,SAEhB,OAAO,KAAK,QACZ,OAAO,KAAK,UAEpB,CAEQ,oBAA2B,CAC3B,KAAK,SACD,KAAK,iBACL,OAAO,aAAa,KAAK,eAAe,EAE5C,KAAK,gBAAkB,OAAO,WAAW,IAAM,CAC3C,KAAK,OAAS,GACd,OAAO,KAAK,eAChB,EAAG,KAAK,aAAa,EAE7B,CAEQ,qBAA4B,CAC5B,KAAK,iBACL,OAAO,aAAa,KAAK,eAAe,EAE5C,OAAO,KAAK,eAChB,CACJ",
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*/\n\nconst DEFAULT_WARMUP = 1000;\nconst DEFAULT_COOLDOWN = 1000;\n\n/**\n * A timer to help with implementation of warnup/cooldown behavior as described here:\n * https://spectrum.adobe.com/page/tooltip/#Immediate-or-delayed-appearance\n */\nexport class OverlayTimer {\n private warmUpDelay = DEFAULT_WARMUP;\n private coolDownDelay = DEFAULT_COOLDOWN;\n\n private isWarm = false;\n private cooldownTimeout?: number;\n\n private component?: HTMLElement;\n private timeout = 0;\n private promise?: Promise<boolean>;\n private resolve?: (cancelled: boolean) => void;\n\n constructor(\n options: { warmUpDelay?: number; coolDownDelay?: number } = {}\n ) {\n Object.assign(this, options);\n }\n\n public async openTimer(component: HTMLElement): Promise<boolean> {\n this.cancelCooldownTimer();\n\n if (!this.component || component !== this.component) {\n if (this.component) {\n this.close(this.component);\n this.cancelCooldownTimer();\n }\n this.component = component;\n\n if (this.isWarm) {\n return false;\n }\n\n this.promise = new Promise((resolve) => {\n this.resolve = resolve;\n this.timeout = window.setTimeout(() => {\n if (this.resolve) {\n this.resolve(false);\n this.isWarm = true;\n }\n }, this.warmUpDelay);\n });\n return this.promise;\n } else if (this.promise) {\n return this.promise;\n } else {\n // This should never happen\n throw new Error('Inconsistent state');\n }\n }\n\n public close(component: HTMLElement): void {\n if (this.component && this.component === component) {\n this.resetCooldownTimer();\n if (this.timeout > 0) {\n clearTimeout(this.timeout);\n this.timeout = 0;\n }\n if (this.resolve) {\n this.resolve(true);\n delete this.resolve;\n }\n delete this.promise;\n delete this.component;\n }\n }\n\n private resetCooldownTimer(): void {\n if (this.isWarm) {\n if (this.cooldownTimeout) {\n window.clearTimeout(this.cooldownTimeout);\n }\n this.cooldownTimeout = window.setTimeout(() => {\n this.isWarm = false;\n delete this.cooldownTimeout;\n }, this.coolDownDelay);\n }\n }\n\n private cancelCooldownTimer(): void {\n if (this.cooldownTimeout) {\n window.clearTimeout(this.cooldownTimeout);\n }\n delete this.cooldownTimeout;\n }\n}\n"],
5
+ "mappings": "aAYA,MAAMA,EAAiB,IACjBC,EAAmB,IAMlB,aAAM,YAAa,CAYtB,YACIC,EAA4D,CAAC,EAC/D,CAbF,KAAQ,YAAc,IACtB,KAAQ,cAAgB,IAExB,KAAQ,OAAS,GAIjB,KAAQ,QAAU,EAOd,OAAO,OAAO,KAAMA,CAAO,CAC/B,CAEA,MAAa,UAAUC,EAA0C,CAG7D,GAFA,KAAK,oBAAoB,EAErB,CAAC,KAAK,WAAaA,IAAc,KAAK,UAOtC,OANI,KAAK,YACL,KAAK,MAAM,KAAK,SAAS,EACzB,KAAK,oBAAoB,GAE7B,KAAK,UAAYA,EAEb,KAAK,OACE,IAGX,KAAK,QAAU,IAAI,QAASC,GAAY,CACpC,KAAK,QAAUA,EACf,KAAK,QAAU,OAAO,WAAW,IAAM,CAC/B,KAAK,UACL,KAAK,QAAQ,EAAK,EAClB,KAAK,OAAS,GAEtB,EAAG,KAAK,WAAW,CACvB,CAAC,EACM,KAAK,SACT,GAAI,KAAK,QACZ,OAAO,KAAK,QAGZ,MAAM,IAAI,MAAM,oBAAoB,CAE5C,CAEO,MAAMD,EAA8B,CACnC,KAAK,WAAa,KAAK,YAAcA,IACrC,KAAK,mBAAmB,EACpB,KAAK,QAAU,IACf,aAAa,KAAK,OAAO,EACzB,KAAK,QAAU,GAEf,KAAK,UACL,KAAK,QAAQ,EAAI,EACjB,OAAO,KAAK,SAEhB,OAAO,KAAK,QACZ,OAAO,KAAK,UAEpB,CAEQ,oBAA2B,CAC3B,KAAK,SACD,KAAK,iBACL,OAAO,aAAa,KAAK,eAAe,EAE5C,KAAK,gBAAkB,OAAO,WAAW,IAAM,CAC3C,KAAK,OAAS,GACd,OAAO,KAAK,eAChB,EAAG,KAAK,aAAa,EAE7B,CAEQ,qBAA4B,CAC5B,KAAK,iBACL,OAAO,aAAa,KAAK,eAAe,EAE5C,OAAO,KAAK,eAChB,CACJ",
6
6
  "names": ["DEFAULT_WARMUP", "DEFAULT_COOLDOWN", "options", "component", "resolve"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  import { css } from "@spectrum-web-components/base";
3
3
  const styles = css`
4
- :host([disabled]) ::slotted([slot=trigger]){pointer-events:none}
4
+ :host([disabled]) ::slotted([slot=trigger]){pointer-events:none}#overlay-content slot{display:none}
5
5
  `;
6
6
  export default styles;
7
7
  //# sourceMappingURL=overlay-trigger.css.dev.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["overlay-trigger.css.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 { css } from '@spectrum-web-components/base';\nconst styles = css`\n:host([disabled]) ::slotted([slot=trigger]){pointer-events:none}\n`;\nexport default styles;"],
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 { css } from '@spectrum-web-components/base';\nconst styles = css`\n:host([disabled]) ::slotted([slot=trigger]){pointer-events:none}#overlay-content slot{display:none}\n`;\nexport default styles;"],
5
5
  "mappings": ";AAWA,SAAS,WAAW;AACpB,MAAM,SAAS;AAAA;AAAA;AAGf,eAAe;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
1
  "use strict";import{css as t}from"@spectrum-web-components/base";const e=t`
2
- :host([disabled]) ::slotted([slot=trigger]){pointer-events:none}
2
+ :host([disabled]) ::slotted([slot=trigger]){pointer-events:none}#overlay-content slot{display:none}
3
3
  `;export default e;
4
4
  //# sourceMappingURL=overlay-trigger.css.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["overlay-trigger.css.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 { css } from '@spectrum-web-components/base';\nconst styles = css`\n:host([disabled]) ::slotted([slot=trigger]){pointer-events:none}\n`;\nexport default styles;"],
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 { css } from '@spectrum-web-components/base';\nconst styles = css`\n:host([disabled]) ::slotted([slot=trigger]){pointer-events:none}#overlay-content slot{display:none}\n`;\nexport default styles;"],
5
5
  "mappings": "aAWA,OAAS,OAAAA,MAAW,gCACpB,MAAMC,EAASD;AAAA;AAAA,EAGf,eAAeC",
6
6
  "names": ["css", "styles"]
7
7
  }
@@ -1,14 +1,24 @@
1
- import type { Placement } from '@floating-ui/dom';
1
+ import type { ThemeData } from '@spectrum-web-components/theme/src/Theme.js';
2
+ import type { Placement as FloatingUIPlacement } from '@floating-ui/dom';
2
3
  import type { VirtualTrigger } from './VirtualTrigger.js';
3
- export declare type Constructor<T = Record<string, unknown>> = {
4
- new (...args: any[]): T;
5
- prototype: T;
6
- };
7
- export { Placement };
8
- export declare type OverlayTypes = 'auto' | 'hint' | 'manual' | 'modal' | 'page';
9
- export declare type TriggerInteractions = OverlayTypes;
10
- export declare type TriggerInteractionsV1 = 'click' | 'longpress' | 'hover' | 'custom' | 'replace' | 'inline' | 'modal';
4
+ export declare type TriggerInteractions = 'click' | 'longpress' | 'hover' | 'custom' | 'replace' | 'inline' | 'modal';
11
5
  export declare type OverlayTriggerInteractions = Extract<TriggerInteractions, 'inline' | 'modal' | 'replace'>;
6
+ export interface OverlayOpenDetail {
7
+ content: HTMLElement;
8
+ contentTip?: HTMLElement;
9
+ delayed: boolean;
10
+ offset: number;
11
+ skidding?: number;
12
+ placement?: Placement;
13
+ receivesFocus?: 'auto';
14
+ virtualTrigger?: VirtualTrigger;
15
+ trigger: HTMLElement;
16
+ root?: HTMLElement;
17
+ interaction: TriggerInteractions;
18
+ theme: ThemeData;
19
+ notImmediatelyClosable?: boolean;
20
+ abortPromise?: Promise<boolean>;
21
+ }
12
22
  export interface OverlayOpenCloseDetail {
13
23
  interaction: TriggerInteractions;
14
24
  reason?: 'external-click';
@@ -16,34 +26,30 @@ export interface OverlayOpenCloseDetail {
16
26
  export interface OverlayCloseReasonDetail {
17
27
  reason?: 'external-click';
18
28
  }
29
+ /**
30
+ * Used, via an event, to query details about how an element should be shown in
31
+ * an overlay
32
+ */
33
+ export interface OverlayDisplayQueryDetail {
34
+ overlayRootName?: string;
35
+ overlayRootElement?: HTMLElement;
36
+ overlayContentTipElement?: HTMLElement;
37
+ }
38
+ export declare type Placement = FloatingUIPlacement | 'none';
19
39
  export declare type OverlayOptions = {
20
- delayed?: boolean;
21
- notImmediatelyClosable?: boolean;
22
- offset?: number | [number, number];
23
- placement?: Placement;
24
- receivesFocus?: 'auto' | 'true' | 'false';
25
- trigger?: HTMLElement | VirtualTrigger;
26
- type?: 'modal' | 'page' | 'hint' | 'auto' | 'manual';
27
- };
28
- export declare type OverlayOptionsV1 = {
29
40
  root?: HTMLElement;
30
41
  delayed?: boolean;
31
42
  placement?: Placement;
32
43
  offset?: number;
33
- receivesFocus?: 'true' | 'false' | 'auto';
44
+ receivesFocus?: 'auto';
34
45
  notImmediatelyClosable?: boolean;
35
46
  abortPromise?: Promise<boolean>;
36
47
  virtualTrigger?: VirtualTrigger;
37
48
  };
38
49
  declare global {
39
50
  interface GlobalEventHandlersEventMap {
51
+ 'sp-overlay-query': CustomEvent<OverlayDisplayQueryDetail>;
40
52
  'sp-open': CustomEvent<OverlayOpenCloseDetail>;
41
53
  'sp-close': CustomEvent<OverlayOpenCloseDetail>;
42
54
  }
43
55
  }
44
- export declare type OpenableElement = HTMLElement & {
45
- open: boolean;
46
- tipElement?: HTMLElement;
47
- updateComplete?: Promise<void>;
48
- };
49
- export declare type OverlayState = 'closed' | 'opening' | 'opened' | 'closing';
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
- export {};
3
2
  //# sourceMappingURL=overlay-types.dev.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["overlay-types.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*/\n\nimport type { Placement } from '@floating-ui/dom';\nimport type { VirtualTrigger } from './VirtualTrigger.dev.js'\n\nexport type Constructor<T = Record<string, unknown>> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (...args: any[]): T;\n prototype: T;\n};\n\nexport { Placement };\n\nexport type OverlayTypes = 'auto' | 'hint' | 'manual' | 'modal' | 'page';\n\nexport type TriggerInteractions = OverlayTypes;\n\nexport type TriggerInteractionsV1 =\n | 'click'\n | 'longpress'\n | 'hover'\n | 'custom'\n | 'replace'\n | 'inline'\n | 'modal';\n\nexport type OverlayTriggerInteractions = Extract<\n TriggerInteractions,\n 'inline' | 'modal' | 'replace'\n>;\n\nexport interface OverlayOpenCloseDetail {\n interaction: TriggerInteractions;\n reason?: 'external-click';\n}\n\nexport interface OverlayCloseReasonDetail {\n reason?: 'external-click';\n}\n\nexport type OverlayOptions = {\n delayed?: boolean;\n notImmediatelyClosable?: boolean;\n offset?: number | [number, number]; // supporting multi-axis\n placement?: Placement;\n receivesFocus?: 'auto' | 'true' | 'false';\n trigger?: HTMLElement | VirtualTrigger;\n type?: 'modal' | 'page' | 'hint' | 'auto' | 'manual';\n};\n\nexport type OverlayOptionsV1 = {\n root?: HTMLElement;\n delayed?: boolean;\n placement?: Placement;\n offset?: number;\n receivesFocus?: 'true' | 'false' | 'auto';\n notImmediatelyClosable?: boolean;\n abortPromise?: Promise<boolean>;\n virtualTrigger?: VirtualTrigger;\n};\n\ndeclare global {\n interface GlobalEventHandlersEventMap {\n 'sp-open': CustomEvent<OverlayOpenCloseDetail>;\n 'sp-close': CustomEvent<OverlayOpenCloseDetail>;\n }\n}\n\nexport type OpenableElement = HTMLElement & {\n open: boolean;\n tipElement?: HTMLElement;\n updateComplete?: Promise<void>;\n};\n\nexport type OverlayState = 'closed' | 'opening' | 'opened' | 'closing';\n"],
5
- "mappings": ";AAqBA;",
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";export{};
1
+ "use strict";
2
2
  //# sourceMappingURL=overlay-types.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["overlay-types.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*/\n\nimport type { Placement } from '@floating-ui/dom';\nimport type { VirtualTrigger } from './VirtualTrigger.js';\n\nexport type Constructor<T = Record<string, unknown>> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (...args: any[]): T;\n prototype: T;\n};\n\nexport { Placement };\n\nexport type OverlayTypes = 'auto' | 'hint' | 'manual' | 'modal' | 'page';\n\nexport type TriggerInteractions = OverlayTypes;\n\nexport type TriggerInteractionsV1 =\n | 'click'\n | 'longpress'\n | 'hover'\n | 'custom'\n | 'replace'\n | 'inline'\n | 'modal';\n\nexport type OverlayTriggerInteractions = Extract<\n TriggerInteractions,\n 'inline' | 'modal' | 'replace'\n>;\n\nexport interface OverlayOpenCloseDetail {\n interaction: TriggerInteractions;\n reason?: 'external-click';\n}\n\nexport interface OverlayCloseReasonDetail {\n reason?: 'external-click';\n}\n\nexport type OverlayOptions = {\n delayed?: boolean;\n notImmediatelyClosable?: boolean;\n offset?: number | [number, number]; // supporting multi-axis\n placement?: Placement;\n receivesFocus?: 'auto' | 'true' | 'false';\n trigger?: HTMLElement | VirtualTrigger;\n type?: 'modal' | 'page' | 'hint' | 'auto' | 'manual';\n};\n\nexport type OverlayOptionsV1 = {\n root?: HTMLElement;\n delayed?: boolean;\n placement?: Placement;\n offset?: number;\n receivesFocus?: 'true' | 'false' | 'auto';\n notImmediatelyClosable?: boolean;\n abortPromise?: Promise<boolean>;\n virtualTrigger?: VirtualTrigger;\n};\n\ndeclare global {\n interface GlobalEventHandlersEventMap {\n 'sp-open': CustomEvent<OverlayOpenCloseDetail>;\n 'sp-close': CustomEvent<OverlayOpenCloseDetail>;\n }\n}\n\nexport type OpenableElement = HTMLElement & {\n open: boolean;\n tipElement?: HTMLElement;\n updateComplete?: Promise<void>;\n};\n\nexport type OverlayState = 'closed' | 'opening' | 'opened' | 'closing';\n"],
5
- "mappings": "aAqBA",
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,3 @@
1
+ import type { ActiveOverlay } from './ActiveOverlay';
2
+ export declare const parentOverlayOf: (el?: Element) => ActiveOverlay | null;
3
+ export declare const findOverlaysRootedInOverlay: (rootOverlay: ActiveOverlay | undefined, activeOverlays: ActiveOverlay[]) => ActiveOverlay[];
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ export const parentOverlayOf = (el) => {
3
+ if (!el)
4
+ return null;
5
+ const closestOverlay = el.closest("active-overlay");
6
+ if (closestOverlay) {
7
+ return closestOverlay;
8
+ }
9
+ const rootNode = el.getRootNode();
10
+ if (rootNode.host) {
11
+ return parentOverlayOf(rootNode.host);
12
+ }
13
+ return null;
14
+ };
15
+ export const findOverlaysRootedInOverlay = (rootOverlay, activeOverlays) => {
16
+ const overlays = [];
17
+ if (!rootOverlay)
18
+ return [];
19
+ for (const overlay of activeOverlays) {
20
+ if (!overlay.root)
21
+ continue;
22
+ if (parentOverlayOf(overlay.root) === rootOverlay) {
23
+ overlays.push(overlay);
24
+ overlays.push(
25
+ ...findOverlaysRootedInOverlay(overlay, activeOverlays)
26
+ );
27
+ }
28
+ }
29
+ return overlays;
30
+ };
31
+ //# sourceMappingURL=overlay-utils.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["overlay-utils.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2022 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*/\n\nimport type { ActiveOverlay } from './ActiveOverlay';\n\nexport const parentOverlayOf = (el?: Element): ActiveOverlay | null => {\n if (!el) return null;\n const closestOverlay = el.closest('active-overlay');\n if (closestOverlay) {\n return closestOverlay;\n }\n const rootNode = el.getRootNode() as ShadowRoot;\n if (rootNode.host) {\n return parentOverlayOf(rootNode.host);\n }\n return null;\n};\n\nexport const findOverlaysRootedInOverlay = (\n rootOverlay: ActiveOverlay | undefined,\n activeOverlays: ActiveOverlay[]\n): ActiveOverlay[] => {\n const overlays: ActiveOverlay[] = [];\n if (!rootOverlay) return [];\n for (const overlay of activeOverlays) {\n if (!overlay.root) continue;\n if (parentOverlayOf(overlay.root) === rootOverlay) {\n overlays.push(overlay);\n overlays.push(\n ...findOverlaysRootedInOverlay(overlay, activeOverlays)\n );\n }\n }\n return overlays;\n};\n"],
5
+ "mappings": ";AAcO,aAAM,kBAAkB,CAAC,OAAuC;AACnE,MAAI,CAAC;AAAI,WAAO;AAChB,QAAM,iBAAiB,GAAG,QAAQ,gBAAgB;AAClD,MAAI,gBAAgB;AAChB,WAAO;AAAA,EACX;AACA,QAAM,WAAW,GAAG,YAAY;AAChC,MAAI,SAAS,MAAM;AACf,WAAO,gBAAgB,SAAS,IAAI;AAAA,EACxC;AACA,SAAO;AACX;AAEO,aAAM,8BAA8B,CACvC,aACA,mBACkB;AAClB,QAAM,WAA4B,CAAC;AACnC,MAAI,CAAC;AAAa,WAAO,CAAC;AAC1B,aAAW,WAAW,gBAAgB;AAClC,QAAI,CAAC,QAAQ;AAAM;AACnB,QAAI,gBAAgB,QAAQ,IAAI,MAAM,aAAa;AAC/C,eAAS,KAAK,OAAO;AACrB,eAAS;AAAA,QACL,GAAG,4BAA4B,SAAS,cAAc;AAAA,MAC1D;AAAA,IACJ;AAAA,EACJ;AACA,SAAO;AACX;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";export const parentOverlayOf=e=>{if(!e)return null;const o=e.closest("active-overlay");if(o)return o;const t=e.getRootNode();return t.host?parentOverlayOf(t.host):null},findOverlaysRootedInOverlay=(e,o)=>{const t=[];if(!e)return[];for(const r of o)r.root&&parentOverlayOf(r.root)===e&&(t.push(r),t.push(...findOverlaysRootedInOverlay(r,o)));return t};
2
+ //# sourceMappingURL=overlay-utils.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["overlay-utils.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2022 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*/\n\nimport type { ActiveOverlay } from './ActiveOverlay';\n\nexport const parentOverlayOf = (el?: Element): ActiveOverlay | null => {\n if (!el) return null;\n const closestOverlay = el.closest('active-overlay');\n if (closestOverlay) {\n return closestOverlay;\n }\n const rootNode = el.getRootNode() as ShadowRoot;\n if (rootNode.host) {\n return parentOverlayOf(rootNode.host);\n }\n return null;\n};\n\nexport const findOverlaysRootedInOverlay = (\n rootOverlay: ActiveOverlay | undefined,\n activeOverlays: ActiveOverlay[]\n): ActiveOverlay[] => {\n const overlays: ActiveOverlay[] = [];\n if (!rootOverlay) return [];\n for (const overlay of activeOverlays) {\n if (!overlay.root) continue;\n if (parentOverlayOf(overlay.root) === rootOverlay) {\n overlays.push(overlay);\n overlays.push(\n ...findOverlaysRootedInOverlay(overlay, activeOverlays)\n );\n }\n }\n return overlays;\n};\n"],
5
+ "mappings": "aAcO,aAAM,gBAAmBA,GAAuC,CACnE,GAAI,CAACA,EAAI,OAAO,KAChB,MAAMC,EAAiBD,EAAG,QAAQ,gBAAgB,EAClD,GAAIC,EACA,OAAOA,EAEX,MAAMC,EAAWF,EAAG,YAAY,EAChC,OAAIE,EAAS,KACF,gBAAgBA,EAAS,IAAI,EAEjC,IACX,EAEa,4BAA8B,CACvCC,EACAC,IACkB,CAClB,MAAMC,EAA4B,CAAC,EACnC,GAAI,CAACF,EAAa,MAAO,CAAC,EAC1B,UAAWG,KAAWF,EACbE,EAAQ,MACT,gBAAgBA,EAAQ,IAAI,IAAMH,IAClCE,EAAS,KAAKC,CAAO,EACrBD,EAAS,KACL,GAAG,4BAA4BC,EAASF,CAAc,CAC1D,GAGR,OAAOC,CACX",
6
+ "names": ["el", "closestOverlay", "rootNode", "rootOverlay", "activeOverlays", "overlays", "overlay"]
7
+ }
@@ -0,0 +1,59 @@
1
+ import type { OverlayOptions, TriggerInteractions } from './overlay-types';
2
+ /**
3
+ * This class allows access to the overlay system which allows a client to
4
+ * position an element in the overlay positioned relative to another node.
5
+ */
6
+ export declare class Overlay {
7
+ private static overlayStack;
8
+ private isOpen;
9
+ private overlayElement;
10
+ private owner;
11
+ private interaction;
12
+ /**
13
+ *
14
+ * @param owner the parent element we will use to position the overlay element
15
+ * @param interaction the type of interaction that caused this overlay to be shown
16
+ * @param overlayElement the item to display as an overlay
17
+ */
18
+ constructor(owner: HTMLElement, interaction: TriggerInteractions, overlayElement: HTMLElement);
19
+ /**
20
+ * Open an overlay
21
+ *
22
+ * @param owner the parent element we will use to position the overlay element
23
+ * @param interaction the type of interaction that caused this overlay to be shown
24
+ * @param overlayElement the item to display as an overlay
25
+ * @param options display parameters
26
+ * @param options.delayed if true delay opening of the overlay based on the global warmup/cooldown timer
27
+ * @param options.offset distance to offset the overlay
28
+ * @param options.placement side on which to position the overlay
29
+ * @returns an Overlay object which can be used to close the overlay
30
+ */
31
+ static open(owner: HTMLElement, interaction: TriggerInteractions, overlayElement: HTMLElement, options: OverlayOptions): Promise<() => void>;
32
+ static update(): void;
33
+ /**
34
+ * Open an overlay
35
+ *
36
+ * @param options display parameters
37
+ * @param options.delayed delay before opening the overlay
38
+ * @param options.offset distance to offset the overlay
39
+ * @param options.placement side on which to position the overlay
40
+ * @returns a Promise that resolves to true if this operation was cancelled
41
+ */
42
+ open({ abortPromise, delayed, offset, placement, receivesFocus, notImmediatelyClosable, virtualTrigger, root, }: OverlayOptions): Promise<boolean>;
43
+ /**
44
+ * Close the overlay if it is open
45
+ */
46
+ close(): void;
47
+ }
48
+ /**
49
+ * Announces that an overlay-based UI element has opened
50
+ * @event sp-open
51
+ * @type {object}
52
+ * @property {TriggerInteractions} interaction type of interaction that triggered the opening
53
+ */
54
+ /**
55
+ * Announces that an overlay-based UI element has opened
56
+ * @event sp-close
57
+ * @type {object}
58
+ * @property {TriggerInteractions} interaction type of interaction that triggered the closing
59
+ */
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ import { OverlayStack } from "./overlay-stack.dev.js";
3
+ const _Overlay = class _Overlay {
4
+ /**
5
+ *
6
+ * @param owner the parent element we will use to position the overlay element
7
+ * @param interaction the type of interaction that caused this overlay to be shown
8
+ * @param overlayElement the item to display as an overlay
9
+ */
10
+ constructor(owner, interaction, overlayElement) {
11
+ this.isOpen = false;
12
+ this.owner = owner;
13
+ this.overlayElement = overlayElement;
14
+ this.interaction = interaction;
15
+ }
16
+ /**
17
+ * Open an overlay
18
+ *
19
+ * @param owner the parent element we will use to position the overlay element
20
+ * @param interaction the type of interaction that caused this overlay to be shown
21
+ * @param overlayElement the item to display as an overlay
22
+ * @param options display parameters
23
+ * @param options.delayed if true delay opening of the overlay based on the global warmup/cooldown timer
24
+ * @param options.offset distance to offset the overlay
25
+ * @param options.placement side on which to position the overlay
26
+ * @returns an Overlay object which can be used to close the overlay
27
+ */
28
+ static async open(owner, interaction, overlayElement, options) {
29
+ const overlay = new _Overlay(owner, interaction, overlayElement);
30
+ if (true) {
31
+ window.__swc.warn(
32
+ void 0,
33
+ "The Overlay API is currently being refactored and there are likely to be breaking changes, deprecations and/or removals in a future release. The SWC team wants feedback from direct Overlay API consumers like you - please share your thoughts on the future of overlays here:",
34
+ "https://github.com/adobe/spectrum-web-components/discussions/2764",
35
+ {
36
+ type: "default",
37
+ level: "deprecation"
38
+ }
39
+ );
40
+ }
41
+ await overlay.open(options);
42
+ return () => {
43
+ overlay.close();
44
+ };
45
+ }
46
+ static update() {
47
+ const overlayUpdateEvent = new CustomEvent("sp-update-overlays", {
48
+ bubbles: true,
49
+ composed: true,
50
+ cancelable: true
51
+ });
52
+ document.dispatchEvent(overlayUpdateEvent);
53
+ }
54
+ /**
55
+ * Open an overlay
56
+ *
57
+ * @param options display parameters
58
+ * @param options.delayed delay before opening the overlay
59
+ * @param options.offset distance to offset the overlay
60
+ * @param options.placement side on which to position the overlay
61
+ * @returns a Promise that resolves to true if this operation was cancelled
62
+ */
63
+ async open({
64
+ abortPromise,
65
+ delayed,
66
+ offset = 0,
67
+ placement = "top",
68
+ receivesFocus,
69
+ notImmediatelyClosable,
70
+ virtualTrigger,
71
+ root
72
+ }) {
73
+ if (this.isOpen)
74
+ return true;
75
+ if (delayed === void 0) {
76
+ delayed = this.overlayElement.hasAttribute("delayed");
77
+ }
78
+ const queryThemeDetail = {
79
+ color: void 0,
80
+ scale: void 0,
81
+ lang: void 0,
82
+ theme: void 0
83
+ };
84
+ const queryThemeEvent = new CustomEvent("sp-query-theme", {
85
+ bubbles: true,
86
+ composed: true,
87
+ detail: queryThemeDetail,
88
+ cancelable: true
89
+ });
90
+ this.owner.dispatchEvent(queryThemeEvent);
91
+ const overlayDetailQuery = {};
92
+ const queryOverlayDetailEvent = new CustomEvent("sp-overlay-query", {
93
+ bubbles: true,
94
+ composed: true,
95
+ detail: overlayDetailQuery,
96
+ cancelable: true
97
+ });
98
+ this.overlayElement.dispatchEvent(queryOverlayDetailEvent);
99
+ await _Overlay.overlayStack.openOverlay({
100
+ abortPromise,
101
+ content: this.overlayElement,
102
+ contentTip: overlayDetailQuery.overlayContentTipElement,
103
+ delayed,
104
+ offset,
105
+ placement,
106
+ trigger: this.owner,
107
+ interaction: this.interaction,
108
+ theme: queryThemeDetail,
109
+ receivesFocus,
110
+ root,
111
+ notImmediatelyClosable,
112
+ virtualTrigger,
113
+ ...overlayDetailQuery
114
+ });
115
+ this.isOpen = true;
116
+ return true;
117
+ }
118
+ /**
119
+ * Close the overlay if it is open
120
+ */
121
+ close() {
122
+ _Overlay.overlayStack.closeOverlay(this.overlayElement);
123
+ }
124
+ };
125
+ _Overlay.overlayStack = new OverlayStack();
126
+ export let Overlay = _Overlay;
127
+ //# sourceMappingURL=overlay.dev.js.map