@spectrum-web-components/overlay 1.1.0 → 1.1.1

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 (204) hide show
  1. package/overlay-trigger.d.ts +6 -0
  2. package/overlay-trigger.dev.js +5 -0
  3. package/overlay-trigger.dev.js.map +7 -0
  4. package/overlay-trigger.js +2 -0
  5. package/overlay-trigger.js.map +7 -0
  6. package/package.json +7 -7
  7. package/sp-overlay.d.ts +6 -0
  8. package/sp-overlay.dev.js +5 -0
  9. package/sp-overlay.dev.js.map +7 -0
  10. package/sp-overlay.js +2 -0
  11. package/sp-overlay.js.map +7 -0
  12. package/src/AbstractOverlay.d.ts +72 -0
  13. package/src/AbstractOverlay.dev.js +234 -0
  14. package/src/AbstractOverlay.dev.js.map +7 -0
  15. package/src/AbstractOverlay.js +2 -0
  16. package/src/AbstractOverlay.js.map +7 -0
  17. package/src/ClickController.d.ts +14 -0
  18. package/src/ClickController.dev.js +42 -0
  19. package/src/ClickController.dev.js.map +7 -0
  20. package/src/ClickController.js +2 -0
  21. package/src/ClickController.js.map +7 -0
  22. package/src/HoverController.d.ts +22 -0
  23. package/src/HoverController.dev.js +177 -0
  24. package/src/HoverController.dev.js.map +7 -0
  25. package/src/HoverController.js +2 -0
  26. package/src/HoverController.js.map +7 -0
  27. package/src/InteractionController.d.ts +44 -0
  28. package/src/InteractionController.dev.js +94 -0
  29. package/src/InteractionController.dev.js.map +7 -0
  30. package/src/InteractionController.js +2 -0
  31. package/src/InteractionController.js.map +7 -0
  32. package/src/LongpressController.d.ts +21 -0
  33. package/src/LongpressController.dev.js +156 -0
  34. package/src/LongpressController.dev.js.map +7 -0
  35. package/src/LongpressController.js +2 -0
  36. package/src/LongpressController.js.map +7 -0
  37. package/src/Overlay.d.ts +464 -0
  38. package/src/Overlay.dev.js +794 -0
  39. package/src/Overlay.dev.js.map +7 -0
  40. package/src/Overlay.js +33 -0
  41. package/src/Overlay.js.map +7 -0
  42. package/src/OverlayDialog.d.ts +4 -0
  43. package/src/OverlayDialog.dev.js +140 -0
  44. package/src/OverlayDialog.dev.js.map +7 -0
  45. package/src/OverlayDialog.js +2 -0
  46. package/src/OverlayDialog.js.map +7 -0
  47. package/src/OverlayNoPopover.d.ts +4 -0
  48. package/src/OverlayNoPopover.dev.js +117 -0
  49. package/src/OverlayNoPopover.dev.js.map +7 -0
  50. package/src/OverlayNoPopover.js +2 -0
  51. package/src/OverlayNoPopover.js.map +7 -0
  52. package/src/OverlayPopover.d.ts +4 -0
  53. package/src/OverlayPopover.dev.js +199 -0
  54. package/src/OverlayPopover.dev.js.map +7 -0
  55. package/src/OverlayPopover.js +2 -0
  56. package/src/OverlayPopover.js.map +7 -0
  57. package/src/OverlayStack.d.ts +44 -0
  58. package/src/OverlayStack.dev.js +163 -0
  59. package/src/OverlayStack.dev.js.map +7 -0
  60. package/src/OverlayStack.js +2 -0
  61. package/src/OverlayStack.js.map +7 -0
  62. package/src/OverlayTrigger.d.ts +52 -0
  63. package/src/OverlayTrigger.dev.js +243 -0
  64. package/src/OverlayTrigger.dev.js.map +7 -0
  65. package/src/OverlayTrigger.js +57 -0
  66. package/src/OverlayTrigger.js.map +7 -0
  67. package/src/PlacementController.d.ts +157 -0
  68. package/src/PlacementController.dev.js +287 -0
  69. package/src/PlacementController.dev.js.map +7 -0
  70. package/src/PlacementController.js +2 -0
  71. package/src/PlacementController.js.map +7 -0
  72. package/src/VirtualTrigger.d.ts +7 -0
  73. package/src/VirtualTrigger.dev.js +32 -0
  74. package/src/VirtualTrigger.dev.js.map +7 -0
  75. package/src/VirtualTrigger.js +2 -0
  76. package/src/VirtualTrigger.js.map +7 -0
  77. package/src/events.d.ts +23 -0
  78. package/src/events.dev.js +39 -0
  79. package/src/events.dev.js.map +7 -0
  80. package/src/events.js +2 -0
  81. package/src/events.js.map +7 -0
  82. package/src/fullSizePlugin.d.ts +12 -0
  83. package/src/fullSizePlugin.dev.js +39 -0
  84. package/src/fullSizePlugin.dev.js.map +7 -0
  85. package/src/fullSizePlugin.js +2 -0
  86. package/src/fullSizePlugin.js.map +7 -0
  87. package/src/index.d.ts +6 -0
  88. package/src/index.dev.js +8 -0
  89. package/src/index.dev.js.map +7 -0
  90. package/src/index.js +2 -0
  91. package/src/index.js.map +7 -0
  92. package/src/loader.d.ts +4 -0
  93. package/src/loader.dev.js +11 -0
  94. package/src/loader.dev.js.map +7 -0
  95. package/src/loader.js +2 -0
  96. package/src/loader.js.map +7 -0
  97. package/src/overlay-events.d.ts +11 -0
  98. package/src/overlay-events.dev.js +8 -0
  99. package/src/overlay-events.dev.js.map +7 -0
  100. package/src/overlay-events.js +2 -0
  101. package/src/overlay-events.js.map +7 -0
  102. package/src/overlay-timer.d.ts +22 -0
  103. package/src/overlay-timer.dev.js +72 -0
  104. package/src/overlay-timer.dev.js.map +7 -0
  105. package/src/overlay-timer.js +2 -0
  106. package/src/overlay-timer.js.map +7 -0
  107. package/src/overlay-trigger-directive.d.ts +26 -0
  108. package/src/overlay-trigger-directive.dev.js +87 -0
  109. package/src/overlay-trigger-directive.dev.js.map +7 -0
  110. package/src/overlay-trigger-directive.js +2 -0
  111. package/src/overlay-trigger-directive.js.map +7 -0
  112. package/src/overlay-trigger.css.d.ts +2 -0
  113. package/src/overlay-trigger.css.dev.js +7 -0
  114. package/src/overlay-trigger.css.dev.js.map +7 -0
  115. package/src/overlay-trigger.css.js +4 -0
  116. package/src/overlay-trigger.css.js.map +7 -0
  117. package/src/overlay-types.d.ts +50 -0
  118. package/src/overlay-types.dev.js +3 -0
  119. package/src/overlay-types.dev.js.map +7 -0
  120. package/src/overlay-types.js +2 -0
  121. package/src/overlay-types.js.map +7 -0
  122. package/src/overlay.css.d.ts +2 -0
  123. package/src/overlay.css.dev.js +7 -0
  124. package/src/overlay.css.dev.js.map +7 -0
  125. package/src/overlay.css.js +4 -0
  126. package/src/overlay.css.js.map +7 -0
  127. package/src/slottable-request-directive.d.ts +17 -0
  128. package/src/slottable-request-directive.dev.js +66 -0
  129. package/src/slottable-request-directive.dev.js.map +7 -0
  130. package/src/slottable-request-directive.js +2 -0
  131. package/src/slottable-request-directive.js.map +7 -0
  132. package/src/slottable-request-event.d.ts +12 -0
  133. package/src/slottable-request-event.dev.js +28 -0
  134. package/src/slottable-request-event.dev.js.map +7 -0
  135. package/src/slottable-request-event.js +2 -0
  136. package/src/slottable-request-event.js.map +7 -0
  137. package/src/strategies.d.ts +8 -0
  138. package/src/strategies.dev.js +10 -0
  139. package/src/strategies.dev.js.map +7 -0
  140. package/src/strategies.js +2 -0
  141. package/src/strategies.js.map +7 -0
  142. package/stories/index.js +48 -0
  143. package/stories/index.js.map +7 -0
  144. package/stories/overlay-directive.stories.js +340 -0
  145. package/stories/overlay-directive.stories.js.map +7 -0
  146. package/stories/overlay-element.stories.js +687 -0
  147. package/stories/overlay-element.stories.js.map +7 -0
  148. package/stories/overlay-story-components.js +338 -0
  149. package/stories/overlay-story-components.js.map +7 -0
  150. package/stories/overlay.stories.js +1412 -0
  151. package/stories/overlay.stories.js.map +7 -0
  152. package/sync/overlay-trigger.d.ts +6 -0
  153. package/sync/overlay-trigger.dev.js +6 -0
  154. package/sync/overlay-trigger.dev.js.map +7 -0
  155. package/sync/overlay-trigger.js +2 -0
  156. package/sync/overlay-trigger.js.map +7 -0
  157. package/test/benchmark/basic-test.js +40 -0
  158. package/test/benchmark/basic-test.js.map +7 -0
  159. package/test/benchmark/directive-test.js +43 -0
  160. package/test/benchmark/directive-test.js.map +7 -0
  161. package/test/benchmark/element-test.js +40 -0
  162. package/test/benchmark/element-test.js.map +7 -0
  163. package/test/benchmark/lazy-test.js +47 -0
  164. package/test/benchmark/lazy-test.js.map +7 -0
  165. package/test/index.js +605 -0
  166. package/test/index.js.map +7 -0
  167. package/test/overlay-directive.test-vrt.js +5 -0
  168. package/test/overlay-directive.test-vrt.js.map +7 -0
  169. package/test/overlay-directive.test.js +162 -0
  170. package/test/overlay-directive.test.js.map +7 -0
  171. package/test/overlay-element.test-vrt.js +5 -0
  172. package/test/overlay-element.test-vrt.js.map +7 -0
  173. package/test/overlay-element.test.js +934 -0
  174. package/test/overlay-element.test.js.map +7 -0
  175. package/test/overlay-lifecycle.test.js +139 -0
  176. package/test/overlay-lifecycle.test.js.map +7 -0
  177. package/test/overlay-memory.test.js +10 -0
  178. package/test/overlay-memory.test.js.map +7 -0
  179. package/test/overlay-timer.test.js +118 -0
  180. package/test/overlay-timer.test.js.map +7 -0
  181. package/test/overlay-trigger-click.test.js +164 -0
  182. package/test/overlay-trigger-click.test.js.map +7 -0
  183. package/test/overlay-trigger-directive.test.js +75 -0
  184. package/test/overlay-trigger-directive.test.js.map +7 -0
  185. package/test/overlay-trigger-extended.test.js +235 -0
  186. package/test/overlay-trigger-extended.test.js.map +7 -0
  187. package/test/overlay-trigger-hover-click.test.js +225 -0
  188. package/test/overlay-trigger-hover-click.test.js.map +7 -0
  189. package/test/overlay-trigger-hover.test.js +308 -0
  190. package/test/overlay-trigger-hover.test.js.map +7 -0
  191. package/test/overlay-trigger-longpress.test.js +531 -0
  192. package/test/overlay-trigger-longpress.test.js.map +7 -0
  193. package/test/overlay-trigger-sync.test.js +5 -0
  194. package/test/overlay-trigger-sync.test.js.map +7 -0
  195. package/test/overlay-trigger.test.js +5 -0
  196. package/test/overlay-trigger.test.js.map +7 -0
  197. package/test/overlay-update.test.js +28 -0
  198. package/test/overlay-update.test.js.map +7 -0
  199. package/test/overlay-v1.test.js +569 -0
  200. package/test/overlay-v1.test.js.map +7 -0
  201. package/test/overlay.test-vrt.js +5 -0
  202. package/test/overlay.test-vrt.js.map +7 -0
  203. package/test/overlay.test.js +865 -0
  204. package/test/overlay.test.js.map +7 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["OverlayTrigger.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 {\n CSSResultArray,\n html,\n PropertyValues,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n query,\n state,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport type { Placement } from '@floating-ui/dom';\n\nimport type { BeforetoggleOpenEvent } from './events.js';\nimport type { Overlay } from './Overlay.js';\nimport type { OverlayTriggerInteractions } from './overlay-types';\n\nimport overlayTriggerStyles from './overlay-trigger.css.js';\n\nexport type OverlayContentTypes = 'click' | 'hover' | 'longpress';\n\n/**\n * @element overlay-trigger\n *\n * @slot trigger - The content that will trigger the various overlays\n * @slot hover-content - The content that will be displayed on hover\n * @slot click-content - The content that will be displayed on click\n * @slot longpress-content - The content that will be displayed on click\n *\n * @fires sp-opened - Announces that the overlay has been opened\n * @fires sp-closed - Announces that the overlay has been closed\n */\nexport class OverlayTrigger extends SpectrumElement {\n public static override get styles(): CSSResultArray {\n return [overlayTriggerStyles];\n }\n\n @property()\n content = 'click hover longpress';\n\n /**\n * @type {\"top\" | \"top-start\" | \"top-end\" | \"right\" | \"right-start\" | \"right-end\" | \"bottom\" | \"bottom-start\" | \"bottom-end\" | \"left\" | \"left-start\" | \"left-end\"}\n * @attr\n */\n @property({ reflect: true })\n public placement?: Placement;\n\n @property()\n public type?: OverlayTriggerInteractions;\n\n @property({ type: Number })\n public offset = 6;\n\n @property({ reflect: true })\n public open?: OverlayContentTypes;\n\n @property({ type: Boolean, reflect: true })\n public disabled = false;\n\n @property({ attribute: 'receives-focus' })\n public receivesFocus: 'true' | 'false' | 'auto' = 'auto';\n\n @state()\n private clickContent: HTMLElement[] = [];\n\n private clickPlacement?: Placement;\n\n @state()\n private longpressContent: HTMLElement[] = [];\n\n private longpressPlacement?: Placement;\n\n @state()\n private hoverContent: HTMLElement[] = [];\n\n private hoverPlacement?: Placement;\n\n @state()\n private targetContent: HTMLElement[] = [];\n\n @query('#click-overlay', true)\n clickOverlayElement!: Overlay;\n\n @query('#longpress-overlay', true)\n longpressOverlayElement!: Overlay;\n\n @query('#hover-overlay', true)\n hoverOverlayElement!: Overlay;\n\n private getAssignedElementsFromSlot(slot: HTMLSlotElement): HTMLElement[] {\n return slot.assignedElements({ flatten: true }) as HTMLElement[];\n }\n\n private handleTriggerContent(\n event: Event & { target: HTMLSlotElement }\n ): void {\n this.targetContent = this.getAssignedElementsFromSlot(event.target);\n }\n\n private handleSlotContent(\n event: Event & { target: HTMLSlotElement }\n ): void {\n switch (event.target.name) {\n case 'click-content':\n this.clickContent = this.getAssignedElementsFromSlot(\n event.target\n );\n break;\n case 'longpress-content':\n this.longpressContent = this.getAssignedElementsFromSlot(\n event.target\n );\n break;\n case 'hover-content':\n this.hoverContent = this.getAssignedElementsFromSlot(\n event.target\n );\n break;\n }\n }\n\n private handleBeforetoggle(event: BeforetoggleOpenEvent): void {\n const { target } = event;\n let type: OverlayContentTypes;\n if (target === this.clickOverlayElement) {\n type = 'click';\n } else if (target === this.longpressOverlayElement) {\n type = 'longpress';\n } else if (target === this.hoverOverlayElement) {\n type = 'hover';\n /* c8 ignore next 3 */\n } else {\n return;\n }\n if (event.newState === 'open') {\n this.open = type;\n } else if (this.open === type) {\n this.open = undefined;\n }\n }\n\n protected override update(changes: PropertyValues): void {\n if (changes.has('clickContent')) {\n this.clickPlacement =\n ((this.clickContent[0]?.getAttribute('placement') ||\n this.clickContent[0]?.getAttribute(\n 'direction'\n )) as Placement) || undefined;\n }\n if (changes.has('hoverContent')) {\n this.hoverPlacement =\n ((this.hoverContent[0]?.getAttribute('placement') ||\n this.hoverContent[0]?.getAttribute(\n 'direction'\n )) as Placement) || undefined;\n }\n if (changes.has('longpressContent')) {\n this.longpressPlacement =\n ((this.longpressContent[0]?.getAttribute('placement') ||\n this.longpressContent[0]?.getAttribute(\n 'direction'\n )) as Placement) || undefined;\n }\n super.update(changes);\n }\n\n protected renderSlot(name: string): TemplateResult {\n return html`\n <slot name=${name} @slotchange=${this.handleSlotContent}></slot>\n `;\n }\n\n protected renderClickOverlay(): TemplateResult {\n import('@spectrum-web-components/overlay/sp-overlay.js');\n const slot = this.renderSlot('click-content');\n if (!this.clickContent.length) {\n return slot;\n }\n return html`\n <sp-overlay\n id=\"click-overlay\"\n ?disabled=${this.disabled || !this.clickContent.length}\n ?open=${this.open === 'click' && !!this.clickContent.length}\n .offset=${this.offset}\n .placement=${this.clickPlacement || this.placement}\n .triggerElement=${this.targetContent[0]}\n .triggerInteraction=${'click'}\n .type=${this.type !== 'modal' ? 'auto' : 'modal'}\n @beforetoggle=${this.handleBeforetoggle}\n .receivesFocus=${this.receivesFocus}\n >\n ${slot}\n </sp-overlay>\n `;\n }\n\n protected renderHoverOverlay(): TemplateResult {\n import('@spectrum-web-components/overlay/sp-overlay.js');\n const slot = this.renderSlot('hover-content');\n if (!this.hoverContent.length) {\n return slot;\n }\n return html`\n <sp-overlay\n id=\"hover-overlay\"\n ?open=${this.open === 'hover' && !!this.hoverContent.length}\n ?disabled=${this.disabled ||\n !this.hoverContent.length ||\n (!!this.open && this.open !== 'hover')}\n .offset=${this.offset}\n .placement=${this.hoverPlacement || this.placement}\n .triggerElement=${this.targetContent[0]}\n .triggerInteraction=${'hover'}\n .type=${'hint'}\n @beforetoggle=${this.handleBeforetoggle}\n .receivesFocus=${this.receivesFocus}\n >\n ${slot}\n </sp-overlay>\n `;\n }\n\n protected renderLongpressOverlay(): TemplateResult {\n import('@spectrum-web-components/overlay/sp-overlay.js');\n const slot = this.renderSlot('longpress-content');\n if (!this.longpressContent.length) {\n return slot;\n }\n return html`\n <sp-overlay\n id=\"longpress-overlay\"\n ?disabled=${this.disabled || !this.longpressContent.length}\n ?open=${this.open === 'longpress' &&\n !!this.longpressContent.length}\n .offset=${this.offset}\n .placement=${this.longpressPlacement || this.placement}\n .triggerElement=${this.targetContent[0]}\n .triggerInteraction=${'longpress'}\n .type=${'auto'}\n @beforetoggle=${this.handleBeforetoggle}\n .receivesFocus=${this.receivesFocus}\n >\n ${slot}\n </sp-overlay>\n <slot name=\"longpress-describedby-descriptor\"></slot>\n `;\n }\n\n protected override render(): TemplateResult {\n const content = this.content.split(' ');\n // Keyboard event availability documented in README.md\n /* eslint-disable lit-a11y/click-events-have-key-events */\n return html`\n <slot\n id=\"trigger\"\n name=\"trigger\"\n @slotchange=${this.handleTriggerContent}\n ></slot>\n ${[\n content.includes('click') ? this.renderClickOverlay() : html``,\n content.includes('hover') ? this.renderHoverOverlay() : html``,\n content.includes('longpress')\n ? this.renderLongpressOverlay()\n : html``,\n ]}\n `;\n /* eslint-enable lit-a11y/click-events-have-key-events */\n }\n\n protected override updated(changes: PropertyValues): void {\n super.updated(changes);\n if (this.disabled && changes.has('disabled')) {\n this.open = undefined;\n return;\n }\n }\n\n protected override async getUpdateComplete(): Promise<boolean> {\n const complete = (await super.getUpdateComplete()) as boolean;\n return complete;\n }\n}\n"],
