@spectrum-web-components/overlay 0.32.1-overlay.41 → 0.33.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 (152) hide show
  1. package/README.md +156 -120
  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 +523 -1382
  8. package/package.json +22 -48
  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 +31 -23
  15. package/src/OverlayTrigger.dev.js +245 -135
  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 +2 -0
  20. package/src/VirtualTrigger.dev.js.map +2 -2
  21. package/src/VirtualTrigger.js +1 -1
  22. package/src/VirtualTrigger.js.map +3 -3
  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 -2
  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-trigger.css.dev.js +1 -1
  43. package/src/overlay-trigger.css.dev.js.map +1 -1
  44. package/src/overlay-trigger.css.js +1 -1
  45. package/src/overlay-trigger.css.js.map +1 -1
  46. package/src/overlay-types.d.ts +4 -6
  47. package/src/overlay-types.dev.js +0 -1
  48. package/src/overlay-types.dev.js.map +3 -3
  49. package/src/overlay-types.js +1 -1
  50. package/src/overlay-types.js.map +3 -3
  51. package/src/overlay-utils.d.ts +3 -0
  52. package/src/overlay-utils.dev.js +31 -0
  53. package/src/overlay-utils.dev.js.map +7 -0
  54. package/src/overlay-utils.js +2 -0
  55. package/src/overlay-utils.js.map +7 -0
  56. package/src/overlay.d.ts +59 -0
  57. package/src/overlay.dev.js +127 -0
  58. package/src/overlay.dev.js.map +7 -0
  59. package/src/overlay.js +2 -0
  60. package/src/overlay.js.map +7 -0
  61. package/stories/overlay-story-components.js +8 -9
  62. package/stories/overlay-story-components.js.map +2 -2
  63. package/stories/overlay.stories.js +668 -677
  64. package/stories/overlay.stories.js.map +2 -2
  65. package/sync/overlay-trigger.d.ts +0 -4
  66. package/sync/overlay-trigger.dev.js +4 -1
  67. package/sync/overlay-trigger.dev.js.map +2 -2
  68. package/sync/overlay-trigger.js +1 -1
  69. package/sync/overlay-trigger.js.map +3 -3
  70. package/test/benchmark/basic-test.js +1 -1
  71. package/test/benchmark/basic-test.js.map +1 -1
  72. package/test/index.js +376 -407
  73. package/test/index.js.map +3 -3
  74. package/test/overlay-lifecycle.test.js +106 -34
  75. package/test/overlay-lifecycle.test.js.map +2 -2
  76. package/test/overlay-trigger-click.test.js +5 -11
  77. package/test/overlay-trigger-click.test.js.map +2 -2
  78. package/test/overlay-trigger-extended.test.js +6 -1
  79. package/test/overlay-trigger-extended.test.js.map +2 -2
  80. package/test/overlay-trigger-hover-click.test.js +23 -23
  81. package/test/overlay-trigger-hover-click.test.js.map +2 -2
  82. package/test/overlay-trigger-hover.test.js +34 -40
  83. package/test/overlay-trigger-hover.test.js.map +2 -2
  84. package/test/overlay-trigger-longpress.test.js +80 -98
  85. package/test/overlay-trigger-longpress.test.js.map +2 -2
  86. package/test/overlay-trigger-sync.test.js +1 -1
  87. package/test/overlay-trigger-sync.test.js.map +2 -2
  88. package/test/overlay-trigger.test.js +1 -1
  89. package/test/overlay-trigger.test.js.map +2 -2
  90. package/test/overlay-update.test.js +4 -4
  91. package/test/overlay-update.test.js.map +2 -2
  92. package/test/overlay.test.js +242 -253
  93. package/test/overlay.test.js.map +3 -3
  94. package/sp-overlay.d.ts +0 -6
  95. package/sp-overlay.dev.js +0 -5
  96. package/sp-overlay.js +0 -2
  97. package/src/Overlay.d.ts +0 -28
  98. package/src/Overlay.dev.js +0 -88
  99. package/src/Overlay.dev.js.map +0 -7
  100. package/src/Overlay.js +0 -2
  101. package/src/Overlay.js.map +0 -7
  102. package/src/OverlayBase.d.ts +0 -124
  103. package/src/OverlayBase.dev.js +0 -719
  104. package/src/OverlayBase.dev.js.map +0 -7
  105. package/src/OverlayBase.js +0 -31
  106. package/src/OverlayBase.js.map +0 -7
  107. package/src/OverlayDialog.d.ts +0 -8
  108. package/src/OverlayDialog.dev.js +0 -160
  109. package/src/OverlayDialog.dev.js.map +0 -7
  110. package/src/OverlayDialog.js +0 -2
  111. package/src/OverlayDialog.js.map +0 -7
  112. package/src/OverlayNoPopover.d.ts +0 -8
  113. package/src/OverlayNoPopover.dev.js +0 -149
  114. package/src/OverlayNoPopover.dev.js.map +0 -7
  115. package/src/OverlayNoPopover.js +0 -2
  116. package/src/OverlayNoPopover.js.map +0 -7
  117. package/src/OverlayPopover.d.ts +0 -8
  118. package/src/OverlayPopover.dev.js +0 -199
  119. package/src/OverlayPopover.dev.js.map +0 -7
  120. package/src/OverlayPopover.js +0 -2
  121. package/src/OverlayPopover.js.map +0 -7
  122. package/src/OverlayStack.d.ts +0 -29
  123. package/src/OverlayStack.dev.js +0 -122
  124. package/src/OverlayStack.dev.js.map +0 -7
  125. package/src/OverlayStack.js +0 -2
  126. package/src/OverlayStack.js.map +0 -7
  127. package/src/PlacementController.d.ts +0 -36
  128. package/src/PlacementController.dev.js +0 -191
  129. package/src/PlacementController.dev.js.map +0 -7
  130. package/src/PlacementController.js +0 -2
  131. package/src/PlacementController.js.map +0 -7
  132. package/src/fullSizePlugin.d.ts +0 -12
  133. package/src/fullSizePlugin.dev.js +0 -39
  134. package/src/fullSizePlugin.dev.js.map +0 -7
  135. package/src/fullSizePlugin.js +0 -2
  136. package/src/fullSizePlugin.js.map +0 -7
  137. package/src/overlay-base.css.dev.js +0 -9
  138. package/src/overlay-base.css.dev.js.map +0 -7
  139. package/src/overlay-base.css.js +0 -6
  140. package/src/overlay-base.css.js.map +0 -7
  141. package/src/topLayerOverTransforms.d.ts +0 -23
  142. package/src/topLayerOverTransforms.dev.js +0 -170
  143. package/src/topLayerOverTransforms.dev.js.map +0 -7
  144. package/src/topLayerOverTransforms.js +0 -2
  145. package/src/topLayerOverTransforms.js.map +0 -7
  146. package/stories/overlay-element.stories.js +0 -247
  147. package/stories/overlay-element.stories.js.map +0 -7
  148. package/test/overlay-element.test-vrt.js +0 -5
  149. package/test/overlay-element.test-vrt.js.map +0 -7
  150. package/test/overlay-element.test.js +0 -664
  151. package/test/overlay-element.test.js.map +0 -7
  152. /package/src/{overlay-base.css.d.ts → active-overlay.css.d.ts} +0 -0
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ## Description
2
2
 
