@spectrum-web-components/overlay 0.16.3 → 0.16.6-devmode.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/active-overlay.dev.js +3 -0
  2. package/active-overlay.dev.js.map +7 -0
  3. package/active-overlay.js +3 -14
  4. package/active-overlay.js.map +7 -1
  5. package/overlay-trigger.dev.js +3 -0
  6. package/overlay-trigger.dev.js.map +7 -0
  7. package/overlay-trigger.js +3 -14
  8. package/overlay-trigger.js.map +7 -1
  9. package/package.json +69 -15
  10. package/src/ActiveOverlay.d.ts +2 -2
  11. package/src/ActiveOverlay.dev.js +445 -0
  12. package/src/ActiveOverlay.dev.js.map +7 -0
  13. package/src/ActiveOverlay.js +404 -423
  14. package/src/ActiveOverlay.js.map +7 -1
  15. package/src/OverlayTrigger.dev.js +293 -0
  16. package/src/OverlayTrigger.dev.js.map +7 -0
  17. package/src/OverlayTrigger.js +245 -264
  18. package/src/OverlayTrigger.js.map +7 -1
  19. package/src/VirtualTrigger.dev.js +30 -0
  20. package/src/VirtualTrigger.dev.js.map +7 -0
  21. package/src/VirtualTrigger.js +28 -38
  22. package/src/VirtualTrigger.js.map +7 -1
  23. package/src/active-overlay.css.dev.js +12 -0
  24. package/src/active-overlay.css.dev.js.map +7 -0
  25. package/src/active-overlay.css.js +3 -14
  26. package/src/active-overlay.css.js.map +7 -1
  27. package/src/index.dev.js +7 -0
  28. package/src/index.dev.js.map +7 -0
  29. package/src/index.js +7 -18
  30. package/src/index.js.map +7 -1
  31. package/src/loader.dev.js +5 -0
  32. package/src/loader.dev.js.map +7 -0
  33. package/src/loader.js +3 -14
  34. package/src/loader.js.map +7 -1
  35. package/src/overlay-events.d.ts +11 -0
  36. package/src/overlay-events.dev.js +7 -0
  37. package/src/overlay-events.dev.js.map +7 -0
  38. package/src/overlay-events.js +7 -0
  39. package/src/overlay-events.js.map +7 -0
  40. package/src/overlay-stack.d.ts +2 -0
  41. package/src/overlay-stack.dev.js +436 -0
  42. package/src/overlay-stack.dev.js.map +7 -0
  43. package/src/overlay-stack.js +374 -419
  44. package/src/overlay-stack.js.map +7 -1
  45. package/src/overlay-timer.dev.js +71 -0
  46. package/src/overlay-timer.dev.js.map +7 -0
  47. package/src/overlay-timer.js +64 -82
  48. package/src/overlay-timer.js.map +7 -1
  49. package/src/overlay-trigger.css.dev.js +6 -0
  50. package/src/overlay-trigger.css.dev.js.map +7 -0
  51. package/src/overlay-trigger.css.js +3 -14
  52. package/src/overlay-trigger.css.js.map +7 -1
  53. package/src/overlay-types.dev.js +1 -0
  54. package/src/overlay-types.dev.js.map +7 -0
  55. package/src/overlay-types.js +1 -13
  56. package/src/overlay-types.js.map +7 -1
  57. package/src/overlay-utils.dev.js +28 -0
  58. package/src/overlay-utils.dev.js.map +7 -0
  59. package/src/overlay-utils.js +22 -33
  60. package/src/overlay-utils.js.map +7 -1
  61. package/src/overlay.dev.js +85 -0
  62. package/src/overlay.dev.js.map +7 -0
  63. package/src/overlay.js +83 -119
  64. package/src/overlay.js.map +7 -1
  65. package/stories/overlay-story-components.js +188 -184
  66. package/stories/overlay-story-components.js.map +7 -1
  67. package/stories/overlay.stories.js +238 -228
  68. package/stories/overlay.stories.js.map +7 -1
  69. package/sync/overlay-trigger.dev.js +7 -0
  70. package/sync/overlay-trigger.dev.js.map +7 -0
  71. package/sync/overlay-trigger.js +5 -16
  72. package/sync/overlay-trigger.js.map +7 -1
  73. package/test/benchmark/basic-test.js +7 -18
  74. package/test/benchmark/basic-test.js.map +7 -1
  75. package/test/overlay-lifecycle.test.js +107 -115
  76. package/test/overlay-lifecycle.test.js.map +7 -1
  77. package/test/overlay-timer.test.js +110 -122
  78. package/test/overlay-timer.test.js.map +7 -1
  79. package/test/overlay-trigger-click.test.js +43 -48
  80. package/test/overlay-trigger-click.test.js.map +7 -1
  81. package/test/overlay-trigger-extended.test.js +167 -182
  82. package/test/overlay-trigger-extended.test.js.map +7 -1
  83. package/test/overlay-trigger-hover-click.test.js +59 -73
  84. package/test/overlay-trigger-hover-click.test.js.map +7 -1
  85. package/test/overlay-trigger-hover.test.js +74 -77
  86. package/test/overlay-trigger-hover.test.js.map +7 -1
  87. package/test/overlay-trigger-longpress.test.js +166 -178
  88. package/test/overlay-trigger-longpress.test.js.map +7 -1
  89. package/test/overlay-trigger-sync.test.js +400 -422
  90. package/test/overlay-trigger-sync.test.js.map +7 -1
  91. package/test/overlay-trigger.test.js +400 -422
  92. package/test/overlay-trigger.test.js.map +7 -1
  93. package/test/overlay.test-vrt.js +4 -15
  94. package/test/overlay.test-vrt.js.map +7 -1
  95. package/test/overlay.test.js +458 -479
  96. package/test/overlay.test.js.map +7 -1
