@spectrum-web-components/overlay 0.14.2-express.9 → 0.15.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 (39) hide show
  1. package/custom-elements.json +34 -9
  2. package/package.json +6 -6
  3. package/src/ActiveOverlay.d.ts +2 -2
  4. package/src/ActiveOverlay.js +15 -7
  5. package/src/ActiveOverlay.js.map +1 -1
  6. package/src/active-overlay.css.js +1 -1
  7. package/src/active-overlay.css.js.map +1 -1
  8. package/src/loader.d.ts +1 -1
  9. package/src/loader.js.map +1 -1
  10. package/src/overlay-stack.d.ts +1 -1
  11. package/src/overlay-stack.js +13 -8
  12. package/src/overlay-stack.js.map +1 -1
  13. package/src/overlay-types.d.ts +6 -1
  14. package/src/overlay-types.js.map +1 -1
  15. package/src/overlay.d.ts +1 -1
  16. package/src/overlay.js +0 -1
  17. package/src/overlay.js.map +1 -1
  18. package/test/overlay-lifecycle.test.js +0 -162
  19. package/test/overlay-lifecycle.test.js.map +0 -1
  20. package/test/overlay-timer.test.js +0 -129
  21. package/test/overlay-timer.test.js.map +0 -1
  22. package/test/overlay-trigger-click.test.js +0 -76
  23. package/test/overlay-trigger-click.test.js.map +0 -1
  24. package/test/overlay-trigger-extended.test.js +0 -232
  25. package/test/overlay-trigger-extended.test.js.map +0 -1
  26. package/test/overlay-trigger-hover-click.test.js +0 -91
  27. package/test/overlay-trigger-hover-click.test.js.map +0 -1
  28. package/test/overlay-trigger-hover.test.js +0 -112
  29. package/test/overlay-trigger-hover.test.js.map +0 -1
  30. package/test/overlay-trigger-longpress.test.js +0 -334
  31. package/test/overlay-trigger-longpress.test.js.map +0 -1
  32. package/test/overlay-trigger-sync.test.js +0 -555
  33. package/test/overlay-trigger-sync.test.js.map +0 -1
  34. package/test/overlay-trigger.test.js +0 -555
  35. package/test/overlay-trigger.test.js.map +0 -1
  36. package/test/overlay.test-vrt.js +0 -15
  37. package/test/overlay.test-vrt.js.map +0 -1
  38. package/test/overlay.test.js +0 -549
  39. package/test/overlay.test.js.map +0 -1
@@ -32,6 +32,12 @@
32
32
  }
33
33
  ]
34
34
  },
35
+ {
36
+ "kind": "javascript-module",
37
+ "path": "sync/overlay-trigger.ts",
38
+ "declarations": [],
39
+ "exports": []
40
+ },
35
41
  {
36
42
  "kind": "javascript-module",
37
43
  "path": "src/ActiveOverlay.ts",
@@ -126,7 +132,7 @@
126
132
  "kind": "field",
127
133
  "name": "theme",
128
134
  "type": {
129
- "text": "{\n color?: Color;\n scale?: Scale;\n lang?: string;\n theme?: Flavor;\n }"
135
+ "text": "{\n color?: Color;\n scale?: Scale;\n lang?: string;\n }"
130
136
  },
131
137
  "privacy": "public",
132
138
  "default": "{}"
@@ -191,6 +197,15 @@
191
197
  "privacy": "public",
192
198
  "default": "6"
193
199
  },
200
+ {
201
+ "kind": "field",
202
+ "name": "skidding",
203
+ "type": {
204
+ "text": "number"
205
+ },
206
+ "privacy": "public",
207
+ "default": "0"
208
+ },
194
209
  {
195
210
  "kind": "field",
196
211
  "name": "interaction",
@@ -1158,7 +1173,7 @@
1158
1173
  {
1159
1174
  "kind": "variable",
1160
1175
  "name": "styles",
1161
- "default": "css`\n@keyframes sp-overlay-fade-in{0%{opacity:0;transform:var(--sp-overlay-from)}to{opacity:1;transform:translate(0)}}@keyframes sp-overlay-fade-out{0%{opacity:1;transform:translate(0)}to{opacity:0;transform:var(--sp-overlay-from)}}:host{display:inline-block;left:0;pointer-events:none;position:absolute;top:0;z-index:1000}:host(:focus){outline:none}:host([placement=none]){height:100vh;height:-webkit-fill-available;height:fill-available;max-height:var(--swc-visual-viewport-height);position:fixed}#contents,sp-theme{height:100%}#contents{animation-duration:var(\n--swc-test-duration,var(--spectrum-global-animation-duration-200,.16s)\n);animation-timing-function:var(\n--spectrum-global-animation-ease-out,ease-out\n);display:inline-block;opacity:1;pointer-events:none;visibility:visible}:host([actual-placement*=top]) #contents{--sp-overlay-from:translateY(var(--spectrum-global-dimension-size-75));align-items:flex-end;display:inline-flex}:host([actual-placement*=right]) #contents{--sp-overlay-from:translateX(calc(var(--spectrum-global-dimension-size-75)*-1))}:host([actual-placement*=bottom]) #contents{--sp-overlay-from:translateY(calc(var(--spectrum-global-dimension-size-75)*-1))}:host([actual-placement*=left]) #contents{--sp-overlay-from:translateX(var(--spectrum-global-dimension-size-75))}:host([animating]) ::slotted(*){pointer-events:none}:host(:not([animating])) ::slotted(*){pointer-events:auto}#contents ::slotted(*){position:relative}\n`"
1176
+ "default": "css`\n@keyframes sp-overlay-fade-in{0%{opacity:0;transform:var(--sp-overlay-from)}to{opacity:1;transform:translate(0)}}@keyframes sp-overlay-fade-out{0%{opacity:1;transform:translate(0)}to{opacity:0;transform:var(--sp-overlay-from)}}:host{display:inline-block;left:-9999em;pointer-events:none;position:absolute;top:-9999em;z-index:1000}:host(:focus){outline:none}:host([placement=none]){height:100vh;height:-webkit-fill-available;height:fill-available;left:0;max-height:var(--swc-visual-viewport-height);position:fixed;top:0}#contents,sp-theme{height:100%}#contents{animation-duration:var(\n--swc-test-duration,var(--spectrum-global-animation-duration-200,.16s)\n);animation-timing-function:var(\n--spectrum-global-animation-ease-out,ease-out\n);display:inline-block;opacity:1;pointer-events:none;visibility:visible}:host([actual-placement*=top]) #contents{--sp-overlay-from:translateY(var(--spectrum-global-dimension-size-75));align-items:flex-end;display:inline-flex}:host([actual-placement*=right]) #contents{--sp-overlay-from:translateX(calc(var(--spectrum-global-dimension-size-75)*-1))}:host([actual-placement*=bottom]) #contents{--sp-overlay-from:translateY(calc(var(--spectrum-global-dimension-size-75)*-1))}:host([actual-placement*=left]) #contents{--sp-overlay-from:translateX(var(--spectrum-global-dimension-size-75))}:host([animating]) ::slotted(*){pointer-events:none}:host(:not([animating])) ::slotted(*){pointer-events:auto}#contents ::slotted(*){position:relative}\n`"
1162
1177
  }
1163
1178
  ],
1164
1179
  "exports": [
@@ -1643,6 +1658,13 @@
1643
1658
  "type": {
1644
1659
  "text": "boolean"
1645
1660
  }
1661
+ },
1662
+ {
1663
+ "name": "clickAway",
1664
+ "optional": true,
1665
+ "type": {
1666
+ "text": "boolean"
1667
+ }
1646
1668
  }