3
- An `<sp-overlay>` element is used to decorate content that you would like to present to your visitors as "overlaid" on the rest of the application. This includes dialogs (modal and not), pickers, tooltips, context menus, et al.
3
+ Overlays in Spectrum Web Components are created via the `Overlay` class system, which prepares an "overlay stack" that can manage the deployment of one or more overlays onto a page. Whether it's needed for transient content like a tooltip, for extended interactions like selecting a value from a picker, or for blocking content like a modal, the imperative APIs outlined below or the declarative APIs delivered by `<overlay-trigger>` should cover your overlay delivery needs.
4
4
 
5
5
  ### Usage
6
6
 
@@ -11,154 +11,190 @@ An `<sp-overlay>` element is used to decorate content that you would like to pre
11
11
  yarn add @spectrum-web-components/overlay
12
12
  ```
13
13
 
14
- Import the side effectful registration of `<sp-overlay>` as follows:
14
+ Import the `Overlay` class to leverage its capabilities within your application or custom element:
15
15
 
16
- ```
17
- import '@spectrum-web-components/overlay/sp-overlay.js';
16
+ ```js
17
+ import { Overlay } from '@spectrum-web-components/overlay';
18
18
  ```
19
19
 
20
- When looking to leverage the `Overlay` base class as a type and/or for extension purposes, do so via:
20
+ Primarily, this class gives you access to the `open` method that will allow you to open an overlay:
21
21
 
