@vonage/vivid 3.37.0 → 3.39.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 (157) hide show
  1. package/accordion/index.js +2 -2
  2. package/accordion-item/index.js +2 -2
  3. package/alert/index.js +4 -4
  4. package/avatar/index.js +1 -1
  5. package/badge/index.js +1 -1
  6. package/banner/index.js +3 -3
  7. package/breadcrumb-item/index.js +2 -2
  8. package/button/index.js +3 -3
  9. package/card/index.js +2 -2
  10. package/checkbox/index.js +2 -2
  11. package/combobox/index.js +6 -6
  12. package/custom-elements.json +4199 -3875
  13. package/data-grid/index.js +1 -1
  14. package/date-picker/index.js +9 -7
  15. package/date-range-picker/index.js +36 -0
  16. package/dialog/index.js +5 -5
  17. package/divider/index.js +1 -1
  18. package/elevation/index.js +1 -1
  19. package/empty-state/index.js +2 -2
  20. package/fab/index.js +3 -3
  21. package/file-picker/index.js +5 -4
  22. package/focus/index.js +1 -1
  23. package/header/index.js +2 -2
  24. package/icon/index.js +1 -1
  25. package/index.js +43 -40
  26. package/layout/index.js +1 -1
  27. package/lib/components.d.ts +1 -0
  28. package/lib/date-picker/date-picker.d.ts +4 -14
  29. package/lib/date-range-picker/date-range-picker.d.ts +15 -0
  30. package/lib/date-range-picker/definition.d.ts +3 -0
  31. package/lib/file-picker/file-picker.d.ts +8 -5
  32. package/lib/file-picker/file-picker.form-associated.d.ts +10 -0
  33. package/lib/file-picker/locale.d.ts +6 -0
  34. package/lib/menu-item/menu-item.d.ts +6 -0
  35. package/lib/tag-group/tag-group.d.ts +1 -0
  36. package/listbox/index.js +4 -4
  37. package/locales/en-GB.js +27 -3
  38. package/locales/en-US.js +27 -3
  39. package/locales/ja-JP.js +25 -1
  40. package/locales/zh-CN.js +25 -1
  41. package/menu/index.js +7 -7
  42. package/menu-item/index.js +3 -3
  43. package/nav/index.js +1 -1
  44. package/nav-disclosure/index.js +3 -3
  45. package/nav-item/index.js +3 -3
  46. package/note/index.js +2 -2
  47. package/number-field/index.js +5 -5
  48. package/option/index.js +3 -3
  49. package/package.json +1 -1
  50. package/pagination/index.js +4 -4
  51. package/popup/index.js +5 -5
  52. package/progress/index.js +1 -1
  53. package/progress-ring/index.js +1 -1
  54. package/radio/index.js +2 -2
  55. package/radio-group/index.js +1 -1
  56. package/select/index.js +7 -7
  57. package/shared/date-picker/calendar/dateRange.d.ts +5 -0
  58. package/shared/date-picker/calendar/presentationDateRange.d.ts +5 -0
  59. package/shared/date-picker/date-picker-base.d.ts +19 -0
  60. package/shared/date-picker/date-picker-base.form-associated.d.ts +10 -0
  61. package/shared/date-picker/date-picker-base.template.d.ts +4 -0
  62. package/{lib → shared}/date-picker/locale.d.ts +6 -0
  63. package/shared/definition.js +4 -4
  64. package/shared/definition10.js +9 -14
  65. package/shared/definition11.js +1 -1
  66. package/shared/definition12.js +1 -1
  67. package/shared/definition13.js +3 -3
  68. package/shared/definition14.js +3 -3
  69. package/shared/definition15.js +5 -5
  70. package/shared/definition16.js +3 -3
  71. package/shared/definition17.js +44 -6055
  72. package/shared/definition18.js +353 -213
  73. package/shared/definition19.js +251 -67
  74. package/shared/definition2.js +1 -1
  75. package/shared/definition20.js +66 -58
  76. package/shared/definition21.js +43 -84
  77. package/shared/definition22.js +75 -2298
  78. package/shared/definition23.js +2361 -45
  79. package/shared/definition24.js +63 -27
  80. package/shared/definition25.js +24 -51
  81. package/shared/definition26.js +36 -805
  82. package/shared/definition27.js +828 -49
  83. package/shared/definition28.js +52 -89
  84. package/shared/definition29.js +88 -24
  85. package/shared/definition3.js +1 -1
  86. package/shared/definition30.js +25 -12
  87. package/shared/definition31.js +12 -53
  88. package/shared/definition32.js +28 -487
  89. package/shared/definition33.js +427 -197
  90. package/shared/definition34.js +260 -174
  91. package/shared/definition35.js +187 -69
  92. package/shared/definition36.js +68 -55
  93. package/shared/definition37.js +61 -421
  94. package/shared/definition38.js +435 -35
  95. package/shared/definition39.js +30 -679
  96. package/shared/definition4.js +3 -3
  97. package/shared/definition40.js +661 -77
  98. package/shared/definition41.js +77 -557
  99. package/shared/definition42.js +559 -106
  100. package/shared/definition43.js +105 -136
  101. package/shared/definition44.js +153 -17
  102. package/shared/definition45.js +16 -79
  103. package/shared/definition46.js +53 -475
  104. package/shared/definition47.js +506 -20
  105. package/shared/definition48.js +22 -121
  106. package/shared/definition49.js +115 -262
  107. package/shared/definition5.js +2 -2
  108. package/shared/definition50.js +248 -120
  109. package/shared/definition51.js +139 -123
  110. package/shared/definition52.js +84 -74
  111. package/shared/definition53.js +114 -69
  112. package/shared/definition54.js +81 -292
  113. package/shared/definition55.js +302 -13
  114. package/shared/definition56.js +11 -41
  115. package/shared/definition57.js +20 -154
  116. package/shared/definition58.js +181 -0
  117. package/shared/definition6.js +2 -2
  118. package/shared/definition7.js +2 -2
  119. package/shared/definition8.js +3 -3
  120. package/shared/index2.js +1 -1
  121. package/shared/listbox.js +1 -1
  122. package/shared/localization/Locale.d.ts +3 -1
  123. package/shared/localized.js +9 -0
  124. package/shared/presentationDate.js +6133 -0
  125. package/shared/text-anchor.template.js +4 -4
  126. package/shared/text-field.js +1 -1
  127. package/side-drawer/index.js +1 -1
  128. package/slider/index.js +2 -2
  129. package/split-button/index.js +3 -3
  130. package/style.css +246 -183
  131. package/styles/core/all.css +1 -1
  132. package/styles/core/theme.css +1 -1
  133. package/styles/core/typography.css +1 -1
  134. package/styles/tokens/theme-dark.css +4 -4
  135. package/styles/tokens/theme-light.css +4 -4
  136. package/styles/tokens/vivid-2-compat.css +1 -1
  137. package/switch/index.js +3 -3
  138. package/tab/index.js +3 -3
  139. package/tab-panel/index.js +1 -1
  140. package/tabs/index.js +5 -5
  141. package/tag/index.js +3 -3
  142. package/tag-group/index.js +1 -1
  143. package/text-area/index.js +3 -3
  144. package/text-field/index.js +3 -3
  145. package/toggletip/index.js +6 -6
  146. package/tooltip/index.js +6 -6
  147. package/tree-item/index.js +3 -3
  148. package/tree-view/index.js +1 -1
  149. package/vivid.api.json +105 -0
  150. package/lib/date-picker/date-picker.form-associated.d.ts +0 -11
  151. package/lib/date-picker/date-picker.template.d.ts +0 -4
  152. /package/{lib → shared}/date-picker/calendar/calendarGrid.d.ts +0 -0
  153. /package/{lib → shared}/date-picker/calendar/dateStr.d.ts +0 -0
  154. /package/{lib → shared}/date-picker/calendar/month.d.ts +0 -0
  155. /package/{lib → shared}/date-picker/calendar/monthPickerGrid.d.ts +0 -0
  156. /package/{lib → shared}/date-picker/calendar/presentationDate.d.ts +0 -0
  157. /package/{lib → shared}/date-picker/calendar/year.d.ts +0 -0