5
+ "mappings": "qNAYA,OAEI,QAAAA,EAEA,mBAAAC,MAEG,gCACP,OACI,YAAAC,EACA,SAAAC,EACA,SAAAC,MACG,kDAOP,OAAOC,MAA0B,2BAe1B,aAAM,uBAAuBJ,CAAgB,CAA7C,kCAMH,aAAU,wBAaV,KAAO,OAAS,EAMhB,KAAO,SAAW,GAGlB,KAAO,cAA2C,OAGlD,KAAQ,aAA8B,CAAC,EAKvC,KAAQ,iBAAkC,CAAC,EAK3C,KAAQ,aAA8B,CAAC,EAKvC,KAAQ,cAA+B,CAAC,EA7CxC,WAA2B,QAAyB,CAChD,MAAO,CAACI,CAAoB,CAChC,CAsDQ,4BAA4BC,EAAsC,CACtE,OAAOA,EAAK,iBAAiB,CAAE,QAAS,EAAK,CAAC,CAClD,CAEQ,qBACJC,EACI,CACJ,KAAK,cAAgB,KAAK,4BAA4BA,EAAM,M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,GA3BhC,eA4BF,6BAGCiB,EAAA,CADPf,EAAM,GA9BE,eA+BD,4BAKAe,EAAA,CADPf,EAAM,GAnCE,eAoCD,gCAKAe,EAAA,CADPf,EAAM,GAxCE,eAyCD,4BAKAe,EAAA,CADPf,EAAM,GA7CE,eA8CD,6BAGRe,EAAA,CADChB,EAAM,iBAAkB,EAAI,GAhDpB,eAiDT,mCAGAgB,EAAA,CADChB,EAAM,qBAAsB,EAAI,GAnDxB,eAoDT,uCAGAgB,EAAA,CADChB,EAAM,iBAAkB,EAAI,GAtDpB,eAuDT",
6
+ "names": ["html", "SpectrumElement", "property", "query", "state", "overlayTriggerStyles", "slot", "event", "target", "type", "changes", "_a", "_b", "_c", "_d", "_e", "_f", "name", "content", "__decorateClass"]
7
+ }
@@ -0,0 +1,157 @@
1
+ import type { ReactiveController, ReactiveElement } from '@spectrum-web-components/base';
2
+ import { Placement } from '@floating-ui/dom';
3
+ import type { VirtualTrigger } from './VirtualTrigger.js';
4
+ import type { OpenableElement } from './overlay-types.js';
5
+ type OverlayOptionsV1 = {
6
+ abortPromise?: Promise<boolean>;
7
+ delayed?: boolean;
8
+ offset?: number | [number, number];
9
+ placement: Placement;
10
+ notImmediatelyClosable?: boolean;
11
+ receivesFocus?: 'auto';
12
+ root?: HTMLElement;
13
+ tipPadding?: number;
14
+ trigger: HTMLElement | VirtualTrigger;
15
+ type?: 'modal' | 'page' | 'hint' | 'auto' | 'manual';
16
+ };
17
+ /**
18
+ * Symbol used to indicate that the placement has been updated.
19
+ */
20
+ export declare const placementUpdatedSymbol: unique symbol;
21
+ /**
22
+ * Controller for managing the placement of an overlay.
23
+ *
24
+ * This class implements the ReactiveController interface and provides methods
25
+ * for managing the positioning and constraints of an overlay element.
26
+ */
27
+ export declare class PlacementController implements ReactiveController {
28
+ /**
29
+ * Function to clean up resources when the controller is no longer needed.
30
+ *
31
+ * @private
32
+ */
33
+ private cleanup?;
34
+ /**
35
+ * Initial height of the overlay.
36
+ *
37
+ * @type {number}
38
+ */
39
+ initialHeight?: number;
40
+ /**
41
+ * Indicates whether the overlay is constrained by available space.
42
+ *
43
+ * @type {boolean}
44
+ */
45
+ isConstrained?: boolean;
46
+ /**
47
+ * The host element that uses this controller.
48
+ *
49
+ * @private
50
+ * @type {ReactiveElement & { elements: OpenableElement[] }}
51
+ */
52
+ private host;
53
+ /**
54
+ * Options for configuring the overlay placement.
55
+ *
56
+ * @private
57
+ * @type {OverlayOptionsV1}
58
+ */
59
+ private options;
60
+ /**
61
+ * A WeakMap to store the original placements of overlay elements.
62
+ *
63
+ * @private
64
+ * @type {WeakMap<HTMLElement, Placement>}
65
+ */
66
+ private originalPlacements;
67
+ /**
68
+ * The target element for the overlay.
69
+ *
70
+ * @private
71
+ * @type {HTMLElement}
72
+ */
73
+ private target;
74
+ /**
75
+ * Creates an instance of the PlacementController.
76
+ *
77
+ * @param {ReactiveElement & { elements: OpenableElement[] }} host - The host element that uses this controller.
78
+ */
79
+ constructor(host: ReactiveElement & {
80
+ elements: OpenableElement[];
81
+ });
82
+ /**
83
+ * Places the overlay relative to the target element.
84
+ *
85
+ * This method sets up the necessary configurations and event listeners to manage the
86
+ * positioning and constraints of the overlay element.
87
+ *
88
+ * @param {HTMLElement} [target=this.target] - The target element for the overlay.
89
+ * @param {OverlayOptionsV1} [options=this.options] - The options for configuring the overlay placement.
90
+ * @returns {Promise<void>} A promise that resolves when the overlay has been placed.
91
+ */
92
+ placeOverlay(target?: HTMLElement, options?: OverlayOptionsV1): Promise<void>;
93
+ /**
94
+ * Flag to allow or disallow placement updates.
95
+ *
96
+ * @type {boolean}
97
+ */
98
+ allowPlacementUpdate: boolean;
99
+ /**
100
+ * Closes the overlay if an ancestor element is updated.
101
+ *
102
+ * This method checks if placement updates are allowed and if the overlay type is not 'modal'.
103
+ * If these conditions are met and a cleanup function is defined, it dispatches a 'close' event
104
+ * on the target element to close the overlay.
105
+ */
106
+ closeForAncestorUpdate: () => void;
107
+ /**
108
+ * Updates the placement of the overlay.
109
+ *
110
+ * This method calls the computePlacement method to recalculate the overlay's position.
111
+ *
112
+ * @private
113
+ */
114
+ private updatePlacement;
115
+ /**
116
+ * Computes the placement of the overlay relative to the target element.
117
+ *
118
+ * This method calculates the necessary positioning and constraints for the overlay element
119
+ * using various middleware functions. It updates the overlay's style and attributes based
120
+ * on the computed position.
121
+ *
122
+ * @returns {Promise<void>} A promise that resolves when the placement has been computed.
123
+ */
124
+ computePlacement(): Promise<void>;
125
+ /**
126
+ * Clears the overlay's position styles.
127
+ *
128
+ * This method removes the max-height and max-width styles from the target element,
129
+ * and resets the initial height and constrained state of the overlay.
130
+ */
131
+ clearOverlayPosition(): void;
132
+ /**
133
+ * Resets the overlay's position.
134
+ *
135
+ * This method clears the overlay's position, forces a reflow, and recomputes the placement.
136
+ */
137
+ resetOverlayPosition: () => void;
138
+ /**
139
+ * Lifecycle method called when the host element is connected to the DOM.
140
+ *
141
+ * This method sets up an event listener to reset the overlay's position when the 'sp-update-overlays' event is dispatched.
142
+ */
143
+ hostConnected(): void;
144
+ /**
145
+ * Lifecycle method called when the host element is updated.
146
+ *
147
+ * This method cleans up resources if the overlay is not open.
148
+ */
149
+ hostUpdated(): void;
150
+ /**
151
+ * Lifecycle method called when the host element is disconnected from the DOM.
152
+ *
153
+ * This method removes the event listener and cleans up resources.
154
+ */
155
+ hostDisconnected(): void;
156
+ }
157
+ export {};
@@ -0,0 +1,287 @@
1
+ "use strict";
2
+ import {
3
+ arrow,
4
+ autoUpdate,
5
+ computePosition,
6
+ flip,
7
+ offset,
8
+ shift,
9
+ size
10
+ } from "@floating-ui/dom";
11
+ function roundByDPR(num) {
12
+ if (typeof num === "undefined") return 0;
13
+ const dpr = window.devicePixelRatio || 1;
14
+ return Math.round(num * dpr) / dpr;
15
+ }
16
+ const REQUIRED_DISTANCE_TO_EDGE = 8;
17
+ const MIN_OVERLAY_HEIGHT = 100;
18
+ const getFallbackPlacements = (placement) => {
19
+ var _a;
20
+ const fallbacks = {
21
+ left: ["right", "bottom", "top"],
22
+ "left-start": ["right-start", "bottom", "top"],
23
+ "left-end": ["right-end", "bottom", "top"],
24
+ right: ["left", "bottom", "top"],
25
+ "right-start": ["left-start", "bottom", "top"],
26
+ "right-end": ["left-end", "bottom", "top"],
27
+ top: ["bottom", "left", "right"],
28
+ "top-start": ["bottom-start", "left", "right"],
29
+ "top-end": ["bottom-end", "left", "right"],
30
+ bottom: ["top", "left", "right"],
31
+ "bottom-start": ["top-start", "left", "right"],
32
+ "bottom-end": ["top-end", "left", "right"]
33
+ };
34
+ return (_a = fallbacks[placement]) != null ? _a : [placement];
35
+ };
36
+ export const placementUpdatedSymbol = Symbol("placement updated");
37
+ export class PlacementController {
38
+ /**
39
+ * Creates an instance of the PlacementController.
40
+ *
41
+ * @param {ReactiveElement & { elements: OpenableElement[] }} host - The host element that uses this controller.
42
+ */
43
+ constructor(host) {
44
+ /**
45
+ * A WeakMap to store the original placements of overlay elements.
46
+ *
47
+ * @private
48
+ * @type {WeakMap<HTMLElement, Placement>}
49
+ */
50
+ this.originalPlacements = /* @__PURE__ */ new WeakMap();
51
+ /**
52
+ * Flag to allow or disallow placement updates.
53
+ *
54
+ * @type {boolean}
55
+ */
56
+ this.allowPlacementUpdate = false;
57
+ /**
58
+ * Closes the overlay if an ancestor element is updated.
59
+ *
60
+ * This method checks if placement updates are allowed and if the overlay type is not 'modal'.
61
+ * If these conditions are met and a cleanup function is defined, it dispatches a 'close' event
62
+ * on the target element to close the overlay.
63
+ */
64
+ this.closeForAncestorUpdate = () => {
65
+ if (!this.allowPlacementUpdate && this.options.type !== "modal" && this.cleanup) {
66
+ this.target.dispatchEvent(new Event("close", { bubbles: true }));
67
+ }
68
+ this.allowPlacementUpdate = false;
69
+ };
70
+ /**
71
+ * Updates the placement of the overlay.
72
+ *
73
+ * This method calls the computePlacement method to recalculate the overlay's position.
74
+ *
75
+ * @private
76
+ */
77
+ this.updatePlacement = () => {
78
+ this.computePlacement();
79
+ };
80
+ /**
81
+ * Resets the overlay's position.
82
+ *
83
+ * This method clears the overlay's position, forces a reflow, and recomputes the placement.
84
+ */
85
+ this.resetOverlayPosition = () => {
86
+ if (!this.target || !this.options) return;
87
+ this.clearOverlayPosition();
88
+ this.host.offsetHeight;
89
+ this.computePlacement();
90
+ };
91
+ this.host = host;
92
+ this.host.addController(this);
93
+ }
94
+ /**
95
+ * Places the overlay relative to the target element.
96
+ *
97
+ * This method sets up the necessary configurations and event listeners to manage the
98
+ * positioning and constraints of the overlay element.
99
+ *
100
+ * @param {HTMLElement} [target=this.target] - The target element for the overlay.
101
+ * @param {OverlayOptionsV1} [options=this.options] - The options for configuring the overlay placement.
102
+ * @returns {Promise<void>} A promise that resolves when the overlay has been placed.
103
+ */
104
+ async placeOverlay(target = this.target, options = this.options) {
105
+ this.target = target;
106
+ this.options = options;
107
+ if (!target || !options) return;
108
+ const cleanupAncestorResize = autoUpdate(
109
+ options.trigger,
110
+ target,
111
+ this.closeForAncestorUpdate,
112
+ {
113
+ ancestorResize: false,
114
+ elementResize: false,
115
+ layoutShift: false
116
+ }
117
+ );
118
+ const cleanupElementResize = autoUpdate(
119
+ options.trigger,
120
+ target,
121
+ this.updatePlacement,
122
+ {
123
+ ancestorScroll: false
124
+ }
125
+ );
126
+ this.cleanup = () => {
127
+ var _a;
128
+ (_a = this.host.elements) == null ? void 0 : _a.forEach((element) => {
129
+ element.addEventListener(
130
+ "sp-closed",
131
+ () => {
132
+ const placement = this.originalPlacements.get(element);
133
+ if (placement) {
134
+ element.setAttribute("placement", placement);
135
+ }
136
+ this.originalPlacements.delete(element);
137
+ },
138
+ { once: true }
139
+ );
140
+ });
141
+ cleanupAncestorResize();
142
+ cleanupElementResize();
143
+ };
144
+ }
145
+ /**
146
+ * Computes the placement of the overlay relative to the target element.
147
+ *
148
+ * This method calculates the necessary positioning and constraints for the overlay element
149
+ * using various middleware functions. It updates the overlay's style and attributes based
150
+ * on the computed position.
151
+ *
152
+ * @returns {Promise<void>} A promise that resolves when the placement has been computed.
153
+ */
154
+ async computePlacement() {
155
+ var _a, _b;
156
+ const { options, target } = this;
157
+ await (document.fonts ? document.fonts.ready : Promise.resolve());
158
+ const flipMiddleware = !(options.trigger instanceof HTMLElement) ? flip({
159
+ padding: REQUIRED_DISTANCE_TO_EDGE,
160
+ fallbackPlacements: getFallbackPlacements(options.placement)
161
+ }) : flip();
162
+ const [mainAxis = 0, crossAxis = 0] = Array.isArray(options == null ? void 0 : options.offset) ? options.offset : [options.offset, 0];
163
+ const tipElement = (_a = this.host.elements.find(
164
+ (el) => el.tipElement
165
+ )) == null ? void 0 : _a.tipElement;
166
+ const middleware = [
167
+ offset({
168
+ mainAxis,
169
+ crossAxis
170
+ }),
171
+ shift({ padding: REQUIRED_DISTANCE_TO_EDGE }),
172
+ flipMiddleware,
173
+ size({
174
+ padding: REQUIRED_DISTANCE_TO_EDGE,
175
+ apply: ({
176
+ availableWidth,
177
+ availableHeight,
178
+ rects: { floating }
179
+ }) => {
180
+ const maxHeight = Math.max(
181
+ MIN_OVERLAY_HEIGHT,
182
+ Math.floor(availableHeight)
183
+ );
184
+ const actualHeight = floating.height;
185
+ this.initialHeight = !this.isConstrained ? actualHeight : this.initialHeight || actualHeight;
186
+ this.isConstrained = actualHeight < this.initialHeight || maxHeight <= actualHeight;
187
+ const appliedHeight = this.isConstrained ? `${maxHeight}px` : "";
188
+ Object.assign(target.style, {
189
+ maxWidth: `${Math.floor(availableWidth)}px`,
190
+ maxHeight: appliedHeight
191
+ });
192
+ }
193
+ }),
194
+ ...tipElement ? [
195
+ arrow({
196
+ element: tipElement,
197
+ padding: options.tipPadding || REQUIRED_DISTANCE_TO_EDGE
198
+ })
199
+ ] : []
200
+ ];
201
+ const { x, y, placement, middlewareData } = await computePosition(
202
+ options.trigger,
203
+ target,
204
+ {
205
+ placement: options.placement,
206
+ middleware,
207
+ strategy: "fixed"
208
+ }
209
+ );
210
+ Object.assign(target.style, {
211
+ top: "0px",
212
+ left: "0px",
213
+ translate: `${roundByDPR(x)}px ${roundByDPR(y)}px`
214
+ });
215
+ target.setAttribute("actual-placement", placement);
216
+ (_b = this.host.elements) == null ? void 0 : _b.forEach((element) => {
217
+ if (!this.originalPlacements.has(element)) {
218
+ this.originalPlacements.set(
219
+ element,
220
+ element.getAttribute("placement")
221
+ );
222
+ }
223
+ element.setAttribute("placement", placement);
224
+ });
225
+ if (tipElement && middlewareData.arrow) {
226
+ const { x: arrowX, y: arrowY } = middlewareData.arrow;
227
+ Object.assign(tipElement.style, {
228
+ top: placement.startsWith("right") || placement.startsWith("left") ? "0px" : "",
229
+ left: placement.startsWith("bottom") || placement.startsWith("top") ? "0px" : "",
230
+ translate: `${roundByDPR(arrowX)}px ${roundByDPR(arrowY)}px`
231
+ });
232
+ }
233
+ }
234
+ /**
235
+ * Clears the overlay's position styles.
236
+ *
237
+ * This method removes the max-height and max-width styles from the target element,
238
+ * and resets the initial height and constrained state of the overlay.
239
+ */
240
+ clearOverlayPosition() {
241
+ if (!this.target) {
242
+ return;
243
+ }
244
+ this.target.style.removeProperty("max-height");
245
+ this.target.style.removeProperty("max-width");
246
+ this.initialHeight = void 0;
247
+ this.isConstrained = false;
248
+ }
249
+ /**
250
+ * Lifecycle method called when the host element is connected to the DOM.
251
+ *
252
+ * This method sets up an event listener to reset the overlay's position when the 'sp-update-overlays' event is dispatched.
253
+ */
254
+ hostConnected() {
255
+ document.addEventListener(
256
+ "sp-update-overlays",
257
+ this.resetOverlayPosition
258
+ );
259
+ }
260
+ /**
261
+ * Lifecycle method called when the host element is updated.
262
+ *
263
+ * This method cleans up resources if the overlay is not open.
264
+ */
265
+ hostUpdated() {
266
+ var _a;
267
+ if (!this.host.open) {
268
+ (_a = this.cleanup) == null ? void 0 : _a.call(this);
269
+ this.cleanup = void 0;
270
+ }
271
+ }
272
+ /**
273
+ * Lifecycle method called when the host element is disconnected from the DOM.
274
+ *
275
+ * This method removes the event listener and cleans up resources.
276
+ */
277
+ hostDisconnected() {
278
+ var _a;
279
+ (_a = this.cleanup) == null ? void 0 : _a.call(this);
280
+ this.cleanup = void 0;
281
+ document.removeEventListener(
282
+ "sp-update-overlays",
283
+ this.resetOverlayPosition
284
+ );
285
+ }
286
+ }
287
+ //# sourceMappingURL=PlacementController.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["PlacementController.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 {\n ReactiveController,\n ReactiveElement,\n} from '@spectrum-web-components/base';\nimport {\n arrow,\n autoUpdate,\n computePosition,\n flip,\n offset,\n Placement,\n shift,\n size,\n} from '@floating-ui/dom';\nimport type { VirtualTrigger } from './VirtualTrigger.dev.js'\nimport type { OpenableElement } from './overlay-types.dev.js'\nimport type { Overlay } from './Overlay.dev.js'\n\ntype OverlayOptionsV1 = {\n abortPromise?: Promise<boolean>;\n delayed?: boolean;\n offset?: number | [number, number]; // supporting multi-axis\n placement: Placement;\n notImmediatelyClosable?: boolean; // rename or place behind other API options\n receivesFocus?: 'auto';\n root?: HTMLElement;\n tipPadding?: number;\n trigger: HTMLElement | VirtualTrigger;\n type?: 'modal' | 'page' | 'hint' | 'auto' | 'manual';\n};\n\n/**\n * Rounds a number by the device pixel ratio (DPR).\n *\n * @param {number} [num] - The number to round.\n * @returns {number} The rounded number.\n */\nfunction roundByDPR(num?: number): number {\n if (typeof num === 'undefined') return 0;\n const dpr = window.devicePixelRatio || 1;\n return Math.round(num * dpr) / dpr;\n}\n\n// Minimum distance required between the overlay and the edge of the container.\n// See: https://spectrum.adobe.com/page/popover/#Container-padding\nconst REQUIRED_DISTANCE_TO_EDGE = 8;\n// Minimum height for the overlay.\n// See: https://github.com/adobe/spectrum-web-components/issues/910\nconst MIN_OVERLAY_HEIGHT = 100;\n\n/**\n * Gets fallback placements for the overlay based on the initial placement.\n *\n * @param {Placement} placement - The initial placement of the overlay.\n * @returns {Placement[]} An array of fallback placements.\n */\nconst getFallbackPlacements = (placement: Placement): Placement[] => {\n const fallbacks: Record<Placement, Placement[]> = {\n left: ['right', 'bottom', 'top'],\n 'left-start': ['right-start', 'bottom', 'top'],\n 'left-end': ['right-end', 'bottom', 'top'],\n right: ['left', 'bottom', 'top'],\n 'right-start': ['left-start', 'bottom', 'top'],\n 'right-end': ['left-end', 'bottom', 'top'],\n top: ['bottom', 'left', 'right'],\n 'top-start': ['bottom-start', 'left', 'right'],\n 'top-end': ['bottom-end', 'left', 'right'],\n bottom: ['top', 'left', 'right'],\n 'bottom-start': ['top-start', 'left', 'right'],\n 'bottom-end': ['top-end', 'left', 'right'],\n };\n return fallbacks[placement] ?? [placement];\n};\n\n/**\n * Symbol used to indicate that the placement has been updated.\n */\nexport const placementUpdatedSymbol = Symbol('placement updated');\n\n/**\n * Controller for managing the placement of an overlay.\n *\n * This class implements the ReactiveController interface and provides methods\n * for managing the positioning and constraints of an overlay element.\n */\nexport class PlacementController implements ReactiveController {\n /**\n * Function to clean up resources when the controller is no longer needed.\n *\n * @private\n */\n private cleanup?: () => void;\n\n /**\n * Initial height of the overlay.\n *\n * @type {number}\n */\n initialHeight?: number;\n\n /**\n * Indicates whether the overlay is constrained by available space.\n *\n * @type {boolean}\n */\n isConstrained?: boolean;\n\n /**\n * The host element that uses this controller.\n *\n * @private\n * @type {ReactiveElement & { elements: OpenableElement[] }}\n */\n private host!: ReactiveElement & { elements: OpenableElement[] };\n\n /**\n * Options for configuring the overlay placement.\n *\n * @private\n * @type {OverlayOptionsV1}\n */\n private options!: OverlayOptionsV1;\n\n /**\n * A WeakMap to store the original placements of overlay elements.\n *\n * @private\n * @type {WeakMap<HTMLElement, Placement>}\n */\n private originalPlacements = new WeakMap<HTMLElement, Placement>();\n\n /**\n * The target element for the overlay.\n *\n * @private\n * @type {HTMLElement}\n */\n private target!: HTMLElement;\n\n /**\n * Creates an instance of the PlacementController.\n *\n * @param {ReactiveElement & { elements: OpenableElement[] }} host - The host element that uses this controller.\n */\n constructor(host: ReactiveElement & { elements: OpenableElement[] }) {\n this.host = host;\n // Add the controller after the MutationObserver has been created in preparation\n // for the `hostConnected`/`hostDisconnected` callbacks to be run.\n this.host.addController(this);\n }\n\n /**\n * Places the overlay relative to the target element.\n *\n * This method sets up the necessary configurations and event listeners to manage the\n * positioning and constraints of the overlay element.\n *\n * @param {HTMLElement} [target=this.target] - The target element for the overlay.\n * @param {OverlayOptionsV1} [options=this.options] - The options for configuring the overlay placement.\n * @returns {Promise<void>} A promise that resolves when the overlay has been placed.\n */\n public async placeOverlay(\n target: HTMLElement = this.target,\n options: OverlayOptionsV1 = this.options\n ): Promise<void> {\n // Set the target and options for the overlay.\n this.target = target;\n this.options = options;\n if (!target || !options) return;\n\n // Set up auto-update for ancestor resize events.\n const cleanupAncestorResize = autoUpdate(\n options.trigger,\n target,\n this.closeForAncestorUpdate,\n {\n ancestorResize: false,\n elementResize: false,\n layoutShift: false,\n }\n );\n\n // Set up auto-update for element resize events.\n const cleanupElementResize = autoUpdate(\n options.trigger,\n target,\n this.updatePlacement,\n {\n ancestorScroll: false,\n }\n );\n\n // Define the cleanup function to remove event listeners and reset placements.\n this.cleanup = () => {\n this.host.elements?.forEach((element) => {\n element.addEventListener(\n 'sp-closed',\n () => {\n const placement = this.originalPlacements.get(element);\n\n if (placement) {\n element.setAttribute('placement', placement);\n }\n\n this.originalPlacements.delete(element);\n },\n { once: true }\n );\n });\n cleanupAncestorResize();\n cleanupElementResize();\n };\n }\n\n /**\n * Flag to allow or disallow placement updates.\n *\n * @type {boolean}\n */\n public allowPlacementUpdate = false;\n\n /**\n * Closes the overlay if an ancestor element is updated.\n *\n * This method checks if placement updates are allowed and if the overlay type is not 'modal'.\n * If these conditions are met and a cleanup function is defined, it dispatches a 'close' event\n * on the target element to close the overlay.\n */\n closeForAncestorUpdate = (): void => {\n if (\n !this.allowPlacementUpdate &&\n this.options.type !== 'modal' &&\n this.cleanup\n ) {\n // Dispatch a 'close' event to close the overlay.\n this.target.dispatchEvent(new Event('close', { bubbles: true }));\n }\n\n // Reset the flag to disallow placement updates.\n this.allowPlacementUpdate = false;\n };\n\n /**\n * Updates the placement of the overlay.\n *\n * This method calls the computePlacement method to recalculate the overlay's position.\n *\n * @private\n */\n private updatePlacement = (): void => {\n this.computePlacement();\n };\n\n /**\n * Computes the placement of the overlay relative to the target element.\n *\n * This method calculates the necessary positioning and constraints for the overlay element\n * using various middleware functions. It updates the overlay's style and attributes based\n * on the computed position.\n *\n * @returns {Promise<void>} A promise that resolves when the placement has been computed.\n */\n async computePlacement(): Promise<void> {\n const { options, target } = this;\n\n // Wait for document fonts to be ready before computing placement.\n await (document.fonts ? document.fonts.ready : Promise.resolve());\n\n // Determine the flip middleware based on the type of trigger element.\n const flipMiddleware = !(options.trigger instanceof HTMLElement)\n ? flip({\n padding: REQUIRED_DISTANCE_TO_EDGE,\n fallbackPlacements: getFallbackPlacements(options.placement),\n })\n : flip();\n\n // Extract main axis and cross axis offsets from options.\n const [mainAxis = 0, crossAxis = 0] = Array.isArray(options?.offset)\n ? options.offset\n : [options.offset, 0];\n\n // Find the tip element within the host elements.\n const tipElement = this.host.elements.find(\n (el) => el.tipElement\n )?.tipElement;\n\n // Define middleware functions for positioning and constraints.\n const middleware = [\n offset({\n mainAxis,\n crossAxis,\n }),\n shift({ padding: REQUIRED_DISTANCE_TO_EDGE }),\n flipMiddleware,\n size({\n padding: REQUIRED_DISTANCE_TO_EDGE,\n apply: ({\n availableWidth,\n availableHeight,\n rects: { floating },\n }) => {\n const maxHeight = Math.max(\n MIN_OVERLAY_HEIGHT,\n Math.floor(availableHeight)\n );\n const actualHeight = floating.height;\n this.initialHeight = !this.isConstrained // && !this.virtualTrigger\n ? actualHeight\n : this.initialHeight || actualHeight;\n this.isConstrained =\n actualHeight < this.initialHeight ||\n maxHeight <= actualHeight;\n const appliedHeight = this.isConstrained\n ? `${maxHeight}px`\n : '';\n Object.assign(target.style, {\n maxWidth: `${Math.floor(availableWidth)}px`,\n maxHeight: appliedHeight,\n });\n },\n }),\n ...(tipElement\n ? [\n arrow({\n element: tipElement,\n padding:\n options.tipPadding || REQUIRED_DISTANCE_TO_EDGE,\n }),\n ]\n : []),\n ];\n\n // Compute the position of the overlay using the defined middleware.\n const { x, y, placement, middlewareData } = await computePosition(\n options.trigger,\n target,\n {\n placement: options.placement,\n middleware,\n strategy: 'fixed',\n }\n );\n\n // Update the overlay's style with the computed position.\n Object.assign(target.style, {\n top: '0px',\n left: '0px',\n translate: `${roundByDPR(x)}px ${roundByDPR(y)}px`,\n });\n\n // Set the 'actual-placement' attribute on the target element.\n target.setAttribute('actual-placement', placement);\n\n // Update the placement attribute for each host element.\n this.host.elements?.forEach((element) => {\n if (!this.originalPlacements.has(element)) {\n this.originalPlacements.set(\n element,\n element.getAttribute('placement') as Placement\n );\n }\n element.setAttribute('placement', placement);\n });\n\n // Update the tip element's style with the computed arrow position.\n if (tipElement && middlewareData.arrow) {\n const { x: arrowX, y: arrowY } = middlewareData.arrow;\n\n Object.assign(tipElement.style, {\n top:\n placement.startsWith('right') ||\n placement.startsWith('left')\n ? '0px'\n : '',\n left:\n placement.startsWith('bottom') ||\n placement.startsWith('top')\n ? '0px'\n : '',\n translate: `${roundByDPR(arrowX)}px ${roundByDPR(arrowY)}px`,\n });\n }\n }\n\n /**\n * Clears the overlay's position styles.\n *\n * This method removes the max-height and max-width styles from the target element,\n * and resets the initial height and constrained state of the overlay.\n */\n public clearOverlayPosition(): void {\n if (!this.target) {\n return;\n }\n // Remove max-height and max-width styles from the target element.\n this.target.style.removeProperty('max-height');\n this.target.style.removeProperty('max-width');\n // Reset the initial height and constrained state.\n this.initialHeight = undefined;\n this.isConstrained = false;\n }\n\n /**\n * Resets the overlay's position.\n *\n * This method clears the overlay's position, forces a reflow, and recomputes the placement.\n */\n public resetOverlayPosition = (): void => {\n if (!this.target || !this.options) return;\n // Clear the overlay's position.\n this.clearOverlayPosition();\n\n // Force a reflow.\n this.host.offsetHeight;\n // Recompute the placement.\n this.computePlacement();\n };\n\n /**\n * Lifecycle method called when the host element is connected to the DOM.\n *\n * This method sets up an event listener to reset the overlay's position when the 'sp-update-overlays' event is dispatched.\n */\n hostConnected(): void {\n document.addEventListener(\n 'sp-update-overlays',\n this.resetOverlayPosition\n );\n }\n\n /**\n * Lifecycle method called when the host element is updated.\n *\n * This method cleans up resources if the overlay is not open.\n */\n hostUpdated(): void {\n if (!(this.host as Overlay).open) {\n // Clean up resources if the overlay is not open.\n this.cleanup?.();\n this.cleanup = undefined;\n }\n }\n\n /**\n * Lifecycle method called when the host element is disconnected from the DOM.\n *\n * This method removes the event listener and cleans up resources.\n */\n hostDisconnected(): void {\n // Clean up resources.\n this.cleanup?.();\n this.cleanup = undefined;\n // Remove the event listener.\n document.removeEventListener(\n 'sp-update-overlays',\n this.resetOverlayPosition\n );\n }\n}\n"],
5
+ "mappings": ";AAgBA;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACG;AAwBP,SAAS,WAAW,KAAsB;AACtC,MAAI,OAAO,QAAQ,YAAa,QAAO;AACvC,QAAM,MAAM,OAAO,oBAAoB;AACvC,SAAO,KAAK,MAAM,MAAM,GAAG,IAAI;AACnC;AAIA,MAAM,4BAA4B;AAGlC,MAAM,qBAAqB;AAQ3B,MAAM,wBAAwB,CAAC,cAAsC;AApErE;AAqEI,QAAM,YAA4C;AAAA,IAC9C,MAAM,CAAC,SAAS,UAAU,KAAK;AAAA,IAC/B,cAAc,CAAC,eAAe,UAAU,KAAK;AAAA,IAC7C,YAAY,CAAC,aAAa,UAAU,KAAK;AAAA,IACzC,OAAO,CAAC,QAA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AA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,mBAAyB;AA5c7B;AA8cQ,eAAK,YAAL;AACA,SAAK,UAAU;AAEf,aAAS;AAAA,MACL;AAAA,MACA,KAAK;AAAA,IACT;AAAA,EACJ;AACJ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";import{arrow as w,autoUpdate as v,computePosition as H,flip as y,offset as R,shift as A,size as M}from"@floating-ui/dom";function c(o){if(typeof o=="undefined")return 0;const t=window.devicePixelRatio||1;return Math.round(o*t)/t}const p=8,C=100,T=o=>{var e;return(e={left:["right","bottom","top"],"left-start":["right-start","bottom","top"],"left-end":["right-end","bottom","top"],right:["left","bottom","top"],"right-start":["left-start","bottom","top"],"right-end":["left-end","bottom","top"],top:["bottom","left","right"],"top-start":["bottom-start","left","right"],"top-end":["bottom-end","left","right"],bottom:["top","left","right"],"bottom-start":["top-start","left","right"],"bottom-end":["top-end","left","right"]}[o])!=null?e:[o]};export const placementUpdatedSymbol=Symbol("placement updated");export class PlacementController{constructor(t){this.originalPlacements=new WeakMap;this.allowPlacementUpdate=!1;this.closeForAncestorUpdate=()=>{!this.allowPlacementUpdate&&this.options.type!=="modal"&&this.cleanup&&this.target.dispatchEvent(new Event("close",{bubbles:!0})),this.allowPlacementUpdate=!1};this.updatePlacement=()=>{this.computePlacement()};this.resetOverlayPosition=()=>{!this.target||!this.options||(this.clearOverlayPosition(),this.host.offsetHeight,this.computePlacement())};this.host=t,this.host.addController(this)}async placeOverlay(t=this.target,e=this.options){if(this.target=t,this.options=e,!t||!e)return;const m=v(e.trigger,t,this.closeForAncestorUpdate,{ancestorResize:!1,elementResize:!1,layoutShift:!1}),h=v(e.trigger,t,this.updatePlacement,{ancestorScroll:!1});this.cleanup=()=>{var n;(n=this.host.elements)==null||n.forEach(a=>{a.addEventListener("sp-closed",()=>{const r=this.originalPlacements.get(a);r&&a.setAttribute("placement",r),this.originalPlacements.delete(a)},{once:!0})}),m(),h()}}async computePlacement(){var g,u;const{options:t,target:e}=this;await(document.fonts?document.fonts.ready:Promise.resolve());const m=t.trigger instanceof HTMLElement?y():y({padding:p,fallbackPlacements:T(t.placement)}),[h=0,n=0]=Array.isArray(t==null?void 0:t.offset)?t.offset:[t.offset,0],a=(g=this.host.elements.find(i=>i.tipElement))==null?void 0:g.tipElement,r=[R({mainAxis:h,crossAxis:n}),A({padding:p}),m,M({padding:p,apply:({availableWidth:i,availableHeight:d,rects:{floating:x}})=>{const b=Math.max(C,Math.floor(d)),l=x.height;this.initialHeight=this.isConstrained&&this.initialHeight||l,this.isConstrained=l<this.initialHeight||b<=l;const O=this.isConstrained?`${b}px`:"";Object.assign(e.style,{maxWidth:`${Math.floor(i)}px`,maxHeight:O})}}),...a?[w({element:a,padding:t.tipPadding||p})]:[]],{x:P,y:E,placement:s,middlewareData:f}=await H(t.trigger,e,{placement:t.placement,middleware:r,strategy:"fixed"});if(Object.assign(e.style,{top:"0px",left:"0px",translate:`${c(P)}px ${c(E)}px`}),e.setAttribute("actual-placement",s),(u=this.host.elements)==null||u.forEach(i=>{this.originalPlacements.has(i)||this.originalPlacements.set(i,i.getAttribute("placement")),i.setAttribute("placement",s)}),a&&f.arrow){const{x:i,y:d}=f.arrow;Object.assign(a.style,{top:s.startsWith("right")||s.startsWith("left")?"0px":"",left:s.startsWith("bottom")||s.startsWith("top")?"0px":"",translate:`${c(i)}px ${c(d)}px`})}}clearOverlayPosition(){this.target&&(this.target.style.removeProperty("max-height"),this.target.style.removeProperty("max-width"),this.initialHeight=void 0,this.isConstrained=!1)}hostConnected(){document.addEventListener("sp-update-overlays",this.resetOverlayPosition)}hostUpdated(){var t;this.host.open||((t=this.cleanup)==null||t.call(this),this.cleanup=void 0)}hostDisconnected(){var t;(t=this.cleanup)==null||t.call(this),this.cleanup=void 0,document.removeEventListener("sp-update-overlays",this.resetOverlayPosition)}}
2
+ //# sourceMappingURL=PlacementController.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["PlacementController.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 {\n ReactiveController,\n ReactiveElement,\n} from '@spectrum-web-components/base';\nimport {\n arrow,\n autoUpdate,\n computePosition,\n flip,\n offset,\n Placement,\n shift,\n size,\n} from '@floating-ui/dom';\nimport type { VirtualTrigger } from './VirtualTrigger.js';\nimport type { OpenableElement } from './overlay-types.js';\nimport type { Overlay } from './Overlay.js';\n\ntype OverlayOptionsV1 = {\n abortPromise?: Promise<boolean>;\n delayed?: boolean;\n offset?: number | [number, number]; // supporting multi-axis\n placement: Placement;\n notImmediatelyClosable?: boolean; // rename or place behind other API options\n receivesFocus?: 'auto';\n root?: HTMLElement;\n tipPadding?: number;\n trigger: HTMLElement | VirtualTrigger;\n type?: 'modal' | 'page' | 'hint' | 'auto' | 'manual';\n};\n\n/**\n * Rounds a number by the device pixel ratio (DPR).\n *\n * @param {number} [num] - The number to round.\n * @returns {number} The rounded number.\n */\nfunction roundByDPR(num?: number): number {\n if (typeof num === 'undefined') return 0;\n const dpr = window.devicePixelRatio || 1;\n return Math.round(num * dpr) / dpr;\n}\n\n// Minimum distance required between the overlay and the edge of the container.\n// See: https://spectrum.adobe.com/page/popover/#Container-padding\nconst REQUIRED_DISTANCE_TO_EDGE = 8;\n// Minimum height for the overlay.\n// See: https://github.com/adobe/spectrum-web-components/issues/910\nconst MIN_OVERLAY_HEIGHT = 100;\n\n/**\n * Gets fallback placements for the overlay based on the initial placement.\n *\n * @param {Placement} placement - The initial placement of the overlay.\n * @returns {Placement[]} An array of fallback placements.\n */\nconst getFallbackPlacements = (placement: Placement): Placement[] => {\n const fallbacks: Record<Placement, Placement[]> = {\n left: ['right', 'bottom', 'top'],\n 'left-start': ['right-start', 'bottom', 'top'],\n 'left-end': ['right-end', 'bottom', 'top'],\n right: ['left', 'bottom', 'top'],\n 'right-start': ['left-start', 'bottom', 'top'],\n 'right-end': ['left-end', 'bottom', 'top'],\n top: ['bottom', 'left', 'right'],\n 'top-start': ['bottom-start', 'left', 'right'],\n 'top-end': ['bottom-end', 'left', 'right'],\n bottom: ['top', 'left', 'right'],\n 'bottom-start': ['top-start', 'left', 'right'],\n 'bottom-end': ['top-end', 'left', 'right'],\n };\n return fallbacks[placement] ?? [placement];\n};\n\n/**\n * Symbol used to indicate that the placement has been updated.\n */\nexport const placementUpdatedSymbol = Symbol('placement updated');\n\n/**\n * Controller for managing the placement of an overlay.\n *\n * This class implements the ReactiveController interface and provides methods\n * for managing the positioning and constraints of an overlay element.\n */\nexport class PlacementController implements ReactiveController {\n /**\n * Function to clean up resources when the controller is no longer needed.\n *\n * @private\n */\n private cleanup?: () => void;\n\n /**\n * Initial height of the overlay.\n *\n * @type {number}\n */\n initialHeight?: number;\n\n /**\n * Indicates whether the overlay is constrained by available space.\n *\n * @type {boolean}\n */\n isConstrained?: boolean;\n\n /**\n * The host element that uses this controller.\n *\n * @private\n * @type {ReactiveElement & { elements: OpenableElement[] }}\n */\n private host!: ReactiveElement & { elements: OpenableElement[] };\n\n /**\n * Options for configuring the overlay placement.\n *\n * @private\n * @type {OverlayOptionsV1}\n */\n private options!: OverlayOptionsV1;\n\n /**\n * A WeakMap to store the original placements of overlay elements.\n *\n * @private\n * @type {WeakMap<HTMLElement, Placement>}\n */\n private originalPlacements = new WeakMap<HTMLElement, Placement>();\n\n /**\n * The target element for the overlay.\n *\n * @private\n * @type {HTMLElement}\n */\n private target!: HTMLElement;\n\n /**\n * Creates an instance of the PlacementController.\n *\n * @param {ReactiveElement & { elements: OpenableElement[] }} host - The host element that uses this controller.\n */\n constructor(host: ReactiveElement & { elements: OpenableElement[] }) {\n this.host = host;\n // Add the controller after the MutationObserver has been created in preparation\n // for the `hostConnected`/`hostDisconnected` callbacks to be run.\n this.host.addController(this);\n }\n\n /**\n * Places the overlay relative to the target element.\n *\n * This method sets up the necessary configurations and event listeners to manage the\n * positioning and constraints of the overlay element.\n *\n * @param {HTMLElement} [target=this.target] - The target element for the overlay.\n * @param {OverlayOptionsV1} [options=this.options] - The options for configuring the overlay placement.\n * @returns {Promise<void>} A promise that resolves when the overlay has been placed.\n */\n public async placeOverlay(\n target: HTMLElement = this.target,\n options: OverlayOptionsV1 = this.options\n ): Promise<void> {\n // Set the target and options for the overlay.\n this.target = target;\n this.options = options;\n if (!target || !options) return;\n\n // Set up auto-update for ancestor resize events.\n const cleanupAncestorResize = autoUpdate(\n options.trigger,\n target,\n this.closeForAncestorUpdate,\n {\n ancestorResize: false,\n elementResize: false,\n layoutShift: false,\n }\n );\n\n // Set up auto-update for element resize events.\n const cleanupElementResize = autoUpdate(\n options.trigger,\n target,\n this.updatePlacement,\n {\n ancestorScroll: false,\n }\n );\n\n // Define the cleanup function to remove event listeners and reset placements.\n this.cleanup = () => {\n this.host.elements?.forEach((element) => {\n element.addEventListener(\n 'sp-closed',\n () => {\n const placement = this.originalPlacements.get(element);\n\n if (placement) {\n element.setAttribute('placement', placement);\n }\n\n this.originalPlacements.delete(element);\n },\n { once: true }\n );\n });\n cleanupAncestorResize();\n cleanupElementResize();\n };\n }\n\n /**\n * Flag to allow or disallow placement updates.\n *\n * @type {boolean}\n */\n public allowPlacementUpdate = false;\n\n /**\n * Closes the overlay if an ancestor element is updated.\n *\n * This method checks if placement updates are allowed and if the overlay type is not 'modal'.\n * If these conditions are met and a cleanup function is defined, it dispatches a 'close' event\n * on the target element to close the overlay.\n */\n closeForAncestorUpdate = (): void => {\n if (\n !this.allowPlacementUpdate &&\n this.options.type !== 'modal' &&\n this.cleanup\n ) {\n // Dispatch a 'close' event to close the overlay.\n this.target.dispatchEvent(new Event('close', { bubbles: true }));\n }\n\n // Reset the flag to disallow placement updates.\n this.allowPlacementUpdate = false;\n };\n\n /**\n * Updates the placement of the overlay.\n *\n * This method calls the computePlacement method to recalculate the overlay's position.\n *\n * @private\n */\n private updatePlacement = (): void => {\n this.computePlacement();\n };\n\n /**\n * Computes the placement of the overlay relative to the target element.\n *\n * This method calculates the necessary positioning and constraints for the overlay element\n * using various middleware functions. It updates the overlay's style and attributes based\n * on the computed position.\n *\n * @returns {Promise<void>} A promise that resolves when the placement has been computed.\n */\n async computePlacement(): Promise<void> {\n const { options, target } = this;\n\n // Wait for document fonts to be ready before computing placement.\n await (document.fonts ? document.fonts.ready : Promise.resolve());\n\n // Determine the flip middleware based on the type of trigger element.\n const flipMiddleware = !(options.trigger instanceof HTMLElement)\n ? flip({\n padding: REQUIRED_DISTANCE_TO_EDGE,\n fallbackPlacements: getFallbackPlacements(options.placement),\n })\n : flip();\n\n // Extract main axis and cross axis offsets from options.\n const [mainAxis = 0, crossAxis = 0] = Array.isArray(options?.offset)\n ? options.offset\n : [options.offset, 0];\n\n // Find the tip element within the host elements.\n const tipElement = this.host.elements.find(\n (el) => el.tipElement\n )?.tipElement;\n\n // Define middleware functions for positioning and constraints.\n const middleware = [\n offset({\n mainAxis,\n crossAxis,\n }),\n shift({ padding: REQUIRED_DISTANCE_TO_EDGE }),\n flipMiddleware,\n size({\n padding: REQUIRED_DISTANCE_TO_EDGE,\n apply: ({\n availableWidth,\n availableHeight,\n rects: { floating },\n }) => {\n const maxHeight = Math.max(\n MIN_OVERLAY_HEIGHT,\n Math.floor(availableHeight)\n );\n const actualHeight = floating.height;\n this.initialHeight = !this.isConstrained // && !this.virtualTrigger\n ? actualHeight\n : this.initialHeight || actualHeight;\n this.isConstrained =\n actualHeight < this.initialHeight ||\n maxHeight <= actualHeight;\n const appliedHeight = this.isConstrained\n ? `${maxHeight}px`\n : '';\n Object.assign(target.style, {\n maxWidth: `${Math.floor(availableWidth)}px`,\n maxHeight: appliedHeight,\n });\n },\n }),\n ...(tipElement\n ? [\n arrow({\n element: tipElement,\n padding:\n options.tipPadding || REQUIRED_DISTANCE_TO_EDGE,\n }),\n ]\n : []),\n ];\n\n // Compute the position of the overlay using the defined middleware.\n const { x, y, placement, middlewareData } = await computePosition(\n options.trigger,\n target,\n {\n placement: options.placement,\n middleware,\n strategy: 'fixed',\n }\n );\n\n // Update the overlay's style with the computed position.\n Object.assign(target.style, {\n top: '0px',\n left: '0px',\n translate: `${roundByDPR(x)}px ${roundByDPR(y)}px`,\n });\n\n // Set the 'actual-placement' attribute on the target element.\n target.setAttribute('actual-placement', placement);\n\n // Update the placement attribute for each host element.\n this.host.elements?.forEach((element) => {\n if (!this.originalPlacements.has(element)) {\n this.originalPlacements.set(\n element,\n element.getAttribute('placement') as Placement\n );\n }\n element.setAttribute('placement', placement);\n });\n\n // Update the tip element's style with the computed arrow position.\n if (tipElement && middlewareData.arrow) {\n const { x: arrowX, y: arrowY } = middlewareData.arrow;\n\n Object.assign(tipElement.style, {\n top:\n placement.startsWith('right') ||\n placement.startsWith('left')\n ? '0px'\n : '',\n left:\n placement.startsWith('bottom') ||\n placement.startsWith('top')\n ? '0px'\n : '',\n translate: `${roundByDPR(arrowX)}px ${roundByDPR(arrowY)}px`,\n });\n }\n }\n\n /**\n * Clears the overlay's position styles.\n *\n * This method removes the max-height and max-width styles from the target element,\n * and resets the initial height and constrained state of the overlay.\n */\n public clearOverlayPosition(): void {\n if (!this.target) {\n return;\n }\n // Remove max-height and max-width styles from the target element.\n this.target.style.removeProperty('max-height');\n this.target.style.removeProperty('max-width');\n // Reset the initial height and constrained state.\n this.initialHeight = undefined;\n this.isConstrained = false;\n }\n\n /**\n * Resets the overlay's position.\n *\n * This method clears the overlay's position, forces a reflow, and recomputes the placement.\n */\n public resetOverlayPosition = (): void => {\n if (!this.target || !this.options) return;\n // Clear the overlay's position.\n this.clearOverlayPosition();\n\n // Force a reflow.\n this.host.offsetHeight;\n // Recompute the placement.\n this.computePlacement();\n };\n\n /**\n * Lifecycle method called when the host element is connected to the DOM.\n *\n * This method sets up an event listener to reset the overlay's position when the 'sp-update-overlays' event is dispatched.\n */\n hostConnected(): void {\n document.addEventListener(\n 'sp-update-overlays',\n this.resetOverlayPosition\n );\n }\n\n /**\n * Lifecycle method called when the host element is updated.\n *\n * This method cleans up resources if the overlay is not open.\n */\n hostUpdated(): void {\n if (!(this.host as Overlay).open) {\n // Clean up resources if the overlay is not open.\n this.cleanup?.();\n this.cleanup = undefined;\n }\n }\n\n /**\n * Lifecycle method called when the host element is disconnected from the DOM.\n *\n * This method removes the event listener and cleans up resources.\n */\n hostDisconnected(): void {\n // Clean up resources.\n this.cleanup?.();\n this.cleanup = undefined;\n // Remove the event listener.\n document.removeEventListener(\n 'sp-update-overlays',\n this.resetOverlayPosition\n );\n }\n}\n"],
5
+ "mappings": "aAgBA,OACI,SAAAA,EACA,cAAAC,EACA,mBAAAC,EACA,QAAAC,EACA,UAAAC,EAEA,SAAAC,EACA,QAAAC,MACG,mBAwBP,SAASC,EAAWC,EAAsB,CACtC,GAAI,OAAOA,GAAQ,YAAa,MAAO,GACvC,MAAMC,EAAM,OAAO,kBAAoB,EACvC,OAAO,KAAK,MAAMD,EAAMC,CAAG,EAAIA,CACnC,CAIA,MAAMC,EAA4B,EAG5BC,EAAqB,IAQrBC,EAAyBC,GAAsC,CApErE,IAAAC,EAmFI,OAAOA,EAd2C,CAC9C,KAAM,CAAC,QAAS,SAAU,KAAK,EAC/B,aAAc,CAAC,cAAe,SAAU,KAAK,EAC7C,WAAY,CAAC,YAAa,SAAU,KAAK,EACzC,MAAO,CAAC,OAAQ,SAAU,KAAK,EAC/B,cAAe,CAAC,aAAc,SAAU,KAAK,EAC7C,YAAa,CAAC,WAAY,SAAU,KAAK,EACzC,IAAK,CAAC,SAAU,OAAQ,OAAO,EAC/B,YAAa,CAAC,eAAgB,OAAQ,OAAO,EAC7C,UAAW,CAAC,aAAc,OAAQ,OAAO,EACz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A,KAAK,UAAL,MAAAA,EAAA,WACA,KAAK,QAAU,OAEvB,CAOA,kBAAyB,CA5c7B,IAAAA,GA8cQA,EAAA,KAAK,UAAL,MAAAA,EAAA,WACA,KAAK,QAAU,OAEf,SAAS,oBACL,qBACA,KAAK,oBACT,CACJ,CACJ",
6
+ "names": ["arrow", "autoUpdate", "computePosition", "flip", "offset", "shift", "size", "roundByDPR", "num", "dpr", "REQUIRED_DISTANCE_TO_EDGE", "MIN_OVERLAY_HEIGHT", "getFallbackPlacements", "placement", "_a", "host", "target", "options", "cleanupAncestorResize", "cleanupElementResize", "element", "_b", "flipMiddleware", "mainAxis", "crossAxis", "tipElement", "el", "middleware", "availableWidth", "availableHeight", "floating", "maxHeight", "actualHeight", "appliedHeight", "x", "y", "middlewareData", "arrowX", "arrowY"]
7
+ }
@@ -0,0 +1,7 @@
1
+ export declare class VirtualTrigger {
2
+ private x;
3
+ private y;
4
+ constructor(x: number, y: number);
5
+ updateBoundingClientRect(x: number, y: number): void;
6
+ getBoundingClientRect(): DOMRect;
7
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ import { AbstractOverlay } from "./AbstractOverlay.dev.js";
3
+ export class VirtualTrigger {
4
+ constructor(x, y) {
5
+ this.x = 0;
6
+ this.y = 0;
7
+ this.x = x;
8
+ this.y = y;
9
+ }
10
+ updateBoundingClientRect(x, y) {
11
+ this.x = x;
12
+ this.y = y;
13
+ AbstractOverlay.update();
14
+ }
15
+ getBoundingClientRect() {
16
+ return {
17
+ width: 0,
18
+ height: 0,
19
+ top: this.y,
20
+ right: this.x,
21
+ y: this.y,
22
+ x: this.x,
23
+ bottom: this.y,
24
+ left: this.x,
25
+ /* c8 ignore next 3 */
26
+ toJSON() {
27
+ return;
28
+ }
29
+ };
30
+ }
31
+ }
32
+ //# sourceMappingURL=VirtualTrigger.dev.js.map