1647
1669
  ]
1648
1670
  },
@@ -1654,7 +1676,16 @@
1654
1676
  "type": {
1655
1677
  "text": "Promise<void>"
1656
1678
  }
1657
- }
1679
+ },
1680
+ "parameters": [
1681
+ {
1682
+ "name": "clickAway",
1683
+ "optional": true,
1684
+ "type": {
1685
+ "text": "boolean"
1686
+ }
1687
+ }
1688
+ ]
1658
1689
  },
1659
1690
  {
1660
1691
  "kind": "field",
@@ -2034,12 +2065,6 @@
2034
2065
  }
2035
2066
  }
2036
2067
  ]
2037
- },
2038
- {
2039
- "kind": "javascript-module",
2040
- "path": "sync/overlay-trigger.ts",
2041
- "declarations": [],
2042
- "exports": []
2043
2068
  }
2044
2069
  ]
2045
2070
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/overlay",
3
- "version": "0.14.2-express.9+abfee7409",
3
+ "version": "0.15.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -49,10 +49,10 @@
49
49
  ],
50
50
  "dependencies": {
51
51
  "@floating-ui/dom": "^0.2.0",
52
- "@spectrum-web-components/action-button": "^0.7.5-express.9+abfee7409",
53
- "@spectrum-web-components/base": "^0.5.2",
54
- "@spectrum-web-components/shared": "^0.13.4",
55
- "@spectrum-web-components/theme": "^0.9.5-express.9+abfee7409",
52
+ "@spectrum-web-components/action-button": "^0.8.0",
53
+ "@spectrum-web-components/base": "^0.5.3",
54
+ "@spectrum-web-components/shared": "^0.13.5",
55
+ "@spectrum-web-components/theme": "^0.10.0",
56
56
  "tslib": "^2.0.0"
57
57
  },
58
58
  "types": "./src/index.d.ts",
@@ -63,5 +63,5 @@
63
63
  "./sync/overlay-trigger.js",
64
64
  "./stories/overlay-story-components.js"
65
65
  ],
66
- "gitHead": "abfee740957976448a3e4cf90df17d6165f857d6"
66
+ "gitHead": "90109a167310260905a734919249c225a404bc74"
67
67
  }
@@ -1,5 +1,5 @@
1
1
  import { CSSResultArray, PropertyValues, SpectrumElement, TemplateResult } from '@spectrum-web-components/base';
2
- import { Color, Flavor, Scale } from '@spectrum-web-components/theme';
2
+ import type { Color, Scale } from '@spectrum-web-components/theme/src/Theme.js';
3
3
  import { OverlayOpenDetail, Placement, TriggerInteractions } from './overlay-types.js';
4
4
  import type { VirtualTrigger } from './VirtualTrigger.js';
