@vonage/vivid 4.16.2 → 4.17.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 (292) hide show
  1. package/custom-elements.json +3426 -506
  2. package/elevation/index.cjs +1 -1
  3. package/elevation/index.js +1 -1
  4. package/index.cjs +147 -39
  5. package/index.js +64 -59
  6. package/lib/accordion/definition.d.ts +2 -0
  7. package/lib/accordion-item/definition.d.ts +2 -0
  8. package/lib/action-group/definition.d.ts +2 -0
  9. package/lib/alert/definition.d.ts +2 -0
  10. package/lib/audio-player/definition.d.ts +2 -0
  11. package/lib/avatar/definition.d.ts +2 -0
  12. package/lib/badge/definition.d.ts +2 -0
  13. package/lib/banner/definition.d.ts +2 -0
  14. package/lib/breadcrumb/definition.d.ts +2 -0
  15. package/lib/breadcrumb-item/definition.d.ts +2 -0
  16. package/lib/button/definition.d.ts +2 -0
  17. package/lib/calendar/calendar.d.ts +2 -0
  18. package/lib/calendar/definition.d.ts +2 -0
  19. package/lib/calendar-event/definition.d.ts +2 -0
  20. package/lib/card/definition.d.ts +2 -0
  21. package/lib/checkbox/definition.d.ts +2 -0
  22. package/lib/combobox/definition.d.ts +2 -0
  23. package/lib/components.d.ts +1 -0
  24. package/lib/data-grid/definition.d.ts +4 -0
  25. package/lib/date-picker/definition.d.ts +2 -0
  26. package/lib/date-range-picker/definition.d.ts +2 -0
  27. package/lib/dial-pad/definition.d.ts +2 -0
  28. package/lib/dialog/definition.d.ts +2 -0
  29. package/lib/divider/definition.d.ts +2 -0
  30. package/lib/empty-state/definition.d.ts +2 -0
  31. package/lib/enums.d.ts +6 -0
  32. package/lib/fab/definition.d.ts +2 -0
  33. package/lib/file-picker/definition.d.ts +2 -0
  34. package/lib/header/definition.d.ts +2 -0
  35. package/lib/icon/definition.d.ts +2 -0
  36. package/lib/layout/definition.d.ts +2 -0
  37. package/lib/menu/definition.d.ts +2 -0
  38. package/lib/menu/menu.d.ts +454 -4
  39. package/lib/menu-item/definition.d.ts +2 -0
  40. package/lib/nav/definition.d.ts +2 -0
  41. package/lib/nav-disclosure/definition.d.ts +2 -0
  42. package/lib/nav-item/definition.d.ts +2 -0
  43. package/lib/note/definition.d.ts +2 -0
  44. package/lib/number-field/definition.d.ts +2 -0
  45. package/lib/option/definition.d.ts +2 -0
  46. package/lib/pagination/definition.d.ts +2 -0
  47. package/lib/popup/definition.d.ts +0 -1
  48. package/lib/popup/popup.d.ts +25 -0
  49. package/lib/progress/definition.d.ts +2 -0
  50. package/lib/progress-ring/definition.d.ts +2 -0
  51. package/lib/radio/definition.d.ts +2 -0
  52. package/lib/radio-group/definition.d.ts +2 -0
  53. package/lib/range-slider/definition.d.ts +2 -0
  54. package/lib/rich-text-editor/definition.d.ts +2 -0
  55. package/lib/rich-text-editor/facades/prose-mirror-vivid.schema.d.ts +2 -0
  56. package/lib/rich-text-editor/facades/vivid-prose-mirror.facade.d.ts +7 -0
  57. package/lib/rich-text-editor/rich-text-editor.d.ts +13 -0
  58. package/lib/rich-text-editor/rich-text-editor.template.d.ts +4 -0
  59. package/lib/searchable-select/definition.d.ts +2 -0
  60. package/lib/select/definition.d.ts +2 -0
  61. package/lib/selectable-box/definition.d.ts +2 -0
  62. package/lib/side-drawer/definition.d.ts +2 -0
  63. package/lib/slider/definition.d.ts +2 -0
  64. package/lib/split-button/definition.d.ts +2 -0
  65. package/lib/switch/definition.d.ts +2 -0
  66. package/lib/tab/definition.d.ts +2 -0
  67. package/lib/tab-panel/definition.d.ts +2 -0
  68. package/lib/tabs/definition.d.ts +2 -0
  69. package/lib/tag/definition.d.ts +2 -0
  70. package/lib/tag-group/definition.d.ts +2 -0
  71. package/lib/text-area/definition.d.ts +2 -0
  72. package/lib/text-field/definition.d.ts +2 -0
  73. package/lib/time-picker/definition.d.ts +2 -0
  74. package/lib/time-picker/inline-time-picker/columns.d.ts +13 -0
  75. package/lib/time-picker/inline-time-picker/definition.d.ts +1 -0
  76. package/lib/time-picker/inline-time-picker/inline-time-picker.d.ts +15 -0
  77. package/lib/time-picker/inline-time-picker/inline-time-picker.template.d.ts +5 -0
  78. package/lib/time-picker/time-picker.template.d.ts +1 -2
  79. package/lib/toggletip/definition.d.ts +2 -0
  80. package/lib/toggletip/toggletip.d.ts +454 -4
  81. package/lib/tooltip/definition.d.ts +2 -0
  82. package/lib/tooltip/tooltip.d.ts +454 -4
  83. package/lib/tree-item/definition.d.ts +2 -0
  84. package/lib/tree-view/definition.d.ts +2 -0
  85. package/lib/video-player/definition.d.ts +2 -0
  86. package/menu/index.js +1 -1
  87. package/package.json +7 -2
  88. package/popup/index.cjs +1 -1
  89. package/popup/index.js +1 -1
  90. package/rich-text-editor/index.cjs +5 -0
  91. package/rich-text-editor/index.js +3 -0
  92. package/searchable-select/index.cjs +1 -1
  93. package/searchable-select/index.js +1 -1
  94. package/select/index.cjs +1 -1
  95. package/select/index.js +1 -1
  96. package/selectable-box/index.cjs +1 -1
  97. package/selectable-box/index.js +1 -1
  98. package/shared/affix.cjs +1 -3
  99. package/shared/affix.js +2 -4
  100. package/shared/anchored.cjs +12 -9
  101. package/shared/anchored.js +13 -10
  102. package/shared/definition.js +1 -1
  103. package/shared/definition10.cjs +1 -0
  104. package/shared/definition10.js +2 -2
  105. package/shared/definition11.cjs +1 -1
  106. package/shared/definition11.js +2 -2
  107. package/shared/definition12.cjs +1 -1
  108. package/shared/definition12.js +2 -2
  109. package/shared/definition13.cjs +15 -2
  110. package/shared/definition13.js +16 -4
  111. package/shared/definition14.cjs +3 -2
  112. package/shared/definition14.js +4 -4
  113. package/shared/definition15.cjs +1 -1
  114. package/shared/definition15.js +2 -2
  115. package/shared/definition16.cjs +18 -18
  116. package/shared/definition16.js +6 -6
  117. package/shared/definition17.cjs +3 -0
  118. package/shared/definition17.js +2 -2
  119. package/shared/definition18.cjs +7 -7
  120. package/shared/definition18.js +4 -4
  121. package/shared/definition19.cjs +15 -15
  122. package/shared/definition19.js +4 -4
  123. package/shared/definition2.cjs +1 -0
  124. package/shared/definition2.js +2 -2
  125. package/shared/definition20.cjs +5 -4
  126. package/shared/definition20.js +6 -6
  127. package/shared/definition21.cjs +3 -2
  128. package/shared/definition21.js +4 -4
  129. package/shared/definition22.js +1 -1
  130. package/shared/definition23.cjs +2 -1
  131. package/shared/definition23.js +3 -3
  132. package/shared/definition24.cjs +2 -1
  133. package/shared/definition24.js +3 -3
  134. package/shared/definition25.cjs +14 -14
  135. package/shared/definition25.js +3 -3
  136. package/shared/definition26.cjs +2 -1
  137. package/shared/definition26.js +3 -3
  138. package/shared/definition27.cjs +1 -1
  139. package/shared/definition27.js +2 -2
  140. package/shared/definition28.cjs +1 -0
  141. package/shared/definition28.js +2 -2
  142. package/shared/definition29.cjs +53 -61
  143. package/shared/definition29.js +54 -63
  144. package/shared/definition3.cjs +1 -0
  145. package/shared/definition3.js +2 -2
  146. package/shared/definition30.cjs +1 -0
  147. package/shared/definition30.js +2 -2
  148. package/shared/definition31.cjs +1 -0
  149. package/shared/definition31.js +2 -2
  150. package/shared/definition32.cjs +1 -0
  151. package/shared/definition32.js +2 -2
  152. package/shared/definition33.cjs +2 -1
  153. package/shared/definition33.js +3 -3
  154. package/shared/definition34.cjs +25 -25
  155. package/shared/definition34.js +5 -5
  156. package/shared/definition35.cjs +1 -1
  157. package/shared/definition35.js +2 -2
  158. package/shared/definition36.cjs +2 -1
  159. package/shared/definition36.js +3 -3
  160. package/shared/definition37.cjs +1 -1
  161. package/shared/definition37.js +2 -2
  162. package/shared/definition38.cjs +2 -1
  163. package/shared/definition38.js +3 -3
  164. package/shared/definition39.cjs +1 -0
  165. package/shared/definition39.js +2 -2
  166. package/shared/definition4.cjs +3 -2
  167. package/shared/definition4.js +4 -4
  168. package/shared/definition40.cjs +1 -1
  169. package/shared/definition40.js +2 -2
  170. package/shared/definition41.cjs +30 -30
  171. package/shared/definition41.js +5 -5
  172. package/shared/definition42.cjs +12538 -1052
  173. package/shared/definition42.js +12538 -1053
  174. package/shared/definition43.cjs +927 -701
  175. package/shared/definition43.js +929 -702
  176. package/shared/definition44.cjs +874 -104
  177. package/shared/definition44.js +874 -104
  178. package/shared/definition45.cjs +114 -90
  179. package/shared/definition45.js +113 -90
  180. package/shared/definition46.cjs +88 -464
  181. package/shared/definition46.js +87 -463
  182. package/shared/definition47.cjs +463 -109
  183. package/shared/definition47.js +462 -109
  184. package/shared/definition48.cjs +108 -106
  185. package/shared/definition48.js +107 -106
  186. package/shared/definition49.cjs +139 -13
  187. package/shared/definition49.js +138 -13
  188. package/shared/definition5.cjs +3 -2
  189. package/shared/definition5.js +5 -5
  190. package/shared/definition50.cjs +16 -114
  191. package/shared/definition50.js +15 -114
  192. package/shared/definition51.cjs +79 -485
  193. package/shared/definition51.js +78 -485
  194. package/shared/definition52.cjs +503 -23
  195. package/shared/definition52.js +502 -23
  196. package/shared/definition53.cjs +25 -123
  197. package/shared/definition53.js +24 -123
  198. package/shared/definition54.cjs +96 -254
  199. package/shared/definition54.js +96 -255
  200. package/shared/definition55.cjs +261 -59
  201. package/shared/definition55.js +262 -60
  202. package/shared/definition56.cjs +72 -861
  203. package/shared/definition56.js +72 -861
  204. package/shared/definition57.cjs +880 -107
  205. package/shared/definition57.js +880 -107
  206. package/shared/definition58.cjs +104 -88
  207. package/shared/definition58.js +104 -89
  208. package/shared/definition59.cjs +80 -165
  209. package/shared/definition59.js +79 -163
  210. package/shared/definition6.cjs +2 -1
  211. package/shared/definition6.js +3 -3
  212. package/shared/definition60.cjs +142 -228
  213. package/shared/definition60.js +141 -229
  214. package/shared/definition61.cjs +233 -70146
  215. package/shared/definition61.js +232 -70146
  216. package/shared/definition62.cjs +69381 -28
  217. package/shared/definition62.js +69380 -27
  218. package/shared/definition63.cjs +28 -2163
  219. package/shared/definition63.js +27 -2161
  220. package/shared/definition64.cjs +2195 -0
  221. package/shared/definition64.js +2190 -0
  222. package/shared/definition7.cjs +2 -1
  223. package/shared/definition7.js +3 -3
  224. package/shared/definition8.cjs +2 -1
  225. package/shared/definition8.js +3 -3
  226. package/shared/definition9.cjs +1 -1
  227. package/shared/definition9.js +2 -2
  228. package/shared/enums.cjs +8 -0
  229. package/shared/enums.js +8 -1
  230. package/shared/form-associated.js +1 -1
  231. package/shared/form-elements.cjs +7 -7
  232. package/shared/form-elements.js +8 -8
  233. package/shared/foundation/vivid-element/vivid-element.d.ts +1 -0
  234. package/shared/patterns/anchored.d.ts +891 -10
  235. package/shared/patterns/trapped-focus.d.ts +2 -0
  236. package/shared/presentationDate.cjs +5 -7
  237. package/shared/presentationDate.js +5 -7
  238. package/shared/slider.template.cjs +4 -4
  239. package/shared/slider.template.js +4 -4
  240. package/shared/text-anchor.template.cjs +2 -2
  241. package/shared/text-anchor.template.js +2 -2
  242. package/shared/text-field.cjs +555 -2
  243. package/shared/text-field.js +554 -2
  244. package/shared/text-field2.cjs +2 -572
  245. package/shared/text-field2.js +2 -571
  246. package/shared/trapped-focus.cjs +7 -1
  247. package/shared/trapped-focus.js +7 -1
  248. package/shared/utils/mixins.d.ts +3 -0
  249. package/shared/vivid-element.cjs +3 -0
  250. package/shared/vivid-element.js +4 -1
  251. package/side-drawer/index.cjs +1 -1
  252. package/side-drawer/index.js +1 -1
  253. package/slider/index.cjs +1 -1
  254. package/slider/index.js +1 -1
  255. package/split-button/index.cjs +1 -1
  256. package/split-button/index.js +1 -1
  257. package/styles/core/all.css +1 -1
  258. package/styles/core/theme.css +1 -1
  259. package/styles/core/typography.css +1 -1
  260. package/styles/tokens/theme-dark.css +4 -4
  261. package/styles/tokens/theme-light.css +4 -4
  262. package/styles/tokens/vivid-2-compat.css +1 -1
  263. package/switch/index.cjs +1 -1
  264. package/switch/index.js +1 -1
  265. package/tab/index.cjs +1 -1
  266. package/tab/index.js +1 -1
  267. package/tab-panel/index.cjs +1 -1
  268. package/tab-panel/index.js +1 -1
  269. package/tabs/index.cjs +1 -1
  270. package/tabs/index.js +1 -1
  271. package/tag/index.cjs +1 -1
  272. package/tag/index.js +1 -1
  273. package/tag-group/index.cjs +1 -1
  274. package/tag-group/index.js +1 -1
  275. package/text-anchor/index.js +1 -1
  276. package/text-area/index.cjs +1 -1
  277. package/text-area/index.js +1 -1
  278. package/text-field/index.cjs +1 -1
  279. package/text-field/index.js +1 -1
  280. package/time-picker/index.cjs +1 -1
  281. package/time-picker/index.js +1 -1
  282. package/toggletip/index.cjs +1 -1
  283. package/toggletip/index.js +1 -1
  284. package/tooltip/index.cjs +1 -1
  285. package/tooltip/index.js +1 -1
  286. package/tree-item/index.cjs +1 -1
  287. package/tree-item/index.js +1 -1
  288. package/tree-view/index.cjs +1 -1
  289. package/tree-view/index.js +1 -1
  290. package/video-player/index.cjs +1 -1
  291. package/video-player/index.js +1 -1
  292. package/vivid.api.json +22795 -1