@@ -0,0 +1,3 @@
1
+ import { ActiveOverlay } from "./src/ActiveOverlay.dev.js";
2
+ customElements.define("active-overlay", ActiveOverlay);
3
+ //# sourceMappingURL=active-overlay.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["active-overlay.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { ActiveOverlay } from './src/ActiveOverlay.dev.js'\n\ncustomElements.define('active-overlay', ActiveOverlay);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'active-overlay': ActiveOverlay;\n }\n}\n"],
5
+ "mappings": "AAWA;AAEA,eAAe,OAAO,kBAAkB,aAAa;",
6
+ "names": []
7
+ }
package/active-overlay.js CHANGED
@@ -1,14 +1,3 @@
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
1
+ import { ActiveOverlay } from "./src/ActiveOverlay.js";
2
+ customElements.define("active-overlay", ActiveOverlay);
3
+ //# sourceMappingURL=active-overlay.js.map
@@ -1 +1,7 @@
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"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["active-overlay.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { ActiveOverlay } from './src/ActiveOverlay.js';\n\ncustomElements.define('active-overlay', ActiveOverlay);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'active-overlay': ActiveOverlay;\n }\n}\n"],
5
+ "mappings": "AAWA;AAEA,eAAe,OAAO,kBAAkB,aAAa;",
6
+ "names": []
7
+ }
@@ -0,0 +1,3 @@
1
+ import { OverlayTrigger } from "./src/OverlayTrigger.dev.js";
2
+ customElements.define("overlay-trigger", OverlayTrigger);
3
+ //# sourceMappingURL=overlay-trigger.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["overlay-trigger.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { OverlayTrigger } from './src/OverlayTrigger.dev.js'\n\ncustomElements.define('overlay-trigger', OverlayTrigger);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'overlay-trigger': OverlayTrigger;\n }\n}\n"],
5
+ "mappings": "AAWA;AAEA,eAAe,OAAO,mBAAmB,cAAc;",
6
+ "names": []
7
+ }
@@ -1,14 +1,3 @@
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
1
+ import { OverlayTrigger } from "./src/OverlayTrigger.js";
2
+ customElements.define("overlay-trigger", OverlayTrigger);
3
+ //# sourceMappingURL=overlay-trigger.js.map
@@ -1 +1,7 @@
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"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["overlay-trigger.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { OverlayTrigger } from './src/OverlayTrigger.js';\n\ncustomElements.define('overlay-trigger', OverlayTrigger);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'overlay-trigger': OverlayTrigger;\n }\n}\n"],
5
+ "mappings": "AAWA;AAEA,eAAe,OAAO,mBAAmB,cAAc;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/overlay",
3
- "version": "0.16.3",
3
+ "version": "0.16.6-devmode.0+07474d44f",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -20,15 +20,69 @@
20
20
  "module": "./src/index.js",