5
5
  export interface PositionResult {
@@ -32,7 +32,6 @@ export declare class ActiveOverlay extends SpectrumElement {
32
32
  color?: Color;
33
33
  scale?: Scale;
34
34
  lang?: string;
35
- theme?: Flavor;
36
35
  };
37
36
  receivesFocus?: 'auto';
38
37
  tabbingAway: boolean;
@@ -41,6 +40,7 @@ export declare class ActiveOverlay extends SpectrumElement {
41
40
  focus(): void;
42
41
  private get hasTheme();
43
42
  offset: number;
43
+ skidding: number;
44
44
  interaction: TriggerInteractions;
45
45
  private positionAnimationFrame;
46
46
  private timeout?;
@@ -13,7 +13,7 @@ import { __decorate } from "tslib";
13
13
  import { html, SpectrumElement, } from '@spectrum-web-components/base';
14
14
  import { ifDefined } from '@spectrum-web-components/base/src/directives.js';
15
15
  import { property } from '@spectrum-web-components/base/src/decorators.js';
16
- import { reparentChildren } from '@spectrum-web-components/shared';
16
+ import { reparentChildren } from '@spectrum-web-components/shared/src/reparent-children.js';
17
17
  import { firstFocusableIn } from '@spectrum-web-components/shared/src/first-focusable-in.js';
18
18
  import styles from './active-overlay.css.js';
19
19
  import { arrow, computePosition, flip, offset, shift, size, } from '@floating-ui/dom';
@@ -78,6 +78,7 @@ export class ActiveOverlay extends SpectrumElement {
78
78
  this.theme = {};
79
79
  this.tabbingAway = false;
80
80
  this.offset = 6;
81
+ this.skidding = 0;
81
82
  this.interaction = 'hover';
82
83
  this.positionAnimationFrame = 0;
83
84
  this.willNotifyClosed = false;
@@ -96,7 +97,10 @@ export class ActiveOverlay extends SpectrumElement {
96
97
  // See: https://github.com/adobe/spectrum-web-components/issues/910
97
98
  const MIN_OVERLAY_HEIGHT = 100;
98
99
  const middleware = [
99
- offset(this.offset),
100
+ offset({
101
+ mainAxis: this.offset,
102
+ crossAxis: this.skidding,
103
+ }),
100
104
  flip({
101
105
  fallbackStrategy: 'initialPlacement',
102
106
  }),
@@ -131,8 +135,9 @@ export class ActiveOverlay extends SpectrumElement {
131
135
  middleware,
132
136
  });
133
137
  Object.assign(this.style, {
134
- left: `${roundByDPR(x)}px`,
135
- top: `${roundByDPR(y)}px`,
138
+ top: '0px',
139
+ left: '0px',
140
+ transform: `translate(${roundByDPR(x)}px, ${roundByDPR(y)}px)`,
136
141
  });
137
142
  if (placement !== this.getAttribute('actual-placement')) {
138
143
  this.setAttribute('actual-placement', placement);
@@ -205,9 +210,12 @@ export class ActiveOverlay extends SpectrumElement {
205
210
  this.tabIndex = -1;
206
211
  const parentOverlay = parentOverlayOf(this.trigger);
207
212
  const parentIsModal = parentOverlay && parentOverlay.slot === 'open';
213
+ if (parentIsModal) {
214
+ this._modalRoot = parentOverlay._modalRoot || parentOverlay;
215
+ }
208
216
  // If an overlay it triggered from within a "modal" overlay, it needs to continue
209
217
  // to act like one to get treated correctly in regards to tab trapping.
210
- if (this.interaction === 'modal' || parentIsModal || this._modalRoot) {
218
+ if (this.interaction === 'modal' || this._modalRoot) {
211
219
  this.slot = 'open';
212
220
  if (this.interaction === 'modal') {
213
221
  this.setAttribute('aria-modal', 'true');
@@ -283,6 +291,7 @@ export class ActiveOverlay extends SpectrumElement {
283
291
  this.virtualTrigger = detail.virtualTrigger;
284
292
  this.placement = detail.placement;
285
293
  this.offset = detail.offset;
294
+ this.skidding = detail.skidding || 0;
286
295
  this.interaction = detail.interaction;
287
296
  this.theme = detail.theme;
288
297
  this.receivesFocus = detail.receivesFocus;
@@ -365,10 +374,9 @@ export class ActiveOverlay extends SpectrumElement {
365
374
  });
366
375
  }
367
376
  renderTheme(content) {
368
- const { color, scale, lang, theme } = this.theme;
377
+ const { color, scale, lang } = this.theme;
369
378
  return html `
370
379
  <sp-theme
371
- theme=${ifDefined(theme)}
372
380
  color=${ifDefined(color)}
373
381
  scale=${ifDefined(scale)}
374
382
  lang=${ifDefined(lang)}
@@ -1 +1 @@
1
- {"version":3,"file":"ActiveOverlay.js","sourceRoot":"","sources":["ActiveOverlay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;;AAEF,OAAO,EAEH,IAAI,EAEJ,eAAe,GAElB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,iDAAiD,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,iDAAiD,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2DAA2D,CAAC;AAE7F,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAQ7C,OAAO,EACH,KAAK,EACL,eAAe,EACf,IAAI,EACJ,MAAM,EACN,KAAK,EACL,IAAI,GACP,MAAM,kBAAkB,CAAC;AAc1B,MAAM,YAAY,GASd;IACA,OAAO,EAAE,MAAM;IACf,MAAM,EAAE;QACJ,IAAI,EAAE;YACF,EAAE,EAAE;gBACA,MAAM,EAAE,QAAQ;aACnB;SACJ;QACD,MAAM,EAAE;YACJ,EAAE,EAAE;gBACA,MAAM,EAAE,QAAQ;gBAChB,IAAI,EAAE,MAAM;aACf;SACJ;QACD,MAAM,EAAE;YACJ,EAAE,EAAE;gBACA,OAAO,EAAE,SAAS;aACrB;SACJ;QACD,OAAO,EAAE;YACL,EAAE,EAAE;gBACA,QAAQ,EAAE,UAAU;aACvB;SACJ;QACD,QAAQ,EAAE;YACN,EAAE,EAAE,EAAE;SACT;KACJ;CACJ,CAAC;AAEF,MAAM,eAAe,GAAG,CACpB,KAAwB,EACxB,KAAc,EACE,EAAE;IAClB,IAAI,CAAC,KAAK;QAAE,OAAO,YAAY,CAAC,OAAO,CAAC;IACxC,oBAA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 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 { ifDefined } from '@spectrum-web-components/base/src/directives.js';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport { reparentChildren } from '@spectrum-web-components/shared';\nimport { firstFocusableIn } from '@spectrum-web-components/shared/src/first-focusable-in.js';\nimport { Color, Flavor, Scale } from '@spectrum-web-components/theme';\nimport styles from './active-overlay.css.js';\nimport {\n OverlayOpenCloseDetail,\n OverlayOpenDetail,\n Placement,\n TriggerInteractions,\n} from './overlay-types.js';\nimport type { VirtualTrigger } from './VirtualTrigger.js';\nimport {\n arrow,\n computePosition,\n flip,\n offset,\n shift,\n size,\n} from '@floating-ui/dom';\n\nexport interface PositionResult {\n arrowOffsetLeft: number;\n arrowOffsetTop: number;\n maxHeight: number;\n placement: string;\n positionLeft: number;\n positionTop: number;\n}\n\ntype OverlayStateType = 'idle' | 'active' | 'hiding' | 'dispose' | 'disposed';\ntype ContentAnimation = 'sp-overlay-fade-in' | 'sp-overlay-fade-out';\n\nconst stateMachine: {\n initial: OverlayStateType;\n states: {\n [stateName: string]: {\n on: {\n [transitionName: string]: OverlayStateType;\n };\n };\n };\n} = {\n initial: 'idle',\n states: {\n idle: {\n on: {\n active: 'active',\n },\n },\n active: {\n on: {\n hiding: 'hiding',\n idle: 'idle',\n },\n },\n hiding: {\n on: {\n dispose: 'dispose',\n },\n },\n dispose: {\n on: {\n disposed: 'disposed',\n },\n },\n disposed: {\n on: {},\n },\n },\n};\n\nconst stateTransition = (\n state?: OverlayStateType,\n event?: string\n): OverlayStateType => {\n if (!state) return stateMachine.initial;\n /* c8 ignore next */\n if (!event) return state;\n return stateMachine.states[state].on[event] || state;\n};\n\nconst parentOverlayOf = (el: Element): ActiveOverlay | null => {\n const closestOverlay = el.closest('active-overlay');\n if (closestOverlay) {\n return closestOverlay;\n }\n const rootNode = el.getRootNode() as ShadowRoot;\n if (rootNode.host) {\n return parentOverlayOf(rootNode.host);\n }\n return null;\n};\n\n/**\n * @element active-overlay\n *\n * @slot - content to display in the overlay\n */\nexport class ActiveOverlay extends SpectrumElement {\n public overlayContent!: HTMLElement;\n public overlayContentTip?: HTMLElement;\n public trigger!: HTMLElement;\n public virtualTrigger?: VirtualTrigger;\n\n protected childrenReady!: Promise<unknown[]>;\n\n @property()\n public _state = stateTransition();\n public get state(): OverlayStateType {\n return this._state;\n }\n public set state(state: OverlayStateType) {\n const nextState = stateTransition(this.state, state);\n if (nextState === this.state) {\n return;\n }\n this._state = nextState;\n if (this.state === 'active' || this.state === 'hiding') {\n this.setAttribute('state', this.state);\n } else {\n this.removeAttribute('state');\n }\n }\n\n @property({ reflect: true, type: Boolean })\n public animating = false;\n\n @property({ reflect: true })\n public placement?: Placement;\n @property({ attribute: false })\n public theme: {\n color?: Color;\n scale?: Scale;\n lang?: string;\n theme?: Flavor;\n } = {};\n @property({ attribute: false })\n public receivesFocus?: 'auto';\n\n public tabbingAway = false;\n private originalPlacement?: Placement;\n private restoreContent?: () => Element[];\n\n public focus(): void {\n const firstFocusable = firstFocusableIn(this);\n if (firstFocusable) {\n firstFocusable.focus();\n /* c8 ignore next 3 */\n } else {\n super.focus();\n }\n this.removeAttribute('tabindex');\n }\n\n private get hasTheme(): boolean {\n return !!this.theme.color || !!this.theme.scale || !!this.theme.lang;\n }\n\n public offset = 6;\n public interaction: TriggerInteractions = 'hover';\n private positionAnimationFrame = 0;\n\n private timeout?: number;\n\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n public constructor() {\n super();\n this.stealOverlayContentPromise = new Promise(\n (res) => (this.stealOverlayContentResolver = res)\n );\n }\n\n private _modalRoot?: ActiveOverlay;\n\n public get hasModalRoot(): boolean {\n return !!this._modalRoot;\n }\n\n public feature(): void {\n this.tabIndex = -1;\n const parentOverlay = parentOverlayOf(this.trigger);\n const parentIsModal = parentOverlay && parentOverlay.slot === 'open';\n // If an overlay it triggered from within a \"modal\" overlay, it needs to continue\n // to act like one to get treated correctly in regards to tab trapping.\n if (this.interaction === 'modal' || parentIsModal || this._modalRoot) {\n this.slot = 'open';\n if (this.interaction === 'modal') {\n this.setAttribute('aria-modal', 'true');\n }\n // If this isn't a modal root, walk up the overlays to the next modal root\n // and \"feature\" each on of the intervening overlays.\n if (this._modalRoot) {\n parentOverlay?.feature();\n }\n }\n }\n\n public obscure(\n nextOverlayInteraction: TriggerInteractions\n ): ActiveOverlay | undefined {\n if (this.slot && nextOverlayInteraction === 'modal') {\n this.removeAttribute('slot');\n this.removeAttribute('aria-modal');\n // Obscure upto and including the next modal root.\n if (this.interaction !== 'modal') {\n const parentOverlay = parentOverlayOf(this.trigger);\n this._modalRoot = parentOverlay?.obscure(\n nextOverlayInteraction\n );\n return this._modalRoot;\n }\n return this;\n }\n return undefined;\n }\n\n public async firstUpdated(\n changedProperties: PropertyValues\n ): Promise<void> {\n super.firstUpdated(changedProperties);\n\n /* c8 ignore next */\n if (!this.overlayContent || !this.trigger) return;\n\n this.stealOverlayContent(\n this.overlayContent as HTMLElement & { placement: Placement }\n );\n\n this.state = 'active';\n this.feature();\n if (this.placement === 'none') {\n this.style.setProperty(\n '--swc-visual-viewport-height',\n `${window.innerHeight}px`\n );\n } else if (this.placement) {\n await this.updateOverlayPosition();\n document.addEventListener(\n 'sp-update-overlays',\n this.updateOverlayPosition\n );\n window.addEventListener('scroll', this.updateOverlayPosition);\n }\n const actions: Promise<unknown>[] = [];\n if (this.placement && this.placement !== 'none') {\n actions.push(this.applyContentAnimation('sp-overlay-fade-in'));\n }\n if (\n typeof (this.overlayContent as SpectrumElement).updateComplete !==\n 'undefined'\n ) {\n actions.push(\n (this.overlayContent as SpectrumElement).updateComplete\n );\n }\n this.childrenReady = Promise.all(actions);\n }\n\n public async openCallback(): Promise<void> {\n await this.updateComplete;\n if (this.receivesFocus) {\n this.focus();\n }\n\n this.trigger.dispatchEvent(\n new CustomEvent<OverlayOpenCloseDetail>('sp-opened', {\n bubbles: true,\n composed: true,\n cancelable: true,\n detail: {\n interaction: this.interaction,\n },\n })\n );\n }\n\n private open(openDetail: OverlayOpenDetail): void {\n this.extractDetail(openDetail);\n }\n\n private extractDetail(detail: OverlayOpenDetail): void {\n this.overlayContent = detail.content;\n this.overlayContentTip = detail.contentTip;\n this.trigger = detail.trigger;\n this.virtualTrigger = detail.virtualTrigger;\n this.placement = detail.placement;\n this.offset = detail.offset;\n this.interaction = detail.interaction;\n this.theme = detail.theme;\n this.receivesFocus = detail.receivesFocus;\n }\n\n public dispose(): void {\n /* c8 ignore next */\n if (this.state !== 'dispose') return;\n\n /* c8 ignore next 4 */\n if (this.timeout) {\n clearTimeout(this.timeout);\n delete this.timeout;\n }\n\n this.trigger.removeEventListener(\n 'keydown',\n this.handleInlineTriggerKeydown\n );\n\n this.returnOverlayContent();\n this.state = 'disposed';\n\n if (this.willNotifyClosed) {\n this.overlayContent.dispatchEvent(new Event('sp-overlay-closed'));\n this.willNotifyClosed = false;\n }\n }\n\n private stealOverlayContent(\n element: HTMLElement & { placement: Placement }\n ): void {\n this.originalPlacement = element.getAttribute('placement') as Placement;\n this.restoreContent = reparentChildren([element], this, (el) => {\n const slotName = el.slot;\n const placement = el.placement;\n el.removeAttribute('slot');\n return (el) => {\n el.slot = slotName;\n el.placement = placement;\n };\n });\n this.stealOverlayContentResolver();\n }\n\n private willNotifyClosed = false;\n\n private returnOverlayContent(): void {\n /* c8 ignore next */\n if (!this.restoreContent) return;\n\n const [element] = this.restoreContent();\n this.restoreContent = undefined;\n this.willNotifyClosed = true;\n\n if (this.originalPlacement) {\n element.setAttribute('placement', this.originalPlacement);\n delete this.originalPlacement;\n }\n }\n\n private initialHeight!: number;\n private isConstrained = false;\n\n public updateOverlayPosition = async (): Promise<void> => {\n if (!this.placement || this.placement === 'none') {\n return;\n }\n await (document.fonts ? document.fonts.ready : Promise.resolve());\n\n function roundByDPR(num: number): number {\n const dpr = window.devicePixelRatio || 1;\n return Math.round(num * dpr) / dpr || -10000;\n }\n\n // See: https://spectrum.adobe.com/page/popover/#Container-padding\n const REQUIRED_DISTANCE_TO_EDGE = 8;\n // See: https://github.com/adobe/spectrum-web-components/issues/910\n const MIN_OVERLAY_HEIGHT = 100;\n\n const middleware = [\n offset(this.offset),\n flip({\n fallbackStrategy: 'initialPlacement',\n }),\n shift({ padding: REQUIRED_DISTANCE_TO_EDGE }),\n size({\n padding: REQUIRED_DISTANCE_TO_EDGE,\n apply: ({ width, height, floating }) => {\n const maxHeight = Math.max(\n MIN_OVERLAY_HEIGHT,\n Math.floor(height)\n );\n const actualHeight = floating.height;\n this.initialHeight = !this.isConstrained\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(this.style, {\n maxWidth: `${Math.floor(width)}px`,\n maxHeight: appliedHeight,\n height: appliedHeight,\n });\n },\n }),\n ];\n if (this.overlayContentTip) {\n middleware.push(arrow({ element: this.overlayContentTip }));\n }\n const { x, y, placement, middlewareData } = await computePosition(\n this.virtualTrigger || this.trigger,\n this,\n {\n placement: this.placement,\n middleware,\n }\n );\n\n Object.assign(this.style, {\n left: `${roundByDPR(x)}px`,\n top: `${roundByDPR(y)}px`,\n });\n\n if (placement !== this.getAttribute('actual-placement')) {\n this.setAttribute('actual-placement', placement);\n this.overlayContent.setAttribute('placement', placement);\n }\n\n if (this.overlayContentTip && middlewareData.arrow) {\n const { x: arrowX, y: arrowY } = middlewareData.arrow;\n\n Object.assign(this.overlayContentTip.style, {\n left: arrowX != null ? `${roundByDPR(arrowX)}px` : '',\n top: arrowY != null ? `${roundByDPR(arrowY)}px` : '',\n right: '',\n bottom: '',\n });\n }\n };\n\n public async hide(animated = true): Promise<void> {\n this.state = 'hiding';\n if (animated) {\n await this.applyContentAnimation('sp-overlay-fade-out');\n }\n this.state = 'dispose';\n }\n\n private schedulePositionUpdate(): void {\n // Edge needs a little time to update the DOM before computing the layout\n cancelAnimationFrame(this.positionAnimationFrame);\n this.positionAnimationFrame = requestAnimationFrame(() =>\n this.updateOverlayPosition()\n );\n }\n\n private onSlotChange(): void {\n this.schedulePositionUpdate();\n }\n\n public handleInlineTriggerKeydown = (event: KeyboardEvent): void => {\n const { code, shiftKey } = event;\n /* c8 ignore next */\n if (code !== 'Tab') return;\n if (shiftKey) {\n this.tabbingAway = true;\n this.dispatchEvent(new Event('close'));\n return;\n }\n\n event.stopPropagation();\n event.preventDefault();\n this.focus();\n };\n\n public applyContentAnimation(\n animation: ContentAnimation\n ): Promise<boolean> {\n if (this.placement === 'none') {\n return Promise.resolve(true);\n }\n return new Promise((resolve): void => {\n const contents = this.shadowRoot.querySelector(\n '#contents'\n ) as HTMLElement;\n const doneHandler = (event: AnimationEvent): void => {\n if (animation !== event.animationName) return;\n contents.removeEventListener('animationend', doneHandler);\n contents.removeEventListener('animationcancel', doneHandler);\n this.animating = false;\n resolve(event.type === 'animationcancel');\n };\n contents.addEventListener('animationend', doneHandler);\n contents.addEventListener('animationcancel', doneHandler);\n\n contents.style.animationName = animation;\n this.animating = true;\n });\n }\n\n public renderTheme(content: TemplateResult): TemplateResult {\n const { color, scale, lang, theme } = this.theme;\n return html`\n <sp-theme\n theme=${ifDefined(theme)}\n color=${ifDefined(color)}\n scale=${ifDefined(scale)}\n lang=${ifDefined(lang)}\n part=\"theme\"\n >\n ${content}\n </sp-theme>\n `;\n }\n\n public render(): TemplateResult {\n const content = html`\n <div id=\"contents\">\n <slot @slotchange=${this.onSlotChange}></slot>\n </div>\n `;\n return this.hasTheme ? this.renderTheme(content) : content;\n }\n\n public static create(details: OverlayOpenDetail): ActiveOverlay {\n const overlay = new ActiveOverlay();\n\n if (details.content) {\n overlay.open(details);\n }\n\n return overlay;\n }\n\n private stealOverlayContentPromise = Promise.resolve();\n private stealOverlayContentResolver!: () => void;\n\n protected async getUpdateComplete(): Promise<boolean> {\n const actions: Promise<unknown>[] = [\n super.getUpdateComplete(),\n this.stealOverlayContentPromise,\n ];\n if (this.childrenReady) {\n actions.push(this.childrenReady);\n }\n const [complete] = await Promise.all(actions);\n return complete as boolean;\n }\n\n disconnectedCallback(): void {\n document.removeEventListener(\n 'sp-update-overlays',\n this.updateOverlayPosition\n );\n window.removeEventListener('scroll', this.updateOverlayPosition);\n super.disconnectedCallback();\n }\n}\n"]}
1
+ {"version":3,"file":"ActiveOverlay.js","sourceRoot":"","sources":["ActiveOverlay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;;AAEF,OAAO,EAEH,IAAI,EAEJ,eAAe,GAElB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,iDAAiD,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,iDAAiD,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,0DAA0D,CAAC;AAC5F,OAAO,EAAE,gBAAgB,EAAE,MAAM,2DAA2D,CAAC;AAE7F,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAQ7C,OAAO,EACH,KAAK,EACL,eAAe,EACf,IAAI,EACJ,MAAM,EACN,KAAK,EACL,IAAI,GACP,MAAM,kBAAkB,CAAC;AAc1B,MAAM,YAAY,GASd;IACA,OAAO,EAAE,MAAM;IACf,MAAM,EAAE;QACJ,IAAI,EAAE;YACF,EAAE,EAAE;gBACA,MAAM,EAAE,QAAQ;aACnB;SACJ;QACD,MAAM,EAAE;YACJ,EAAE,EAAE;gBACA,MAAM,EAAE,QAAQ;gBAChB,IAAI,EAAE,MAAM;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BAAoB;QAChB,QAAQ,CAAC,mBAAmB,CACxB,oBAAoB,EACpB,IAAI,CAAC,qBAAqB,CAC7B,CAAC;QACF,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,IAAI,CAAC,qBAAqB,CAAC,CAAC;QACjE,KAAK,CAAC,oBAAoB,EAAE,CAAC;IACjC,CAAC;CACJ;AApcG;IADC,QAAQ,EAAE;6CACuB;AAkBlC;IADC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gDAClB;AAGzB;IADC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gDACC;AAE7B;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;4CAKxB;AAEP;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;oDACD","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 { ifDefined } from '@spectrum-web-components/base/src/directives.js';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport { reparentChildren } from '@spectrum-web-components/shared/src/reparent-children.js';\nimport { firstFocusableIn } from '@spectrum-web-components/shared/src/first-focusable-in.js';\nimport type { Color, Scale } from '@spectrum-web-components/theme/src/Theme.js';\nimport styles from './active-overlay.css.js';\nimport {\n OverlayOpenCloseDetail,\n OverlayOpenDetail,\n Placement,\n TriggerInteractions,\n} from './overlay-types.js';\nimport type { VirtualTrigger } from './VirtualTrigger.js';\nimport {\n arrow,\n computePosition,\n flip,\n offset,\n shift,\n size,\n} from '@floating-ui/dom';\n\nexport interface PositionResult {\n arrowOffsetLeft: number;\n arrowOffsetTop: number;\n maxHeight: number;\n placement: string;\n positionLeft: number;\n positionTop: number;\n}\n\ntype OverlayStateType = 'idle' | 'active' | 'hiding' | 'dispose' | 'disposed';\ntype ContentAnimation = 'sp-overlay-fade-in' | 'sp-overlay-fade-out';\n\nconst stateMachine: {\n initial: OverlayStateType;\n states: {\n [stateName: string]: {\n on: {\n [transitionName: string]: OverlayStateType;\n };\n };\n };\n} = {\n initial: 'idle',\n states: {\n idle: {\n on: {\n active: 'active',\n },\n },\n active: {\n on: {\n hiding: 'hiding',\n idle: 'idle',\n },\n },\n hiding: {\n on: {\n dispose: 'dispose',\n },\n },\n dispose: {\n on: {\n disposed: 'disposed',\n },\n },\n disposed: {\n on: {},\n },\n },\n};\n\nconst stateTransition = (\n state?: OverlayStateType,\n event?: string\n): OverlayStateType => {\n if (!state) return stateMachine.initial;\n /* c8 ignore next */\n if (!event) return state;\n return stateMachine.states[state].on[event] || state;\n};\n\nconst parentOverlayOf = (el: Element): ActiveOverlay | null => {\n const closestOverlay = el.closest('active-overlay');\n if (closestOverlay) {\n return closestOverlay;\n }\n const rootNode = el.getRootNode() as ShadowRoot;\n if (rootNode.host) {\n return parentOverlayOf(rootNode.host);\n }\n return null;\n};\n\n/**\n * @element active-overlay\n *\n * @slot - content to display in the overlay\n */\nexport class ActiveOverlay extends SpectrumElement {\n public overlayContent!: HTMLElement;\n public overlayContentTip?: HTMLElement;\n public trigger!: HTMLElement;\n public virtualTrigger?: VirtualTrigger;\n\n protected childrenReady!: Promise<unknown[]>;\n\n @property()\n public _state = stateTransition();\n public get state(): OverlayStateType {\n return this._state;\n }\n public set state(state: OverlayStateType) {\n const nextState = stateTransition(this.state, state);\n if (nextState === this.state) {\n return;\n }\n this._state = nextState;\n if (this.state === 'active' || this.state === 'hiding') {\n this.setAttribute('state', this.state);\n } else {\n this.removeAttribute('state');\n }\n }\n\n @property({ reflect: true, type: Boolean })\n public animating = false;\n\n @property({ reflect: true })\n public placement?: Placement;\n @property({ attribute: false })\n public theme: {\n color?: Color;\n scale?: Scale;\n lang?: string;\n } = {};\n @property({ attribute: false })\n public receivesFocus?: 'auto';\n\n public tabbingAway = false;\n private originalPlacement?: Placement;\n private restoreContent?: () => Element[];\n\n public focus(): void {\n const firstFocusable = firstFocusableIn(this);\n if (firstFocusable) {\n firstFocusable.focus();\n /* c8 ignore next 3 */\n } else {\n super.focus();\n }\n this.removeAttribute('tabindex');\n }\n\n private get hasTheme(): boolean {\n return !!this.theme.color || !!this.theme.scale || !!this.theme.lang;\n }\n\n public offset = 6;\n public skidding = 0;\n public interaction: TriggerInteractions = 'hover';\n private positionAnimationFrame = 0;\n\n private timeout?: number;\n\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n public constructor() {\n super();\n this.stealOverlayContentPromise = new Promise(\n (res) => (this.stealOverlayContentResolver = res)\n );\n }\n\n private _modalRoot?: ActiveOverlay;\n\n public get hasModalRoot(): boolean {\n return !!this._modalRoot;\n }\n\n public feature(): void {\n this.tabIndex = -1;\n const parentOverlay = parentOverlayOf(this.trigger);\n const parentIsModal = parentOverlay && parentOverlay.slot === 'open';\n if (parentIsModal) {\n this._modalRoot = parentOverlay._modalRoot || parentOverlay;\n }\n // If an overlay it triggered from within a \"modal\" overlay, it needs to continue\n // to act like one to get treated correctly in regards to tab trapping.\n if (this.interaction === 'modal' || this._modalRoot) {\n this.slot = 'open';\n if (this.interaction === 'modal') {\n this.setAttribute('aria-modal', 'true');\n }\n // If this isn't a modal root, walk up the overlays to the next modal root\n // and \"feature\" each on of the intervening overlays.\n if (this._modalRoot) {\n parentOverlay?.feature();\n }\n }\n }\n\n public obscure(\n nextOverlayInteraction: TriggerInteractions\n ): ActiveOverlay | undefined {\n if (this.slot && nextOverlayInteraction === 'modal') {\n this.removeAttribute('slot');\n this.removeAttribute('aria-modal');\n // Obscure upto and including the next modal root.\n if (this.interaction !== 'modal') {\n const parentOverlay = parentOverlayOf(this.trigger);\n this._modalRoot = parentOverlay?.obscure(\n nextOverlayInteraction\n );\n return this._modalRoot;\n }\n return this;\n }\n return undefined;\n }\n\n public async firstUpdated(\n changedProperties: PropertyValues\n ): Promise<void> {\n super.firstUpdated(changedProperties);\n\n /* c8 ignore next */\n if (!this.overlayContent || !this.trigger) return;\n\n this.stealOverlayContent(\n this.overlayContent as HTMLElement & { placement: Placement }\n );\n\n this.state = 'active';\n this.feature();\n if (this.placement === 'none') {\n this.style.setProperty(\n '--swc-visual-viewport-height',\n `${window.innerHeight}px`\n );\n } else if (this.placement) {\n await this.updateOverlayPosition();\n document.addEventListener(\n 'sp-update-overlays',\n this.updateOverlayPosition\n );\n window.addEventListener('scroll', this.updateOverlayPosition);\n }\n const actions: Promise<unknown>[] = [];\n if (this.placement && this.placement !== 'none') {\n actions.push(this.applyContentAnimation('sp-overlay-fade-in'));\n }\n if (\n typeof (this.overlayContent as SpectrumElement).updateComplete !==\n 'undefined'\n ) {\n actions.push(\n (this.overlayContent as SpectrumElement).updateComplete\n );\n }\n this.childrenReady = Promise.all(actions);\n }\n\n public async openCallback(): Promise<void> {\n await this.updateComplete;\n if (this.receivesFocus) {\n this.focus();\n }\n\n this.trigger.dispatchEvent(\n new CustomEvent<OverlayOpenCloseDetail>('sp-opened', {\n bubbles: true,\n composed: true,\n cancelable: true,\n detail: {\n interaction: this.interaction,\n },\n })\n );\n }\n\n private open(openDetail: OverlayOpenDetail): void {\n this.extractDetail(openDetail);\n }\n\n private extractDetail(detail: OverlayOpenDetail): void {\n this.overlayContent = detail.content;\n this.overlayContentTip = detail.contentTip;\n this.trigger = detail.trigger;\n this.virtualTrigger = detail.virtualTrigger;\n this.placement = detail.placement;\n this.offset = detail.offset;\n this.skidding = detail.skidding || 0;\n this.interaction = detail.interaction;\n this.theme = detail.theme;\n this.receivesFocus = detail.receivesFocus;\n }\n\n public dispose(): void {\n /* c8 ignore next */\n if (this.state !== 'dispose') return;\n\n /* c8 ignore next 4 */\n if (this.timeout) {\n clearTimeout(this.timeout);\n delete this.timeout;\n }\n\n this.trigger.removeEventListener(\n 'keydown',\n this.handleInlineTriggerKeydown\n );\n\n this.returnOverlayContent();\n this.state = 'disposed';\n\n if (this.willNotifyClosed) {\n this.overlayContent.dispatchEvent(new Event('sp-overlay-closed'));\n this.willNotifyClosed = false;\n }\n }\n\n private stealOverlayContent(\n element: HTMLElement & { placement: Placement }\n ): void {\n this.originalPlacement = element.getAttribute('placement') as Placement;\n this.restoreContent = reparentChildren([element], this, (el) => {\n const slotName = el.slot;\n const placement = el.placement;\n el.removeAttribute('slot');\n return (el) => {\n el.slot = slotName;\n el.placement = placement;\n };\n });\n this.stealOverlayContentResolver();\n }\n\n private willNotifyClosed = false;\n\n private returnOverlayContent(): void {\n /* c8 ignore next */\n if (!this.restoreContent) return;\n\n const [element] = this.restoreContent();\n this.restoreContent = undefined;\n this.willNotifyClosed = true;\n\n if (this.originalPlacement) {\n element.setAttribute('placement', this.originalPlacement);\n delete this.originalPlacement;\n }\n }\n\n private initialHeight!: number;\n private isConstrained = false;\n\n public updateOverlayPosition = async (): Promise<void> => {\n if (!this.placement || this.placement === 'none') {\n return;\n }\n await (document.fonts ? document.fonts.ready : Promise.resolve());\n\n function roundByDPR(num: number): number {\n const dpr = window.devicePixelRatio || 1;\n return Math.round(num * dpr) / dpr || -10000;\n }\n\n // See: https://spectrum.adobe.com/page/popover/#Container-padding\n const REQUIRED_DISTANCE_TO_EDGE = 8;\n // See: https://github.com/adobe/spectrum-web-components/issues/910\n const MIN_OVERLAY_HEIGHT = 100;\n\n const middleware = [\n offset({\n mainAxis: this.offset,\n crossAxis: this.skidding,\n }),\n flip({\n fallbackStrategy: 'initialPlacement',\n }),\n shift({ padding: REQUIRED_DISTANCE_TO_EDGE }),\n size({\n padding: REQUIRED_DISTANCE_TO_EDGE,\n apply: ({ width, height, floating }) => {\n const maxHeight = Math.max(\n MIN_OVERLAY_HEIGHT,\n Math.floor(height)\n );\n const actualHeight = floating.height;\n this.initialHeight = !this.isConstrained\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(this.style, {\n maxWidth: `${Math.floor(width)}px`,\n maxHeight: appliedHeight,\n height: appliedHeight,\n });\n },\n }),\n ];\n if (this.overlayContentTip) {\n middleware.push(arrow({ element: this.overlayContentTip }));\n }\n const { x, y, placement, middlewareData } = await computePosition(\n this.virtualTrigger || this.trigger,\n this,\n {\n placement: this.placement,\n middleware,\n }\n );\n\n Object.assign(this.style, {\n top: '0px',\n left: '0px',\n transform: `translate(${roundByDPR(x)}px, ${roundByDPR(y)}px)`,\n });\n\n if (placement !== this.getAttribute('actual-placement')) {\n this.setAttribute('actual-placement', placement);\n this.overlayContent.setAttribute('placement', placement);\n }\n\n if (this.overlayContentTip && middlewareData.arrow) {\n const { x: arrowX, y: arrowY } = middlewareData.arrow;\n\n Object.assign(this.overlayContentTip.style, {\n left: arrowX != null ? `${roundByDPR(arrowX)}px` : '',\n top: arrowY != null ? `${roundByDPR(arrowY)}px` : '',\n right: '',\n bottom: '',\n });\n }\n };\n\n public async hide(animated = true): Promise<void> {\n this.state = 'hiding';\n if (animated) {\n await this.applyContentAnimation('sp-overlay-fade-out');\n }\n this.state = 'dispose';\n }\n\n private schedulePositionUpdate(): void {\n // Edge needs a little time to update the DOM before computing the layout\n cancelAnimationFrame(this.positionAnimationFrame);\n this.positionAnimationFrame = requestAnimationFrame(() =>\n this.updateOverlayPosition()\n );\n }\n\n private onSlotChange(): void {\n this.schedulePositionUpdate();\n }\n\n public handleInlineTriggerKeydown = (event: KeyboardEvent): void => {\n const { code, shiftKey } = event;\n /* c8 ignore next */\n if (code !== 'Tab') return;\n if (shiftKey) {\n this.tabbingAway = true;\n this.dispatchEvent(new Event('close'));\n return;\n }\n\n event.stopPropagation();\n event.preventDefault();\n this.focus();\n };\n\n public applyContentAnimation(\n animation: ContentAnimation\n ): Promise<boolean> {\n if (this.placement === 'none') {\n return Promise.resolve(true);\n }\n return new Promise((resolve): void => {\n const contents = this.shadowRoot.querySelector(\n '#contents'\n ) as HTMLElement;\n const doneHandler = (event: AnimationEvent): void => {\n if (animation !== event.animationName) return;\n contents.removeEventListener('animationend', doneHandler);\n contents.removeEventListener('animationcancel', doneHandler);\n this.animating = false;\n resolve(event.type === 'animationcancel');\n };\n contents.addEventListener('animationend', doneHandler);\n contents.addEventListener('animationcancel', doneHandler);\n\n contents.style.animationName = animation;\n this.animating = true;\n });\n }\n\n public renderTheme(content: TemplateResult): TemplateResult {\n const { color, scale, lang } = this.theme;\n return html`\n <sp-theme\n color=${ifDefined(color)}\n scale=${ifDefined(scale)}\n lang=${ifDefined(lang)}\n part=\"theme\"\n >\n ${content}\n </sp-theme>\n `;\n }\n\n public render(): TemplateResult {\n const content = html`\n <div id=\"contents\">\n <slot @slotchange=${this.onSlotChange}></slot>\n </div>\n `;\n return this.hasTheme ? this.renderTheme(content) : content;\n }\n\n public static create(details: OverlayOpenDetail): ActiveOverlay {\n const overlay = new ActiveOverlay();\n\n if (details.content) {\n overlay.open(details);\n }\n\n return overlay;\n }\n\n private stealOverlayContentPromise = Promise.resolve();\n private stealOverlayContentResolver!: () => void;\n\n protected async getUpdateComplete(): Promise<boolean> {\n const actions: Promise<unknown>[] = [\n super.getUpdateComplete(),\n this.stealOverlayContentPromise,\n ];\n if (this.childrenReady) {\n actions.push(this.childrenReady);\n }\n const [complete] = await Promise.all(actions);\n return complete as boolean;\n }\n\n disconnectedCallback(): void {\n document.removeEventListener(\n 'sp-update-overlays',\n this.updateOverlayPosition\n );\n window.removeEventListener('scroll', this.updateOverlayPosition);\n super.disconnectedCallback();\n }\n}\n"]}
@@ -11,7 +11,7 @@ governing permissions and limitations under the License.
11
11
  */
12
12
  import { css } from '@spectrum-web-components/base';
13
13
  const styles = css `
14
- @keyframes sp-overlay-fade-in{0%{opacity:0;transform:var(--sp-overlay-from)}to{opacity:1;transform:translate(0)}}@keyframes sp-overlay-fade-out{0%{opacity:1;transform:translate(0)}to{opacity:0;transform:var(--sp-overlay-from)}}:host{display:inline-block;left:0;pointer-events:none;position:absolute;top:0;z-index:1000}:host(:focus){outline:none}:host([placement=none]){height:100vh;height:-webkit-fill-available;height:fill-available;max-height:var(--swc-visual-viewport-height);position:fixed}#contents,sp-theme{height:100%}#contents{animation-duration:var(
14
+ @keyframes sp-overlay-fade-in{0%{opacity:0;transform:var(--sp-overlay-from)}to{opacity:1;transform:translate(0)}}@keyframes sp-overlay-fade-out{0%{opacity:1;transform:translate(0)}to{opacity:0;transform:var(--sp-overlay-from)}}:host{display:inline-block;left:-9999em;pointer-events:none;position:absolute;top:-9999em;z-index:1000}:host(:focus){outline:none}:host([placement=none]){height:100vh;height:-webkit-fill-available;height:fill-available;left:0;max-height:var(--swc-visual-viewport-height);position:fixed;top:0}#contents,sp-theme{height:100%}#contents{animation-duration:var(
15
15
  --swc-test-duration,var(--spectrum-global-animation-duration-200,.16s)
16
16
  );animation-timing-function:var(
17
17
  --spectrum-global-animation-ease-out,ease-out
@@ -1 +1 @@
1
- {"version":3,"file":"active-overlay.css.js","sourceRoot":"","sources":["active-overlay.css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACpD,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;CAMjB,CAAC;AACF,eAAe,MAAM,CAAC","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 { css } from '@spectrum-web-components/base';\nconst styles = css`\n@keyframes sp-overlay-fade-in{0%{opacity:0;transform:var(--sp-overlay-from)}to{opacity:1;transform:translate(0)}}@keyframes sp-overlay-fade-out{0%{opacity:1;transform:translate(0)}to{opacity:0;transform:var(--sp-overlay-from)}}:host{display:inline-block;left:0;pointer-events:none;position:absolute;top:0;z-index:1000}:host(:focus){outline:none}:host([placement=none]){height:100vh;height:-webkit-fill-available;height:fill-available;max-height:var(--swc-visual-viewport-height);position:fixed}#contents,sp-theme{height:100%}#contents{animation-duration:var(\n--swc-test-duration,var(--spectrum-global-animation-duration-200,.16s)\n);animation-timing-function:var(\n--spectrum-global-animation-ease-out,ease-out\n);display:inline-block;opacity:1;pointer-events:none;visibility:visible}:host([actual-placement*=top]) #contents{--sp-overlay-from:translateY(var(--spectrum-global-dimension-size-75));align-items:flex-end;display:inline-flex}:host([actual-placement*=right]) #contents{--sp-overlay-from:translateX(calc(var(--spectrum-global-dimension-size-75)*-1))}:host([actual-placement*=bottom]) #contents{--sp-overlay-from:translateY(calc(var(--spectrum-global-dimension-size-75)*-1))}:host([actual-placement*=left]) #contents{--sp-overlay-from:translateX(var(--spectrum-global-dimension-size-75))}:host([animating]) ::slotted(*){pointer-events:none}:host(:not([animating])) ::slotted(*){pointer-events:auto}#contents ::slotted(*){position:relative}\n`;\nexport default styles;"]}
1
+ {"version":3,"file":"active-overlay.css.js","sourceRoot":"","sources":["active-overlay.css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACpD,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;CAMjB,CAAC;AACF,eAAe,MAAM,CAAC","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 { css } from '@spectrum-web-components/base';\nconst styles = css`\n@keyframes sp-overlay-fade-in{0%{opacity:0;transform:var(--sp-overlay-from)}to{opacity:1;transform:translate(0)}}@keyframes sp-overlay-fade-out{0%{opacity:1;transform:translate(0)}to{opacity:0;transform:var(--sp-overlay-from)}}:host{display:inline-block;left:-9999em;pointer-events:none;position:absolute;top:-9999em;z-index:1000}:host(:focus){outline:none}:host([placement=none]){height:100vh;height:-webkit-fill-available;height:fill-available;left:0;max-height:var(--swc-visual-viewport-height);position:fixed;top:0}#contents,sp-theme{height:100%}#contents{animation-duration:var(\n--swc-test-duration,var(--spectrum-global-animation-duration-200,.16s)\n);animation-timing-function:var(\n--spectrum-global-animation-ease-out,ease-out\n);display:inline-block;opacity:1;pointer-events:none;visibility:visible}:host([actual-placement*=top]) #contents{--sp-overlay-from:translateY(var(--spectrum-global-dimension-size-75));align-items:flex-end;display:inline-flex}:host([actual-placement*=right]) #contents{--sp-overlay-from:translateX(calc(var(--spectrum-global-dimension-size-75)*-1))}:host([actual-placement*=bottom]) #contents{--sp-overlay-from:translateY(calc(var(--spectrum-global-dimension-size-75)*-1))}:host([actual-placement*=left]) #contents{--sp-overlay-from:translateX(var(--spectrum-global-dimension-size-75))}:host([animating]) ::slotted(*){pointer-events:none}:host(:not([animating])) ::slotted(*){pointer-events:auto}#contents ::slotted(*){position:relative}\n`;\nexport default styles;"]}
package/src/loader.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { OverlayOptions, TriggerInteractions } from './overlay-types';
1
+ import type { OverlayOptions, TriggerInteractions } from './overlay-types';
2
2
  export declare const openOverlay: (target: HTMLElement, interaction: TriggerInteractions, content: HTMLElement, options: OverlayOptions) => Promise<() => void>;
package/src/loader.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"loader.js","sourceRoot":"","sources":["loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAIF,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,EAC5B,MAAmB,EACnB,WAAgC,EAChC,OAAoB,EACpB,OAAuB,EACJ,EAAE;IACrB,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,CAAC;IACjD,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAC/D,CAAC,CAAC","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 { OverlayOptions, TriggerInteractions } from './overlay-types';\n\nexport const openOverlay = async (\n target: HTMLElement,\n interaction: TriggerInteractions,\n content: HTMLElement,\n options: OverlayOptions\n): Promise<() => void> => {\n const { Overlay } = await import('./overlay.js');\n return Overlay.open(target, interaction, content, options);\n};\n"]}
1
+ {"version":3,"file":"loader.js","sourceRoot":"","sources":["loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAIF,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,EAC5B,MAAmB,EACnB,WAAgC,EAChC,OAAoB,EACpB,OAAuB,EACJ,EAAE;IACrB,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,CAAC;IACjD,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAC/D,CAAC,CAAC","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport type { OverlayOptions, TriggerInteractions } from './overlay-types';\n\nexport const openOverlay = async (\n target: HTMLElement,\n interaction: TriggerInteractions,\n content: HTMLElement,\n options: OverlayOptions\n): Promise<() => void> => {\n const { Overlay } = await import('./overlay.js');\n return Overlay.open(target, interaction, content, options);\n};\n"]}
@@ -1,5 +1,5 @@
1
1
  import { ActiveOverlay } from './ActiveOverlay.js';
2
- import { OverlayOpenDetail } from './overlay-types';
2
+ import type { OverlayOpenDetail } from './overlay-types';
3
3
  import '../active-overlay.js';
4
4
  export declare class OverlayStack {
5
5
  overlays: ActiveOverlay[];
@@ -82,7 +82,7 @@ export class OverlayStack {
82
82
  if (this.preventMouseRootClose || event.defaultPrevented) {
83
83
  return;
84
84
  }
85
- this.closeTopOverlay();
85
+ this.closeTopOverlay(true);
86
86
  };
87
87
  this.handleKeyUp = (event) => {
88
88
  if (event.code === 'Escape') {
@@ -286,9 +286,12 @@ export class OverlayStack {
286
286
  });
287
287
  }
288
288
  addOverlayEventListeners(activeOverlay) {
289
- activeOverlay.addEventListener('close', () => {
290
- this.hideAndCloseOverlay(activeOverlay);
291
- });
289
+ activeOverlay.addEventListener('close', ((event) => {
290
+ var _a;
291
+ this.hideAndCloseOverlay(activeOverlay, true, // animated?
292
+ !!((_a = event.detail) === null || _a === void 0 ? void 0 : _a.reason) // clickAway?
293
+ );
294
+ }));
292
295
  switch (activeOverlay.interaction) {
293
296
  case 'replace':
294
297
  this.addReplaceOverlayEventListeners(activeOverlay);
@@ -367,11 +370,12 @@ export class OverlayStack {
367
370
  manageFocusAfterCloseWhenLastOverlay(overlay) {
368
371
  this.stopTabTrapping();
369
372
  const isModal = overlay.interaction === 'modal';
373
+ const isReceivesFocus = overlay.receivesFocus === 'auto';
370
374
  const isReplace = overlay.interaction === 'replace';
371
375
  const isInline = overlay.interaction === 'inline';
372
376
  const isTabbingAwayFromInlineOrReplace = (isReplace || isInline) && !overlay.tabbingAway;
373
377
  overlay.tabbingAway = false;
374
- if (!isModal && !isTabbingAwayFromInlineOrReplace) {
378
+ if (!isModal && !isReceivesFocus && !isTabbingAwayFromInlineOrReplace) {
375
379
  return;
376
380
  }
377
381
  // Manage post closure focus when needed.
@@ -395,7 +399,7 @@ export class OverlayStack {
395
399
  overlay.trigger.focus();
396
400
  }
397
401
  }
398
- async hideAndCloseOverlay(overlay, animated) {
402
+ async hideAndCloseOverlay(overlay, animated, clickAway) {
399
403
  if (!overlay) {
400
404
  return;
401
405
  }
@@ -434,11 +438,12 @@ export class OverlayStack {
434
438
  cancelable: true,
435
439
  detail: {
436
440
  interaction: overlay.interaction,
441
+ reason: clickAway ? 'external-click' : undefined,
437
442
  },
438
443
  }));
439
444
  }
440
- closeTopOverlay() {
441
- return this.hideAndCloseOverlay(this.topOverlay);
445
+ closeTopOverlay(clickAway) {
446
+ return this.hideAndCloseOverlay(this.topOverlay, true, clickAway);
442
447
  }
443
448
  }
444
449
  //# sourceMappingURL=overlay-stack.js.map