22
+ ```js
23
+ Overlay.open(
24
+ (owner: HTMLElement), // the element to open the overlay in reference to, "trigger"
25
+ (interaction: TriggerInteractions), // the type of interaction type that opened the overlay
26
+ (overlayElement: HTMLElement), // the element that will be projected into the overlay, "content"
27
+ (options: OverlayOptions) // options to customize the overlay
28
+ );
22
29
  ```
23
- import {
24
- Overlay
25
- } from '@spectrum-web-components/overlay';
30
+
31
+ `Overlay.open()` is an asynchronous method that returns a function for closing the overlay, so it is common to leverage this functionality like the following:
32
+
33
+ ```js
34
+ (async () => {
35
+ const trigger = document.querySelector('#trigger');
36
+ const interaction = 'click';
37
+ const content = document.querySelector('#content');
38
+ const options = {
39
+ offset: 0,
40
+ placement: 'bottom',
41
+ };
42
+ const closeOverlay = await Overlay.open(
43
+ trigger,
44
+ interaction,
45
+ content,
46
+ options
47
+ );
48
+ })();
26
49
  ```
27
50
 
28
- ## Example
51
+ ## Types
29
52
 
30
- ```html
31
- <sp-button id="trigger">Overlay Trigger</sp-button>
32
- <sp-overlay trigger="trigger@click">
33
- <sp-popover>
34
- <sp-dialog>
35
- <h2 slot="heading">Clicking opens this popover...</h2>
36
- <p>But, it really could be anything. Really.</p>
37
- </sp-dialog>
38
- </sp-popover>
39
- </sp-overlay>
40
- ```
53
+ ### TriggerInteractions
41
54
 
42
- ## API
55
+ This outlines the user experience that is to be delivered through the process of opening and closing an overlay.
43
56
 
