@vonage/vivid 3.51.0 → 3.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (261) hide show
  1. package/alert/index.cjs +1 -1
  2. package/alert/index.js +1 -1
  3. package/appearance-ui/index.cjs +19 -11
  4. package/appearance-ui/index.js +19 -11
  5. package/audio-player/index.cjs +2 -1
  6. package/audio-player/index.js +2 -1
  7. package/card/index.cjs +1 -1
  8. package/card/index.js +1 -1
  9. package/combobox/index.cjs +2 -5
  10. package/combobox/index.js +2 -5
  11. package/custom-elements.json +1357 -529
  12. package/date-picker/index.cjs +3 -6
  13. package/date-picker/index.js +3 -6
  14. package/date-range-picker/index.cjs +2 -5
  15. package/date-range-picker/index.js +2 -5
  16. package/dialog/index.cjs +1 -1
  17. package/dialog/index.js +1 -1
  18. package/elevation/index.cjs +1 -1
  19. package/elevation/index.js +1 -1
  20. package/file-picker/index.cjs +0 -2
  21. package/file-picker/index.js +0 -2
  22. package/header/index.cjs +1 -1
  23. package/header/index.js +1 -1
  24. package/index.cjs +60 -58
  25. package/index.js +22 -23
  26. package/lib/avatar/definition.d.ts +1 -1
  27. package/lib/button/button.d.ts +1 -0
  28. package/lib/button/definition.d.ts +1 -1
  29. package/lib/calendar-event/definition.d.ts +1 -1
  30. package/lib/components.d.ts +1 -0
  31. package/lib/layout/definition.d.ts +1 -1
  32. package/lib/menu-item/menu-item.d.ts +3 -0
  33. package/lib/range-slider/definition.d.ts +3 -0
  34. package/lib/range-slider/locale.d.ts +4 -0
  35. package/lib/range-slider/range-slider.d.ts +32 -0
  36. package/lib/range-slider/range-slider.form-associated.d.ts +10 -0
  37. package/lib/range-slider/range-slider.template.d.ts +4 -0
  38. package/lib/range-slider/utils/lerp.d.ts +2 -0
  39. package/lib/range-slider/utils/roundToStepValue.d.ts +1 -0
  40. package/lib/slider/slider.template.d.ts +1 -0
  41. package/lib/split-button/definition.d.ts +1 -1
  42. package/listbox/index.cjs +23 -22
  43. package/listbox/index.js +23 -22
  44. package/locales/en-GB.cjs +4 -0
  45. package/locales/en-GB.js +4 -0
  46. package/locales/en-US.cjs +4 -0
  47. package/locales/en-US.js +4 -0
  48. package/locales/ja-JP.cjs +5 -1
  49. package/locales/ja-JP.js +5 -1
  50. package/locales/zh-CN.cjs +4 -0
  51. package/locales/zh-CN.js +4 -0
  52. package/menu/index.cjs +3 -3
  53. package/menu/index.js +3 -3
  54. package/menu-item/index.cjs +2 -2
  55. package/menu-item/index.js +2 -2
  56. package/number-field/index.cjs +0 -2
  57. package/number-field/index.js +0 -2
  58. package/package.json +34 -34
  59. package/popup/index.cjs +2 -2
  60. package/popup/index.js +2 -2
  61. package/range-slider/index.cjs +22 -0
  62. package/range-slider/index.js +20 -0
  63. package/select/index.cjs +3 -3
  64. package/select/index.js +3 -3
  65. package/selectable-box/index.cjs +1 -1
  66. package/selectable-box/index.js +1 -1
  67. package/shared/Reflector.cjs +5 -1
  68. package/shared/Reflector.js +5 -1
  69. package/shared/affix.cjs +11 -4
  70. package/shared/affix.js +12 -4
  71. package/shared/anchored.cjs +8 -2
  72. package/shared/anchored.js +8 -2
  73. package/shared/definition.cjs +8 -3
  74. package/shared/definition.js +8 -3
  75. package/shared/definition10.cjs +5 -5
  76. package/shared/definition10.js +5 -5
  77. package/shared/definition11.cjs +75 -47
  78. package/shared/definition11.js +76 -48
  79. package/shared/definition12.cjs +12 -14
  80. package/shared/definition12.js +12 -14
  81. package/shared/definition13.cjs +118 -75
  82. package/shared/definition13.js +118 -75
  83. package/shared/definition14.cjs +33 -32
  84. package/shared/definition14.js +33 -32
  85. package/shared/definition15.cjs +20 -7
  86. package/shared/definition15.js +20 -7
  87. package/shared/definition16.cjs +37 -42
  88. package/shared/definition16.js +36 -41
  89. package/shared/definition17.cjs +125 -65
  90. package/shared/definition17.js +126 -66
  91. package/shared/definition18.cjs +30 -14
  92. package/shared/definition18.js +30 -14
  93. package/shared/definition19.cjs +116 -80
  94. package/shared/definition19.js +116 -80
  95. package/shared/definition2.cjs +10 -5
  96. package/shared/definition2.js +10 -5
  97. package/shared/definition20.cjs +16 -15
  98. package/shared/definition20.js +16 -15
  99. package/shared/definition21.cjs +6 -10
  100. package/shared/definition21.js +6 -10
  101. package/shared/definition22.cjs +14 -18
  102. package/shared/definition22.js +14 -18
  103. package/shared/definition23.cjs +34 -35
  104. package/shared/definition23.js +34 -35
  105. package/shared/definition24.cjs +116 -69
  106. package/shared/definition24.js +116 -69
  107. package/shared/definition25.cjs +2 -4
  108. package/shared/definition25.js +2 -4
  109. package/shared/definition26.cjs +9 -8
  110. package/shared/definition26.js +9 -8
  111. package/shared/definition27.cjs +7 -5
  112. package/shared/definition27.js +7 -5
  113. package/shared/definition28.cjs +209 -143
  114. package/shared/definition28.js +209 -143
  115. package/shared/definition29.cjs +10 -4
  116. package/shared/definition29.js +10 -4
  117. package/shared/definition3.cjs +7 -10
  118. package/shared/definition3.js +7 -10
  119. package/shared/definition30.cjs +7 -5
  120. package/shared/definition30.js +7 -5
  121. package/shared/definition31.cjs +2 -4
  122. package/shared/definition31.js +2 -4
  123. package/shared/definition32.cjs +1 -3
  124. package/shared/definition32.js +1 -3
  125. package/shared/definition33.cjs +7 -10
  126. package/shared/definition33.js +7 -10
  127. package/shared/definition34.cjs +76 -59
  128. package/shared/definition34.js +76 -59
  129. package/shared/definition35.cjs +19 -20
  130. package/shared/definition35.js +19 -20
  131. package/shared/definition36.cjs +30 -14
  132. package/shared/definition36.js +30 -14
  133. package/shared/definition37.cjs +33 -46
  134. package/shared/definition37.js +33 -46
  135. package/shared/definition38.cjs +31 -33
  136. package/shared/definition38.js +31 -33
  137. package/shared/definition39.cjs +13 -4
  138. package/shared/definition39.js +13 -4
  139. package/shared/definition4.cjs +23 -11
  140. package/shared/definition4.js +23 -11
  141. package/shared/definition40.cjs +19 -14
  142. package/shared/definition40.js +19 -14
  143. package/shared/definition41.cjs +534 -635
  144. package/shared/definition41.js +534 -635
  145. package/shared/definition42.cjs +674 -106
  146. package/shared/definition42.js +673 -105
  147. package/shared/definition43.cjs +122 -79
  148. package/shared/definition43.js +120 -77
  149. package/shared/definition44.cjs +72 -567
  150. package/shared/definition44.js +71 -565
  151. package/shared/definition45.cjs +520 -118
  152. package/shared/definition45.js +518 -117
  153. package/shared/definition46.cjs +117 -130
  154. package/shared/definition46.js +116 -129
  155. package/shared/definition47.cjs +152 -18
  156. package/shared/definition47.js +151 -17
  157. package/shared/definition48.cjs +20 -77
  158. package/shared/definition48.js +19 -76
  159. package/shared/definition49.cjs +52 -495
  160. package/shared/definition49.js +51 -494
  161. package/shared/definition5.cjs +20 -17
  162. package/shared/definition5.js +20 -17
  163. package/shared/definition50.cjs +525 -24
  164. package/shared/definition50.js +524 -23
  165. package/shared/definition51.cjs +28 -119
  166. package/shared/definition51.js +26 -118
  167. package/shared/definition52.cjs +113 -266
  168. package/shared/definition52.js +113 -265
  169. package/shared/definition53.cjs +285 -245
  170. package/shared/definition53.js +285 -245
  171. package/shared/definition54.cjs +285 -751
  172. package/shared/definition54.js +284 -750
  173. package/shared/definition55.cjs +828 -99
  174. package/shared/definition55.js +827 -98
  175. package/shared/definition56.cjs +126 -77
  176. package/shared/definition56.js +125 -76
  177. package/shared/definition57.cjs +125 -71
  178. package/shared/definition57.js +124 -70
  179. package/shared/definition58.cjs +73 -287
  180. package/shared/definition58.js +74 -288
  181. package/shared/definition59.cjs +298 -40
  182. package/shared/definition59.js +297 -39
  183. package/shared/definition6.cjs +3 -4
  184. package/shared/definition6.js +3 -4
  185. package/shared/definition60.cjs +24 -1784
  186. package/shared/definition60.js +23 -1783
  187. package/shared/definition61.cjs +1819 -11
  188. package/shared/definition61.js +1818 -11
  189. package/shared/definition7.cjs +6 -4
  190. package/shared/definition7.js +6 -4
  191. package/shared/definition8.cjs +25 -18
  192. package/shared/definition8.js +25 -18
  193. package/shared/definition9.cjs +6 -9
  194. package/shared/definition9.js +6 -9
  195. package/shared/icon.cjs +7 -2
  196. package/shared/icon.js +7 -2
  197. package/shared/index2.cjs +1 -1
  198. package/shared/index2.js +1 -1
  199. package/shared/key-codes2.cjs +8 -0
  200. package/shared/key-codes2.js +5 -1
  201. package/shared/localization/Locale.d.ts +2 -0
  202. package/shared/patterns/index.d.ts +0 -1
  203. package/shared/presentationDate.cjs +126 -78
  204. package/shared/presentationDate.js +126 -78
  205. package/shared/slider.template.cjs +71 -0
  206. package/shared/slider.template.js +67 -0
  207. package/shared/text-anchor.template.cjs +30 -35
  208. package/shared/text-anchor.template.js +30 -35
  209. package/shared/text-field.cjs +1 -1
  210. package/shared/text-field.js +1 -1
  211. package/side-drawer/index.cjs +1 -1
  212. package/side-drawer/index.js +1 -1
  213. package/slider/index.cjs +2 -1
  214. package/slider/index.js +2 -1
  215. package/split-button/index.cjs +1 -1
  216. package/split-button/index.js +1 -1
  217. package/styles/core/all.css +1 -1
  218. package/styles/core/theme.css +1 -1
  219. package/styles/core/typography.css +1 -1
  220. package/styles/fonts/spezia-variable.css +39 -13
  221. package/styles/tokens/theme-dark.css +4 -4
  222. package/styles/tokens/theme-light.css +4 -4
  223. package/styles/tokens/vivid-2-compat.css +4 -2
  224. package/switch/index.cjs +1 -1
  225. package/switch/index.js +1 -1
  226. package/tab/index.cjs +1 -1
  227. package/tab/index.js +1 -1
  228. package/tab-panel/index.cjs +1 -1
  229. package/tab-panel/index.js +1 -1
  230. package/tabs/index.cjs +3 -3
  231. package/tabs/index.js +3 -3
  232. package/tag/index.cjs +1 -1
  233. package/tag/index.js +1 -1
  234. package/tag-group/index.cjs +1 -1
  235. package/tag-group/index.js +1 -1
  236. package/text-area/index.cjs +1 -1
  237. package/text-area/index.js +1 -1
  238. package/text-field/index.cjs +1 -4
  239. package/text-field/index.js +1 -4
  240. package/time-picker/index.cjs +4 -7
  241. package/time-picker/index.js +4 -7
  242. package/toggletip/index.cjs +3 -3
  243. package/toggletip/index.js +3 -3
  244. package/tooltip/index.cjs +3 -3
  245. package/tooltip/index.js +3 -3
  246. package/tree-item/index.cjs +1 -1
  247. package/tree-item/index.js +1 -1
  248. package/tree-view/index.cjs +1 -1
  249. package/tree-view/index.js +1 -1
  250. package/vivid.api.json +117 -1
  251. package/focus/index.cjs +0 -7
  252. package/focus/index.js +0 -5
  253. package/lib/focus/definition.d.ts +0 -3
  254. package/lib/focus/focus.d.ts +0 -3
  255. package/lib/focus/focus.template.d.ts +0 -4
  256. package/lib/popup/popup.d.ts +0 -21
  257. package/shared/focus.cjs +0 -8
  258. package/shared/focus.js +0 -6
  259. package/shared/focus2.cjs +0 -11
  260. package/shared/focus2.js +0 -9
  261. package/shared/patterns/focus.d.ts +0 -3
