@spectrum-web-components/overlay 0.41.0 → 0.41.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.
Files changed (100) hide show
  1. package/custom-elements.json +996 -314
  2. package/package.json +31 -7
  3. package/src/AbstractOverlay.d.ts +13 -3
  4. package/src/AbstractOverlay.dev.js +54 -19
  5. package/src/AbstractOverlay.dev.js.map +2 -2
  6. package/src/AbstractOverlay.js +1 -1
  7. package/src/AbstractOverlay.js.map +3 -3
  8. package/src/ClickController.d.ts +14 -0
  9. package/src/ClickController.dev.js +42 -0
  10. package/src/ClickController.dev.js.map +7 -0
  11. package/src/ClickController.js +2 -0
  12. package/src/ClickController.js.map +7 -0
  13. package/src/HoverController.d.ts +19 -0
  14. package/src/HoverController.dev.js +141 -0
  15. package/src/HoverController.dev.js.map +7 -0
  16. package/src/HoverController.js +2 -0
  17. package/src/HoverController.js.map +7 -0
  18. package/src/InteractionController.d.ts +23 -0
  19. package/src/InteractionController.dev.js +45 -0
  20. package/src/InteractionController.dev.js.map +7 -0
  21. package/src/InteractionController.js +2 -0
  22. package/src/InteractionController.js.map +7 -0
  23. package/src/LongpressController.d.ts +21 -0
  24. package/src/LongpressController.dev.js +157 -0
  25. package/src/LongpressController.dev.js.map +7 -0
  26. package/src/LongpressController.js +2 -0
  27. package/src/LongpressController.js.map +7 -0
  28. package/src/Overlay.d.ts +17 -50
  29. package/src/Overlay.dev.js +86 -363
  30. package/src/Overlay.dev.js.map +2 -2
  31. package/src/Overlay.js +10 -10
  32. package/src/Overlay.js.map +3 -3
  33. package/src/OverlayDialog.dev.js +8 -1
  34. package/src/OverlayDialog.dev.js.map +2 -2
  35. package/src/OverlayDialog.js +1 -1
  36. package/src/OverlayDialog.js.map +3 -3
  37. package/src/OverlayNoPopover.dev.js +9 -3
  38. package/src/OverlayNoPopover.dev.js.map +2 -2
  39. package/src/OverlayNoPopover.js +1 -1
  40. package/src/OverlayNoPopover.js.map +3 -3
  41. package/src/OverlayPopover.dev.js +10 -1
  42. package/src/OverlayPopover.dev.js.map +2 -2
  43. package/src/OverlayPopover.js +1 -1
  44. package/src/OverlayPopover.js.map +3 -3
  45. package/src/OverlayStack.dev.js +3 -0
  46. package/src/OverlayStack.dev.js.map +2 -2
  47. package/src/OverlayStack.js +1 -1
  48. package/src/OverlayStack.js.map +2 -2
  49. package/src/index.d.ts +1 -0
  50. package/src/index.dev.js +1 -0
  51. package/src/index.dev.js.map +2 -2
  52. package/src/index.js +1 -1
  53. package/src/index.js.map +2 -2
  54. package/src/overlay-trigger-directive.d.ts +31 -0
  55. package/src/overlay-trigger-directive.dev.js +102 -0
  56. package/src/overlay-trigger-directive.dev.js.map +7 -0
  57. package/src/overlay-trigger-directive.js +2 -0
  58. package/src/overlay-trigger-directive.js.map +7 -0
  59. package/src/overlay-trigger.css.dev.js +1 -1
  60. package/src/overlay-trigger.css.dev.js.map +1 -1
  61. package/src/overlay-trigger.css.js +1 -1
  62. package/src/overlay-trigger.css.js.map +1 -1
  63. package/src/overlay-types.d.ts +7 -0
  64. package/src/overlay-types.dev.js.map +1 -1
  65. package/src/overlay-types.js.map +1 -1
  66. package/src/overlay.css.dev.js +1 -3
  67. package/src/overlay.css.dev.js.map +2 -2
  68. package/src/overlay.css.js +1 -3
  69. package/src/overlay.css.js.map +2 -2
  70. package/src/slottable-request-event.d.ts +7 -0
  71. package/src/slottable-request-event.dev.js +28 -0
  72. package/src/slottable-request-event.dev.js.map +7 -0
  73. package/src/slottable-request-event.js +2 -0
  74. package/src/slottable-request-event.js.map +7 -0
  75. package/stories/overlay-directive.stories.js +203 -0
  76. package/stories/overlay-directive.stories.js.map +7 -0
  77. package/stories/overlay-element.stories.js +44 -1
  78. package/stories/overlay-element.stories.js.map +2 -2
  79. package/stories/overlay.stories.js +9 -9
  80. package/stories/overlay.stories.js.map +2 -2
  81. package/test/benchmark/basic-test.js +24 -1
  82. package/test/benchmark/basic-test.js.map +2 -2
  83. package/test/benchmark/directive-test.js +42 -0
  84. package/test/benchmark/directive-test.js.map +7 -0
  85. package/test/benchmark/element-test.js +40 -0
  86. package/test/benchmark/element-test.js.map +7 -0
  87. package/test/benchmark/lazy-test.js +48 -0
  88. package/test/benchmark/lazy-test.js.map +7 -0
  89. package/test/index.js +11 -176
  90. package/test/index.js.map +2 -2
  91. package/test/overlay-directive.test-vrt.js +5 -0
  92. package/test/overlay-directive.test-vrt.js.map +7 -0
  93. package/test/overlay-directive.test.js +147 -0
  94. package/test/overlay-directive.test.js.map +7 -0
  95. package/test/overlay-element.test.js +152 -1
  96. package/test/overlay-element.test.js.map +2 -2
  97. package/test/overlay-trigger-directive.test.js +75 -0
  98. package/test/overlay-trigger-directive.test.js.map +7 -0
  99. package/test/overlay-trigger-extended.test.js +1 -1
  100. package/test/overlay-trigger-extended.test.js.map +2 -2
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+ import { conditionAttributeWithId } from "@spectrum-web-components/base/src/condition-attribute-with-id.js";
3
+ import { randomID } from "@spectrum-web-components/shared/src/random-id.js";
4
+ import { InteractionController, InteractionTypes } from "./InteractionController.dev.js";
5
+ import { noop } from "./AbstractOverlay.dev.js";
6
+ const HOVER_DELAY = 300;
7
+ export class HoverController extends InteractionController {
8
+ constructor() {
9
+ super(...arguments);
10
+ this.type = InteractionTypes.hover;
11
+ this.elementIds = [];
12
+ this.focusedin = false;
13
+ this.pointerentered = false;
14
+ }
15
+ handleTargetFocusin() {
16
+ this.host.open = true;
17
+ this.focusedin = true;
18
+ }
19
+ handleTargetFocusout() {
20
+ this.focusedin = false;
21
+ if (this.pointerentered)
22
+ return;
23
+ this.host.open = false;
24
+ }
25
+ handleTargetPointerenter() {
26
+ if (this.hoverTimeout) {
27
+ clearTimeout(this.hoverTimeout);
28
+ this.hoverTimeout = void 0;
29
+ }
30
+ if (this.host.disabled)
31
+ return;
32
+ this.host.open = true;
33
+ this.pointerentered = true;
34
+ }
35
+ handleTargetPointerleave() {
36
+ this.doPointerleave();
37
+ }
38
+ // set a timeout once the pointer enters and the overlay is shown
39
+ // give the user time to enter the overlay
40
+ handleHostPointerenter() {
41
+ if (this.hoverTimeout) {
42
+ clearTimeout(this.hoverTimeout);
43
+ this.hoverTimeout = void 0;
44
+ }
45
+ }
46
+ handleHostPointerleave() {
47
+ this.doPointerleave();
48
+ }
49
+ prepareDescription() {
50
+ if (!this.host.elements.length)
51
+ return;
52
+ const triggerRoot = this.target.getRootNode();
53
+ const contentRoot = this.host.elements[0].getRootNode();
54
+ const overlayRoot = this.host.getRootNode();
55
+ if (triggerRoot === overlayRoot) {
56
+ this.prepareOverlayRelativeDescription();
57
+ } else if (triggerRoot === contentRoot) {
58
+ this.prepareContentRelativeDescription();
59
+ }
60
+ }
61
+ prepareOverlayRelativeDescription() {
62
+ const releaseDescription = conditionAttributeWithId(
63
+ this.target,
64
+ "aria-describedby",
65
+ [this.host.id]
66
+ );
67
+ this.releaseDescription = () => {
68
+ releaseDescription();
69
+ this.releaseDescription = noop;
70
+ };
71
+ }
72
+ prepareContentRelativeDescription() {
73
+ const elementIds = [];
74
+ const appliedIds = this.host.elements.map((el) => {
75
+ elementIds.push(el.id);
76
+ if (!el.id) {
77
+ el.id = `${this.host.tagName.toLowerCase()}-helper-${randomID()}`;
78
+ }
79
+ return el.id;
80
+ });
81
+ this.elementIds = elementIds;
82
+ const releaseDescription = conditionAttributeWithId(
83
+ this.target,
84
+ "aria-describedby",
85
+ appliedIds
86
+ );
87
+ this.releaseDescription = () => {
88
+ releaseDescription();
89
+ this.host.elements.map((el, index) => {
90
+ el.id = this.elementIds[index];
91
+ });
92
+ this.releaseDescription = noop;
93
+ };
94
+ }
95
+ doPointerleave() {
96
+ this.pointerentered = false;
97
+ const triggerElement = this.target;
98
+ if (this.focusedin && triggerElement.matches(":focus-visible"))
99
+ return;
100
+ this.hoverTimeout = setTimeout(() => {
101
+ this.host.open = false;
102
+ }, HOVER_DELAY);
103
+ }
104
+ init() {
105
+ var _a;
106
+ (_a = this.abortController) == null ? void 0 : _a.abort();
107
+ this.abortController = new AbortController();
108
+ const { signal } = this.abortController;
109
+ this.target.addEventListener(
110
+ "focusin",
111
+ () => this.handleTargetFocusin(),
112
+ { signal }
113
+ );
114
+ this.target.addEventListener(
115
+ "focusout",
116
+ () => this.handleTargetFocusout(),
117
+ { signal }
118
+ );
119
+ this.target.addEventListener(
120
+ "pointerenter",
121
+ () => this.handleTargetPointerenter(),
122
+ { signal }
123
+ );
124
+ this.target.addEventListener(
125
+ "pointerleave",
126
+ () => this.handleTargetPointerleave(),
127
+ { signal }
128
+ );
129
+ this.host.addEventListener(
130
+ "pointerenter",
131
+ () => this.handleHostPointerenter(),
132
+ { signal }
133
+ );
134
+ this.host.addEventListener(
135
+ "pointerleave",
136
+ () => this.handleHostPointerleave(),
137
+ { signal }
138
+ );
139
+ }
140
+ }
141
+ //# sourceMappingURL=HoverController.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["HoverController.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2024 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 { conditionAttributeWithId } from '@spectrum-web-components/base/src/condition-attribute-with-id.js';\nimport { randomID } from '@spectrum-web-components/shared/src/random-id.js';\n\nimport { InteractionController, InteractionTypes } from './InteractionController.dev.js'\nimport { noop } from './AbstractOverlay.dev.js'\n\nconst HOVER_DELAY = 300;\n\nexport class HoverController extends InteractionController {\n override type = InteractionTypes.hover;\n\n private elementIds: string[] = [];\n\n focusedin = false;\n\n private hoverTimeout?: ReturnType<typeof setTimeout>;\n\n pointerentered = false;\n\n handleTargetFocusin(): void {\n this.host.open = true;\n this.focusedin = true;\n }\n\n handleTargetFocusout(): void {\n this.focusedin = false;\n if (this.pointerentered) return;\n this.host.open = false;\n }\n\n handleTargetPointerenter(): void {\n if (this.hoverTimeout) {\n clearTimeout(this.hoverTimeout);\n this.hoverTimeout = undefined;\n }\n if (this.host.disabled) return;\n this.host.open = true;\n this.pointerentered = true;\n }\n\n handleTargetPointerleave(): void {\n this.doPointerleave();\n }\n\n // set a timeout once the pointer enters and the overlay is shown\n // give the user time to enter the overlay\n handleHostPointerenter(): void {\n if (this.hoverTimeout) {\n clearTimeout(this.hoverTimeout);\n this.hoverTimeout = undefined;\n }\n }\n\n handleHostPointerleave(): void {\n this.doPointerleave();\n }\n\n override prepareDescription(): void {\n // require \"content\" to apply relationship\n if (!this.host.elements.length) return;\n\n const triggerRoot = this.target.getRootNode();\n const contentRoot = this.host.elements[0].getRootNode();\n const overlayRoot = this.host.getRootNode();\n if (triggerRoot === overlayRoot) {\n this.prepareOverlayRelativeDescription();\n } else if (triggerRoot === contentRoot) {\n this.prepareContentRelativeDescription();\n }\n }\n\n private prepareOverlayRelativeDescription(): void {\n const releaseDescription = conditionAttributeWithId(\n this.target,\n 'aria-describedby',\n [this.host.id]\n );\n this.releaseDescription = () => {\n releaseDescription();\n this.releaseDescription = noop;\n };\n }\n\n private prepareContentRelativeDescription(): void {\n const elementIds: string[] = [];\n const appliedIds = this.host.elements.map((el) => {\n elementIds.push(el.id);\n if (!el.id) {\n el.id = `${this.host.tagName.toLowerCase()}-helper-${randomID()}`;\n }\n return el.id;\n });\n this.elementIds = elementIds;\n const releaseDescription = conditionAttributeWithId(\n this.target,\n 'aria-describedby',\n appliedIds\n );\n this.releaseDescription = () => {\n releaseDescription();\n this.host.elements.map((el, index) => {\n el.id = this.elementIds[index];\n });\n this.releaseDescription = noop;\n };\n }\n\n protected doPointerleave(): void {\n this.pointerentered = false;\n const triggerElement = this.target as HTMLElement;\n if (this.focusedin && triggerElement.matches(':focus-visible')) return;\n\n this.hoverTimeout = setTimeout(() => {\n this.host.open = false;\n }, HOVER_DELAY);\n }\n\n override init(): void {\n // Clean up listeners if they've already been bound\n this.abortController?.abort();\n this.abortController = new AbortController();\n const { signal } = this.abortController;\n this.target.addEventListener(\n 'focusin',\n () => this.handleTargetFocusin(),\n { signal }\n );\n this.target.addEventListener(\n 'focusout',\n () => this.handleTargetFocusout(),\n { signal }\n );\n this.target.addEventListener(\n 'pointerenter',\n () => this.handleTargetPointerenter(),\n { signal }\n );\n this.target.addEventListener(\n 'pointerleave',\n () => this.handleTargetPointerleave(),\n { signal }\n );\n this.host.addEventListener(\n 'pointerenter',\n () => this.handleHostPointerenter(),\n { signal }\n );\n this.host.addEventListener(\n 'pointerleave',\n () => this.handleHostPointerleave(),\n { signal }\n );\n }\n}\n"],
5
+ "mappings": ";AAYA,SAAS,gCAAgC;AACzC,SAAS,gBAAgB;AAEzB,SAAS,uBAAuB,wBAAwB;AACxD,SAAS,YAAY;AAErB,MAAM,cAAc;AAEb,aAAM,wBAAwB,sBAAsB;AAAA,EAApD;AAAA;AACH,SAAS,OAAO,iBAAiB;AAEjC,SAAQ,aAAuB,CAAC;AAEhC,qBAAY;AAIZ,0BAAiB;AAAA;AAAA,EAEjB,sBAA4B;AACxB,SAAK,KAAK,OAAO;AACjB,SAAK,YAAY;AAAA,EACrB;AAAA,EAEA,uBAA6B;AACzB,SAAK,YAAY;AACjB,QAAI,KAAK;AAAgB;AACzB,SAAK,KAAK,OAAO;AAAA,EACrB;AAAA,EAEA,2BAAiC;AAC7B,QAAI,KAAK,cAAc;AACnB,mBAAa,KAAK,YAAY;AAC9B,WAAK,eAAe;AAAA,IACxB;AACA,QAAI,KAAK,KAAK;AAAU;AACxB,SAAK,KAAK,OAAO;AACjB,SAAK,iBAAiB;AAAA,EAC1B;AAAA,EAEA,2BAAiC;AAC7B,SAAK,eAAe;AAAA,EACxB;AAAA;AAAA;AAAA,EAIA,yBAA+B;AAC3B,QAAI,KAAK,cAAc;AACnB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AAK,iBAAiB;AACtB,UAAM,iBAAiB,KAAK;AAC5B,QAAI,KAAK,aAAa,eAAe,QAAQ,gBAAgB;AAAG;AAEhE,SAAK,eAAe,WAAW,MAAM;AACjC,WAAK,KAAK,OAAO;AAAA,IACrB,GAAG,WAAW;AAAA,EAClB;AAAA,EAES,OAAa;AAjI1B;AAmIQ,eAAK,oBAAL,mBAAsB;AACtB,SAAK,kBAAkB,IAAI,gBAAgB;AAC3C,UAAM,EAAE,OAAO,IAAI,KAAK;AACxB,SAAK,OAAO;AAAA,MACR;AAAA,MACA,MAAM,KAAK,oBAAoB;AAAA,MAC/B,EAAE,OAAO;AAAA,IACb;AACA,SAAK,OAAO;AAAA,MACR;AAAA,MACA,MAAM,KAAK,qBAAqB;AAAA,MAChC,EAAE,OAAO;AAAA,IACb;AACA,SAAK,OAAO;AAAA,MACR;AAAA,MACA,MAAM,KAAK,yBAAyB;AAAA,MACpC,EAAE,OAAO;AAAA,IACb;AACA,SAAK,OAAO;AAAA,MACR;AAAA,MACA,MAAM,KAAK,yBAAyB;AAAA,MACpC,EAAE,OAAO;AAAA,IACb;AACA,SAAK,KAAK;AAAA,MACN;AAAA,MACA,MAAM,KAAK,uBAAuB;AAAA,MAClC,EAAE,OAAO;AAAA,IACb;AACA,SAAK,KAAK;AAAA,MACN;AAAA,MACA,MAAM,KAAK,uBAAuB;AAAA,MAClC,EAAE,OAAO;AAAA,IACb;AAAA,EACJ;AACJ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";import{conditionAttributeWithId as r}from"@spectrum-web-components/base/src/condition-attribute-with-id.js";import{randomID as a}from"@spectrum-web-components/shared/src/random-id.js";import{InteractionController as h,InteractionTypes as d}from"./InteractionController.js";import{noop as s}from"./AbstractOverlay.js";const l=300;export class HoverController extends h{constructor(){super(...arguments);this.type=d.hover;this.elementIds=[];this.focusedin=!1;this.pointerentered=!1}handleTargetFocusin(){this.host.open=!0,this.focusedin=!0}handleTargetFocusout(){this.focusedin=!1,!this.pointerentered&&(this.host.open=!1)}handleTargetPointerenter(){this.hoverTimeout&&(clearTimeout(this.hoverTimeout),this.hoverTimeout=void 0),!this.host.disabled&&(this.host.open=!0,this.pointerentered=!0)}handleTargetPointerleave(){this.doPointerleave()}handleHostPointerenter(){this.hoverTimeout&&(clearTimeout(this.hoverTimeout),this.hoverTimeout=void 0)}handleHostPointerleave(){this.doPointerleave()}prepareDescription(){if(!this.host.elements.length)return;const e=this.target.getRootNode(),t=this.host.elements[0].getRootNode(),o=this.host.getRootNode();e===o?this.prepareOverlayRelativeDescription():e===t&&this.prepareContentRelativeDescription()}prepareOverlayRelativeDescription(){const e=r(this.target,"aria-describedby",[this.host.id]);this.releaseDescription=()=>{e(),this.releaseDescription=s}}prepareContentRelativeDescription(){const e=[],t=this.host.elements.map(i=>(e.push(i.id),i.id||(i.id=`${this.host.tagName.toLowerCase()}-helper-${a()}`),i.id));this.elementIds=e;const o=r(this.target,"aria-describedby",t);this.releaseDescription=()=>{o(),this.host.elements.map((i,n)=>{i.id=this.elementIds[n]}),this.releaseDescription=s}}doPointerleave(){this.pointerentered=!1;const e=this.target;this.focusedin&&e.matches(":focus-visible")||(this.hoverTimeout=setTimeout(()=>{this.host.open=!1},l))}init(){var t;(t=this.abortController)==null||t.abort(),this.abortController=new AbortController;const{signal:e}=this.abortController;this.target.addEventListener("focusin",()=>this.handleTargetFocusin(),{signal:e}),this.target.addEventListener("focusout",()=>this.handleTargetFocusout(),{signal:e}),this.target.addEventListener("pointerenter",()=>this.handleTargetPointerenter(),{signal:e}),this.target.addEventListener("pointerleave",()=>this.handleTargetPointerleave(),{signal:e}),this.host.addEventListener("pointerenter",()=>this.handleHostPointerenter(),{signal:e}),this.host.addEventListener("pointerleave",()=>this.handleHostPointerleave(),{signal:e})}}
2
+ //# sourceMappingURL=HoverController.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["HoverController.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2024 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 { conditionAttributeWithId } from '@spectrum-web-components/base/src/condition-attribute-with-id.js';\nimport { randomID } from '@spectrum-web-components/shared/src/random-id.js';\n\nimport { InteractionController, InteractionTypes } from './InteractionController.js';\nimport { noop } from './AbstractOverlay.js';\n\nconst HOVER_DELAY = 300;\n\nexport class HoverController extends InteractionController {\n override type = InteractionTypes.hover;\n\n private elementIds: string[] = [];\n\n focusedin = false;\n\n private hoverTimeout?: ReturnType<typeof setTimeout>;\n\n pointerentered = false;\n\n handleTargetFocusin(): void {\n this.host.open = true;\n this.focusedin = true;\n }\n\n handleTargetFocusout(): void {\n this.focusedin = false;\n if (this.pointerentered) return;\n this.host.open = false;\n }\n\n handleTargetPointerenter(): void {\n if (this.hoverTimeout) {\n clearTimeout(this.hoverTimeout);\n this.hoverTimeout = undefined;\n }\n if (this.host.disabled) return;\n this.host.open = true;\n this.pointerentered = true;\n }\n\n handleTargetPointerleave(): void {\n this.doPointerleave();\n }\n\n // set a timeout once the pointer enters and the overlay is shown\n // give the user time to enter the overlay\n handleHostPointerenter(): void {\n if (this.hoverTimeout) {\n clearTimeout(this.hoverTimeout);\n this.hoverTimeout = undefined;\n }\n }\n\n handleHostPointerleave(): void {\n this.doPointerleave();\n }\n\n override prepareDescription(): void {\n // require \"content\" to apply relationship\n if (!this.host.elements.length) return;\n\n const triggerRoot = this.target.getRootNode();\n const contentRoot = this.host.elements[0].getRootNode();\n const overlayRoot = this.host.getRootNode();\n if (triggerRoot === overlayRoot) {\n this.prepareOverlayRelativeDescription();\n } else if (triggerRoot === contentRoot) {\n this.prepareContentRelativeDescription();\n }\n }\n\n private prepareOverlayRelativeDescription(): void {\n const releaseDescription = conditionAttributeWithId(\n this.target,\n 'aria-describedby',\n [this.host.id]\n );\n this.releaseDescription = () => {\n releaseDescription();\n this.releaseDescription = noop;\n };\n }\n\n private prepareContentRelativeDescription(): void {\n const elementIds: string[] = [];\n const appliedIds = this.host.elements.map((el) => {\n elementIds.push(el.id);\n if (!el.id) {\n el.id = `${this.host.tagName.toLowerCase()}-helper-${randomID()}`;\n }\n return el.id;\n });\n this.elementIds = elementIds;\n const releaseDescription = conditionAttributeWithId(\n this.target,\n 'aria-describedby',\n appliedIds\n );\n this.releaseDescription = () => {\n releaseDescription();\n this.host.elements.map((el, index) => {\n el.id = this.elementIds[index];\n });\n this.releaseDescription = noop;\n };\n }\n\n protected doPointerleave(): void {\n this.pointerentered = false;\n const triggerElement = this.target as HTMLElement;\n if (this.focusedin && triggerElement.matches(':focus-visible')) return;\n\n this.hoverTimeout = setTimeout(() => {\n this.host.open = false;\n }, HOVER_DELAY);\n }\n\n override init(): void {\n // Clean up listeners if they've already been bound\n this.abortController?.abort();\n this.abortController = new AbortController();\n const { signal } = this.abortController;\n this.target.addEventListener(\n 'focusin',\n () => this.handleTargetFocusin(),\n { signal }\n );\n this.target.addEventListener(\n 'focusout',\n () => this.handleTargetFocusout(),\n { signal }\n );\n this.target.addEventListener(\n 'pointerenter',\n () => this.handleTargetPointerenter(),\n { signal }\n );\n this.target.addEventListener(\n 'pointerleave',\n () => this.handleTargetPointerleave(),\n { signal }\n );\n this.host.addEventListener(\n 'pointerenter',\n () => this.handleHostPointerenter(),\n { signal }\n );\n this.host.addEventListener(\n 'pointerleave',\n () => this.handleHostPointerleave(),\n { signal }\n );\n }\n}\n"],
5
+ "mappings": "aAYA,OAAS,4BAAAA,MAAgC,mEACzC,OAAS,YAAAC,MAAgB,mDAEzB,OAAS,yBAAAC,EAAuB,oBAAAC,MAAwB,6BACxD,OAAS,QAAAC,MAAY,uBAErB,M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D,EAAqBT,EACvB,KAAK,OACL,mBACAW,CACJ,EACA,KAAK,mBAAqB,IAAM,CAC5BF,EAAmB,EACnB,KAAK,KAAK,SAAS,IAAI,CAACG,EAAIC,IAAU,CAClCD,EAAG,GAAK,KAAK,WAAWC,CAAK,CACjC,CAAC,EACD,KAAK,mBAAqBT,CAC9B,CACJ,CAEU,gBAAuB,CAC7B,KAAK,eAAiB,GACtB,MAAMU,EAAiB,KAAK,OACxB,KAAK,WAAaA,EAAe,QAAQ,gBAAgB,IAE7D,KAAK,aAAe,WAAW,IAAM,CACjC,KAAK,KAAK,KAAO,EACrB,EAAGT,CAAW,EAClB,CAES,MAAa,CAjI1B,IAAAU,GAmIQA,EAAA,KAAK,kBAAL,MAAAA,EAAsB,QACtB,KAAK,gBAAkB,IAAI,gBAC3B,KAAM,CAAE,OAAAC,CAAO,EAAI,KAAK,gBACxB,KAAK,OAAO,iBACR,UACA,IAAM,KAAK,oBAAoB,EAC/B,CAAE,OAAAA,CAAO,CACb,EACA,KAAK,OAAO,iBACR,WACA,IAAM,KAAK,qBAAqB,EAChC,CAAE,OAAAA,CAAO,CACb,EACA,KAAK,OAAO,iBACR,eACA,IAAM,KAAK,yBAAyB,EACpC,CAAE,OAAAA,CAAO,CACb,EACA,KAAK,OAAO,iBACR,eACA,IAAM,KAAK,yBAAyB,EACpC,CAAE,OAAAA,CAAO,CACb,EACA,KAAK,KAAK,iBACN,eACA,IAAM,KAAK,uBAAuB,EAClC,CAAE,OAAAA,CAAO,CACb,EACA,KAAK,KAAK,iBACN,eACA,IAAM,KAAK,uBAAuB,EAClC,CAAE,OAAAA,CAAO,CACb,CACJ,CACJ",
6
+ "names": ["conditionAttributeWithId", "randomID", "InteractionController", "InteractionTypes", "noop", "HOVER_DELAY", "triggerRoot", "contentRoot", "overlayRoot", "releaseDescription", "elementIds", "appliedIds", "el", "index", "triggerElement", "_a", "signal"]
7
+ }
@@ -0,0 +1,23 @@
1
+ import type { ReactiveController } from 'lit';
2
+ import { AbstractOverlay } from './AbstractOverlay.js';
3
+ export declare enum InteractionTypes {
4
+ 'click' = 0,
5
+ 'hover' = 1,
6
+ 'longpress' = 2
7
+ }
8
+ export declare class InteractionController implements ReactiveController {
9
+ host: AbstractOverlay;
10
+ target: HTMLElement;
11
+ private isPersistent;
12
+ abortController: AbortController;
13
+ get activelyOpening(): boolean;
14
+ type: InteractionTypes;
15
+ constructor(host: AbstractOverlay, target: HTMLElement, isPersistent?: boolean);
16
+ prepareDescription(_: HTMLElement): void;
17
+ releaseDescription(): void;
18
+ shouldCompleteOpen(): void;
19
+ init(): void;
20
+ abort(): void;
21
+ hostConnected(): void;
22
+ hostDisconnected(): void;
23
+ }
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ export var InteractionTypes = /* @__PURE__ */ ((InteractionTypes2) => {
3
+ InteractionTypes2[InteractionTypes2["click"] = 0] = "click";
4
+ InteractionTypes2[InteractionTypes2["hover"] = 1] = "hover";
5
+ InteractionTypes2[InteractionTypes2["longpress"] = 2] = "longpress";
6
+ return InteractionTypes2;
7
+ })(InteractionTypes || {});
8
+ export class InteractionController {
9
+ constructor(host, target, isPersistent = false) {
10
+ this.host = host;
11
+ this.target = target;
12
+ this.isPersistent = isPersistent;
13
+ this.host.addController(this);
14
+ this.prepareDescription(this.target);
15
+ if (this.isPersistent) {
16
+ this.init();
17
+ }
18
+ }
19
+ get activelyOpening() {
20
+ return false;
21
+ }
22
+ prepareDescription(_) {
23
+ }
24
+ releaseDescription() {
25
+ }
26
+ shouldCompleteOpen() {
27
+ }
28
+ /* c8 ignore next 3 */
29
+ init() {
30
+ }
31
+ abort() {
32
+ var _a;
33
+ this.releaseDescription();
34
+ (_a = this.abortController) == null ? void 0 : _a.abort();
35
+ }
36
+ hostConnected() {
37
+ this.init();
38
+ }
39
+ hostDisconnected() {
40
+ if (!this.isPersistent) {
41
+ this.abort();
42
+ }
43
+ }
44
+ }
45
+ //# sourceMappingURL=InteractionController.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["InteractionController.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2024 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport type { ReactiveController } from 'lit';\nimport { AbstractOverlay } from './AbstractOverlay.dev.js'\n\nexport enum InteractionTypes {\n 'click',\n 'hover',\n 'longpress',\n}\n\nexport class InteractionController implements ReactiveController {\n abortController!: AbortController;\n\n get activelyOpening(): boolean {\n return false;\n }\n\n type!: InteractionTypes;\n\n constructor(public host: AbstractOverlay, public target: HTMLElement, private isPersistent = false) {\n this.host.addController(this);\n this.prepareDescription(this.target);\n if (this.isPersistent) {\n this.init();\n }\n }\n\n prepareDescription(_: HTMLElement): void {}\n\n releaseDescription(): void {}\n\n shouldCompleteOpen(): void {}\n\n /* c8 ignore next 3 */\n init(): void {\n // Abstract init() method.\n }\n\n abort(): void {\n this.releaseDescription();\n this.abortController?.abort();\n }\n\n hostConnected(): void {\n this.init();\n }\n\n hostDisconnected(): void {\n if (!this.isPersistent) {\n this.abort();\n }\n }\n}\n"],
5
+ "mappings": ";AAeO,WAAK,mBAAL,kBAAKA,sBAAL;AACH,EAAAA,oCAAA;AACA,EAAAA,oCAAA;AACA,EAAAA,oCAAA;AAHQ,SAAAA;AAAA,GAAA;AAML,aAAM,sBAAoD;AAAA,EAS7D,YAAmB,MAA8B,QAA6B,eAAe,OAAO;AAAjF;AAA8B;AAA6B;AAC1E,SAAK,KAAK,cAAc,IAAI;AAC5B,SAAK,mBAAmB,KAAK,MAAM;AACnC,QAAI,KAAK,cAAc;AACnB,WAAK,KAAK;AAAA,IACd;AAAA,EACJ;AAAA,EAZA,IAAI,kBAA2B;AAC3B,WAAO;AAAA,EACX;AAAA,EAYA,mBAAmB,GAAsB;AAAA,EAAC;AAAA,EAE1C,qBAA2B;AAAA,EAAC;AAAA,EAE5B,qBAA2B;AAAA,EAAC;AAAA;AAAA,EAG5B,OAAa;AAAA,EAEb;AAAA,EAEA,QAAc;AAjDlB;AAkDQ,SAAK,mBAAmB;AACxB,eAAK,oBAAL,mBAAsB;AAAA,EAC1B;AAAA,EAEA,gBAAsB;AAClB,SAAK,KAAK;AAAA,EACd;AAAA,EAEA,mBAAyB;AACrB,QAAI,CAAC,KAAK,cAAc;AACpB,WAAK,MAAM;AAAA,IACf;AAAA,EACJ;AACJ;",
6
+ "names": ["InteractionTypes"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";export var InteractionTypes=(t=>(t[t.click=0]="click",t[t.hover=1]="hover",t[t.longpress=2]="longpress",t))(InteractionTypes||{});export class InteractionController{constructor(e,r,t=!1){this.host=e;this.target=r;this.isPersistent=t;this.host.addController(this),this.prepareDescription(this.target),this.isPersistent&&this.init()}get activelyOpening(){return!1}prepareDescription(e){}releaseDescription(){}shouldCompleteOpen(){}init(){}abort(){var e;this.releaseDescription(),(e=this.abortController)==null||e.abort()}hostConnected(){this.init()}hostDisconnected(){this.isPersistent||this.abort()}}
2
+ //# sourceMappingURL=InteractionController.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["InteractionController.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2024 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport type { ReactiveController } from 'lit';\nimport { AbstractOverlay } from './AbstractOverlay.js';\n\nexport enum InteractionTypes {\n 'click',\n 'hover',\n 'longpress',\n}\n\nexport class InteractionController implements ReactiveController {\n abortController!: AbortController;\n\n get activelyOpening(): boolean {\n return false;\n }\n\n type!: InteractionTypes;\n\n constructor(public host: AbstractOverlay, public target: HTMLElement, private isPersistent = false) {\n this.host.addController(this);\n this.prepareDescription(this.target);\n if (this.isPersistent) {\n this.init();\n }\n }\n\n prepareDescription(_: HTMLElement): void {}\n\n releaseDescription(): void {}\n\n shouldCompleteOpen(): void {}\n\n /* c8 ignore next 3 */\n init(): void {\n // Abstract init() method.\n }\n\n abort(): void {\n this.releaseDescription();\n this.abortController?.abort();\n }\n\n hostConnected(): void {\n this.init();\n }\n\n hostDisconnected(): void {\n if (!this.isPersistent) {\n this.abort();\n }\n }\n}\n"],
5
+ "mappings": "aAeO,WAAK,kBAAAA,IACRA,IAAA,iBACAA,IAAA,iBACAA,IAAA,yBAHQA,IAAA,sBAML,aAAM,qBAAoD,CAS7D,YAAmBC,EAA8BC,EAA6BC,EAAe,GAAO,CAAjF,UAAAF,EAA8B,YAAAC,EAA6B,kBAAAC,EAC1E,KAAK,KAAK,cAAc,IAAI,EAC5B,KAAK,mBAAmB,KAAK,MAAM,EAC/B,KAAK,cACL,KAAK,KAAK,CAElB,CAZA,IAAI,iBAA2B,CAC3B,MAAO,EACX,CAYA,mBAAmBC,EAAsB,CAAC,CAE1C,oBAA2B,CAAC,CAE5B,oBAA2B,CAAC,CAG5B,MAAa,CAEb,CAEA,OAAc,CAjDlB,IAAAC,EAkDQ,KAAK,mBAAmB,GACxBA,EAAA,KAAK,kBAAL,MAAAA,EAAsB,OAC1B,CAEA,eAAsB,CAClB,KAAK,KAAK,CACd,CAEA,kBAAyB,CAChB,KAAK,cACN,KAAK,MAAM,CAEnB,CACJ",
6
+ "names": ["InteractionTypes", "host", "target", "isPersistent", "_", "_a"]
7
+ }
@@ -0,0 +1,21 @@
1
+ import { InteractionController, InteractionTypes } from './InteractionController.js';
2
+ export declare const LONGPRESS_INSTRUCTIONS: {
3
+ touch: string;
4
+ keyboard: string;
5
+ mouse: string;
6
+ };
7
+ export declare class LongpressController extends InteractionController {
8
+ type: InteractionTypes;
9
+ get activelyOpening(): boolean;
10
+ protected longpressState: null | 'potential' | 'opening' | 'pressed';
11
+ releaseDescription: () => void;
12
+ private timeout;
13
+ handleLongpress(): void;
14
+ handlePointerdown(event: PointerEvent): void;
15
+ private handlePointerup;
16
+ private handleKeydown;
17
+ private handleKeyup;
18
+ prepareDescription(trigger: HTMLElement): void;
19
+ shouldCompleteOpen(): void;
20
+ init(): void;
21
+ }
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+ import {
3
+ isAndroid,
4
+ isIOS
5
+ } from "@spectrum-web-components/shared/src/platform.js";
6
+ import { conditionAttributeWithId } from "@spectrum-web-components/base/src/condition-attribute-with-id.js";
7
+ import { randomID } from "@spectrum-web-components/shared/src/random-id.js";
8
+ import { noop } from "./AbstractOverlay.dev.js";
9
+ import { InteractionController, InteractionTypes } from "./InteractionController.dev.js";
10
+ const LONGPRESS_DURATION = 300;
11
+ export const LONGPRESS_INSTRUCTIONS = {
12
+ touch: "Double tap and long press for additional options",
13
+ keyboard: "Press Space or Alt+Down Arrow for additional options",
14
+ mouse: "Click and hold for additional options"
15
+ };
16
+ export class LongpressController extends InteractionController {
17
+ constructor() {
18
+ super(...arguments);
19
+ this.type = InteractionTypes.longpress;
20
+ this.longpressState = null;
21
+ this.releaseDescription = noop;
22
+ this.handlePointerup = () => {
23
+ clearTimeout(this.timeout);
24
+ if (!this.target)
25
+ return;
26
+ this.longpressState = this.host.state === "opening" ? "pressed" : null;
27
+ document.removeEventListener("pointerup", this.handlePointerup);
28
+ document.removeEventListener("pointercancel", this.handlePointerup);
29
+ };
30
+ }
31
+ get activelyOpening() {
32
+ return this.longpressState === "opening" || this.longpressState === "pressed";
33
+ }
34
+ handleLongpress() {
35
+ this.host.open = true;
36
+ this.longpressState = this.longpressState === "potential" ? "opening" : "pressed";
37
+ }
38
+ handlePointerdown(event) {
39
+ if (!this.target)
40
+ return;
41
+ if (event.button !== 0)
42
+ return;
43
+ this.longpressState = "potential";
44
+ document.addEventListener("pointerup", this.handlePointerup);
45
+ document.addEventListener("pointercancel", this.handlePointerup);
46
+ const triggerHandlesLongpress = "holdAffordance" in this.target;
47
+ if (triggerHandlesLongpress)
48
+ return;
49
+ this.timeout = setTimeout(() => {
50
+ if (!this.target)
51
+ return;
52
+ this.target.dispatchEvent(
53
+ new CustomEvent("longpress", {
54
+ bubbles: true,
55
+ composed: true,
56
+ detail: {
57
+ source: "pointer"
58
+ }
59
+ })
60
+ );
61
+ }, LONGPRESS_DURATION);
62
+ }
63
+ handleKeydown(event) {
64
+ const { code, altKey } = event;
65
+ if (altKey && code === "ArrowDown") {
66
+ event.stopPropagation();
67
+ event.stopImmediatePropagation();
68
+ }
69
+ }
70
+ handleKeyup(event) {
71
+ const { code, altKey } = event;
72
+ if (code === "Space" || altKey && code === "ArrowDown") {
73
+ if (!this.target) {
74
+ return;
75
+ }
76
+ event.stopPropagation();
77
+ this.target.dispatchEvent(
78
+ new CustomEvent("longpress", {
79
+ bubbles: true,
80
+ composed: true,
81
+ detail: {
82
+ source: "keyboard"
83
+ }
84
+ })
85
+ );
86
+ setTimeout(() => {
87
+ this.longpressState = null;
88
+ });
89
+ }
90
+ }
91
+ prepareDescription(trigger) {
92
+ if (
93
+ // do not reapply until target is recycled
94
+ this.releaseDescription !== noop || // require "longpress content" to apply relationship
95
+ !this.host.elements.length
96
+ ) {
97
+ return;
98
+ }
99
+ const longpressDescription = document.createElement("div");
100
+ longpressDescription.id = `longpress-describedby-descriptor-${randomID()}`;
101
+ const messageType = isIOS() || isAndroid() ? "touch" : "keyboard";
102
+ longpressDescription.textContent = LONGPRESS_INSTRUCTIONS[messageType];
103
+ longpressDescription.slot = "longpress-describedby-descriptor";
104
+ const triggerParent = trigger.getRootNode();
105
+ const overlayParent = this.host.getRootNode();
106
+ if (triggerParent === overlayParent) {
107
+ this.host.append(longpressDescription);
108
+ } else {
109
+ longpressDescription.hidden = !("host" in triggerParent);
110
+ trigger.insertAdjacentElement("afterend", longpressDescription);
111
+ }
112
+ const releaseDescription = conditionAttributeWithId(
113
+ trigger,
114
+ "aria-describedby",
115
+ [longpressDescription.id]
116
+ );
117
+ this.releaseDescription = () => {
118
+ releaseDescription();
119
+ longpressDescription.remove();
120
+ this.releaseDescription = noop;
121
+ };
122
+ }
123
+ shouldCompleteOpen() {
124
+ this.longpressState = this.longpressState === "pressed" ? null : this.longpressState;
125
+ }
126
+ init() {
127
+ var _a;
128
+ (_a = this.abortController) == null ? void 0 : _a.abort();
129
+ this.abortController = new AbortController();
130
+ const { signal } = this.abortController;
131
+ this.target.addEventListener(
132
+ "longpress",
133
+ () => this.handleLongpress(),
134
+ { signal }
135
+ );
136
+ this.target.addEventListener(
137
+ "pointerdown",
138
+ (event) => this.handlePointerdown(event),
139
+ { signal }
140
+ );
141
+ this.prepareDescription(this.target);
142
+ if (this.target.holdAffordance) {
143
+ return;
144
+ }
145
+ this.target.addEventListener(
146
+ "keydown",
147
+ (event) => this.handleKeydown(event),
148
+ { signal }
149
+ );
150
+ this.target.addEventListener(
151
+ "keyup",
152
+ (event) => this.handleKeyup(event),
153
+ { signal }
154
+ );
155
+ }
156
+ }
157
+ //# sourceMappingURL=LongpressController.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["LongpressController.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2024 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 isAndroid,\n isIOS,\n} from '@spectrum-web-components/shared/src/platform.js';\nimport { conditionAttributeWithId } from '@spectrum-web-components/base/src/condition-attribute-with-id.js';\nimport { randomID } from '@spectrum-web-components/shared/src/random-id.js';\n\nimport { noop } from './AbstractOverlay.dev.js'\nimport { InteractionController, InteractionTypes } from './InteractionController.dev.js'\n\nconst LONGPRESS_DURATION = 300;\nexport const LONGPRESS_INSTRUCTIONS = {\n touch: 'Double tap and long press for additional options',\n keyboard: 'Press Space or Alt+Down Arrow for additional options',\n mouse: 'Click and hold for additional options',\n};\n\ntype LongpressEvent = {\n source: 'pointer' | 'keyboard';\n};\n\nexport class LongpressController extends InteractionController {\n override type = InteractionTypes.longpress;\n\n override get activelyOpening(): boolean {\n return (\n this.longpressState === 'opening' ||\n this.longpressState === 'pressed'\n );\n }\n\n protected longpressState: null | 'potential' | 'opening' | 'pressed' = null;\n\n override releaseDescription = noop;\n\n private timeout!: ReturnType<typeof setTimeout>;\n\n handleLongpress(): void {\n this.host.open = true;\n this.longpressState =\n this.longpressState === 'potential' ? 'opening' : 'pressed';\n }\n\n handlePointerdown(event: PointerEvent): void {\n if (!this.target) return;\n if (event.button !== 0) return;\n this.longpressState = 'potential';\n document.addEventListener('pointerup', this.handlePointerup);\n document.addEventListener('pointercancel', this.handlePointerup);\n // Only dispatch longpress event if the trigger element isn't doing it for us.\n const triggerHandlesLongpress = 'holdAffordance' in this.target;\n if (triggerHandlesLongpress) return;\n this.timeout = setTimeout(() => {\n if (!this.target) return;\n this.target.dispatchEvent(\n new CustomEvent<LongpressEvent>('longpress', {\n bubbles: true,\n composed: true,\n detail: {\n source: 'pointer',\n },\n })\n );\n }, LONGPRESS_DURATION);\n }\n\n private handlePointerup = (): void => {\n clearTimeout(this.timeout);\n if (!this.target) return;\n // When triggered by the pointer, the last of `opened`\n // or `pointerup` should move the `longpressState` to\n // `null` so that the earlier event can void the \"light\n // dismiss\" and keep the Overlay open.\n this.longpressState = this.host.state === 'opening' ? 'pressed' : null;\n document.removeEventListener('pointerup', this.handlePointerup);\n document.removeEventListener('pointercancel', this.handlePointerup);\n };\n\n private handleKeydown(event: KeyboardEvent): void {\n const { code, altKey } = event;\n if (altKey && code === 'ArrowDown') {\n event.stopPropagation();\n event.stopImmediatePropagation();\n }\n }\n\n private handleKeyup(event: KeyboardEvent): void {\n const { code, altKey } = event;\n if (code === 'Space' || (altKey && code === 'ArrowDown')) {\n if (!this.target) {\n return;\n }\n event.stopPropagation();\n this.target.dispatchEvent(\n new CustomEvent<LongpressEvent>('longpress', {\n bubbles: true,\n composed: true,\n detail: {\n source: 'keyboard',\n },\n })\n );\n setTimeout(() => {\n this.longpressState = null;\n });\n }\n }\n\n override prepareDescription(trigger: HTMLElement): void {\n if (\n // do not reapply until target is recycled\n this.releaseDescription !== noop ||\n // require \"longpress content\" to apply relationship\n !this.host.elements.length\n ) {\n return;\n }\n\n const longpressDescription = document.createElement('div');\n longpressDescription.id = `longpress-describedby-descriptor-${randomID()}`;\n const messageType = isIOS() || isAndroid() ? 'touch' : 'keyboard';\n longpressDescription.textContent = LONGPRESS_INSTRUCTIONS[messageType];\n longpressDescription.slot = 'longpress-describedby-descriptor';\n const triggerParent = trigger.getRootNode() as HTMLElement;\n const overlayParent = this.host.getRootNode() as HTMLElement;\n // Manage the placement of the helper element in an accessible place with\n // the lowest chance of negatively affecting the layout of the page.\n if (triggerParent === overlayParent) {\n // Trigger and Overlay in same DOM tree...\n // Append helper element to Overlay.\n this.host.append(longpressDescription);\n } else {\n // If Trigger in <body>, hide helper\n longpressDescription.hidden = !('host' in triggerParent);\n // Trigger and Overlay in different DOM tree, Trigger in shadow tree...\n // Insert helper element after Trigger.\n trigger.insertAdjacentElement('afterend', longpressDescription);\n }\n\n const releaseDescription = conditionAttributeWithId(\n trigger,\n 'aria-describedby',\n [longpressDescription.id]\n );\n this.releaseDescription = () => {\n releaseDescription();\n longpressDescription.remove();\n this.releaseDescription = noop;\n };\n }\n\n override shouldCompleteOpen(): void {\n // When triggered by the pointer, the last of `opened`\n // or `pointerup` should move the `longpressState` to\n // `null` so that the earlier event can void the \"light\n // dismiss\" and keep the Overlay open.\n this.longpressState =\n this.longpressState === 'pressed' ? null : this.longpressState;\n }\n\n override init(): void {\n // Clean up listeners if they've already been bound\n this.abortController?.abort();\n this.abortController = new AbortController();\n const { signal } = this.abortController;\n this.target.addEventListener(\n 'longpress',\n () => this.handleLongpress(),\n { signal }\n );\n this.target.addEventListener(\n 'pointerdown',\n (event: PointerEvent) => this.handlePointerdown(event),\n { signal }\n );\n\n this.prepareDescription(this.target);\n if (\n (this.target as HTMLElement & { holdAffordance: boolean })\n .holdAffordance\n ) {\n // Only bind keyboard events when the trigger element isn't doing it for us.\n return;\n }\n this.target.addEventListener(\n 'keydown',\n (event: KeyboardEvent) => this.handleKeydown(event),\n { signal }\n );\n this.target.addEventListener(\n 'keyup',\n (event: KeyboardEvent) => this.handleKeyup(event),\n { signal }\n );\n }\n}\n"],
5
+ "mappings": ";AAYA;AAAA,EACI;AAAA,EACA;AAAA,OACG;AACP,SAAS,gCAAgC;AACzC,SAAS,gBAAgB;AAEzB,SAAS,YAAY;AACrB,SAAS,uBAAuB,wBAAwB;AAExD,MAAM,qBAAqB;AACpB,aAAM,yBAAyB;AAAA,EAClC,OAAO;AAAA,EACP,UAAU;AAAA,EACV,OAAO;AACX;AAMO,aAAM,4BAA4B,sBAAsB;AAAA,EAAxD;AAAA;AACH,SAAS,OAAO,iBAAiB;AASjC,SAAU,iBAA6D;AAEvE,SAAS,qBAAqB;AAiC9B,SAAQ,kBAAkB,MAAY;AAClC,mBAAa,KAAK,OAAO;AACzB,UAAI,CAAC,KAAK;AAAQ;AAKlB,WAAK,iBAAiB,KAAK,KAAK,UAAU,YAAY,YAAY;AAClE,eAAS,oBAAoB,aAAa,KAAK,eAAe;AAC9D,eAAS,oBAAoB,iBAAiB,KAAK,eAAe;AAAA,IACtE;AAAA;AAAA,EApDA,IAAa,kBAA2B;AACpC,W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AA,IACJ;AACA,SAAK,OAAO;AAAA,MACR;AAAA,MACA,CAAC,UAAyB,KAAK,cAAc,KAAK;AAAA,MAClD,EAAE,OAAO;AAAA,IACb;AACA,SAAK,OAAO;AAAA,MACR;AAAA,MACA,CAAC,UAAyB,KAAK,YAAY,KAAK;AAAA,MAChD,EAAE,OAAO;AAAA,IACb;AAAA,EACJ;AACJ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";import{isAndroid as a,isIOS as d}from"@spectrum-web-components/shared/src/platform.js";import{conditionAttributeWithId as p}from"@spectrum-web-components/base/src/condition-attribute-with-id.js";import{randomID as l}from"@spectrum-web-components/shared/src/random-id.js";import{noop as r}from"./AbstractOverlay.js";import{InteractionController as h,InteractionTypes as c}from"./InteractionController.js";const g=300;export const LONGPRESS_INSTRUCTIONS={touch:"Double tap and long press for additional options",keyboard:"Press Space or Alt+Down Arrow for additional options",mouse:"Click and hold for additional options"};export class LongpressController extends h{constructor(){super(...arguments);this.type=c.longpress;this.longpressState=null;this.releaseDescription=r;this.handlePointerup=()=>{clearTimeout(this.timeout),this.target&&(this.longpressState=this.host.state==="opening"?"pressed":null,document.removeEventListener("pointerup",this.handlePointerup),document.removeEventListener("pointercancel",this.handlePointerup))}}get activelyOpening(){return this.longpressState==="opening"||this.longpressState==="pressed"}handleLongpress(){this.host.open=!0,this.longpressState=this.longpressState==="potential"?"opening":"pressed"}handlePointerdown(e){!this.target||e.button!==0||(this.longpressState="potential",document.addEventListener("pointerup",this.handlePointerup),document.addEventListener("pointercancel",this.handlePointerup),"holdAffordance"in this.target)||(this.timeout=setTimeout(()=>{this.target&&this.target.dispatchEvent(new CustomEvent("longpress",{bubbles:!0,composed:!0,detail:{source:"pointer"}}))},g))}handleKeydown(e){const{code:t,altKey:o}=e;o&&t==="ArrowDown"&&(e.stopPropagation(),e.stopImmediatePropagation())}handleKeyup(e){const{code:t,altKey:o}=e;if(t==="Space"||o&&t==="ArrowDown"){if(!this.target)return;e.stopPropagation(),this.target.dispatchEvent(new CustomEvent("longpress",{bubbles:!0,composed:!0,detail:{source:"keyboard"}})),setTimeout(()=>{this.longpressState=null})}}prepareDescription(e){if(this.releaseDescription!==r||!this.host.elements.length)return;const t=document.createElement("div");t.id=`longpress-describedby-descriptor-${l()}`;const o=d()||a()?"touch":"keyboard";t.textContent=LONGPRESS_INSTRUCTIONS[o],t.slot="longpress-describedby-descriptor";const n=e.getRootNode(),s=this.host.getRootNode();n===s?this.host.append(t):(t.hidden=!("host"in n),e.insertAdjacentElement("afterend",t));const i=p(e,"aria-describedby",[t.id]);this.releaseDescription=()=>{i(),t.remove(),this.releaseDescription=r}}shouldCompleteOpen(){this.longpressState=this.longpressState==="pressed"?null:this.longpressState}init(){var t;(t=this.abortController)==null||t.abort(),this.abortController=new AbortController;const{signal:e}=this.abortController;this.target.addEventListener("longpress",()=>this.handleLongpress(),{signal:e}),this.target.addEventListener("pointerdown",o=>this.handlePointerdown(o),{signal:e}),this.prepareDescription(this.target),!this.target.holdAffordance&&(this.target.addEventListener("keydown",o=>this.handleKeydown(o),{signal:e}),this.target.addEventListener("keyup",o=>this.handleKeyup(o),{signal:e}))}}
2
+ //# sourceMappingURL=LongpressController.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["LongpressController.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2024 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 isAndroid,\n isIOS,\n} from '@spectrum-web-components/shared/src/platform.js';\nimport { conditionAttributeWithId } from '@spectrum-web-components/base/src/condition-attribute-with-id.js';\nimport { randomID } from '@spectrum-web-components/shared/src/random-id.js';\n\nimport { noop } from './AbstractOverlay.js';\nimport { InteractionController, InteractionTypes } from './InteractionController.js';\n\nconst LONGPRESS_DURATION = 300;\nexport const LONGPRESS_INSTRUCTIONS = {\n touch: 'Double tap and long press for additional options',\n keyboard: 'Press Space or Alt+Down Arrow for additional options',\n mouse: 'Click and hold for additional options',\n};\n\ntype LongpressEvent = {\n source: 'pointer' | 'keyboard';\n};\n\nexport class LongpressController extends InteractionController {\n override type = InteractionTypes.longpress;\n\n override get activelyOpening(): boolean {\n return (\n this.longpressState === 'opening' ||\n this.longpressState === 'pressed'\n );\n }\n\n protected longpressState: null | 'potential' | 'opening' | 'pressed' = null;\n\n override releaseDescription = noop;\n\n private timeout!: ReturnType<typeof setTimeout>;\n\n handleLongpress(): void {\n this.host.open = true;\n this.longpressState =\n this.longpressState === 'potential' ? 'opening' : 'pressed';\n }\n\n handlePointerdown(event: PointerEvent): void {\n if (!this.target) return;\n if (event.button !== 0) return;\n this.longpressState = 'potential';\n document.addEventListener('pointerup', this.handlePointerup);\n document.addEventListener('pointercancel', this.handlePointerup);\n // Only dispatch longpress event if the trigger element isn't doing it for us.\n const triggerHandlesLongpress = 'holdAffordance' in this.target;\n if (triggerHandlesLongpress) return;\n this.timeout = setTimeout(() => {\n if (!this.target) return;\n this.target.dispatchEvent(\n new CustomEvent<LongpressEvent>('longpress', {\n bubbles: true,\n composed: true,\n detail: {\n source: 'pointer',\n },\n })\n );\n }, LONGPRESS_DURATION);\n }\n\n private handlePointerup = (): void => {\n clearTimeout(this.timeout);\n if (!this.target) return;\n // When triggered by the pointer, the last of `opened`\n // or `pointerup` should move the `longpressState` to\n // `null` so that the earlier event can void the \"light\n // dismiss\" and keep the Overlay open.\n this.longpressState = this.host.state === 'opening' ? 'pressed' : null;\n document.removeEventListener('pointerup', this.handlePointerup);\n document.removeEventListener('pointercancel', this.handlePointerup);\n };\n\n private handleKeydown(event: KeyboardEvent): void {\n const { code, altKey } = event;\n if (altKey && code === 'ArrowDown') {\n event.stopPropagation();\n event.stopImmediatePropagation();\n }\n }\n\n private handleKeyup(event: KeyboardEvent): void {\n const { code, altKey } = event;\n if (code === 'Space' || (altKey && code === 'ArrowDown')) {\n if (!this.target) {\n return;\n }\n event.stopPropagation();\n this.target.dispatchEvent(\n new CustomEvent<LongpressEvent>('longpress', {\n bubbles: true,\n composed: true,\n detail: {\n source: 'keyboard',\n },\n })\n );\n setTimeout(() => {\n this.longpressState = null;\n });\n }\n }\n\n override prepareDescription(trigger: HTMLElement): void {\n if (\n // do not reapply until target is recycled\n this.releaseDescription !== noop ||\n // require \"longpress content\" to apply relationship\n !this.host.elements.length\n ) {\n return;\n }\n\n const longpressDescription = document.createElement('div');\n longpressDescription.id = `longpress-describedby-descriptor-${randomID()}`;\n const messageType = isIOS() || isAndroid() ? 'touch' : 'keyboard';\n longpressDescription.textContent = LONGPRESS_INSTRUCTIONS[messageType];\n longpressDescription.slot = 'longpress-describedby-descriptor';\n const triggerParent = trigger.getRootNode() as HTMLElement;\n const overlayParent = this.host.getRootNode() as HTMLElement;\n // Manage the placement of the helper element in an accessible place with\n // the lowest chance of negatively affecting the layout of the page.\n if (triggerParent === overlayParent) {\n // Trigger and Overlay in same DOM tree...\n // Append helper element to Overlay.\n this.host.append(longpressDescription);\n } else {\n // If Trigger in <body>, hide helper\n longpressDescription.hidden = !('host' in triggerParent);\n // Trigger and Overlay in different DOM tree, Trigger in shadow tree...\n // Insert helper element after Trigger.\n trigger.insertAdjacentElement('afterend', longpressDescription);\n }\n\n const releaseDescription = conditionAttributeWithId(\n trigger,\n 'aria-describedby',\n [longpressDescription.id]\n );\n this.releaseDescription = () => {\n releaseDescription();\n longpressDescription.remove();\n this.releaseDescription = noop;\n };\n }\n\n override shouldCompleteOpen(): void {\n // When triggered by the pointer, the last of `opened`\n // or `pointerup` should move the `longpressState` to\n // `null` so that the earlier event can void the \"light\n // dismiss\" and keep the Overlay open.\n this.longpressState =\n this.longpressState === 'pressed' ? null : this.longpressState;\n }\n\n override init(): void {\n // Clean up listeners if they've already been bound\n this.abortController?.abort();\n this.abortController = new AbortController();\n const { signal } = this.abortController;\n this.target.addEventListener(\n 'longpress',\n () => this.handleLongpress(),\n { signal }\n );\n this.target.addEventListener(\n 'pointerdown',\n (event: PointerEvent) => this.handlePointerdown(event),\n { signal }\n );\n\n this.prepareDescription(this.target);\n if (\n (this.target as HTMLElement & { holdAffordance: boolean })\n .holdAffordance\n ) {\n // Only bind keyboard events when the trigger element isn't doing it for us.\n return;\n }\n this.target.addEventListener(\n 'keydown',\n (event: KeyboardEvent) => this.handleKeydown(event),\n { signal }\n );\n this.target.addEventListener(\n 'keyup',\n (event: KeyboardEvent) => this.handleKeyup(event),\n { signal }\n );\n }\n}\n"],
5
+ "mappings": "aAYA,OACI,aAAAA,EACA,SAAAC,MACG,kDACP,OAAS,4BAAAC,MAAgC,mEACzC,OAAS,YAAAC,MAAgB,mDAEzB,OAAS,QAAAC,MAAY,uBACrB,OAAS,yBAAAC,EAAuB,oBAAAC,MAAwB,6BAExD,MAAMC,EAAqB,IACpB,aAAM,uBAAyB,CAClC,MAAO,mDACP,SAAU,uDACV,MAAO,uCACX,EAMO,aAAM,4BAA4BF,CAAsB,CAAxD,kCACH,KAAS,KAAOC,EAAiB,UASjC,KAAU,eAA6D,KAEvE,KAAS,mBAAqBF,EAiC9B,KAAQ,gBAAkB,IAAY,CAClC,aAAa,KAAK,OAAO,EACpB,KAAK,SAKV,KAAK,eAAiB,KAAK,KAAK,QAAU,UAAY,UAAY,KAClE,SAAS,oBAAoB,YAAa,KAAK,eAAe,EAC9D,SAAS,oBAAoB,gBAAiB,KAAK,eAAe,EACtE,EApDA,IAAa,iBAA2B,CACpC,OACI,KAAK,iBAAmB,WACxB,KAAK,iBAAmB,SAEhC,CAQA,iBAAwB,CACpB,KAAK,KAAK,KAAO,GACjB,KAAK,eACD,KAAK,iBAAmB,YAAc,UAAY,SAC1D,CAEA,kBAAkBI,EAA2B,CACrC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AqB,OAAS,EAAE,SAAUE,GAG1CH,EAAQ,sBAAsB,WAAYC,CAAoB,GAGlE,MAAMI,EAAqBd,EACvBS,EACA,mBACA,CAACC,EAAqB,EAAE,CAC5B,EACA,KAAK,mBAAqB,IAAM,CAC5BI,EAAmB,EACnBJ,EAAqB,OAAO,EAC5B,KAAK,mBAAqBR,CAC9B,CACJ,CAES,oBAA2B,CAKhC,KAAK,eACD,KAAK,iBAAmB,UAAY,KAAO,KAAK,cACxD,CAES,MAAa,CA5K1B,IAAAa,GA8KQA,EAAA,KAAK,kBAAL,MAAAA,EAAsB,QACtB,KAAK,gBAAkB,IAAI,gBAC3B,KAAM,CAAE,OAAAC,CAAO,EAAI,KAAK,gBACxB,KAAK,OAAO,iBACR,YACA,IAAM,KAAK,gBAAgB,EAC3B,CAAE,OAAAA,CAAO,CACb,EACA,KAAK,OAAO,iBACR,cACCV,GAAwB,KAAK,kBAAkBA,CAAK,EACrD,CAAE,OAAAU,CAAO,CACb,EAEA,KAAK,mBAAmB,KAAK,MAAM,EAE9B,MAAK,OACD,iBAKT,KAAK,OAAO,iBACR,UACCV,GAAyB,KAAK,cAAcA,CAAK,EAClD,CAAE,OAAAU,CAAO,CACb,EACA,KAAK,OAAO,iBACR,QACCV,GAAyB,KAAK,YAAYA,CAAK,EAChD,CAAE,OAAAU,CAAO,CACb,EACJ,CACJ",
6
+ "names": ["isAndroid", "isIOS", "conditionAttributeWithId", "randomID", "noop", "InteractionController", "InteractionTypes", "LONGPRESS_DURATION", "event", "code", "altKey", "trigger", "longpressDescription", "messageType", "triggerParent", "overlayParent", "releaseDescription", "_a", "signal"]
7
+ }