@@ -1,138 +1,154 @@
1
1
  'use strict';
2
2
 
3
- const definition = require('./definition63.cjs');
3
+ const definition = require('./definition64.cjs');
4
4
  const vividElement = require('./vivid-element.cjs');
5
5
  const anchored = require('./anchored.cjs');
6
6
  const index = require('./index.cjs');
7
7
  const classNames = require('./class-names.cjs');
8
+ const when = require('./when.cjs');
8
9
 
9
- const styles = ":host :host{display:var(--_popup-display, inline)}:host :host([slotted-anchor]){--_popup-display: contents}.control{pointer-events:none}.tooltip{width:var(--tooltip-inline-size, auto);max-inline-size:var(--tooltip-max-inline-size, 30ch)}.tooltip-text{padding:8px 12px;color:var(--vvd-color-canvas-text);font:var(--vvd-typography-base-bold)}";
10
+ const styles = ":host :host{display:var(--_popup-display, inline)}:host :host([slotted-anchor]){--_popup-display: contents}.content-wrapper{width:var(--toggletip-inline-size, auto);padding:16px;max-inline-size:var(--toggletip-max-inline-size, 30ch)}.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}";
10
11
 
11
12
  var __defProp = Object.defineProperty;
12
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
- var __typeError = (msg) => {
14
- throw TypeError(msg);
15
- };
16
13
  var __decorateClass = (decorators, target, key, kind) => {
17
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
14
+ var result = void 0 ;
18
15
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
19
16
  if (decorator = decorators[i])
20
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
21
- if (kind && result) __defProp(target, key, result);
17
+ result = (decorator(target, key, result) ) || result;
18
+ if (result) __defProp(target, key, result);
22
19
  return result;
23
20
  };
