@spectrum-web-components/overlay 0.12.1 → 0.13.2

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.
@@ -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",
@@ -485,7 +491,7 @@
485
491
  },
486
492
  {
487
493
  "kind": "method",
488
- "name": "_getUpdateComplete",
494
+ "name": "getUpdateComplete",
489
495
  "privacy": "protected",
490
496
  "return": {
491
497
  "type": {
@@ -952,7 +958,7 @@
952
958
  },
953
959
  {
954
960
  "kind": "method",
955
- "name": "_getUpdateComplete",
961
+ "name": "getUpdateComplete",
956
962
  "privacy": "protected",
957
963
  "return": {
958
964
  "type": {
@@ -1113,7 +1119,7 @@
1113
1119
  {
1114
1120
  "kind": "variable",
1115
1121
  "name": "styles",
1116
- "default": "css`\n@keyframes sp-overlay-fade-in{0%{opacity:0;transform:var(--sp-overlay-from)}to{opacity:100%;transform:translate(0)}}@keyframes sp-overlay-fade-out{0%{opacity:100%;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}#contents,sp-theme{height:100%}#contents{animation-duration:var(--spectrum-global-animation-duration-200,.16s);animation-timing-function:var(\n--spectrum-global-animation-ease-out,ease-out\n);display:inline-block;opacity:100%;pointer-events:none;visibility:visible}:host([data-popper-placement*=top]) #contents{--sp-overlay-from:translateY(var(--spectrum-global-dimension-size-75))}:host([data-popper-placement*=right]) #contents{--sp-overlay-from:translateX(calc(-1*var(--spectrum-global-dimension-size-75)))}:host([data-popper-placement*=bottom]) #contents{--sp-overlay-from:translateY(calc(-1*var(--spectrum-global-dimension-size-75)))}:host([data-popper-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`"
1122
+ "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}#contents,sp-theme{height:100%}#contents{animation-duration:var(--spectrum-global-animation-duration-200,.16s);animation-timing-function:var(\n--spectrum-global-animation-ease-out,ease-out\n);display:inline-block;opacity:1;pointer-events:none;visibility:visible}:host([data-popper-placement*=top]) #contents{--sp-overlay-from:translateY(var(--spectrum-global-dimension-size-75))}:host([data-popper-placement*=right]) #contents{--sp-overlay-from:translateX(calc(-1*var(--spectrum-global-dimension-size-75)))}:host([data-popper-placement*=bottom]) #contents{--sp-overlay-from:translateY(calc(-1*var(--spectrum-global-dimension-size-75)))}:host([data-popper-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`"
1117
1123
  }
1118
1124
  ],
1119
1125
  "exports": [
@@ -1360,6 +1366,25 @@
1360
1366
  }
1361
1367
  }
1362
1368
  },
1369
+ {
1370
+ "kind": "field",
1371
+ "name": "_bodyMarginsApplied",
1372
+ "type": {
1373
+ "text": "boolean"
1374
+ },
1375
+ "privacy": "private",
1376
+ "default": "false"
1377
+ },
1378
+ {
1379
+ "kind": "method",
1380
+ "name": "applyBodyMargins",
1381
+ "privacy": "private",
1382
+ "return": {
1383
+ "type": {
1384
+ "text": "void"
1385
+ }
1386
+ }
1387
+ },
1363
1388
  {
1364
1389
  "kind": "method",
1365
1390
  "name": "startTabTrapping",
@@ -1809,7 +1834,7 @@
1809
1834
  {
1810
1835
  "kind": "variable",
1811
1836
  "name": "styles",
1812
- "default": "css`\n#trigger{display:contents}:host([disabled]) #trigger{pointer-events:none}#overlay-content{display:none}\n`"
1837
+ "default": "css`\n:host([disabled]) ::slotted([slot=trigger]){pointer-events:none}#overlay-content{display:none}\n`"
1813
1838
  }
1814
1839
  ],
1815
1840
  "exports": [
@@ -2054,12 +2079,6 @@
2054
2079
  }
2055
2080
  }
2056
2081
  ]
2057
- },
2058
- {
2059
- "kind": "javascript-module",
2060
- "path": "sync/overlay-trigger.ts",
2061
- "declarations": [],
2062
- "exports": []
2063
2082
  }
2064
2083
  ]
2065
2084
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/overlay",
3
- "version": "0.12.1",
3
+ "version": "0.13.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -48,11 +48,11 @@
48
48
  "lit-html"
49
49
  ],
50
50
  "dependencies": {
51
- "@popperjs/core": "^2.10.2",
52
- "@spectrum-web-components/action-button": "^0.6.1",
53
- "@spectrum-web-components/base": "^0.4.6",
54
- "@spectrum-web-components/shared": "^0.12.11",
55
- "@spectrum-web-components/theme": "^0.8.16",
51
+ "@popperjs/core": "^2.11.0",
52
+ "@spectrum-web-components/action-button": "^0.7.2",
53
+ "@spectrum-web-components/base": "^0.5.1",
54
+ "@spectrum-web-components/shared": "^0.13.2",
55
+ "@spectrum-web-components/theme": "^0.9.2",
56
56
  "popper-max-size-modifier": "^0.2.0",
57
57
  "tslib": "^2.0.0"
58
58
  },
@@ -64,5 +64,5 @@
64
64
  "./sync/overlay-trigger.js",
65
65
  "./stories/overlay-story-components.js"
66
66
  ],
67
- "gitHead": "9c7ac25264762a9b7bad2ef3f111d5eb613f9d05"
67
+ "gitHead": "5ad16bd185710525afa48bd76099cb0ebde4c4cb"
68
68
  }
@@ -10,13 +10,6 @@ export interface PositionResult {
10
10
  positionLeft: number;
11
11
  positionTop: number;
12
12
  }
13
- declare global {
14
- interface Document {
15
- fonts?: {
16
- ready: Promise<void>;
17
- };
18
- }
19
- }
20
13
  declare type OverlayStateType = 'idle' | 'active' | 'visible' | 'hiding' | 'dispose' | 'disposed';
21
14
  declare type ContentAnimation = 'sp-overlay-fade-in' | 'sp-overlay-fade-out';
22
15
  /**
@@ -83,6 +76,6 @@ export declare class ActiveOverlay extends SpectrumElement {
83
76
  static create(details: OverlayOpenDetail): ActiveOverlay;
84
77
  private stealOverlayContentPromise;
85
78
  private stealOverlayContentResolver;
86
- protected _getUpdateComplete(): Promise<boolean>;
79
+ protected getUpdateComplete(): Promise<boolean>;
87
80
  }
88
81
  export {};
@@ -10,7 +10,9 @@ OF ANY KIND, either express or implied. See the License for the specific languag
10
10
  governing permissions and limitations under the License.
11
11
  */
