@adobe/spectrum-wc-core 2.0.0-beta.2 → 2.0.0-beta.4

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 (157) hide show
  1. package/README.md +1 -1
  2. package/dist/components/accordion/Accordion.base.js +28 -22
  3. package/dist/components/accordion/Accordion.base.js.map +1 -1
  4. package/dist/components/accordion/AccordionItem.base.d.ts +16 -6
  5. package/dist/components/accordion/AccordionItem.base.js +6 -3
  6. package/dist/components/accordion/AccordionItem.base.js.map +1 -1
  7. package/dist/components/action-group/ActionGroup.base.d.ts +108 -0
  8. package/dist/components/action-group/ActionGroup.base.js +53 -0
  9. package/dist/components/action-group/ActionGroup.base.js.map +1 -0
  10. package/dist/components/action-group/ActionGroup.types.d.ts +17 -0
  11. package/dist/components/action-group/ActionGroup.types.js +12 -0
  12. package/dist/components/action-group/ActionGroup.types.js.map +1 -0
  13. package/dist/components/action-group/index.d.ts +13 -0
  14. package/dist/components/action-group/index.js +3 -0
  15. package/dist/components/alert-banner/AlertBanner.base.js +11 -10
  16. package/dist/components/alert-banner/AlertBanner.base.js.map +1 -1
  17. package/dist/components/asset/Asset.base.d.ts +89 -10
  18. package/dist/components/asset/Asset.base.js +117 -12
  19. package/dist/components/asset/Asset.base.js.map +1 -1
  20. package/dist/components/asset/Asset.types.d.ts +20 -2
  21. package/dist/components/asset/Asset.types.js +10 -2
  22. package/dist/components/asset/Asset.types.js.map +1 -1
  23. package/dist/components/asset/index.js +3 -3
  24. package/dist/components/avatar/Avatar.base.js +18 -22
  25. package/dist/components/avatar/Avatar.base.js.map +1 -1
  26. package/dist/components/badge/Badge.base.d.ts +24 -8
  27. package/dist/components/badge/Badge.base.js +22 -17
  28. package/dist/components/badge/Badge.base.js.map +1 -1
  29. package/dist/components/button/Button.base.d.ts +20 -10
  30. package/dist/components/button/Button.base.js +17 -12
  31. package/dist/components/button/Button.base.js.map +1 -1
  32. package/dist/components/button-group/ButtonGroup.base.js +19 -12
  33. package/dist/components/button-group/ButtonGroup.base.js.map +1 -1
  34. package/dist/components/card/Card.base.d.ts +95 -46
  35. package/dist/components/card/Card.base.js +71 -23
  36. package/dist/components/card/Card.base.js.map +1 -1
  37. package/dist/components/card/Card.types.d.ts +1 -0
  38. package/dist/components/card/Card.types.js +2 -2
  39. package/dist/components/card/Card.types.js.map +1 -1
  40. package/dist/components/card/index.js +3 -3
  41. package/dist/components/divider/Divider.base.js +13 -8
  42. package/dist/components/divider/Divider.base.js.map +1 -1
  43. package/dist/components/dropzone/Dropzone.base.d.ts +74 -0
  44. package/dist/components/dropzone/Dropzone.base.js +82 -0
  45. package/dist/components/dropzone/Dropzone.base.js.map +1 -0
  46. package/dist/components/dropzone/Dropzone.types.d.ts +43 -0
  47. package/dist/components/dropzone/Dropzone.types.js +15 -0
  48. package/dist/components/dropzone/Dropzone.types.js.map +1 -0
  49. package/dist/components/dropzone/index.d.ts +13 -0
  50. package/dist/components/dropzone/index.js +3 -0
  51. package/dist/components/icon/Icon.base.d.ts +11 -7
  52. package/dist/components/icon/Icon.base.js +13 -20
  53. package/dist/components/icon/Icon.base.js.map +1 -1
  54. package/dist/components/illustrated-message/IllustratedMessage.base.d.ts +22 -8
  55. package/dist/components/illustrated-message/IllustratedMessage.base.js +33 -20
  56. package/dist/components/illustrated-message/IllustratedMessage.base.js.map +1 -1
  57. package/dist/components/infield-button/InfieldButton.base.d.ts +28 -0
  58. package/dist/components/infield-button/InfieldButton.base.js +22 -0
  59. package/dist/components/infield-button/InfieldButton.base.js.map +1 -0
  60. package/dist/components/infield-button/InfieldButton.types.d.ts +13 -0
  61. package/dist/components/infield-button/InfieldButton.types.js +11 -0
  62. package/dist/components/infield-button/InfieldButton.types.js.map +1 -0
  63. package/dist/components/infield-button/index.d.ts +13 -0
  64. package/dist/components/infield-button/index.js +3 -0
  65. package/dist/components/meter/Meter.base.js +11 -9
  66. package/dist/components/meter/Meter.base.js.map +1 -1
  67. package/dist/components/popover/Popover.base.d.ts +1 -21
  68. package/dist/components/popover/Popover.base.js +57 -77
  69. package/dist/components/popover/Popover.base.js.map +1 -1
  70. package/dist/components/progress-circle/ProgressCircle.base.d.ts +0 -1
  71. package/dist/components/progress-circle/ProgressCircle.base.js +26 -22
  72. package/dist/components/progress-circle/ProgressCircle.base.js.map +1 -1
  73. package/dist/components/status-light/StatusLight.base.d.ts +1 -1
  74. package/dist/components/status-light/StatusLight.base.js +12 -9
  75. package/dist/components/status-light/StatusLight.base.js.map +1 -1
  76. package/dist/components/tabs/TabPanel.base.d.ts +1 -1
  77. package/dist/components/tabs/TabPanel.base.js.map +1 -1
  78. package/dist/components/tabs/Tabs.base.js +44 -32
  79. package/dist/components/tabs/Tabs.base.js.map +1 -1
  80. package/dist/components/tooltip/Tooltip.base.js +57 -22
  81. package/dist/components/tooltip/Tooltip.base.js.map +1 -1
  82. package/dist/controllers/color-controller/src/color-controller.js +45 -44
  83. package/dist/controllers/color-controller/src/color-controller.js.map +1 -1
  84. package/dist/controllers/drag-and-drop-controller/index.d.ts +12 -0
  85. package/dist/controllers/drag-and-drop-controller/index.js +2 -0
  86. package/dist/controllers/drag-and-drop-controller/src/drag-and-drop-controller.d.ts +68 -0
  87. package/dist/controllers/drag-and-drop-controller/src/drag-and-drop-controller.js +56 -0
  88. package/dist/controllers/drag-and-drop-controller/src/drag-and-drop-controller.js.map +1 -0
  89. package/dist/controllers/focusgroup-navigation-controller/src/focusgroup-navigation-controller.d.ts +1 -1
  90. package/dist/controllers/focusgroup-navigation-controller/src/focusgroup-navigation-controller.js.map +1 -1
  91. package/dist/controllers/index.d.ts +6 -2
  92. package/dist/controllers/index.js +15 -11
  93. package/dist/controllers/language-resolution.d.ts +1 -1
  94. package/dist/controllers/language-resolution.js.map +1 -1
  95. package/dist/controllers/page-scroll-lock-controller/index.d.ts +12 -0
  96. package/dist/controllers/page-scroll-lock-controller/index.js +2 -0
  97. package/dist/controllers/{page-scroll-lock.js → page-scroll-lock-controller/src/page-scroll-lock.js} +1 -1
  98. package/dist/controllers/page-scroll-lock-controller/src/page-scroll-lock.js.map +1 -0
  99. package/dist/controllers/slot-presence-controller/index.d.ts +12 -0
  100. package/dist/controllers/slot-presence-controller/index.js +2 -0
  101. package/dist/controllers/slot-presence-controller/src/slot-presence-controller.d.ts +57 -0
  102. package/dist/controllers/slot-presence-controller/src/slot-presence-controller.js +44 -0
  103. package/dist/controllers/slot-presence-controller/src/slot-presence-controller.js.map +1 -0
  104. package/dist/controllers/slot-text-controller/index.d.ts +12 -0
  105. package/dist/controllers/slot-text-controller/index.js +2 -0
  106. package/dist/controllers/slot-text-controller/src/slot-text-controller.d.ts +92 -0
  107. package/dist/controllers/slot-text-controller/src/slot-text-controller.js +53 -0
  108. package/dist/controllers/slot-text-controller/src/slot-text-controller.js.map +1 -0
  109. package/dist/controllers/trigger-press-controller/index.d.ts +12 -0
  110. package/dist/controllers/trigger-press-controller/index.js +2 -0
  111. package/dist/controllers/trigger-press-controller/src/trigger-press-controller.d.ts +149 -0
  112. package/dist/controllers/trigger-press-controller/src/trigger-press-controller.js +43 -0
  113. package/dist/controllers/trigger-press-controller/src/trigger-press-controller.js.map +1 -0
  114. package/dist/directives/index.d.ts +1 -1
  115. package/dist/element/define-element.js +1 -1
  116. package/dist/element/define-element.js.map +1 -1
  117. package/dist/element/index.d.ts +1 -1
  118. package/dist/element/index.js +2 -2
  119. package/dist/element/spectrum-element.d.ts +58 -15
  120. package/dist/element/spectrum-element.js +56 -37
  121. package/dist/element/spectrum-element.js.map +1 -1
  122. package/dist/element/version.d.ts +3 -3
  123. package/dist/element/version.js +1 -1
  124. package/dist/element/version.js.map +1 -1
  125. package/dist/mixins/index.d.ts +0 -2
  126. package/dist/mixins/index.js +4 -6
  127. package/dist/mixins/linear-progress-mixin.d.ts +1 -2
  128. package/dist/mixins/linear-progress-mixin.js +35 -34
  129. package/dist/mixins/linear-progress-mixin.js.map +1 -1
  130. package/dist/mixins/pending-mixin.js +12 -11
  131. package/dist/mixins/pending-mixin.js.map +1 -1
  132. package/dist/mixins/sized-mixin.d.ts +28 -0
  133. package/dist/mixins/sized-mixin.js +6 -6
  134. package/dist/mixins/sized-mixin.js.map +1 -1
  135. package/dist/utils/dev-validation.d.ts +88 -0
  136. package/dist/utils/dev-validation.js +33 -0
  137. package/dist/utils/dev-validation.js.map +1 -0
  138. package/dist/utils/index.d.ts +2 -0
  139. package/dist/utils/index.js +12 -10
  140. package/dist/utils/is-focus-visible-in-tree.d.ts +33 -0
  141. package/dist/utils/is-focus-visible-in-tree.js +11 -0
  142. package/dist/utils/is-focus-visible-in-tree.js.map +1 -0
  143. package/dist/utils/resolve-trigger.js.map +1 -1
  144. package/package.json +213 -18
  145. package/CHANGELOG.md +0 -125
  146. package/dist/_virtual/_@oxc-project_runtime@0.124.0/helpers/defineProperty.js +0 -12
  147. package/dist/_virtual/_@oxc-project_runtime@0.124.0/helpers/toPrimitive.js +0 -14
  148. package/dist/_virtual/_@oxc-project_runtime@0.124.0/helpers/toPropertyKey.js +0 -9
  149. package/dist/_virtual/_@oxc-project_runtime@0.124.0/helpers/typeof.js +0 -11
  150. package/dist/controllers/page-scroll-lock.js.map +0 -1
  151. package/dist/mixins/observe-slot-presence.d.ts +0 -12
  152. package/dist/mixins/observe-slot-presence.js +0 -40
  153. package/dist/mixins/observe-slot-presence.js.map +0 -1
  154. package/dist/mixins/observe-slot-text.d.ts +0 -11
  155. package/dist/mixins/observe-slot-text.js +0 -60
  156. package/dist/mixins/observe-slot-text.js.map +0 -1
  157. /package/dist/controllers/{page-scroll-lock.d.ts → page-scroll-lock-controller/src/page-scroll-lock.d.ts} +0 -0
@@ -1,11 +1,11 @@
1
1
  import { __decorate as e } from "../../_virtual/_@oxc-project_runtime@0.124.0/helpers/decorate.js";
2
2
  import { POPOVER_VALID_PLACEMENTS as t, POPOVER_VALID_SIZES as n } from "./Popover.types.js";
3
3
  import { property as r } from "lit/decorators.js";
4
- import { PageScrollLockController as i, PlacementController as a } from "@adobe/spectrum-wc-core/controllers/index.js";
5
- import { SpectrumElement as o } from "@adobe/spectrum-wc-core/element/index.js";
6
- import { deepContains as s, getActiveElement as c, isTopDismissible as l, physicalSide as u, registerDismissible as d, resolveTrigger as f, runAfterTransition as p, unregisterDismissible as m } from "@adobe/spectrum-wc-core/utils/index.js";
4
+ import { PageScrollLockController as i, PlacementController as a, TriggerPressController as o } from "@adobe/spectrum-wc-core/controllers/index.js";
5
+ import { SpectrumElement as s } from "@adobe/spectrum-wc-core/element/index.js";
6
+ import { deepContains as c, getActiveElement as l, isTopDismissible as u, physicalSide as d, registerDismissible as f, resolveTrigger as p, runAfterTransition as m, unregisterDismissible as h, validateEnum as g, warnIf as _ } from "@adobe/spectrum-wc-core/utils/index.js";
7
7
  //#region components/popover/Popover.base.ts