@@ -1,10 +1,17 @@
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 './definition57.js';
1
+ import { a as attr, o as observable, h as html, r as registerFactory } from './index.js';
2
+ import { f as focusRegistries } from './definition56.js';
3
+ import { a as iconRegistries } from './definition25.js';
4
+ import { A as AffixIcon, a as affixIconTemplateFactory } from './affix.js';
5
+ import { e as errorText, f as formElements, F as FormElementSuccessText, a as FormElementHelperText, b as FormElementCharCount, g as getFeedbackTemplate } from './index2.js';
6
+ import { T as TextField$1 } from './text-field2.js';
7
+ import { a as applyMixins } from './apply-mixins.js';
8
+ import { s as styles } from './text-field.js';
9
+ import { f as focusTemplateFactory } from './focus2.js';
3
10
  import { w as when } from './when.js';
11
+ import { s as slotted } from './slotted.js';
12
+ import { r as ref } from './ref.js';
4
13
  import { c as classNames } from './class-names.js';
5
14
 
6
- const styles = "/**\n * Do not edit directly\n * Generated on Tue, 26 Sep 2023 13:00:58 GMT\n */\n.control {\n display: inline-block;\n}\n\n.content-wrapper {\n width: var(--toggletip-inline-size, auto);\n padding: 16px;\n}\n\n.headline {\n font: var(--vvd-typography-base-bold);\n}\n\n.action-items {\n display: flex;\n justify-content: flex-end;\n gap: 10px;\n}\n\n::slotted([slot=action-items]) {\n margin-block-start: 16px;\n}";
7
-
8
15
  var __defProp = Object.defineProperty;