12
12
  import { __decorate } from "tslib";
13
- import { html, ifDefined, property, SpectrumElement, } from '@spectrum-web-components/base';
13
+ import { html, SpectrumElement, } from '@spectrum-web-components/base';
14
+ import { ifDefined } from '@spectrum-web-components/base/src/directives.js';
15
+ import { property } from '@spectrum-web-components/base/src/decorators.js';
14
16
  import { reparentChildren } from '@spectrum-web-components/shared';
15
17
  import { firstFocusableIn } from '@spectrum-web-components/shared/src/first-focusable-in.js';
16
18
  import styles from './active-overlay.css.js';
@@ -372,8 +374,8 @@ export class ActiveOverlay extends SpectrumElement {
372
374
  }
373
375
  return overlay;
374
376
  }
375
- async _getUpdateComplete() {
376
- const complete = (await super._getUpdateComplete());
377
+ async getUpdateComplete() {
378
+ const complete = (await super.getUpdateComplete());
377
379
  await this.stealOverlayContentPromise;
378
380
  return complete;
379
381
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ActiveOverlay.js","sourceRoot":"","sources":["ActiveOverlay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;;AAEF,OAAO,EAEH,IAAI,EACJ,SAAS,EACT,QAAQ,EAER,eAAe,GAElB,MAAM,+BAA+B,CAAC;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,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAC/D,CAAC;IAEM,MAAM,CAAC,MAAM,CAAC,OAA0B;QAC3C,MAAM,OAAO,GAAG,IAAI,aAAa,EAAE,CAAC;QAEpC,IAAI,OAAO,CAAC,OAAO,EAAE;YACjB,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SACzB;QAED,OAAO,OAAO,CAAC;IACnB,CAAC;IAKS,KAAK,CAAC,kBAAkB;QAC9B,MAAM,QAAQ,GAAG,CAAC,MAAM,KAAK,CAAC,kBAAkB,EAAE,CAAY,CAAC;QAC/D,MAAM,IAAI,CAAC,0BAA0B,CAAC;QACtC,OAAO,QAAQ,CAAC;IACpB,CAAC;CACJ;AA3YG;IADC,QAAQ,EAAE;6CACuB;AAsBlC;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;AAY9B;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC;0DACV","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 ifDefined,\n property,\n PropertyValues,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { reparentChildren } from '@spectrum-web-components/shared';\nimport { firstFocusableIn } from '@spectrum-web-components/shared/src/first-focusable-in.js';\nimport { Color, Scale } from '@spectrum-web-components/theme';\nimport styles from './active-overlay.css.js';\nimport {\n OverlayOpenDetail,\n Placement,\n TriggerInteractions,\n OverlayOpenCloseDetail,\n} from './overlay-types.js';\nimport { applyMaxSize, createPopper, Instance, maxSize } from './popper.js';\nimport { VirtualTrigger } from './VirtualTrigger.js';\n\nexport interface PositionResult {\n arrowOffsetLeft: number;\n arrowOffsetTop: number;\n maxHeight: number;\n placement: string;\n positionLeft: number;\n positionTop: number;\n}\n\ndeclare global {\n interface Document {\n fonts?: {\n ready: Promise<void>;\n };\n }\n}\n\ntype OverlayStateType =\n | 'idle'\n | 'active'\n | 'visible'\n | 'hiding'\n | 'dispose'\n | '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 visible: 'visible',\n hiding: 'hiding',\n idle: 'idle',\n },\n },\n visible: {\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 private popper?: Instance;\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 (\n this.state === 'active' ||\n this.state === 'visible' ||\n this.state === 'hiding'\n ) {\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 /**\n * @prop Used by the popper library to indicate where the overlay was\n * actually rendered. Popper may switch which side an overlay\n * is rendered on to fit it on the screen\n */\n @property({ attribute: 'data-popper-placement' })\n public dataPopperPlacement?: Placement;\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 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 // 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 firstUpdated(changedProperties: PropertyValues): void {\n super.firstUpdated(changedProperties);\n\n /* c8 ignore next */\n if (!this.overlayContent) return;\n\n this.stealOverlayContent(this.overlayContent);\n\n /* c8 ignore next */\n if (!this.overlayContent || !this.trigger) return;\n\n if (this.placement && this.placement !== 'none') {\n this.popper = createPopper(\n this.virtualTrigger || this.trigger,\n this,\n {\n placement: this.placement,\n modifiers: [\n maxSize,\n applyMaxSize,\n {\n name: 'arrow',\n options: {\n element: this.overlayContentTip,\n },\n },\n {\n name: 'offset',\n options: {\n offset: [0, this.offset],\n },\n },\n ],\n }\n );\n }\n\n this.state = 'active';\n\n document.addEventListener('sp-update-overlays', () => {\n this.updateOverlayPosition();\n this.state = 'visible';\n });\n\n this.feature();\n this.updateOverlayPosition()\n .then(() => this.applyContentAnimation('sp-overlay-fade-in'))\n .then(() => {\n if (this.receivesFocus) {\n this.focus();\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\n private updateOverlayPopperPlacement(): void {\n /* c8 ignore next */\n const activeWithContent =\n this.state === 'active' && this.overlayContent;\n if (!activeWithContent) return;\n\n if (this.dataPopperPlacement) {\n // Copy this attribute to the actual overlay node so that it can use\n // the attribute for styling shadow DOM elements based on the side\n // that popper has chosen for it\n this.overlayContent.setAttribute(\n 'placement',\n this.dataPopperPlacement\n );\n } else if (this.originalPlacement) {\n this.overlayContent.setAttribute(\n 'placement',\n this.originalPlacement\n );\n } else {\n this.overlayContent.removeAttribute('placement');\n }\n }\n\n public updated(changedProperties: PropertyValues): void {\n if (changedProperties.has('dataPopperPlacement')) {\n this.updateOverlayPopperPlacement();\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 if (this.popper) {\n this.popper.destroy();\n this.popper = undefined;\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(element: HTMLElement): void {\n this.originalPlacement = element.getAttribute('placement') as Placement;\n this.restoreContent = reparentChildren([element], this, (el) => {\n const slotName = el.slot;\n el.removeAttribute('slot');\n return (el) => {\n el.slot = slotName;\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 public async updateOverlayPosition(): Promise<void> {\n await (document.fonts ? document.fonts.ready : Promise.resolve());\n if (this.popper) {\n await this.popper.update();\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 connectedCallback(): void {\n super.connectedCallback();\n this.schedulePositionUpdate();\n }\n\n public applyContentAnimation(\n animation: ContentAnimation\n ): Promise<boolean> {\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 complete = (await super._getUpdateComplete()) as boolean;\n await this.stealOverlayContentPromise;\n return complete;\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,iCAAiC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2DAA2D,CAAC;AAE7F,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAO7C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAY,OAAO,EAAE,MAAM,aAAa,CAAC;AAqB5E,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,OAAO,EAAE,SAAS;gBAClB,MAAM,EAAE,QAAQ;gBAChB,IAAI,EAAE,MAAM;aACf;SACJ;QACD,OAAO,EAAE;YACL,EAAE,EAAE;gBACA,MA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AE;6CACuB;AAsBlC;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;AAY9B;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC;0DACV","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';\nimport { firstFocusableIn } from '@spectrum-web-components/shared/src/first-focusable-in.js';\nimport { Color, 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 { applyMaxSize, createPopper, Instance, maxSize } from './popper.js';\nimport { VirtualTrigger } from './VirtualTrigger.js';\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 =\n | 'idle'\n | 'active'\n | 'visible'\n | 'hiding'\n | 'dispose'\n | '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 visible: 'visible',\n hiding: 'hiding',\n idle: 'idle',\n },\n },\n visible: {\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 private popper?: Instance;\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 (\n this.state === 'active' ||\n this.state === 'visible' ||\n this.state === 'hiding'\n ) {\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 /**\n * @prop Used by the popper library to indicate where the overlay was\n * actually rendered. Popper may switch which side an overlay\n * is rendered on to fit it on the screen\n */\n @property({ attribute: 'data-popper-placement' })\n public dataPopperPlacement?: Placement;\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 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 // 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 firstUpdated(changedProperties: PropertyValues): void {\n super.firstUpdated(changedProperties);\n\n /* c8 ignore next */\n if (!this.overlayContent) return;\n\n this.stealOverlayContent(this.overlayContent);\n\n /* c8 ignore next */\n if (!this.overlayContent || !this.trigger) return;\n\n if (this.placement && this.placement !== 'none') {\n this.popper = createPopper(\n this.virtualTrigger || this.trigger,\n this,\n {\n placement: this.placement,\n modifiers: [\n maxSize,\n applyMaxSize,\n {\n name: 'arrow',\n options: {\n element: this.overlayContentTip,\n },\n },\n {\n name: 'offset',\n options: {\n offset: [0, this.offset],\n },\n },\n ],\n }\n );\n }\n\n this.state = 'active';\n\n document.addEventListener('sp-update-overlays', () => {\n this.updateOverlayPosition();\n this.state = 'visible';\n });\n\n this.feature();\n this.updateOverlayPosition()\n .then(() => this.applyContentAnimation('sp-overlay-fade-in'))\n .then(() => {\n if (this.receivesFocus) {\n this.focus();\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\n private updateOverlayPopperPlacement(): void {\n /* c8 ignore next */\n const activeWithContent =\n this.state === 'active' && this.overlayContent;\n if (!activeWithContent) return;\n\n if (this.dataPopperPlacement) {\n // Copy this attribute to the actual overlay node so that it can use\n // the attribute for styling shadow DOM elements based on the side\n // that popper has chosen for it\n this.overlayContent.setAttribute(\n 'placement',\n this.dataPopperPlacement\n );\n } else if (this.originalPlacement) {\n this.overlayContent.setAttribute(\n 'placement',\n this.originalPlacement\n );\n } else {\n this.overlayContent.removeAttribute('placement');\n }\n }\n\n public updated(changedProperties: PropertyValues): void {\n if (changedProperties.has('dataPopperPlacement')) {\n this.updateOverlayPopperPlacement();\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 if (this.popper) {\n this.popper.destroy();\n this.popper = undefined;\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(element: HTMLElement): void {\n this.originalPlacement = element.getAttribute('placement') as Placement;\n this.restoreContent = reparentChildren([element], this, (el) => {\n const slotName = el.slot;\n el.removeAttribute('slot');\n return (el) => {\n el.slot = slotName;\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 public async updateOverlayPosition(): Promise<void> {\n await (document.fonts ? document.fonts.ready : Promise.resolve());\n if (this.popper) {\n await this.popper.update();\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 connectedCallback(): void {\n super.connectedCallback();\n this.schedulePositionUpdate();\n }\n\n public applyContentAnimation(\n animation: ContentAnimation\n ): Promise<boolean> {\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 complete = (await super.getUpdateComplete()) as boolean;\n await this.stealOverlayContentPromise;\n return complete;\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { LitElement, CSSResultArray, TemplateResult, PropertyValues } from '@spectrum-web-components/base';
2
- import { Placement, TriggerInteractions, OverlayOptions } from './overlay-types';
1
+ import { CSSResultArray, LitElement, PropertyValues, TemplateResult } from '@spectrum-web-components/base';
2
+ import { OverlayOptions, Placement, TriggerInteractions } from './overlay-types';
3
3
  export declare type OverlayContentTypes = 'click' | 'hover' | 'longpress';
4
4
  /**
5
5
  * @element overlay-trigger
@@ -52,6 +52,6 @@ export declare class OverlayTrigger extends LitElement {
52
52
  private extractSlotContentFromEvent;
53
53
  private openStatePromise;
54
54
  private openStateResolver;
55
- protected _getUpdateComplete(): Promise<boolean>;
55
+ protected getUpdateComplete(): Promise<boolean>;
56
56
  disconnectedCallback(): void;
57
57
  }
@@ -9,8 +9,10 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
9
9
  OF ANY KIND, either express or implied. See the License for the specific language
10
10
  governing permissions and limitations under the License.
11
11
  */
12
+ var _a;
12
13
  import { __decorate } from "tslib";
13
- import { html, LitElement, property, } from '@spectrum-web-components/base';
14
+ import { html, LitElement, } from '@spectrum-web-components/base';
15
+ import { property } from '@spectrum-web-components/base/src/decorators.js';
14
16
  import { firstFocusableIn } from '@spectrum-web-components/shared/src/first-focusable-in.js';
15
17
  import { openOverlay } from './loader.js';
16
18
  import overlayTriggerStyles from './overlay-trigger.css.js';
@@ -55,7 +57,7 @@ export class OverlayTrigger extends LitElement {
55
57
  // Keyboard event availability documented in README.md
56
58
  /* eslint-disable lit-a11y/click-events-have-key-events */
57
59
  return html `
58
- <div
60
+ <slot
59
61
  id="trigger"
60
62
  @click=${this.onTrigger}
61
63
  @longpress=${this.onTrigger}
@@ -64,12 +66,9 @@ export class OverlayTrigger extends LitElement {
64
66
  @focusin=${this.onTrigger}
65
67
  @focusout=${this.onTrigger}
66
68
  @sp-closed=${this.handleClose}
67
- >
68
- <slot
69
- @slotchange=${this.onTargetSlotChange}
70
- name="trigger"
71
- ></slot>
72
- </div>
69
+ @slotchange=${this.onTargetSlotChange}
70
+ name="trigger"
71
+ ></slot>
73
72
  <div id="overlay-content">
74
73
  <slot
75
74
  @slotchange=${this.onClickSlotChange}
@@ -113,14 +112,14 @@ export class OverlayTrigger extends LitElement {
113
112
  });
114
113
  }
115
114
  manageOpen() {
116
- var _a;
115
+ var _b;
117
116
  const openHandlers = {
118
117
  click: () => this.onTriggerClick(),
119
118
  hover: () => this.onTriggerMouseEnter(),
120
119
  longpress: () => this.onTriggerLongpress(),
121
120
  none: () => this.closeAllOverlays(),
122
121
  };
123
- openHandlers[(_a = this.open) !== null && _a !== void 0 ? _a : 'none']();
122
+ openHandlers[(_b = this.open) !== null && _b !== void 0 ? _b : 'none']();
124
123
  }
125
124
  async openOverlay(target, interaction, content, options) {
126
125
  this.openStatePromise = new Promise((res) => (this.openStateResolver = res));
@@ -189,7 +188,7 @@ export class OverlayTrigger extends LitElement {
189
188
  this.closeClickOverlay = this.openOverlay(targetContent, this.type ? this.type : 'click', clickContent, this.overlayOptions);
190
189
  }
191
190
  async onTriggerLongpress() {
192
- var _a, _b;
191
+ var _b, _c;
193
192
  if (!this.targetContent ||
194
193
  !this.longpressContent ||
195
194
  this.closeLongpressOverlay) {
@@ -198,7 +197,7 @@ export class OverlayTrigger extends LitElement {
198
197
  const { targetContent, longpressContent } = this;
199
198
  this.closeAllOverlays();
200
199
  this.prepareToFocusOverlayContent(longpressContent);
201
- const notImmediatelyClosable = ((_b = (_a = this._longpressEvent) === null || _a === void 0 ? void 0 : _a.detail) === null || _b === void 0 ? void 0 : _b.source) !== 'keyboard';
200
+ const notImmediatelyClosable = ((_c = (_b = this._longpressEvent) === null || _b === void 0 ? void 0 : _b.detail) === null || _c === void 0 ? void 0 : _c.source) !== 'keyboard';
202
201
  this.closeLongpressOverlay = this.openOverlay(targetContent, this.type ? this.type : 'longpress', longpressContent, Object.assign(Object.assign({}, this.overlayOptions), { receivesFocus: 'auto', notImmediatelyClosable }));
203
202
  this._longpressEvent = undefined;
204
203
  }
@@ -234,8 +233,8 @@ export class OverlayTrigger extends LitElement {
234
233
  const nodes = slot.assignedNodes({ flatten: true });
235
234
  return nodes.find((node) => node instanceof HTMLElement);
236
235
  }
237
- async _getUpdateComplete() {
238
- const complete = (await super._getUpdateComplete());
236
+ async getUpdateComplete() {
237
+ const complete = (await super.getUpdateComplete());
239
238
  await this.openStatePromise;
240
239
  return complete;
241
240
  }
@@ -244,6 +243,7 @@ export class OverlayTrigger extends LitElement {
244
243
  super.disconnectedCallback();
245
244
  }
246
245
  }
246
+ _a = OverlayTrigger;
247
247
  OverlayTrigger.openOverlay = async (target, interaction, content, options) => {
248
248
  return openOverlay(target, interaction, content, options);
249
249
  };
@@ -1 +1 @@
1
- {"version":3,"file":"OverlayTrigger.js","sourceRoot":"","sources":["OverlayTrigger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;;AAEF,OAAO,EACH,IAAI,EACJ,UAAU,EACV,QAAQ,GAIX,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,2DAA2D,CAAC;AAQ7F,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,oBAAoB,MAAM,0BAA0B,CAAC;AAS5D;;;;;;;;;;GAUG;AACH,MAAM,OAAO,cAAe,SAAQ,UAAU;IAA9C;;QASI;;;WAGG;QAEI,cAAS,GAAc,QAAQ,CAAC;QAMhC,WAAM,GAAG,CAAC,CAAC;QAMX,aAAQ,GAAG,KAAK,CAAC;QA+NhB,iBAAY,GAAiC,GAAG,EAAE;YACtD,OAAO;QACX,CAAC,CAAC;QA0DM,qBAAgB,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAajD,CAAC;IA7TU,MAAM,KAAK,MAAM;QACpB,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAClC,CAAC;IA0BO,WAAW,CAAC,KAA2C;QAC3D,IACI,KAAK;YACL,KAAK,CAAC,MAAM,CAAC,WAAW,KAAK,IAAI,CAAC,IAAI;YACtC,KAAK,CAAC,MAAM,CAAC,W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EAAE,CAAC;QACxB,KAAK,CAAC,oBAAoB,EAAE,CAAC;IACjC,CAAC;;AAnLa,0BAAW,GAAG,KAAK,EAC7B,MAAmB,EACnB,WAAgC,EAChC,OAAoB,EACpB,OAAuB,EACJ,EAAE;IACrB,OAAO,WAAW,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAC9D,CAAC,CAAC;AAvIF;IADC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;iDACW;AAGvC;IADC,QAAQ,EAAE;4CACgE;AAG3E;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8CACxB;AAGlB;IADC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;4CACM;AAGlC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gDACnB","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 html,\n LitElement,\n property,\n CSSResultArray,\n TemplateResult,\n PropertyValues,\n} from '@spectrum-web-components/base';\nimport type { LongpressEvent } from '@spectrum-web-components/action-button';\nimport { firstFocusableIn } from '@spectrum-web-components/shared/src/first-focusable-in.js';\n\nimport {\n Placement,\n TriggerInteractions,\n OverlayOptions,\n OverlayOpenCloseDetail,\n} from './overlay-types';\nimport { openOverlay } from './loader.js';\nimport overlayTriggerStyles from './overlay-trigger.css.js';\n\nexport type OverlayContentTypes = 'click' | 'hover' | 'longpress';\n\ntype closeOverlay =\n | 'closeClickOverlay'\n | 'closeHoverOverlay'\n | 'closeLongpressOverlay';\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 LitElement {\n private closeClickOverlay?: Promise<() => void>;\n private closeLongpressOverlay?: Promise<() => void>;\n private closeHoverOverlay?: Promise<() => void>;\n\n public static get styles(): CSSResultArray {\n return [overlayTriggerStyles];\n }\n\n /**\n * @type {\"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\"}\n * @attr\n */\n @property({ reflect: true })\n public placement: Placement = 'bottom';\n\n @property()\n public type?: Extract<TriggerInteractions, 'inline' | 'modal' | 'replace'>;\n\n @property({ type: Number, reflect: true })\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 private clickContent?: HTMLElement;\n private longpressContent?: HTMLElement;\n private hoverContent?: HTMLElement;\n private targetContent?: HTMLElement;\n\n private handleClose(event?: CustomEvent<OverlayOpenCloseDetail>): void {\n if (\n event &&\n event.detail.interaction !== this.open &&\n event.detail.interaction !== this.type\n ) {\n return;\n }\n this.removeAttribute('open');\n }\n\n protected render(): TemplateResult {\n // Keyboard event availability documented in README.md\n /* eslint-disable lit-a11y/click-events-have-key-events */\n return html`\n <div\n id=\"trigger\"\n @click=${this.onTrigger}\n @longpress=${this.onTrigger}\n @mouseenter=${this.onTrigger}\n @mouseleave=${this.onTrigger}\n @focusin=${this.onTrigger}\n @focusout=${this.onTrigger}\n @sp-closed=${this.handleClose}\n >\n <slot\n @slotchange=${this.onTargetSlotChange}\n name=\"trigger\"\n ></slot>\n </div>\n <div id=\"overlay-content\">\n <slot\n @slotchange=${this.onClickSlotChange}\n name=\"click-content\"\n ></slot>\n <slot\n @slotchange=${this.onLongpressSlotChange}\n name=\"longpress-content\"\n ></slot>\n <slot\n @slotchange=${this.onHoverSlotChange}\n name=\"hover-content\"\n ></slot>\n </div>\n `;\n /* eslint-enable lit-a11y/click-events-have-key-events */\n }\n\n protected updated(changes: PropertyValues): void {\n super.updated(changes);\n if (this.disabled && changes.has('disabled')) {\n this.closeAllOverlays();\n return;\n }\n if (changes.has('open')) {\n this.manageOpen();\n }\n }\n\n private closeAllOverlays(): void {\n if (this.abortOverlay) this.abortOverlay(true);\n (\n [\n 'closeClickOverlay',\n 'closeHoverOverlay',\n 'closeLongpressOverlay',\n ] as closeOverlay[]\n ).forEach(async (name) => {\n const canClose = this[name] as Promise<() => void>;\n if (canClose == null) return;\n delete this[name];\n (await canClose)();\n });\n }\n\n private manageOpen(): void {\n const openHandlers: Record<OverlayContentTypes | 'none', () => void> = {\n click: () => this.onTriggerClick(),\n hover: () => this.onTriggerMouseEnter(),\n longpress: () => this.onTriggerLongpress(),\n none: () => this.closeAllOverlays(),\n };\n openHandlers[this.open ?? 'none']();\n }\n\n private async openOverlay(\n target: HTMLElement,\n interaction: TriggerInteractions,\n content: HTMLElement,\n options: OverlayOptions\n ): Promise<() => void> {\n this.openStatePromise = new Promise(\n (res) => (this.openStateResolver = res)\n );\n this.addEventListener(\n 'sp-opened',\n () => {\n this.openStateResolver();\n },\n { once: true }\n );\n return OverlayTrigger.openOverlay(\n target,\n interaction,\n content,\n options\n );\n }\n\n public static openOverlay = async (\n target: HTMLElement,\n interaction: TriggerInteractions,\n content: HTMLElement,\n options: OverlayOptions\n ): Promise<() => void> => {\n return openOverlay(target, interaction, content, options);\n };\n\n private get overlayOptions(): OverlayOptions {\n return {\n offset: this.offset,\n placement: this.placement,\n receivesFocus:\n this.type && this.type !== 'inline' ? 'auto' : undefined,\n };\n }\n\n private onTrigger(event: CustomEvent<LongpressEvent>): void {\n if (this.disabled) return;\n\n switch (event.type) {\n case 'mouseenter':\n case 'focusin':\n if (!this.open && this.hoverContent) {\n this.open = 'hover';\n }\n return;\n case 'mouseleave':\n case 'focusout':\n if (this.open === 'hover') {\n this.handleClose();\n }\n return;\n case 'click':\n if (this.clickContent) {\n this.open = event.type;\n } else if (this.closeHoverOverlay) {\n event.preventDefault();\n }\n return;\n case 'longpress':\n if (this.longpressContent) {\n this._longpressEvent = event;\n this.open = event.type;\n }\n return;\n }\n }\n\n private prepareToFocusOverlayContent(overlayContent: HTMLElement): void {\n if (this.type !== 'modal') {\n return;\n }\n const firstFocusable = firstFocusableIn(overlayContent);\n if (!firstFocusable) {\n overlayContent.tabIndex = 0;\n }\n }\n\n public async onTriggerClick(): Promise<void> {\n if (\n !this.targetContent ||\n !this.clickContent ||\n this.closeClickOverlay\n ) {\n return;\n }\n const { targetContent, clickContent } = this;\n this.closeAllOverlays();\n this.prepareToFocusOverlayContent(clickContent);\n this.closeClickOverlay = this.openOverlay(\n targetContent,\n this.type ? this.type : 'click',\n clickContent,\n this.overlayOptions\n );\n }\n\n private _longpressEvent?: CustomEvent<LongpressEvent>;\n\n private async onTriggerLongpress(): Promise<void> {\n if (\n !this.targetContent ||\n !this.longpressContent ||\n this.closeLongpressOverlay\n ) {\n return;\n }\n const { targetContent, longpressContent } = this;\n this.closeAllOverlays();\n this.prepareToFocusOverlayContent(longpressContent);\n const notImmediatelyClosable =\n this._longpressEvent?.detail?.source !== 'keyboard';\n this.closeLongpressOverlay = this.openOverlay(\n targetContent,\n this.type ? this.type : 'longpress',\n longpressContent,\n {\n ...this.overlayOptions,\n receivesFocus: 'auto',\n notImmediatelyClosable,\n }\n );\n this._longpressEvent = undefined;\n }\n\n private abortOverlay: (cancelled: boolean) => void = () => {\n return;\n };\n\n public async onTriggerMouseEnter(): Promise<void> {\n if (\n !this.targetContent ||\n !this.hoverContent ||\n this.closeHoverOverlay\n ) {\n return;\n }\n const abortPromise: Promise<boolean> = new Promise((res) => {\n this.abortOverlay = res;\n });\n const { targetContent, hoverContent } = this;\n this.closeHoverOverlay = this.openOverlay(\n targetContent,\n 'hover',\n hoverContent,\n {\n abortPromise,\n ...this.overlayOptions,\n }\n );\n }\n\n private onClickSlotChange(\n event: Event & { target: HTMLSlotElement }\n ): void {\n this.clickContent = this.extractSlotContentFromEvent(event);\n this.manageOpen();\n }\n\n private onLongpressSlotChange(\n event: Event & { target: HTMLSlotElement }\n ): void {\n this.longpressContent = this.extractSlotContentFromEvent(event);\n this.manageOpen();\n }\n\n private onHoverSlotChange(\n event: Event & { target: HTMLSlotElement }\n ): void {\n this.hoverContent = this.extractSlotContentFromEvent(event);\n this.manageOpen();\n }\n\n private onTargetSlotChange(\n event: Event & { target: HTMLSlotElement }\n ): void {\n this.targetContent = this.extractSlotContentFromEvent(event);\n }\n\n private extractSlotContentFromEvent(event: Event): HTMLElement | undefined {\n const slot = event.target as HTMLSlotElement;\n const nodes = slot.assignedNodes({ flatten: true });\n return nodes.find((node) => node instanceof HTMLElement) as HTMLElement;\n }\n\n private openStatePromise = Promise.resolve();\n private openStateResolver!: () => void;\n\n protected async _getUpdateComplete(): Promise<boolean> {\n const complete = (await super._getUpdateComplete()) as boolean;\n await this.openStatePromise;\n return complete;\n }\n\n public disconnectedCallback(): void {\n this.closeAllOverlays();\n super.disconnectedCallback();\n }\n}\n"]}
1
+ {"version":3,"file":"OverlayTrigger.js","sourceRoot":"","sources":["OverlayTrigger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;;;AAEF,OAAO,EAEH,IAAI,EACJ,UAAU,GAGb,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,iDAAiD,CAAC;AAE3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,2DAA2D,CAAC;AAQ7F,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,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AA2B,CAAC,KAAK,CAAC,CAAC;IACjE,CAAC;IAEO,2BAA2B,CAAC,KAAY;QAC5C,MAAM,IAAI,GAAG,KAAK,CAAC,MAAyB,CAAC;QAC7C,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QACpD,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,YAAY,WAAW,CAAgB,CAAC;IAC5E,CAAC;IAKS,KAAK,CAAC,iBAAiB;QAC7B,MAAM,QAAQ,GAAG,CAAC,MAAM,KAAK,CAAC,iBAAiB,EAAE,CAAY,CAAC;QAC9D,MAAM,IAAI,CAAC,gBAAgB,CAAC;QAC5B,OAAO,QAAQ,CAAC;IACpB,CAAC;IAEM,oBAAoB;QACvB,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,KAAK,CAAC,oBAAoB,EAAE,CAAC;IACjC,CAAC;;;AAnLa,0BAAW,GAAG,KAAK,EAC7B,MAAmB,EACnB,WAAgC,EAChC,OAAoB,EACpB,OAAuB,EACJ,EAAE;IACrB,OAAO,WAAW,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAC9D,CAAE,CAAA;AApIF;IADC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;iDACW;AAGvC;IADC,QAAQ,EAAE;4CACgE;AAG3E;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8CACxB;AAGlB;IADC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;4CACM;AAGlC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gDACnB","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 LitElement,\n PropertyValues,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport type { LongpressEvent } from '@spectrum-web-components/action-button';\nimport { firstFocusableIn } from '@spectrum-web-components/shared/src/first-focusable-in.js';\n\nimport {\n OverlayOpenCloseDetail,\n OverlayOptions,\n Placement,\n TriggerInteractions,\n} from './overlay-types';\nimport { openOverlay } from './loader.js';\nimport overlayTriggerStyles from './overlay-trigger.css.js';\n\nexport type OverlayContentTypes = 'click' | 'hover' | 'longpress';\n\ntype closeOverlay =\n | 'closeClickOverlay'\n | 'closeHoverOverlay'\n | 'closeLongpressOverlay';\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 LitElement {\n private closeClickOverlay?: Promise<() => void>;\n private closeLongpressOverlay?: Promise<() => void>;\n private closeHoverOverlay?: Promise<() => void>;\n\n public static get styles(): CSSResultArray {\n return [overlayTriggerStyles];\n }\n\n /**\n * @type {\"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\"}\n * @attr\n */\n @property({ reflect: true })\n public placement: Placement = 'bottom';\n\n @property()\n public type?: Extract<TriggerInteractions, 'inline' | 'modal' | 'replace'>;\n\n @property({ type: Number, reflect: true })\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 private clickContent?: HTMLElement;\n private longpressContent?: HTMLElement;\n private hoverContent?: HTMLElement;\n private targetContent?: HTMLElement;\n\n private handleClose(event?: CustomEvent<OverlayOpenCloseDetail>): void {\n if (\n event &&\n event.detail.interaction !== this.open &&\n event.detail.interaction !== this.type\n ) {\n return;\n }\n this.removeAttribute('open');\n }\n\n protected render(): TemplateResult {\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 @click=${this.onTrigger}\n @longpress=${this.onTrigger}\n @mouseenter=${this.onTrigger}\n @mouseleave=${this.onTrigger}\n @focusin=${this.onTrigger}\n @focusout=${this.onTrigger}\n @sp-closed=${this.handleClose}\n @slotchange=${this.onTargetSlotChange}\n name=\"trigger\"\n ></slot>\n <div id=\"overlay-content\">\n <slot\n @slotchange=${this.onClickSlotChange}\n name=\"click-content\"\n ></slot>\n <slot\n @slotchange=${this.onLongpressSlotChange}\n name=\"longpress-content\"\n ></slot>\n <slot\n @slotchange=${this.onHoverSlotChange}\n name=\"hover-content\"\n ></slot>\n </div>\n `;\n /* eslint-enable lit-a11y/click-events-have-key-events */\n }\n\n protected updated(changes: PropertyValues): void {\n super.updated(changes);\n if (this.disabled && changes.has('disabled')) {\n this.closeAllOverlays();\n return;\n }\n if (changes.has('open')) {\n this.manageOpen();\n }\n }\n\n private closeAllOverlays(): void {\n if (this.abortOverlay) this.abortOverlay(true);\n (\n [\n 'closeClickOverlay',\n 'closeHoverOverlay',\n 'closeLongpressOverlay',\n ] as closeOverlay[]\n ).forEach(async (name) => {\n const canClose = this[name] as Promise<() => void>;\n if (canClose == null) return;\n delete this[name];\n (await canClose)();\n });\n }\n\n private manageOpen(): void {\n const openHandlers: Record<OverlayContentTypes | 'none', () => void> = {\n click: () => this.onTriggerClick(),\n hover: () => this.onTriggerMouseEnter(),\n longpress: () => this.onTriggerLongpress(),\n none: () => this.closeAllOverlays(),\n };\n openHandlers[this.open ?? 'none']();\n }\n\n private async openOverlay(\n target: HTMLElement,\n interaction: TriggerInteractions,\n content: HTMLElement,\n options: OverlayOptions\n ): Promise<() => void> {\n this.openStatePromise = new Promise(\n (res) => (this.openStateResolver = res)\n );\n this.addEventListener(\n 'sp-opened',\n () => {\n this.openStateResolver();\n },\n { once: true }\n );\n return OverlayTrigger.openOverlay(\n target,\n interaction,\n content,\n options\n );\n }\n\n public static openOverlay = async (\n target: HTMLElement,\n interaction: TriggerInteractions,\n content: HTMLElement,\n options: OverlayOptions\n ): Promise<() => void> => {\n return openOverlay(target, interaction, content, options);\n };\n\n private get overlayOptions(): OverlayOptions {\n return {\n offset: this.offset,\n placement: this.placement,\n receivesFocus:\n this.type && this.type !== 'inline' ? 'auto' : undefined,\n };\n }\n\n private onTrigger(event: CustomEvent<LongpressEvent>): void {\n if (this.disabled) return;\n\n switch (event.type) {\n case 'mouseenter':\n case 'focusin':\n if (!this.open && this.hoverContent) {\n this.open = 'hover';\n }\n return;\n case 'mouseleave':\n case 'focusout':\n if (this.open === 'hover') {\n this.handleClose();\n }\n return;\n case 'click':\n if (this.clickContent) {\n this.open = event.type;\n } else if (this.closeHoverOverlay) {\n event.preventDefault();\n }\n return;\n case 'longpress':\n if (this.longpressContent) {\n this._longpressEvent = event;\n this.open = event.type;\n }\n return;\n }\n }\n\n private prepareToFocusOverlayContent(overlayContent: HTMLElement): void {\n if (this.type !== 'modal') {\n return;\n }\n const firstFocusable = firstFocusableIn(overlayContent);\n if (!firstFocusable) {\n overlayContent.tabIndex = 0;\n }\n }\n\n public async onTriggerClick(): Promise<void> {\n if (\n !this.targetContent ||\n !this.clickContent ||\n this.closeClickOverlay\n ) {\n return;\n }\n const { targetContent, clickContent } = this;\n this.closeAllOverlays();\n this.prepareToFocusOverlayContent(clickContent);\n this.closeClickOverlay = this.openOverlay(\n targetContent,\n this.type ? this.type : 'click',\n clickContent,\n this.overlayOptions\n );\n }\n\n private _longpressEvent?: CustomEvent<LongpressEvent>;\n\n private async onTriggerLongpress(): Promise<void> {\n if (\n !this.targetContent ||\n !this.longpressContent ||\n this.closeLongpressOverlay\n ) {\n return;\n }\n const { targetContent, longpressContent } = this;\n this.closeAllOverlays();\n this.prepareToFocusOverlayContent(longpressContent);\n const notImmediatelyClosable =\n this._longpressEvent?.detail?.source !== 'keyboard';\n this.closeLongpressOverlay = this.openOverlay(\n targetContent,\n this.type ? this.type : 'longpress',\n longpressContent,\n {\n ...this.overlayOptions,\n receivesFocus: 'auto',\n notImmediatelyClosable,\n }\n );\n this._longpressEvent = undefined;\n }\n\n private abortOverlay: (cancelled: boolean) => void = () => {\n return;\n };\n\n public async onTriggerMouseEnter(): Promise<void> {\n if (\n !this.targetContent ||\n !this.hoverContent ||\n this.closeHoverOverlay\n ) {\n return;\n }\n const abortPromise: Promise<boolean> = new Promise((res) => {\n this.abortOverlay = res;\n });\n const { targetContent, hoverContent } = this;\n this.closeHoverOverlay = this.openOverlay(\n targetContent,\n 'hover',\n hoverContent,\n {\n abortPromise,\n ...this.overlayOptions,\n }\n );\n }\n\n private onClickSlotChange(\n event: Event & { target: HTMLSlotElement }\n ): void {\n this.clickContent = this.extractSlotContentFromEvent(event);\n this.manageOpen();\n }\n\n private onLongpressSlotChange(\n event: Event & { target: HTMLSlotElement }\n ): void {\n this.longpressContent = this.extractSlotContentFromEvent(event);\n this.manageOpen();\n }\n\n private onHoverSlotChange(\n event: Event & { target: HTMLSlotElement }\n ): void {\n this.hoverContent = this.extractSlotContentFromEvent(event);\n this.manageOpen();\n }\n\n private onTargetSlotChange(\n event: Event & { target: HTMLSlotElement }\n ): void {\n this.targetContent = this.extractSlotContentFromEvent(event);\n }\n\n private extractSlotContentFromEvent(event: Event): HTMLElement | undefined {\n const slot = event.target as HTMLSlotElement;\n const nodes = slot.assignedNodes({ flatten: true });\n return nodes.find((node) => node instanceof HTMLElement) as HTMLElement;\n }\n\n private openStatePromise = Promise.resolve();\n private openStateResolver!: () => void;\n\n protected async getUpdateComplete(): Promise<boolean> {\n const complete = (await super.getUpdateComplete()) as boolean;\n await this.openStatePromise;\n return complete;\n }\n\n public disconnectedCallback(): void {\n this.closeAllOverlays();\n super.disconnectedCallback();\n }\n}\n"]}
@@ -11,9 +11,9 @@ 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:100%;transform:translate(0)}}@keyframes sp-overlay-fade-out{0%{opacity:100%;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}#contents,sp-theme{height:100%}#contents{animation-duration:var(--spectrum-global-animation-duration-200,.16s);animation-timing-function: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:0;pointer-events:none;position:absolute;top:0;z-index:1000}:host(:focus){outline:none}#contents,sp-theme{height:100%}#contents{animation-duration:var(--spectrum-global-animation-duration-200,.16s);animation-timing-function:var(
15
15
  --spectrum-global-animation-ease-out,ease-out
16
- );display:inline-block;opacity:100%;pointer-events:none;visibility:visible}:host([data-popper-placement*=top]) #contents{--sp-overlay-from:translateY(var(--spectrum-global-dimension-size-75))}:host([data-popper-placement*=right]) #contents{--sp-overlay-from:translateX(calc(-1*var(--spectrum-global-dimension-size-75)))}:host([data-popper-placement*=bottom]) #contents{--sp-overlay-from:translateY(calc(-1*var(--spectrum-global-dimension-size-75)))}:host([data-popper-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}
16
+ );display:inline-block;opacity:1;pointer-events:none;visibility:visible}:host([data-popper-placement*=top]) #contents{--sp-overlay-from:translateY(var(--spectrum-global-dimension-size-75))}:host([data-popper-placement*=right]) #contents{--sp-overlay-from:translateX(calc(-1*var(--spectrum-global-dimension-size-75)))}:host([data-popper-placement*=bottom]) #contents{--sp-overlay-from:translateY(calc(-1*var(--spectrum-global-dimension-size-75)))}:host([data-popper-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}
17
17
  `;
18
18
  export default styles;
19
19
  //# sourceMappingURL=active-overlay.css.js.map
@@ -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;;;;CAIjB,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:100%;transform:translate(0)}}@keyframes sp-overlay-fade-out{0%{opacity:100%;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}#contents,sp-theme{height:100%}#contents{animation-duration:var(--spectrum-global-animation-duration-200,.16s);animation-timing-function:var(\n--spectrum-global-animation-ease-out,ease-out\n);display:inline-block;opacity:100%;pointer-events:none;visibility:visible}:host([data-popper-placement*=top]) #contents{--sp-overlay-from:translateY(var(--spectrum-global-dimension-size-75))}:host([data-popper-placement*=right]) #contents{--sp-overlay-from:translateX(calc(-1*var(--spectrum-global-dimension-size-75)))}:host([data-popper-placement*=bottom]) #contents{--sp-overlay-from:translateY(calc(-1*var(--spectrum-global-dimension-size-75)))}:host([data-popper-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;;;;CAIjB,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}#contents,sp-theme{height:100%}#contents{animation-duration:var(--spectrum-global-animation-duration-200,.16s);animation-timing-function:var(\n--spectrum-global-animation-ease-out,ease-out\n);display:inline-block;opacity:1;pointer-events:none;visibility:visible}:host([data-popper-placement*=top]) #contents{--sp-overlay-from:translateY(var(--spectrum-global-dimension-size-75))}:host([data-popper-placement*=right]) #contents{--sp-overlay-from:translateX(calc(-1*var(--spectrum-global-dimension-size-75)))}:host([data-popper-placement*=bottom]) #contents{--sp-overlay-from:translateY(calc(-1*var(--spectrum-global-dimension-size-75)))}:host([data-popper-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 +1 @@
1
- {"version":3,"file":"apply-max-size.js","sourceRoot":"","sources":["apply-max-size.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAIF,MAAM,mBAAmB,GAAG,IAAI,OAAO,EAAE,CAAC;AAE1C,MAAM,CAAC,MAAM,YAAY,GAAsD;IAC3E,IAAI,EAAE,cAAc;IACpB,OAAO,EAAE,IAAI;IACb,KAAK,EAAE,aAAa;IACpB,QAAQ,EAAE,CAAC,SAAS,CAAC;IACrB,EAAE,CAAC,EAAE,KAAK,EAA8C;QACpD,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC;QAC1D,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;YACjD,mBAAmB,CAAC,GAAG,CACnB,KAAK,CAAC,QAAQ,CAAC,MAAM,EACrB,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAC5B,CAAC;SACL;QACD,MAAM,YAAY,GAAG,mBAAmB,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACpE,MAAM,eAAe,GAAG,SAAS,GAAG,YAAY,CAAC;QACjD,MAAM,aAAa,GAAG,eAAe,CAAC,CAAC,CAAC,GAAG,SAAS,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9D,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,GAAG,aAAa,CAAC;QAC9C,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,aAAa,CAAC;IAC/C,CAAC;CACJ,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 { ModifierArguments, Modifier } from '@popperjs/core/lib/types';\n\nconst appliedSizeDefaults = new WeakMap();\n\nexport const applyMaxSize: Modifier<'applyMaxSize', Record<string, unknown>> = {\n name: 'applyMaxSize',\n enabled: true,\n phase: 'beforeWrite',\n requires: ['maxSize'],\n fn({ state }: ModifierArguments<Record<string, unknown>>): void {\n const { height: maxHeight } = state.modifiersData.maxSize;\n if (!appliedSizeDefaults.has(state.elements.popper)) {\n appliedSizeDefaults.set(\n state.elements.popper,\n state.rects.popper.height\n );\n }\n const actualHeight = appliedSizeDefaults.get(state.elements.popper);\n const constrainHeight = maxHeight < actualHeight;\n const appliedHeight = constrainHeight ? `${maxHeight}px` : '';\n state.styles.popper.maxHeight = appliedHeight;\n state.styles.popper.height = appliedHeight;\n },\n};\n"]}
1
+ {"version":3,"file":"apply-max-size.js","sourceRoot":"","sources":["apply-max-size.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAIF,MAAM,mBAAmB,GAAG,IAAI,OAAO,EAAE,CAAC;AAE1C,MAAM,CAAC,MAAM,YAAY,GAAsD;IAC3E,IAAI,EAAE,cAAc;IACpB,OAAO,EAAE,IAAI;IACb,KAAK,EAAE,aAAa;IACpB,QAAQ,EAAE,CAAC,SAAS,CAAC;IACrB,EAAE,CAAC,EAAE,KAAK,EAA8C;QACpD,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC;QAC1D,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;YACjD,mBAAmB,CAAC,GAAG,CACnB,KAAK,CAAC,QAAQ,CAAC,MAAM,EACrB,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAC5B,CAAC;SACL;QACD,MAAM,YAAY,GAAG,mBAAmB,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACpE,MAAM,eAAe,GAAG,SAAS,GAAG,YAAY,CAAC;QACjD,MAAM,aAAa,GAAG,eAAe,CAAC,CAAC,CAAC,GAAG,SAAS,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9D,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,GAAG,aAAa,CAAC;QAC9C,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,aAAa,CAAC;IAC/C,CAAC;CACJ,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 { Modifier, ModifierArguments } from '@popperjs/core/lib/types';\n\nconst appliedSizeDefaults = new WeakMap();\n\nexport const applyMaxSize: Modifier<'applyMaxSize', Record<string, unknown>> = {\n name: 'applyMaxSize',\n enabled: true,\n phase: 'beforeWrite',\n requires: ['maxSize'],\n fn({ state }: ModifierArguments<Record<string, unknown>>): void {\n const { height: maxHeight } = state.modifiersData.maxSize;\n if (!appliedSizeDefaults.has(state.elements.popper)) {\n appliedSizeDefaults.set(\n state.elements.popper,\n state.rects.popper.height\n );\n }\n const actualHeight = appliedSizeDefaults.get(state.elements.popper);\n const constrainHeight = maxHeight < actualHeight;\n const appliedHeight = constrainHeight ? `${maxHeight}px` : '';\n state.styles.popper.maxHeight = appliedHeight;\n state.styles.popper.height = appliedHeight;\n },\n};\n"]}
package/src/loader.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { TriggerInteractions, OverlayOptions } from './overlay-types';
1
+ import { 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 { TriggerInteractions, OverlayOptions } 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 { 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"]}
@@ -13,6 +13,8 @@ export declare class OverlayStack {
13
13
  private overlayHolder;
14
14
  private _eventsAreBound;
15
15
  private initTabTrapping;
16
+ private _bodyMarginsApplied;
17
+ private applyBodyMargins;
16
18
  private startTabTrapping;
17
19
  private stopTabTrapping;
18
20
  private forwardContextmenuEvent;