21
21
  "type": "module",
22
22
  "exports": {
23
- ".": "./src/index.js",
24
- "./src/*": "./src/*",
23
+ ".": {
24
+ "development": "./src/index.dev.js",
25
+ "default": "./src/index.js"
26
+ },
25
27
  "./package.json": "./package.json",
26
- "./active-overlay": "./active-overlay.js",
27
- "./active-overlay.js": "./active-overlay.js",
28
- "./overlay-trigger": "./overlay-trigger.js",
29
- "./overlay-trigger.js": "./overlay-trigger.js",
30
- "./sync/overlay-trigger": "./sync/overlay-trigger.js",
31
- "./sync/overlay-trigger.js": "./sync/overlay-trigger.js"
28
+ "./src/ActiveOverlay.js": {
29
+ "development": "./src/ActiveOverlay.dev.js",
30
+ "default": "./src/ActiveOverlay.js"
31
+ },
32
+ "./src/OverlayTrigger.js": {
33
+ "development": "./src/OverlayTrigger.dev.js",
34
+ "default": "./src/OverlayTrigger.js"
35
+ },
36
+ "./src/VirtualTrigger.js": {
37
+ "development": "./src/VirtualTrigger.dev.js",
38
+ "default": "./src/VirtualTrigger.js"
39
+ },
40
+ "./src/active-overlay.css.js": "./src/active-overlay.css.js",
41
+ "./src/index.js": {
42
+ "development": "./src/index.dev.js",
43
+ "default": "./src/index.js"
44
+ },
45
+ "./src/loader.js": {
46
+ "development": "./src/loader.dev.js",
47
+ "default": "./src/loader.js"
48
+ },
49
+ "./src/overlay-events.js": {
50
+ "development": "./src/overlay-events.dev.js",
51
+ "default": "./src/overlay-events.js"
52
+ },
53
+ "./src/overlay-stack.js": {
54
+ "development": "./src/overlay-stack.dev.js",
55
+ "default": "./src/overlay-stack.js"
56
+ },
57
+ "./src/overlay-timer.js": {
58
+ "development": "./src/overlay-timer.dev.js",
59
+ "default": "./src/overlay-timer.js"
60
+ },
61
+ "./src/overlay-trigger.css.js": "./src/overlay-trigger.css.js",
62
+ "./src/overlay-types.js": {
63
+ "development": "./src/overlay-types.dev.js",
64
+ "default": "./src/overlay-types.js"
65
+ },
66
+ "./src/overlay-utils.js": {
67
+ "development": "./src/overlay-utils.dev.js",
68
+ "default": "./src/overlay-utils.js"
69
+ },
70
+ "./src/overlay.js": {
71
+ "development": "./src/overlay.dev.js",
72
+ "default": "./src/overlay.js"
73
+ },
74
+ "./active-overlay.js": {
75
+ "development": "./active-overlay.dev.js",
76
+ "default": "./active-overlay.js"
77
+ },
78
+ "./overlay-trigger.js": {
79
+ "development": "./overlay-trigger.dev.js",
80
+ "default": "./overlay-trigger.js"
81
+ },
82
+ "./sync/overlay-trigger.js": {
83
+ "development": "./sync/overlay-trigger.dev.js",
84
+ "default": "./sync/overlay-trigger.js"
85
+ }
32
86
  },