9
16
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
10
17
  var __decorateClass = (decorators, target, key, kind) => {
@@ -16,135 +23,144 @@ var __decorateClass = (decorators, target, key, kind) => {
16
23
  __defProp(target, key, result);
17
24
  return result;
18
25
  };
19
- class Toggletip extends FoundationElement {
20
- constructor() {
21
- super(...arguments);
22
- this.#anchorEl = null;
23
- this.#observeMissingAnchor = (anchorId) => {
24
- this.#observer = new MutationObserver(() => {
25
- const anchor = document.getElementById(anchorId);
26
- if (anchor) {
27
- this.#anchorEl = anchor;
28
- this.#setupAnchor(this.#anchorEl);
29
- this.#observer.disconnect();
30
- this.#observer = void 0;
31
- }
32
- });
33
- this.#observer.observe(document.body, { childList: true, subtree: true });
34
- };
35
- this.#ANCHOR_ARIA_LABEL_SUFFIX = " ; Show more information";
36
- this.alternate = false;
37
- this.placement = "right";
38
- this.anchor = "";
39
- this.open = false;
40
- this.#openIfClosed = () => {
41
- if (!this.open)
42
- DOM.queueUpdate(() => this.open = true);
43
- };
44
- this.#closeOnClickOutside = (e) => {
45
- if (!this.contains(e.target))
46
- this.open = false;
47
- };
48
- this.#closeOnEscape = (e) => {
49
- if (e.key === "Escape")
50
- this.open = false;
51
- };
52
- }
53
- #observer;
54
- #anchorEl;
55
- #observeMissingAnchor;
56
- #ANCHOR_ARIA_LABEL_SUFFIX;
57
- anchorChanged(_, newValue) {
58
- if (this.#anchorEl)
59
- this.#cleanupAnchor(this.#anchorEl);
60
- this.#observer?.disconnect();
61
- this.#anchorEl = newValue instanceof HTMLElement ? newValue : document.getElementById(newValue);
62
- if (this.#anchorEl) {
63
- this.#setupAnchor(this.#anchorEl);
64
- } else {
65
- this.#observeMissingAnchor(newValue);
66
- }
67
- }
68
- openChanged(oldValue, newValue) {
69
- if (oldValue === void 0)
70
- return;
71
- if (newValue) {
72
- document.addEventListener("click", this.#closeOnClickOutside);
73
- document.addEventListener("keydown", this.#closeOnEscape);
74
- this.setAttribute("role", "status");
75
- } else {
76
- document.removeEventListener("click", this.#closeOnClickOutside);
77
- document.removeEventListener("keydown", this.#closeOnEscape);
78
- this.removeAttribute("role");
79
- }
80
- if (this.#anchorEl) {
81
- this.#anchorEl.ariaExpanded = this.open.toString();
82
- }
83
- }
84
- disconnectedCallback() {
85
- super.disconnectedCallback();
86
- if (this.#anchorEl)
87
- this.#cleanupAnchor(this.#anchorEl);
88
- this.#observer?.disconnect();
89
- document.removeEventListener("keydown", this.#closeOnEscape);
90
- }
91
- #setupAnchor(a) {
92
- a.addEventListener("click", this.#openIfClosed, true);
93
- a.ariaLabel = (a.ariaLabel ?? "") + this.#ANCHOR_ARIA_LABEL_SUFFIX;
94
- }
95
- #cleanupAnchor(a) {
96
- a.removeEventListener("click", this.#openIfClosed, true);
97
- if (a.ariaLabel)
98
- a.ariaLabel = a.ariaLabel.replace(this.#ANCHOR_ARIA_LABEL_SUFFIX, "");
99
- }
100
- #openIfClosed;
101
- #closeOnClickOutside;
102
- #closeOnEscape;
103
- }
26
+ let TextField = class extends TextField$1 {
27
+ };
104
28
  __decorateClass([
105
29
  attr
106
- ], Toggletip.prototype, "headline", 2);
30
+ ], TextField.prototype, "appearance", 2);
107
31
  __decorateClass([
108
- attr({ mode: "boolean" })
109
- ], Toggletip.prototype, "alternate", 2);
32
+ attr
33
+ ], TextField.prototype, "shape", 2);
110
34
  __decorateClass([
111
- attr({ mode: "fromView" })
112
- ], Toggletip.prototype, "placement", 2);
35
+ attr
36
+ ], TextField.prototype, "autoComplete", 2);
113
37
  __decorateClass([
114
- attr({ mode: "fromView" })
115
- ], Toggletip.prototype, "anchor", 2);
38
+ observable
39
+ ], TextField.prototype, "actionItemsSlottedContent", 2);
116
40
  __decorateClass([
117
- attr({ mode: "boolean" })
118
- ], Toggletip.prototype, "open", 2);
41
+ observable
42
+ ], TextField.prototype, "leadingActionItemsSlottedContent", 2);
43
+ TextField = __decorateClass([
44
+ errorText,
45
+ formElements
46
+ ], TextField);
47
+ applyMixins(TextField, AffixIcon, FormElementCharCount, FormElementHelperText, FormElementSuccessText);
119
48
 