24
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
25
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
26
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
27
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
28
- var _Tooltip_instances, setupAnchor_fn, cleanupAnchor_fn, _show, _hide, updateListeners_fn, _closeOnEscape;
29
- let Tooltip = class extends vividElement.VividElement {
21
+ class Toggletip extends anchored.Anchored(vividElement.VividElement) {
30
22
  constructor() {
31
23
  super(...arguments);
32
- __privateAdd(this, _Tooltip_instances);
24
+ this.#ANCHOR_ARIA_LABEL_SUFFIX = " ; Show more information";
25
+ this.alternate = false;
26
+ this.placement = "right";
33
27
  this.open = false;
34
- __privateAdd(this, _show, () => {
35
- this.open = true;
36
- });
37
- __privateAdd(this, _hide, () => {
38
- this.open = false;
39
- });
40
- __privateAdd(this, _closeOnEscape, (e) => {
41
- if (e.key === "Escape") __privateGet(this, _hide).call(this);
42
- });
28
+ this.#openIfClosed = () => {
29
+ if (!this.open) vividElement.DOM.queueUpdate(() => this.open = true);
30
+ };
31
+ this.#closeOnClickOutside = (e) => {
32
+ const clickedOutside = !this.contains(e.target);
33
+ const clickedOnAnchor = this._anchorEl?.contains(e.target);
34
+ if (clickedOutside || clickedOnAnchor) this.open = false;
35
+ };
36
+ this.#closeOnEscape = (e) => {
37
+ if (e.key === "Escape") {
38
+ this.open = false;
39
+ }
40
+ };
41
+ }
42
+ #ANCHOR_ARIA_LABEL_SUFFIX;
43
+ openChanged(oldValue, newValue) {
44
+ if (oldValue === void 0) return;
45
+ if (newValue) {
46
+ this.setAttribute("role", "status");
47
+ } else {
48
+ this.removeAttribute("role");
49
+ }
50
+ this.#updateListeners();
51
+ if (this._anchorEl) {
52
+ this.#updateAnchor(this._anchorEl);
53
+ }
43
54
  }