33
87
  "scripts": {
34
88
  "test": "echo \"Error: run tests from mono-repo root.\" && exit 1"
@@ -48,11 +102,11 @@
48
102
  "lit-html"
49
103
  ],
50
104
  "dependencies": {
51
- "@floating-ui/dom": "^0.4.4",
52
- "@spectrum-web-components/action-button": "^0.8.6",
53
- "@spectrum-web-components/base": "^0.5.7",
54
- "@spectrum-web-components/shared": "^0.14.2",
55
- "@spectrum-web-components/theme": "^0.11.2",
105
+ "@floating-ui/dom": "^0.5.2",
106
+ "@spectrum-web-components/action-button": "^0.9.1-devmode.0+07474d44f",
107
+ "@spectrum-web-components/base": "^0.5.9-devmode.24+07474d44f",
108
+ "@spectrum-web-components/shared": "^0.14.5-devmode.0+07474d44f",
109
+ "@spectrum-web-components/theme": "^0.12.1-devmode.0+07474d44f",
56
110
  "tslib": "^2.0.0"
57
111
  },
58
112
  "types": "./src/index.d.ts",
@@ -63,5 +117,5 @@
63
117
  "./sync/overlay-trigger.js",
64
118
  "./stories/overlay-story-components.js"
65
119
  ],
66
- "gitHead": "275ee61b152ac3eed0cd1603d8eab2aec90876a0"
120
+ "gitHead": "07474d44f6cee1db241b9ccf3dc812514ffbe7fa"
67
121
  }
@@ -1,4 +1,4 @@
1
- import { CSSResultArray, PropertyValues, SpectrumElement, TemplateResult } from '@spectrum-web-components/base';
1
+ import { CSSResultArray, SpectrumElement, TemplateResult } from '@spectrum-web-components/base';
2
2
  import type { Color, Scale, ThemeVariant } from '@spectrum-web-components/theme/src/Theme.js';
3
3
  import { OverlayOpenDetail, Placement, TriggerInteractions } from './overlay-types.js';
4
4
  import type { VirtualTrigger } from './VirtualTrigger.js';