120
- const getClasses = (_) => classNames("control");
121
- const ToggletipTemplate = (context) => {
122
- const popup = context.tagFor(Popup);
49
+ const getStateClasses = ({
50
+ errorValidationMessage,
51
+ disabled,
52
+ value,
53
+ readOnly,
54
+ placeholder,
55
+ appearance,
56
+ shape,
57
+ label,
58
+ successText,
59
+ actionItemsSlottedContent,
60
+ leadingActionItemsSlottedContent,
61
+ icon
62
+ }) => classNames(
63
+ ["error connotation-alert", Boolean(errorValidationMessage)],
64
+ ["disabled", disabled],
65
+ ["has-value", Boolean(value)],
66
+ ["readonly", readOnly],
67
+ ["placeholder", Boolean(placeholder)],
68
+ [`appearance-${appearance}`, Boolean(appearance)],
69
+ [`shape-${shape}`, Boolean(shape)],
70
+ ["no-label", !label],
71
+ ["has-icon", !!icon],
72
+ ["success connotation-success", Boolean(successText)],
73
+ ["action-items", !!actionItemsSlottedContent?.length],
74
+ ["leading-action-items", !!leadingActionItemsSlottedContent?.length],
75
+ ["no-leading", !(leadingActionItemsSlottedContent?.length || icon)]
76
+ );
77
+ function renderLabel() {
123
78
  return html`
124
- <${popup}
125
- class="${getClasses}"
126
- arrow
127
- :anchor="${(x) => x.anchor}"
128
- :open="${(x) => x.open}"
129
- ?alternate="${(x) => !x.alternate}"
130
- placement="${(x) => x.placement}"
131
- exportparts="vvd-theme-alternate"
132
- >
133
- <div class="content-wrapper">
134
- ${when((x) => x.headline, html`<header class="headline">${(x) => x.headline}</header>`)}
135
- <slot></slot>
136
- <footer class="action-items"><slot name="action-items"></slot></footer>
137
- </div>
138
- </${popup}>
79
+ <label for="control" class="label">
80
+ ${(x) => x.label}
81
+ </label>`;
82
+ }
83
+ function renderCharCount() {
84
+ return html`
85
+ <span class="char-count">${(x) => x.value ? x.value.length : 0} / ${(x) => x.maxlength}</span>
139
86
  `;
87
+ }
88
+ const TextfieldTemplate = (context) => {
89
+ const affixIconTemplate = affixIconTemplateFactory(context);
90
+ const focusTemplate = focusTemplateFactory(context);
91
+ return html`
92
+ <div class="base ${getStateClasses}">
93
+ ${when((x) => x.charCount && x.maxlength, renderCharCount())}
94
+ ${when((x) => x.label, renderLabel())}
95
+ <div class="fieldset">
96
+ <div class="leading-items-wrapper">
97
+ <slot name="leading-action-items" ${slotted("leadingActionItemsSlottedContent")}></slot>
98
+ ${(x) => affixIconTemplate(x.icon)}
99
+ </div>
100
+
101
+ <div class="wrapper">
102
+ <input class="control"
103
+ id="control"
104
+ @input="${(x) => x.handleTextInput()}"
105
+ @change="${(x) => x.handleChange()}"
106
+ ?autofocus="${(x) => x.autofocus}"
107
+ ?disabled="${(x) => x.disabled}"
108
+ list="${(x) => x.list}"
109
+ maxlength="${(x) => x.maxlength}"
110
+ minlength="${(x) => x.minlength}"
111
+ pattern="${(x) => x.pattern}"
112
+ placeholder="${(x) => x.placeholder}"
113
+ ?readonly="${(x) => x.readOnly}"
114
+ ?required="${(x) => x.required}"
115
+ size="${(x) => x.size}"
116
+ autocomplete="${(x) => x.autoComplete}"
117
+ name="${(x) => x.name}"
118
+ ?spellcheck="${(x) => x.spellcheck}"
119
+ :value="${(x) => x.value}"
120
+ type="${(x) => x.type}"
121
+ aria-atomic="${(x) => x.ariaAtomic}"
122
+ aria-busy="${(x) => x.ariaBusy}"
123
+ aria-controls="${(x) => x.ariaControls}"
124
+ aria-current="${(x) => x.ariaCurrent}"
125
+ aria-describedby="${(x) => x.ariaDescribedby}"
126
+ aria-details="${(x) => x.ariaDetails}"
127
+ aria-disabled="${(x) => x.ariaDisabled}"
128
+ aria-errormessage="${(x) => x.ariaErrormessage}"
129
+ aria-flowto="${(x) => x.ariaFlowto}"
130
+ aria-haspopup="${(x) => x.ariaHaspopup}"
131
+ aria-hidden="${(x) => x.ariaHidden}"
132
+ aria-invalid="${(x) => x.ariaInvalid}"
133
+ aria-keyshortcuts="${(x) => x.ariaKeyshortcuts}"
134
+ aria-label="${(x) => x.ariaLabel}"
135
+ aria-labelledby="${(x) => x.ariaLabelledby}"
136
+ aria-live="${(x) => x.ariaLive}"
137
+ aria-owns="${(x) => x.ariaOwns}"
138
+ aria-relevant="${(x) => x.ariaRelevant}"
139
+ aria-roledescription="${(x) => x.ariaRoledescription}"
140
+ ${ref("control")}
141
+ />
142
+ ${() => focusTemplate}
143
+ </div>
144
+ <div class="action-items-wrapper">
145
+ <slot name="action-items" ${slotted("actionItemsSlottedContent")}></slot>
146
+ </div>
147
+
148
+ </div>
149
+ ${when((x) => !x.successText && !x.errorValidationMessage && x.helperText?.length, getFeedbackTemplate("helper", context))}
150
+ ${when((x) => !x.successText && x.errorValidationMessage, getFeedbackTemplate("error", context))}
151
+ ${when((x) => x.successText, getFeedbackTemplate("success", context))}
152
+ </div>`;
140
153
  };
141
154
 
142
- const toggletipDefinition = Toggletip.compose({
143
- baseName: "toggletip",
144
- template: ToggletipTemplate,
145
- styles
155
+ const textFieldDefinition = TextField.compose({
156
+ baseName: "text-field",
157
+ template: TextfieldTemplate,
158
+ styles,
159
+ shadowOptions: {
160
+ delegatesFocus: true
161
+ }
146
162
  });
147
- const toggletipRegistries = [toggletipDefinition(), ...popupRegistries];
148
- const registerToggletip = registerFactory(toggletipRegistries);
163
+ const textFieldRegistries = [textFieldDefinition(), ...iconRegistries, ...focusRegistries];
164
+ const registerTextField = registerFactory(textFieldRegistries);
149
165
 
150
- export { toggletipRegistries as a, registerToggletip as r, toggletipDefinition as t };
166
+ export { TextField as T, textFieldRegistries as a, registerTextField as r, textFieldDefinition as t };
@@ -1,8 +1,9 @@
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 './definition57.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 './definition58.js';
3
+ import { w as when } from './when.js';
3
4
  import { c as classNames } from './class-names.js';
4
5
 
5
- const styles = "/**\n * Do not edit directly\n * Generated on Tue, 26 Sep 2023 13:00:58 GMT\n */\n.control {\n pointer-events: none;\n}\n\n.tooltip {\n width: var(--tooltip-inline-size, auto);\n}\n.tooltip-text {\n padding: 8px 12px;\n color: var(--vvd-color-canvas-text);\n font: var(--vvd-typography-base-bold);\n}";
6
+ const styles = "/**\n * Do not edit directly\n * Generated on Tue, 17 Oct 2023 15:27:52 GMT\n */\n.control {\n display: inline-block;\n}\n\n.content-wrapper {\n width: var(--toggletip-inline-size, auto);\n padding: 16px;\n}\n\n.headline {\n font: var(--vvd-typography-base-bold);\n}\n\n.action-items {\n display: flex;\n justify-content: flex-end;\n gap: 10px;\n}\n\n::slotted([slot=action-items]) {\n margin-block-start: 16px;\n}";
6
7
 
7
8
  var __defProp = Object.defineProperty;
8
9
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -15,126 +16,135 @@ var __decorateClass = (decorators, target, key, kind) => {
15
16
  __defProp(target, key, result);
16
17
  return result;
17
18
  };
18
- class Tooltip extends FoundationElement {
19
+ class Toggletip extends FoundationElement {
19
20
  constructor() {
20
21
  super(...arguments);
21
22
  this.#anchorEl = null;
22
- this.open = false;
23
23
  this.#observeMissingAnchor = (anchorId) => {
24
24
  this.#observer = new MutationObserver(() => {
25
25
  const anchor = document.getElementById(anchorId);
26
26
  if (anchor) {
27
27
  this.#anchorEl = anchor;
28
- this.#anchorUpdated();
28
+ this.#setupAnchor(this.#anchorEl);
29
29
  this.#observer.disconnect();
30
30
  this.#observer = void 0;
31
31
  }
32
32
  });
33
33
  this.#observer.observe(document.body, { childList: true, subtree: true });
34
34
  };
35
- this.#show = () => {
36
- this.open = true;
35
+ this.#ANCHOR_ARIA_LABEL_SUFFIX = " ; Show more information";
36
+ this.alternate = false;
37
+ this.placement = "right";
38
+ this.anchor = "";
39
+ this.open = false;
40
+ this.#openIfClosed = () => {
41
+ if (!this.open)
42
+ DOM.queueUpdate(() => this.open = true);
37
43
  };
38
- this.#hide = () => {
39
- this.open = false;
44
+ this.#closeOnClickOutside = (e) => {
45
+ if (!this.contains(e.target))
46
+ this.open = false;
40
47
  };
41
48
  this.#closeOnEscape = (e) => {
42
49
  if (e.key === "Escape")
43
- this.#hide();
50
+ this.open = false;
44
51
  };