44
- ```html
45
- open delayed offset="Number | [Number, Number]" placement=${placement}
46
- received-focus=${‘true’ | ‘false’ | ‘auto’ (default)} trigger=${idOfTrigger AND
47
- ${string}@${string}} .triggerElement(s)=${trigger Element by reference} // match
48
- naming to aria element reference spec .triggerInteraction=${ ‘click’ |
49
- ‘longpress’ | ‘hover’ } type=${type}
57
+ ```
58
+ type TriggerInteractions =
59
+ | 'click'
60
+ | 'custom',
61
+ | 'hover'
62
+ | 'inline'
63
+ | 'modal'
64
+ | 'replace';
50
65
  ```
51
66
 
52
- ## Fallback support
67
+ `click` will open an overlay that will close immediately on the next click that is not on an element within the overlay.
53
68
 
54
- While the [`<dialog>` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog) is widely supported by browsers, the [`popover` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/popover) is still quite new. When leveraged in browsers that do not yet support the `popover` attribute, there may be additional intervention required to ensure your content is delivered to your visitors as expected.
69
+ `custom` is less opinionated and allows for some customization of the process from the outside.
55
70
 
56
- ### Complex layered
71
+ `hover` will close the overlay as soon as the pointer leaves the trigger to which the overlay is connected.
57
72
 
58
- When an overlay is placed within a page with complex layering, the content therein can fall behind other content in the `z-index` stack. The following example is somewhat contrived but, imagine a toolbar next to a properties panel. If the toolbar has a lower `z-index` and the properties panel, any overlaid content (tooltips, etc.) within that toolbar will display underneath any content in the properties panel with which it may share pixels.
73
+ `inline` places the overlay after the trigger but before the next element in the logical tab order. This means the `shift + tab` keyboard stroke will return to the trigger.
74
+
75
+ `modal` manages the overlay like a modal and will trap the tab order within its contents only.
76
+
77
+ `replace` will position the overlay directly in the position of the trigger in the logical tab order. This means the `shift + tab` keyboard stroke will return the focusable element immediately prior to the trigger.
78
+
79
+ ### OverlayOptions
59
80
 
60
- ```html
61
- <div class="complex-layered-demo">
62
- <div class="complex-layered-holder">
63
- <sp-action-button id="complex-layered">Trigger</sp-action-button>
64
- <sp-overlay trigger="complex-layered@hover" placement="bottom-start">
65
- <sp-tooltip>
66
- I can be partially blocked when [popover] is not available
67
- </sp-tooltip>
68
- </sp-overlay>
69
- </div>
70
- <div class="complex-layered-blocker"></div>
71
- </div>
72
- <style>
73
- .complex-layered-demo {
74
- position: relative;
75
- }
76
- .complex-layered-holder {
77
- z-index: 1;
78
- position: relative;
79
- }
80
- .complex-layered-blocker {
81
- position: relative;
82
- z-index: 10;
83
- background: white;
84
- width: 100%;
85
- height: 40px;
86
- }
87
- </style>
81
+ ```
82
+ type OverlayOptions = {
83
+ delayed?: boolean;
84
+ placement?: Placement;
85
+ offset?: number;
86
+ receivesFocus?: 'auto';
87
+ notImmediatelyClosable?: boolean;
88
+ }
88
89
  ```
89
90
 
90
- Properly managed `z-index` values will support working around this issue while browsers work to adopt the `popover` attribute. In this demo, you can easily achieve the same output but sharing one `z-index` between the various pieces of content, removing `z-index` values altogether, or raising the `.complex-layered-holder` element to a higher `z-index` than the `.complex-layered-blocker` element.
91
+ `delayed` allows for the overlay to open the overlay with warmup/cooldown behaviors as described at https://spectrum.adobe.com/page/tooltip/#Immediate-or-delayed-appearance
91
92
 
92
- ### Contained
93
+ `placement` outlines where the overlay system should attempt to position the overlay in relation to the trigger. When the layout of the page and/or current scroll positioning prevents the successful placement of the content in this way, the `placement` will be automatically applied as the value best suited for those conditions. Placements available include: `"auto" | "auto-start" | "auto-end" | "top" | "bottom" | "right" | "left" | "top-start" | "top-end" | "bottom-start" | "bottom-end" | "right-start" | "right-end" | "left-start" | "left-end" | "none"`.
93
94
 