@@ -1,11 +1,12 @@
1
1
  'use strict';
2
2
 
3
3
  const index = require('./index.cjs');
4
- const definition = require('./definition60.cjs');
4
+ const definition = require('./definition61.cjs');
5
5
  const anchored = require('./anchored.cjs');
6
+ const when = require('./when.cjs');
6
7
  const classNames = require('./class-names.cjs');
7
8
 
8
- const styles = ":host{display:var(--_popup-display, inline)}:host([slotted-anchor]){--_popup-display: contents}.control{pointer-events:none}.tooltip{width:var(--tooltip-inline-size, auto)}.tooltip-text{padding:8px 12px;color:var(--vvd-color-canvas-text);font:var(--vvd-typography-base-bold)}\n";
9
+ const styles = ":host{display:var(--_popup-display, inline)}:host([slotted-anchor]){--_popup-display: contents}.content-wrapper{width:var(--toggletip-inline-size, auto);padding:16px}.headline{font:var(--vvd-typography-base-bold)}.action-items{display:flex;justify-content:flex-end;gap:10px}::slotted([slot=action-items]){margin-block-start:16px}\n";
9
10
 
10
11
  var __defProp = Object.defineProperty;
11
12
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -18,113 +19,161 @@ var __decorateClass = (decorators, target, key, kind) => {
18
19
  __defProp(target, key, result);
19
20
  return result;
20
21
  };