@@ -52,7 +52,7 @@ export declare class ActiveOverlay extends SpectrumElement {
52
52
  get hasModalRoot(): boolean;
53
53
  feature(): void;
54
54
  obscure(nextOverlayInteraction: TriggerInteractions): ActiveOverlay | undefined;
55
- firstUpdated(changedProperties: PropertyValues): Promise<void>;
55
+ willUpdate(): Promise<void>;
56
56
  openCallback(lifecycleCallback: () => Promise<void> | void): Promise<void>;
57
57
  private open;
58
58
  private extractDetail;
@@ -0,0 +1,445 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __decorateClass = (decorators, target, key, kind) => {
4
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
+ if (decorator = decorators[i])
7
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
+ if (kind && result)
9
+ __defProp(target, key, result);
10
+ return result;
11
+ };
12
+ import {
13
+ html,
14
+ SpectrumElement
15
+ } from "@spectrum-web-components/base";
16
+ import { ifDefined } from "@spectrum-web-components/base/src/directives.js";
17
+ import { property } from "@spectrum-web-components/base/src/decorators.js";
18
+ import { reparentChildren } from "@spectrum-web-components/shared/src/reparent-children.js";
19
+ import { firstFocusableIn } from "@spectrum-web-components/shared/src/first-focusable-in.js";
20
+ import styles from "./active-overlay.css.js";
21
+ import { parentOverlayOf } from "./overlay-utils.dev.js";
22
+ import {
23
+ arrow,
24
+ computePosition,
25
+ flip,
26
+ offset,
27
+ shift,
28
+ size
29
+ } from "@floating-ui/dom";
30
+ const stateMachine = {
31
+ initial: "idle",
32
+ states: {
33
+ idle: {
34
+ on: {
35
+ active: "active"
36
+ }
37
+ },
38
+ active: {
39
+ on: {
40
+ hiding: "hiding",
41
+ idle: "idle"
42
+ }
43
+ },
44
+ hiding: {
45
+ on: {
46
+ dispose: "dispose"
47
+ }
48
+ },
49
+ dispose: {
50
+ on: {
51
+ disposed: "disposed"
52
+ }
53
+ },
54
+ disposed: {
55
+ on: {}
56
+ }
57
+ }
58
+ };
59
+ const stateTransition = (state, event) => {
60
+ if (!state)
61
+ return stateMachine.initial;
62
+ if (!event)
63
+ return state;
64
+ return stateMachine.states[state].on[event] || state;
65
+ };
66
+ const getFallbackPlacements = (placement) => {
67
+ var _a;
68
+ const fallbacks = {
69
+ left: ["right", "bottom", "top"],
70
+ "left-start": ["right-start", "bottom", "top"],
71
+ "left-end": ["right-end", "bottom", "top"],
72
+ right: ["left", "bottom", "top"],
73
+ "right-start": ["left-start", "bottom", "top"],
74
+ "right-end": ["left-end", "bottom", "top"],
75
+ top: ["bottom", "left", "right"],
76
+ "top-start": ["bottom-start", "left", "right"],
77
+ "top-end": ["bottom-end", "left", "right"],
78
+ bottom: ["top", "left", "right"],
79
+ "bottom-start": ["top-start", "left", "right"],
80
+ "bottom-end": ["top-end", "left", "right"]
81
+ };
82
+ return (_a = fallbacks[placement]) != null ? _a : [placement];
83
+ };
84
+ const _ActiveOverlay = class extends SpectrumElement {
85
+ constructor() {
86
+ super();
87
+ this._state = stateTransition();
88
+ this.animating = false;
89
+ this.theme = {};
90
+ this.tabbingAway = false;
91
+ this.offset = 6;
92
+ this.skidding = 0;
93
+ this.interaction = "hover";
94
+ this.positionAnimationFrame = 0;
95
+ this.willNotifyClosed = false;
96
+ this.isConstrained = false;
97
+ this.updateOverlayPosition = async () => {
98
+ if (!this.placement || this.placement === "none") {
99
+ return;
100
+ }
101
+ await (document.fonts ? document.fonts.ready : Promise.resolve());
102
+ function roundByDPR(num) {
103
+ const dpr = window.devicePixelRatio || 1;
104
+ return Math.round(num * dpr) / dpr || -1e4;
105
+ }
106
+ const REQUIRED_DISTANCE_TO_EDGE = 8;
107
+ const MIN_OVERLAY_HEIGHT = 100;
108
+ const flipMiddleware = this.virtualTrigger ? flip({
109
+ padding: REQUIRED_DISTANCE_TO_EDGE,
110
+ fallbackPlacements: getFallbackPlacements(this.placement)
111
+ }) : flip({
112
+ padding: REQUIRED_DISTANCE_TO_EDGE
113
+ });
114
+ const middleware = [
115
+ offset({
116
+ mainAxis: this.offset,
117
+ crossAxis: this.skidding
118
+ }),
119
+ shift({ padding: REQUIRED_DISTANCE_TO_EDGE }),
120
+ flipMiddleware,
121
+ size({
122
+ padding: REQUIRED_DISTANCE_TO_EDGE,
123
+ apply: ({
124
+ availableWidth,
125
+ availableHeight,
126
+ rects: { floating }
127
+ }) => {
128
+ const maxHeight = Math.max(MIN_OVERLAY_HEIGHT, Math.floor(availableHeight));
129
+ const actualHeight = floating.height;
130
+ this.initialHeight = !this.isConstrained && !this.virtualTrigger ? actualHeight : this.initialHeight || actualHeight;
131
+ this.isConstrained = actualHeight < this.initialHeight || maxHeight <= actualHeight;
132
+ const appliedHeight = this.isConstrained ? `${maxHeight}px` : "";
133
+ Object.assign(this.style, {
134
+ maxWidth: `${Math.floor(availableWidth)}px`,
135
+ maxHeight: appliedHeight,
136
+ height: appliedHeight
137
+ });
138
+ }
139
+ })
140
+ ];
141
+ if (this.overlayContentTip) {
142
+ middleware.push(arrow({ element: this.overlayContentTip }));
143
+ }
144
+ const { x, y, placement, middlewareData } = await computePosition(this.virtualTrigger || this.trigger, this, {
145
+ placement: this.placement,
146
+ middleware
147
+ });
148
+ Object.assign(this.style, {
149
+ top: "0px",
150
+ left: "0px",
151
+ transform: `translate(${roundByDPR(x)}px, ${roundByDPR(y)}px)`
152
+ });
153
+ if (placement !== this.getAttribute("actual-placement")) {
154
+ this.setAttribute("actual-placement", placement);
155
+ this.overlayContent.setAttribute("placement", placement);
156
+ }
157
+ if (this.overlayContentTip && middlewareData.arrow) {
158
+ const { x: arrowX, y: arrowY } = middlewareData.arrow;
159
+ Object.assign(this.overlayContentTip.style, {
160
+ left: arrowX != null ? `${roundByDPR(arrowX)}px` : "",
161
+ top: arrowY != null ? `${roundByDPR(arrowY)}px` : "",
162
+ right: "",
163
+ bottom: ""
164
+ });
165
+ }
166
+ };
167
+ this.handleInlineTriggerKeydown = (event) => {
168
+ const { code, shiftKey } = event;
169
+ if (code !== "Tab")
170
+ return;
171
+ if (shiftKey) {
172
+ this.tabbingAway = true;
173
+ this.dispatchEvent(new Event("close"));
174
+ return;
175
+ }
176
+ event.stopPropagation();
177
+ event.preventDefault();
178
+ this.focus();
179
+ };
180
+ this.stealOverlayContentPromise = Promise.resolve();
181
+ this.stealOverlayContentPromise = new Promise((res) => this.stealOverlayContentResolver = res);
182
+ }
183
+ get state() {
184
+ return this._state;
185
+ }
186
+ set state(state) {
187
+ const nextState = stateTransition(this.state, state);
188
+ if (nextState === this.state) {
189
+ return;
190
+ }
191
+ this._state = nextState;
192
+ if (this.state === "active" || this.state === "hiding") {
193
+ this.setAttribute("state", this.state);
194
+ } else {
195
+ this.removeAttribute("state");
196
+ }
197
+ }
198
+ async focus() {
199
+ const firstFocusable = firstFocusableIn(this);
200
+ if (firstFocusable) {
201
+ if (firstFocusable.updateComplete) {
202
+ await firstFocusable.updateComplete;
203
+ }
204
+ const activeElement = this.getRootNode().activeElement;
205
+ if (activeElement === this || !this.contains(activeElement)) {
206
+ firstFocusable.focus();
207
+ }
208
+ } else {
209
+ super.focus();
210
+ }
211
+ this.removeAttribute("tabindex");
212
+ }
213
+ get hasTheme() {
214
+ return !!this.theme.color || !!this.theme.scale || !!this.theme.lang;
215
+ }
216
+ static get styles() {
217
+ return [styles];
218
+ }
219
+ get hasModalRoot() {
220
+ return !!this._modalRoot;
221
+ }
222
+ feature() {
223
+ this.tabIndex = -1;
224
+ const parentOverlay = parentOverlayOf(this.trigger);
225
+ const parentIsModal = parentOverlay && parentOverlay.slot === "open";
226
+ if (parentIsModal) {
227
+ this._modalRoot = parentOverlay._modalRoot || parentOverlay;
228
+ }
229
+ if (this.interaction === "modal" || this._modalRoot) {
230
+ this.slot = "open";
231
+ if (this.interaction === "modal") {
232
+ this.setAttribute("aria-modal", "true");
233
+ }
234
+ if (this._modalRoot) {
235
+ parentOverlay == null ? void 0 : parentOverlay.feature();
236
+ }
237
+ }
238
+ }
239
+ obscure(nextOverlayInteraction) {
240
+ if (this.slot && nextOverlayInteraction === "modal") {
241
+ this.removeAttribute("slot");
242
+ this.removeAttribute("aria-modal");
243
+ if (this.interaction !== "modal") {
244
+ const parentOverlay = parentOverlayOf(this.trigger);
245
+ this._modalRoot = parentOverlay == null ? void 0 : parentOverlay.obscure(nextOverlayInteraction);
246
+ return this._modalRoot;
247
+ }
248
+ return this;
249
+ }
250
+ return void 0;
251
+ }
252
+ async willUpdate() {
253
+ if (this.hasUpdated)
254
+ return;
255
+ if (!this.overlayContent || !this.trigger)
256
+ return;
257
+ this.stealOverlayContent(this.overlayContent);
258
+ this.state = "active";
259
+ this.feature();
260
+ if (this.placement === "none") {
261
+ this.style.setProperty("--swc-visual-viewport-height", `${window.innerHeight}px`);
262
+ } else if (this.placement) {
263
+ await this.updateOverlayPosition();
264
+ document.addEventListener("sp-update-overlays", this.updateOverlayPosition);
265
+ window.addEventListener("scroll", this.updateOverlayPosition);
266
+ }
267
+ const actions = [];
268
+ if (this.placement && this.placement !== "none") {
269
+ actions.push(this.applyContentAnimation("sp-overlay-fade-in"));
270
+ }
271
+ if (typeof this.overlayContent.updateComplete !== "undefined") {
272
+ actions.push(this.overlayContent.updateComplete);
273
+ }
274
+ this.childrenReady = Promise.all(actions);
275
+ }
276
+ async openCallback(lifecycleCallback) {
277
+ await this.updateComplete;
278
+ if (this.receivesFocus) {
279
+ await this.focus();
280
+ }
281
+ await lifecycleCallback();
282
+ this.trigger.dispatchEvent(new CustomEvent("sp-opened", {
283
+ bubbles: true,
284
+ composed: true,
285
+ cancelable: true,
286
+ detail: {
287
+ interaction: this.interaction
288
+ }
289
+ }));
290
+ }
291
+ open(openDetail) {
292
+ this.extractDetail(openDetail);
293
+ }
294
+ extractDetail(detail) {
295
+ this.overlayContent = detail.content;
296
+ this.overlayContentTip = detail.contentTip;
297
+ this.trigger = detail.trigger;
298
+ this.virtualTrigger = detail.virtualTrigger;
299
+ this.placement = detail.placement;
300
+ this.offset = detail.offset;
301
+ this.skidding = detail.skidding || 0;
302
+ this.interaction = detail.interaction;
303
+ this.theme = detail.theme;
304
+ this.receivesFocus = detail.receivesFocus;
305
+ this.root = detail.root;
306
+ }
307
+ dispose() {
308
+ if (this.state !== "dispose")
309
+ return;
310
+ if (this.timeout) {
311
+ clearTimeout(this.timeout);
312
+ delete this.timeout;
313
+ }
314
+ this.trigger.removeEventListener("keydown", this.handleInlineTriggerKeydown);
315
+ this.returnOverlayContent();
316
+ this.state = "disposed";
317
+ if (this.willNotifyClosed) {
318
+ this.overlayContent.dispatchEvent(new Event("sp-overlay-closed"));
319
+ this.willNotifyClosed = false;
320
+ }
321
+ }
322
+ stealOverlayContent(element) {
323
+ this.originalPlacement = element.getAttribute("placement");
324
+ this.restoreContent = reparentChildren([element], this, {
325
+ position: "beforeend",
326
+ prepareCallback: (el) => {
327
+ const slotName = el.slot;
328
+ const placement = el.placement;
329
+ el.removeAttribute("slot");
330
+ return (el2) => {
331
+ el2.slot = slotName;
332
+ el2.placement = placement;
333
+ };
334
+ }
335
+ });
336
+ this.stealOverlayContentResolver();
337
+ }
338
+ returnOverlayContent() {
339
+ if (!this.restoreContent)
340
+ return;
341
+ const [element] = this.restoreContent();
342
+ this.restoreContent = void 0;
343
+ this.willNotifyClosed = true;
344
+ if (this.originalPlacement) {
345
+ element.setAttribute("placement", this.originalPlacement);
346
+ delete this.originalPlacement;
347
+ }
348
+ }
349
+ async hide(animated = true) {
350
+ this.state = "hiding";
351
+ if (animated) {
352
+ await this.applyContentAnimation("sp-overlay-fade-out");
353
+ }
354
+ this.state = "dispose";
355
+ }
356
+ schedulePositionUpdate() {
357
+ cancelAnimationFrame(this.positionAnimationFrame);
358
+ this.positionAnimationFrame = requestAnimationFrame(() => this.updateOverlayPosition());
359
+ }
360
+ onSlotChange() {
361
+ this.schedulePositionUpdate();
362
+ }
363
+ applyContentAnimation(animation) {
364
+ if (this.placement === "none") {
365
+ return Promise.resolve(true);
366
+ }
367
+ return new Promise((resolve) => {
368
+ const contents = this.shadowRoot.querySelector("#contents");
369
+ const doneHandler = (event) => {
370
+ if (animation !== event.animationName)
371
+ return;
372
+ contents.removeEventListener("animationend", doneHandler);
373
+ contents.removeEventListener("animationcancel", doneHandler);
374
+ this.animating = false;
375
+ resolve(event.type === "animationcancel");
376
+ };
377
+ contents.addEventListener("animationend", doneHandler);
378
+ contents.addEventListener("animationcancel", doneHandler);
379
+ contents.style.animationName = animation;
380
+ this.animating = true;
381
+ });
382
+ }
383
+ renderTheme(content) {
384
+ const { color, scale, lang, theme } = this.theme;
385
+ return html`
386
+ <sp-theme
387
+ theme=${ifDefined(theme)}
388
+ color=${ifDefined(color)}
389
+ scale=${ifDefined(scale)}
390
+ lang=${ifDefined(lang)}
391
+ part="theme"
392
+ >
393
+ ${content}
394
+ </sp-theme>
395
+ `;
396
+ }
397
+ render() {
398
+ const content = html`
399
+ <div id="contents">
400
+ <slot @slotchange=${this.onSlotChange}></slot>
401
+ </div>
402
+ `;
403
+ return this.hasTheme ? this.renderTheme(content) : content;
404
+ }
405
+ static create(details) {
406
+ const overlay = new _ActiveOverlay();
407
+ if (details.content) {
408
+ overlay.open(details);
409
+ }
410
+ return overlay;
411
+ }
412
+ async getUpdateComplete() {
413
+ const actions = [
414
+ super.getUpdateComplete(),
415
+ this.stealOverlayContentPromise
416
+ ];
417
+ if (this.childrenReady) {
418
+ actions.push(this.childrenReady);
419
+ }
420
+ const [complete] = await Promise.all(actions);
421
+ return complete;
422
+ }
423
+ disconnectedCallback() {
424
+ document.removeEventListener("sp-update-overlays", this.updateOverlayPosition);
425
+ window.removeEventListener("scroll", this.updateOverlayPosition);
426
+ super.disconnectedCallback();
427
+ }
428
+ };
429
+ export let ActiveOverlay = _ActiveOverlay;
430
+ __decorateClass([
431
+ property()
432
+ ], ActiveOverlay.prototype, "_state", 2);
433
+ __decorateClass([
434
+ property({ reflect: true, type: Boolean })
435
+ ], ActiveOverlay.prototype, "animating", 2);
436
+ __decorateClass([
437
+ property({ reflect: true })
438
+ ], ActiveOverlay.prototype, "placement", 2);
439
+ __decorateClass([
440
+ property({ attribute: false })
441
+ ], ActiveOverlay.prototype, "theme", 2);
442
+ __decorateClass([
443
+ property({ attribute: false })
444
+ ], ActiveOverlay.prototype, "receivesFocus", 2);
445
+ //# sourceMappingURL=ActiveOverlay.dev.js.map