44
55
  connectedCallback() {
45
56
  super.connectedCallback();
46
- __privateMethod(this, _Tooltip_instances, updateListeners_fn).call(this);
57
+ this.#updateListeners();
47
58
  }
48
59
  disconnectedCallback() {
49
60
  super.disconnectedCallback();
50
- __privateMethod(this, _Tooltip_instances, updateListeners_fn).call(this);
61
+ this.#updateListeners();
51
62
  }
52
63
  /**
53
64
  * @internal
54
65
  */
55
66
  _anchorElChanged(oldValue, newValue) {
56
- if (oldValue) __privateMethod(this, _Tooltip_instances, cleanupAnchor_fn).call(this, oldValue);
57
- if (newValue) __privateMethod(this, _Tooltip_instances, setupAnchor_fn).call(this, newValue);
67
+ if (oldValue) this.#cleanupAnchor(oldValue);
68
+ if (newValue) this.#setupAnchor(newValue);
58
69
  }
59
- /**
60
- * @internal
61
- */
62
- openChanged(oldValue) {
63
- if (oldValue === void 0) return;
64
- __privateMethod(this, _Tooltip_instances, updateListeners_fn).call(this);
70
+ #setupAnchor(a) {
71
+ a.addEventListener("click", this.#openIfClosed, true);
72
+ a.ariaLabel = (a.ariaLabel ?? "") + this.#ANCHOR_ARIA_LABEL_SUFFIX;
73
+ this.#updateAnchor(a);
65
74
  }
66
- };
67
- _Tooltip_instances = new WeakSet();
68
- setupAnchor_fn = function(a) {
69
- a.addEventListener("mouseover", __privateGet(this, _show));
70
- a.addEventListener("mouseout", __privateGet(this, _hide));
71
- a.addEventListener("focusin", __privateGet(this, _show));
72
- a.addEventListener("focusout", __privateGet(this, _hide));
73
- };
74
- cleanupAnchor_fn = function(a) {
75
- a.removeEventListener("mouseover", __privateGet(this, _show));
76
- a.removeEventListener("mouseout", __privateGet(this, _hide));
77
- a.removeEventListener("focusin", __privateGet(this, _show));
78
- a.removeEventListener("focusout", __privateGet(this, _hide));
79
- };
80
- _show = new WeakMap();
81
- _hide = new WeakMap();
82
- updateListeners_fn = function() {
83
- document.removeEventListener("keydown", __privateGet(this, _closeOnEscape));
84
- if (this.open && this.isConnected) {
85
- document.addEventListener("keydown", __privateGet(this, _closeOnEscape));
75
+ #updateAnchor(a) {
76
+ a.setAttribute("aria-expanded", this.open.toString());
86
77
  }
87
- };
88
- _closeOnEscape = new WeakMap();
78
+ #cleanupAnchor(a) {
79
+ a.removeEventListener("click", this.#openIfClosed, true);
80
+ if (a.ariaLabel)
81
+ a.ariaLabel = a.ariaLabel.replace(this.#ANCHOR_ARIA_LABEL_SUFFIX, "");
82
+ }
83
+ #openIfClosed;
84
+ #updateListeners() {
85
+ document.removeEventListener("click", this.#closeOnClickOutside);
86
+ document.removeEventListener("keydown", this.#closeOnEscape);
87
+ if (this.open && this.isConnected) {
88
+ document.addEventListener("click", this.#closeOnClickOutside);
89
+ document.addEventListener("keydown", this.#closeOnEscape);
90
+ }
91
+ }
92
+ #closeOnClickOutside;
93
+ #closeOnEscape;
94
+ }
89
95
  __decorateClass([
90
96
  vividElement.attr
91
- ], Tooltip.prototype, "text", 2);
97
+ ], Toggletip.prototype, "headline");
98
+ __decorateClass([
99
+ vividElement.attr({ mode: "boolean" })
100
+ ], Toggletip.prototype, "alternate");
92
101
  __decorateClass([
93
102
  vividElement.attr({ mode: "fromView" })
94
- ], Tooltip.prototype, "placement", 2);
103
+ ], Toggletip.prototype, "placement");
95
104
  __decorateClass([
96
105
  vividElement.attr({ mode: "boolean" })
97
- ], Tooltip.prototype, "open", 2);
98
- Tooltip = __decorateClass([
99
- anchored.anchored
100
- ], Tooltip);
106
+ ], Toggletip.prototype, "open");
101
107
 