94
- [CSS Containment](https://developer.mozilla.org/en-US/docs/Web/CSS/contain) allows a developer direct control over how the internals of one element affects the paint and layout of the internals of other elements on the same page. While leveraging some of its values can offer performance gains, they can interrupt the delivery of your overlaid content.
95
+ `offset` defines the distance of the overlay content from the trigger, measured in pixels.
95
96
 
96
- ```html
97
- <div class="contained-demo">
98
- <sp-action-button id="contained">Trigger</sp-action-button>
99
- <sp-overlay trigger="contained@hover" placement="bottom-start">
100
- <sp-tooltip>
101
- I can be blocked when [popover] is not available
102
- </sp-tooltip>
103
- </sp-overlay>
104
- </div>
105
- <style>
106
- .contained-demo {
107
- contain: content;
108
- }
109
- </style>
110
- ```
97
+ `receivesFocus` tells the overlay stack to throw focus into the overlay after it has opened.
111
98
 
112
- You could just _remove_ the `contain` rule. But, if you are not OK with simply removing the `contain` value, you still have options. In the case that you would like to continue to leverage `contain` is to place "contained" content separately from your overlaid content, like so:
99
+ `notImmediatelyClosable` prevents immediate clicks from closing the overlay. If you find that a trigger event is immediately overridden with a subsequent click (for instance, a `focus` trigger that should be closed on `click`), set `notImmediatelyClosable: true` to disregard clicks that coincide with the opening trigger.
100
+
101
+ ### Events
102
+
103
+ The work to both open and close an overlay is asynchronous. This asynchrony is surfaced into the application via DOM events dispatched from the `trigger` element of your overlay. An `sp-opened` event will be dispatched once the overlay has finished opening, and an `sp-closed` event will be dispatched once the overlay has finished closing. In both cases, the dispatched event will include a `detail` property with an `interaction: TriggerInteractions` key to support associating the event/overlay with its originating `interaction`.
104
+
105
+ ## Example
113
106
 
114
107
  ```html
115
- <div class="contained-demo">
116
- <sp-action-button id="contained-working">Trigger</sp-action-button>
117
- </div>
118
- <sp-overlay trigger="contained-working@hover" placement="bottom-start">
119
- <sp-tooltip>I can be blocked when [popover] is not available</sp-tooltip>
120
- </sp-overlay>
121
- <style>
122
- .contained-demo {
123
- contain: content;
124
- }
125
- </style>
108
+ <sp-button
109
+ onclick="
110
+ const trigger = this;
111
+ const interaction = 'click';
112
+ const content = this.nextElementSibling;
113
+ if (!content) return;
114
+ const options = {
115
+ offset: 0,
116
+ placement: 'right',
117
+ };
118
+ content.open = true;
119
+ const closeOverlayPromise = Overlay.open(
120
+ trigger,
121
+ interaction,
122
+ content,
123
+ options
124
+ );
125
+ setTimeout(function () {
126
+ closeOverlayPromise.then(function(close) {
127
+ close();
128
+ content.open = false;
129
+ });
130
+ }, 5000);
131
+ "
132
+ >
133
+ Click me for a 5 second overlay!
134
+ </sp-button>
135
+ <sp-popover>
136
+ <sp-dialog size="medium">
137
+ <h2 slot="heading">Demo</h2>
138
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
139
+ tempor incididunt ut labore et dolore magna aliqua. Auctor augue mauris
140
+ augue neque gravida. Libero volutpat sed ornare arcu. Quisque egestas
141
+ diam in arcu cursus euismod quis viverra. Posuere ac ut consequat semper
142
+ viverra nam libero justo laoreet. Enim ut tellus elementum sagittis
143
+ vitae et leo duis ut. Neque laoreet suspendisse interdum consectetur
144
+ libero id faucibus nisl. Diam volutpat commodo sed egestas egestas.
145
+ Dolor magna eget est lorem ipsum dolor. Vitae suscipit tellus mauris a
146
+ diam maecenas sed. Turpis in eu mi bibendum neque egestas congue.
147
+ Rhoncus est pellentesque elit ullamcorper dignissim cras lobortis.
148
+ </sp-dialog>
149
+ </sp-popover>
126
150
  ```
127
151
 
128
- `<sp-overlay>` accepts an ID reference via the `trigger` attribute to relate it to interactions and positioning in the DOM. To fulfill this reference the two elements need to be in the same DOM tree. However, `<sp-overlay>` alternatively accepts a `triggerElement` _property_ that opens even more flexibility in addressing this situation.
152
+ ## Styling
129
153
 
130
- ### Clip pathed
154
+ When an overlay is opened from within a styled DOM scope as created by an `<sp-theme>` element, this scope will be resolved and recreated with in the `<active-overlay>` element that is created to host the overlaid content directly in the `<body>`. By default, the generated `<sp-theme>` element will be supplied with settings of the scope from which the overlay is triggered, including any "app" centric CSS Custom Properties that might be applied via `Theme.registerThemeFragment('app', 'app', themeFragment)` therein. In the case that you have set CSS Custom Properties for the scope created by an `<sp-theme>` element via other methods, you can specify that those values should also be applied to overlay content using the `theme` part on the `<active-overlay>` element via the `active-overlay::part(theme) { /* styles */ }` selector.
131
155
 
132
- While not offering the same performance opportunities as `contain`, `clip-path` can also restrict how content in an element is surfaced at paint time. When overlaid content should display outside of the `clip-path`, without the `popover` attribute that content could be _clipped_.
156
+ ## Advanced Usage
133
157
 
134
- ```html
135
- <div class="clip-pathed-demo">
136
- <sp-action-button id="clip-pathed">Trigger</sp-action-button>
137
- <sp-overlay trigger="clip-pathed@hover" placement="bottom-start">
138
- <sp-tooltip>
139
- I can be blocked when [popover] is not available
140
- </sp-tooltip>
141
- </sp-overlay>
142
- </div>
143
- <style>
144
- .clip-pathed-demo {
145
- clip-path: inset(0 0);
146
- }
147
- </style>
148
- ```
158
+ When working with the DOM-based APIs of custom elements, it is sometimes preferred to project content into an overlay from a different shadow root (eg projecting a single-slotted element into the overlay). To ensure that the content can be marshalled through any number of `<slot>` elements which are addressed into subsequent `<slot>` elements, be sure to use the `flatten: true` option when querying `slot.asignedNodes()`:
149
159
 
150
- Here, again, working with your content needs (whether or not you want to leverage `clip-path`) or DOM structure (not colocating clipped and non-clipped content) will allow you to avoid this issue:
160
+ ```js
161
+ const trigger = shadowRoot.querySelector('#trigger');
162
+ const slot = shadowRoot.querySelector('slot');
163
+ const interaction = 'click';
164
+ const content = slot
165
+ .assignedNodes({ flatten: true })
166
+ .find((node) => node instanceof HTMLElement);
167
+ const options = {
168
+ offset: 0,
169
+ placement: 'bottom',
170
+ };
171
+ const closeOverlay = await Overlay.open(trigger, interaction, content, options);
172
+ ```
151
173
 
152
- ```html
153
- <div class="clip-pathed-demo">
154
- <sp-action-button id="clip-pathed-working">Trigger</sp-action-button>
155
- </div>
156
- <sp-overlay trigger="clip-pathed-working@hover" placement="bottom-start">
157
- <sp-tooltip>I can be blocked when [popover] is not available</sp-tooltip>
158
- </sp-overlay>
159
- <style>
160
- .clip-pathed-demo {
161
- clip-path: inset(0 0);
162
- }
163
- </style>
174
+ Other times, you may want to compose content from multiple shadow roots into a single overlay. This is a pattern seen in the `<sp-dropdown>` element: its `<sp-menu>` light DOM child is wrapped by its `<sp-popover>` shadow DOM child before being projected into an overlay. What follows is a more trivial example, where content in the light DOM of an element is injected into an element in the shadow DOM of the same element and then projected into an overlay. Notice the added work here of setting a comment node into the light DOM as a placeholder for the "stolen" content, and then swapping that content back into the light DOM when the overlay is closed.
175
+
176
+ ```js
177
+ const trigger = this.shadowRoot.querySelector('#trigger');
178
+ const outterContent = this.shadowRoot.querySelector('#outter-content');
179
+ const innerContent = this.querySelector('#inner-content');
180
+ const innerContentParent =
181
+ innerContent.parentElement || innerContent.getRootNode();
182
+ const placeholder = document.createComment('placeholder for inner content');
183
+ innerContentParent.replaceChild(placeholder, innerContent);
184
+ outterContent.append(innerContent);
185
+ const interaction = 'click';
186
+ const options = {
187
+ offset: 0,
188
+ placement: 'bottom',
189
+ };
190
+ const closeOverlayPromise = Overlay.open(
191
+ trigger,
192
+ interaction,
193
+ outterContent,
194
+ options
195
+ );
196
+ const closeOverlay = function () {
197
+ closeOverlayPromise.then((close) => close());
198
+ innerContentParent.replaceChild(placeholder, innerContent);
199
+ };
164
200
  ```
@@ -0,0 +1,6 @@
1
+ import { ActiveOverlay } from './src/ActiveOverlay.js';
2
+ declare global {
3
+ interface HTMLElementTagNameMap {
4
+ 'active-overlay': ActiveOverlay;
5
+ }
6
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ import { defineElement } from "@spectrum-web-components/base/src/define-element.js";
3
+ import { ActiveOverlay } from "./src/ActiveOverlay.dev.js";
4
+ defineElement("active-overlay", ActiveOverlay);
5
+ //# sourceMappingURL=active-overlay.dev.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["sp-overlay.ts"],
4
- "sourcesContent": ["/*\nCopyright 2023 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { defineElement } from '@spectrum-web-components/base/src/define-element.js';\nimport { Overlay } from './src/Overlay.dev.js'\n\ndefineElement('sp-overlay', Overlay);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-overlay': Overlay;\n }\n}\n"],
5
- "mappings": ";AAWA,SAAS,qBAAqB;AAC9B,SAAS,eAAe;AAExB,cAAc,cAAc,OAAO;",
3
+ "sources": ["active-overlay.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { defineElement } from '@spectrum-web-components/base/src/define-element.js';\nimport { ActiveOverlay } from './src/ActiveOverlay.dev.js'\n\ndefineElement('active-overlay', ActiveOverlay);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'active-overlay': ActiveOverlay;\n }\n}\n"],
5
+ "mappings": ";AAWA,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAE9B,cAAc,kBAAkB,aAAa;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,2 @@
1
+ "use strict";import{defineElement as e}from"@spectrum-web-components/base/src/define-element.js";import{ActiveOverlay as a}from"./src/ActiveOverlay.js";e("active-overlay",a);
2
+ //# sourceMappingURL=active-overlay.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["sp-overlay.ts"],
4
- "sourcesContent": ["/*\nCopyright 2023 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { defineElement } from '@spectrum-web-components/base/src/define-element.js';\nimport { Overlay } from './src/Overlay.js';\n\ndefineElement('sp-overlay', Overlay);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-overlay': Overlay;\n }\n}\n"],
5
- "mappings": "aAWA,OAAS,iBAAAA,MAAqB,sDAC9B,OAAS,WAAAC,MAAe,mBAExBD,EAAc,aAAcC,CAAO",
6
- "names": ["defineElement", "Overlay"]
3
+ "sources": ["active-overlay.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { defineElement } from '@spectrum-web-components/base/src/define-element.js';\nimport { ActiveOverlay } from './src/ActiveOverlay.js';\n\ndefineElement('active-overlay', ActiveOverlay);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'active-overlay': ActiveOverlay;\n }\n}\n"],
5
+ "mappings": "aAWA,OAAS,iBAAAA,MAAqB,sDAC9B,OAAS,iBAAAC,MAAqB,yBAE9BD,EAAc,iBAAkBC,CAAa",
6
+ "names": ["defineElement", "ActiveOverlay"]
7
7
  }