8
- var h, g = [
8
+ var v, y = [
9
9
  "placement",
10
10
  "offset",
11
11
  "crossOffset",
@@ -14,40 +14,22 @@ var h, g = [
14
14
  "hideArrow",
15
15
  "tipPadding",
16
16
  "size"
17
- ], _ = class extends o {
17
+ ], b = class extends s {
18
18
  constructor(...e) {
19
- super(...e), this.open = !1, this.modal = !1, this.accessibleLabel = "", this.placement = "bottom", this.hideArrow = !1, this.offset = 8, this.crossOffset = 0, this.containerPadding = 8, this.shouldFlip = !0, this.tipPadding = 8, this.triggerElement = null, this.manual = !1, this._placementController = new a(this), this._scrollLock = new i(this), this._interactiveElement = null, this._anchor = null, this._clickTrigger = null, this._triggerPointerActive = !1, this._pressEndAbort = null, this._dismissedByTriggerPress = !1, this._closeSource = null, this._syncingOpen = !1, this._suppressOpenEvent = !1, this._hasCompletedFirstUpdate = !1, this._pendingFocusOnOpen = !1, this._onTriggerPressStart = () => {
20
- this._triggerPointerActive = !0, this._pressEndAbort = new AbortController();
21
- let { signal: e } = this._pressEndAbort;
22
- document.addEventListener("pointerup", this._onTriggerPressEnd, {
23
- capture: !0,
24
- once: !0,
25
- signal: e
26
- }), document.addEventListener("pointercancel", this._onTriggerPressEnd, {
27
- capture: !0,
28
- once: !0,
29
- signal: e
30
- });
31
- }, this._onTriggerPressEnd = (e) => {
32
- var t;
33
- (t = this._pressEndAbort) == null || t.abort(), !(e.type === "pointerup" && e.composedPath().includes(this._clickTrigger)) && (this._triggerPointerActive = !1);
34
- }, this._onTriggerClick = () => {
35
- let e = this._dismissedByTriggerPress;
36
- this._triggerPointerActive = !1, this._dismissedByTriggerPress = !1, !e && (this.open = !this.open);
37
- }, this._onBeforeToggle = (e) => {
19
+ super(...e), this.open = !1, this.modal = !1, this.accessibleLabel = "", this.placement = "bottom", this.hideArrow = !1, this.offset = 8, this.crossOffset = 0, this.containerPadding = 8, this.shouldFlip = !0, this.tipPadding = 8, this.triggerElement = null, this.manual = !1, this._placementController = new a(this), this._scrollLock = new i(this), this._interactiveElement = null, this._anchor = null, this._pressGuard = new o(this), this._closeSource = null, this._syncingOpen = !1, this._suppressOpenEvent = !1, this._hasCompletedFirstUpdate = !1, this._pendingFocusOnOpen = !1, this._onBeforeToggle = (e) => {
38
20
  if (e.newState === "open") this._dispatchOpen();
39
21
  else {
40
22
  var t;
41
23
  let e = (t = this._closeSource) == null ? "outside" : t;
42
- e === "outside" && this._triggerPointerActive && (this._dismissedByTriggerPress = !0);
24
+ e === "outside" && this._pressGuard.noteNativeDismiss();
43
25
  let r = this._isFocusWithin();
44
26
  if (this._syncOpen(!1), this._dispatchClose(e), this._closeTeardown(), r) {
45
27
  var n;
46
- (n = this._interactiveElement) == null || n.focus();
28
+ (n = this._interactiveElement) == null || n.focus({ preventScroll: !0 });
47
29
  }
48
30
  }
49
31
  }, this._onCancel = (e) => {
50
- if (!l(this)) {
32
+ if (!u(this)) {
51
33
  e.preventDefault();
52
34
  return;
53
35
  }
@@ -71,15 +53,21 @@ var h, g = [
71
53
  }
72
54
  disconnectedCallback() {
73
55
  var e;
74
- super.disconnectedCallback(), this._placementController.stop(), (e = this._cancelAfterTransition) == null || e.call(this), m(this), this._removeEscapeListener(), this._scrollLock.unlock(), this._removeTriggerListeners(), this._clearTriggerAria(), this._interactiveElement = null, this._anchor = null;
56
+ super.disconnectedCallback(), this._placementController.stop(), (e = this._cancelAfterTransition) == null || e.call(this), h(this), this._removeEscapeListener(), this._scrollLock.unlock(), this._clearTriggerAria(), this._interactiveElement = null, this._anchor = null;
75
57
  }
76
58
  update(e) {
77
- var t;
78
- if ((t = window.__swc) != null && t.DEBUG) {
79
- let e = this.constructor;
80
- e.VALID_PLACEMENTS.includes(this.placement) || window.__swc.warn(this, `<${this.localName}> element expects the "placement" attribute to be one of the following:`, "https://spectrum-web-components.adobe.com/?path=/docs/components-popover--docs", { issues: [...e.VALID_PLACEMENTS] });
81
- }
82
- super.update(e);
59
+ let t = this.constructor;
60
+ g(this, {
61
+ prop: "placement",
62
+ value: this.placement,
63
+ valid: t.VALID_PLACEMENTS,
64
+ url: "https://spectrum-web-components.adobe.com/?path=/docs/components-popover--docs"
65
+ }), this.size !== void 0 && g(this, {
66
+ prop: "size",
67
+ value: this.size,
68
+ valid: t.VALID_SIZES,
69
+ url: "https://spectrum-web-components.adobe.com/?path=/docs/components-popover--docs"
70
+ }), super.update(e);
83
71
  }
84
72
  updated(e) {
85
73
  if (super.updated(e), (e.has("for") || e.has("triggerElement") || e.has("modal") || e.has("manual")) && this._wireTrigger(), e.has("open")) {
@@ -89,28 +77,21 @@ var h, g = [
89
77
  this._hasCompletedFirstUpdate = !0;
90
78
  }
91
79
  _positioningChanged(e) {
92
- return g.some((t) => e.has(t));
80
+ return y.some((t) => e.has(t));
93
81
  }
94
82
  _wireTrigger() {
95
- var e;
96
- let { trigger: t, interactiveElement: n } = f(this, {
83
+ let { trigger: e, interactiveElement: t } = p(this, {
97
84
  for: this.for,
98
85
  triggerElement: this.triggerElement instanceof HTMLElement ? this.triggerElement : null
99
86
  });
100
- !t && this.for && (e = window.__swc) != null && e.DEBUG && window.__swc.warn(this, `<${this.localName}> for="${this.for}" did not resolve to an element in the current tree root. Check that the referenced id exists in the same document tree root.`, "https://spectrum-web-components.adobe.com/?path=/docs/components-popover--docs", { level: "high" }), this._interactiveElement && this._interactiveElement !== n && this._clearTriggerAria(), this._interactiveElement = n, this._anchor = this.triggerElement && !(this.triggerElement instanceof HTMLElement) ? this.triggerElement : t, n && (n.ariaControlsElements = [this], n.setAttribute("aria-expanded", String(this.open)), n.setAttribute("aria-haspopup", "dialog"));
101
- let r = this.manual ? null : t;
102
- r !== this._clickTrigger && (this._removeTriggerListeners(), r && (r.addEventListener("pointerdown", this._onTriggerPressStart, { capture: !0 }), r.addEventListener("touchstart", this._onTriggerPressStart, { capture: !0 }), r.addEventListener("click", this._onTriggerClick), this._clickTrigger = r));
103
- }
104
- _removeTriggerListeners() {
105
- var e, t, n;
106
- (e = this._clickTrigger) == null || e.removeEventListener("pointerdown", this._onTriggerPressStart, { capture: !0 }), (t = this._clickTrigger) == null || t.removeEventListener("touchstart", this._onTriggerPressStart, { capture: !0 }), (n = this._clickTrigger) == null || n.removeEventListener("click", this._onTriggerClick), this._clickTrigger = null;
87
+ _(this, !e && !!this.for, `<${this.localName}> for="${this.for}" did not resolve to an element in the current tree root. Check that the referenced id exists in the same document tree root.`, "https://spectrum-web-components.adobe.com/?path=/docs/components-popover--docs", { level: "high" }), this._interactiveElement && this._interactiveElement !== t && this._clearTriggerAria(), this._interactiveElement = t, this._anchor = this.triggerElement && !(this.triggerElement instanceof HTMLElement) ? this.triggerElement : e, t && (t.ariaControlsElements = [this], t.setAttribute("aria-expanded", String(this.open)), t.setAttribute("aria-haspopup", "dialog")), this._pressGuard.attach(this.manual ? null : e, { onToggle: () => this.open = !this.open });
107
88
  }
108
89
  _clearTriggerAria() {
109
90
  let e = this._interactiveElement;
110
91
  e && (e.ariaControlsElements = null, e.removeAttribute("aria-expanded"), e.removeAttribute("aria-haspopup"));
111
92
  }
112
93
  _isFocusWithin() {
113
- return s(this, c());
94
+ return c(this, l());
114
95
  }
115
96
  _startPositioning() {
116
97
  var e;
@@ -129,39 +110,38 @@ var h, g = [
129
110
  tipElement: n ? (e = this.tipElement) == null ? void 0 : e : void 0,
130
111
  tipPadding: this.tipPadding,
131
112
  onPlacementChange: (e) => {
132
- this.setAttribute("actual-placement", u(e)), this._pendingFocusOnOpen && (this._pendingFocusOnOpen = !1, this._focusSurface());
113
+ this.setAttribute("actual-placement", d(e)), this._pendingFocusOnOpen && (this._pendingFocusOnOpen = !1, this._focusSurface());
133
114
  }
134
115
  });
135
116
  }
136
117
  _show(e = !1) {
137
- var t;
138
- let n = this.internalElement;
139
- if (n) {
140
- if ((t = window.__swc) != null && t.DEBUG && !this.accessibleLabel.trim() && window.__swc.warn(this, `<${this.localName}> must have an "accessible-label" attribute to name the dialog for assistive technology.`, "https://spectrum-web-components.adobe.com/?path=/docs/components-popover--docs", { issues: ["accessible-label"] }), this.modal) {
141
- let t = n, r = t.open;
118
+ let t = this.internalElement;
119
+ if (t) {
120
+ if (_(this, !this.accessibleLabel.trim(), `<${this.localName}> must have an "accessible-label" attribute to name the dialog for assistive technology.`, "https://spectrum-web-components.adobe.com/?path=/docs/components-popover--docs", { issues: ["accessible-label"] }), this.modal) {
121
+ let n = t, r = n.open;
142
122
  if (!r) {
143
- let { scrollX: e, scrollY: n } = window;
123
+ let { scrollX: e, scrollY: t } = window;
144
124
  try {
145
- t.showModal(), r = !0;
125
+ n.showModal(), r = !0;
146
126
  } catch (e) {
147
127
  r = !1;
148
128
  }
149
- window.scrollTo(e, n);
129
+ window.scrollTo(e, t);
150
130
  }
151
131
  if (!r) return;
152
- this._removeEscapeListener(), this._scrollLock.lock(), d(this), e || this._dispatchOpen();
132
+ this._removeEscapeListener(), this._scrollLock.lock(), f(this), e || this._dispatchOpen();
153
133
  } else {
154
- let t = n.matches(":popover-open");
155
- if (!t) {
134
+ let n = t.matches(":popover-open");
135
+ if (!n) {
156
136
  this._suppressOpenEvent = e;
157
137
  try {
158
- n.showPopover(), t = !0;
138
+ t.showPopover(), n = !0;
159
139
  } catch (e) {
160
- this._suppressOpenEvent = !1, t = !1;
140
+ this._suppressOpenEvent = !1, n = !1;
161
141
  }
162
142
  }
163
- if (!t) return;
164
- this._scrollLock.unlock(), d(this), this._addEscapeListener(), this._pendingFocusOnOpen = this._hasCompletedFirstUpdate;
143
+ if (!n) return;
144
+ this._scrollLock.unlock(), f(this), this._addEscapeListener(), this._pendingFocusOnOpen = this._hasCompletedFirstUpdate;
165
145
  }
166
146
  this._startPositioning();
167
147
  }
@@ -185,7 +165,7 @@ var h, g = [
185
165
  }
186
166
  }
187
167
  _closeTeardown() {
188
- m(this), this._removeEscapeListener(), this._scrollLock.unlock();
168
+ h(this), this._removeEscapeListener(), this._scrollLock.unlock();
189
169
  }
190
170
  _stopPositioningWhenClosed() {
191
171
  this.open || (this._placementController.stop(), this.removeAttribute("actual-placement"));
@@ -195,7 +175,7 @@ var h, g = [
195
175
  }
196
176
  _addEscapeListener() {
197
177
  this._escapeListener || (this._escapeListener = (e) => {
198
- e.key === "Escape" && l(this) && (this._closeSource = "escape");
178
+ e.key === "Escape" && u(this) && (this._closeSource = "escape");
199
179
  }, document.addEventListener("keydown", this._escapeListener, { capture: !0 }));
200
180
  }
201
181
  _removeEscapeListener() {
@@ -236,48 +216,48 @@ var h, g = [
236
216
  e();
237
217
  return;
238
218
  }
239
- this._cancelAfterTransition = p(r, () => {
219
+ this._cancelAfterTransition = m(r, () => {
240
220
  this._cancelAfterTransition = void 0, e();
241
221
  }, { fallback: t });
242
222
  }
243
223
  };
244
- h = _, h.VALID_PLACEMENTS = t, h.VALID_SIZES = n, e([r({
224
+ v = b, v.VALID_PLACEMENTS = t, v.VALID_SIZES = n, e([r({
245
225
  type: Boolean,
246
226
  reflect: !0
247
- })], _.prototype, "open", void 0), e([r({
227
+ })], b.prototype, "open", void 0), e([r({
248
228
  type: Boolean,
249
229
  reflect: !0
250
- })], _.prototype, "modal", void 0), e([r({
230
+ })], b.prototype, "modal", void 0), e([r({
251
231
  type: String,
252
232
  attribute: "accessible-label"
253
- })], _.prototype, "accessibleLabel", void 0), e([r({
233
+ })], b.prototype, "accessibleLabel", void 0), e([r({
254
234
  type: String,
255
235
  reflect: !0
256
- })], _.prototype, "placement", void 0), e([r({
236
+ })], b.prototype, "placement", void 0), e([r({
257
237
  type: String,
258
238
  reflect: !0
259
- })], _.prototype, "size", void 0), e([r({
239
+ })], b.prototype, "size", void 0), e([r({
260
240
  type: Boolean,
261
241
  reflect: !0,
262
242
  attribute: "hide-arrow"
263
- })], _.prototype, "hideArrow", void 0), e([r({ type: Number })], _.prototype, "offset", void 0), e([r({
243
+ })], b.prototype, "hideArrow", void 0), e([r({ type: Number })], b.prototype, "offset", void 0), e([r({
264
244
  type: Number,
265
245
  attribute: "cross-offset"
266
- })], _.prototype, "crossOffset", void 0), e([r({
246
+ })], b.prototype, "crossOffset", void 0), e([r({
267
247
  type: Number,
268
248
  attribute: "container-padding"
269
- })], _.prototype, "containerPadding", void 0), e([r({
249
+ })], b.prototype, "containerPadding", void 0), e([r({
270
250
  type: Boolean,
271
251
  reflect: !0,
272
252
  attribute: "should-flip"
273
- })], _.prototype, "shouldFlip", void 0), e([r({
253
+ })], b.prototype, "shouldFlip", void 0), e([r({
274
254
  type: Number,
275
255
  attribute: "tip-padding"
276
- })], _.prototype, "tipPadding", void 0), e([r({ type: String })], _.prototype, "for", void 0), e([r({ attribute: !1 })], _.prototype, "triggerElement", void 0), e([r({
256
+ })], b.prototype, "tipPadding", void 0), e([r({ type: String })], b.prototype, "for", void 0), e([r({ attribute: !1 })], b.prototype, "triggerElement", void 0), e([r({
277
257
  type: Boolean,
278
258
  reflect: !0
279
- })], _.prototype, "manual", void 0);
259
+ })], b.prototype, "manual", void 0);
280
260
  //#endregion
281
- export { _ as PopoverBase };
261
+ export { b as PopoverBase };
282
262
 
283
263
  //# sourceMappingURL=Popover.base.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Popover.base.js","names":[],"sources":["../../../components/popover/Popover.base.ts"],"sourcesContent":["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { PropertyValues } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport {\n PageScrollLockController,\n PlacementController,\n type VirtualTrigger,\n} from '@adobe/spectrum-wc-core/controllers/index.js';\nimport { SpectrumElement } from '@adobe/spectrum-wc-core/element/index.js';\nimport {\n deepContains,\n getActiveElement,\n isTopDismissible,\n physicalSide,\n registerDismissible,\n resolveTrigger,\n runAfterTransition,\n unregisterDismissible,\n} from '@adobe/spectrum-wc-core/utils/index.js';\n\nimport {\n type Placement,\n POPOVER_VALID_PLACEMENTS,\n POPOVER_VALID_SIZES,\n type PopoverCloseSource,\n type PopoverSize,\n} from './Popover.types.js';\n\n/**\n * The `aria-controls` relationship is wired via the element-reference IDL\n * (`ariaControlsElements`) so it works across shadow boundaries. The property\n * is Baseline but not yet in every TypeScript DOM lib, so it is declared here.\n */\ninterface ARIAControlsElements {\n ariaControlsElements?: readonly Element[] | null;\n}\n\n/** Properties whose change re-anchors the surface while open. */\nconst POSITIONING_PROPERTIES = [\n 'placement',\n 'offset',\n 'crossOffset',\n 'containerPadding',\n 'shouldFlip',\n 'hideArrow',\n 'tipPadding',\n 'size',\n] as const;\n\n/**\n * Abstract base for the popover component. Owns the popover's behavior: the\n * dual-mode dialog lifecycle (`showPopover()` / `showModal()`), trigger and ARIA\n * wiring, positioning through the `PlacementController`, dismissal coordination,\n * and `swc-*` event dispatch. The concrete SWC subclass adds only the styles, the\n * render template, and the shadow-DOM element getters (`internalElement`,\n * `tipElement`) it overrides.\n *\n * @slot - Popover content. Free-form; consumers slot whatever pattern they build.\n */\nexport abstract class PopoverBase extends SpectrumElement {\n /**\n * @internal\n *\n * The valid placement values for the popover. Narrowed in downstream\n * first-party subclasses per the proxy pattern.\n */\n static readonly VALID_PLACEMENTS: readonly Placement[] =\n POPOVER_VALID_PLACEMENTS;\n\n /**\n * @internal\n *\n * The valid fixed sizes for the popover.\n */\n static readonly VALID_SIZES: readonly PopoverSize[] = POPOVER_VALID_SIZES;\n\n /**\n * Whether the popover is open.\n *\n * @default false\n */\n @property({ type: Boolean, reflect: true })\n public open = false;\n\n /**\n * Opt in to blocking modal behavior (`<dialog>.showModal()`): focus trap,\n * background inert, native `role=\"dialog\"`. When unset, the popover uses\n * `popover=\"auto\"` light-dismiss behavior.\n *\n * @default false\n */\n @property({ type: Boolean, reflect: true })\n public modal = false;\n\n /**\n * Accessible name for the popover's dialog surface, forwarded as `aria-label`\n * to the internal element. Required in both modes (the surface is a dialog);\n * the component dev-warns when opened without one.\n */\n @property({ type: String, attribute: 'accessible-label' })\n public accessibleLabel = '';\n\n /**\n * The placement of the popover relative to its trigger.\n *\n * @default 'bottom'\n */\n @property({ type: String, reflect: true })\n public placement: Placement = 'bottom';\n\n /**\n * Optional fixed size. When set, the popover uses a fixed inline size\n * (`s` → 336px, `m` → 416px, `l` → 576px); when unset, it fits its contents.\n */\n @property({ type: String, reflect: true })\n public size?: PopoverSize;\n\n // The flipped placement is kept off the public property surface (a readonly\n // property is still writable at runtime and could desync from the controller).\n // It is reflected as the internal `actual-placement` host attribute for CSS\n // only, mirroring Tooltip; consumers read the requested side via `placement`.\n\n /**\n * Hide the popover's arrow (tip). The arrow is shown by default.\n *\n * @default false\n */\n @property({ type: Boolean, reflect: true, attribute: 'hide-arrow' })\n public hideArrow = false;\n\n /**\n * Main-axis offset in pixels from the trigger.\n *\n * @default 8\n */\n @property({ type: Number })\n public offset = 8;\n\n /**\n * Cross-axis offset in pixels from the trigger.\n *\n * @default 0\n */\n @property({ type: Number, attribute: 'cross-offset' })\n public crossOffset = 0;\n\n /**\n * Distance from the viewport edge for the `flip` and `shift` middleware.\n *\n * Positioning implementation detail. Set by first-party components; excluded\n * from the public API. Users are not expected to set it.\n *\n * @internal\n * @default 8\n */\n @property({ type: Number, attribute: 'container-padding' })\n public containerPadding = 8;\n\n /**\n * Allow the popover to flip to the opposite side when constrained. When\n * `false`, the popover stays in the requested placement.\n *\n * @default true\n */\n @property({ type: Boolean, reflect: true, attribute: 'should-flip' })\n public shouldFlip = true;\n\n /**\n * Minimum inset of the tip from the popover's corners, passed to the\n * `PlacementController`'s `arrow` middleware as its `padding`.\n *\n * Positioning implementation detail. Set by first-party components; excluded\n * from the public API. Users are not expected to set it.\n *\n * @internal\n * @default 8\n */\n @property({ type: Number, attribute: 'tip-padding' })\n public tipPadding = 8;\n\n /**\n * ID of the trigger element in the same document tree root.\n */\n @property({ type: String })\n public for?: string;\n\n /**\n * Direct trigger reference. Overrides `for` when both are set. Use for\n * cross-shadow-root triggers or programmatic wiring.\n */\n @property({ attribute: false })\n public triggerElement: HTMLElement | VirtualTrigger | null = null;\n\n /**\n * Suppress the automatic click-to-toggle wiring on the resolved trigger. When\n * set, control visibility through the `open` property instead. ARIA\n * relationship wiring still applies.\n *\n * @default false\n */\n @property({ type: Boolean, reflect: true })\n public manual = false;\n\n // ──────────────────────────────\n // RENDERING-LAYER HANDLES\n // ──────────────────────────────\n\n /**\n * The internal top-layer element (a `<div popover>` or a `<dialog>`) the\n * lifecycle drives. Mandatory: the SWC rendering layer must implement this to\n * return the rendered `.swc-Popover` element from the shadow DOM (it may still\n * return `null` before the first render, which the lifecycle guards against).\n */\n protected abstract get internalElement(): HTMLElement | null;\n\n /**\n * The arrow tip element passed to the `PlacementController`. Optional: returns\n * `null` in the base class (no arrow), and the SWC rendering layer overrides it\n * to return the rendered `.swc-Popover-tip` element when an arrow is shown.\n */\n protected get tipElement(): HTMLElement | null {\n return null;\n }\n\n /**\n * The arrow's height in pixels, added to the trigger gap when the arrow is\n * shown. Returns `0` in the base class; the SWC rendering layer overrides it\n * with the token-derived value so the gap stays in sync with the tip, keeping\n * the base free of any coupling to the surface's CSS.\n */\n protected get arrowHeight(): number {\n return 0;\n }\n\n // ──────────────────\n // STATE\n // ──────────────────\n\n private _placementController = new PlacementController(this);\n\n /**\n * Page-scroll lock for modal mode. Reference-counted at module scope so stacked\n * modal surfaces coordinate a single lock and restore the original overflow\n * exactly once. See {@link PageScrollLockController}.\n */\n private _scrollLock = new PageScrollLockController(this);\n\n /** The trigger's AT-facing element that receives ARIA wiring. */\n private _interactiveElement: (HTMLElement & ARIAControlsElements) | null =\n null;\n\n /** The positioning anchor (an element or a `VirtualTrigger`). */\n private _anchor: HTMLElement | VirtualTrigger | null = null;\n\n /** The element the click-to-toggle listeners are currently attached to. */\n private _clickTrigger: HTMLElement | null = null;\n\n /**\n * True between a trigger press start (`pointerdown`/`touchstart`) and its\n * `click`, so a light-dismiss inside that window is attributed to the press.\n * Both events open it, covering touch (where the dismiss can fire off\n * `touchstart` before `pointerdown`).\n */\n private _triggerPointerActive = false;\n\n /** Cancels the pending press-end listeners armed in `_onTriggerPressStart`. */\n private _pressEndAbort: AbortController | null = null;\n\n /**\n * Set when the trigger press light-dismissed an open popover (an `'outside'`\n * close observed while `_triggerPointerActive`), so the trailing `click` of\n * that same gesture is read as the close rather than a reopen.\n */\n private _dismissedByTriggerPress = false;\n\n /** Cause of the in-progress close, read when dispatching `swc-close`. */\n private _closeSource: PopoverCloseSource | null = null;\n\n /** Suppresses the open/close effect when `open` is synced from a native event. */\n private _syncingOpen = false;\n\n /**\n * Suppresses the next `swc-open` dispatch. Set when re-showing an\n * already-open popover (a `modal` toggle swaps the internal element), so the\n * mode swap does not emit a second `swc-open` with no intervening close.\n */\n private _suppressOpenEvent = false;\n\n /** Document Escape listener (default mode) used to label the close source. */\n private _escapeListener?: (event: KeyboardEvent) => void;\n\n /** Tears down the in-flight `_afterTransition` wiring (listener + fallback timer). */\n private _cancelAfterTransition?: () => void;\n\n /**\n * Set after the first render. Auto-focus on open is suppressed until then so an\n * initially-`open` popover (server-rendered or a static demo) does not steal\n * focus on mount; only an open triggered after the element is live moves focus.\n */\n private _hasCompletedFirstUpdate = false;\n\n /**\n * Set when a default-mode open should move focus into the dialog surface;\n * consumed by the first placement compute so focus lands after the surface is\n * anchored on screen (focusing it at its 0,0 reset origin would shift layout).\n * Modal mode moves focus natively via `showModal()`.\n */\n private _pendingFocusOnOpen = false;\n\n // ──────────────────\n // LIFECYCLE\n // ──────────────────\n\n public override disconnectedCallback(): void {\n super.disconnectedCallback();\n this._placementController.stop();\n this._cancelAfterTransition?.();\n unregisterDismissible(this);\n this._removeEscapeListener();\n this._scrollLock.unlock();\n this._removeTriggerListeners();\n this._clearTriggerAria();\n this._interactiveElement = null;\n this._anchor = null;\n // Focus restoration on close is handled elsewhere (default mode in\n // `_onBeforeToggle`, modal mode natively). Removing an open popover from the\n // DOM is not: the browser has already moved focus to `<body>` before this\n // runs, so there is no trigger to restore to.\n }\n\n protected override update(changedProperties: PropertyValues): void {\n if (window.__swc?.DEBUG) {\n // Validate against the static so subclasses that narrow the placement set\n // (the proxy pattern) get their own valid values checked at runtime.\n const constructor = this.constructor as typeof PopoverBase;\n if (!constructor.VALID_PLACEMENTS.includes(this.placement)) {\n window.__swc.warn(\n this,\n `<${this.localName}> element expects the \"placement\" attribute to be one of the following:`,\n 'https://spectrum-web-components.adobe.com/?path=/docs/components-popover--docs',\n {\n issues: [...constructor.VALID_PLACEMENTS],\n }\n );\n }\n }\n super.update(changedProperties);\n }\n\n protected override updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n\n if (\n changedProperties.has('for') ||\n changedProperties.has('triggerElement') ||\n changedProperties.has('modal') ||\n changedProperties.has('manual')\n ) {\n this._wireTrigger();\n }\n\n if (changedProperties.has('open')) {\n if (this._syncingOpen) {\n // The change came from a native event; the element is already in the\n // right state. Just consume the guard.\n this._syncingOpen = false;\n } else if (this.open) {\n this._show();\n } else {\n this._hide();\n }\n this._interactiveElement?.setAttribute(\n 'aria-expanded',\n String(this.open)\n );\n } else if (this.open && changedProperties.has('modal')) {\n // `modal` toggled while open: the render swapped the internal element\n // between a `<div popover=\"auto\">` and a `<dialog>`. Lit removed the old\n // element (the browser closes a disconnected top-layer element), so the\n // newly rendered element is present but never went through its show API.\n // Re-show so the correct mode engages (e.g. `showModal()` traps focus),\n // without re-emitting `swc-open` for a popover that never closed.\n this._show(true);\n } else if (\n this.open &&\n (this._positioningChanged(changedProperties) ||\n changedProperties.has('for') ||\n changedProperties.has('triggerElement'))\n ) {\n // Re-anchor while open when a positioning input or the trigger changes.\n this._startPositioning();\n }\n\n // First render is done: subsequent opens may move focus into the surface.\n this._hasCompletedFirstUpdate = true;\n }\n\n private _positioningChanged(changedProperties: PropertyValues): boolean {\n return POSITIONING_PROPERTIES.some((prop) => changedProperties.has(prop));\n }\n\n // ──────────────────────────\n // TRIGGER + ARIA\n // ──────────────────────────\n\n private _wireTrigger(): void {\n const { trigger, interactiveElement } = resolveTrigger(this, {\n for: this.for,\n triggerElement:\n this.triggerElement instanceof HTMLElement ? this.triggerElement : null,\n });\n\n if (!trigger && this.for && window.__swc?.DEBUG) {\n window.__swc.warn(\n this,\n `<${this.localName}> for=\"${this.for}\" did not resolve to an element in the current tree root. Check that the referenced id exists in the same document tree root.`,\n 'https://spectrum-web-components.adobe.com/?path=/docs/components-popover--docs',\n { level: 'high' }\n );\n }\n\n if (\n this._interactiveElement &&\n this._interactiveElement !== interactiveElement\n ) {\n this._clearTriggerAria();\n }\n\n this._interactiveElement = interactiveElement;\n // A `VirtualTrigger` (non-element) anchors positioning only; an element\n // trigger anchors positioning and carries ARIA.\n this._anchor =\n this.triggerElement && !(this.triggerElement instanceof HTMLElement)\n ? this.triggerElement\n : trigger;\n\n if (interactiveElement) {\n // Durable across open/close cycles; visibility is conveyed by aria-expanded.\n interactiveElement.ariaControlsElements = [this];\n interactiveElement.setAttribute('aria-expanded', String(this.open));\n // The surface is a dialog in both modes, so the trigger always signals it.\n interactiveElement.setAttribute('aria-haspopup', 'dialog');\n }\n\n // Click-to-toggle on the trigger host, unless the consumer drives `open`\n // themselves (`manual`). Listens on the host so clicks bubbling from an inner\n // button are caught. The capturing `pointerdown`/`touchstart` listeners open\n // the reopen-guard gesture window (see `_onTriggerPressStart`).\n const clickTrigger = this.manual ? null : trigger;\n if (clickTrigger !== this._clickTrigger) {\n this._removeTriggerListeners();\n if (clickTrigger) {\n clickTrigger.addEventListener(\n 'pointerdown',\n this._onTriggerPressStart,\n {\n capture: true,\n }\n );\n clickTrigger.addEventListener('touchstart', this._onTriggerPressStart, {\n capture: true,\n });\n clickTrigger.addEventListener('click', this._onTriggerClick);\n this._clickTrigger = clickTrigger;\n }\n }\n // Re-anchoring while open (trigger or positioning input changed) is driven\n // from `updated()`, so this method only wires the trigger and ARIA. Doing it\n // here too would double-start the controller when `updated()` also re-shows\n // or re-anchors in the same cycle (e.g. a `modal` toggle while open).\n }\n\n private _removeTriggerListeners(): void {\n this._clickTrigger?.removeEventListener(\n 'pointerdown',\n this._onTriggerPressStart,\n { capture: true }\n );\n this._clickTrigger?.removeEventListener(\n 'touchstart',\n this._onTriggerPressStart,\n { capture: true }\n );\n this._clickTrigger?.removeEventListener('click', this._onTriggerClick);\n this._clickTrigger = null;\n }\n\n // In the default mode, pressing the (outside) trigger while open is a native\n // light-dismiss: the browser hides the popover before the click fires. Opening\n // the gesture window at press start (capture, before the dismiss) lets\n // `_onBeforeToggle` attribute that close to the press, so `_onTriggerClick`\n // reads the trailing click as a close, not a reopen. Only sets the flag, never\n // clears `_dismissedByTriggerPress`: on touch both `pointerdown` and\n // `touchstart` fire for one press, and the second must not reset a dismissal\n // already recorded (`_onTriggerClick` clears it per gesture).\n private _onTriggerPressStart = (): void => {\n this._triggerPointerActive = true;\n // Catches a press that ends without a click (drag off the trigger, or a\n // cancelled gesture), which would otherwise leave the flag stuck true.\n this._pressEndAbort = new AbortController();\n const { signal } = this._pressEndAbort;\n document.addEventListener('pointerup', this._onTriggerPressEnd, {\n capture: true,\n once: true,\n signal,\n });\n document.addEventListener('pointercancel', this._onTriggerPressEnd, {\n capture: true,\n once: true,\n signal,\n });\n };\n\n private _onTriggerPressEnd = (event: PointerEvent): void => {\n this._pressEndAbort?.abort();\n // A same-target pointerup still gets its own click, which resets the flag\n // itself; resetting it here too would race that click's read of\n // `_dismissedByTriggerPress`. pointercancel never gets a click, so it\n // always resets.\n if (\n event.type === 'pointerup' &&\n event.composedPath().includes(this._clickTrigger as EventTarget)\n ) {\n return;\n }\n this._triggerPointerActive = false;\n };\n\n // If the press light-dismissed the popover (recorded in `_onBeforeToggle`),\n // consume this click so it does not toggle back open; otherwise toggle from the\n // live state. Keying off the real close event makes this correct with or without\n // a native dismiss (e.g. keyboard activation) and needs no timer. (`popovertarget`\n // can't reach the shadow-DOM surface across roots, so the correlation is manual.)\n private _onTriggerClick = (): void => {\n const dismissedByThisGesture = this._dismissedByTriggerPress;\n this._triggerPointerActive = false;\n this._dismissedByTriggerPress = false;\n if (dismissedByThisGesture) {\n return;\n }\n this.open = !this.open;\n };\n\n private _clearTriggerAria(): void {\n const element = this._interactiveElement;\n if (!element) {\n return;\n }\n element.ariaControlsElements = null;\n element.removeAttribute('aria-expanded');\n element.removeAttribute('aria-haspopup');\n }\n\n // Whether focus is currently within the popover's content. `deepContains`\n // crosses shadow boundaries, so focus inside a slotted custom element (e.g. a\n // button's inner control) is detected; the content is slotted, so its DOM\n // ancestors lead back to this host.\n private _isFocusWithin(): boolean {\n return deepContains(this, getActiveElement());\n }\n\n // ──────────────────────────\n // POSITIONING\n // ──────────────────────────\n\n private _startPositioning(): void {\n const floating = this.internalElement;\n if (!floating || !this._anchor) {\n // No element or no anchor to position against (e.g. the trigger was\n // changed to an unresolved id while open). Tear down any prior session so\n // the surface is not left anchored to stale geometry; clearing\n // `actual-placement` also re-gates it hidden until a valid anchor returns.\n this._placementController.stop();\n this.removeAttribute('actual-placement');\n return;\n }\n const showArrow = !this.hideArrow;\n // Clear `actual-placement` to re-gate the surface and tip for this session:\n // `start()` calls `stop()`, which resets the inline `translate` to the 0,0\n // origin until the async first compute re-anchors. The stylesheet reveals the\n // surface and tip only once `actual-placement` is present, so they stay hidden\n // through that window (and a rapid reopen during the close fade) instead of\n // painting at 0,0. Re-set by `onPlacementChange` once the session anchors.\n this.removeAttribute('actual-placement');\n // Add the arrow height to the trigger gap so the surface clears the tip on\n // every side. Applied through the controller's direction-aware main-axis\n // offset, not a CSS margin (a margin only shifts the absolutely-positioned\n // surface on its block-/inline-start sides). `arrowHeight` comes from the\n // rendering layer.\n this._placementController.start(this._anchor, floating, {\n placement: this.placement,\n offset: this.offset + (showArrow ? this.arrowHeight : 0),\n crossOffset: this.crossOffset,\n containerPadding: this.containerPadding,\n shouldFlip: this.shouldFlip,\n tipElement: showArrow ? (this.tipElement ?? undefined) : undefined,\n tipPadding: this.tipPadding,\n onPlacementChange: (next) => {\n // Expose the computed physical side as the `actual-placement` host\n // attribute for CSS: it orients the tip and, by its presence, reveals the\n // surface and tip (gated off until now so the entry fade runs from the\n // anchored position, not the 0,0 origin). The first compute of a session\n // always fires this (`stop()` resets the last-notified placement). The\n // controller skips the compute only for a 0x0 element, but the surface\n // always has border and padded chrome, so it is never zero-sized while\n // open. Not a public property; removed in `_stopPositioningWhenClosed`.\n this.setAttribute('actual-placement', physicalSide(next));\n // Now anchored and revealed: move focus in for a pending default-mode\n // open. Focusing earlier, at the 0,0 origin, would shift layout/scroll.\n if (this._pendingFocusOnOpen) {\n this._pendingFocusOnOpen = false;\n this._focusSurface();\n }\n },\n });\n }\n\n // ──────────────────\n // OPEN/CLOSE\n // ──────────────────\n\n // `reShow` is true when re-engaging the show API for a popover that is already\n // open (a `modal` toggle swaps the internal element). It suppresses a second\n // `swc-open` for a popover that never closed.\n private _show(reShow = false): void {\n const element = this.internalElement;\n if (!element) {\n return;\n }\n // The surface is a dialog in both modes, so it must have an accessible name.\n if (window.__swc?.DEBUG && !this.accessibleLabel.trim()) {\n window.__swc.warn(\n this,\n `<${this.localName}> must have an \"accessible-label\" attribute to name the dialog for assistive technology.`,\n 'https://spectrum-web-components.adobe.com/?path=/docs/components-popover--docs',\n { issues: ['accessible-label'] }\n );\n }\n // Enter the top layer first; only register listeners, the dismissible stack,\n // and positioning once the native show actually succeeds, so a failed\n // `showPopover()`/`showModal()` does not leave the component wired up for a\n // popover that never opened.\n if (this.modal) {\n const dialog = element as HTMLDialogElement;\n let shown = dialog.open;\n if (!shown) {\n // `showModal()` synchronously moves focus into the dialog, scrolling the\n // page to it, and has no `preventScroll` option. Positioning is async, so\n // the surface is still at its 0,0 origin when focus lands. Capture and\n // restore the scroll position around the call; it is synchronous, so the\n // restore is seamless (no paint between).\n const { scrollX, scrollY } = window;\n try {\n dialog.showModal();\n shown = true;\n } catch {\n shown = false;\n }\n window.scrollTo(scrollX, scrollY);\n }\n if (!shown) {\n return;\n }\n // Modal mode uses the native `<dialog>` Escape (`cancel`); drop any\n // default-mode document listener left over from a prior mode.\n this._removeEscapeListener();\n this._scrollLock.lock();\n registerDismissible(this);\n // `<dialog>` modal-mode has no native open event, so dispatch here (unless\n // this is a re-show of an already-open popover).\n if (!reShow) {\n this._dispatchOpen();\n }\n } else {\n let shown = element.matches(':popover-open');\n if (!shown) {\n // `showPopover()` fires `beforetoggle` synchronously, which dispatches\n // `swc-open`; suppress that one dispatch on a re-show.\n this._suppressOpenEvent = reShow;\n try {\n element.showPopover();\n shown = true;\n } catch {\n this._suppressOpenEvent = false;\n shown = false;\n }\n }\n if (!shown) {\n return;\n }\n // Default mode never locks scroll; release a lock left from a prior modal\n // mode (e.g. `modal` toggled false while open).\n this._scrollLock.unlock();\n registerDismissible(this);\n this._addEscapeListener();\n // Move focus into the dialog surface so assistive technology lands inside\n // it (modal mode does this natively via `showModal()`). Deferred to the\n // first placement compute so focus lands once the surface is anchored on\n // screen, not at its 0,0 reset origin. Suppressed on the initial render so\n // an initially-`open` popover does not steal focus.\n this._pendingFocusOnOpen = this._hasCompletedFirstUpdate;\n // `swc-open` is dispatched from the `beforetoggle` listener.\n }\n this._startPositioning();\n }\n\n // Move focus into the open default-mode dialog surface. The surface is a named\n // `role=\"dialog\"` element, so focusing it announces the dialog and seats the\n // user inside it; `preventScroll` because it is already anchored in the top\n // layer. Focus restoration on close is handled by `_onBeforeToggle`.\n private _focusSurface(): void {\n this.internalElement?.focus({ preventScroll: true });\n }\n\n private _hide(): void {\n const element = this.internalElement;\n if (!element) {\n return;\n }\n // Attribute a close source only when actually hiding an open element. Setting\n // it unconditionally would poison the next real close: the initial render\n // calls `_hide()` for the default `open = false`, and a stale `'programmatic'`\n // source would survive (no `beforetoggle` clears it), making the first genuine\n // light-dismiss read as non-`outside` and defeating the reopen guard.\n if (this.modal) {\n const dialog = element as HTMLDialogElement;\n if (dialog.open) {\n this._closeSource ??= 'programmatic';\n dialog.close();\n }\n } else if (element.matches(':popover-open')) {\n this._closeSource ??= 'programmatic';\n try {\n element.hidePopover();\n } catch {\n /* already hidden */\n }\n }\n }\n\n private _closeTeardown(): void {\n unregisterDismissible(this);\n this._removeEscapeListener();\n this._scrollLock.unlock();\n // `aria-expanded` is written by `updated()` on every `open` change, so it is\n // not set here. Positioning is frozen at close start (autoUpdate stopped in\n // `_dispatchClose`) and fully torn down only after the close transition (see\n // `_stopPositioningWhenClosed`), so the surface and arrow keep their position\n // and offset during the fade.\n }\n\n // Tear down positioning once the close animation has completed. Guarded by\n // `!this.open` so a rapid re-open during the fade keeps its positioning.\n private _stopPositioningWhenClosed(): void {\n if (this.open) {\n return;\n }\n this._placementController.stop();\n this.removeAttribute('actual-placement');\n }\n\n /** Set `open` without re-triggering the show/hide effect. */\n private _syncOpen(value: boolean): void {\n if (this.open === value) {\n return;\n }\n this._syncingOpen = true;\n this.open = value;\n }\n\n // ──────────────────────────────\n // NATIVE EVENT HANDLERS\n // (bound by the SWC render template)\n // ──────────────────────────────\n\n // Default mode: the popover-API lifecycle on the internal `<div>`.\n protected _onBeforeToggle = (event: ToggleEvent): void => {\n if (event.newState === 'open') {\n this._dispatchOpen();\n } else {\n const source = this._closeSource ?? 'outside';\n // Attribute an outside light-dismiss that lands during a trigger press to\n // that press, so `_onTriggerClick` reads the trailing click as the close\n // rather than a reopen.\n if (source === 'outside' && this._triggerPointerActive) {\n this._dismissedByTriggerPress = true;\n }\n // `beforetoggle` fires before the popover hides, so focus is still inside if\n // it was there. Unlike modal `<dialog>` (which restores focus natively), the\n // popover API drops focus to `<body>` when the focused content is hidden, so\n // restore it to the trigger. Gated on focus actually being inside our content\n // so an outside click that moved focus elsewhere is left alone.\n const restoreFocusToTrigger = this._isFocusWithin();\n this._syncOpen(false);\n this._dispatchClose(source);\n this._closeTeardown();\n if (restoreFocusToTrigger) {\n this._interactiveElement?.focus();\n }\n }\n };\n\n // Modal mode: Escape routes through the native `cancel` event. Honor the\n // dismissible stack so Escape dismisses the topmost layer first: if something\n // opened on top of this dialog, cancel the close and let that layer handle the\n // key. The next Escape, once this dialog is topmost, closes it.\n protected _onCancel = (event: Event): void => {\n if (!isTopDismissible(this)) {\n event.preventDefault();\n return;\n }\n this._closeSource = 'escape';\n };\n\n // Modal mode: `close` fires for Escape, backdrop-click, and programmatic close.\n protected _onClose = (): void => {\n const source = this._closeSource ?? 'programmatic';\n this._syncOpen(false);\n this._dispatchClose(source);\n this._closeTeardown();\n };\n\n // Modal mode: a pointerdown on the dialog's backdrop is an outside dismiss. The\n // backdrop targets the dialog element itself, as does its own border, so confirm\n // the point is outside the dialog box before closing; otherwise a press on the\n // 1px border would dismiss like a backdrop click.\n protected _onPointerDown = (event: PointerEvent): void => {\n const dialog = this.internalElement;\n if (!dialog || event.target !== dialog) {\n return;\n }\n const rect = dialog.getBoundingClientRect();\n const outsideDialogBox =\n event.clientX < rect.left ||\n event.clientX > rect.right ||\n event.clientY < rect.top ||\n event.clientY > rect.bottom;\n if (!outsideDialogBox) {\n return;\n }\n this._closeSource = 'outside';\n (dialog as HTMLDialogElement).close();\n };\n\n private _addEscapeListener(): void {\n if (this._escapeListener) {\n return;\n }\n this._escapeListener = (event: KeyboardEvent): void => {\n if (event.key === 'Escape' && isTopDismissible(this)) {\n this._closeSource = 'escape';\n }\n };\n document.addEventListener('keydown', this._escapeListener, {\n capture: true,\n });\n }\n\n private _removeEscapeListener(): void {\n if (!this._escapeListener) {\n return;\n }\n document.removeEventListener('keydown', this._escapeListener, {\n capture: true,\n });\n this._escapeListener = undefined;\n }\n\n // ──────────────────\n // EVENTS\n // ──────────────────\n\n private _dispatchOpen(): void {\n // A re-show of an already-open popover (modal toggle) must not emit a second\n // `swc-open`; consume the one-shot suppression set in `_show`.\n if (this._suppressOpenEvent) {\n this._suppressOpenEvent = false;\n return;\n }\n this.dispatchEvent(\n new CustomEvent('swc-open', { bubbles: true, composed: true })\n );\n // No fallback timer on open: nothing is gated on `swc-after-open`, so a\n // delayed (janky) `transitionend` must not be pre-empted by the timer.\n this._afterTransition(() => {\n this.dispatchEvent(\n new CustomEvent('swc-after-open', { bubbles: true, composed: true })\n );\n }, false);\n }\n\n private _dispatchClose(source: PopoverCloseSource): void {\n // Freeze positioning at the current location the moment the close begins.\n // `stop()` tears down the `autoUpdate` loop but leaves the inline `translate`\n // and `actual-placement` in place, so the surface fades out from where it is.\n // `beforetoggle` fires before the surface hides, so this runs before the fade.\n // Without it, a nested popover keeps auto-updating during its fade: when an\n // ancestor popover closes and its content collapses, the nested popover's\n // anchor shifts, `autoUpdate` recomputes, and it flashes to a new position\n // before disappearing. The attribute and remaining inline styles are cleared\n // after the transition in `_stopPositioningWhenClosed`.\n this._placementController.stop();\n this.dispatchEvent(\n new CustomEvent('swc-close', {\n detail: { source },\n bubbles: true,\n composed: true,\n })\n );\n this._afterTransition(() => {\n this.dispatchEvent(\n new CustomEvent('swc-after-close', { bubbles: true, composed: true })\n );\n // Positioning autoUpdate was already frozen at close start; this clears the\n // now-stale `actual-placement` attribute once the exit transition finishes.\n this._stopPositioningWhenClosed();\n });\n this._closeSource = null;\n }\n\n // Run `callback` once the internal element's transition settles (or\n // immediately when none will run). Each call supersedes the previous\n // open/close cycle's pending run, so a rapid close-then-reopen never\n // dispatches a spurious `swc-after-close` after reopening. `fallback` arms the\n // allow-discrete safety timer (default true; the close path relies on it to\n // always tear down positioning). Shared with Tooltip via `core/utils`.\n private _afterTransition(callback: () => void, fallback = true): void {\n this._cancelAfterTransition?.();\n const element = this.internalElement;\n if (!element) {\n callback();\n return;\n }\n this._cancelAfterTransition = runAfterTransition(\n element,\n () => {\n this._cancelAfterTransition = undefined;\n callback();\n },\n { fallback }\n );\n }\n}\n"],"mappings":";;;;;;;OAkDM,IAAyB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,EAYqB,IAAtB,cAA0C,EAAgB;;2BAuB1C,iBAUC,2BAQU,qBAQK,2BAoBX,kBAQH,sBAQK,2BAYK,qBASN,sBAaA,yBAayC,oBAU7C,gCAqCe,IAAI,EAAoB,KAAK,qBAOtC,IAAI,EAAyB,KAAK,6BAItD,qBAGqD,2BAGX,mCAQZ,0BAGiB,sCAOd,wBAGe,0BAG3B,8BAOM,oCAaM,+BAQL,sCA4La;AAIzC,GAHA,KAAK,wBAAwB,IAG7B,KAAK,iBAAiB,IAAI,iBAAiB;GAC3C,IAAM,EAAE,cAAW,KAAK;AAMxB,GALA,SAAS,iBAAiB,aAAa,KAAK,oBAAoB;IAC9D,SAAS;IACT,MAAM;IACN;IACD,CAAC,EACF,SAAS,iBAAiB,iBAAiB,KAAK,oBAAoB;IAClE,SAAS;IACT,MAAM;IACN;IACD,CAAC;gCAG0B,MAA8B;;AAC1D,IAAA,IAAA,KAAK,mBAAA,QAAA,EAAgB,OAAO,EAM1B,IAAM,SAAS,eACf,EAAM,cAAc,CAAC,SAAS,KAAK,cAA6B,MAIlE,KAAK,wBAAwB;kCAQO;GACpC,IAAM,IAAyB,KAAK;AACpC,QAAK,wBAAwB,IAC7B,KAAK,2BAA2B,IAC5B,OAGJ,KAAK,OAAO,CAAC,KAAK;6BA4OS,MAA6B;AACxD,OAAI,EAAM,aAAa,OACrB,MAAK,eAAe;QACf;;IACL,IAAM,KAAA,IAAS,KAAK,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AS;CAAE,MAAM;CAAQ,WAAW;CAAqB,CAAC,CAAA,EAAA,EAAA,WAAA,oBAAA,KAAA,EAAA,KAS1D,EAAS;CAAE,MAAM;CAAS,SAAS;CAAM,WAAW;CAAe,CAAC,CAAA,EAAA,EAAA,WAAA,cAAA,KAAA,EAAA,KAapE,EAAS;CAAE,MAAM;CAAQ,WAAW;CAAe,CAAC,CAAA,EAAA,EAAA,WAAA,cAAA,KAAA,EAAA,KAMpD,EAAS,EAAE,MAAM,QAAQ,CAAC,CAAA,EAAA,EAAA,WAAA,OAAA,KAAA,EAAA,KAO1B,EAAS,EAAE,WAAW,IAAO,CAAC,CAAA,EAAA,EAAA,WAAA,kBAAA,KAAA,EAAA,KAU9B,EAAS;CAAE,MAAM;CAAS,SAAS;CAAM,CAAC,CAAA,EAAA,EAAA,WAAA,UAAA,KAAA,EAAA"}
1
+ {"version":3,"file":"Popover.base.js","names":[],"sources":["../../../components/popover/Popover.base.ts"],"sourcesContent":["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { PropertyValues } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport {\n PageScrollLockController,\n PlacementController,\n TriggerPressController,\n type VirtualTrigger,\n} from '@adobe/spectrum-wc-core/controllers/index.js';\nimport { SpectrumElement } from '@adobe/spectrum-wc-core/element/index.js';\nimport {\n deepContains,\n getActiveElement,\n isTopDismissible,\n physicalSide,\n registerDismissible,\n resolveTrigger,\n runAfterTransition,\n unregisterDismissible,\n validateEnum,\n warnIf,\n} from '@adobe/spectrum-wc-core/utils/index.js';\n\nimport {\n type Placement,\n POPOVER_VALID_PLACEMENTS,\n POPOVER_VALID_SIZES,\n type PopoverCloseSource,\n type PopoverSize,\n} from './Popover.types.js';\n\n/**\n * The `aria-controls` relationship is wired via the element-reference IDL\n * (`ariaControlsElements`) so it works across shadow boundaries. The property\n * is Baseline but not yet in every TypeScript DOM lib, so it is declared here.\n */\ninterface ARIAControlsElements {\n ariaControlsElements?: readonly Element[] | null;\n}\n\n/** Properties whose change re-anchors the surface while open. */\nconst POSITIONING_PROPERTIES = [\n 'placement',\n 'offset',\n 'crossOffset',\n 'containerPadding',\n 'shouldFlip',\n 'hideArrow',\n 'tipPadding',\n 'size',\n] as const;\n\n/**\n * Abstract base for the popover component. Owns the popover's behavior: the\n * dual-mode dialog lifecycle (`showPopover()` / `showModal()`), trigger and ARIA\n * wiring, positioning through the `PlacementController`, dismissal coordination,\n * and `swc-*` event dispatch. The concrete SWC subclass adds only the styles, the\n * render template, and the shadow-DOM element getters (`internalElement`,\n * `tipElement`) it overrides.\n *\n * @slot - Popover content. Free-form; consumers slot whatever pattern they build.\n */\nexport abstract class PopoverBase extends SpectrumElement {\n /**\n * @internal\n *\n * The valid placement values for the popover. Narrowed in downstream\n * first-party subclasses per the proxy pattern.\n */\n static readonly VALID_PLACEMENTS: readonly Placement[] =\n POPOVER_VALID_PLACEMENTS;\n\n /**\n * @internal\n *\n * The valid fixed sizes for the popover.\n */\n static readonly VALID_SIZES: readonly PopoverSize[] = POPOVER_VALID_SIZES;\n\n /**\n * Whether the popover is open.\n *\n * @default false\n */\n @property({ type: Boolean, reflect: true })\n public open = false;\n\n /**\n * Opt in to blocking modal behavior (`<dialog>.showModal()`): focus trap,\n * background inert, native `role=\"dialog\"`. When unset, the popover uses\n * `popover=\"auto\"` light-dismiss behavior.\n *\n * @default false\n */\n @property({ type: Boolean, reflect: true })\n public modal = false;\n\n /**\n * Accessible name for the popover's dialog surface, forwarded as `aria-label`\n * to the internal element. Required in both modes (the surface is a dialog);\n * the component dev-warns when opened without one.\n */\n @property({ type: String, attribute: 'accessible-label' })\n public accessibleLabel = '';\n\n /**\n * The placement of the popover relative to its trigger.\n *\n * @default 'bottom'\n */\n @property({ type: String, reflect: true })\n public placement: Placement = 'bottom';\n\n /**\n * Optional fixed size. When set, the popover uses a fixed inline size\n * (`s` → 336px, `m` → 416px, `l` → 576px); when unset, it fits its contents.\n */\n @property({ type: String, reflect: true })\n public size?: PopoverSize;\n\n // The flipped placement is kept off the public property surface (a readonly\n // property is still writable at runtime and could desync from the controller).\n // It is reflected as the internal `actual-placement` host attribute for CSS\n // only, mirroring Tooltip; consumers read the requested side via `placement`.\n\n /**\n * Hide the popover's arrow (tip). The arrow is shown by default.\n *\n * @default false\n */\n @property({ type: Boolean, reflect: true, attribute: 'hide-arrow' })\n public hideArrow = false;\n\n /**\n * Main-axis offset in pixels from the trigger.\n *\n * @default 8\n */\n @property({ type: Number })\n public offset = 8;\n\n /**\n * Cross-axis offset in pixels from the trigger.\n *\n * @default 0\n */\n @property({ type: Number, attribute: 'cross-offset' })\n public crossOffset = 0;\n\n /**\n * Distance from the viewport edge for the `flip` and `shift` middleware.\n *\n * Positioning implementation detail. Set by first-party components; excluded\n * from the public API. Users are not expected to set it.\n *\n * @internal\n * @default 8\n */\n @property({ type: Number, attribute: 'container-padding' })\n public containerPadding = 8;\n\n /**\n * Allow the popover to flip to the opposite side when constrained. When\n * `false`, the popover stays in the requested placement.\n *\n * @default true\n */\n @property({ type: Boolean, reflect: true, attribute: 'should-flip' })\n public shouldFlip = true;\n\n /**\n * Minimum inset of the tip from the popover's corners, passed to the\n * `PlacementController`'s `arrow` middleware as its `padding`.\n *\n * Positioning implementation detail. Set by first-party components; excluded\n * from the public API. Users are not expected to set it.\n *\n * @internal\n * @default 8\n */\n @property({ type: Number, attribute: 'tip-padding' })\n public tipPadding = 8;\n\n /**\n * ID of the trigger element in the same document tree root.\n */\n @property({ type: String })\n public for?: string;\n\n /**\n * Direct trigger reference. Overrides `for` when both are set. Use for\n * cross-shadow-root triggers or programmatic wiring.\n */\n @property({ attribute: false })\n public triggerElement: HTMLElement | VirtualTrigger | null = null;\n\n /**\n * Suppress the automatic click-to-toggle wiring on the resolved trigger. When\n * set, control visibility through the `open` property instead. ARIA\n * relationship wiring still applies.\n *\n * @default false\n */\n @property({ type: Boolean, reflect: true })\n public manual = false;\n\n // ──────────────────────────────\n // RENDERING-LAYER HANDLES\n // ──────────────────────────────\n\n /**\n * The internal top-layer element (a `<div popover>` or a `<dialog>`) the\n * lifecycle drives. Mandatory: the SWC rendering layer must implement this to\n * return the rendered `.swc-Popover` element from the shadow DOM (it may still\n * return `null` before the first render, which the lifecycle guards against).\n */\n protected abstract get internalElement(): HTMLElement | null;\n\n /**\n * The arrow tip element passed to the `PlacementController`. Optional: returns\n * `null` in the base class (no arrow), and the SWC rendering layer overrides it\n * to return the rendered `.swc-Popover-tip` element when an arrow is shown.\n */\n protected get tipElement(): HTMLElement | null {\n return null;\n }\n\n /**\n * The arrow's height in pixels, added to the trigger gap when the arrow is\n * shown. Returns `0` in the base class; the SWC rendering layer overrides it\n * with the token-derived value so the gap stays in sync with the tip, keeping\n * the base free of any coupling to the surface's CSS.\n */\n protected get arrowHeight(): number {\n return 0;\n }\n\n // ──────────────────\n // STATE\n // ──────────────────\n\n private _placementController = new PlacementController(this);\n\n /**\n * Page-scroll lock for modal mode. Reference-counted at module scope so stacked\n * modal surfaces coordinate a single lock and restore the original overflow\n * exactly once. See {@link PageScrollLockController}.\n */\n private _scrollLock = new PageScrollLockController(this);\n\n /** The trigger's AT-facing element that receives ARIA wiring. */\n private _interactiveElement: (HTMLElement & ARIAControlsElements) | null =\n null;\n\n /** The positioning anchor (an element or a `VirtualTrigger`). */\n private _anchor: HTMLElement | VirtualTrigger | null = null;\n\n // Click-to-toggle on the resolved trigger, without the surface reopening on\n // the same click that light-dismissed it (see the controller's own doc for\n // why that needs dedicated gesture tracking, not just a naive toggle).\n private readonly _pressGuard = new TriggerPressController(this);\n\n /** Cause of the in-progress close, read when dispatching `swc-close`. */\n private _closeSource: PopoverCloseSource | null = null;\n\n /** Suppresses the open/close effect when `open` is synced from a native event. */\n private _syncingOpen = false;\n\n /**\n * Suppresses the next `swc-open` dispatch. Set when re-showing an\n * already-open popover (a `modal` toggle swaps the internal element), so the\n * mode swap does not emit a second `swc-open` with no intervening close.\n */\n private _suppressOpenEvent = false;\n\n /** Document Escape listener (default mode) used to label the close source. */\n private _escapeListener?: (event: KeyboardEvent) => void;\n\n /** Tears down the in-flight `_afterTransition` wiring (listener + fallback timer). */\n private _cancelAfterTransition?: () => void;\n\n /**\n * Set after the first render. Auto-focus on open is suppressed until then so an\n * initially-`open` popover (server-rendered or a static demo) does not steal\n * focus on mount; only an open triggered after the element is live moves focus.\n */\n private _hasCompletedFirstUpdate = false;\n\n /**\n * Set when a default-mode open should move focus into the dialog surface;\n * consumed by the first placement compute so focus lands after the surface is\n * anchored on screen (focusing it at its 0,0 reset origin would shift layout).\n * Modal mode moves focus natively via `showModal()`.\n */\n private _pendingFocusOnOpen = false;\n\n // ──────────────────\n // LIFECYCLE\n // ──────────────────\n\n public override disconnectedCallback(): void {\n super.disconnectedCallback();\n this._placementController.stop();\n this._cancelAfterTransition?.();\n unregisterDismissible(this);\n this._removeEscapeListener();\n this._scrollLock.unlock();\n this._clearTriggerAria();\n this._interactiveElement = null;\n this._anchor = null;\n // Focus restoration on close is handled elsewhere (default mode in\n // `_onBeforeToggle`, modal mode natively). Removing an open popover from the\n // DOM is not: the browser has already moved focus to `<body>` before this\n // runs, so there is no trigger to restore to.\n }\n\n protected override update(changedProperties: PropertyValues): void {\n // Validate against the static so subclasses that narrow the placement set\n // (the proxy pattern) get their own valid values checked at runtime.\n const constructor = this.constructor as typeof PopoverBase;\n validateEnum(this, {\n prop: 'placement',\n value: this.placement,\n valid: constructor.VALID_PLACEMENTS,\n url: 'https://spectrum-web-components.adobe.com/?path=/docs/components-popover--docs',\n });\n if (this.size !== undefined) {\n validateEnum(this, {\n prop: 'size',\n value: this.size,\n valid: constructor.VALID_SIZES,\n url: 'https://spectrum-web-components.adobe.com/?path=/docs/components-popover--docs',\n });\n }\n super.update(changedProperties);\n }\n\n protected override updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n\n if (\n changedProperties.has('for') ||\n changedProperties.has('triggerElement') ||\n changedProperties.has('modal') ||\n changedProperties.has('manual')\n ) {\n this._wireTrigger();\n }\n\n if (changedProperties.has('open')) {\n if (this._syncingOpen) {\n // The change came from a native event; the element is already in the\n // right state. Just consume the guard.\n this._syncingOpen = false;\n } else if (this.open) {\n this._show();\n } else {\n this._hide();\n }\n this._interactiveElement?.setAttribute(\n 'aria-expanded',\n String(this.open)\n );\n } else if (this.open && changedProperties.has('modal')) {\n // `modal` toggled while open: the render swapped the internal element\n // between a `<div popover=\"auto\">` and a `<dialog>`. Lit removed the old\n // element (the browser closes a disconnected top-layer element), so the\n // newly rendered element is present but never went through its show API.\n // Re-show so the correct mode engages (e.g. `showModal()` traps focus),\n // without re-emitting `swc-open` for a popover that never closed.\n this._show(true);\n } else if (\n this.open &&\n (this._positioningChanged(changedProperties) ||\n changedProperties.has('for') ||\n changedProperties.has('triggerElement'))\n ) {\n // Re-anchor while open when a positioning input or the trigger changes.\n this._startPositioning();\n }\n\n // First render is done: subsequent opens may move focus into the surface.\n this._hasCompletedFirstUpdate = true;\n }\n\n private _positioningChanged(changedProperties: PropertyValues): boolean {\n return POSITIONING_PROPERTIES.some((prop) => changedProperties.has(prop));\n }\n\n // ──────────────────────────\n // TRIGGER + ARIA\n // ──────────────────────────\n\n private _wireTrigger(): void {\n const { trigger, interactiveElement } = resolveTrigger(this, {\n for: this.for,\n triggerElement:\n this.triggerElement instanceof HTMLElement ? this.triggerElement : null,\n });\n\n warnIf(\n this,\n !trigger && Boolean(this.for),\n `<${this.localName}> for=\"${this.for}\" did not resolve to an element in the current tree root. Check that the referenced id exists in the same document tree root.`,\n 'https://spectrum-web-components.adobe.com/?path=/docs/components-popover--docs',\n { level: 'high' }\n );\n\n if (\n this._interactiveElement &&\n this._interactiveElement !== interactiveElement\n ) {\n this._clearTriggerAria();\n }\n\n this._interactiveElement = interactiveElement;\n // A `VirtualTrigger` (non-element) anchors positioning only; an element\n // trigger anchors positioning and carries ARIA.\n this._anchor =\n this.triggerElement && !(this.triggerElement instanceof HTMLElement)\n ? this.triggerElement\n : trigger;\n\n if (interactiveElement) {\n // Durable across open/close cycles; visibility is conveyed by aria-expanded.\n interactiveElement.ariaControlsElements = [this];\n interactiveElement.setAttribute('aria-expanded', String(this.open));\n // The surface is a dialog in both modes, so the trigger always signals it.\n interactiveElement.setAttribute('aria-haspopup', 'dialog');\n }\n\n // Click-to-toggle on the trigger host, unless the consumer drives `open`\n // themselves (`manual`). Listens on the host so clicks bubbling from an\n // inner button are caught. `attach` is a no-op for an unchanged trigger.\n this._pressGuard.attach(this.manual ? null : trigger, {\n onToggle: () => (this.open = !this.open),\n });\n // Re-anchoring while open (trigger or positioning input changed) is driven\n // from `updated()`, so this method only wires the trigger and ARIA. Doing it\n // here too would double-start the controller when `updated()` also re-shows\n // or re-anchors in the same cycle (e.g. a `modal` toggle while open).\n }\n\n private _clearTriggerAria(): void {\n const element = this._interactiveElement;\n if (!element) {\n return;\n }\n element.ariaControlsElements = null;\n element.removeAttribute('aria-expanded');\n element.removeAttribute('aria-haspopup');\n }\n\n // Whether focus is currently within the popover's content. `deepContains`\n // crosses shadow boundaries, so focus inside a slotted custom element (e.g. a\n // button's inner control) is detected; the content is slotted, so its DOM\n // ancestors lead back to this host.\n private _isFocusWithin(): boolean {\n return deepContains(this, getActiveElement());\n }\n\n // ──────────────────────────\n // POSITIONING\n // ──────────────────────────\n\n private _startPositioning(): void {\n const floating = this.internalElement;\n if (!floating || !this._anchor) {\n // No element or no anchor to position against (e.g. the trigger was\n // changed to an unresolved id while open). Tear down any prior session so\n // the surface is not left anchored to stale geometry; clearing\n // `actual-placement` also re-gates it hidden until a valid anchor returns.\n this._placementController.stop();\n this.removeAttribute('actual-placement');\n return;\n }\n const showArrow = !this.hideArrow;\n // Clear `actual-placement` to re-gate the surface and tip for this session:\n // `start()` calls `stop()`, which resets the inline `translate` to the 0,0\n // origin until the async first compute re-anchors. The stylesheet reveals the\n // surface and tip only once `actual-placement` is present, so they stay hidden\n // through that window (and a rapid reopen during the close fade) instead of\n // painting at 0,0. Re-set by `onPlacementChange` once the session anchors.\n this.removeAttribute('actual-placement');\n // Add the arrow height to the trigger gap so the surface clears the tip on\n // every side. Applied through the controller's direction-aware main-axis\n // offset, not a CSS margin (a margin only shifts the absolutely-positioned\n // surface on its block-/inline-start sides). `arrowHeight` comes from the\n // rendering layer.\n this._placementController.start(this._anchor, floating, {\n placement: this.placement,\n offset: this.offset + (showArrow ? this.arrowHeight : 0),\n crossOffset: this.crossOffset,\n containerPadding: this.containerPadding,\n shouldFlip: this.shouldFlip,\n tipElement: showArrow ? (this.tipElement ?? undefined) : undefined,\n tipPadding: this.tipPadding,\n onPlacementChange: (next) => {\n // Expose the computed physical side as the `actual-placement` host\n // attribute for CSS: it orients the tip and, by its presence, reveals the\n // surface and tip (gated off until now so the entry fade runs from the\n // anchored position, not the 0,0 origin). The first compute of a session\n // always fires this (`stop()` resets the last-notified placement). The\n // controller skips the compute only for a 0x0 element, but the surface\n // always has border and padded chrome, so it is never zero-sized while\n // open. Not a public property; removed in `_stopPositioningWhenClosed`.\n this.setAttribute('actual-placement', physicalSide(next));\n // Now anchored and revealed: move focus in for a pending default-mode\n // open. Focusing earlier, at the 0,0 origin, would shift layout/scroll.\n if (this._pendingFocusOnOpen) {\n this._pendingFocusOnOpen = false;\n this._focusSurface();\n }\n },\n });\n }\n\n // ──────────────────\n // OPEN/CLOSE\n // ──────────────────\n\n // `reShow` is true when re-engaging the show API for a popover that is already\n // open (a `modal` toggle swaps the internal element). It suppresses a second\n // `swc-open` for a popover that never closed.\n private _show(reShow = false): void {\n const element = this.internalElement;\n if (!element) {\n return;\n }\n // The surface is a dialog in both modes, so it must have an accessible name.\n warnIf(\n this,\n !this.accessibleLabel.trim(),\n `<${this.localName}> must have an \"accessible-label\" attribute to name the dialog for assistive technology.`,\n 'https://spectrum-web-components.adobe.com/?path=/docs/components-popover--docs',\n { issues: ['accessible-label'] }\n );\n // Enter the top layer first; only register listeners, the dismissible stack,\n // and positioning once the native show actually succeeds, so a failed\n // `showPopover()`/`showModal()` does not leave the component wired up for a\n // popover that never opened.\n if (this.modal) {\n const dialog = element as HTMLDialogElement;\n let shown = dialog.open;\n if (!shown) {\n // `showModal()` synchronously moves focus into the dialog, scrolling the\n // page to it, and has no `preventScroll` option. Positioning is async, so\n // the surface is still at its 0,0 origin when focus lands. Capture and\n // restore the scroll position around the call; it is synchronous, so the\n // restore is seamless (no paint between).\n const { scrollX, scrollY } = window;\n try {\n dialog.showModal();\n shown = true;\n } catch {\n shown = false;\n }\n window.scrollTo(scrollX, scrollY);\n }\n if (!shown) {\n return;\n }\n // Modal mode uses the native `<dialog>` Escape (`cancel`); drop any\n // default-mode document listener left over from a prior mode.\n this._removeEscapeListener();\n this._scrollLock.lock();\n registerDismissible(this);\n // `<dialog>` modal-mode has no native open event, so dispatch here (unless\n // this is a re-show of an already-open popover).\n if (!reShow) {\n this._dispatchOpen();\n }\n } else {\n let shown = element.matches(':popover-open');\n if (!shown) {\n // `showPopover()` fires `beforetoggle` synchronously, which dispatches\n // `swc-open`; suppress that one dispatch on a re-show.\n this._suppressOpenEvent = reShow;\n try {\n element.showPopover();\n shown = true;\n } catch {\n this._suppressOpenEvent = false;\n shown = false;\n }\n }\n if (!shown) {\n return;\n }\n // Default mode never locks scroll; release a lock left from a prior modal\n // mode (e.g. `modal` toggled false while open).\n this._scrollLock.unlock();\n registerDismissible(this);\n this._addEscapeListener();\n // Move focus into the dialog surface so assistive technology lands inside\n // it (modal mode does this natively via `showModal()`). Deferred to the\n // first placement compute so focus lands once the surface is anchored on\n // screen, not at its 0,0 reset origin. Suppressed on the initial render so\n // an initially-`open` popover does not steal focus.\n this._pendingFocusOnOpen = this._hasCompletedFirstUpdate;\n // `swc-open` is dispatched from the `beforetoggle` listener.\n }\n this._startPositioning();\n }\n\n // Move focus into the open default-mode dialog surface. The surface is a named\n // `role=\"dialog\"` element, so focusing it announces the dialog and seats the\n // user inside it; `preventScroll` because it is already anchored in the top\n // layer. Focus restoration on close is handled by `_onBeforeToggle`.\n private _focusSurface(): void {\n this.internalElement?.focus({ preventScroll: true });\n }\n\n private _hide(): void {\n const element = this.internalElement;\n if (!element) {\n return;\n }\n // Attribute a close source only when actually hiding an open element. Setting\n // it unconditionally would poison the next real close: the initial render\n // calls `_hide()` for the default `open = false`, and a stale `'programmatic'`\n // source would survive (no `beforetoggle` clears it), making the first genuine\n // light-dismiss read as non-`outside` and defeating the reopen guard.\n if (this.modal) {\n const dialog = element as HTMLDialogElement;\n if (dialog.open) {\n this._closeSource ??= 'programmatic';\n dialog.close();\n }\n } else if (element.matches(':popover-open')) {\n this._closeSource ??= 'programmatic';\n try {\n element.hidePopover();\n } catch {\n /* already hidden */\n }\n }\n }\n\n private _closeTeardown(): void {\n unregisterDismissible(this);\n this._removeEscapeListener();\n this._scrollLock.unlock();\n // `aria-expanded` is written by `updated()` on every `open` change, so it is\n // not set here. Positioning is frozen at close start (autoUpdate stopped in\n // `_dispatchClose`) and fully torn down only after the close transition (see\n // `_stopPositioningWhenClosed`), so the surface and arrow keep their position\n // and offset during the fade.\n }\n\n // Tear down positioning once the close animation has completed. Guarded by\n // `!this.open` so a rapid re-open during the fade keeps its positioning.\n private _stopPositioningWhenClosed(): void {\n if (this.open) {\n return;\n }\n this._placementController.stop();\n this.removeAttribute('actual-placement');\n }\n\n /** Set `open` without re-triggering the show/hide effect. */\n private _syncOpen(value: boolean): void {\n if (this.open === value) {\n return;\n }\n this._syncingOpen = true;\n this.open = value;\n }\n\n // ──────────────────────────────\n // NATIVE EVENT HANDLERS\n // (bound by the SWC render template)\n // ──────────────────────────────\n\n // Default mode: the popover-API lifecycle on the internal `<div>`.\n protected _onBeforeToggle = (event: ToggleEvent): void => {\n if (event.newState === 'open') {\n this._dispatchOpen();\n } else {\n const source = this._closeSource ?? 'outside';\n // Attribute an outside light-dismiss that lands during a trigger press\n // to that press, so the trailing click is read as the close rather\n // than a reopen (see `TriggerPressController`).\n if (source === 'outside') {\n this._pressGuard.noteNativeDismiss();\n }\n // `beforetoggle` fires before the popover hides, so focus is still inside if\n // it was there. Unlike modal `<dialog>` (which restores focus natively), the\n // popover API drops focus to `<body>` when the focused content is hidden, so\n // restore it to the trigger. Gated on focus actually being inside our content\n // so an outside click that moved focus elsewhere is left alone.\n const restoreFocusToTrigger = this._isFocusWithin();\n this._syncOpen(false);\n this._dispatchClose(source);\n this._closeTeardown();\n if (restoreFocusToTrigger) {\n // `preventScroll` so restoring focus does not scroll a trigger that the\n // user scrolled out of view back into it (matches `_focusSurface`).\n this._interactiveElement?.focus({ preventScroll: true });\n }\n }\n };\n\n // Modal mode: Escape routes through the native `cancel` event. Honor the\n // dismissible stack so Escape dismisses the topmost layer first: if something\n // opened on top of this dialog, cancel the close and let that layer handle the\n // key. The next Escape, once this dialog is topmost, closes it.\n protected _onCancel = (event: Event): void => {\n if (!isTopDismissible(this)) {\n event.preventDefault();\n return;\n }\n this._closeSource = 'escape';\n };\n\n // Modal mode: `close` fires for Escape, backdrop-click, and programmatic close.\n protected _onClose = (): void => {\n const source = this._closeSource ?? 'programmatic';\n this._syncOpen(false);\n this._dispatchClose(source);\n this._closeTeardown();\n };\n\n // Modal mode: a pointerdown on the dialog's backdrop is an outside dismiss. The\n // backdrop targets the dialog element itself, as does its own border, so confirm\n // the point is outside the dialog box before closing; otherwise a press on the\n // 1px border would dismiss like a backdrop click.\n protected _onPointerDown = (event: PointerEvent): void => {\n const dialog = this.internalElement;\n if (!dialog || event.target !== dialog) {\n return;\n }\n const rect = dialog.getBoundingClientRect();\n const outsideDialogBox =\n event.clientX < rect.left ||\n event.clientX > rect.right ||\n event.clientY < rect.top ||\n event.clientY > rect.bottom;\n if (!outsideDialogBox) {\n return;\n }\n this._closeSource = 'outside';\n (dialog as HTMLDialogElement).close();\n };\n\n private _addEscapeListener(): void {\n if (this._escapeListener) {\n return;\n }\n this._escapeListener = (event: KeyboardEvent): void => {\n if (event.key === 'Escape' && isTopDismissible(this)) {\n this._closeSource = 'escape';\n }\n };\n document.addEventListener('keydown', this._escapeListener, {\n capture: true,\n });\n }\n\n private _removeEscapeListener(): void {\n if (!this._escapeListener) {\n return;\n }\n document.removeEventListener('keydown', this._escapeListener, {\n capture: true,\n });\n this._escapeListener = undefined;\n }\n\n // ──────────────────\n // EVENTS\n // ──────────────────\n\n private _dispatchOpen(): void {\n // A re-show of an already-open popover (modal toggle) must not emit a second\n // `swc-open`; consume the one-shot suppression set in `_show`.\n if (this._suppressOpenEvent) {\n this._suppressOpenEvent = false;\n return;\n }\n this.dispatchEvent(\n new CustomEvent('swc-open', { bubbles: true, composed: true })\n );\n // No fallback timer on open: nothing is gated on `swc-after-open`, so a\n // delayed (janky) `transitionend` must not be pre-empted by the timer.\n this._afterTransition(() => {\n this.dispatchEvent(\n new CustomEvent('swc-after-open', { bubbles: true, composed: true })\n );\n }, false);\n }\n\n private _dispatchClose(source: PopoverCloseSource): void {\n // Freeze positioning at the current location the moment the close begins.\n // `stop()` tears down the `autoUpdate` loop but leaves the inline `translate`\n // and `actual-placement` in place, so the surface fades out from where it is.\n // `beforetoggle` fires before the surface hides, so this runs before the fade.\n // Without it, a nested popover keeps auto-updating during its fade: when an\n // ancestor popover closes and its content collapses, the nested popover's\n // anchor shifts, `autoUpdate` recomputes, and it flashes to a new position\n // before disappearing. The attribute and remaining inline styles are cleared\n // after the transition in `_stopPositioningWhenClosed`.\n this._placementController.stop();\n this.dispatchEvent(\n new CustomEvent('swc-close', {\n detail: { source },\n bubbles: true,\n composed: true,\n })\n );\n this._afterTransition(() => {\n this.dispatchEvent(\n new CustomEvent('swc-after-close', { bubbles: true, composed: true })\n );\n // Positioning autoUpdate was already frozen at close start; this clears the\n // now-stale `actual-placement` attribute once the exit transition finishes.\n this._stopPositioningWhenClosed();\n });\n this._closeSource = null;\n }\n\n // Run `callback` once the internal element's transition settles (or\n // immediately when none will run). Each call supersedes the previous\n // open/close cycle's pending run, so a rapid close-then-reopen never\n // dispatches a spurious `swc-after-close` after reopening. `fallback` arms the\n // allow-discrete safety timer (default true; the close path relies on it to\n // always tear down positioning). Shared with Tooltip via `core/utils`.\n private _afterTransition(callback: () => void, fallback = true): void {\n this._cancelAfterTransition?.();\n const element = this.internalElement;\n if (!element) {\n callback();\n return;\n }\n this._cancelAfterTransition = runAfterTransition(\n element,\n () => {\n this._cancelAfterTransition = undefined;\n callback();\n },\n { fallback }\n );\n }\n}\n"],"mappings":";;;;;;;OAqDM,IAAyB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,EAYqB,IAAtB,cAA0C,EAAgB;;2BAuB1C,iBAUC,2BAQU,qBAQK,2BAoBX,kBAQH,sBAQK,2BAYK,qBASN,sBAaA,yBAayC,oBAU7C,gCAqCe,IAAI,EAAoB,KAAK,qBAOtC,IAAI,EAAyB,KAAK,6BAItD,qBAGqD,yBAKxB,IAAI,EAAuB,KAAK,sBAGb,0BAG3B,8BAOM,oCAaM,+BAQL,4BA6XD,MAA6B;AACxD,OAAI,EAAM,aAAa,OACrB,MAAK,eAAe;QACf;;IACL,IAAM,KAAA,IAAS,KAAK,iBAAA,OAAgB,YAAhB;AAIpB,IAAI,MAAW,aACb,KAAK,YAAY,mBAAmB;IAOtC,IAAM,IAAwB,KAAK,gBAAgB;AAInD,QAHA,KAAK,UAAU,GAAM,EACrB,KAAK,eAAe,EAAO,EAC3B,KAAK,gBAAgB,EACjB,GAAuB;;AAGzB,MAAA,IAAA,KAAK,wBAAA,QAAA,EAAqB,MAAM,EAAE,eAAe,IAAM,CAAC;;;uBASvC,MAAuB;AAC5C,OAAI,CAAC,EAAiB,KAAK,EAAE;AAC3B,MAAM,gBAAgB;AACtB;;AAEF,QAAK,eAAe;2BAIW;;GAC/B,IAAM,KAAA,IAAS,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AAS;CAAE,MAAM;CAAS,SAAS;CAAM,WAAW;CAAc,CAAC,CAAA,EAAA,EAAA,WAAA,aAAA,KAAA,EAAA,KAQnE,EAAS,EAAE,MAAM,QAAQ,CAAC,CAAA,EAAA,EAAA,WAAA,UAAA,KAAA,EAAA,KAQ1B,EAAS;CAAE,MAAM;CAAQ,WAAW;CAAgB,CAAC,CAAA,EAAA,EAAA,WAAA,eAAA,KAAA,EAAA,KAYrD,EAAS;CAAE,MAAM;CAAQ,WAAW;CAAqB,CAAC,CAAA,EAAA,EAAA,WAAA,oBAAA,KAAA,EAAA,KAS1D,EAAS;CAAE,MAAM;CAAS,SAAS;CAAM,WAAW;CAAe,CAAC,CAAA,EAAA,EAAA,WAAA,cAAA,KAAA,EAAA,KAapE,EAAS;CAAE,MAAM;CAAQ,WAAW;CAAe,CAAC,CAAA,EAAA,EAAA,WAAA,cAAA,KAAA,EAAA,KAMpD,EAAS,EAAE,MAAM,QAAQ,CAAC,CAAA,EAAA,EAAA,WAAA,OAAA,KAAA,EAAA,KAO1B,EAAS,EAAE,WAAW,IAAO,CAAC,CAAA,EAAA,EAAA,WAAA,kBAAA,KAAA,EAAA,KAU9B,EAAS;CAAE,MAAM;CAAS,SAAS;CAAM,CAAC,CAAA,EAAA,EAAA,WAAA,UAAA,KAAA,EAAA"}
@@ -76,7 +76,6 @@ export declare abstract class ProgressCircleBase extends ProgressCircleBase_base
76
76
  private static clampProgress;
77
77
  private formatProgress;
78
78
  private warnDeprecatedLightDomChildren;
79
- private warnMissingAccessibleName;
80
79
  protected willUpdate(changes: PropertyValues): void;
81
80
  protected firstUpdated(changes: PropertyValues): void;
82
81
  protected updated(changes: PropertyValues): void;
@@ -3,11 +3,12 @@ import { PROGRESS_CIRCLE_VALID_SIZES as t } from "./ProgressCircle.types.js";
3
3
  import { property as n } from "lit/decorators.js";
4
4
  import { SpectrumElement as r } from "@adobe/spectrum-wc-core/element/index.js";
5
5
  import { SizedMixin as i } from "@adobe/spectrum-wc-core/mixins/index.js";
6
- import { LanguageResolutionController as a, languageResolverUpdatedSymbol as o } from "@adobe/spectrum-wc-core/controllers/language-resolution.js";
6
+ import { isDebug as a, validateEnum as o, warnIf as s } from "@adobe/spectrum-wc-core/utils/index.js";
7
+ import { LanguageResolutionController as c, languageResolverUpdatedSymbol as l } from "@adobe/spectrum-wc-core/controllers/language-resolution.js";
7
8
  //#region components/progress-circle/ProgressCircle.base.ts
8
- var s, c = class e extends i(r, { validSizes: t }) {
9
+ var u, d = class e extends i(r, { validSizes: t }) {
9
10
  constructor(...e) {
10
- super(...e), this.label = "", this.progress = null, this.languageResolver = new a(this);
11
+ super(...e), this.label = "", this.progress = null, this.languageResolver = new c(this);
11
12
  }
12
13
  static hasMeaningfulLightDomChildren(e) {
13
14
  for (let n of e.childNodes) {
@@ -30,19 +31,7 @@ var s, c = class e extends i(r, { validSizes: t }) {
30
31
  }).format(((e = this.progress) == null ? 0 : e) / 100);
31
32
  }
32
33
  warnDeprecatedLightDomChildren() {
33
- var t;
34
- (t = window.__swc) != null && t.DEBUG && e.hasMeaningfulLightDomChildren(this) && window.__swc.warn(this, `<${this.localName}> no longer has a default slot. Light DOM children are not rendered and are not used for an accessible name. Use the "label" attribute or property, or "aria-label" / "aria-labelledby" on the host instead.`, "https://opensource.adobe.com/spectrum-web-components/second-gen/?path=/docs/components-progress-circle--docs", { level: "deprecation" });
35
- }
36
- warnMissingAccessibleName() {
37
- var t, n;
38
- (t = window.__swc) != null && t.DEBUG && ((n = window.__swc) == null || n.warn(this, `<${this.localName}> requires an accessible name. A default label of "${e.DEFAULT_LABEL}" has been applied, but a more specific label should be provided via:`, "https://opensource.adobe.com/spectrum-web-components/second-gen/?path=/docs/components-progress-circle--docs", {
39
- type: "accessibility",
40
- issues: [
41
- "value supplied to the \"label\" attribute, which will be displayed visually as part of the element, or",
42
- "value supplied to the \"aria-label\" attribute, which will only be provided to screen readers, or",
43
- "an element ID reference supplied to the \"aria-labelledby\" attribute, which will be provided by screen readers and will need to be managed manually by the parent application."
44
- ]
45
- }));
34
+ s(this, e.hasMeaningfulLightDomChildren(this), `<${this.localName}> no longer has a default slot. Light DOM children are not rendered and are not used for an accessible name. Use the "label" attribute or property, or "aria-label" / "aria-labelledby" on the host instead.`, "https://spectrum-web-components.adobe.com/?path=/docs/components-progress-circle--docs", { level: "deprecation" });
46
35
  }
47
36
  willUpdate(t) {
48
37
  if (t.has("progress") && this.progress !== null) {
@@ -55,19 +44,34 @@ var s, c = class e extends i(r, { validSizes: t }) {
55
44
  super.firstUpdated(e), this.setAttribute("role", "progressbar");
56
45
  }
57
46
  updated(t) {
58
- var n;
59
- super.updated(t), t.has("progress") && (this.progress !== null && this.progress >= 0 ? (this.setAttribute("aria-valuemin", "0"), this.setAttribute("aria-valuemax", "100"), this.setAttribute("aria-valuenow", String(this.progress)), this.setAttribute("aria-valuetext", this.formatProgress())) : (this.removeAttribute("aria-valuemin"), this.removeAttribute("aria-valuemax"), this.removeAttribute("aria-valuenow"), this.removeAttribute("aria-valuetext"))), this.progress !== null && t.has(o) && this.setAttribute("aria-valuetext", this.formatProgress()), t.has("label") && (this.label.length ? this.setAttribute("aria-label", this.label) : t.get("label") === this.getAttribute("aria-label") && this.removeAttribute("aria-label")), t.has("label") && !this.hasAccessibleName() && (this.setAttribute("aria-label", e.DEFAULT_LABEL), this.warnMissingAccessibleName()), (n = window.__swc) != null && n.DEBUG && this.warnDeprecatedLightDomChildren();
47
+ if (super.updated(t), t.has("progress") && (this.progress !== null && this.progress >= 0 ? (this.setAttribute("aria-valuemin", "0"), this.setAttribute("aria-valuemax", "100"), this.setAttribute("aria-valuenow", String(this.progress)), this.setAttribute("aria-valuetext", this.formatProgress())) : (this.removeAttribute("aria-valuemin"), this.removeAttribute("aria-valuemax"), this.removeAttribute("aria-valuenow"), this.removeAttribute("aria-valuetext"))), this.progress !== null && t.has(l) && this.setAttribute("aria-valuetext", this.formatProgress()), t.has("label") && (this.label.length ? this.setAttribute("aria-label", this.label) : t.get("label") === this.getAttribute("aria-label") && this.removeAttribute("aria-label")), t.has("label") && !this.hasAccessibleName() && (this.setAttribute("aria-label", e.DEFAULT_LABEL), s(this, !0, `<${this.localName}> requires an accessible name. A default label of "${e.DEFAULT_LABEL}" has been applied, but a more specific label should be provided via:`, "https://spectrum-web-components.adobe.com/?path=/docs/components-progress-circle--docs", {
48
+ type: "accessibility",
49
+ issues: [
50
+ "value supplied to the \"label\" attribute, which will be displayed visually as part of the element, or",
51
+ "value supplied to the \"aria-label\" attribute, which will only be provided to screen readers, or",
52
+ "an element ID reference supplied to the \"aria-labelledby\" attribute, which will be provided by screen readers and will need to be managed manually by the parent application."
53
+ ]
54
+ })), t.has("staticColor") && this.staticColor !== void 0) {
55
+ let e = this.constructor;
56
+ o(this, {
57
+ prop: "static-color",
58
+ value: this.staticColor,
59
+ valid: e.STATIC_COLORS,
60
+ url: "https://spectrum-web-components.adobe.com/?path=/docs/components-progress-circle--docs"
61
+ });
62
+ }
63
+ a() && this.warnDeprecatedLightDomChildren();
60
64
  }
61
65
  };
62
- s = c, s.DEFAULT_LABEL = "Loading", e([n({
66
+ u = d, u.DEFAULT_LABEL = "Loading", e([n({
63
67
  type: String,
64
68
  reflect: !0,
65
69
  attribute: "static-color"
66
- })], c.prototype, "staticColor", void 0), e([n({ type: String })], c.prototype, "label", void 0), e([n({
70
+ })], d.prototype, "staticColor", void 0), e([n({ type: String })], d.prototype, "label", void 0), e([n({
67
71
  type: Number,
68
72
  reflect: !0
69
- })], c.prototype, "progress", void 0);
73
+ })], d.prototype, "progress", void 0);
70
74
  //#endregion
71
- export { c as ProgressCircleBase };
75
+ export { d as ProgressCircleBase };
72
76
 
73
77
  //# sourceMappingURL=ProgressCircle.base.js.map