102
- const getClasses = ({ open }) => classNames.classNames("control", ["open", Boolean(open)]);
103
- const TooltipTemplate = (context) => {
104
- const popupTag = context.tagFor(definition.Popup);
108
+ const getClasses = (_) => classNames.classNames("control");
109
+ const ToggletipTemplate = (context) => {
110
+ const popup = context.tagFor(definition.Popup);
105
111
  const anchorSlotTemplate = anchored.anchorSlotTemplateFactory();
106
112
  return vividElement.html`
107
- ${anchorSlotTemplate}
108
- <${popupTag} class="${getClasses}" arrow alternate
109
- :placement=${(x) => x.placement}
110
- :anchor="${(x) => x._anchorEl}"
111
- :open="${(x) => x.open}"
112
- @keydown="${(x, c) => {
113
- if (x.open && index.handleEscapeKeyAndStopPropogation(c.event)) {
114
- x.open = false;
113
+ ${anchorSlotTemplate}
114
+ <${popup}
115
+ @keydown="${(x, { event }) => {
116
+ if (x.open && index.handleEscapeKeyAndStopPropogation(event)) {
117
+ return false;
115
118
  }
119
+ return true;
116
120
  }}"
117
- exportparts="vvd-theme-alternate">
118
- <div class="tooltip" role="tooltip">
119
- <header part="vvd-theme-alternate" class="tooltip-header">
120
- <div class="tooltip-text">${(x) => x.text}</div>
121
- </header>
122
- </div>
123
- </${popupTag}>`;
121
+ class="${getClasses}"
122
+ arrow
123
+ :anchor="${(x) => x._anchorEl}"
124
+ :open="${(x) => x.open}"
125
+ ?alternate="${(x) => !x.alternate}"
126
+ placement="${(x) => x.placement}"
127
+ exportparts="vvd-theme-alternate"
128
+ >
129
+ <div class="content-wrapper">
130
+ ${when.when(
131
+ (x) => x.headline,
132
+ vividElement.html`<header class="headline">${(x) => x.headline}</header>`
133
+ )}
134
+ <slot></slot>
135
+ <footer class="action-items"><slot name="action-items"></slot></footer>
136
+ </div>
137
+ </${popup}>
138
+ `;
124
139
  };
125
140
 
126
- const tooltipDefinition = vividElement.defineVividComponent(
127
- "tooltip",
128
- Tooltip,
129
- TooltipTemplate,
141
+ const toggletipDefinition = vividElement.defineVividComponent(
142
+ "toggletip",
143
+ Toggletip,
144
+ ToggletipTemplate,
130
145
  [definition.popupDefinition],
131
146
  {
132
147
  styles
133
148
  }
134
149
  );
135
- const registerTooltip = vividElement.createRegisterFunction(tooltipDefinition);
150
+ const registerToggletip = vividElement.createRegisterFunction(toggletipDefinition);
136
151
 
137
- exports.registerTooltip = registerTooltip;
138
- exports.tooltipDefinition = tooltipDefinition;
152
+ exports.Toggletip = Toggletip;
153
+ exports.registerToggletip = registerToggletip;
154
+ exports.toggletipDefinition = toggletipDefinition;
@@ -1,135 +1,150 @@
1
- import { P as Popup, p as popupDefinition } from './definition63.js';
2
- import { V as VividElement, a as attr, h as html, d as defineVividComponent, f as createRegisterFunction } from './vivid-element.js';
3
- import { a as anchored, b as anchorSlotTemplateFactory } from './anchored.js';
1
+ import { P as Popup, p as popupDefinition } from './definition64.js';
2
+ import { D as DOM, V as VividElement, a as attr, h as html, d as createRegisterFunction, f as defineVividComponent } from './vivid-element.js';
3
+ import { A as Anchored, a as anchorSlotTemplateFactory } from './anchored.js';
4
4
  import { h as handleEscapeKeyAndStopPropogation } from './index.js';
5
5
  import { c as classNames } from './class-names.js';
6
+ import { w as when } from './when.js';
6
7
 
7
- const styles = ":host :host{display:var(--_popup-display, inline)}:host :host([slotted-anchor]){--_popup-display: contents}.control{pointer-events:none}.tooltip{width:var(--tooltip-inline-size, auto);max-inline-size:var(--tooltip-max-inline-size, 30ch)}.tooltip-text{padding:8px 12px;color:var(--vvd-color-canvas-text);font:var(--vvd-typography-base-bold)}";
8
+ const styles = ":host :host{display:var(--_popup-display, inline)}:host :host([slotted-anchor]){--_popup-display: contents}.content-wrapper{width:var(--toggletip-inline-size, auto);padding:16px;max-inline-size:var(--toggletip-max-inline-size, 30ch)}.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}";
8
9
 
9
10
  var __defProp = Object.defineProperty;
10
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
11
- var __typeError = (msg) => {
12
- throw TypeError(msg);
13
- };
14
11
  var __decorateClass = (decorators, target, key, kind) => {
15
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
12
+ var result = void 0 ;
16
13
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
17
14
  if (decorator = decorators[i])
18
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
19
- if (kind && result) __defProp(target, key, result);
15
+ result = (decorator(target, key, result) ) || result;
16
+ if (result) __defProp(target, key, result);
20
17
  return result;
21
18
  };
22
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
23
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
24
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
25
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
26
- var _Tooltip_instances, setupAnchor_fn, cleanupAnchor_fn, _show, _hide, updateListeners_fn, _closeOnEscape;
27
- let Tooltip = class extends VividElement {
19
+ class Toggletip extends Anchored(VividElement) {
28
20
  constructor() {
29
21
  super(...arguments);
30
- __privateAdd(this, _Tooltip_instances);
22
+ this.#ANCHOR_ARIA_LABEL_SUFFIX = " ; Show more information";
23
+ this.alternate = false;
24
+ this.placement = "right";
31
25
  this.open = false;
32
- __privateAdd(this, _show, () => {
33
- this.open = true;
34
- });
35
- __privateAdd(this, _hide, () => {
36
- this.open = false;
37
- });
38
- __privateAdd(this, _closeOnEscape, (e) => {
39
- if (e.key === "Escape") __privateGet(this, _hide).call(this);
40
- });
26
+ this.#openIfClosed = () => {
27
+ if (!this.open) DOM.queueUpdate(() => this.open = true);
28
+ };
29
+ this.#closeOnClickOutside = (e) => {
30
+ const clickedOutside = !this.contains(e.target);
31
+ const clickedOnAnchor = this._anchorEl?.contains(e.target);
32
+ if (clickedOutside || clickedOnAnchor) this.open = false;
33
+ };
34
+ this.#closeOnEscape = (e) => {
35
+ if (e.key === "Escape") {
36
+ this.open = false;
37
+ }
38
+ };
39
+ }
40
+ #ANCHOR_ARIA_LABEL_SUFFIX;
41
+ openChanged(oldValue, newValue) {
42
+ if (oldValue === void 0) return;
43
+ if (newValue) {
44
+ this.setAttribute("role", "status");
45
+ } else {
46
+ this.removeAttribute("role");
47
+ }
48
+ this.#updateListeners();
49
+ if (this._anchorEl) {
50
+ this.#updateAnchor(this._anchorEl);
51
+ }
41
52
  }
42
53
  connectedCallback() {
43
54
  super.connectedCallback();
44
- __privateMethod(this, _Tooltip_instances, updateListeners_fn).call(this);
55
+ this.#updateListeners();
45
56
  }
46
57
  disconnectedCallback() {
47
58
  super.disconnectedCallback();
48
- __privateMethod(this, _Tooltip_instances, updateListeners_fn).call(this);
59
+ this.#updateListeners();
49
60
  }
50
61
  /**
51
62
  * @internal
52
63
  */
53
64
  _anchorElChanged(oldValue, newValue) {
54
- if (oldValue) __privateMethod(this, _Tooltip_instances, cleanupAnchor_fn).call(this, oldValue);
55
- if (newValue) __privateMethod(this, _Tooltip_instances, setupAnchor_fn).call(this, newValue);
65
+ if (oldValue) this.#cleanupAnchor(oldValue);
66
+ if (newValue) this.#setupAnchor(newValue);
56
67
  }
57
- /**
58
- * @internal
59
- */
60
- openChanged(oldValue) {
61
- if (oldValue === void 0) return;
62
- __privateMethod(this, _Tooltip_instances, updateListeners_fn).call(this);
68
+ #setupAnchor(a) {
69
+ a.addEventListener("click", this.#openIfClosed, true);
70
+ a.ariaLabel = (a.ariaLabel ?? "") + this.#ANCHOR_ARIA_LABEL_SUFFIX;
71
+ this.#updateAnchor(a);
63
72
  }
64
- };
65
- _Tooltip_instances = new WeakSet();
66
- setupAnchor_fn = function(a) {
67
- a.addEventListener("mouseover", __privateGet(this, _show));
68
- a.addEventListener("mouseout", __privateGet(this, _hide));
69
- a.addEventListener("focusin", __privateGet(this, _show));
70
- a.addEventListener("focusout", __privateGet(this, _hide));
71
- };
72
- cleanupAnchor_fn = function(a) {
73
- a.removeEventListener("mouseover", __privateGet(this, _show));
74
- a.removeEventListener("mouseout", __privateGet(this, _hide));
75
- a.removeEventListener("focusin", __privateGet(this, _show));
76
- a.removeEventListener("focusout", __privateGet(this, _hide));
77
- };
78
- _show = new WeakMap();
79
- _hide = new WeakMap();
80
- updateListeners_fn = function() {
81
- document.removeEventListener("keydown", __privateGet(this, _closeOnEscape));
82
- if (this.open && this.isConnected) {
83
- document.addEventListener("keydown", __privateGet(this, _closeOnEscape));
73
+ #updateAnchor(a) {
74
+ a.setAttribute("aria-expanded", this.open.toString());
84
75
  }
85
- };
86
- _closeOnEscape = new WeakMap();
76
+ #cleanupAnchor(a) {
77
+ a.removeEventListener("click", this.#openIfClosed, true);
78
+ if (a.ariaLabel)
79
+ a.ariaLabel = a.ariaLabel.replace(this.#ANCHOR_ARIA_LABEL_SUFFIX, "");
80
+ }
81
+ #openIfClosed;
82
+ #updateListeners() {
83
+ document.removeEventListener("click", this.#closeOnClickOutside);
84
+ document.removeEventListener("keydown", this.#closeOnEscape);
85
+ if (this.open && this.isConnected) {
86
+ document.addEventListener("click", this.#closeOnClickOutside);
87
+ document.addEventListener("keydown", this.#closeOnEscape);
88
+ }
89
+ }
90
+ #closeOnClickOutside;
91
+ #closeOnEscape;
92
+ }
87
93
  __decorateClass([
88
94
  attr
89
- ], Tooltip.prototype, "text", 2);
95
+ ], Toggletip.prototype, "headline");
96
+ __decorateClass([
97
+ attr({ mode: "boolean" })
98
+ ], Toggletip.prototype, "alternate");
90
99
  __decorateClass([
91
100
  attr({ mode: "fromView" })
92
- ], Tooltip.prototype, "placement", 2);
101
+ ], Toggletip.prototype, "placement");
93
102
  __decorateClass([
94
103
  attr({ mode: "boolean" })
95
- ], Tooltip.prototype, "open", 2);
96
- Tooltip = __decorateClass([
97
- anchored
98
- ], Tooltip);
104
+ ], Toggletip.prototype, "open");
99
105
 
100
- const getClasses = ({ open }) => classNames("control", ["open", Boolean(open)]);
101
- const TooltipTemplate = (context) => {
102
- const popupTag = context.tagFor(Popup);
106
+ const getClasses = (_) => classNames("control");
107
+ const ToggletipTemplate = (context) => {
108
+ const popup = context.tagFor(Popup);
103
109
  const anchorSlotTemplate = anchorSlotTemplateFactory();
104
110
  return html`
105
- ${anchorSlotTemplate}
106
- <${popupTag} class="${getClasses}" arrow alternate
107
- :placement=${(x) => x.placement}
108
- :anchor="${(x) => x._anchorEl}"
109
- :open="${(x) => x.open}"
110
- @keydown="${(x, c) => {
111
- if (x.open && handleEscapeKeyAndStopPropogation(c.event)) {
112
- x.open = false;
111
+ ${anchorSlotTemplate}
112
+ <${popup}
113
+ @keydown="${(x, { event }) => {
114
+ if (x.open && handleEscapeKeyAndStopPropogation(event)) {
115
+ return false;
113
116
  }
117
+ return true;
114
118
  }}"
115
- exportparts="vvd-theme-alternate">
116
- <div class="tooltip" role="tooltip">
117
- <header part="vvd-theme-alternate" class="tooltip-header">
118
- <div class="tooltip-text">${(x) => x.text}</div>
119
- </header>
120
- </div>
121
- </${popupTag}>`;
119
+ class="${getClasses}"
120
+ arrow
121
+ :anchor="${(x) => x._anchorEl}"
122
+ :open="${(x) => x.open}"
123
+ ?alternate="${(x) => !x.alternate}"
124
+ placement="${(x) => x.placement}"
125
+ exportparts="vvd-theme-alternate"
126
+ >
127
+ <div class="content-wrapper">
128
+ ${when(
129
+ (x) => x.headline,
130
+ html`<header class="headline">${(x) => x.headline}</header>`
131
+ )}
132
+ <slot></slot>
133
+ <footer class="action-items"><slot name="action-items"></slot></footer>
134
+ </div>
135
+ </${popup}>
136
+ `;
122
137
  };
123
138
 
124
- const tooltipDefinition = defineVividComponent(
125
- "tooltip",
126
- Tooltip,
127
- TooltipTemplate,
139
+ const toggletipDefinition = defineVividComponent(
140
+ "toggletip",
141
+ Toggletip,
142
+ ToggletipTemplate,
128
143
  [popupDefinition],
129
144
  {
130
145
  styles
131
146
  }
132
147
  );
133
- const registerTooltip = createRegisterFunction(tooltipDefinition);
148
+ const registerToggletip = createRegisterFunction(toggletipDefinition);
134
149
 
135
- export { registerTooltip as r, tooltipDefinition as t };
150
+ export { Toggletip as T, registerToggletip as r, toggletipDefinition as t };