@spectrum-web-components/overlay 0.14.2-express.9 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom-elements.json +28 -3
- package/package.json +6 -6
- package/active-overlay.d.ts +0 -6
- package/active-overlay.js +0 -14
- package/active-overlay.js.map +0 -1
- package/overlay-trigger.d.ts +0 -6
- package/overlay-trigger.js +0 -14
- package/overlay-trigger.js.map +0 -1
- package/src/ActiveOverlay.d.ts +0 -77
- package/src/ActiveOverlay.js +0 -428
- package/src/ActiveOverlay.js.map +0 -1
- package/src/OverlayTrigger.d.ts +0 -66
- package/src/OverlayTrigger.js +0 -310
- package/src/OverlayTrigger.js.map +0 -1
- package/src/VirtualTrigger.d.ts +0 -7
- package/src/VirtualTrigger.js +0 -40
- package/src/VirtualTrigger.js.map +0 -1
- package/src/active-overlay.css.d.ts +0 -2
- package/src/active-overlay.css.js +0 -21
- package/src/active-overlay.css.js.map +0 -1
- package/src/index.d.ts +0 -6
- package/src/index.js +0 -18
- package/src/index.js.map +0 -1
- package/src/loader.d.ts +0 -2
- package/src/loader.js +0 -16
- package/src/loader.js.map +0 -1
- package/src/overlay-stack.d.ts +0 -46
- package/src/overlay-stack.js +0 -444
- package/src/overlay-stack.js.map +0 -1
- package/src/overlay-timer.d.ts +0 -22
- package/src/overlay-timer.js +0 -89
- package/src/overlay-timer.js.map +0 -1
- package/src/overlay-trigger.css.d.ts +0 -2
- package/src/overlay-trigger.css.js +0 -17
- package/src/overlay-trigger.css.js.map +0 -1
- package/src/overlay-types.d.ts +0 -47
- package/src/overlay-types.js +0 -13
- package/src/overlay-types.js.map +0 -1
- package/src/overlay.d.ts +0 -59
- package/src/overlay.js +0 -120
- package/src/overlay.js.map +0 -1
- package/stories/overlay-story-components.js +0 -292
- package/stories/overlay-story-components.js.map +0 -1
- package/stories/overlay.stories.js +0 -805
- package/stories/overlay.stories.js.map +0 -1
- package/sync/overlay-trigger.d.ts +0 -1
- package/sync/overlay-trigger.js +0 -18
- package/sync/overlay-trigger.js.map +0 -1
- package/test/overlay-lifecycle.test.js +0 -162
- package/test/overlay-lifecycle.test.js.map +0 -1
- package/test/overlay-timer.test.js +0 -129
- package/test/overlay-timer.test.js.map +0 -1
- package/test/overlay-trigger-click.test.js +0 -76
- package/test/overlay-trigger-click.test.js.map +0 -1
- package/test/overlay-trigger-extended.test.js +0 -232
- package/test/overlay-trigger-extended.test.js.map +0 -1
- package/test/overlay-trigger-hover-click.test.js +0 -91
- package/test/overlay-trigger-hover-click.test.js.map +0 -1
- package/test/overlay-trigger-hover.test.js +0 -112
- package/test/overlay-trigger-hover.test.js.map +0 -1
- package/test/overlay-trigger-longpress.test.js +0 -334
- package/test/overlay-trigger-longpress.test.js.map +0 -1
- package/test/overlay-trigger-sync.test.js +0 -555
- package/test/overlay-trigger-sync.test.js.map +0 -1
- package/test/overlay-trigger.test.js +0 -555
- package/test/overlay-trigger.test.js.map +0 -1
- package/test/overlay.test-vrt.js +0 -15
- package/test/overlay.test-vrt.js.map +0 -1
- package/test/overlay.test.js +0 -549
- package/test/overlay.test.js.map +0 -1
package/custom-elements.json
CHANGED
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
"kind": "field",
|
|
127
127
|
"name": "theme",
|
|
128
128
|
"type": {
|
|
129
|
-
"text": "{\n color?: Color;\n scale?: Scale;\n lang?: string;\n
|
|
129
|
+
"text": "{\n color?: Color;\n scale?: Scale;\n lang?: string;\n }"
|
|
130
130
|
},
|
|
131
131
|
"privacy": "public",
|
|
132
132
|
"default": "{}"
|
|
@@ -191,6 +191,15 @@
|
|
|
191
191
|
"privacy": "public",
|
|
192
192
|
"default": "6"
|
|
193
193
|
},
|
|
194
|
+
{
|
|
195
|
+
"kind": "field",
|
|
196
|
+
"name": "skidding",
|
|
197
|
+
"type": {
|
|
198
|
+
"text": "number"
|
|
199
|
+
},
|
|
200
|
+
"privacy": "public",
|
|
201
|
+
"default": "0"
|
|
202
|
+
},
|
|
194
203
|
{
|
|
195
204
|
"kind": "field",
|
|
196
205
|
"name": "interaction",
|
|
@@ -1158,7 +1167,7 @@
|
|
|
1158
1167
|
{
|
|
1159
1168
|
"kind": "variable",
|
|
1160
1169
|
"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
|
|
1170
|
+
"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
1171
|
}
|
|
1163
1172
|
],
|
|
1164
1173
|
"exports": [
|
|
@@ -1643,6 +1652,13 @@
|
|
|
1643
1652
|
"type": {
|
|
1644
1653
|
"text": "boolean"
|
|
1645
1654
|
}
|
|
1655
|
+
},
|
|
1656
|
+
{
|
|
1657
|
+
"name": "clickAway",
|
|
1658
|
+
"optional": true,
|
|
1659
|
+
"type": {
|
|
1660
|
+
"text": "boolean"
|
|
1661
|
+
}
|
|
1646
1662
|
}
|
|
1647
1663
|
]
|
|
1648
1664
|
},
|
|
@@ -1654,7 +1670,16 @@
|
|
|
1654
1670
|
"type": {
|
|
1655
1671
|
"text": "Promise<void>"
|
|
1656
1672
|
}
|
|
1657
|
-
}
|
|
1673
|
+
},
|
|
1674
|
+
"parameters": [
|
|
1675
|
+
{
|
|
1676
|
+
"name": "clickAway",
|
|
1677
|
+
"optional": true,
|
|
1678
|
+
"type": {
|
|
1679
|
+
"text": "boolean"
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
]
|
|
1658
1683
|
},
|
|
1659
1684
|
{
|
|
1660
1685
|
"kind": "field",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/overlay",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
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.
|
|
53
|
-
"@spectrum-web-components/base": "^0.5.
|
|
54
|
-
"@spectrum-web-components/shared": "^0.13.
|
|
55
|
-
"@spectrum-web-components/theme": "^0.
|
|
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": "
|
|
66
|
+
"gitHead": "57aba8030b6af96af4015a0aa830e342a17dc219"
|
|
67
67
|
}
|
package/active-overlay.d.ts
DELETED
package/active-overlay.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020 Adobe. All rights reserved.
|
|
3
|
-
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
|
|
7
|
-
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
import { ActiveOverlay } from './src/ActiveOverlay.js';
|
|
13
|
-
customElements.define('active-overlay', ActiveOverlay);
|
|
14
|
-
//# sourceMappingURL=active-overlay.js.map
|
package/active-overlay.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"active-overlay.js","sourceRoot":"","sources":["active-overlay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,cAAc,CAAC,MAAM,CAAC,gBAAgB,EAAE,aAAa,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*/\nimport { ActiveOverlay } from './src/ActiveOverlay.js';\n\ncustomElements.define('active-overlay', ActiveOverlay);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'active-overlay': ActiveOverlay;\n }\n}\n"]}
|
package/overlay-trigger.d.ts
DELETED
package/overlay-trigger.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020 Adobe. All rights reserved.
|
|
3
|
-
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
|
|
7
|
-
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
import { OverlayTrigger } from './src/OverlayTrigger.js';
|
|
13
|
-
customElements.define('overlay-trigger', OverlayTrigger);
|
|
14
|
-
//# sourceMappingURL=overlay-trigger.js.map
|
package/overlay-trigger.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"overlay-trigger.js","sourceRoot":"","sources":["overlay-trigger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,cAAc,CAAC,MAAM,CAAC,iBAAiB,EAAE,cAAc,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*/\nimport { OverlayTrigger } from './src/OverlayTrigger.js';\n\ncustomElements.define('overlay-trigger', OverlayTrigger);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'overlay-trigger': OverlayTrigger;\n }\n}\n"]}
|
package/src/ActiveOverlay.d.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { CSSResultArray, PropertyValues, SpectrumElement, TemplateResult } from '@spectrum-web-components/base';
|
|
2
|
-
import { Color, Flavor, Scale } from '@spectrum-web-components/theme';
|
|
3
|
-
import { OverlayOpenDetail, Placement, TriggerInteractions } from './overlay-types.js';
|
|
4
|
-
import type { VirtualTrigger } from './VirtualTrigger.js';
|
|
5
|
-
export interface PositionResult {
|
|
6
|
-
arrowOffsetLeft: number;
|
|
7
|
-
arrowOffsetTop: number;
|
|
8
|
-
maxHeight: number;
|
|
9
|
-
placement: string;
|
|
10
|
-
positionLeft: number;
|
|
11
|
-
positionTop: number;
|
|
12
|
-
}
|
|
13
|
-
declare type OverlayStateType = 'idle' | 'active' | 'hiding' | 'dispose' | 'disposed';
|
|
14
|
-
declare type ContentAnimation = 'sp-overlay-fade-in' | 'sp-overlay-fade-out';
|
|
15
|
-
/**
|
|
16
|
-
* @element active-overlay
|
|
17
|
-
*
|
|
18
|
-
* @slot - content to display in the overlay
|
|
19
|
-
*/
|
|
20
|
-
export declare class ActiveOverlay extends SpectrumElement {
|
|
21
|
-
overlayContent: HTMLElement;
|
|
22
|
-
overlayContentTip?: HTMLElement;
|
|
23
|
-
trigger: HTMLElement;
|
|
24
|
-
virtualTrigger?: VirtualTrigger;
|
|
25
|
-
protected childrenReady: Promise<unknown[]>;
|
|
26
|
-
_state: OverlayStateType;
|
|
27
|
-
get state(): OverlayStateType;
|
|
28
|
-
set state(state: OverlayStateType);
|
|
29
|
-
animating: boolean;
|
|
30
|
-
placement?: Placement;
|
|
31
|
-
theme: {
|
|
32
|
-
color?: Color;
|
|
33
|
-
scale?: Scale;
|
|
34
|
-
lang?: string;
|
|
35
|
-
theme?: Flavor;
|
|
36
|
-
};
|
|
37
|
-
receivesFocus?: 'auto';
|
|
38
|
-
tabbingAway: boolean;
|
|
39
|
-
private originalPlacement?;
|
|
40
|
-
private restoreContent?;
|
|
41
|
-
focus(): void;
|
|
42
|
-
private get hasTheme();
|
|
43
|
-
offset: number;
|
|
44
|
-
interaction: TriggerInteractions;
|
|
45
|
-
private positionAnimationFrame;
|
|
46
|
-
private timeout?;
|
|
47
|
-
static get styles(): CSSResultArray;
|
|
48
|
-
constructor();
|
|
49
|
-
private _modalRoot?;
|
|
50
|
-
get hasModalRoot(): boolean;
|
|
51
|
-
feature(): void;
|
|
52
|
-
obscure(nextOverlayInteraction: TriggerInteractions): ActiveOverlay | undefined;
|
|
53
|
-
firstUpdated(changedProperties: PropertyValues): Promise<void>;
|
|
54
|
-
openCallback(): Promise<void>;
|
|
55
|
-
private open;
|
|
56
|
-
private extractDetail;
|
|
57
|
-
dispose(): void;
|
|
58
|
-
private stealOverlayContent;
|
|
59
|
-
private willNotifyClosed;
|
|
60
|
-
private returnOverlayContent;
|
|
61
|
-
private initialHeight;
|
|
62
|
-
private isConstrained;
|
|
63
|
-
updateOverlayPosition: () => Promise<void>;
|
|
64
|
-
hide(animated?: boolean): Promise<void>;
|
|
65
|
-
private schedulePositionUpdate;
|
|
66
|
-
private onSlotChange;
|
|
67
|
-
handleInlineTriggerKeydown: (event: KeyboardEvent) => void;
|
|
68
|
-
applyContentAnimation(animation: ContentAnimation): Promise<boolean>;
|
|
69
|
-
renderTheme(content: TemplateResult): TemplateResult;
|
|
70
|
-
render(): TemplateResult;
|
|
71
|
-
static create(details: OverlayOpenDetail): ActiveOverlay;
|
|
72
|
-
private stealOverlayContentPromise;
|
|
73
|
-
private stealOverlayContentResolver;
|
|
74
|
-
protected getUpdateComplete(): Promise<boolean>;
|
|
75
|
-
disconnectedCallback(): void;
|
|
76
|
-
}
|
|
77
|
-
export {};
|
package/src/ActiveOverlay.js
DELETED
|
@@ -1,428 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020 Adobe. All rights reserved.
|
|
3
|
-
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
|
|
7
|
-
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
import { __decorate } from "tslib";
|
|
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';
|
|
16
|
-
import { reparentChildren } from '@spectrum-web-components/shared';
|
|
17
|
-
import { firstFocusableIn } from '@spectrum-web-components/shared/src/first-focusable-in.js';
|
|
18
|
-
import styles from './active-overlay.css.js';
|
|
19
|
-
import { arrow, computePosition, flip, offset, shift, size, } from '@floating-ui/dom';
|
|
20
|
-
const stateMachine = {
|
|
21
|
-
initial: 'idle',
|
|
22
|
-
states: {
|
|
23
|
-
idle: {
|
|
24
|
-
on: {
|
|
25
|
-
active: 'active',
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
active: {
|
|
29
|
-
on: {
|
|
30
|
-
hiding: 'hiding',
|
|
31
|
-
idle: 'idle',
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
hiding: {
|
|
35
|
-
on: {
|
|
36
|
-
dispose: 'dispose',
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
dispose: {
|
|
40
|
-
on: {
|
|
41
|
-
disposed: 'disposed',
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
disposed: {
|
|
45
|
-
on: {},
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
const stateTransition = (state, event) => {
|
|
50
|
-
if (!state)
|
|
51
|
-
return stateMachine.initial;
|
|
52
|
-
/* c8 ignore next */
|
|
53
|
-
if (!event)
|
|
54
|
-
return state;
|
|
55
|
-
return stateMachine.states[state].on[event] || state;
|
|
56
|
-
};
|
|
57
|
-
const parentOverlayOf = (el) => {
|
|
58
|
-
const closestOverlay = el.closest('active-overlay');
|
|
59
|
-
if (closestOverlay) {
|
|
60
|
-
return closestOverlay;
|
|
61
|
-
}
|
|
62
|
-
const rootNode = el.getRootNode();
|
|
63
|
-
if (rootNode.host) {
|
|
64
|
-
return parentOverlayOf(rootNode.host);
|
|
65
|
-
}
|
|
66
|
-
return null;
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* @element active-overlay
|
|
70
|
-
*
|
|
71
|
-
* @slot - content to display in the overlay
|
|
72
|
-
*/
|
|
73
|
-
export class ActiveOverlay extends SpectrumElement {
|
|
74
|
-
constructor() {
|
|
75
|
-
super();
|
|
76
|
-
this._state = stateTransition();
|
|
77
|
-
this.animating = false;
|
|
78
|
-
this.theme = {};
|
|
79
|
-
this.tabbingAway = false;
|
|
80
|
-
this.offset = 6;
|
|
81
|
-
this.interaction = 'hover';
|
|
82
|
-
this.positionAnimationFrame = 0;
|
|
83
|
-
this.willNotifyClosed = false;
|
|
84
|
-
this.isConstrained = false;
|
|
85
|
-
this.updateOverlayPosition = async () => {
|
|
86
|
-
if (!this.placement || this.placement === 'none') {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
await (document.fonts ? document.fonts.ready : Promise.resolve());
|
|
90
|
-
function roundByDPR(num) {
|
|
91
|
-
const dpr = window.devicePixelRatio || 1;
|
|
92
|
-
return Math.round(num * dpr) / dpr || -10000;
|
|
93
|
-
}
|
|
94
|
-
// See: https://spectrum.adobe.com/page/popover/#Container-padding
|
|
95
|
-
const REQUIRED_DISTANCE_TO_EDGE = 8;
|
|
96
|
-
// See: https://github.com/adobe/spectrum-web-components/issues/910
|
|
97
|
-
const MIN_OVERLAY_HEIGHT = 100;
|
|
98
|
-
const middleware = [
|
|
99
|
-
offset(this.offset),
|
|
100
|
-
flip({
|
|
101
|
-
fallbackStrategy: 'initialPlacement',
|
|
102
|
-
}),
|
|
103
|
-
shift({ padding: REQUIRED_DISTANCE_TO_EDGE }),
|
|
104
|
-
size({
|
|
105
|
-
padding: REQUIRED_DISTANCE_TO_EDGE,
|
|
106
|
-
apply: ({ width, height, floating }) => {
|
|
107
|
-
const maxHeight = Math.max(MIN_OVERLAY_HEIGHT, Math.floor(height));
|
|
108
|
-
const actualHeight = floating.height;
|
|
109
|
-
this.initialHeight = !this.isConstrained
|
|
110
|
-
? actualHeight
|
|
111
|
-
: this.initialHeight || actualHeight;
|
|
112
|
-
this.isConstrained =
|
|
113
|
-
actualHeight < this.initialHeight ||
|
|
114
|
-
maxHeight <= actualHeight;
|
|
115
|
-
const appliedHeight = this.isConstrained
|
|
116
|
-
? `${maxHeight}px`
|
|
117
|
-
: '';
|
|
118
|
-
Object.assign(this.style, {
|
|
119
|
-
maxWidth: `${Math.floor(width)}px`,
|
|
120
|
-
maxHeight: appliedHeight,
|
|
121
|
-
height: appliedHeight,
|
|
122
|
-
});
|
|
123
|
-
},
|
|
124
|
-
}),
|
|
125
|
-
];
|
|
126
|
-
if (this.overlayContentTip) {
|
|
127
|
-
middleware.push(arrow({ element: this.overlayContentTip }));
|
|
128
|
-
}
|
|
129
|
-
const { x, y, placement, middlewareData } = await computePosition(this.virtualTrigger || this.trigger, this, {
|
|
130
|
-
placement: this.placement,
|
|
131
|
-
middleware,
|
|
132
|
-
});
|
|
133
|
-
Object.assign(this.style, {
|
|
134
|
-
left: `${roundByDPR(x)}px`,
|
|
135
|
-
top: `${roundByDPR(y)}px`,
|
|
136
|
-
});
|
|
137
|
-
if (placement !== this.getAttribute('actual-placement')) {
|
|
138
|
-
this.setAttribute('actual-placement', placement);
|
|
139
|
-
this.overlayContent.setAttribute('placement', placement);
|
|
140
|
-
}
|
|
141
|
-
if (this.overlayContentTip && middlewareData.arrow) {
|
|
142
|
-
const { x: arrowX, y: arrowY } = middlewareData.arrow;
|
|
143
|
-
Object.assign(this.overlayContentTip.style, {
|
|
144
|
-
left: arrowX != null ? `${roundByDPR(arrowX)}px` : '',
|
|
145
|
-
top: arrowY != null ? `${roundByDPR(arrowY)}px` : '',
|
|
146
|
-
right: '',
|
|
147
|
-
bottom: '',
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
this.handleInlineTriggerKeydown = (event) => {
|
|
152
|
-
const { code, shiftKey } = event;
|
|
153
|
-
/* c8 ignore next */
|
|
154
|
-
if (code !== 'Tab')
|
|
155
|
-
return;
|
|
156
|
-
if (shiftKey) {
|
|
157
|
-
this.tabbingAway = true;
|
|
158
|
-
this.dispatchEvent(new Event('close'));
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
event.stopPropagation();
|
|
162
|
-
event.preventDefault();
|
|
163
|
-
this.focus();
|
|
164
|
-
};
|
|
165
|
-
this.stealOverlayContentPromise = Promise.resolve();
|
|
166
|
-
this.stealOverlayContentPromise = new Promise((res) => (this.stealOverlayContentResolver = res));
|
|
167
|
-
}
|
|
168
|
-
get state() {
|
|
169
|
-
return this._state;
|
|
170
|
-
}
|
|
171
|
-
set state(state) {
|
|
172
|
-
const nextState = stateTransition(this.state, state);
|
|
173
|
-
if (nextState === this.state) {
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
this._state = nextState;
|
|
177
|
-
if (this.state === 'active' || this.state === 'hiding') {
|
|
178
|
-
this.setAttribute('state', this.state);
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
this.removeAttribute('state');
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
focus() {
|
|
185
|
-
const firstFocusable = firstFocusableIn(this);
|
|
186
|
-
if (firstFocusable) {
|
|
187
|
-
firstFocusable.focus();
|
|
188
|
-
/* c8 ignore next 3 */
|
|
189
|
-
}
|
|
190
|
-
else {
|
|
191
|
-
super.focus();
|
|
192
|
-
}
|
|
193
|
-
this.removeAttribute('tabindex');
|
|
194
|
-
}
|
|
195
|
-
get hasTheme() {
|
|
196
|
-
return !!this.theme.color || !!this.theme.scale || !!this.theme.lang;
|
|
197
|
-
}
|
|
198
|
-
static get styles() {
|
|
199
|
-
return [styles];
|
|
200
|
-
}
|
|
201
|
-
get hasModalRoot() {
|
|
202
|
-
return !!this._modalRoot;
|
|
203
|
-
}
|
|
204
|
-
feature() {
|
|
205
|
-
this.tabIndex = -1;
|
|
206
|
-
const parentOverlay = parentOverlayOf(this.trigger);
|
|
207
|
-
const parentIsModal = parentOverlay && parentOverlay.slot === 'open';
|
|
208
|
-
// If an overlay it triggered from within a "modal" overlay, it needs to continue
|
|
209
|
-
// to act like one to get treated correctly in regards to tab trapping.
|
|
210
|
-
if (this.interaction === 'modal' || parentIsModal || this._modalRoot) {
|
|
211
|
-
this.slot = 'open';
|
|
212
|
-
if (this.interaction === 'modal') {
|
|
213
|
-
this.setAttribute('aria-modal', 'true');
|
|
214
|
-
}
|
|
215
|
-
// If this isn't a modal root, walk up the overlays to the next modal root
|
|
216
|
-
// and "feature" each on of the intervening overlays.
|
|
217
|
-
if (this._modalRoot) {
|
|
218
|
-
parentOverlay === null || parentOverlay === void 0 ? void 0 : parentOverlay.feature();
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
obscure(nextOverlayInteraction) {
|
|
223
|
-
if (this.slot && nextOverlayInteraction === 'modal') {
|
|
224
|
-
this.removeAttribute('slot');
|
|
225
|
-
this.removeAttribute('aria-modal');
|
|
226
|
-
// Obscure upto and including the next modal root.
|
|
227
|
-
if (this.interaction !== 'modal') {
|
|
228
|
-
const parentOverlay = parentOverlayOf(this.trigger);
|
|
229
|
-
this._modalRoot = parentOverlay === null || parentOverlay === void 0 ? void 0 : parentOverlay.obscure(nextOverlayInteraction);
|
|
230
|
-
return this._modalRoot;
|
|
231
|
-
}
|
|
232
|
-
return this;
|
|
233
|
-
}
|
|
234
|
-
return undefined;
|
|
235
|
-
}
|
|
236
|
-
async firstUpdated(changedProperties) {
|
|
237
|
-
super.firstUpdated(changedProperties);
|
|
238
|
-
/* c8 ignore next */
|
|
239
|
-
if (!this.overlayContent || !this.trigger)
|
|
240
|
-
return;
|
|
241
|
-
this.stealOverlayContent(this.overlayContent);
|
|
242
|
-
this.state = 'active';
|
|
243
|
-
this.feature();
|
|
244
|
-
if (this.placement === 'none') {
|
|
245
|
-
this.style.setProperty('--swc-visual-viewport-height', `${window.innerHeight}px`);
|
|
246
|
-
}
|
|
247
|
-
else if (this.placement) {
|
|
248
|
-
await this.updateOverlayPosition();
|
|
249
|
-
document.addEventListener('sp-update-overlays', this.updateOverlayPosition);
|
|
250
|
-
window.addEventListener('scroll', this.updateOverlayPosition);
|
|
251
|
-
}
|
|
252
|
-
const actions = [];
|
|
253
|
-
if (this.placement && this.placement !== 'none') {
|
|
254
|
-
actions.push(this.applyContentAnimation('sp-overlay-fade-in'));
|
|
255
|
-
}
|
|
256
|
-
if (typeof this.overlayContent.updateComplete !==
|
|
257
|
-
'undefined') {
|
|
258
|
-
actions.push(this.overlayContent.updateComplete);
|
|
259
|
-
}
|
|
260
|
-
this.childrenReady = Promise.all(actions);
|
|
261
|
-
}
|
|
262
|
-
async openCallback() {
|
|
263
|
-
await this.updateComplete;
|
|
264
|
-
if (this.receivesFocus) {
|
|
265
|
-
this.focus();
|
|
266
|
-
}
|
|
267
|
-
this.trigger.dispatchEvent(new CustomEvent('sp-opened', {
|
|
268
|
-
bubbles: true,
|
|
269
|
-
composed: true,
|
|
270
|
-
cancelable: true,
|
|
271
|
-
detail: {
|
|
272
|
-
interaction: this.interaction,
|
|
273
|
-
},
|
|
274
|
-
}));
|
|
275
|
-
}
|
|
276
|
-
open(openDetail) {
|
|
277
|
-
this.extractDetail(openDetail);
|
|
278
|
-
}
|
|
279
|
-
extractDetail(detail) {
|
|
280
|
-
this.overlayContent = detail.content;
|
|
281
|
-
this.overlayContentTip = detail.contentTip;
|
|
282
|
-
this.trigger = detail.trigger;
|
|
283
|
-
this.virtualTrigger = detail.virtualTrigger;
|
|
284
|
-
this.placement = detail.placement;
|
|
285
|
-
this.offset = detail.offset;
|
|
286
|
-
this.interaction = detail.interaction;
|
|
287
|
-
this.theme = detail.theme;
|
|
288
|
-
this.receivesFocus = detail.receivesFocus;
|
|
289
|
-
}
|
|
290
|
-
dispose() {
|
|
291
|
-
/* c8 ignore next */
|
|
292
|
-
if (this.state !== 'dispose')
|
|
293
|
-
return;
|
|
294
|
-
/* c8 ignore next 4 */
|
|
295
|
-
if (this.timeout) {
|
|
296
|
-
clearTimeout(this.timeout);
|
|
297
|
-
delete this.timeout;
|
|
298
|
-
}
|
|
299
|
-
this.trigger.removeEventListener('keydown', this.handleInlineTriggerKeydown);
|
|
300
|
-
this.returnOverlayContent();
|
|
301
|
-
this.state = 'disposed';
|
|
302
|
-
if (this.willNotifyClosed) {
|
|
303
|
-
this.overlayContent.dispatchEvent(new Event('sp-overlay-closed'));
|
|
304
|
-
this.willNotifyClosed = false;
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
stealOverlayContent(element) {
|
|
308
|
-
this.originalPlacement = element.getAttribute('placement');
|
|
309
|
-
this.restoreContent = reparentChildren([element], this, (el) => {
|
|
310
|
-
const slotName = el.slot;
|
|
311
|
-
const placement = el.placement;
|
|
312
|
-
el.removeAttribute('slot');
|
|
313
|
-
return (el) => {
|
|
314
|
-
el.slot = slotName;
|
|
315
|
-
el.placement = placement;
|
|
316
|
-
};
|
|
317
|
-
});
|
|
318
|
-
this.stealOverlayContentResolver();
|
|
319
|
-
}
|
|
320
|
-
returnOverlayContent() {
|
|
321
|
-
/* c8 ignore next */
|
|
322
|
-
if (!this.restoreContent)
|
|
323
|
-
return;
|
|
324
|
-
const [element] = this.restoreContent();
|
|
325
|
-
this.restoreContent = undefined;
|
|
326
|
-
this.willNotifyClosed = true;
|
|
327
|
-
if (this.originalPlacement) {
|
|
328
|
-
element.setAttribute('placement', this.originalPlacement);
|
|
329
|
-
delete this.originalPlacement;
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
async hide(animated = true) {
|
|
333
|
-
this.state = 'hiding';
|
|
334
|
-
if (animated) {
|
|
335
|
-
await this.applyContentAnimation('sp-overlay-fade-out');
|
|
336
|
-
}
|
|
337
|
-
this.state = 'dispose';
|
|
338
|
-
}
|
|
339
|
-
schedulePositionUpdate() {
|
|
340
|
-
// Edge needs a little time to update the DOM before computing the layout
|
|
341
|
-
cancelAnimationFrame(this.positionAnimationFrame);
|
|
342
|
-
this.positionAnimationFrame = requestAnimationFrame(() => this.updateOverlayPosition());
|
|
343
|
-
}
|
|
344
|
-
onSlotChange() {
|
|
345
|
-
this.schedulePositionUpdate();
|
|
346
|
-
}
|
|
347
|
-
applyContentAnimation(animation) {
|
|
348
|
-
if (this.placement === 'none') {
|
|
349
|
-
return Promise.resolve(true);
|
|
350
|
-
}
|
|
351
|
-
return new Promise((resolve) => {
|
|
352
|
-
const contents = this.shadowRoot.querySelector('#contents');
|
|
353
|
-
const doneHandler = (event) => {
|
|
354
|
-
if (animation !== event.animationName)
|
|
355
|
-
return;
|
|
356
|
-
contents.removeEventListener('animationend', doneHandler);
|
|
357
|
-
contents.removeEventListener('animationcancel', doneHandler);
|
|
358
|
-
this.animating = false;
|
|
359
|
-
resolve(event.type === 'animationcancel');
|
|
360
|
-
};
|
|
361
|
-
contents.addEventListener('animationend', doneHandler);
|
|
362
|
-
contents.addEventListener('animationcancel', doneHandler);
|
|
363
|
-
contents.style.animationName = animation;
|
|
364
|
-
this.animating = true;
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
|
-
renderTheme(content) {
|
|
368
|
-
const { color, scale, lang, theme } = this.theme;
|
|
369
|
-
return html `
|
|
370
|
-
<sp-theme
|
|
371
|
-
theme=${ifDefined(theme)}
|
|
372
|
-
color=${ifDefined(color)}
|
|
373
|
-
scale=${ifDefined(scale)}
|
|
374
|
-
lang=${ifDefined(lang)}
|
|
375
|
-
part="theme"
|
|
376
|
-
>
|
|
377
|
-
${content}
|
|
378
|
-
</sp-theme>
|
|
379
|
-
`;
|
|
380
|
-
}
|
|
381
|
-
render() {
|
|
382
|
-
const content = html `
|
|
383
|
-
<div id="contents">
|
|
384
|
-
<slot @slotchange=${this.onSlotChange}></slot>
|
|
385
|
-
</div>
|
|
386
|
-
`;
|
|
387
|
-
return this.hasTheme ? this.renderTheme(content) : content;
|
|
388
|
-
}
|
|
389
|
-
static create(details) {
|
|
390
|
-
const overlay = new ActiveOverlay();
|
|
391
|
-
if (details.content) {
|
|
392
|
-
overlay.open(details);
|
|
393
|
-
}
|
|
394
|
-
return overlay;
|
|
395
|
-
}
|
|
396
|
-
async getUpdateComplete() {
|
|
397
|
-
const actions = [
|
|
398
|
-
super.getUpdateComplete(),
|
|
399
|
-
this.stealOverlayContentPromise,
|
|
400
|
-
];
|
|
401
|
-
if (this.childrenReady) {
|
|
402
|
-
actions.push(this.childrenReady);
|
|
403
|
-
}
|
|
404
|
-
const [complete] = await Promise.all(actions);
|
|
405
|
-
return complete;
|
|
406
|
-
}
|
|
407
|
-
disconnectedCallback() {
|
|
408
|
-
document.removeEventListener('sp-update-overlays', this.updateOverlayPosition);
|
|
409
|
-
window.removeEventListener('scroll', this.updateOverlayPosition);
|
|
410
|
-
super.disconnectedCallback();
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
__decorate([
|
|
414
|
-
property()
|
|
415
|
-
], ActiveOverlay.prototype, "_state", void 0);
|
|
416
|
-
__decorate([
|
|
417
|
-
property({ reflect: true, type: Boolean })
|
|
418
|
-
], ActiveOverlay.prototype, "animating", void 0);
|
|
419
|
-
__decorate([
|
|
420
|
-
property({ reflect: true })
|
|
421
|
-
], ActiveOverlay.prototype, "placement", void 0);
|
|
422
|
-
__decorate([
|
|
423
|
-
property({ attribute: false })
|
|
424
|
-
], ActiveOverlay.prototype, "theme", void 0);
|
|
425
|
-
__decorate([
|
|
426
|
-
property({ attribute: false })
|
|
427
|
-
], ActiveOverlay.prototype, "receivesFocus", void 0);
|
|
428
|
-
//# sourceMappingURL=ActiveOverlay.js.map
|