21
- let Tooltip = class extends index.FoundationElement {
22
+ var __accessCheck = (obj, member, msg) => {
23
+ if (!member.has(obj))
24
+ throw TypeError("Cannot " + msg);
25
+ };
26
+ var __privateGet = (obj, member, getter) => {
27
+ __accessCheck(obj, member, "read from private field");
28
+ return getter ? getter.call(obj) : member.get(obj);
29
+ };
30
+ var __privateAdd = (obj, member, value) => {
31
+ if (member.has(obj))
32
+ throw TypeError("Cannot add the same private member more than once");
33
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
34
+ };
35
+ var __privateMethod = (obj, member, method) => {
36
+ __accessCheck(obj, member, "access private method");
37
+ return method;
38
+ };
39
+ var _ANCHOR_ARIA_LABEL_SUFFIX, _setupAnchor, setupAnchor_fn, _updateAnchor, updateAnchor_fn, _cleanupAnchor, cleanupAnchor_fn, _openIfClosed, _updateListeners, updateListeners_fn, _closeOnClickOutside, _closeOnEscape;
40
+ let Toggletip = class extends index.FoundationElement {
22
41
  constructor() {
23
42
  super(...arguments);
43
+ __privateAdd(this, _setupAnchor);
44
+ __privateAdd(this, _updateAnchor);
45
+ __privateAdd(this, _cleanupAnchor);
46
+ __privateAdd(this, _updateListeners);
47
+ __privateAdd(this, _ANCHOR_ARIA_LABEL_SUFFIX, " ; Show more information");
48
+ this.alternate = false;
49
+ this.placement = "right";
24
50
  this.open = false;
25
- this.#show = () => {
26
- this.open = true;
27
- };
28
- this.#hide = () => {
29
- this.open = false;
30
- };
31
- this.#closeOnEscape = (e) => {
51
+ __privateAdd(this, _openIfClosed, () => {
52
+ if (!this.open)
53
+ index.DOM.queueUpdate(() => this.open = true);
54
+ });
55
+ __privateAdd(this, _closeOnClickOutside, (e) => {
56
+ const clickedOutside = !this.contains(e.target);
57
+ const clickedOnAnchor = this._anchorEl?.contains(e.target);
58
+ if (clickedOutside || clickedOnAnchor)
59
+ this.open = false;
60
+ });
61
+ __privateAdd(this, _closeOnEscape, (e) => {
32
62
  if (e.key === "Escape")
33
- this.#hide();
34
- };
63
+ this.open = false;
64
+ });
65
+ }
66
+ openChanged(oldValue, newValue) {
67
+ if (oldValue === void 0)
68
+ return;
69
+ if (newValue) {
70
+ this.setAttribute("role", "status");
71
+ } else {
72
+ this.removeAttribute("role");
73
+ }
74
+ __privateMethod(this, _updateListeners, updateListeners_fn).call(this);
75
+ if (this._anchorEl) {
76
+ __privateMethod(this, _updateAnchor, updateAnchor_fn).call(this, this._anchorEl);
77
+ }
35
78
  }