45
52
  }
46
- #anchorEl;
47
53
  #observer;
54
+ #anchorEl;
55
+ #observeMissingAnchor;
56
+ #ANCHOR_ARIA_LABEL_SUFFIX;
48
57
  anchorChanged(_, newValue) {
49
58
  if (this.#anchorEl)
50
- this.#removeEventListener();
59
+ this.#cleanupAnchor(this.#anchorEl);
51
60
  this.#observer?.disconnect();
52
61
  this.#anchorEl = newValue instanceof HTMLElement ? newValue : document.getElementById(newValue);
53
62
  if (this.#anchorEl) {
54
- this.#anchorUpdated();
63
+ this.#setupAnchor(this.#anchorEl);
55
64
  } else {
56
65
  this.#observeMissingAnchor(newValue);
57
66
  }
58
67
  }
59
- #observeMissingAnchor;
68
+ openChanged(oldValue, newValue) {
69
+ if (oldValue === void 0)
70
+ return;
71
+ if (newValue) {
72
+ document.addEventListener("click", this.#closeOnClickOutside);
73
+ document.addEventListener("keydown", this.#closeOnEscape);
74
+ this.setAttribute("role", "status");
75
+ } else {
76
+ document.removeEventListener("click", this.#closeOnClickOutside);
77
+ document.removeEventListener("keydown", this.#closeOnEscape);
78
+ this.removeAttribute("role");
79
+ }
80
+ if (this.#anchorEl) {
81
+ this.#anchorEl.ariaExpanded = this.open.toString();
82
+ }
83
+ }
60
84
  disconnectedCallback() {
61
85
  super.disconnectedCallback();
62
- this.#removeEventListener();
86
+ if (this.#anchorEl)
87
+ this.#cleanupAnchor(this.#anchorEl);
63
88
  this.#observer?.disconnect();
64
89
  document.removeEventListener("keydown", this.#closeOnEscape);
65
90
  }
66
- #anchorUpdated() {
67
- this.#removeEventListener();
68
- this.#addEventListener();
91
+ #setupAnchor(a) {
92
+ a.addEventListener("click", this.#openIfClosed, true);
93
+ a.ariaLabel = (a.ariaLabel ?? "") + this.#ANCHOR_ARIA_LABEL_SUFFIX;
69
94
  }
70
- #addEventListener() {
71
- if (this.#anchorEl) {
72
- this.#anchorEl.addEventListener("mouseover", this.#show);
73
- this.#anchorEl.addEventListener("mouseout", this.#hide);
74
- this.#anchorEl.addEventListener("focusin", this.#show);
75
- this.#anchorEl.addEventListener("focusout", this.#hide);
76
- }
95
+ #cleanupAnchor(a) {
96
+ a.removeEventListener("click", this.#openIfClosed, true);
97
+ if (a.ariaLabel)
98
+ a.ariaLabel = a.ariaLabel.replace(this.#ANCHOR_ARIA_LABEL_SUFFIX, "");
77
99
  }
78
- #removeEventListener() {
79
- this.#anchorEl?.removeEventListener("mouseover", this.#show);
80
- this.#anchorEl?.removeEventListener("mouseout", this.#hide);
81
- this.#anchorEl?.removeEventListener("focusin", this.#show);
82
- this.#anchorEl?.removeEventListener("focusout", this.#hide);
83
- }
84
- #show;
85
- #hide;
100
+ #openIfClosed;
101
+ #closeOnClickOutside;
86
102
  #closeOnEscape;
87
- openChanged(_, newValue) {
88
- if (_ === void 0)
89
- return;
90
- if (newValue) {
91
- document.addEventListener("keydown", this.#closeOnEscape);
92
- } else {
93
- document.removeEventListener("keydown", this.#closeOnEscape);
94
- }
95
- }
96
103
  }
97
104
  __decorateClass([
98
105
  attr
99
- ], Tooltip.prototype, "text", 2);
100
- __decorateClass([
101
- attr({ mode: "fromView" })
102
- ], Tooltip.prototype, "placement", 2);
106
+ ], Toggletip.prototype, "headline", 2);
103
107
  __decorateClass([
104
108
  attr({ mode: "boolean" })
105
- ], Tooltip.prototype, "open", 2);
109
+ ], Toggletip.prototype, "alternate", 2);
106
110
  __decorateClass([
107
111
  attr({ mode: "fromView" })
108
- ], Tooltip.prototype, "anchor", 2);
112
+ ], Toggletip.prototype, "placement", 2);
113
+ __decorateClass([
114
+ attr({ mode: "fromView" })
115
+ ], Toggletip.prototype, "anchor", 2);
116
+ __decorateClass([
117
+ attr({ mode: "boolean" })
118
+ ], Toggletip.prototype, "open", 2);
109
119
 
110
- const getClasses = ({
111
- open
112
- }) => classNames(
113
- "control",
114
- ["open", Boolean(open)]
115
- );
116
- const TooltipTemplate = (context) => {
117
- const popupTag = context.tagFor(Popup);
120
+ const getClasses = (_) => classNames("control");
121
+ const ToggletipTemplate = (context) => {
122
+ const popup = context.tagFor(Popup);
118
123
  return html`
119
- <${popupTag} class="${getClasses}" arrow alternate
120
- :placement=${(x) => x.placement}
121
- :anchor="${(x) => x.anchor}"
122
- :open=${(x) => x.open}
123
- exportparts="vvd-theme-alternate">
124
- <div class="tooltip" role="tooltip">
125
- <header part="vvd-theme-alternate" class="tooltip-header">
126
- <div class="tooltip-text">${(x) => x.text}</div>
127
- </header>
128
- </div>
129
- </${popupTag}>`;
124
+ <${popup}
125
+ class="${getClasses}"
126
+ arrow
127
+ :anchor="${(x) => x.anchor}"
128
+ :open="${(x) => x.open}"
129
+ ?alternate="${(x) => !x.alternate}"
130
+ placement="${(x) => x.placement}"
131
+ exportparts="vvd-theme-alternate"
132
+ >
133
+ <div class="content-wrapper">
134
+ ${when((x) => x.headline, html`<header class="headline">${(x) => x.headline}</header>`)}
135
+ <slot></slot>
136
+ <footer class="action-items"><slot name="action-items"></slot></footer>
137
+ </div>
138
+ </${popup}>
139
+ `;
130
140
  };
131
141
 
132
- const tooltipDefinition = Tooltip.compose({
133
- baseName: "tooltip",
134
- template: TooltipTemplate,
142
+ const toggletipDefinition = Toggletip.compose({
143
+ baseName: "toggletip",
144
+ template: ToggletipTemplate,
135
145
  styles
136
146
  });
137
- const tooltipRegistries = [tooltipDefinition(), ...popupRegistries];
138
- const registerTooltip = registerFactory(tooltipRegistries);
147
+ const toggletipRegistries = [toggletipDefinition(), ...popupRegistries];
148
+ const registerToggletip = registerFactory(toggletipRegistries);
139
149
 
140
- export { tooltipRegistries as a, registerTooltip as r, tooltipDefinition as t };
150
+ export { toggletipRegistries as a, registerToggletip as r, toggletipDefinition as t };