36
79
  connectedCallback() {
37
80
  super.connectedCallback();
38
- this.#updateListeners();
81
+ __privateMethod(this, _updateListeners, updateListeners_fn).call(this);
39
82
  }
40
83
  disconnectedCallback() {
41
84
  super.disconnectedCallback();
42
- this.#updateListeners();
85
+ __privateMethod(this, _updateListeners, updateListeners_fn).call(this);
43
86
  }
44
87
  /**
45
88
  * @internal
46
89
  */
47
90
  _anchorElChanged(oldValue, newValue) {
48
91
  if (oldValue)
49
- this.#cleanupAnchor(oldValue);
92
+ __privateMethod(this, _cleanupAnchor, cleanupAnchor_fn).call(this, oldValue);
50
93
  if (newValue)
51
- this.#setupAnchor(newValue);
52
- }
53
- #setupAnchor(a) {
54
- a.addEventListener("mouseover", this.#show);
55
- a.addEventListener("mouseout", this.#hide);
56
- a.addEventListener("focusin", this.#show);
57
- a.addEventListener("focusout", this.#hide);
58
- }
59
- #cleanupAnchor(a) {
60
- a.removeEventListener("mouseover", this.#show);
61
- a.removeEventListener("mouseout", this.#hide);
62
- a.removeEventListener("focusin", this.#show);
63
- a.removeEventListener("focusout", this.#hide);
64
- }
65
- #show;
66
- #hide;
67
- #updateListeners() {
68
- document.removeEventListener("keydown", this.#closeOnEscape);
69
- if (this.open && this.isConnected) {
70
- document.addEventListener("keydown", this.#closeOnEscape);
71
- }
94
+ __privateMethod(this, _setupAnchor, setupAnchor_fn).call(this, newValue);
72
95
  }
73
- #closeOnEscape;
74
- /**
75
- * @internal
76
- */
77
- openChanged(oldValue) {
78
- if (oldValue === void 0)
79
- return;
80
- this.#updateListeners();
96
+ };
97
+ _ANCHOR_ARIA_LABEL_SUFFIX = new WeakMap();
98
+ _setupAnchor = new WeakSet();
99
+ setupAnchor_fn = function(a) {
100
+ a.addEventListener("click", __privateGet(this, _openIfClosed), true);
101
+ a.ariaLabel = (a.ariaLabel ?? "") + __privateGet(this, _ANCHOR_ARIA_LABEL_SUFFIX);
102
+ __privateMethod(this, _updateAnchor, updateAnchor_fn).call(this, a);
103
+ };
104
+ _updateAnchor = new WeakSet();
105
+ updateAnchor_fn = function(a) {
106
+ a.setAttribute("aria-expanded", this.open.toString());
107
+ };
108
+ _cleanupAnchor = new WeakSet();
109
+ cleanupAnchor_fn = function(a) {
110
+ a.removeEventListener("click", __privateGet(this, _openIfClosed), true);
111
+ if (a.ariaLabel)
112
+ a.ariaLabel = a.ariaLabel.replace(__privateGet(this, _ANCHOR_ARIA_LABEL_SUFFIX), "");
113
+ };
114
+ _openIfClosed = new WeakMap();
115
+ _updateListeners = new WeakSet();
116
+ updateListeners_fn = function() {
117
+ document.removeEventListener("click", __privateGet(this, _closeOnClickOutside));
118
+ document.removeEventListener("keydown", __privateGet(this, _closeOnEscape));
119
+ if (this.open && this.isConnected) {
120
+ document.addEventListener("click", __privateGet(this, _closeOnClickOutside));
121
+ document.addEventListener("keydown", __privateGet(this, _closeOnEscape));
81
122
  }
82
123
  };
124
+ _closeOnClickOutside = new WeakMap();
125
+ _closeOnEscape = new WeakMap();
83
126
  __decorateClass([
84
127
  index.attr
85
- ], Tooltip.prototype, "text", 2);
128
+ ], Toggletip.prototype, "headline", 2);
129
+ __decorateClass([
130
+ index.attr({ mode: "boolean" })
131
+ ], Toggletip.prototype, "alternate", 2);
86
132
  __decorateClass([
87
133
  index.attr({ mode: "fromView" })
88
- ], Tooltip.prototype, "placement", 2);
134
+ ], Toggletip.prototype, "placement", 2);
89
135
  __decorateClass([
90
136
  index.attr({ mode: "boolean" })
91
- ], Tooltip.prototype, "open", 2);
92
- Tooltip = __decorateClass([
137
+ ], Toggletip.prototype, "open", 2);
138
+ Toggletip = __decorateClass([
93
139
  anchored.anchored
94
- ], Tooltip);
140
+ ], Toggletip);
95
141
 
96
- const getClasses = ({
97
- open
98
- }) => classNames.classNames(
99
- "control",
100
- ["open", Boolean(open)]
101
- );
102
- const TooltipTemplate = (context) => {
103
- const popupTag = context.tagFor(definition.Popup);
142
+ const getClasses = (_) => classNames.classNames("control");
143
+ const ToggletipTemplate = (context) => {
144
+ const popup = context.tagFor(definition.Popup);
104
145
  const anchorSlotTemplate = anchored.anchorSlotTemplateFactory();
105
146
  return index.html`
106
- ${anchorSlotTemplate}
107
- <${popupTag} class="${getClasses}" arrow alternate
108
- :placement=${(x) => x.placement}
109
- :anchor="${(x) => x._anchorEl}"
110
- :open=${(x) => x.open}
111
- exportparts="vvd-theme-alternate">
112
- <div class="tooltip" role="tooltip">
113
- <header part="vvd-theme-alternate" class="tooltip-header">
114
- <div class="tooltip-text">${(x) => x.text}</div>
115
- </header>
116
- </div>
117
- </${popupTag}>`;
147
+ ${anchorSlotTemplate}
148
+ <${popup}
149
+ class="${getClasses}"
150
+ arrow
151
+ :anchor="${(x) => x._anchorEl}"
152
+ :open="${(x) => x.open}"
153
+ ?alternate="${(x) => !x.alternate}"
154
+ placement="${(x) => x.placement}"
155
+ exportparts="vvd-theme-alternate"
156
+ >
157
+ <div class="content-wrapper">
158
+ ${when.when(
159
+ (x) => x.headline,
160
+ index.html`<header class="headline">${(x) => x.headline}</header>`
161
+ )}
162
+ <slot></slot>
163
+ <footer class="action-items"><slot name="action-items"></slot></footer>
164
+ </div>
165
+ </${popup}>
166
+ `;
118
167
  };
119
168
 
120
- const tooltipDefinition = Tooltip.compose({
121
- baseName: "tooltip",
122
- template: TooltipTemplate,
169
+ const toggletipDefinition = Toggletip.compose({
170
+ baseName: "toggletip",
171
+ template: ToggletipTemplate,
123
172
  styles
124
173
  });
125
- const tooltipRegistries = [tooltipDefinition(), ...definition.popupRegistries];
126
- const registerTooltip = index.registerFactory(tooltipRegistries);
174
+ const toggletipRegistries = [toggletipDefinition(), ...definition.popupRegistries];
175
+ const registerToggletip = index.registerFactory(toggletipRegistries);
127
176
 
128
- exports.registerTooltip = registerTooltip;
129
- exports.tooltipDefinition = tooltipDefinition;
130
- exports.tooltipRegistries = tooltipRegistries;
177
+ exports.registerToggletip = registerToggletip;
178
+ exports.toggletipDefinition = toggletipDefinition;
179
+ exports.toggletipRegistries = toggletipRegistries;
@@ -1,9 +1,10 @@
1
- import { a as attr, F as FoundationElement, h as html, r as registerFactory } from './index.js';
2
- import { P as Popup, p as popupRegistries } from './definition60.js';
1
+ import { a as attr, F as FoundationElement, D as DOM, h as html, r as registerFactory } from './index.js';
2
+ import { P as Popup, p as popupRegistries } from './definition61.js';
3
3
  import { b as anchored, a as anchorSlotTemplateFactory } from './anchored.js';
4
+ import { w as when } from './when.js';
4
5
  import { c as classNames } from './class-names.js';
5
6
 
6
- const styles = ":host{display:var(--_popup-display, inline)}:host([slotted-anchor]){--_popup-display: contents}.control{pointer-events:none}.tooltip{width:var(--tooltip-inline-size, auto)}.tooltip-text{padding:8px 12px;color:var(--vvd-color-canvas-text);font:var(--vvd-typography-base-bold)}\n";
7
+ const styles = ":host{display:var(--_popup-display, inline)}:host([slotted-anchor]){--_popup-display: contents}.content-wrapper{width:var(--toggletip-inline-size, auto);padding:16px}.headline{font:var(--vvd-typography-base-bold)}.action-items{display:flex;justify-content:flex-end;gap:10px}::slotted([slot=action-items]){margin-block-start:16px}\n";
7
8
 
8
9
  var __defProp = Object.defineProperty;
9
10
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -16,111 +17,159 @@ var __decorateClass = (decorators, target, key, kind) => {
16
17
  __defProp(target, key, result);
17
18
  return result;
18
19
  };
19
- let Tooltip = class extends FoundationElement {
20
+ var __accessCheck = (obj, member, msg) => {
21
+ if (!member.has(obj))
22
+ throw TypeError("Cannot " + msg);
23
+ };
24
+ var __privateGet = (obj, member, getter) => {
25
+ __accessCheck(obj, member, "read from private field");
26
+ return getter ? getter.call(obj) : member.get(obj);
27
+ };
28
+ var __privateAdd = (obj, member, value) => {
29
+ if (member.has(obj))
30
+ throw TypeError("Cannot add the same private member more than once");
31
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
32
+ };
33
+ var __privateMethod = (obj, member, method) => {
34
+ __accessCheck(obj, member, "access private method");
35
+ return method;
36
+ };
37
+ var _ANCHOR_ARIA_LABEL_SUFFIX, _setupAnchor, setupAnchor_fn, _updateAnchor, updateAnchor_fn, _cleanupAnchor, cleanupAnchor_fn, _openIfClosed, _updateListeners, updateListeners_fn, _closeOnClickOutside, _closeOnEscape;
38
+ let Toggletip = class extends FoundationElement {
20
39
  constructor() {
21
40
  super(...arguments);
41
+ __privateAdd(this, _setupAnchor);
42
+ __privateAdd(this, _updateAnchor);
43
+ __privateAdd(this, _cleanupAnchor);
44
+ __privateAdd(this, _updateListeners);
45
+ __privateAdd(this, _ANCHOR_ARIA_LABEL_SUFFIX, " ; Show more information");
46
+ this.alternate = false;
47
+ this.placement = "right";
22
48
  this.open = false;
23
- this.#show = () => {
24
- this.open = true;
25
- };
26
- this.#hide = () => {
27
- this.open = false;
28
- };
29
- this.#closeOnEscape = (e) => {
49
+ __privateAdd(this, _openIfClosed, () => {
50
+ if (!this.open)
51
+ DOM.queueUpdate(() => this.open = true);
52
+ });
53
+ __privateAdd(this, _closeOnClickOutside, (e) => {
54
+ const clickedOutside = !this.contains(e.target);
55
+ const clickedOnAnchor = this._anchorEl?.contains(e.target);
56
+ if (clickedOutside || clickedOnAnchor)
57
+ this.open = false;
58
+ });
59
+ __privateAdd(this, _closeOnEscape, (e) => {
30
60
  if (e.key === "Escape")
31
- this.#hide();
32
- };
61
+ this.open = false;
62
+ });
63
+ }
64
+ openChanged(oldValue, newValue) {
65
+ if (oldValue === void 0)
66
+ return;
67
+ if (newValue) {
68
+ this.setAttribute("role", "status");
69
+ } else {
70
+ this.removeAttribute("role");
71
+ }
72
+ __privateMethod(this, _updateListeners, updateListeners_fn).call(this);
73
+ if (this._anchorEl) {
74
+ __privateMethod(this, _updateAnchor, updateAnchor_fn).call(this, this._anchorEl);
75
+ }
33
76
  }
34
77
  connectedCallback() {
35
78
  super.connectedCallback();
36
- this.#updateListeners();
79
+ __privateMethod(this, _updateListeners, updateListeners_fn).call(this);
37
80
  }
38
81
  disconnectedCallback() {
39
82
  super.disconnectedCallback();
40
- this.#updateListeners();
83
+ __privateMethod(this, _updateListeners, updateListeners_fn).call(this);
41
84
  }
42
85
  /**
43
86
  * @internal
44
87
  */
45
88
  _anchorElChanged(oldValue, newValue) {
46
89
  if (oldValue)
47
- this.#cleanupAnchor(oldValue);
90
+ __privateMethod(this, _cleanupAnchor, cleanupAnchor_fn).call(this, oldValue);
48
91
  if (newValue)
49
- this.#setupAnchor(newValue);
50
- }
51
- #setupAnchor(a) {
52
- a.addEventListener("mouseover", this.#show);
53
- a.addEventListener("mouseout", this.#hide);
54
- a.addEventListener("focusin", this.#show);
55
- a.addEventListener("focusout", this.#hide);
56
- }
57
- #cleanupAnchor(a) {
58
- a.removeEventListener("mouseover", this.#show);
59
- a.removeEventListener("mouseout", this.#hide);
60
- a.removeEventListener("focusin", this.#show);
61
- a.removeEventListener("focusout", this.#hide);
62
- }
63
- #show;
64
- #hide;
65
- #updateListeners() {
66
- document.removeEventListener("keydown", this.#closeOnEscape);
67
- if (this.open && this.isConnected) {
68
- document.addEventListener("keydown", this.#closeOnEscape);
69
- }
92
+ __privateMethod(this, _setupAnchor, setupAnchor_fn).call(this, newValue);
70
93
  }
71
- #closeOnEscape;
72
- /**
73
- * @internal
74
- */
75
- openChanged(oldValue) {
76
- if (oldValue === void 0)
77
- return;
78
- this.#updateListeners();
94
+ };
95
+ _ANCHOR_ARIA_LABEL_SUFFIX = new WeakMap();
96
+ _setupAnchor = new WeakSet();
97
+ setupAnchor_fn = function(a) {
98
+ a.addEventListener("click", __privateGet(this, _openIfClosed), true);
99
+ a.ariaLabel = (a.ariaLabel ?? "") + __privateGet(this, _ANCHOR_ARIA_LABEL_SUFFIX);
100
+ __privateMethod(this, _updateAnchor, updateAnchor_fn).call(this, a);
101
+ };
102
+ _updateAnchor = new WeakSet();
103
+ updateAnchor_fn = function(a) {
104
+ a.setAttribute("aria-expanded", this.open.toString());
105
+ };
106
+ _cleanupAnchor = new WeakSet();
107
+ cleanupAnchor_fn = function(a) {
108
+ a.removeEventListener("click", __privateGet(this, _openIfClosed), true);
109
+ if (a.ariaLabel)
110
+ a.ariaLabel = a.ariaLabel.replace(__privateGet(this, _ANCHOR_ARIA_LABEL_SUFFIX), "");
111
+ };
112
+ _openIfClosed = new WeakMap();
113
+ _updateListeners = new WeakSet();
114
+ updateListeners_fn = function() {
115
+ document.removeEventListener("click", __privateGet(this, _closeOnClickOutside));
116
+ document.removeEventListener("keydown", __privateGet(this, _closeOnEscape));
117
+ if (this.open && this.isConnected) {
118
+ document.addEventListener("click", __privateGet(this, _closeOnClickOutside));
119
+ document.addEventListener("keydown", __privateGet(this, _closeOnEscape));
79
120
  }
80
121
  };
122
+ _closeOnClickOutside = new WeakMap();
123
+ _closeOnEscape = new WeakMap();
81
124
  __decorateClass([
82
125
  attr
83
- ], Tooltip.prototype, "text", 2);
126
+ ], Toggletip.prototype, "headline", 2);
127
+ __decorateClass([
128
+ attr({ mode: "boolean" })
129
+ ], Toggletip.prototype, "alternate", 2);
84
130
  __decorateClass([
85
131
  attr({ mode: "fromView" })
86
- ], Tooltip.prototype, "placement", 2);
132
+ ], Toggletip.prototype, "placement", 2);
87
133
  __decorateClass([
88
134
  attr({ mode: "boolean" })
89
- ], Tooltip.prototype, "open", 2);
90
- Tooltip = __decorateClass([
135
+ ], Toggletip.prototype, "open", 2);
136
+ Toggletip = __decorateClass([
91
137
  anchored
92
- ], Tooltip);
138
+ ], Toggletip);
93
139
 
94
- const getClasses = ({
95
- open
96
- }) => classNames(
97
- "control",
98
- ["open", Boolean(open)]
99
- );
100
- const TooltipTemplate = (context) => {
101
- const popupTag = context.tagFor(Popup);
140
+ const getClasses = (_) => classNames("control");
141
+ const ToggletipTemplate = (context) => {
142
+ const popup = context.tagFor(Popup);
102
143
  const anchorSlotTemplate = anchorSlotTemplateFactory();
103
144
  return html`
104
- ${anchorSlotTemplate}
105
- <${popupTag} class="${getClasses}" arrow alternate
106
- :placement=${(x) => x.placement}
107
- :anchor="${(x) => x._anchorEl}"
108
- :open=${(x) => x.open}
109
- exportparts="vvd-theme-alternate">
110
- <div class="tooltip" role="tooltip">
111
- <header part="vvd-theme-alternate" class="tooltip-header">
112
- <div class="tooltip-text">${(x) => x.text}</div>
113
- </header>
114
- </div>
115
- </${popupTag}>`;
145
+ ${anchorSlotTemplate}
146
+ <${popup}
147
+ class="${getClasses}"
148
+ arrow
149
+ :anchor="${(x) => x._anchorEl}"
150
+ :open="${(x) => x.open}"
151
+ ?alternate="${(x) => !x.alternate}"
152
+ placement="${(x) => x.placement}"
153
+ exportparts="vvd-theme-alternate"
154
+ >
155
+ <div class="content-wrapper">
156
+ ${when(
157
+ (x) => x.headline,
158
+ html`<header class="headline">${(x) => x.headline}</header>`
159
+ )}
160
+ <slot></slot>
161
+ <footer class="action-items"><slot name="action-items"></slot></footer>
162
+ </div>
163
+ </${popup}>
164
+ `;
116
165
  };
117
166
 
118
- const tooltipDefinition = Tooltip.compose({
119
- baseName: "tooltip",
120
- template: TooltipTemplate,
167
+ const toggletipDefinition = Toggletip.compose({
168
+ baseName: "toggletip",
169
+ template: ToggletipTemplate,
121
170
  styles
122
171
  });
123
- const tooltipRegistries = [tooltipDefinition(), ...popupRegistries];
124
- const registerTooltip = registerFactory(tooltipRegistries);
172
+ const toggletipRegistries = [toggletipDefinition(), ...popupRegistries];
173
+ const registerToggletip = registerFactory(toggletipRegistries);
125
174
 
126
- export { tooltipRegistries as a, registerTooltip as r, tooltipDefinition as t };
175
+ export { toggletipRegistries as a, registerToggletip as r, toggletipDefinition as t };